Loading src/CreateImage.cpp +22 −21 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ static inline void free2( RayTrace::create_image_struct *info ) // Run the tests for a single file int run_tests( const std::string &filename, const Options &options ) { if ( rank() == 0 ) const int rank = getRank(); if ( rank == 0 ) std::cout << "Running tests for " << filename << std::endl; // Get the list of methods to try Loading @@ -107,7 +108,7 @@ int run_tests( const std::string &filename, const Options &options ) std::vector<Times> perf1( methods.size() ); std::vector<Times> perf2( methods.size() ); for ( size_t i = 0; i < methods.size(); i++ ) { if ( rank() == 0 ) if ( rank == 0 ) std::cout << " Running " << methods[i] << std::endl; bool serial = methods[i] == "cpu" || methods[i] == "Kokkos-Serial"; int iterations = options.iterations; Loading Loading @@ -146,16 +147,27 @@ int run_tests( const std::string &filename, const Options &options ) if ( !pass ) N_errors++; } if ( perf1[i].avg[0] < 0.5 * perf1[i].avg[1] ) { std::cout << "Slow rank detected: " << rank() << std::endl; if ( perf1[i].avg[0] > 2.0 * perf1[i].avg[1] ) { printf( " Slow rank detected: %i\n", rank ); N_errors++; } barrier(); if ( rank == 0 ) { if ( perf1[i].std[1] > 0.25 * perf1[i].avg[1] ) { printf( " Standard deviation exceeded tolerance (25%%)\n" ); N_errors++; } if ( perf1[i].max[1] > 2.0 * perf1[i].avg[1] ) { printf( " Maximum runtime exceeded average by more than 2X\n" ); N_errors++; } } free( (void *) info->image ); free( (void *) info->I_ang ); info->image = nullptr; info->I_ang = nullptr; } if ( rank() == 0 ) { if ( rank == 0 ) { if ( options.benchmark ) { double t = perf2[0].avg[1]; double N = 0; Loading @@ -166,24 +178,13 @@ int run_tests( const std::string &filename, const Options &options ) auto &beam = *( info->seed_beam ); N = beam.nx * beam.ny * beam.na * beam.nb; } N *= size(); N *= getSize(); printf( "\n%0.3e rays/s\n", N / t ); } else { printf( "\n METHOD Avg Min Max Std Dev\n" ); for ( size_t i = 0; i < methods.size(); i++ ) { double min = perf1[i].min[1]; double max = perf1[i].max[1]; double avg = perf1[i].avg[1]; double dev = perf1[i].std[1]; printf( "%14s %7.3f %7.3f %7.3f %7.3f\n", methods[i].c_str(), avg, min, max, dev ); if ( dev / avg > 0.25 ) { printf( " Standard deviation exceeded tolerance (25%%)\n" ); N_errors++; } if ( ( max - avg ) / avg > 0.50 ) { printf( " Maximum runtime exceeded average by more than 50%%\n" ); N_errors++; } printf( "%14s %7.3f %7.3f %7.3f %7.3f\n", methods[i].c_str(), perf1[i].avg[1], perf1[i].min[1], perf1[i].max[1], perf1[i].std[1] ); } std::cout << std::endl; } Loading Loading @@ -244,7 +245,7 @@ int main( int argc, char *argv[] ) KokkosInitialize( argc, argv ); // Print hardware stats if ( rank() == 0 ) if ( getRank() == 0 ) printHardware(); // Run the tests for all files Loading @@ -253,7 +254,7 @@ int main( int argc, char *argv[] ) N_errors += run_tests( filenames[i], options ); // Finished if ( rank() == 0 ) { if ( getRank() == 0 ) { if ( N_errors == 0 ) std::cout << "\nAll tests passed\n"; else Loading src/CreateImageHelpers.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ struct Times { double avg[2]; double std[2]; Times(); Times( const std::vector<double> × ); explicit Times( const std::vector<double> × ); }; Loading src/MPI_helpers.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -14,13 +14,13 @@ void shutdown() MPI_Finalize(); } void barrier() { MPI_Barrier( MPI_COMM_WORLD ); } int rank() int getRank() { int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); return rank; } int size() int getSize() { int size; MPI_Comm_size( MPI_COMM_WORLD, &size ); Loading @@ -40,7 +40,7 @@ double bcast( double x, int root ) } std::vector<double> gatherAll( const std::vector<double>& x ) { std::vector<double> y( x.size() * size(), 0 ); std::vector<double> y( x.size() * getSize(), 0 ); MPI_Allgather( x.data(), x.size(), MPI_DOUBLE, y.data(), x.size(), MPI_DOUBLE, MPI_COMM_WORLD ); return y; } Loading @@ -53,8 +53,8 @@ std::vector<double> gatherAll( const std::vector<double>& x ) void startup( int, char* [] ) {} void shutdown() {} void barrier() {} int rank() { return 0; } int size() { return 1; } int getRank() { return 0; } int getSize() { return 1; } int sumReduce( const int val ) { return val; } double bcast( double x, int ) { return x; } std::vector<double> gatherAll( const std::vector<double>& x ) { return x; } Loading src/MPI_helpers.h +2 −2 Original line number Diff line number Diff line Loading @@ -6,8 +6,8 @@ void startup( int argc, char* argv[] ); void shutdown(); void barrier(); int rank(); int size(); int getRank(); int getSize(); int sumReduce( const int val ); double bcast( double x, int root = 0 ); std::vector<double> gatherAll( const std::vector<double>& x ); Loading
src/CreateImage.cpp +22 −21 Original line number Diff line number Diff line Loading @@ -87,7 +87,8 @@ static inline void free2( RayTrace::create_image_struct *info ) // Run the tests for a single file int run_tests( const std::string &filename, const Options &options ) { if ( rank() == 0 ) const int rank = getRank(); if ( rank == 0 ) std::cout << "Running tests for " << filename << std::endl; // Get the list of methods to try Loading @@ -107,7 +108,7 @@ int run_tests( const std::string &filename, const Options &options ) std::vector<Times> perf1( methods.size() ); std::vector<Times> perf2( methods.size() ); for ( size_t i = 0; i < methods.size(); i++ ) { if ( rank() == 0 ) if ( rank == 0 ) std::cout << " Running " << methods[i] << std::endl; bool serial = methods[i] == "cpu" || methods[i] == "Kokkos-Serial"; int iterations = options.iterations; Loading Loading @@ -146,16 +147,27 @@ int run_tests( const std::string &filename, const Options &options ) if ( !pass ) N_errors++; } if ( perf1[i].avg[0] < 0.5 * perf1[i].avg[1] ) { std::cout << "Slow rank detected: " << rank() << std::endl; if ( perf1[i].avg[0] > 2.0 * perf1[i].avg[1] ) { printf( " Slow rank detected: %i\n", rank ); N_errors++; } barrier(); if ( rank == 0 ) { if ( perf1[i].std[1] > 0.25 * perf1[i].avg[1] ) { printf( " Standard deviation exceeded tolerance (25%%)\n" ); N_errors++; } if ( perf1[i].max[1] > 2.0 * perf1[i].avg[1] ) { printf( " Maximum runtime exceeded average by more than 2X\n" ); N_errors++; } } free( (void *) info->image ); free( (void *) info->I_ang ); info->image = nullptr; info->I_ang = nullptr; } if ( rank() == 0 ) { if ( rank == 0 ) { if ( options.benchmark ) { double t = perf2[0].avg[1]; double N = 0; Loading @@ -166,24 +178,13 @@ int run_tests( const std::string &filename, const Options &options ) auto &beam = *( info->seed_beam ); N = beam.nx * beam.ny * beam.na * beam.nb; } N *= size(); N *= getSize(); printf( "\n%0.3e rays/s\n", N / t ); } else { printf( "\n METHOD Avg Min Max Std Dev\n" ); for ( size_t i = 0; i < methods.size(); i++ ) { double min = perf1[i].min[1]; double max = perf1[i].max[1]; double avg = perf1[i].avg[1]; double dev = perf1[i].std[1]; printf( "%14s %7.3f %7.3f %7.3f %7.3f\n", methods[i].c_str(), avg, min, max, dev ); if ( dev / avg > 0.25 ) { printf( " Standard deviation exceeded tolerance (25%%)\n" ); N_errors++; } if ( ( max - avg ) / avg > 0.50 ) { printf( " Maximum runtime exceeded average by more than 50%%\n" ); N_errors++; } printf( "%14s %7.3f %7.3f %7.3f %7.3f\n", methods[i].c_str(), perf1[i].avg[1], perf1[i].min[1], perf1[i].max[1], perf1[i].std[1] ); } std::cout << std::endl; } Loading Loading @@ -244,7 +245,7 @@ int main( int argc, char *argv[] ) KokkosInitialize( argc, argv ); // Print hardware stats if ( rank() == 0 ) if ( getRank() == 0 ) printHardware(); // Run the tests for all files Loading @@ -253,7 +254,7 @@ int main( int argc, char *argv[] ) N_errors += run_tests( filenames[i], options ); // Finished if ( rank() == 0 ) { if ( getRank() == 0 ) { if ( N_errors == 0 ) std::cout << "\nAll tests passed\n"; else Loading
src/CreateImageHelpers.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ struct Times { double avg[2]; double std[2]; Times(); Times( const std::vector<double> × ); explicit Times( const std::vector<double> × ); }; Loading
src/MPI_helpers.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -14,13 +14,13 @@ void shutdown() MPI_Finalize(); } void barrier() { MPI_Barrier( MPI_COMM_WORLD ); } int rank() int getRank() { int rank; MPI_Comm_rank( MPI_COMM_WORLD, &rank ); return rank; } int size() int getSize() { int size; MPI_Comm_size( MPI_COMM_WORLD, &size ); Loading @@ -40,7 +40,7 @@ double bcast( double x, int root ) } std::vector<double> gatherAll( const std::vector<double>& x ) { std::vector<double> y( x.size() * size(), 0 ); std::vector<double> y( x.size() * getSize(), 0 ); MPI_Allgather( x.data(), x.size(), MPI_DOUBLE, y.data(), x.size(), MPI_DOUBLE, MPI_COMM_WORLD ); return y; } Loading @@ -53,8 +53,8 @@ std::vector<double> gatherAll( const std::vector<double>& x ) void startup( int, char* [] ) {} void shutdown() {} void barrier() {} int rank() { return 0; } int size() { return 1; } int getRank() { return 0; } int getSize() { return 1; } int sumReduce( const int val ) { return val; } double bcast( double x, int ) { return x; } std::vector<double> gatherAll( const std::vector<double>& x ) { return x; } Loading
src/MPI_helpers.h +2 −2 Original line number Diff line number Diff line Loading @@ -6,8 +6,8 @@ void startup( int argc, char* argv[] ); void shutdown(); void barrier(); int rank(); int size(); int getRank(); int getSize(); int sumReduce( const int val ); double bcast( double x, int root = 0 ); std::vector<double> gatherAll( const std::vector<double>& x );