File tree 3 files changed +37
-20
lines changed 3 files changed +37
-20
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ if (NOT MSVC AND UR_SANITIZER_INCLUDE_DIR)
245
245
include /asan_rtl.hpp
246
246
include /sanitizer_defs.hpp
247
247
include /spir_global_var.hpp
248
+ include /group_utils.hpp
248
249
${sycl-compiler_deps})
249
250
250
251
set (sanitizer_generic_compile_opts ${compile_opts}
@@ -303,6 +304,7 @@ if (NOT MSVC AND UR_SANITIZER_INCLUDE_DIR)
303
304
include /msan_rtl.hpp
304
305
include /sanitizer_defs.hpp
305
306
include /spir_global_var.hpp
307
+ include /group_utils.hpp
306
308
sycl-compiler)
307
309
308
310
set (tsan_obj_deps
@@ -311,6 +313,7 @@ if (NOT MSVC AND UR_SANITIZER_INCLUDE_DIR)
311
313
include /tsan_rtl.hpp
312
314
include /sanitizer_defs.hpp
313
315
include /spir_global_var.hpp
316
+ include /group_utils.hpp
314
317
sycl-compiler)
315
318
endif ()
316
319
Original file line number Diff line number Diff line change
1
+ // ==------------------ group_utils.hpp - utils for group -------------------==//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+ #pragma once
9
+
10
+ #include " spirv_vars.h"
11
+
12
+ #if defined(__SPIR__) || defined(__SPIRV__)
13
+
14
+ static inline size_t WorkGroupLinearId () {
15
+ return __spirv_BuiltInWorkgroupId.x * __spirv_BuiltInNumWorkgroups.y *
16
+ __spirv_BuiltInNumWorkgroups.z +
17
+ __spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
18
+ __spirv_BuiltInWorkgroupId.z ;
19
+ }
20
+
21
+ // For GPU device, each sub group is a hardware thread
22
+ static inline size_t SubGroupLinearId () {
23
+ return __spirv_BuiltInGlobalLinearId / __spirv_BuiltInSubgroupSize;
24
+ }
25
+
26
+ static inline void SubGroupBarrier () {
27
+ __spirv_ControlBarrier (__spv::Scope::Subgroup, __spv::Scope::Subgroup,
28
+ __spv::MemorySemanticsMask::SequentiallyConsistent |
29
+ __spv::MemorySemanticsMask::CrossWorkgroupMemory |
30
+ __spv::MemorySemanticsMask::WorkgroupMemory);
31
+ }
32
+
33
+ #endif // __SPIR__ || __SPIRV__
Original file line number Diff line number Diff line change 8
8
#pragma once
9
9
10
10
#include " atomic.hpp"
11
+ #include " group_utils.hpp"
11
12
#include " spir_global_var.hpp"
12
- #include " spirv_vars.h"
13
13
#include < cstdint>
14
14
15
15
using uptr = uintptr_t ;
@@ -66,23 +66,4 @@ __SYCL_PRIVATE__ void *ToPrivate(void *ptr) {
66
66
return __spirv_GenericCastToPtrExplicit_ToPrivate (ptr, 7 );
67
67
}
68
68
69
- size_t WorkGroupLinearId () {
70
- return __spirv_BuiltInWorkgroupId.x * __spirv_BuiltInNumWorkgroups.y *
71
- __spirv_BuiltInNumWorkgroups.z +
72
- __spirv_BuiltInWorkgroupId.y * __spirv_BuiltInNumWorkgroups.z +
73
- __spirv_BuiltInWorkgroupId.z ;
74
- }
75
-
76
- // For GPU device, each sub group is a hardware thread
77
- size_t SubGroupLinearId () {
78
- return __spirv_BuiltInGlobalLinearId / __spirv_BuiltInSubgroupSize;
79
- }
80
-
81
- void SubGroupBarrier () {
82
- __spirv_ControlBarrier (__spv::Scope::Subgroup, __spv::Scope::Subgroup,
83
- __spv::MemorySemanticsMask::SequentiallyConsistent |
84
- __spv::MemorySemanticsMask::CrossWorkgroupMemory |
85
- __spv::MemorySemanticsMask::WorkgroupMemory);
86
- }
87
-
88
69
#endif // __SPIR__ || __SPIRV__
You can’t perform that action at this time.
0 commit comments