Skip to content

Commit 4d7dbd8

Browse files
author
Alexander Johnston
committed
[SYCL][CUDA] Code style and cleanup to CUDA support
Signed-off-by: Alexander Johnston <[email protected]>
1 parent 683faf0 commit 4d7dbd8

File tree

16 files changed

+36
-39
lines changed

16 files changed

+36
-39
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/detail/scheduler/scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Scheduler {
8787
// releaseHostAccessor is called.
8888
// Returns an event which indicates when these nodes are completed and host
8989
// accessor is ready for using.
90-
EventImplPtr addHostAccessor(Requirement *Req, const bool destructor = false);
90+
EventImplPtr addHostAccessor(Requirement *Req, const bool Destructor = false);
9191

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

sycl/include/CL/sycl/handler.hpp

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

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

779779
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"
@@ -83,7 +83,6 @@ set(SYCL_SOURCES
8383
"detail/usm/usm_dispatch.cpp"
8484
"detail/usm/usm_impl.cpp"
8585
"detail/util.cpp"
86-
"cg.cpp"
8786
"context.cpp"
8887
"device.cpp"
8988
"device_selector.cpp"

sycl/source/context.cpp

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

2424
__SYCL_INLINE_NAMESPACE(cl) {
2525
namespace sycl {
26-
context::context(const async_handler &AsyncHandler, bool usePrimaryContext)
26+
context::context(const async_handler &AsyncHandler, bool UsePrimaryContext)
2727
: context(default_selector().select_device(), AsyncHandler,
28-
usePrimaryContext) {}
28+
UsePrimaryContext) {}
2929

3030
context::context(const device &Device, async_handler AsyncHandler,
31-
bool usePrimaryContext)
31+
bool UsePrimaryContext)
3232
: context(vector_class<device>(1, Device), AsyncHandler,
33-
usePrimaryContext) {}
33+
UsePrimaryContext) {}
3434

3535
context::context(const platform &Platform, async_handler AsyncHandler,
36-
bool usePrimaryContext)
37-
: context(Platform.get_devices(), AsyncHandler, usePrimaryContext) {}
36+
bool UsePrimaryContext)
37+
: context(Platform.get_devices(), AsyncHandler, UsePrimaryContext) {}
3838

3939
context::context(const vector_class<device> &DeviceList,
40-
async_handler AsyncHandler, bool usePrimaryContext) {
40+
async_handler AsyncHandler, bool UsePrimaryContext) {
4141
if (DeviceList.empty()) {
4242
throw invalid_parameter_error("DeviceList is empty.");
4343
}
@@ -47,7 +47,7 @@ context::context(const vector_class<device> &DeviceList,
4747
if (NonHostDeviceIter == DeviceList.end())
4848
impl =
4949
std::make_shared<detail::context_impl>(DeviceList[0], AsyncHandler,
50-
usePrimaryContext);
50+
UsePrimaryContext);
5151
else {
5252
const device &NonHostDevice = *NonHostDeviceIter;
5353
const auto &NonHostPlatform = NonHostDevice.get_platform().get();
@@ -61,7 +61,7 @@ context::context(const vector_class<device> &DeviceList,
6161
"Can't add devices across platforms to a single context.");
6262
else
6363
impl = std::make_shared<detail::context_impl>(DeviceList, AsyncHandler,
64-
usePrimaryContext);
64+
UsePrimaryContext);
6565
}
6666
}
6767
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
@@ -14,9 +14,8 @@ namespace sycl {
1414
namespace detail {
1515

1616
AccessorImplHost::~AccessorImplHost() {
17-
if (MBlockedCmd) {
17+
if (MBlockedCmd)
1818
detail::Scheduler::getInstance().releaseHostAccessor(this);
19-
}
2019
}
2120
}
2221
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ cl_mem interop_handler::getMemImpl(detail::Requirement* Req) const {
3434
}
3535

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

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)