From c6e73fd8597c436200c51f0d42bbd285cc5766ee Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 07:13:33 -0500 Subject: [PATCH 1/7] Remove build/skip --- conda-recipe/meta.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index cb8da56f06..76ebc2d691 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -9,7 +9,6 @@ source: build: number: 0 - skip: True # [not linux] script_env: - ONEAPI_ROOT From 55b30ec2d109b1e0c7da4ba5fb524a3c51c78c9e Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 07:21:12 -0500 Subject: [PATCH 2/7] Add bld.bat --- conda-recipe/bld.bat | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 conda-recipe/bld.bat diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat new file mode 100644 index 0000000000..f25d5be87b --- /dev/null +++ b/conda-recipe/bld.bat @@ -0,0 +1,35 @@ +call "%ONEAPI_ROOT%compiler\latest\env\vars.bat" +set "CC=dpcpp-cl.exe" +set "CXX=dpcpp-cl.exe" + +rmdir /S /Q build_cmake +mkdir build_cmake +cd build_cmake + +set "DPCPP_ROOT=%ONEAPI_ROOT%/compiler/latest/windows" + +cmake -G Ninja ^ + -DCMAKE_BUILD_TYPE=Release ^ + "-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX%" ^ + "-DCMAKE_PREFIX_PATH=%INSTALL_PREFIX%" ^ + "-DDPCPP_ROOT=%DPCPP_ROOT%" ^ + "%SRC_DIR%/oneapi_wrapper" +IF %ERRORLEVEL% NEQ 0 exit 1 + +ninja -n +ninja install +IF %ERRORLEVEL% NEQ 0 exit 1 + +cd .. + +REM required by dpglue +set "DP_GLUE_LIBDIR=%LIBRARY_PREFIX%/lib" +set "DP_GLUE_INCLDIR=%LIBRARY_PREFIX%/include" +set "OpenCL_LIBDIR=%DPCPP_ROOT%/lib" +REM required by oneapi_interface +set "DPPL_ONEAPI_INTERFACE_LIBDIR=%LIBRARY_PREFIX%/lib" +set "DPPL_ONEAPI_INTERFACE_INCLDIR=%LIBRARY_PREFIX%/include" + +"%PYTHON%" setup.py build +"%PYTHON%" setup.py install +IF %ERRORLEVEL% NEQ 0 exit 1 From ac0a3e9190db230f145e710be20386fdb3086760 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 09:40:23 -0500 Subject: [PATCH 3/7] Fix OpenCL.lib path --- oneapi_wrapper/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oneapi_wrapper/CMakeLists.txt b/oneapi_wrapper/CMakeLists.txt index c39431783b..5d9106d709 100644 --- a/oneapi_wrapper/CMakeLists.txt +++ b/oneapi_wrapper/CMakeLists.txt @@ -150,7 +150,7 @@ if(WIN32) target_link_libraries( DPPLOpenCLInterface PRIVATE - ${OpenCL_INCLUDE_DIR}/../lib/x64/OpenCL.lib + ${DPCPP_ROOT}/lib/OpenCL.lib ) endif() From 4d3d4451c17db6470674f1ec94555c19e7cda4cc Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 13:45:43 -0500 Subject: [PATCH 4/7] Fix runtime_library_dirs --- setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2cf3305409..bb178eca98 100644 --- a/setup.py +++ b/setup.py @@ -99,6 +99,11 @@ def getpyexts(): elif IS_MAC: librarys = [dppl_oneapi_interface_lib] + if IS_LIN or IS_MAC: + runtime_library_dirs = [os.path.abspath('dppl')] + elif IS_WIN: + runtime_library_dirs = [] + exts = cythonize(Extension('dppl._oneapi_interface', [os.path.abspath('dppl/oneapi_interface.pyx'),], depends=[dppl_oneapi_interface_include,], @@ -108,7 +113,7 @@ def getpyexts(): extra_link_args=ela, libraries=libs, library_dirs=librarys, - runtime_library_dirs=[os.path.abspath('dppl')], + runtime_library_dirs=runtime_library_dirs, language='c++')) return exts From a7c99e11bf4bbfaa1504d547d6d73b6696ec84da Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 13:54:58 -0500 Subject: [PATCH 5/7] Add DPPL_API to dppl_oneapi_interface.hppdppl_oneapi_interface.hpp --- .../include/dppl_oneapi_interface.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/oneapi_wrapper/include/dppl_oneapi_interface.hpp b/oneapi_wrapper/include/dppl_oneapi_interface.hpp index 27d8dad3c7..94ca7434ee 100644 --- a/oneapi_wrapper/include/dppl_oneapi_interface.hpp +++ b/oneapi_wrapper/include/dppl_oneapi_interface.hpp @@ -29,6 +29,16 @@ #include #include +#ifdef _WIN32 +# ifdef DPPLOneapiInterface_EXPORTS +# define DPPL_API __declspec(dllexport) +# else +# define DPPL_API __declspec(dllimport) +# endif +#elif +# define DPPL_API +#endif + namespace dppl { @@ -59,26 +69,35 @@ enum class sycl_device_type : unsigned int class DpplOneAPIRuntime { public: + DPPL_API int64_t getNumPlatforms (size_t *platforms) const; + DPPL_API int64_t getCurrentQueue (void **Q) const; + DPPL_API int64_t getQueue (void **Q, dppl::sycl_device_type DeviceTy, size_t DNum = 0) const; + DPPL_API int64_t resetGlobalQueue (dppl::sycl_device_type DeviceTy, size_t DNum = 0); /*! * Push a new sycl queue to the top of the activate_queues deque. The * newly activated queue is returned to caller inside the Q object. */ + DPPL_API int64_t activateQueue (void **Q, dppl::sycl_device_type DeviceTy, size_t DNum); + DPPL_API int64_t deactivateCurrentQueue (); + DPPL_API int64_t dump () const; + DPPL_API int64_t dump_queue (const void *Q) const; }; +DPPL_API int64_t deleteQueue (void *Q); } /* end of namespace dppl */ From f769ca156b5eb052e395abf5215833592bfcca6d Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 13:57:07 -0500 Subject: [PATCH 6/7] Add DPPL_API to dppl_opencl_interface.h --- .../include/dppl_opencl_interface.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/oneapi_wrapper/include/dppl_opencl_interface.h b/oneapi_wrapper/include/dppl_opencl_interface.h index 8adb882028..b95acc0468 100644 --- a/oneapi_wrapper/include/dppl_opencl_interface.h +++ b/oneapi_wrapper/include/dppl_opencl_interface.h @@ -29,6 +29,18 @@ #include #include + +#ifdef _WIN32 +# ifdef DPPLOpenCLInterface_EXPORTS +# define DPPL_API __declspec(dllexport) +# else +# define DPPL_API __declspec(dllimport) +# endif +#elif +# define DPPL_API +#endif + + enum DP_GLUE_ERROR_CODES { DP_GLUE_SUCCESS = 0, @@ -122,6 +134,7 @@ struct dp_runtime typedef struct dp_runtime* runtime_t; +DPPL_API int set_curr_env (runtime_t rt, env_t env); /*! @@ -133,6 +146,7 @@ int set_curr_env (runtime_t rt, env_t env); * @return An error code indicating if the runtime_t object was successfully * initialized. */ +DPPL_API int create_dp_runtime (runtime_t *rt); @@ -143,21 +157,25 @@ int create_dp_runtime (runtime_t *rt); * * @return An error code indicating if resource freeing was successful. */ +DPPL_API int destroy_dp_runtime (runtime_t *rt); /*! * */ +DPPL_API int create_dp_rw_mem_buffer (env_t env_t_ptr, size_t buffsize, buffer_t *buff); +DPPL_API int destroy_dp_rw_mem_buffer (buffer_t *buff); /*! * */ +DPPL_API int write_dp_mem_buffer_to_device (env_t env_t_ptr, buffer_t buff, bool blocking_copy, @@ -169,6 +187,7 @@ int write_dp_mem_buffer_to_device (env_t env_t_ptr, /*! * */ +DPPL_API int read_dp_mem_buffer_from_device (env_t env_t_ptr, buffer_t buff, bool blocking_copy, @@ -180,6 +199,7 @@ int read_dp_mem_buffer_from_device (env_t env_t_ptr, /*! * */ +DPPL_API int create_dp_program_from_spirv (env_t env_t_ptr, const void *il, size_t length, @@ -189,6 +209,7 @@ int create_dp_program_from_spirv (env_t env_t_ptr, /*! * */ +DPPL_API int create_dp_program_from_source (env_t env_t_ptr, unsigned int count, const char **strings, @@ -198,26 +219,31 @@ int create_dp_program_from_source (env_t env_t_ptr, /*! * */ +DPPL_API int destroy_dp_program (program_t *program_t_ptr); +DPPL_API int build_dp_program (env_t env_t_ptr, program_t program_t_ptr); /*! * */ +DPPL_API int create_dp_kernel (env_t env_t_ptr, program_t program_ptr, const char *kernel_name, kernel_t *kernel_ptr); +DPPL_API int destroy_dp_kernel (kernel_t *kernel_ptr); /*! * */ +DPPL_API int create_dp_kernel_arg (const void *arg_value, size_t arg_size, kernel_arg_t *kernel_arg_t_ptr); @@ -226,6 +252,7 @@ int create_dp_kernel_arg (const void *arg_value, /*! * */ +DPPL_API int create_dp_kernel_arg_from_buffer (buffer_t *buffer_t_ptr, kernel_arg_t *kernel_arg_t_ptr); @@ -233,12 +260,14 @@ int create_dp_kernel_arg_from_buffer (buffer_t *buffer_t_ptr, /*! * */ +DPPL_API int destroy_dp_kernel_arg (kernel_arg_t *kernel_arg_t_ptr); /*! * */ +DPPL_API int set_args_and_enqueue_dp_kernel (env_t env_t_ptr, kernel_t kernel_t_ptr, size_t nargs, @@ -252,6 +281,7 @@ int set_args_and_enqueue_dp_kernel (env_t env_t_ptr, /*! * */ +DPPL_API int set_args_and_enqueue_dp_kernel_auto_blocking (env_t env_t_ptr, kernel_t kernel_t_ptr, size_t nargs, @@ -264,12 +294,14 @@ int set_args_and_enqueue_dp_kernel_auto_blocking (env_t env_t_ptr, /*! * */ +DPPL_API int retain_dp_context (env_t env_t_ptr); /*! * */ +DPPL_API int release_dp_context (env_t env_t_ptr); From addcd2cee330b6397dbad99eb8747b22aca5deb8 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Mon, 10 Aug 2020 14:00:57 -0500 Subject: [PATCH 7/7] Remove DPPL_API from dppl_opencl_interface.h for CFFI --- dppl/driverapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dppl/driverapi.py b/dppl/driverapi.py index e0bf7c0d12..6e38c9e1aa 100644 --- a/dppl/driverapi.py +++ b/dppl/driverapi.py @@ -49,7 +49,7 @@ glue_h = ''.join(list(filter(lambda x: len(x) > 0 and x[0] != "#", open(dpglue_incldir + '/dppl_opencl_interface.h', 'r') - .readlines()))) + .readlines()))).replace('DPPL_API', '') # cdef() expects a single string declaring the C types, functions and # globals needed to use the shared object. It must be in valid C syntax.