Skip to content

Commit fd576d3

Browse files
authored
[SYCLomatic] Add query api mapping for 2 cub warpreduce API (#2899)
Signed-off-by: intwanghao <hao3.wang@intel.com>
1 parent 5d261f0 commit fd576d3

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// clang-format off
2+
#include <cstddef>
3+
#include <cub/cub.cuh>
4+
5+
__device__ void test(int thread_data, int valid_items) {
6+
// Start
7+
__shared__ typename cub::WarpReduce<int>::TempStorage temp_storage;
8+
int result1 = cub::WarpReduce<int>(temp_storage).Reduce(thread_data/*int*/, cub::Min()/*ReductionOp*/);
9+
int result2 = cub::WarpReduce<int>(temp_storage).Reduce(thread_data/*int*/, cub::Min()/*ReductionOp*/, valid_items/*int*/);
10+
// End
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// clang-format off
2+
#include <cstddef>
3+
#include <cub/cub.cuh>
4+
5+
__device__ void test(int thread_data, int valid_items) {
6+
// Start
7+
__shared__ typename cub::WarpReduce<int>::TempStorage temp_storage;
8+
int result1 = cub::WarpReduce<int>(temp_storage).Sum(thread_data/*int*/);
9+
int result2 = cub::WarpReduce<int>(temp_storage).Sum(thread_data/*int*/, valid_items/*int*/);
10+
// End
11+
}

clang/test/dpct/query_api_mapping/CUB/cub_warp.cu

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,20 @@
3737
// CHECK_WARPSCAN_BROADCAST: Is migrated to:
3838
// CHECK_WARPSCAN_BROADCAST: sycl::group_broadcast(sycl::ext::oneapi::this_work_item::get_sub_group(), thread_data, 0);
3939

40+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cub::WarpReduce::Sum | FileCheck %s -check-prefix=CHECK_WARPREDUCE_SUM
41+
// CHECK_WARPREDUCE_SUM: CUDA API:
42+
// CHECK_WARPREDUCE_SUM: __shared__ typename cub::WarpReduce<int>::TempStorage temp_storage;
43+
// CHECK_WARPREDUCE_SUM: int result1 = cub::WarpReduce<int>(temp_storage).Sum(thread_data/*int*/);
44+
// CHECK_WARPREDUCE_SUM: int result2 = cub::WarpReduce<int>(temp_storage).Sum(thread_data/*int*/, valid_items/*int*/);
45+
// CHECK_WARPREDUCE_SUM: Is migrated to:
46+
// CHECK_WARPREDUCE_SUM: int result1 = sycl::reduce_over_group(sycl::ext::oneapi::this_work_item::get_sub_group(), thread_data, sycl::plus<>());
47+
// CHECK_WARPREDUCE_SUM: int result2 = dpct::group::reduce_over_partial_group(sycl::ext::oneapi::this_work_item::get_nd_item<3>(), thread_data, valid_items, sycl::plus<>());
48+
49+
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cub::WarpReduce::Reduce | FileCheck %s -check-prefix=CHECK_WARPREDUCE_REDUCE
50+
// CHECK_WARPREDUCE_REDUCE: CUDA API:
51+
// CHECK_WARPREDUCE_REDUCE: __shared__ typename cub::WarpReduce<int>::TempStorage temp_storage;
52+
// CHECK_WARPREDUCE_REDUCE: int result1 = cub::WarpReduce<int>(temp_storage).Reduce(thread_data/*int*/, cub::Min()/*ReductionOp*/);
53+
// CHECK_WARPREDUCE_REDUCE: int result2 = cub::WarpReduce<int>(temp_storage).Reduce(thread_data/*int*/, cub::Min()/*ReductionOp*/, valid_items/*int*/);
54+
// CHECK_WARPREDUCE_REDUCE: Is migrated to:
55+
// CHECK_WARPREDUCE_REDUCE: int result1 = sycl::reduce_over_group(sycl::ext::oneapi::this_work_item::get_sub_group(), thread_data, sycl::minimum<>());
56+
// CHECK_WARPREDUCE_REDUCE: int result2 = dpct::group::reduce_over_partial_group(sycl::ext::oneapi::this_work_item::get_nd_item<3>(), thread_data, valid_items, sycl::minimum<>());

clang/test/dpct/query_api_mapping/test_all.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,8 @@
833833
// CHECK-NEXT: cub::DeviceSelect::Flagged
834834
// CHECK-NEXT: cub::DeviceSelect::If
835835
// CHECK-NEXT: cub::DeviceSelect::Unique
836+
// CHECK-NEXT: cub::WarpReduce::Reduce
837+
// CHECK-NEXT: cub::WarpReduce::Sum
836838
// CHECK-NEXT: cub::WarpScan::Broadcast
837839
// CHECK-NEXT: cub::WarpScan::ExclusiveScan
838840
// CHECK-NEXT: cub::WarpScan::ExclusiveSum

0 commit comments

Comments
 (0)