File tree Expand file tree Collapse file tree 3 files changed +37
-20
lines changed Expand file tree Collapse file tree 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)
245245 include /asan_rtl.hpp
246246 include /sanitizer_defs.hpp
247247 include /spir_global_var.hpp
248+ include /group_utils.hpp
248249 ${sycl-compiler_deps})
249250
250251 set (sanitizer_generic_compile_opts ${compile_opts}
@@ -303,6 +304,7 @@ if (NOT MSVC AND UR_SANITIZER_INCLUDE_DIR)
303304 include /msan_rtl.hpp
304305 include /sanitizer_defs.hpp
305306 include /spir_global_var.hpp
307+ include /group_utils.hpp
306308 sycl-compiler)
307309
308310 set (tsan_obj_deps
@@ -311,6 +313,7 @@ if (NOT MSVC AND UR_SANITIZER_INCLUDE_DIR)
311313 include /tsan_rtl.hpp
312314 include /sanitizer_defs.hpp
313315 include /spir_global_var.hpp
316+ include /group_utils.hpp
314317 sycl-compiler)
315318endif ()
316319
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 88#pragma once
99
1010#include " atomic.hpp"
11+ #include " group_utils.hpp"
1112#include " spir_global_var.hpp"
12- #include " spirv_vars.h"
1313#include < cstdint>
1414
1515using uptr = uintptr_t ;
@@ -66,23 +66,4 @@ __SYCL_PRIVATE__ void *ToPrivate(void *ptr) {
6666 return __spirv_GenericCastToPtrExplicit_ToPrivate (ptr, 7 );
6767}
6868
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-
8869#endif // __SPIR__ || __SPIRV__
You can’t perform that action at this time.
0 commit comments