-
Notifications
You must be signed in to change notification settings - Fork 2
Lesson 10: Launch - Matrix transpose #42
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b39b751
add launch lesson
johnbowen42 3ae1808
add cmake command
johnbowen42 cf67729
Updates to Launch transpose.
rchen20 915c347
Merge branch 'main' into bowen/launch-kernel
artv3 dd92090
remove old files, rename lesson 10
artv3 f0cc11f
update files
artv3 ae3c43b
file name update
artv3 0448e38
add working version of launch matrix transpose
artv3 38daada
clean up pass to exercise
artv3 b7c5ceb
fix up readme
artv3 866411d
clean up pass
artv3 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
47 changes: 47 additions & 0 deletions
47
Intro_Tutorial/lessons/12_raja_device_kernel_complete/12_raja_launch_transpose.cpp
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,47 @@ | ||
| #include <iostream> | ||
|
|
||
| #include "RAJA/RAJA.hpp" | ||
| #include "umpire/Umpire.hpp" | ||
| #include "umpire/strategy/QuickPool.hpp" | ||
|
|
||
| int main() | ||
| { | ||
| #if defined (COMPILE) | ||
| constexpr int N{10000}; | ||
| constexpr int M{7000}; | ||
| double* a{nullptr}; | ||
| double* a_t{nullptr}; | ||
|
|
||
| auto& rm = umpire::ResourceManager::getInstance(); | ||
|
|
||
| auto allocator = rm.getAllocator("UM"); | ||
| auto pool = rm.makeAllocator<umpire::strategy::QuickPool>("POOL", allocator); | ||
|
|
||
| a = static_cast<double *>(pool.allocate(N*M*sizeof(double))); | ||
| a_t = static_cast<double *>(pool.allocate(N*M*sizeof(double))); | ||
|
|
||
| constexpr int DIM = 2; | ||
|
|
||
| RAJA::View<double, RAJA::Layout<DIM>> A(a, N, M); | ||
| RAJA::View<double, RAJA::Layout<DIM>> A_t(a_t, M, N); | ||
|
|
||
| using EXEC_POL = | ||
| RAJA::cuda_launch_t<false>; | ||
| using teams_x = /*what policy do we need here?*/ | ||
| using threads_x = /*what loop policy do we need here?*/ | ||
artv3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| RAJA::launch<EXEC_POL>(RAJA::ExecPlace::DEVICE, | ||
| /*What type of parameters do we need to specify bounds*/, | ||
| [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { | ||
| RAJA::loop<teams_x>(ctx, col_range, [&] (int col) { | ||
| RAJA::loop<threads_x>(ctx, row_range, [&] (int row) { | ||
| A_t(col, row) = A(row, col); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| pool.deallocate(a); | ||
| pool.deallocate(a_t); | ||
| #endif | ||
| return 0; | ||
| } | ||
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
46 changes: 46 additions & 0 deletions
46
...ial/lessons/12_raja_device_kernel_complete/solution/12_raja_launch_transpose_solution.cpp
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,46 @@ | ||
| #include <iostream> | ||
|
|
||
| #include "RAJA/RAJA.hpp" | ||
| #include "umpire/Umpire.hpp" | ||
| #include "umpire/strategy/QuickPool.hpp" | ||
|
|
||
| int main() | ||
| { | ||
| constexpr int N{10000}; | ||
| constexpr int M{7000}; | ||
| double* a{nullptr}; | ||
| double* a_t{nullptr}; | ||
|
|
||
| auto& rm = umpire::ResourceManager::getInstance(); | ||
|
|
||
| auto allocator = rm.getAllocator("UM"); | ||
| auto pool = rm.makeAllocator<umpire::strategy::QuickPool>("POOL", allocator); | ||
|
|
||
| a = static_cast<double *>(pool.allocate(N*M*sizeof(double))); | ||
| a_t = static_cast<double *>(pool.allocate(N*M*sizeof(double))); | ||
|
|
||
| constexpr int DIM = 2; | ||
|
|
||
| RAJA::View<double, RAJA::Layout<DIM>> A(a, N, M); | ||
| RAJA::View<double, RAJA::Layout<DIM>> A_t(a_t, M, N); | ||
|
|
||
| using EXEC_POL = | ||
| RAJA::cuda_launch_t<false>; | ||
| using teams_x = RAJA::cuda_block_x_direct; | ||
| using threads_x = RAJA::cuda_thread_x_loop; | ||
artv3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| RAJA::launch<EXEC_POL>(RAJA::ExecPlace::DEVICE, | ||
artv3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RAJA::LaunchParams(RAJA::Teams(N), RAJA::Threads(M)), | ||
| [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { | ||
| RAJA::loop<teams_x>(ctx, col_range, [&] (int col) { | ||
| RAJA::loop<threads_x>(ctx, row_range, [&] (int row) { | ||
| A_t(col, row) = A(row, col); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| pool.deallocate(a); | ||
| pool.deallocate(a_t); | ||
|
|
||
| return 0; | ||
| } | ||
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.