Android: restored compatibility
This commit is contained in:
@@ -25,8 +25,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
#Binary to convert .cu files to const char *
|
#Binary to convert .cu files to const char *
|
||||||
add_executable(bin2cpp ${CMAKE_MODULE_PATH}/helpers/bin2cpp.cpp)
|
if(NOT ANDROID)
|
||||||
include("${CMAKE_MODULE_PATH}/helpers/CodeToH.cmake")
|
add_executable(bin2cpp ${CMAKE_MODULE_PATH}/helpers/bin2cpp.cpp)
|
||||||
|
include("${CMAKE_MODULE_PATH}/helpers/CodeToH.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
#Source files
|
#Source files
|
||||||
file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp)
|
file(GLOB_RECURSE LIBISAAC_SRC lib/*.cpp)
|
||||||
|
@@ -13,6 +13,7 @@ if(ANDROID)
|
|||||||
file(GLOB _TMP ${PATH})
|
file(GLOB _TMP ${PATH})
|
||||||
set(L_HINTS ${L_HINTS} ${_TMP})
|
set(L_HINTS ${L_HINTS} ${_TMP})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
find_library(OPENCL_LIBRARIES NAMES OpenCL NO_CMAKE_FIND_ROOT_PATH HINTS ${L_HINTS} )
|
||||||
else()
|
else()
|
||||||
set(X86_CL_GLOB_HINTS /opt/AMDAPPSDK*/lib/x86_64)
|
set(X86_CL_GLOB_HINTS /opt/AMDAPPSDK*/lib/x86_64)
|
||||||
foreach(PATH ${X86_CL_GLOB_HINTS})
|
foreach(PATH ${X86_CL_GLOB_HINTS})
|
||||||
@@ -20,9 +21,9 @@ else()
|
|||||||
set(L_HINTS ${L_HINTS} ${_TMP})
|
set(L_HINTS ${L_HINTS} ${_TMP})
|
||||||
endforeach()
|
endforeach()
|
||||||
set(L_HINTS ${L_HINTS} ${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/lib/)
|
set(L_HINTS ${L_HINTS} ${CUDA_TOOLKIT_ROOT_DIR}/targets/x86_64-linux/lib/)
|
||||||
|
find_library(OPENCL_LIBRARIES NAMES OpenCL HINTS ${L_HINTS} )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(OPENCL_LIBRARIES NAMES OpenCL HINTS ${L_HINTS} )
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(OpenCL DEFAULT_MSG OPENCL_LIBRARIES)
|
find_package_handle_standard_args(OpenCL DEFAULT_MSG OPENCL_LIBRARIES)
|
||||||
mark_as_advanced(OpenCL)
|
mark_as_advanced(OpenCL)
|
||||||
|
1
cmake/android/example.sh
Normal file
1
cmake/android/example.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/android.cmake -DANDROID_NDK=/opt/android-ndk-r10d/ -DANDROID_ABI=armeabi-v7a with NEON -DANDROID_NATIVE_API_LEVEL=19 -DANDROID_APK_API_LEVEL=19 -DANDROID_APK_RUN=1 ../
|
@@ -1,8 +1,10 @@
|
|||||||
#Database
|
if(NOT ANDROID)
|
||||||
set(DATABASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/profiles/presets/")
|
#Presets
|
||||||
file(GLOB_RECURSE JSON_FILES "${DATABASE_PATH}/json/*.json")
|
set(DATABASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/profiles/presets/")
|
||||||
CODE_TO_H(SOURCES ${JSON_FILES} VARNAME json_files EXTENSION "hpp" OUTPUT_DIR "${DATABASE_PATH}"
|
file(GLOB_RECURSE JSON_FILES "${DATABASE_PATH}/json/*.json")
|
||||||
NAMESPACE "isaac presets" TARGET database EOF "1")
|
CODE_TO_H(SOURCES ${JSON_FILES} VARNAME json_files EXTENSION "hpp" OUTPUT_DIR "${DATABASE_PATH}"
|
||||||
|
NAMESPACE "isaac presets" TARGET database EOF "1")
|
||||||
|
endif()
|
||||||
|
|
||||||
#Compilation
|
#Compilation
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
2
lib/external/to_string.hpp
vendored
2
lib/external/to_string.hpp
vendored
@@ -13,7 +13,7 @@ template<class T>
|
|||||||
inline std::string to_string ( T const t )
|
inline std::string to_string ( T const t )
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#if defined(ANDROID) || defined(__CYGWIN__)
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << t;
|
ss << t;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
4
python/setup.py
Executable file → Normal file
4
python/setup.py
Executable file → Normal file
@@ -61,7 +61,7 @@ def main():
|
|||||||
def find_opencl():
|
def find_opencl():
|
||||||
cvars = sysconfig.get_config_vars()
|
cvars = sysconfig.get_config_vars()
|
||||||
is_on_android = '-mandroid' in cvars['PY_CFLAGS']
|
is_on_android = '-mandroid' in cvars['PY_CFLAGS']
|
||||||
lib = find_library('OpenCL', '' if is_on_android else '/opt/AMDAPPSDK*/lib/x86_64')
|
lib = find_library('OpenCL', '/opt/adreno-driver/lib' if is_on_android else '/opt/AMDAPPSDK*/lib/x86_64')
|
||||||
return {'include': '', 'lib': dirname(lib)} if lib else None
|
return {'include': '', 'lib': dirname(lib)} if lib else None
|
||||||
|
|
||||||
def find_in_path(name, path):
|
def find_in_path(name, path):
|
||||||
@@ -115,7 +115,7 @@ def main():
|
|||||||
include =' src/include src/lib/external'.split() + ['external/boost/', 'external/boost/boost/', os.path.join(find_module("numpy")[1], "core", "include")]
|
include =' src/include src/lib/external'.split() + ['external/boost/', 'external/boost/boost/', os.path.join(find_module("numpy")[1], "core", "include")]
|
||||||
|
|
||||||
#Source files
|
#Source files
|
||||||
src = 'src/lib/wrap/clBLAS.cpp src/lib/value_scalar.cpp src/lib/symbolic/preset.cpp src/lib/symbolic/io.cpp src/lib/symbolic/expression.cpp src/lib/symbolic/execute.cpp src/lib/profiles/profiles.cpp src/lib/profiles/presets.cpp src/lib/profiles/predictors/random_forest.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/gemv.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/stream.cpp src/lib/kernels/parse.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.cpp src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/driver/program_cache.cpp src/lib/driver/program.cpp src/lib/driver/platform.cpp src/lib/driver/ndrange.cpp src/lib/driver/kernel.cpp src/lib/driver/handle.cpp src/lib/driver/event.cpp src/lib/driver/device.cpp src/lib/driver/context.cpp src/lib/driver/command_queue.cpp src/lib/driver/check.cpp src/lib/driver/buffer.cpp src/lib/driver/backend.cpp src/lib/array.cpp '.split() + [os.path.join('src', 'bind', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'kernels.cpp', 'exceptions.cpp']]
|
src = 'src/lib/symbolic/preset.cpp src/lib/symbolic/execute.cpp src/lib/symbolic/io.cpp src/lib/symbolic/expression.cpp src/lib/array.cpp src/lib/value_scalar.cpp src/lib/driver/backend.cpp src/lib/driver/device.cpp src/lib/driver/kernel.cpp src/lib/driver/buffer.cpp src/lib/driver/platform.cpp src/lib/driver/check.cpp src/lib/driver/program.cpp src/lib/driver/command_queue.cpp src/lib/driver/program_cache.cpp src/lib/driver/context.cpp src/lib/driver/event.cpp src/lib/driver/ndrange.cpp src/lib/driver/handle.cpp src/lib/exception/unknown_datatype.cpp src/lib/exception/operation_not_supported.cpp src/lib/profiles/presets.cpp src/lib/profiles/profiles.cpp src/lib/profiles/predictors/random_forest.cpp src/lib/kernels/templates/gemv.cpp src/lib/kernels/templates/axpy.cpp src/lib/kernels/templates/gemm.cpp src/lib/kernels/templates/ger.cpp src/lib/kernels/templates/dot.cpp src/lib/kernels/templates/base.cpp src/lib/kernels/mapped_object.cpp src/lib/kernels/stream.cpp src/lib/kernels/parse.cpp src/lib/kernels/keywords.cpp src/lib/kernels/binder.cpp src/lib/wrap/clBLAS.cpp '.split() + [os.path.join('src', 'bind', sf) for sf in ['_isaac.cpp', 'core.cpp', 'driver.cpp', 'kernels.cpp', 'exceptions.cpp']]
|
||||||
boostsrc = 'external/boost/libs/'
|
boostsrc = 'external/boost/libs/'
|
||||||
for s in ['numpy','python','smart_ptr','system','thread']:
|
for s in ['numpy','python','smart_ptr','system','thread']:
|
||||||
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
src = src + [x for x in recursive_glob('external/boost/libs/' + s + '/src/','.cpp') if 'win32' not in x and 'pthread' not in x]
|
||||||
|
@@ -2,14 +2,15 @@
|
|||||||
#include <android_native_app_glue.h>
|
#include <android_native_app_glue.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "isaac/array.h"
|
#include "isaac/array.h"
|
||||||
#include "isaac/tools/to_string.hpp"
|
|
||||||
|
|
||||||
void android_main(struct android_app* state)
|
void android_main(struct android_app* state)
|
||||||
{
|
{
|
||||||
app_dummy(); // Make sure glue isn't stripped
|
app_dummy(); // Make sure glue isn't stripped
|
||||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", "This is a test");
|
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", "This is a test");
|
||||||
isaac::array test(5, isaac::FLOAT_TYPE);
|
isaac::array test(5, isaac::FLOAT_TYPE);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", isaac::tools::to_string(test).c_str());
|
std::ostringstream oss;
|
||||||
|
oss << test;
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "IsaacAndroidTest", oss.str().c_str());
|
||||||
ANativeActivity_finish(state->activity);
|
ANativeActivity_finish(state->activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user