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

Update benchmark plotting scripts #703

Merged
merged 16 commits into from
Sep 19, 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
5 changes: 4 additions & 1 deletion benchmark/core/Cabana_BinSortPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ int main( int argc, char* argv[] )
if ( argc > 2 )
run_type = argv[2];
std::vector<int> problem_sizes = { 1000, 10000 };
std::vector<int> host_problem_sizes = problem_sizes;
std::vector<int> num_bins = { 10, 100, 1000, 10000 };
if ( run_type == "large" )
{
problem_sizes = { 1000, 10000, 100000, 1000000, 10000000 };
host_problem_sizes = { 1000, 10000, 100000 };
num_bins = { 10, 100, 1000, 10000, 100000, 1000000, 10000000 };
}

Expand All @@ -227,7 +229,8 @@ int main( int argc, char* argv[] )
performanceTest<device_type>( file, "device_", problem_sizes,
num_bins );
}
performanceTest<host_device_type>( file, "host_", problem_sizes, num_bins );
performanceTest<host_device_type>( file, "host_", host_problem_sizes,
num_bins );

// Close the output file on rank 0.
file.close();
Expand Down
9 changes: 6 additions & 3 deletions benchmark/core/Cabana_LinkedCellPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,13 @@ int main( int argc, char* argv[] )
if ( argc > 2 )
run_type = argv[2];
std::vector<int> problem_sizes = { 100, 1000 };
std::vector<int> host_problem_sizes = problem_sizes;
std::vector<double> cutoff_ratios = { 3.0, 4.0 };
if ( run_type == "large" )
problem_sizes = { 1000, 10000, 100000, 1000000 };

