Commit fda063f7 by Winter Committed by Marcus Winter

removed dependency on installed OpenCL SDK, adapted test to succeed when OpenCL is unavailable

parent 7fe7875a
...@@ -53,12 +53,6 @@ if(POLICY CMP0053) ...@@ -53,12 +53,6 @@ if(POLICY CMP0053)
cmake_policy(SET CMP0053 OLD) cmake_policy(SET CMP0053 OLD)
endif(POLICY CMP0053) endif(POLICY CMP0053)
include(CMakeCommon/FindOpenCL.cmake)
IF(NOT OpenCL_FOUND)
MESSAGE( STATUS "OpenCL is not there, will build without MTAPI OpenCL Plugin." )
ENDIF()
# give the user the possibility, to append compiler flags # give the user the possibility, to append compiler flags
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CMAKE_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CMAKE_C_FLAGS}")
...@@ -88,6 +82,7 @@ option(USE_EXCEPTIONS "Specify whether exceptions should be activated in C++" ON ...@@ -88,6 +82,7 @@ option(USE_EXCEPTIONS "Specify whether exceptions should be activated in C++" ON
option(INSTALL_DOCS "Specify whether Doxygen docs should be installed" ON) option(INSTALL_DOCS "Specify whether Doxygen docs should be installed" ON)
option(WARNINGS_ARE_ERRORS "Specify whether warnings should be treated as errors" OFF) option(WARNINGS_ARE_ERRORS "Specify whether warnings should be treated as errors" OFF)
option(USE_AUTOMATIC_INITIALIZATION "Specify whether the MTAPI C++ interface, algorithms and dataflow should automatically intialize the MTAPI node if no explicit initialization is present" ON) option(USE_AUTOMATIC_INITIALIZATION "Specify whether the MTAPI C++ interface, algorithms and dataflow should automatically intialize the MTAPI node if no explicit initialization is present" ON)
option(BUILD_OPENCL_PLUGIN "Specify whether the MTAPI OpenCL plugin should be built" OFF)
## LOCAL INSTALLATION OF SUBPROJECT BINARIES ## LOCAL INSTALLATION OF SUBPROJECT BINARIES
# #
...@@ -146,7 +141,7 @@ set(EXPECTED_EMBB_TEST_EXECUTABLES "embb_algorithms_cpp_test" ...@@ -146,7 +141,7 @@ set(EXPECTED_EMBB_TEST_EXECUTABLES "embb_algorithms_cpp_test"
) )
# if opencl is there, we also expect the mtapi opencl test to be generated # if opencl is there, we also expect the mtapi opencl test to be generated
if(OpenCL_FOUND) if(BUILD_OPENCL_PLUGIN STREQUAL ON)
list(APPEND EXPECTED_EMBB_TEST_EXECUTABLES "embb_mtapi_opencl_c_test") list(APPEND EXPECTED_EMBB_TEST_EXECUTABLES "embb_mtapi_opencl_c_test")
endif() endif()
...@@ -182,7 +177,7 @@ add_subdirectory(base_c) ...@@ -182,7 +177,7 @@ add_subdirectory(base_c)
add_subdirectory(base_cpp) add_subdirectory(base_cpp)
add_subdirectory(mtapi_c) add_subdirectory(mtapi_c)
add_subdirectory(mtapi_network_c) add_subdirectory(mtapi_network_c)
if(OpenCL_FOUND) if(BUILD_OPENCL_PLUGIN STREQUAL ON)
add_subdirectory(mtapi_opencl_c) add_subdirectory(mtapi_opencl_c)
endif() endif()
add_subdirectory(tasks_cpp) add_subdirectory(tasks_cpp)
......
...@@ -21,7 +21,7 @@ include_directories( ...@@ -21,7 +21,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../dataflow_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../../dataflow_cpp/include
) )
if(OpenCL_FOUND) if(BUILD_OPENCL_PLUGIN STREQUAL ON)
# used in source code, to include opencl code # used in source code, to include opencl code
add_definitions(-DEMBB_WITH_OPENCL) add_definitions(-DEMBB_WITH_OPENCL)
# add opencl includes # add opencl includes
......
...@@ -259,7 +259,11 @@ void mtapi_opencl_plugin_initialize( ...@@ -259,7 +259,11 @@ void mtapi_opencl_plugin_initialize(
embb_mtapi_opencl_plugin_t * plugin = &embb_mtapi_opencl_plugin; embb_mtapi_opencl_plugin_t * plugin = &embb_mtapi_opencl_plugin;
err = embb_mtapi_opencl_link_at_runtime(); err = embb_mtapi_opencl_link_at_runtime();
if (err != 0) { if (err <= 0) {
// OpenCL not available, or wrong version
local_status = MTAPI_ERR_FUNC_NOT_IMPLEMENTED;
} else {
// all good, go ahead
err = clGetPlatformIDs(1, &plugin->platform_id, NULL); err = clGetPlatformIDs(1, &plugin->platform_id, NULL);
if (CL_SUCCESS == err) { if (CL_SUCCESS == err) {
err = clGetDeviceIDs(plugin->platform_id, CL_DEVICE_TYPE_DEFAULT, err = clGetDeviceIDs(plugin->platform_id, CL_DEVICE_TYPE_DEFAULT,
......
...@@ -263,7 +263,7 @@ int embb_mtapi_opencl_link_at_runtime() { ...@@ -263,7 +263,7 @@ int embb_mtapi_opencl_link_at_runtime() {
void * opencl_dll_handle = dlopen("libOpenCL.so", RTLD_LAZY); void * opencl_dll_handle = dlopen("libOpenCL.so", RTLD_LAZY);
#endif #endif
if (opencl_dll_handle == 0) if (opencl_dll_handle == 0)
return 0; return -1;
#ifdef EMBB_PLATFORM_COMPILER_MSVC #ifdef EMBB_PLATFORM_COMPILER_MSVC
#pragma warning(push) #pragma warning(push)
......
...@@ -34,5 +34,7 @@ LinkerTest::LinkerTest() { ...@@ -34,5 +34,7 @@ LinkerTest::LinkerTest() {
} }
void LinkerTest::TestBasic() { void LinkerTest::TestBasic() {
PT_EXPECT(embb_mtapi_opencl_link_at_runtime() != 0); int result = embb_mtapi_opencl_link_at_runtime();
bool success = result != 0;
PT_EXPECT(success);
} }
...@@ -75,6 +75,10 @@ void TaskTest::TestBasic() { ...@@ -75,6 +75,10 @@ void TaskTest::TestBasic() {
} }
mtapi_opencl_plugin_initialize(&status); mtapi_opencl_plugin_initialize(&status);
if (status == MTAPI_ERR_FUNC_NOT_IMPLEMENTED) {
// OpenCL unavailable
return;
}
MTAPI_CHECK_STATUS(status); MTAPI_CHECK_STATUS(status);
mtapi_initialize( mtapi_initialize(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment