Skip to content

Commit c8b14c0

Browse files
authored
Refactor oneapi wrapper v2 (#20)
* Update gitignore. * Refactor file names, scripts, etc. Drop the word oneapi in favor of sycl. * Fix compiler flag warning on windows and add line at end of file. * Update CMakeLists.txt
1 parent 154c64f commit c8b14c0

19 files changed

+102
-183
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ __pycache__/
1212

1313
# CMake build and local install directory
1414
build
15+
build_cmake
1516
install
1617

18+
# Eclipse project files
19+
.project
20+
.pydevproject
21+
1722
# Emacs temp files
1823
*~
1924

backends/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Eclipse project files
2+
.cproject
3+
.settings
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function (check_for_dpcpp)
3434
message(STATUS "dpcpp ver[${dpcpp_result}]: ${X}")
3535
endforeach()
3636
else()
37-
message(FATAL_ERROR "DPCPP needed to build dppl_oneapi_interface")
37+
message(FATAL_ERROR "DPCPP needed to build dppl_sycl_interface")
3838
endif()
3939
endfunction()
4040

@@ -73,7 +73,7 @@ if(WIN32)
7373
-Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations \
7474
-fdiagnostics-color=auto -O3 \
7575
")
76-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qstd=c++17")
7777
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3 -DDEBUG ")
7878
elseif(UNIX)
7979
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
@@ -98,9 +98,9 @@ message(STATUS "OpenCL_LIBRARY: ${OpenCL_LIBRARY}")
9898
# Todo : Add build rules for doxygen
9999

100100
add_library(
101-
DPPLOneapiInterface
101+
DPPLSyclInterface
102102
SHARED
103-
source/dppl_oneapi_interface.cpp
103+
source/dppl_sycl_interface.cpp
104104
)
105105

106106
# Install DPPLOpenCLInterface
@@ -110,9 +110,9 @@ add_library(
110110
source/dppl_opencl_interface.c
111111
)
112112

113-
# Install DPPLOneAPIInterface
113+
# Install DPPLSyclInterface
114114
target_include_directories(
115-
DPPLOneapiInterface
115+
DPPLSyclInterface
116116
PRIVATE
117117
${CMAKE_SOURCE_DIR}/include/
118118
${PYTHON_INCLUDE_DIR}
@@ -138,12 +138,12 @@ if(WIN32)
138138
${DPCPP_ROOT}/include/sycl
139139
)
140140
target_include_directories(
141-
DPPLOneapiInterface
141+
DPPLSyclInterface
142142
PUBLIC
143143
${DPCPP_ROOT}/include/sycl
144144
)
145145
target_link_libraries(
146-
DPPLOneapiInterface
146+
DPPLSyclInterface
147147
PRIVATE
148148
${DPCPP_ROOT}/lib/sycl.lib
149149
)
@@ -156,7 +156,7 @@ endif()
156156

157157
install(
158158
TARGETS
159-
DPPLOneapiInterface
159+
DPPLSyclInterface
160160
LIBRARY DESTINATION
161161
"${CMAKE_INSTALL_PREFIX}/lib/"
162162
)
File renamed without changes.
File renamed without changes.

oneapi_wrapper/include/dppl_oneapi_interface.hpp renamed to backends/include/dppl_sycl_interface.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- dppl_oneapi_interface.hpp - DPPL-SYCL interface ---*- C++ -*-------===//
1+
//===--- dppl_sycl_interface.hpp - DPPL-SYCL interface ----*- C++ -*-------===//
22
//
33
// Python Data Parallel Processing Library (PyDPPL)
44
//
@@ -30,7 +30,7 @@
3030
#include <deque>
3131

3232
#ifdef _WIN32
33-
# ifdef DPPLOneapiInterface_EXPORTS
33+
# ifdef DPPLSyclInterface_EXPORTS
3434
# define DPPL_API __declspec(dllexport)
3535
# else
3636
# define DPPL_API __declspec(dllimport)
@@ -59,14 +59,14 @@ enum class sycl_device_type : unsigned int
5959

6060

6161
////////////////////////////////////////////////////////////////////////////////
62-
//////////////////////////////// DpplOneAPIRuntime /////////////////////////////
62+
/////////////////////////////// DpplSyclQueueManager ///////////////////////////
6363
////////////////////////////////////////////////////////////////////////////////
6464

65-
/*! \class DpplOneAPIRuntime
65+
/*! \class DpplSyclQueueManager
6666
* \brief A runtime and context factory class
6767
*
6868
*/
69-
class DpplOneAPIRuntime
69+
class DpplSyclQueueManager
7070
{
7171
public:
7272
DPPL_API
File renamed without changes.

oneapi_wrapper/source/dppl_opencl_interface.c renamed to backends/source/dppl_opencl_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===------ dppl_oneapi_interface.c - DPPL-OpenCL interface ----*- C -*----===//
1+
//===------ dppl_opencl_interface.c - DPPL-OpenCL interface ----*- C -*----===//
22
//
33
// Python Data Parallel Processing Library (PyDPPL)
44
//

oneapi_wrapper/source/dppl_oneapi_interface.cpp renamed to backends/source/dppl_sycl_interface.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- dppl_oneapi_interface.cpp - DPPL-SYCL interface ---*- C++ -*-------===//
1+
//===--- dppl_sycl_interface.cpp - DPPL-SYCL interface -----*- C++ -*------===//
22
//
33
// Python Data Parallel Processing Library (PyDPPL)
44
//
@@ -20,10 +20,10 @@
2020
///
2121
/// \file
2222
/// This file implements the data types and functions declared in
23-
/// dppl_oneapi_interface.hpp.
23+
/// dppl_sycl_interface.hpp.
2424
///
2525
//===----------------------------------------------------------------------===//
26-
#include "dppl_oneapi_interface.hpp"
26+
#include "dppl_sycl_interface.hpp"
2727
#include "dppl_error_codes.hpp"
2828
#include <cassert>
2929
#include <iomanip>
@@ -80,14 +80,14 @@ int64_t error_reporter (const std::string & msg)
8080
return DPPL_FAILURE;
8181
}
8282

83-
class DpplOneAPIRuntimeHelper
83+
class DpplSyclQueueManagerHelper
8484
{
8585
size_t num_platforms_;
8686
cl::sycl::vector_class<cl::sycl::queue> cpu_queues_;
8787
cl::sycl::vector_class<cl::sycl::queue> gpu_queues_;
8888
std::deque<cl::sycl::queue> active_queues_;
8989
public:
90-
DpplOneAPIRuntimeHelper ()
90+
DpplSyclQueueManagerHelper ()
9191
: num_platforms_(platform::get_platforms().size())
9292
{
9393
for(auto d : device::get_devices(info::device_type::cpu))
@@ -98,19 +98,19 @@ class DpplOneAPIRuntimeHelper
9898
active_queues_.emplace_back(default_selector());
9999
}
100100

101-
~DpplOneAPIRuntimeHelper ()
101+
~DpplSyclQueueManagerHelper ()
102102
{
103103

104104
}
105105

106-
friend dppl::DpplOneAPIRuntime;
106+
friend dppl::DpplSyclQueueManager;
107107
};
108108

109-
// This singleton function is needed to create the DpplOneAPIRuntimeHelper object
110-
// in a predictable manner without which there is a chance of segfault.
111-
DpplOneAPIRuntimeHelper& get_gRtHelper()
109+
// This singleton function is needed to create the DpplOneAPIRuntimeHelper
110+
// object in a predictable manner without which there is a chance of segfault.
111+
DpplSyclQueueManagerHelper& get_gRtHelper()
112112
{
113-
static DpplOneAPIRuntimeHelper * helper = new DpplOneAPIRuntimeHelper();
113+
static auto * helper = new DpplSyclQueueManagerHelper();
114114
return *helper;
115115
}
116116

@@ -132,18 +132,18 @@ int64_t dppl::deleteQueue (void *Q)
132132

133133

134134
////////////////////////////////////////////////////////////////////////////////
135-
/////////////////////////////// DpplOneAPIRuntime //////////////////////////////
135+
////////////////////////////// DpplSyclQueueManager ////////////////////////////
136136
////////////////////////////////////////////////////////////////////////////////
137137

138138

139-
int64_t DpplOneAPIRuntime::dump_queue (const void *QPtr) const
139+
int64_t DpplSyclQueueManager::dump_queue (const void *QPtr) const
140140
{
141141
auto Q = static_cast<const queue*>(QPtr);
142142
dump_device_info(Q->get_device());
143143
return DPPL_SUCCESS;
144144
}
145145

146-
int64_t DpplOneAPIRuntime::dump () const
146+
int64_t DpplSyclQueueManager::dump () const
147147
{
148148
size_t i = 0;
149149

@@ -179,14 +179,14 @@ int64_t DpplOneAPIRuntime::dump () const
179179
}
180180

181181

182-
int64_t DpplOneAPIRuntime::getNumPlatforms (size_t *platforms) const
182+
int64_t DpplSyclQueueManager::getNumPlatforms (size_t *platforms) const
183183
{
184184
*platforms = gRtHelper.num_platforms_;
185185
return DPPL_SUCCESS;
186186
}
187187

188188

189-
int64_t DpplOneAPIRuntime::getCurrentQueue (void **QPtr) const
189+
int64_t DpplSyclQueueManager::getCurrentQueue (void **QPtr) const
190190
{
191191
if (gRtHelper.active_queues_.empty())
192192
return error_reporter("No currently active queues.");
@@ -196,7 +196,7 @@ int64_t DpplOneAPIRuntime::getCurrentQueue (void **QPtr) const
196196
}
197197

198198

199-
int64_t DpplOneAPIRuntime::getQueue (void **QPtr, sycl_device_type DeviceTy,
199+
int64_t DpplSyclQueueManager::getQueue (void **QPtr, sycl_device_type DeviceTy,
200200
size_t DNum) const
201201
{
202202
if (DeviceTy == sycl_device_type::cpu) {
@@ -227,7 +227,7 @@ int64_t DpplOneAPIRuntime::getQueue (void **QPtr, sycl_device_type DeviceTy,
227227
}
228228

229229

230-
int64_t DpplOneAPIRuntime::resetGlobalQueue (sycl_device_type DeviceTy,
230+
int64_t DpplSyclQueueManager::resetGlobalQueue (sycl_device_type DeviceTy,
231231
size_t DNum)
232232
{
233233
if(gRtHelper.active_queues_.empty())
@@ -274,7 +274,7 @@ int64_t DpplOneAPIRuntime::resetGlobalQueue (sycl_device_type DeviceTy,
274274

275275

276276
int64_t
277-
DpplOneAPIRuntime::activateQueue (void **QPtr,
277+
DpplSyclQueueManager::activateQueue (void **QPtr,
278278
sycl_device_type DeviceTy,
279279
size_t DNum)
280280
{
@@ -322,7 +322,7 @@ DpplOneAPIRuntime::activateQueue (void **QPtr,
322322
}
323323

324324

325-
int64_t DpplOneAPIRuntime::deactivateCurrentQueue ()
325+
int64_t DpplSyclQueueManager::deactivateCurrentQueue ()
326326
{
327327
if(gRtHelper.active_queues_.empty())
328328
return error_reporter("No active contexts");

conda-recipe/bld.bat

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cmake -G Ninja ^
1313
"-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX%" ^
1414
"-DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX%" ^
1515
"-DDPCPP_ROOT=%DPCPP_ROOT%" ^
16-
"%SRC_DIR%/oneapi_wrapper"
16+
"%SRC_DIR%/backends"
1717
IF %ERRORLEVEL% NEQ 0 exit 1
1818

1919
ninja -n
@@ -23,12 +23,13 @@ IF %ERRORLEVEL% NEQ 0 exit 1
2323
cd ..
2424

2525
REM required by dpglue
26-
set "DP_GLUE_LIBDIR=%LIBRARY_PREFIX%/lib"
27-
set "DP_GLUE_INCLDIR=%LIBRARY_PREFIX%/include"
26+
set "DPPL_OPENCL_INTERFACE_LIBDIR=%LIBRARY_PREFIX%/lib"
27+
set "DPPL_OPENCL_INTERFACE_INCLDIR=%LIBRARY_PREFIX%/include"
2828
set "OpenCL_LIBDIR=%DPCPP_ROOT%/lib"
29+
2930
REM required by oneapi_interface
30-
set "DPPL_ONEAPI_INTERFACE_LIBDIR=%LIBRARY_PREFIX%/lib"
31-
set "DPPL_ONEAPI_INTERFACE_INCLDIR=%LIBRARY_PREFIX%/include"
31+
set "DPPL_SYCL_INTERFACE_LIBDIR=%LIBRARY_PREFIX%/lib"
32+
set "DPPL_SYCL_INTERFACE_INCLDIR=%LIBRARY_PREFIX%/include"
3233

3334
"%PYTHON%" setup.py clean --all
3435
"%PYTHON%" setup.py build

0 commit comments

Comments
 (0)