Commit 1a2259d4 by Marcus Winter Committed by unknown

mtapi_opencl_c: linux support, test cleanup

parent b4d1dd0e
......@@ -13,7 +13,11 @@ FOREACH(src_tmp ${EMBB_MTAPI_OPENCL_C_SOURCES})
SET_PROPERTY(SOURCE ${src_tmp} PROPERTY LANGUAGE CXX)
ENDFOREACH(src_tmp)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC)
set (EMBB_MAPI_OPENCL_LIBS dl)
ENDIF()
# Execute the GroupSources macro
include(${CMAKE_SOURCE_DIR}/CMakeCommon/GroupSourcesMSVC.cmake)
GroupSourcesMSVC(include)
......@@ -34,7 +38,7 @@ target_link_libraries(embb_mtapi_opencl_c embb_mtapi_c embb_base_c)
if (BUILD_TESTS STREQUAL ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include)
add_executable (embb_mtapi_opencl_c_test ${EMBB_MTAPI_OPENCL_TEST_SOURCES})
target_link_libraries(embb_mtapi_opencl_c_test embb_mtapi_opencl_c embb_mtapi_c partest embb_base_c ${compiler_libs})
target_link_libraries(embb_mtapi_opencl_c_test embb_mtapi_opencl_c embb_mtapi_c partest embb_base_c ${compiler_libs} ${EMBB_MAPI_OPENCL_LIBS})
CopyBin(BIN embb_mtapi_c_test DEST ${local_install_dir})
endif()
......
......@@ -166,14 +166,26 @@ DECLARECLFUNC(cl_mem, clCreateFromGLBuffer, (cl_context context, cl_mem_flags fl
//////////////////////////////////////////////////////////////////////////
// system specific functions
//---- Windows Functions -------------------------------------------------
#ifdef _WIN32
#include <Windows.h>
#define CHECKEDIMPORT(name) name##_Dynamic = (name##Proc)GetProcAddress( opencl_dll_handle, #name ); if ( name##_Dynamic == 0 ) return 0;
#else
#include <dlfcn.h>
#define CHECKEDIMPORT(name) name##_Dynamic = (name##Proc)dlsym( opencl_dll_handle, #name ); if ( name##_Dynamic == 0 ) return 0;
#endif
int embb_mtapi_opencl_link_at_runtime() {
#ifdef _WIN32
HMODULE opencl_dll_handle = LoadLibraryA("opencl.dll");
#else
void * opencl_dll_handle = dlopen("libOpenCL.so", RTLD_LAZY);
#endif
if (opencl_dll_handle == 0)
return 0;
......
......@@ -31,6 +31,10 @@
#define MTAPI_CHECK_STATUS(status) \
PT_ASSERT(MTAPI_SUCCESS == status)
#define OPENCL_DOMAIN 1
#define OPENCL_NODE 2
#define OPENCL_JOB 2
// OpenCL Kernel Function for element by element vector addition
const char * kernel =
"__kernel void test(\n"
......@@ -74,8 +78,8 @@ void TaskTest::TestBasic() {
MTAPI_CHECK_STATUS(status);
mtapi_initialize(
1,
1,
OPENCL_DOMAIN,
OPENCL_NODE,
MTAPI_NULL,
MTAPI_NULL,
&status);
......@@ -83,14 +87,14 @@ void TaskTest::TestBasic() {
float node_local = 1.0f;
action = mtapi_opencl_action_create(
1,
OPENCL_JOB,
kernel, "test", 32, 4,
&node_local, sizeof(float),
&status);
MTAPI_CHECK_STATUS(status);
status = MTAPI_ERR_UNKNOWN;
job = mtapi_job_get(1, 1, &status);
job = mtapi_job_get(OPENCL_JOB, OPENCL_DOMAIN, &status);
MTAPI_CHECK_STATUS(status);
task = mtapi_task_start(
......@@ -111,4 +115,7 @@ void TaskTest::TestBasic() {
mtapi_finalize(&status);
MTAPI_CHECK_STATUS(status);
mtapi_opencl_plugin_finalize(&status);
MTAPI_CHECK_STATUS(status);
}
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