Skip to content

Commit 546d150

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into bump-cb
2 parents f61f0fe + b8a3979 commit 546d150

File tree

119 files changed

+4396
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4396
-701
lines changed

clang/test/Driver/clang-offload-extract.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ __declspec(align(sizeof(void*) * 2))
6464
const void* padding[2] = {0, 0};
6565

6666
#ifdef _WIN32
67-
char __start_omp_offloading_entries = 1;
68-
char __stop_omp_offloading_entries = 1;
67+
char __start_llvm_offload_entries = 1;
68+
char __stop_llvm_offload_entries = 1;
6969
#endif
7070

7171
void __tgt_register_lib(void *desc) {}

clang/test/Driver/clang-offload-wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
// CHECK-IR: [[ENTBEGIN:@.+]] = external hidden constant [[ENTTY]]
130130
// CHECK-IR: [[ENTEND:@.+]] = external hidden constant [[ENTTY]]
131131

132-
// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, section "omp_offloading_entries"
132+
// CHECK-IR: [[DUMMY:@.+]] = hidden constant [0 x [[ENTTY]]] zeroinitializer, section "llvm_offload_entries"
133133

134134
// CHECK-IR: [[OMP_BIN:@.+]] = internal unnamed_addr constant [[OMP_BINTY:\[[0-9]+ x i8\]]] c"Content of device file3{{.+}}"
135135
// CHECK-IR: [[OMP_INFO:@.+]] = internal local_unnamed_addr constant [2 x i64] [i64 ptrtoint (ptr [[OMP_BIN]] to i64), i64 24], section ".tgtimg", align 16

clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,9 @@ class BinaryWrapper {
10061006
/// library. It is defined as follows
10071007
///
10081008
/// __attribute__((visibility("hidden")))
1009-
/// extern __tgt_offload_entry *__start_omp_offloading_entries;
1009+
/// extern __tgt_offload_entry *__start_llvm_offload_entries;
10101010
/// __attribute__((visibility("hidden")))
1011-
/// extern __tgt_offload_entry *__stop_omp_offloading_entries;
1011+
/// extern __tgt_offload_entry *__stop_llvm_offload_entries;
10121012
///
10131013
/// static const char Image0[] = { <Bufs.front() contents> };
10141014
/// ...
@@ -1018,23 +1018,23 @@ class BinaryWrapper {
10181018
/// {
10191019
/// Image0, /*ImageStart*/
10201020
/// Image0 + sizeof(Image0), /*ImageEnd*/
1021-
/// __start_omp_offloading_entries, /*EntriesBegin*/
1022-
/// __stop_omp_offloading_entries /*EntriesEnd*/
1021+
/// __start_llvm_offload_entries, /*EntriesBegin*/
1022+
/// __stop_llvm_offload_entries /*EntriesEnd*/
10231023
/// },
10241024
/// ...
10251025
/// {
10261026
/// ImageN, /*ImageStart*/
10271027
/// ImageN + sizeof(ImageN), /*ImageEnd*/
1028-
/// __start_omp_offloading_entries, /*EntriesBegin*/
1029-
/// __stop_omp_offloading_entries /*EntriesEnd*/
1028+
/// __start_llvm_offload_entries, /*EntriesBegin*/
1029+
/// __stop_llvm_offload_entries /*EntriesEnd*/
10301030
/// }
10311031
/// };
10321032
///
10331033
/// static const __tgt_bin_desc BinDesc = {
10341034
/// sizeof(Images) / sizeof(Images[0]), /*NumDeviceImages*/
10351035
/// Images, /*DeviceImages*/
1036-
/// __start_omp_offloading_entries, /*HostEntriesBegin*/
1037-
/// __stop_omp_offloading_entries /*HostEntriesEnd*/
1036+
/// __start_llvm_offload_entries, /*HostEntriesBegin*/
1037+
/// __stop_llvm_offload_entries /*HostEntriesEnd*/
10381038
/// };
10391039
///
10401040
/// Global variable that represents BinDesc is returned.
@@ -1049,24 +1049,24 @@ class BinaryWrapper {
10491049
// Create external begin/end symbols for the offload entries table.
10501050
auto *EntriesStart = new GlobalVariable(
10511051
M, getEntryTy(), /*isConstant*/ true, GlobalValue::ExternalLinkage,
1052-
/*Initializer*/ nullptr, "__start_omp_offloading_entries");
1052+
/*Initializer*/ nullptr, "__start_llvm_offload_entries");
10531053
EntriesStart->setVisibility(GlobalValue::HiddenVisibility);
10541054
auto *EntriesStop = new GlobalVariable(
10551055
M, getEntryTy(), /*isConstant*/ true, GlobalValue::ExternalLinkage,
1056-
/*Initializer*/ nullptr, "__stop_omp_offloading_entries");
1056+
/*Initializer*/ nullptr, "__stop_llvm_offload_entries");
10571057
EntriesStop->setVisibility(GlobalValue::HiddenVisibility);
10581058

10591059
// We assume that external begin/end symbols that we have created above
10601060
// will be defined by the linker. But linker will do that only if linker
1061-
// inputs have section with "omp_offloading_entries" name which is not
1061+
// inputs have section with "llvm_offload_entries" name which is not
10621062
// guaranteed. So, we just create dummy zero sized object in the offload
10631063
// entries section to force linker to define those symbols.
10641064
auto *DummyInit =
10651065
ConstantAggregateZero::get(ArrayType::get(getEntryTy(), 0u));
10661066
auto *DummyEntry = new GlobalVariable(
10671067
M, DummyInit->getType(), true, GlobalVariable::ExternalLinkage,
10681068
DummyInit, "__dummy.omp_offloading.entry");
1069-
DummyEntry->setSection("omp_offloading_entries");
1069+
DummyEntry->setSection("llvm_offload_entries");
10701070
DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
10711071

10721072
EntriesB = EntriesStart;

devops/scripts/benchmarks/utils/utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,37 @@ def run(
4949
command = command.split()
5050

5151
env = os.environ.copy()
52-
5352
for ldlib in ld_library:
5453
if os.path.isdir(ldlib):
55-
env["LD_LIBRARY_PATH"] = (
56-
ldlib + os.pathsep + env.get("LD_LIBRARY_PATH", "")
54+
env_vars["LD_LIBRARY_PATH"] = os.pathsep.join(
55+
filter(None, [ldlib, env_vars.get("LD_LIBRARY_PATH", "")])
5756
)
5857
else:
5958
log.warning(f"LD_LIBRARY_PATH component does not exist: {ldlib}")
6059

6160
# order is important, we want provided sycl rt libraries to be first
6261
if add_sycl:
6362
sycl_bin_path = os.path.join(options.sycl, "bin")
64-
env["PATH"] = sycl_bin_path + os.pathsep + env.get("PATH", "")
63+
env_vars["PATH"] = os.pathsep.join(
64+
filter(None, [sycl_bin_path, env_vars.get("PATH", "")])
65+
)
6566
sycl_lib_path = os.path.join(options.sycl, "lib")
66-
env["LD_LIBRARY_PATH"] = (
67-
sycl_lib_path + os.pathsep + env.get("LD_LIBRARY_PATH", "")
67+
env_vars["LD_LIBRARY_PATH"] = os.pathsep.join(
68+
filter(None, [sycl_lib_path, env_vars.get("LD_LIBRARY_PATH", "")])
6869
)
6970

70-
env.update(env_vars)
71-
7271
command_str = " ".join(command)
7372
env_str = " ".join(f"{key}={value}" for key, value in env_vars.items())
7473
full_command_str = f"{env_str} {command_str}".strip()
7574
log.debug(f"Running: {full_command_str}")
7675

76+
for key, value in env_vars.items():
77+
# Only PATH and LD_LIBRARY_PATH should be prepended to existing values
78+
if key in ("PATH", "LD_LIBRARY_PATH") and (old := env.get(key)):
79+
env[key] = os.pathsep.join([value, old])
80+
else:
81+
env[key] = value
82+
7783
# Normalize input to bytes if it's a str
7884
if isinstance(input, str):
7985
input_bytes = input.encode()

llvm/lib/SYCLPostLink/ComputeModuleRuntimeInfo.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ bool isModuleUsingTsan(const Module &M) {
6666
// Optional.
6767
// Otherwise, it returns an Optional containing a list of reached
6868
// SPIR kernel function's names.
69-
static std::optional<std::vector<StringRef>>
70-
traverseCGToFindSPIRKernels(const Function *StartingFunction) {
69+
static std::optional<std::vector<StringRef>> traverseCGToFindSPIRKernels(
70+
const std::vector<Function *> &StartingFunctionVec) {
7171
std::queue<const Function *> FunctionsToVisit;
7272
std::unordered_set<const Function *> VisitedFunctions;
73-
FunctionsToVisit.push(StartingFunction);
73+
for (const Function *FPtr : StartingFunctionVec)
74+
FunctionsToVisit.push(FPtr);
7475
std::vector<StringRef> KernelNames;
7576

7677
while (!FunctionsToVisit.empty()) {
@@ -106,13 +107,20 @@ traverseCGToFindSPIRKernels(const Function *StartingFunction) {
106107
return {std::move(KernelNames)};
107108
}
108109

109-
static std::vector<StringRef> getKernelNamesUsingAssert(const Module &M) {
110-
auto *DevicelibAssertFailFunction = M.getFunction("__devicelib_assert_fail");
111-
if (!DevicelibAssertFailFunction)
110+
static std::vector<StringRef>
111+
getKernelNamesUsingSpecialFunctions(const Module &M,
112+
const std::vector<StringRef> &FNames) {
113+
std::vector<Function *> SpecialFunctionVec;
114+
for (const auto Fn : FNames) {
115+
Function *FPtr = M.getFunction(Fn);
116+
if (FPtr)
117+
SpecialFunctionVec.push_back(FPtr);
118+
}
119+
120+
if (SpecialFunctionVec.size() == 0)
112121
return {};
113122

114-
auto TraverseResult =
115-
traverseCGToFindSPIRKernels(DevicelibAssertFailFunction);
123+
auto TraverseResult = traverseCGToFindSPIRKernels(SpecialFunctionVec);
116124

117125
if (TraverseResult.has_value())
118126
return std::move(*TraverseResult);
@@ -442,7 +450,9 @@ PropSetRegTy computeModuleProperties(const Module &M,
442450
PropSet.add(PropSetRegTy::SYCL_MISC_PROP, "optLevel", OptLevel);
443451
}
444452
{
445-
std::vector<StringRef> FuncNames = getKernelNamesUsingAssert(M);
453+
std::vector<StringRef> AssertFuncNames{"__devicelib_assert_fail"};
454+
std::vector<StringRef> FuncNames =
455+
getKernelNamesUsingSpecialFunctions(M, AssertFuncNames);
446456
for (const StringRef &FName : FuncNames)
447457
PropSet.add(PropSetRegTy::SYCL_ASSERT_USED, FName, true);
448458
}

sycl/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ if (NOT WIN32)
363363
RENAME "libsycl.so.${SYCL_VERSION_STRING}-gdb.py"
364364
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/"
365365
COMPONENT sycl-headers-extras)
366+
if (SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB)
367+
install(FILES
368+
"${CMAKE_CURRENT_SOURCE_DIR}/gdb/libsycl.so-gdb.py"
369+
RENAME "libsycl-preview.so.${SYCL_VERSION_STRING}-gdb.py"
370+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/"
371+
COMPONENT sycl-headers-extras)
372+
endif()
366373
endif()
367374

368375
if(SYCL_ENABLE_XPTI_TRACING AND

sycl/include/sycl/detail/kernel_launch_helper.hpp

Lines changed: 126 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
#include <sycl/detail/compile_time_kernel_info.hpp>
1313
#include <sycl/detail/helpers.hpp>
1414
#include <sycl/detail/is_device_copyable.hpp>
15+
#include <sycl/detail/type_traits.hpp>
1516
#include <sycl/ext/intel/experimental/fp_control_kernel_properties.hpp>
1617
#include <sycl/ext/intel/experimental/kernel_execution_properties.hpp>
18+
#include <sycl/ext/oneapi/experimental/cluster_group_prop.hpp>
19+
#include <sycl/ext/oneapi/experimental/graph.hpp>
20+
#include <sycl/ext/oneapi/experimental/use_root_sync_prop.hpp>
1721
#include <sycl/ext/oneapi/experimental/virtual_functions.hpp>
1822
#include <sycl/ext/oneapi/kernel_properties/properties.hpp>
1923
#include <sycl/ext/oneapi/work_group_scratch_memory.hpp>
@@ -253,23 +257,130 @@ struct KernelWrapper<
253257
}
254258
}; // KernelWrapper struct
255259

256-
struct KernelLaunchPropertyWrapper {
257-
template <typename KernelName, typename PropertyProcessor,
258-
typename KernelType>
259-
static void parseProperties([[maybe_unused]] PropertyProcessor h,
260-
[[maybe_unused]] const KernelType &KernelFunc) {
261-
#ifndef __SYCL_DEVICE_ONLY__
262-
// If there are properties provided by get method then process them.
263-
if constexpr (ext::oneapi::experimental::detail::
264-
HasKernelPropertiesGetMethod<const KernelType &>::value) {
265-
266-
h->template processProperties<
267-
detail::CompileTimeKernelInfo<KernelName>.IsESIMD>(
268-
KernelFunc.get(ext::oneapi::experimental::properties_tag{}));
260+
// This namespace encapsulates everything related to parsing kernel launch
261+
// properties.
262+
inline namespace kernel_launch_properties_v1 {
263+
264+
template <typename key, typename = void> struct MarshalledProperty;
265+
266+
// Generic implementation for runtime properties.
267+
template <typename PropertyTy>
268+
struct MarshalledProperty<
269+
PropertyTy,
270+
std::enable_if_t<!std::is_empty_v<PropertyTy> &&
271+
std::is_same_v<PropertyTy, typename PropertyTy::key_t>>> {
272+
std::optional<PropertyTy> MProperty;
273+
274+
template <typename InputPropertyTy>
275+
MarshalledProperty(const InputPropertyTy &Props) {
276+
(void)Props;
277+
if constexpr (InputPropertyTy::template has_property<PropertyTy>())
278+
MProperty = Props.template get_property<PropertyTy>();
279+
}
280+
281+
MarshalledProperty() = default;
282+
};
283+
284+
// Generic implementation for properties with non-template value_t.
285+
template <typename PropertyTy>
286+
struct MarshalledProperty<PropertyTy,
287+
std::void_t<typename PropertyTy::value_t>> {
288+
bool MPresent = false;
289+
290+
template <typename InputPropertyTy>
291+
MarshalledProperty(const InputPropertyTy &) {
292+
using namespace sycl::ext::oneapi::experimental;
293+
MPresent = InputPropertyTy::template has_property<
294+
sycl::ext::oneapi::experimental::use_root_sync_key>();
295+
}
296+
297+
MarshalledProperty() = default;
298+
};
299+
300+
// Specialization for work group progress property.
301+
template <typename PropertyTy>
302+
struct MarshalledProperty<
303+
PropertyTy,
304+
std::enable_if_t<check_type_in_v<
305+
PropertyTy, sycl::ext::oneapi::experimental::work_group_progress_key,
306+
sycl::ext::oneapi::experimental::sub_group_progress_key,
307+
sycl::ext::oneapi::experimental::work_item_progress_key>>> {
308+
309+
using forward_progress_guarantee =
310+
sycl::ext::oneapi::experimental::forward_progress_guarantee;
311+
using execution_scope = sycl::ext::oneapi::experimental::execution_scope;
312+
313+
std::optional<forward_progress_guarantee> MFPGuarantee;
314+
std::optional<execution_scope> MFPCoordinationScope;
315+
316+
template <typename InputPropertyTy>
317+
MarshalledProperty(const InputPropertyTy &Props) {
318+
(void)Props;
319+
320+
if constexpr (InputPropertyTy::template has_property<PropertyTy>()) {
321+
MFPGuarantee = Props.template get_property<PropertyTy>().guarantee;
322+
MFPCoordinationScope =
323+
Props.template get_property<PropertyTy>().coordinationScope;
269324
}
270-
#endif
271325
}
272-
}; // KernelLaunchPropertyWrapper struct
326+
327+
MarshalledProperty() = default;
328+
};
329+
330+
template <typename... keys> struct PropsHolder : MarshalledProperty<keys>... {
331+
bool MEmpty = true;
332+
333+
template <typename PropertiesT,
334+
class = typename std::enable_if_t<
335+
ext::oneapi::experimental::is_property_list_v<PropertiesT>>>
336+
PropsHolder(PropertiesT Props)
337+
: MarshalledProperty<keys>(Props)...,
338+
MEmpty(((!PropertiesT::template has_property<keys>() && ...))) {}
339+
340+
PropsHolder() = default;
341+
342+
constexpr bool isEmpty() const { return MEmpty; }
343+
344+
template <typename PropertyCastKey> constexpr auto get() const {
345+
return static_cast<const MarshalledProperty<PropertyCastKey> *>(this);
346+
}
347+
};
348+
349+
using KernelPropertyHolderStructTy =
350+
PropsHolder<sycl::ext::oneapi::experimental::work_group_scratch_size,
351+
sycl::ext::intel::experimental::cache_config_key,
352+
sycl::ext::oneapi::experimental::use_root_sync_key,
353+
sycl::ext::oneapi::experimental::work_group_progress_key,
354+
sycl::ext::oneapi::experimental::sub_group_progress_key,
355+
sycl::ext::oneapi::experimental::work_item_progress_key,
356+
sycl::ext::oneapi::experimental::cuda::cluster_size_key<1>,
357+
sycl::ext::oneapi::experimental::cuda::cluster_size_key<2>,
358+
sycl::ext::oneapi::experimental::cuda::cluster_size_key<3>>;
359+
360+
/// Note: it is important that this function *does not* depend on kernel
361+
/// name or kernel type, because then it will be instantiated for every
362+
/// kernel, even though body of those instantiated functions could be almost
363+
/// the same, thus unnecessary increasing compilation time.
364+
template <bool IsESIMDKernel = false, typename PropertiesT,
365+
class = typename std::enable_if_t<
366+
ext::oneapi::experimental::is_property_list_v<PropertiesT>>>
367+
constexpr KernelPropertyHolderStructTy
368+
extractKernelProperties(PropertiesT Props) {
369+
static_assert(
370+
!PropertiesT::template has_property<
371+
sycl::ext::intel::experimental::fp_control_key>() ||
372+
(PropertiesT::template has_property<
373+
sycl::ext::intel::experimental::fp_control_key>() &&
374+
IsESIMDKernel),
375+
"Floating point control property is supported for ESIMD kernels only.");
376+
static_assert(
377+
!PropertiesT::template has_property<
378+
sycl::ext::oneapi::experimental::indirectly_callable_key>(),
379+
"indirectly_callable property cannot be applied to SYCL kernels");
380+
381+
return KernelPropertyHolderStructTy(Props);
382+
}
383+
} // namespace kernel_launch_properties_v1
273384

274385
} // namespace detail
275386
} // namespace _V1

sycl/include/sycl/ext/oneapi/experimental/cluster_group_prop.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct cluster_size
2222
cluster_size<Dim>,
2323
::sycl::ext::oneapi::experimental::detail::ClusterLaunch> {
2424
cluster_size(const range<Dim> &size) : size(size) {}
25-
sycl::range<Dim> get_cluster_size() { return size; }
25+
sycl::range<Dim> get_cluster_size() const { return size; }
2626

2727
private:
2828
range<Dim> size;

0 commit comments

Comments
 (0)