Skip to content

Commit e1aeee2

Browse files
authored
[SYCLomatic] Add the cooperative_groups::this_thread migration. (#2783)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
1 parent 7a28a5b commit e1aeee2

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

clang/lib/DPCT/RulesLang/APINamesCooperativeGroups.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ CONDITIONAL_FACTORY_ENTRY(
192192
UNSUPPORT_FACTORY_ENTRY("tiled_partition", Diagnostics::API_NOT_MIGRATED,
193193
ARG("tiled_partition")))
194194

195+
CONDITIONAL_FACTORY_ENTRY(
196+
UseLogicalGroup,
197+
FEATURE_REQUEST_FACTORY(
198+
HelperFeatureEnum::device_ext,
199+
CALL_FACTORY_ENTRY("this_thread",
200+
CALL(MapNames::getDpctNamespace() +
201+
"experimental::logical_group",
202+
NDITEM, GROUP, ARG("1")))),
203+
UNSUPPORT_FACTORY_ENTRY("this_thread",
204+
Diagnostics::TRY_EXPERIMENTAL_FEATURE,
205+
ARG("this_thread"),
206+
ARG("--use-experimental-features=logical-group")))
207+
195208
CONDITIONAL_FACTORY_ENTRY(
196209
UseNonUniformGroups,
197210
CALL_FACTORY_ENTRY(

clang/lib/DPCT/RulesLang/MapNamesLang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ const std::vector<std::string> MemoryDataTypeRule::RemoveMember{
308308
const std::unordered_set<std::string> MapNamesLang::CooperativeGroupsAPISet{
309309
"this_thread_block",
310310
"this_grid",
311+
"this_thread",
311312
"sync",
312313
"tiled_partition",
313314
"thread_rank",

clang/lib/DPCT/RulesLang/RulesLangCooperativeGroups.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void CooperativeGroupsFunctionRule::runRule(
119119
FuncName == "num_threads" || FuncName == "inclusive_scan" ||
120120
FuncName == "exclusive_scan" || FuncName == "coalesced_threads" ||
121121
FuncName == "this_grid" || FuncName == "num_blocks" ||
122-
FuncName == "block_rank") {
122+
FuncName == "block_rank" || FuncName == "this_thread") {
123123
// There are 3 usages of cooperative groups APIs.
124124
// 1. cg::thread_block tb; tb.sync(); // member function
125125
// 2. cg::thread_block tb; cg::sync(tb); // free function

clang/lib/DPCT/SrcAPI/APINames.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ ENTRY(cuGraphicsResourceGetMappedEglFrame, cuGraphicsResourceGetMappedEglFrame,
21362136
// Coopeartive_group migration.
21372137
ENTRY(cooperative_groups::coalesced_threads, cooperative_groups::__v1::coalesced_threads, true, NO_FLAG, P4, "Successful/DPCT1119")
21382138
ENTRY(cooperative_groups::thread_rank, cooperative_groups::__v1::thread_rank, true, NO_FLAG, P4, "Successful")
2139-
ENTRY(cooperative_groups::this_thread, cooperative_groups::__v1::this_thread, false, NO_FLAG, P4, "comment")
2139+
ENTRY(cooperative_groups::this_thread, cooperative_groups::__v1::this_thread, true, NO_FLAG, P4, "Successful/DPCT1119")
21402140
ENTRY(cooperative_groups::this_grid, cooperative_groups::__v1::this_grid, true, NO_FLAG, P4, "Successful")
21412141
ENTRY(cooperative_groups::this_multi_grid, cooperative_groups::__v1::this_multi_grid, false, NO_FLAG, P4, "comment")
21422142
ENTRY(cooperative_groups::this_thread_block, cooperative_groups::__v1::this_thread_block, true, NO_FLAG, P4, "Successful")

clang/test/dpct/sync_api_nd_range_barrier.cu

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,8 @@ int foo3() {
205205
// CHECK-NEXT: const sycl::group<3> *cptb);
206206
__device__ void foo4(const cg::thread_block &crtb,
207207
const cg::thread_block *cptb);
208+
209+
__device__ void foo5() {
210+
// CHECK: auto thread = dpct::experimental::logical_group(item_ct1, item_ct1.get_group(), 1);
211+
auto thread = cg::this_thread();
212+
}

0 commit comments

Comments
 (0)