Skip to content

Commit 57ed3b9

Browse files
author
Yihan Wang
authored
[SYCLomatic #1009] Add test for cub::WarpReduce::Sum(T input, int valid_items) (#367)
Signed-off-by: Wang, Yihan <[email protected]>
1 parent a77f40c commit 57ed3b9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

features/feature_case/cub/cub_warp.cu

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ __global__ void ReduceValidKernel(int* data, int valid_items) {
178178
data[threadid] = output;
179179
}
180180

181+
__global__ void SumValidKernel(int* data, int valid_items) {
182+
typedef cub::WarpReduce<int> WarpReduce;
183+
184+
__shared__ typename WarpReduce::TempStorage temp1;
185+
186+
int threadid = threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.x * blockDim.y + blockIdx.x * blockDim.x * blockDim.y * blockDim.z;
187+
188+
int input = data[threadid];
189+
int output = 0;
190+
output = WarpReduce(temp1).Sum(input, valid_items);
191+
data[threadid] = output;
192+
}
193+
181194
__global__ void ThreadLoadKernel(int* data) {
182195
int threadid = threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.x * blockDim.y + blockIdx.x * blockDim.x * blockDim.y * blockDim.z;
183196

@@ -479,6 +492,18 @@ int main() {
479492
print_data(dev_data, 1);
480493
}
481494

495+
init_data(dev_data, DATA_NUM);
496+
SumValidKernel<<<GridSize, BlockSize>>>(dev_data, valid_items);
497+
cudaDeviceSynchronize();
498+
if(!verify_data(dev_data, expect_valid10, 1, 1)) {
499+
std::cout << "ReduceValidKernel" << " verify failed" << std::endl;
500+
Result = false;
501+
std::cout << "expect:" << std::endl;
502+
print_data(expect10, 1);
503+
std::cout << "current result:" << std::endl;
504+
print_data(dev_data, 1);
505+
}
506+
482507
GridSize = {2};
483508
BlockSize = {16, 8, 1};
484509
int expect11[DATA_NUM] = {

0 commit comments

Comments
 (0)