-
Notifications
You must be signed in to change notification settings - Fork 96
[SYCLomatic] Support migration for cub::{StoreDirectBlocked, StoreDirectStriped} API #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
abhilash1910
wants to merge
23
commits into
oneapi-src:SYCLomatic
from
abhilash1910:blockload_support
Closed
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d842dfe
cub::blockload migration
abhilash1910 c014557
add blockload + fix
abhilash1910 aadbb89
add block load sample
abhilash1910 3e83abb
add line
abhilash1910 c856837
add prototype kernel api
abhilash1910 8b66f8e
fix bugs
abhilash1910 8b5589a
fix bugs
abhilash1910 7841813
Merge branch 'oneapi-src:SYCLomatic' into blockload_support
abhilash1910 ea33c67
Merge branch 'oneapi-src:SYCLomatic' into blockload_support
abhilash1910 f190341
Merge branch 'oneapi-src:SYCLomatic' into blockload_support
abhilash1910 d0a0e8b
modify to store
abhilash1910 b336ff2
add store rewriter
abhilash1910 2550602
revert changes
abhilash1910 7efbc81
revert changes
abhilash1910 5f7d10b
fix issue
abhilash1910 3b0494f
remove manual parsing
abhilash1910 d2ad0e5
Update APINames_CUB.inc
abhilash1910 9993f85
fix test
abhilash1910 a064b46
format fix
abhilash1910 23735aa
add newline
abhilash1910 5fc94c6
fix include file
abhilash1910 fd9c641
fix blank line
abhilash1910 ee15a11
Merge branch 'SYCLomatic' into blockload_support
abhilash1910 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,7 +107,6 @@ ENTRY_MEMBER_FUNCTION(cub::BlockExchange, cub::BlockExchange, ScatterToStripedFl | |
ENTRY_MEMBER_FUNCTION(cub::BlockHistogram, cub::BlockHistogram, InitHistogram, InitHistogram, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockHistogram, cub::BlockHistogram, Histogram, Histogram, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockHistogram, cub::BlockHistogram, Composite, Composite, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockLoad, cub::BlockLoad, Load, Load, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockStore, cub::BlockStore, Store, Store, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockRadixSort, cub::BlockRadixSort, Sort, Sort, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockRadixSort, cub::BlockRadixSort, SortDescending, SortDescending, false, NO_FLAG, P4, "Comment") | ||
|
@@ -123,6 +122,7 @@ ENTRY_MEMBER_FUNCTION(cub::BlockShuffle, cub::BlockShuffle, Offset, Offset, fals | |
ENTRY_MEMBER_FUNCTION(cub::BlockShuffle, cub::BlockShuffle, Rotate, Rotate, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockShuffle, cub::BlockShuffle, Up, Up, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockShuffle, cub::BlockShuffle, Down, Down, false, NO_FLAG, P4, "Comment") | ||
ENTRY_MEMBER_FUNCTION(cub::BlockLoad, cub::BlockLoad, Load, Load, true, NO_FLAG, P4, "Successful") | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove extra blank line change. |
||
// Device Level | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2 | ||
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2 | ||
// RUN: dpct -in-root %S -out-root %T/blocklevel/blockload %S/blockload.cu --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only | ||
// RUN: FileCheck --input-file %T/blocklevel/blockscan/blockload.dp.cpp --match-full-lines %s | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <cuda_runtime.h> | ||
#include <cub/cub.cuh> | ||
|
||
#define WARP_SIZE 32 | ||
|
||
const int N = 256; | ||
const int BlockSize = 128; | ||
const int ItemsPerThread = 4; | ||
|
||
|
||
void init_data(int* data, int num) { | ||
for(int i = 0; i < num; i++) | ||
data[i] = i; | ||
} | ||
void verify_data(int* data, int num) { | ||
return; | ||
} | ||
void print_data(int* data, int num) { | ||
for (int i = 0; i < num; i++) { | ||
std::cout << data[i] << " "; | ||
} | ||
std::cout << std::endl; | ||
} | ||
|
||
//CHECK: void SumKernel(int* data, | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//CHECK-NEXT: const sycl::nd_item<3> &item_ct1) { | ||
//CHECK-EMPTY: | ||
//CHECK-NEXT: int threadid = item_ct1.get_local_id(2); | ||
//CHECK-EMPTY: | ||
//CHECK-NEXT: int input = data[threadid]; | ||
//CHECK-NEXT: int output = 0; | ||
//CHECK-NEXT: output = sycl::reduce_over_group(item_ct1.get_group(), input, sycl::plus<>()); | ||
//CHECK-NEXT: data[threadid] = output; | ||
//CHECK-NEXT:} | ||
|
||
__global__ void BlockLoadKernel(int *d_data) | ||
{ | ||
// Specialize BlockLoad for a 1D block of 128 threads owning 4 integer items each | ||
typedef cub::BlockLoad<int, BlockSize, ItemsPerThread, cub::BLOCK_LOAD_WARP_TRANSPOSE> BlockLoad; | ||
// Allocate shared memory for BlockLoad | ||
__shared__ typename BlockLoad::TempStorage temp_storage; | ||
// Load a segment of consecutive items that are blocked across threads | ||
int thread_data[ItemsPerThread]; | ||
int offset = threadIdx.x * ItemsPerThread; | ||
BlockLoad(temp_storage).Load(d_data + offset, thread_data); | ||
|
||
// Print loaded data | ||
printf("Thread %d loaded: %d %d %d %d\n", threadIdx.x, thread_data[0], thread_data[1], thread_data[2], thread_data[3]); | ||
} | ||
|
||
int main() | ||
{ | ||
int h_data[N]; | ||
init_data(h_data, N); | ||
int *d_data; | ||
cudaMalloc((void**)&d_data, N * sizeof(int)); | ||
cudaMemcpy(d_data, h_data, N * sizeof(int), cudaMemcpyHostToDevice); | ||
|
||
//CHECK: q_ct1.parallel_for( | ||
//CHECK-NEXT: sycl::nd_range<3>(GridSize * BlockSize, BlockSize), | ||
//CHECK-NEXT: [=](sycl::nd_item<3> item_ct1) { | ||
//CHECK-NEXT: BlockLoadKernel(dev_data, item_ct1); | ||
//CHECK-NEXT: }); | ||
|
||
dim3 block(BlockSize); | ||
dim3 grid((N + BlockSize - 1) / BlockSize); | ||
|
||
BlockLoadKernel<<<grid, block>>>(d_data); | ||
cudaDeviceSynchronize(); | ||
//verify_data(d_data, N); | ||
|
||
cudaFree(d_data); | ||
|
||
return 0; | ||
} | ||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.