{
problem_sizes = { 1000, 10000, 100000, 1000000, 10000000, 100000000 };
host_problem_sizes = { 1000, 10000, 100000 };
}
// Open the output file on rank 0.
std::fstream file;
file.open( filename, std::fstream::out );
Expand All @@ -211,7 +214,7 @@ int main( int argc, char* argv[] )
performanceTest<device_type>( file, "device_", problem_sizes,
cutoff_ratios );
}
performanceTest<host_device_type>( file, "host_", problem_sizes,
performanceTest<host_device_type>( file, "host_", host_problem_sizes,
cutoff_ratios );

// Close the output file on rank 0.
Expand Down
44 changes: 42 additions & 2 deletions benchmark/core/Cabana_NeighborArborXPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,49 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
// Create the neighbor list.
double cutoff = cutoff_ratios[c];
create_timer.start( pid );

// Note: this needs to match the neighbor function used below
// (only necessary for the neighbor statistics printing).
using neigh_type =
Cabana::Experimental::Dense<memory_space, ListTag>;

auto const nlist = Cabana::Experimental::make2DNeighborList(
ListTag{}, Cabana::slice<0>( aosoas[p], "position" ), 0,
num_p, cutoff );
create_timer.stop( pid );

// Print neighbor statistics once per system.
if ( t == 0 )
{
std::size_t max_neigh;
Kokkos::Max<std::size_t> max_reducer( max_neigh );
std::size_t min_neigh;
Kokkos::Min<std::size_t> min_reducer( min_neigh );
std::size_t total_neigh;
Kokkos::Sum<std::size_t> total_reducer( total_neigh );
Kokkos::parallel_reduce(
"Cabana::Benchmark::countNeighbors", policy,
KOKKOS_LAMBDA( const int p, std::size_t& min,
std::size_t& max, std::size_t& sum ) {
auto const val =
Cabana::NeighborList<neigh_type>::numNeighbor(
nlist, p );
if ( val < min )
min = val;
if ( val > max )
max = val;
sum += val;
},
min_reducer, max_reducer, total_reducer );
Kokkos::fence();
std::cout << "List min neighbors: " << min_neigh
<< std::endl;
std::cout << "List max neighbors: " << max_neigh
<< std::endl;
std::cout << "List avg neighbors: " << total_neigh / num_p
<< std::endl;
std::cout << std::endl;
}
// Iterate through the neighbor list.
iteration_timer.start( pid );
Cabana::neighbor_parallel_for( policy, count_op, nlist,
Expand Down Expand Up @@ -175,10 +213,12 @@ int main( int argc, char* argv[] )
if ( argc > 2 )
run_type = argv[2];
std::vector<int> problem_sizes = { 100, 1000 };
std::vector<int> host_problem_sizes = problem_sizes;
std::vector<double> cutoff_ratios = { 2.0, 3.0 };
if ( run_type == "large" )
{
problem_sizes = { 1000, 10000, 100000, 1000000 };
problem_sizes = { 1000, 10000, 100000, 1000000, 10000000 };
host_problem_sizes = { 1000, 10000, 100000 };
cutoff_ratios = { 3.0, 4.0, 5.0 };
}

Expand All @@ -199,7 +239,7 @@ int main( int argc, char* argv[] )
performanceTest<device_type>( file, "device_", problem_sizes,
cutoff_ratios );
}
performanceTest<host_device_type>( file, "host_", problem_sizes,
performanceTest<host_device_type>( file, "host_", host_problem_sizes,
cutoff_ratios );

// Close the output file on rank 0.
Expand Down
64 changes: 29 additions & 35 deletions benchmark/core/Cabana_NeighborVerletPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
using LayoutTag = Cabana::VerletLayout2D;
using BuildTag = Cabana::TeamVectorOpTag;
using IterTag = Cabana::SerialOpTag;
using neigh_type =
Cabana::VerletList<memory_space, ListTag, LayoutTag, BuildTag>;

// Declare problem sizes.
int num_problem_size = problem_sizes.size();
Expand Down Expand Up @@ -139,11 +141,9 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
// Create the neighbor list.
double cutoff = cutoff_ratios[c0];
create_timer.start( pid );
Cabana::VerletList<memory_space, ListTag, LayoutTag,
BuildTag>
nlist( Cabana::slice<0>( aosoas[p], "position" ), 0,
num_p, cutoff, cell_ratios[c1], grid_min,
grid_max );
neigh_type nlist( Cabana::slice<0>( aosoas[p], "position" ),
0, num_p, cutoff, cell_ratios[c1],
grid_min, grid_max );
create_timer.stop( pid );

// Iterate through the neighbor list.
Expand All @@ -157,39 +157,31 @@ void performanceTest( std::ostream& stream, const std::string& test_prefix,
// Print neighbor statistics once per system.
if ( t == 0 )
{
Kokkos::MinMaxScalar<int> min_max;
Kokkos::MinMax<int> reducer( min_max );
auto const& nlist_data_count =
nlist._data.counts; // capture just the view
std::size_t max_neigh;
Kokkos::Max<std::size_t> max_reducer( max_neigh );
std::size_t min_neigh;
Kokkos::Min<std::size_t> min_reducer( min_neigh );
std::size_t total_neigh;
Kokkos::Sum<std::size_t> total_reducer( total_neigh );
Kokkos::parallel_reduce(
"Cabana::countMinMax", policy,
KOKKOS_LAMBDA(
const int p,
Kokkos::MinMaxScalar<int>& local_minmax ) {
auto const val = nlist_data_count( p );
if ( val < local_minmax.min_val )
{
local_minmax.min_val = val;
}
if ( val > local_minmax.max_val )
{
local_minmax.max_val = val;
}
"Cabana::Benchmark::countNeighbors", policy,
KOKKOS_LAMBDA( const int p, std::size_t& min,
std::size_t& max,
std::size_t& sum ) {
auto const val = Cabana::NeighborList<
neigh_type>::numNeighbor( nlist, p );
if ( val < min )
min = val;
if ( val > max )
max = val;
sum += val;
},
reducer );
min_reducer, max_reducer, total_reducer );
Kokkos::fence();
std::cout << "List min neighbors: " << min_max.min_val
std::cout << "List min neighbors: " << min_neigh
<< std::endl;
std::cout << "List max neighbors: " << min_max.max_val
std::cout << "List max neighbors: " << max_neigh
<< std::endl;
int total_neigh = 0;
Kokkos::parallel_reduce(
"Cabana::countSum", policy,
KOKKOS_LAMBDA( const int p, int& nsum ) {
nsum += nlist._data.counts( p );
},
total_neigh );
Kokkos::fence();
std::cout
<< "List avg neighbors: " << total_neigh / num_p
<< std::endl;
Expand Down Expand Up @@ -232,11 +224,13 @@ int main( int argc, char* argv[] )
if ( argc > 2 )
run_type = argv[2];
std::vector<int> problem_sizes = { 100, 1000 };
std::vector<int> host_problem_sizes = problem_sizes;
std::vector<double> cutoff_ratios = { 2.0, 3.0 };
std::vector<double> cell_ratios = { 1.0 };
if ( run_type == "large" )
{
problem_sizes = { 1000, 10000, 100000, 1000000 };
problem_sizes = { 1000, 10000, 100000, 1000000, 10000000 };
host_problem_sizes = { 1000, 10000, 100000 };
cutoff_ratios = { 3.0, 4.0, 5.0 };
cell_ratios = { 1.0 };
}
Expand All @@ -258,7 +252,7 @@ int main( int argc, char* argv[] )
performanceTest<device_type>( file, "device_", problem_sizes,
cutoff_ratios, cell_ratios );
}
performanceTest<host_device_type>( file, "host_", problem_sizes,
performanceTest<host_device_type>( file, "host_", host_problem_sizes,
cutoff_ratios, cell_ratios );

// Close the output file on rank 0.
Expand Down
12 changes: 6 additions & 6 deletions benchmark/grid/Cabana_Grid_HaloPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ int main( int argc, char* argv[] )
// Don't run twice on the CPU if only host enabled.
if ( !std::is_same<device_type, host_device_type>{} )
{
performanceTest<device_type>( file, partitioner,
grid_sizes_per_dim_per_rank, "device_",
halo_widths, MPI_COMM_WORLD );
performanceTest<device_type>(
file, partitioner, grid_sizes_per_dim_per_rank, "device_device_",
halo_widths, MPI_COMM_WORLD );
}
performanceTest<host_device_type>( file, partitioner,
grid_sizes_per_dim_per_rank, "host_",
halo_widths, MPI_COMM_WORLD );
performanceTest<host_device_type>(
file, partitioner, grid_sizes_per_dim_per_rank, "host_host_",
halo_widths, MPI_COMM_WORLD );

// Finalize
Kokkos::finalize();
Expand Down
Loading
Loading