Skip to content

Commit

Permalink
Merge pull request #101 from Adrian-Diaz/Adrian's-Branch
Browse files Browse the repository at this point in the history
ENH: make FOR_FIRST arguments consistent with other FORs
  • Loading branch information
Adrian-Diaz authored Oct 3, 2024
2 parents d7ecb7f + 1e26051 commit d5bf5c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit d5bf5c7

Please sign in to comment.