Skip to content

Commit 3d1ed39

Browse files
[SYCLomatic] Add 2 cooperative_groups experimental query API mappings. (#2917)
Signed-off-by: Chen, Sheng S <sheng.s.chen@intel.com>
2 parents e637dd9 + 705a3c0 commit 3d1ed39

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#define _CG_ABI_EXPERIMENTAL
2+
3+
#include <cooperative_groups.h>
4+
__device__
5+
void _Copy() {
6+
__shared__ cooperative_groups::experimental::block_tile_memory<8> shared;
7+
// Start
8+
cooperative_groups::thread_block thb = cooperative_groups::experimental::this_thread_block(shared/*cooperative_groups::experimental::block_tile_memory*/);
9+
// End
10+
}
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#define _CG_ABI_EXPERIMENTAL
3+
#include <cuda.h>
4+
#include "cooperative_groups.h"
5+
6+
__device__ void test(cooperative_groups::thread_block tb) {
7+
cooperative_groups::experimental::block_tile_memory<1, 1> mem;
8+
// Start
9+
cooperative_groups::thread_block_tile<32> tbt32 = cooperative_groups::experimental::tiled_partition<32>(tb/*cooperative_groups::thread_block*/);
10+
// End
11+
}

clang/lib/DPCT/DPCT.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,10 @@ int runDPCT(int argc, const char **argv) {
14331433
StringRef ErrStr = Err;
14341434
// Avoid the "Visual Studio version" error on windows platform.
14351435
if (ErrStr.find("error:") == ErrStr.rfind("error:") &&
1436-
ErrStr.contains(
1437-
"error -- unsupported Microsoft Visual Studio version")) {
1436+
(ErrStr.contains("no function template matches function "
1437+
"template specialization 'this_multi_grid'") ||
1438+
ErrStr.contains(
1439+
"error -- unsupported Microsoft Visual Studio version"))) {
14381440
break;
14391441
}
14401442
if (ErrStr.contains("use of undeclared identifier")) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// UNSUPPORTED: system-windows
2+
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v12.1, v12.2, v12.3, v12.4, v12.5, v12.6, v12.7, v12.8, v12.9
3+
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2, cuda-11.0, cuda-12.1, cuda-12.2, cuda-12.3, cuda-12.4, cuda-12.5, cuda-12.6, cuda-12.7, cuda-12.8, cuda-12.9
4+
5+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cooperative_groups::exclusive_scan | FileCheck %s -check-prefix=CG_EXCLUSIVE_SCAN
6+
// CG_EXCLUSIVE_SCAN: CUDA API:
7+
// CG_EXCLUSIVE_SCAN-NEXT: cooperative_groups::exclusive_scan(
8+
// CG_EXCLUSIVE_SCAN-NEXT: tile32 /* type group */, sdata[tid] /* type value */,
9+
// CG_EXCLUSIVE_SCAN-NEXT: cooperative_groups::plus<double>() /* type operator */);
10+
// CG_EXCLUSIVE_SCAN-NEXT: cooperative_groups::exclusive_scan(tile32 /* type group */,
11+
// CG_EXCLUSIVE_SCAN-NEXT sdata[tid] /* type value */);
12+
// CG_EXCLUSIVE_SCAN: Is migrated to:
13+
// CG_EXCLUSIVE_SCAN-NEXT: sycl::exclusive_scan_over_group(sycl::ext::oneapi::this_work_item::get_sub_group(), sdata[tid], sycl::plus<double>());
14+
// CG_EXCLUSIVE_SCAN-NEXT: sycl::exclusive_scan_over_group(sycl::ext::oneapi::this_work_item::get_sub_group(), sdata[tid], sycl::plus<>());
15+
16+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cooperative_groups::experimental::this_thread_block
17+
// CG_EXP_THIS_THREAD_BLOCK: CUDA API:
18+
// CG_EXP_THIS_THREAD_BLOCK-NEXT: cooperative_groups::thread_block thb = cooperative_groups::experimental::this_thread_block(shared/*cooperative_groups::experimental::block_tile_memory*/);
19+
// CG_EXP_THIS_THREAD_BLOCK-NEXT: Is migrated to:
20+
// CG_EXP_THIS_THREAD_BLOCK-NEXT: sycl::group<3> thb = sycl::ext::oneapi::this_work_item::get_work_group<3>();
21+
22+
23+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cooperative_groups::experimental::tiled_partition
24+
// CG_EXP_THIS_TILED_PARTITION: CUDA API:
25+
// CG_EXP_THIS_TILED_PARTITION-NEXT: cooperative_groups::thread_block_tile<32> tbt32 = cooperative_groups::experimental::tiled_partition<32>(tb/*cooperative_groups::thread_block*/);
26+
// CG_EXP_THIS_TILED_PARTITION-NEXT: Is migrated to:
27+
// CG_EXP_THIS_TILED_PARTITION-NEXT: sycl::sub_group tbt32 = sycl::ext::oneapi::this_work_item::get_sub_group();

clang/test/dpct/query_api_mapping/test_all.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@
630630
// CHECK-NEXT: cooperative_groups::coalesced_group::thread_rank
631631
// CHECK-NEXT: cooperative_groups::coalesced_threads
632632
// CHECK-NEXT: cooperative_groups::exclusive_scan
633+
// CHECK-NEXT: cooperative_groups::experimental::this_thread_block
634+
// CHECK-NEXT: cooperative_groups::experimental::tiled_partition
633635
// CHECK-NEXT: cooperative_groups::greater
634636
// CHECK-NEXT: cooperative_groups::grid_group::block_rank
635637
// CHECK-NEXT: cooperative_groups::grid_group::num_blocks

0 commit comments

Comments
 (0)