-
Notifications
You must be signed in to change notification settings - Fork 6
CabanaSliceFactory now works with multiple types. #3
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
Changes from 5 commits
34177d0
8a49253
7009fba
9c8249d
d62a009
790cedd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,34 +3,37 @@ | |
| int main(int argc, char* argv[]) { | ||
| // AoSoA parameters | ||
| const int vecLen = 4; | ||
|
Contributor
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. Should this still be here?
Contributor
Author
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. nope. It will be removed in the next version |
||
| const int width = 1; | ||
| int num_tuples = 10; | ||
|
|
||
| Kokkos::ScopeGuard scope_guard(argc, argv); | ||
|
|
||
| using member_type = double; | ||
| using DataTypes = Cabana::MemberTypes<member_type[width]>; | ||
| using ExecutionSpace = Kokkos::Cuda; | ||
HazelCullom marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| using MemorySpace = Kokkos::CudaSpace; | ||
|
|
||
|
|
||
| // Slice Wrapper Factory | ||
| CabSliceFactory<ExecutionSpace, MemorySpace, | ||
| member_type, width, vecLen> cabSliceFactory(num_tuples); | ||
| vecLen, double, int, float, char> cabSliceFactory(num_tuples); | ||
|
|
||
| auto slice_wrapper = cabSliceFactory.makeSliceCab(); | ||
| auto slice_wrapper0 = cabSliceFactory.makeSliceCab<0>(); | ||
| auto slice_wrapper1 = cabSliceFactory.makeSliceCab<1>(); | ||
| auto slice_wrapper2 = cabSliceFactory.makeSliceCab<2>(); | ||
| auto slice_wrapper3 = cabSliceFactory.makeSliceCab<3>(); | ||
|
|
||
| // simd_parallel_for setup | ||
| Cabana::SimdPolicy<vecLen, ExecutionSpace> simd_policy(0, num_tuples); | ||
|
Contributor
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. Can we eliminate the
Contributor
Author
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. done! |
||
|
|
||
| // kernel that reads and writes | ||
| auto vector_kernel = KOKKOS_LAMBDA(const int s, const int a) { | ||
| for (int i = 0; i < width; i++) { | ||
| printf("s: %d, a: %d, i: %d\n", s,a,i); | ||
| double x = 42/(s+a+1.3); | ||
| slice_wrapper.access(s,a,i) = x; | ||
| printf("value: %lf\n", slice_wrapper.access(s,a,i)); | ||
| } | ||
| printf("s: %d, a: %d\n", s,a); | ||
| double x = 42/(s+a+1.3); | ||
| slice_wrapper0.access(s,a) = x; | ||
| slice_wrapper1.access(s,a) = s+a; | ||
| slice_wrapper2.access(s,a) = float(x); | ||
| slice_wrapper3.access(s,a) = 'a'+s+a; | ||
| printf("SW0 value: %lf\n", slice_wrapper0.access(s,a)); | ||
| printf("SW1 value: %d\n", slice_wrapper1.access(s,a)); | ||
| printf("SW2 value: %f\n", slice_wrapper2.access(s,a)); | ||
| printf("SW3 value: %c\n", slice_wrapper3.access(s,a)); | ||
| }; | ||
|
|
||
| Cabana::simd_parallel_for(simd_policy, vector_kernel, "parallel_for_cabSliceFactory"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.