Skip to content

Commit

Permalink
clean up pass
Browse files Browse the repository at this point in the history
  • Loading branch information
artv3 committed Dec 23, 2024
1 parent 28e714d commit fc1f6a8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions examples/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
const int M = 2;

// Allocate memory for pointer
int *Right_ptr = memoryManager::allocate<int>(K * N * M);
int *Left_ptr = memoryManager::allocate<int>(K * N * M );
int *Rptr = memoryManager::allocate<int>(K * N * M);
int *Lptr = memoryManager::allocate<int>(K * N * M);

//----------------------------------------------------------------------------//
//
// Initialize memory using right most unit stride
//
//----------------------------------------------------------------------------//
std::cout << "\n\nInitialize array with right most indexing...\n";
auto Rview = RAJA::Reshape<RAJA::layout_right>::get(Right_ptr, K, N, M);
auto Rview = RAJA::Reshape<RAJA::layout_right>::get(Rptr, K, N, M);

for(int k = 0; k < K; ++k) {
for(int n = 0; n < N; ++n) {
Expand All @@ -72,7 +72,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
}
}

checkResult(Right_ptr, K, N, M);
checkResult(Rptr, K, N, M);


//----------------------------------------------------------------------------//
Expand All @@ -82,7 +82,7 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
//----------------------------------------------------------------------------//
std::cout << "\n\nInitialize array with left most indexing...\n";

auto Lview = RAJA::Reshape<RAJA::layout_left>::get(Left_ptr, K, N, M);
auto Lview = RAJA::Reshape<RAJA::layout_left>::get(Lptr, K, N, M);

//Note the loop ordering has change from above
for(int m = 0; m < M; ++m) {
Expand All @@ -95,13 +95,13 @@ int main(int RAJA_UNUSED_ARG(argc), char **RAJA_UNUSED_ARG(argv[]))
}
}

checkResult(Right_ptr, K, N, M);
checkResult(Lptr, K, N, M);

//
// Clean up.
//
memoryManager::deallocate(Right_ptr);
memoryManager::deallocate(Left_ptr);
memoryManager::deallocate(Rptr);
memoryManager::deallocate(Lptr);

std::cout << "\n DONE!...\n";
return 0;
Expand Down

0 comments on commit fc1f6a8

Please sign in to comment.