Skip to content

Commit 22f31bc

Browse files
author
Alexander Johnston
committed
[SYCL][CUDA] Code style and cleanup to CUDA support
Signed-off-by: Alexander Johnston <[email protected]>
1 parent 77ef0af commit 22f31bc

File tree

16 files changed

+39
-42
lines changed

16 files changed

+39
-42
lines changed

clang/include/clang/Config/config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
#cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER
8282

8383
/* Define if we have SYCL PI CUDA support */
84-
#cmakedefine SYCL_HAVE_PI_CUDA ${SYCL_HAVE_PI_CUDA}
84+
#cmakedefine01 SYCL_HAVE_PI_CUDA
8585

8686
/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
8787
#cmakedefine01 CLANG_SPAWN_CC1

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
11031103
if (TI.getTriple().isNVPTX()) {
11041104
Builder.defineMacro("__SYCL_NVPTX__", "1");
11051105
}
1106-
1107-
if (!getenv("DISABLE_INFER_AS"))
1108-
Builder.defineMacro("__SYCL_ENABLE_INFER_AS__", "1");
11091106
}
11101107
if (LangOpts.SYCLUnnamedLambda)
11111108
Builder.defineMacro("__SYCL_UNNAMED_LAMBDA__", "1");

sycl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
142142
set(sycl_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/source)
143143
set(sycl_detail_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include/CL/sycl/detail)
144144
set(sycl_detail_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/source/detail)
145+
set(sycl_plugin_dir ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
145146
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
146147
set(version_header "${sycl_inc_dir}/CL/sycl/version.hpp")
147148
configure_file("${version_header}.in" "${version_header}")

sycl/include/CL/sycl/context.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class context {
3333
/// exceptions.
3434
///
3535
/// @param AsyncHandler is an instance of async_handler.
36-
/// @param useCUDAPrimaryContext is a bool determining whether to use the
36+
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
3737
/// primary context in the CUDA backend.
3838
explicit context(const async_handler &AsyncHandler = {},
39-
bool useCUDAPrimaryContext = false);
39+
bool UseCUDAPrimaryContext = false);
4040

4141
/// Constructs a SYCL context instance using the provided device.
4242
///
@@ -47,10 +47,10 @@ class context {
4747
///
4848
/// @param Device is an instance of SYCL device.
4949
/// @param AsyncHandler is an instance of async_handler.
50-
/// @param useCUDAPrimaryContext is a bool determining whether to use the
50+
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
5151
/// primary context in the CUDA backend.
5252
context(const device &Device, async_handler AsyncHandler = {},
53-
bool useCUDAPrimaryContext = false);
53+
bool UseCUDAPrimaryContext = false);
5454

5555
/// Constructs a SYCL context instance using the provided platform.
5656
///
@@ -61,10 +61,10 @@ class context {
6161
///
6262
/// @param Platform is an instance of SYCL platform.
6363
/// @param AsyncHandler is an instance of async_handler.
64-
/// @param useCUDAPrimaryContext is a bool determining whether to use the
64+
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
6565
/// primary context in the CUDA backend.
6666
context(const platform &Platform, async_handler AsyncHandler = {},
67-
bool useCUDAPrimaryContext = false);
67+
bool UseCUDAPrimaryContext = false);
6868

6969
/// Constructs a SYCL context instance using list of devices.
7070
///
@@ -76,10 +76,10 @@ class context {
7676
///
7777
/// @param DeviceList is a list of SYCL device instances.
7878
/// @param AsyncHandler is an instance of async_handler.
79-
/// @param useCUDAPrimaryContext is a bool determining whether to use the
79+
/// @param UseCUDAPrimaryContext is a bool determining whether to use the
8080
/// primary context in the CUDA backend.
8181
context(const vector_class<device> &DeviceList,
82-
async_handler AsyncHandler = {}, bool useCUDAPrimaryContext = false);
82+
async_handler AsyncHandler = {}, bool UseCUDAPrimaryContext = false);
8383

8484
/// Constructs a SYCL context instance from OpenCL cl_context.
8585
///

sycl/include/CL/sycl/detail/cg.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class InteropTask {
177177
std::function<void(cl::sycl::interop_handler)> MFunc;
178178

179179
public:
180-
InteropTask(std::function<void(cl::sycl::interop_handler)> Func)
180+
InteropTask(function_class<void(cl::sycl::interop_handler)> Func)
181181
: MFunc(Func) {}
182182
void call(cl::sycl::interop_handler &h) { MFunc(h); }
183183
};

sycl/include/CL/sycl/handler.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,9 @@ class handler {
773773
#endif
774774
}
775775

776-
// Similar to single_task, but passed lambda will be executed on host
777-
// dependencies are satisfied on the device.
778-
// Functor takes an interop_handler argument
776+
/// Invokes a lambda on the host. Dependencies are satisfied on the host.
777+
///
778+
/// @param Func is a lambda that is executed on the host
779779
template <typename FuncT> void interop_task(FuncT Func) {
780780

781781
MInteropTask.reset(new detail::InteropTask(std::move(Func)));

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set_target_properties(
1717
add_library(pi_cuda SHARED
1818
"${sycl_inc_dir}/CL/sycl/detail/pi.h"
1919
"${sycl_inc_dir}/CL/sycl/detail/pi.hpp"
20-
"${sycl_inc_dir}/CL/sycl/detail/pi_cuda.hpp"
20+
"pi_cuda.hpp"
2121
"pi_cuda.cpp"
2222
)
2323

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <CL/sycl/backend/cuda.hpp>
1010
#include <CL/sycl/detail/pi.hpp>
11-
#include <CL/sycl/detail/pi_cuda.hpp>
11+
#include <pi_cuda.hpp>
1212
#include <algorithm>
1313
#include <cassert>
1414
#include <cuda.h>

sycl/include/CL/sycl/detail/pi_cuda.hpp renamed to sycl/plugins/cuda/pi_cuda.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef PI_CUDA_HPP
1414
#define PI_CUDA_HPP
1515

16-
#include "pi.h"
16+
#include "CL/sycl/detail/pi.h"
1717
#include <array>
1818
#include <atomic>
1919
#include <cassert>

sycl/source/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#cmake_policy(SET CMP0057 NEW)
55
#include(AddLLVM)
66

7-
87
function(add_sycl_rt_library LIB_NAME)
98

109
add_library(${LIB_NAME} SHARED ${ARGN})
@@ -49,6 +48,7 @@ set(SYCL_SOURCES
4948
"detail/builtins_integer.cpp"
5049
"detail/builtins_math.cpp"
5150
"detail/builtins_relational.cpp"
51+
"detail/cg.cpp"
5252
"detail/pi.cpp"
5353
"detail/common.cpp"
5454
"detail/config.cpp"
@@ -84,7 +84,6 @@ set(SYCL_SOURCES
8484
"detail/usm/usm_impl.cpp"
8585
"detail/util.cpp"
8686
"accessor.cpp"
87-
"cg.cpp"
8887
"context.cpp"
8988
"device.cpp"
9089
"device_selector.cpp"

sycl/source/context.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424

2525
__SYCL_INLINE_NAMESPACE(cl) {
2626
namespace sycl {
27-
context::context(const async_handler &AsyncHandler, bool usePrimaryContext)
27+
context::context(const async_handler &AsyncHandler, bool UsePrimaryContext)
2828
: context(default_selector().select_device(), AsyncHandler,
29-
usePrimaryContext) {}
29+
UsePrimaryContext) {}
3030

3131
context::context(const device &Device, async_handler AsyncHandler,
32-
bool usePrimaryContext)
32+
bool UsePrimaryContext)
3333
: context(vector_class<device>(1, Device), AsyncHandler,
34-
usePrimaryContext) {}
34+
UsePrimaryContext) {}
3535

3636
context::context(const platform &Platform, async_handler AsyncHandler,
37-
bool usePrimaryContext)
38-
: context(Platform.get_devices(), AsyncHandler, usePrimaryContext) {}
37+
bool UsePrimaryContext)
38+
: context(Platform.get_devices(), AsyncHandler, UsePrimaryContext) {}
3939

4040
context::context(const vector_class<device> &DeviceList,
41-
async_handler AsyncHandler, bool usePrimaryContext) {
41+
async_handler AsyncHandler, bool UsePrimaryContext) {
4242
if (DeviceList.empty()) {
4343
throw invalid_parameter_error("DeviceList is empty.");
4444
}
@@ -48,7 +48,7 @@ context::context(const vector_class<device> &DeviceList,
4848
if (NonHostDeviceIter == DeviceList.end())
4949
impl =
5050
std::make_shared<detail::context_impl>(DeviceList[0], AsyncHandler,
51-
usePrimaryContext);
51+
UsePrimaryContext);
5252
else {
5353
const device &NonHostDevice = *NonHostDeviceIter;
5454
const auto &NonHostPlatform = NonHostDevice.get_platform().get();
@@ -62,7 +62,7 @@ context::context(const vector_class<device> &DeviceList,
6262
"Can't add devices across platforms to a single context.");
6363
else
6464
impl = std::make_shared<detail::context_impl>(DeviceList, AsyncHandler,
65-
usePrimaryContext);
65+
UsePrimaryContext);
6666
}
6767
}
6868
context::context(cl_context ClContext, async_handler AsyncHandler) {

sycl/source/detail/accessor_impl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace sycl {
1515
namespace detail {
1616

1717
AccessorImplHost::~AccessorImplHost() {
18-
if (MBlockedCmd) {
18+
if (MBlockedCmd)
1919
detail::Scheduler::getInstance().releaseHostAccessor(this);
20-
}
2120
}
2221

2322
void addHostAccessorAndWait(Requirement *Req) {

sycl/source/cg.cpp renamed to sycl/source/detail/cg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "CL/sycl/detail/cg.hpp"
10-
#include <CL/sycl/detail/scheduler/scheduler.hpp>
11-
#include <CL/sycl/detail/scheduler/commands.hpp>
1210
#include <CL/sycl/detail/memory_manager.hpp>
13-
#include <CL/sycl/detail/queue_impl.hpp>
11+
#include <detail/queue_impl.hpp>
12+
#include <detail/scheduler/commands.hpp>
13+
#include <detail/scheduler/scheduler.hpp>
1414

1515

1616
#include <memory>
@@ -34,4 +34,4 @@ cl_mem interop_handler::getMemImpl(detail::Requirement* Req) const {
3434
}
3535

3636
} // sycl
37-
} // sycl
37+
} // cl

sycl/source/detail/scheduler/scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Scheduler {
8686
// operations with the same memory object that have side effects are blocked
8787
// until releaseHostAccessor is called. Returns an event which indicates
8888
// when these nodes are completed and host accessor is ready for using.
89-
EventImplPtr addHostAccessor(Requirement *Req, const bool destructor = false);
89+
EventImplPtr addHostAccessor(Requirement *Req, const bool Destructor = false);
9090

9191
// Unblocks operations with the memory object.
9292
void releaseHostAccessor(Requirement *Req);

sycl/source/device_selector.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ int default_selector::operator()(const device &dev) const {
3838
std::string backend = (SYCL_BE ? SYCL_BE : "");
3939
// Taking the version information from the platform gives us more useful
4040
// information than the driver_version of the device.
41-
const platform Platform = dev.get_info<info::device::platform>();
42-
const std::string PlatformVersion =
43-
Platform.get_info<info::platform::version>();;
41+
const platform platform = dev.get_info<info::device::platform>();
42+
const std::string platformVersion =
43+
platform.get_info<info::platform::version>();;
4444
// If using PI_CUDA, don't accept a non-CUDA device
45-
if (PlatformVersion.find("CUDA") == std::string::npos &&
45+
if (platformVersion.find("CUDA") == std::string::npos &&
4646
backend == "PI_CUDA") {
4747
return -1;
4848
}
4949
// If using PI_OPENCL, don't accept a non-OpenCL device
50-
if (PlatformVersion.find("OpenCL") == std::string::npos &&
50+
if (platformVersion.find("OpenCL") == std::string::npos &&
5151
backend == "PI_OPENCL") {
5252
return -1;
5353
}

sycl/unittests/pi/cuda/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ target_include_directories(
2121
${CUDA_INCLUDE_DIRS}
2222
${sycl_detail_inc_dir}
2323
${sycl_inc_dir}
24+
"${sycl_plugin_dir}/cuda/"
2425
)

0 commit comments

Comments
 (0)