Skip to content

Commit ab02a86

Browse files
committed
Merge remote-tracking branch 'remote/sycl' into stream-class
2 parents d5f0fea + 6c8b622 commit ab02a86

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4208,6 +4208,17 @@ static bool ContainsWrapperAction(const Action *A) {
42084208
return false;
42094209
}
42104210

4211+
/// Check whether the given input tree contains any append footer actions
4212+
static bool ContainsAppendFooterAction(const Action *A) {
4213+
if (isa<AppendFooterJobAction>(A))
4214+
return true;
4215+
for (const auto &AI : A->inputs())
4216+
if (ContainsAppendFooterAction(AI))
4217+
return true;
4218+
4219+
return false;
4220+
}
4221+
42114222
// Put together an external compiler compilation call which is used instead
42124223
// of the clang invocation for the host compile of an offload compilation.
42134224
// Enabling command line: clang++ -fsycl -fsycl-host-compiler=<HostExe>
@@ -4641,8 +4652,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46414652
if (!IsSYCLOffloadDevice) {
46424653
// Add the -include option to add the integration header
46434654
StringRef Header = D.getIntegrationHeader(Input.getBaseInput());
4655+
// Do not add the integration header if we are compiling after the
4656+
// integration footer has been applied. Check for the append job
4657+
// action to determine this.
46444658
if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID &&
4645-
!Header.empty()) {
4659+
!Header.empty() && !ContainsAppendFooterAction(&JA)) {
46464660
CmdArgs.push_back("-include");
46474661
CmdArgs.push_back(Args.MakeArgString(Header));
46484662
// When creating dependency information, filter out the generated

clang/test/Driver/sycl-int-footer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// Check compilation tool steps when using the integrated footer
2+
// RUN: %clangxx -fsycl -fsycl-use-footer %s -### 2>&1 \
3+
// RUN: | FileCheck -check-prefix FOOTER %s
4+
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"
5+
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "[[PREPROC:.+\.ii]]"
6+
// FOOTER: append-file{{.*}} "[[PREPROC]]" "--append=[[INTFOOTER]]" "--output=[[APPENDEDSRC:.+\.cpp]]"
7+
// FOOTER: clang{{.*}} "-fsycl-is-host"{{.*}} "[[APPENDEDSRC]]"
8+
// FOOTER-NOT: "-include" "[[INTHEADER]]"

libdevice/device_itt.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "spirv_vars.h"
1616

1717
#define ITT_STUB_ATTRIBUTES __attribute__((noinline, optnone))
18+
#define ITT_WRAPPER_ATTRIBUTES __attribute__((always_inline))
1819

1920
/// Atomic operation type
2021
enum __itt_atomic_mem_op_t {
@@ -36,7 +37,7 @@ DEVICE_EXTERN_C char __spirv_SpecConstant(int, char);
3637

3738
#define ITT_SPEC_CONSTANT 0xFF747469
3839

39-
static inline bool isITTEnabled() {
40+
static ITT_WRAPPER_ATTRIBUTES bool isITTEnabled() {
4041
return __spirv_SpecConstant(ITT_SPEC_CONSTANT, 0) != 0;
4142
}
4243

@@ -50,14 +51,15 @@ static inline bool isITTEnabled() {
5051
// be computed in the wrapper itself and has to be passed from outside.
5152
// If a compiler needs to invoke such an API, it has to use the user
5253
// visible API directly (i.e. __itt_offload_sync_acquired).
53-
DEVICE_EXTERN_C
54-
void __itt_offload_wi_start_wrapper();
55-
DEVICE_EXTERN_C
56-
void __itt_offload_wi_finish_wrapper();
57-
DEVICE_EXTERN_C
58-
void __itt_offload_wg_barrier_wrapper();
59-
DEVICE_EXTERN_C
60-
void __itt_offload_wi_resume_wrapper();
54+
//
55+
// FIXME: we need to add always_inline compiler wrappers
56+
// for atomic_op_start/finish. Compiler calls user
57+
// wrappers right now, and they may interfere with
58+
// debugging user code in non-ITT mode.
59+
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_start_wrapper();
60+
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_finish_wrapper();
61+
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wg_barrier_wrapper();
62+
DEVICE_EXTERN_C ITT_WRAPPER_ATTRIBUTES void __itt_offload_wi_resume_wrapper();
6163

6264
// Non-inlinable and non-optimizable APIs that are recognized
6365
// by profiling tools.

sycl/plugins/cuda/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,3 @@ install(TARGETS pi_cuda
4343
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}" COMPONENT pi_cuda
4444
RUNTIME DESTINATION "bin" COMPONENT pi_cuda
4545
)
46-
47-
# `sycl/source/CMakeLists.txt` adapted when SYCL_BUILD_PI_CUDA is defined:
48-
# target_link_libraries(sycl PUBLIC pi_cuda)
49-
# target_compile_definitions(sycl PUBLIC USE_PI_CUDA)

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ function(add_sycl_rt_library LIB_NAME)
8282
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:pi_cuda>
8383
)
8484

85-
target_compile_definitions(${LIB_OBJ_NAME}
86-
PUBLIC
87-
$<$<BOOL:${SYCL_BUILD_PI_CUDA}>:USE_PI_CUDA>)
88-
8985
add_common_options(${LIB_NAME} ${LIB_OBJ_NAME})
9086

9187
set_target_properties(${LIB_NAME} PROPERTIES

sycl/source/detail/context_impl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ context_impl::context_impl(const vector_class<cl::sycl::device> Devices,
4545

4646
const auto Backend = getPlugin().getBackend();
4747
if (Backend == backend::cuda) {
48-
#if USE_PI_CUDA
4948
const bool UseCUDAPrimaryContext =
5049
MPropList.has_property<property::context::cuda::use_primary_context>();
5150
const pi_context_properties Props[] = {
@@ -55,10 +54,6 @@ context_impl::context_impl(const vector_class<cl::sycl::device> Devices,
5554

5655
getPlugin().call<PiApiKind::piContextCreate>(
5756
Props, DeviceIds.size(), DeviceIds.data(), nullptr, nullptr, &MContext);
58-
#else
59-
cl::sycl::detail::pi::die(
60-
"CUDA support was not enabled at compilation time");
61-
#endif
6257
} else {
6358
getPlugin().call<PiApiKind::piContextCreate>(nullptr, DeviceIds.size(),
6459
DeviceIds.data(), nullptr,

0 commit comments

Comments
 (0)