24 #include "openPMD/config.hpp" 27 #include "RandomDatasetFiller.hpp" 29 #include "openPMD/openPMD.hpp" 30 #include "openPMD/benchmark/mpi/MPIBenchmarkReport.hpp" 31 #include "openPMD/benchmark/mpi/DatasetFiller.hpp" 32 #include "openPMD/benchmark/mpi/BlockSlicer.hpp" 55 template<
typename DatasetFillerProv
ider >
60 using extentT = Extent::value_type;
61 MPI_Comm communicator = MPI_COMM_WORLD;
68 std::shared_ptr< BlockSlicer > m_blockSlicer;
70 DatasetFillerProvider m_dfp;
90 std::shared_ptr< BlockSlicer > blockSlicer,
91 DatasetFillerProvider dfp,
92 MPI_Comm comm = MPI_COMM_WORLD
106 std::string compression,
107 uint8_t compressionLevel,
110 typename decltype( Series::iterations )::key_type iterations,
126 std::string compression,
127 uint8_t compressionLevel,
130 typename decltype( Series::iterations)::key_type iterations
133 void resetConfigurations( );
144 template<
typename Clock >
150 std::string m_basePath;
158 typename decltype( Series::iterations)::key_type>>
182 template<
typename Clock >
183 struct BenchmarkExecution
189 m_benchmark { benchmark }
208 typename Clock::duration writeBenchmark(
209 std::string
const & compression,
213 std::string
const & extension,
215 typename decltype( Series::iterations)::key_type iterations
230 typename Clock::duration readBenchmark(
233 std::string extension,
234 typename decltype( Series::iterations)::key_type iterations
237 template<
typename T >
259 template<
typename DatasetFillerProv
ider >
260 template<
typename Clock >
267 BenchmarkExecution< Clock > exec {
this };
269 std::set< Datatype > datatypes;
270 for(
auto const & conf: m_configurations )
272 datatypes.insert( std::get< DTYPE >( conf ) );
274 for( Datatype dt: datatypes )
288 template<
typename DatasetFillerProv
ider >
290 std::string basePath,
292 std::shared_ptr< BlockSlicer > blockSlicer,
293 DatasetFillerProvider dfp,
296 communicator { comm },
297 totalExtent { std::move( tExtent ) },
298 m_blockSlicer { std::move( blockSlicer ) },
300 m_basePath { std::move( basePath ) }
302 if( m_blockSlicer ==
nullptr )
303 throw std::runtime_error(
"Argument blockSlicer cannot be a nullptr!");
307 template<
typename DatasetFillerProv
ider >
327 return m_blockSlicer->sliceBlock(
335 template<
typename DatasetFillerProv
ider >
337 std::string compression,
338 uint8_t compressionLevel,
341 typename decltype( Series::iterations)::key_type iterations,
345 this->m_configurations
357 template<
typename DatasetFillerProv
ider >
359 std::string compression,
360 uint8_t compressionLevel,
363 typename decltype( Series::iterations)::key_type iterations
382 template<
typename DatasetFillerProv
ider >
390 template<
typename DatasetFillerProv
ider >
391 template<
typename Clock >
392 template<
typename T >
393 typename Clock::duration
395 std::string
const & compression,
399 std::string
const & extension,
401 typename decltype( Series::iterations)::key_type iterations
404 MPI_Barrier( m_benchmark->communicator );
405 auto start = Clock::now( );
409 m_benchmark->m_basePath +
"." + extension,
411 m_benchmark->communicator
414 for(
typename decltype( Series::iterations)::key_type i = 0;
418 auto writeData = datasetFiller->produceData( );
423 series.iterations[i].meshes[
"id"][MeshRecordComponent::SCALAR];
425 Datatype datatype = determineDatatype( writeData );
430 if( !compression.empty( ) )
432 dataset.setCompression(
438 id.resetDataset( dataset );
450 MPI_Barrier( m_benchmark->communicator );
451 auto end = Clock::now( );
454 for(
typename decltype( Series::iterations)::key_type i = 0;
458 datasetFiller->produceData( );
460 auto deduct = Clock::now( );
462 return end - start - ( deduct - end );
466 template<
typename DatasetFillerProv
ider >
467 template<
typename Clock >
468 template<
typename T >
469 typename Clock::duration
473 std::string extension,
474 typename decltype( Series::iterations)::key_type iterations
477 MPI_Barrier( m_benchmark->communicator );
479 auto start = Clock::now( );
482 m_benchmark->m_basePath +
"." + extension,
484 m_benchmark->communicator
487 for(
typename decltype( Series::iterations)::key_type i = 0;
493 series.iterations[i].meshes[
"id"][MeshRecordComponent::SCALAR];
496 auto chunk_data =
id.loadChunk<
T >(
503 MPI_Barrier( m_benchmark->communicator );
504 auto end = Clock::now( );
509 template<
typename DatasetFillerProv
ider >
510 template<
typename Clock >
511 template<
typename T >
518 Datatype dt = determineDatatype< T >( );
524 for(
auto const & config: m_benchmark->m_configurations )
526 std::string compression;
527 uint8_t compressionLevel;
531 typename decltype( Series::iterations)::key_type iterations;
546 auto localCuboid = m_benchmark->slice( size );
548 extentT blockSize = 1;
549 for(
auto ext: localCuboid.second )
553 dsf->setNumberOfItems( blockSize );
555 auto writeTime = writeBenchmark< T >(
564 auto readTime = readBenchmark< T >(
588 template<
typename DatasetFillerProv
ider >
589 template<
typename Clock >
597 throw std::runtime_error(
"Unknown/unsupported datatype requested to be benchmarked." );
void addReport(int rootThread, std::string compression, uint8_t level, std::string extension, int threadSize, Datatype dt, typename decltype(Series::iterations)::key_type iterations, std::pair< Duration, Duration > const &report)
Add results for a certain compression strategy and level.
Definition: MPIBenchmarkReport.hpp:245
Definition: Dataset.hpp:36
An abstract class to create one iteration of data per thread.
Definition: DatasetFiller.hpp:37
Extent totalExtent
Total extent of the hypercuboid used in the benchmark.
Definition: MPIBenchmark.hpp:66
create new series and truncate existing (files)
MPIBenchmarkReport< typename Clock::duration > runBenchmark(int rootThread=0)
Main function for running a benchmark.
Definition: MPIBenchmark.hpp:262
Datatype
Concrete datatype of an object available at runtime.
Definition: Datatype.hpp:42
Root level of the openPMD hierarchy.
Definition: Series.hpp:64
Class representing a benchmark.
Definition: MPIBenchmark.hpp:56
The report for a single benchmark produced by <openPMD/benchmark/mpi/MPIBenchmark>.
Definition: MPIBenchmarkReport.hpp:44
void flush()
Execute all required remaining IO operations to write or read data.
Definition: Series.cpp:359
MPIBenchmark(std::string basePath, Extent tExtent, std::shared_ptr< BlockSlicer > blockSlicer, DatasetFillerProvider dfp, MPI_Comm comm=MPI_COMM_WORLD)
Construct an MPI benchmark manually.
Definition: MPIBenchmark.hpp:289
ReturnType switchType(Datatype dt, Action action, Args &&... args)
Generalizes switching over an openPMD datatype.
Definition: Datatype.hpp:642
Public definitions of openPMD-api.
Definition: Date.cpp:29
Definition: MeshRecordComponent.hpp:30
open series as read-only, fails if series is not found
void addConfiguration(std::string compression, uint8_t compressionLevel, std::string backend, Datatype dt, typename decltype(Series::iterations)::key_type iterations, int threadSize)
Definition: MPIBenchmark.hpp:336