Skip to content

Commit

Permalink
fixup: use Kokkos::Array for sparse benchmark particle creation
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Aug 2, 2023
1 parent 277cf95 commit 64f1001
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions benchmark/cajita/Cajita_SparseMapPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
// Declare the size (cell nums) of the domain
int num_cells_per_dim_size = num_cells_per_dim.size();

// Copy corners to device arrays.
Kokkos::Array<float, 3> global_high_kokkos;
Kokkos::Array<float, 3> global_low_kokkos;
for ( std::size_t d = 0; d < 3; ++d )
{
global_low_kokkos[d] = global_low_corner[d];
global_high_kokkos[d] = global_high_corner[d];
}

// Create random sets of particle positions.
using position_type = Kokkos::View<float* [3], memory_space>;
std::vector<position_type> positions( num_problem_size );
Expand All @@ -54,8 +63,8 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
Kokkos::ViewAllocateWithoutInitializing( "positions" ),
problem_sizes[p] );
Cabana::createParticles( Cabana::InitRandom(), positions[p],
problem_sizes[p], global_low_corner,
global_high_corner );
problem_sizes[p], global_low_kokkos,
global_high_kokkos );
}
// Number of runs in the test loops.
int num_run = 10;
Expand Down
13 changes: 11 additions & 2 deletions benchmark/cajita/Cajita_SparsePartitionerPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ void performanceTest( ParticleWorkloadTag, std::ostream& stream, MPI_Comm comm,
int max_par_num = problem_sizes.back() / comm_size +
( problem_sizes.back() % comm_size < comm_rank ? 1 : 0 );

// Copy corners to device arrays.
Kokkos::Array<float, 3> global_high_kokkos;
Kokkos::Array<float, 3> global_low_kokkos;
for ( std::size_t d = 0; d < 3; ++d )
{
global_low_kokkos[d] = global_low_corner[d];
global_high_kokkos[d] = global_high_corner[d];
}

// Create random sets of particle positions.
using position_type = Kokkos::View<float* [3], memory_space>;
std::vector<position_type> positions( num_problem_size );
Expand All @@ -130,8 +139,8 @@ void performanceTest( ParticleWorkloadTag, std::ostream& stream, MPI_Comm comm,
Kokkos::ViewAllocateWithoutInitializing( "positions" ),
problem_sizes[p] );
Cabana::createParticles( Cabana::InitRandom(), positions[p],
problem_sizes[p], global_low_corner,
global_high_corner );
problem_sizes[p], global_low_kokkos,
global_high_kokkos );
}

for ( int c = 0; c < num_cells_per_dim_size; ++c )
Expand Down

0 comments on commit 64f1001

Please sign in to comment.