Skip to content
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

ENH: make FOR_FIRST arguments consistent with other FORs #101

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions examples/main_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ int main(int argc, char* argv[])
FOR_ALL(i_i, 0, hiersize, j_j, 0, hiersize, k_k, 0, hiersize, {
hierTest3D(i_i, j_j, k_k) = 0.0;
});
FOR_FIRST(i_i,hiersize, {
FOR_FIRST(i_i, 0, hiersize, {
// Kokkos::parallel_for( \
//Kokkos::TeamPolicy<>( 32, Kokkos::AUTO, 32 ), \
//KOKKOS_LAMBDA ( const Kokkos::TeamPolicy<>::member_type &teamMember ) {
Expand Down Expand Up @@ -908,7 +908,7 @@ int main(int argc, char* argv[])

printf("\n\n\nHierarchical Reduce\n");
//2D nesting
FOR_FIRST(i_i,hiersize, {
FOR_FIRST(i_i, 0, hiersize, {
// Kokkos::parallel_for( \
//Kokkos::TeamPolicy<>( 32, Kokkos::AUTO, 32 ), \
//KOKKOS_LAMBDA ( const Kokkos::TeamPolicy<>::member_type &teamMember ) {
Expand Down Expand Up @@ -936,29 +936,29 @@ int main(int argc, char* argv[])

printf("\n\n\nHierarchical Vectorized Reduce\n");
//3D vector nesting
FOR_FIRST(i_i,hiersize, {
FOR_FIRST(i_i, 1, hiersize+1, {
// Kokkos::parallel_for( \
//Kokkos::TeamPolicy<>( 32, Kokkos::AUTO, 32 ), \
//KOKKOS_LAMBDA ( const Kokkos::TeamPolicy<>::member_type &teamMember ) {
//const int i_i = TEAM_ID;
double result = 0;
double lsum;
FOR_SECOND(j_j, i_i, hiersize, {
FOR_SECOND(j_j, i_i-1, hiersize, {
// Kokkos::parallel_for( \
//Kokkos::TeamThreadRange( teamMember, istart, iend ), [&] ( const int (j_j) ) {
// hierTest2D(i_i,j_j) = i_i * (j_j+1);
// int jstart = j_j*32;
// int jend = (j_j+1)*32;
FOR_REDUCE_SUM_THIRD(k_k, i_i, j_j, lsum, {
lsum += hierTest3D(i_i,j_j,k_k);
FOR_REDUCE_SUM_THIRD(k_k, i_i-1, j_j, lsum, {
lsum += hierTest3D(i_i-1,j_j,k_k);
// Kokkos::parallel_for( \
//Kokkos::TeamThreadRange( teamMember, istart, iend ), [&] ( const int (j_j) ) {
// hierTest2D(i_i,j_j) = i_i * (j_j+1);
// int jstart = j_j*32;
// int jend = (j_j+1)*32;
}, result);
hierTest2D(i_i,j_j)= result;
//printf("value at %d , %d is %f\n", i_i, j_j, hierTest2D(i_i,j_j));
hierTest2D(i_i-1,j_j)= result;
printf("value at %d , %d is %f\n", i_i, j_j, hierTest2D(i_i-1,j_j));
});
});
Kokkos::fence();
Expand Down
6 changes: 3 additions & 3 deletions src/include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ THREAD_ID \
teamMember.team_rank()

#define \
FOR_FIRST(i, x1, fcn) \
FOR_FIRST(i, x0, x1, fcn) \
Kokkos::parallel_for( \
Kokkos::TeamPolicy<>( x1, Kokkos::AUTO, 32 ), \
Kokkos::TeamPolicy<>( x1-x0, Kokkos::AUTO, 32 ), \
KOKKOS_LAMBDA ( const Kokkos::TeamPolicy<>::member_type &teamMember ) \
{ const int i = TEAM_ID; fcn} )
{ const int i = TEAM_ID + x0; fcn} )

#define \
FOR_SECOND(j, y0, y1, fcn) \
Expand Down
Loading