From 5b47fc96fe2445ff6fa84485465850e0f6af3542 Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Fri, 24 May 2024 12:21:15 -0400 Subject: [PATCH] Clarify execution space vs device type --- examples/dam_break.cpp | 15 ++++++++------- examples/free_fall.cpp | 15 ++++++++------- src/ExaMPM_Solver.hpp | 23 +++++++++++++---------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/examples/dam_break.cpp b/examples/dam_break.cpp index e394f10..205832e 100644 --- a/examples/dam_break.cpp +++ b/examples/dam_break.cpp @@ -66,7 +66,7 @@ struct ParticleInitFunc //---------------------------------------------------------------------------// void damBreak( const double cell_size, const int ppc, const int halo_size, const double delta_t, const double t_final, const int write_freq, - const std::string& device ) + const std::string& exec_space ) { // The dam break domain is in a box on [0,1] in each dimension. Kokkos::Array global_box = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 }; @@ -109,7 +109,7 @@ void damBreak( const double cell_size, const int ppc, const int halo_size, // Solve the problem. auto solver = ExaMPM::createSolver( - device, MPI_COMM_WORLD, global_box, global_num_cell, periodic, + exec_space, MPI_COMM_WORLD, global_box, global_num_cell, periodic, partitioner, halo_size, ParticleInitFunc( cell_size, ppc, density ), ppc, bulk_modulus, density, gamma, kappa, delta_t, gravity, bc ); solver->solve( t_final, write_freq ); @@ -126,7 +126,7 @@ int main( int argc, char* argv[] ) if ( argc < 8 ) { std::cerr << "Usage: ./DamBreak cell_size parts_per_cell_size " - "halo_cells dt t_end write_freq device\n"; + "halo_cells dt t_end write_freq exec_space\n"; std::cerr << "\nwhere cell_size edge length of a computational " "cell (domain is unit cube)\n"; std::cerr @@ -136,7 +136,7 @@ int main( int argc, char* argv[] ) std::cerr << " t_end simulation end time\n"; std::cerr << " write_freq number of steps between output files\n"; - std::cerr << " device compute device: serial, openmp, " + std::cerr << " exec_space execute with: serial, openmp, " "cuda, hip\n"; std::cerr << "\nfor example: ./DamBreak 0.05 2 0 0.001 1.0 10 serial\n"; Kokkos::finalize(); @@ -162,11 +162,12 @@ int main( int argc, char* argv[] ) // write frequency int write_freq = std::atoi( argv[6] ); - // device type - std::string device( argv[7] ); + // execution space + std::string exec_space( argv[7] ); // run the problem. - damBreak( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device ); + damBreak( cell_size, ppc, halo_size, delta_t, t_final, write_freq, + exec_space ); Kokkos::finalize(); diff --git a/examples/free_fall.cpp b/examples/free_fall.cpp index 35d2e38..513ccd7 100644 --- a/examples/free_fall.cpp +++ b/examples/free_fall.cpp @@ -65,7 +65,7 @@ struct ParticleInitFunc //---------------------------------------------------------------------------// void freeFall( const double cell_size, const int ppc, const int halo_size, const double delta_t, const double t_final, const int write_freq, - const std::string& device ) + const std::string& exec_space ) { // The free fall domain is in a box on [-0.5,0.5] in each dimension. Kokkos::Array global_box = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }; @@ -106,7 +106,7 @@ void freeFall( const double cell_size, const int ppc, const int halo_size, // Solve the problem. auto solver = ExaMPM::createSolver( - device, MPI_COMM_WORLD, global_box, global_num_cell, periodic, + exec_space, MPI_COMM_WORLD, global_box, global_num_cell, periodic, partitioner, halo_size, ParticleInitFunc( cell_size, ppc, density ), ppc, bulk_modulus, density, gamma, kappa, delta_t, gravity, bc ); solver->solve( t_final, write_freq ); @@ -123,7 +123,7 @@ int main( int argc, char* argv[] ) if ( argc < 8 ) { std::cerr << "Usage: ./FreeFall cell_size parts_per_cell_size " - "halo_cells dt t_end write_freq device\n"; + "halo_cells dt t_end write_freq exec_space\n"; std::cerr << "\nwhere cell_size edge length of a computational " "cell (domain is unit cube)\n"; std::cerr @@ -133,7 +133,7 @@ int main( int argc, char* argv[] ) std::cerr << " t_end simulation end time\n"; std::cerr << " write_freq number of steps between output files\n"; - std::cerr << " device compute device: serial, openmp, " + std::cerr << " exec_space execute with: serial, openmp, " "cuda, hip\n"; std::cerr << "\nfor example: ./FreeFall 0.05 2 0 0.001 1.0 10 serial\n"; Kokkos::finalize(); @@ -159,11 +159,12 @@ int main( int argc, char* argv[] ) // write frequency int write_freq = std::atoi( argv[6] ); - // device type - std::string device( argv[7] ); + // execution space + std::string exec_space( argv[7] ); // run the problem. - freeFall( cell_size, ppc, halo_size, delta_t, t_final, write_freq, device ); + freeFall( cell_size, ppc, halo_size, delta_t, t_final, write_freq, + exec_space ); Kokkos::finalize(); diff --git a/src/ExaMPM_Solver.hpp b/src/ExaMPM_Solver.hpp index ac2cfc6..a06fa86 100644 --- a/src/ExaMPM_Solver.hpp +++ b/src/ExaMPM_Solver.hpp @@ -144,7 +144,7 @@ class Solver : public SolverBase // Creation method. template std::shared_ptr -createSolver( const std::string& device, MPI_Comm comm, +createSolver( const std::string& exec_space, MPI_Comm comm, const Kokkos::Array& global_bounding_box, const std::array& global_num_cell, const std::array& periodic, @@ -155,8 +155,9 @@ createSolver( const std::string& device, MPI_Comm comm, const double delta_t, const double gravity, const BoundaryCondition& bc ) { - if ( 0 == device.compare( "serial" ) || 0 == device.compare( "Serial" ) || - 0 == device.compare( "SERIAL" ) ) + if ( 0 == exec_space.compare( "serial" ) || + 0 == exec_space.compare( "Serial" ) || + 0 == exec_space.compare( "SERIAL" ) ) { #ifdef KOKKOS_ENABLE_SERIAL return std::make_shared< @@ -168,9 +169,9 @@ createSolver( const std::string& device, MPI_Comm comm, throw std::runtime_error( "Serial Backend Not Enabled" ); #endif } - else if ( 0 == device.compare( "openmp" ) || - 0 == device.compare( "OpenMP" ) || - 0 == device.compare( "OPENMP" ) ) + else if ( 0 == exec_space.compare( "openmp" ) || + 0 == exec_space.compare( "OpenMP" ) || + 0 == exec_space.compare( "OPENMP" ) ) { #ifdef KOKKOS_ENABLE_OPENMP return std::make_shared< @@ -182,8 +183,9 @@ createSolver( const std::string& device, MPI_Comm comm, throw std::runtime_error( "OpenMP Backend Not Enabled" ); #endif } - else if ( 0 == device.compare( "cuda" ) || 0 == device.compare( "Cuda" ) || - 0 == device.compare( "CUDA" ) ) + else if ( 0 == exec_space.compare( "cuda" ) || + 0 == exec_space.compare( "Cuda" ) || + 0 == exec_space.compare( "CUDA" ) ) { #ifdef KOKKOS_ENABLE_CUDA return std::make_shared< @@ -195,8 +197,9 @@ createSolver( const std::string& device, MPI_Comm comm, throw std::runtime_error( "CUDA Backend Not Enabled" ); #endif } - else if ( 0 == device.compare( "hip" ) || 0 == device.compare( "Hip" ) || - 0 == device.compare( "HIP" ) ) + else if ( 0 == exec_space.compare( "hip" ) || + 0 == exec_space.compare( "Hip" ) || + 0 == exec_space.compare( "HIP" ) ) { #ifdef KOKKOS_ENABLE_HIP return std::make_shared