@@ -64,6 +64,12 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
64
64
using namespace HDF5 ;
65
65
using namespace OutputUtils ;
66
66
67
+ if constexpr (WRITE_SINGLE_PRECISION) {
68
+ Kokkos::Profiling::pushRegion (" PHDF5::WriteOutputFileSinglePrec" );
69
+ } else {
70
+ Kokkos::Profiling::pushRegion (" PHDF5::WriteOutputFileRealPrec" );
71
+ }
72
+
67
73
// writes all graphics variables to hdf file
68
74
// HDF5 structures
69
75
// Also writes companion xdmf file
@@ -111,7 +117,9 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
111
117
// -------------------------------------------------------------------------------- //
112
118
// WRITING ATTRIBUTES //
113
119
// -------------------------------------------------------------------------------- //
120
+ Kokkos::Profiling::pushRegion (" write Attributes" );
114
121
{
122
+ Kokkos::Profiling::pushRegion (" write input" );
115
123
// write input key-value pairs
116
124
std::ostringstream oss;
117
125
pin->ParameterDump (oss);
@@ -120,11 +128,13 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
120
128
const H5G input_group = MakeGroup (file, " /Input" );
121
129
122
130
HDF5WriteAttribute (" File" , oss.str ().c_str (), input_group);
123
- } // Input section
131
+ Kokkos::Profiling::popRegion (); // write input
132
+ } // Input section
124
133
125
134
// we'll need this again at the end
126
135
const H5G info_group = MakeGroup (file, " /Info" );
127
136
{
137
+ Kokkos::Profiling::pushRegion (" write Info" );
128
138
HDF5WriteAttribute (" OutputFormatVersion" , OUTPUT_VERSION_FORMAT, info_group);
129
139
130
140
if (tm != nullptr ) {
@@ -178,18 +188,22 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
178
188
}
179
189
180
190
HDF5WriteAttribute (" BoundaryConditions" , boundary_condition_str, info_group);
181
- } // Info section
191
+ Kokkos::Profiling::popRegion (); // write Info
192
+ } // Info section
182
193
183
194
// write Params
184
195
{
196
+ Kokkos::Profiling::pushRegion (" behold: write Params" );
185
197
const H5G params_group = MakeGroup (file, " /Params" );
186
198
187
199
for (const auto &package : pm->packages .AllPackages ()) {
188
200
const auto state = package.second ;
189
201
// Write all params that can be written as HDF5 attributes
190
202
state->AllParams ().WriteAllToHDF5 (state->label (), params_group);
191
203
}
192
- } // Params section
204
+ Kokkos::Profiling::popRegion (); // behold: write Params
205
+ } // Params section
206
+ Kokkos::Profiling::popRegion (); // write Attributes
193
207
194
208
// -------------------------------------------------------------------------------- //
195
209
// WRITING MESHBLOCK METADATA //
@@ -226,6 +240,7 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
226
240
227
241
// write Blocks metadata
228
242
{
243
+ Kokkos::Profiling::pushRegion (" write block metadata" );
229
244
const H5G gBlocks = MakeGroup (file, " /Blocks" );
230
245
231
246
// write Xmin[ndim] for blocks
@@ -255,9 +270,11 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
255
270
HDF5Write2D (gBlocks , " loc.level-gid-lid-cnghost-gflag" , tmpID.data (), p_loc_offset,
256
271
p_loc_cnt, p_glob_cnt, pl_xfer);
257
272
}
258
- } // Block section
273
+ Kokkos::Profiling::popRegion (); // write block metadata
274
+ } // Block section
259
275
260
276
// Write mesh coordinates to file
277
+ Kokkos::Profiling::pushRegion (" write mesh coords" );
261
278
for (const bool face : {true , false }) {
262
279
const H5G gLocations = MakeGroup (file, face ? " /Locations" : " /VolumeLocations" );
263
280
@@ -280,10 +297,12 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
280
297
HDF5Write2D (gLocations , " z" , loc_z.data (), p_loc_offset, p_loc_cnt, p_glob_cnt,
281
298
pl_xfer);
282
299
}
300
+ Kokkos::Profiling::popRegion (); // write mesh coords
283
301
284
302
// Write Levels and Logical Locations with the level for each Meshblock loclist contains
285
303
// levels and logical locations for all meshblocks on all ranks
286
304
{
305
+ Kokkos::Profiling::pushRegion (" write levels and locations" );
287
306
const auto &loclist = pm->GetLocList ();
288
307
289
308
std::vector<std::int64_t > levels;
@@ -310,11 +329,13 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
310
329
311
330
// reset for collective output
312
331
local_count[0 ] = num_blocks_local;
332
+ Kokkos::Profiling::popRegion (); // write levels and locations
313
333
}
314
334
315
335
// -------------------------------------------------------------------------------- //
316
336
// WRITING VARIABLES DATA //
317
337
// -------------------------------------------------------------------------------- //
338
+ Kokkos::Profiling::pushRegion (" write all variable data" );
318
339
319
340
// All blocks have the same list of variable metadata that exist in the entire
320
341
// simulation, but not all variables may be allocated on all blocks
@@ -391,6 +412,7 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
391
412
392
413
// for each variable we write
393
414
for (auto &vinfo : all_vars_info) {
415
+ Kokkos::Profiling::pushRegion (" write variable loop" );
394
416
// not really necessary, but doesn't hurt
395
417
memset (tmpData.data (), 0 , tmpData.size () * sizeof (OutT));
396
418
@@ -448,13 +470,18 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
448
470
449
471
#ifndef PARTHENON_DISABLE_HDF5_COMPRESSION
450
472
PARTHENON_HDF5_CHECK (H5Pset_chunk (pl_dcreate, ndim, chunk_size.data ()));
451
- PARTHENON_HDF5_CHECK (
452
- H5Pset_deflate (pl_dcreate, std::min (9 , output_params.hdf5_compression_level )));
473
+ // Do not run the pipeline if compression is soft disabled.
474
+ // By default data would still be passed, which may result in slower output.
475
+ if (output_params.hdf5_compression_level > 0 ) {
476
+ PARTHENON_HDF5_CHECK (
477
+ H5Pset_deflate (pl_dcreate, std::min (9 , output_params.hdf5_compression_level )));
478
+ }
453
479
#endif
454
480
455
481
// load up data
456
482
hsize_t index = 0 ;
457
483
484
+ Kokkos::Profiling::pushRegion (" fill host output buffer" );
458
485
// for each local mesh block
459
486
for (size_t b_idx = 0 ; b_idx < num_blocks_local; ++b_idx) {
460
487
const auto &pmb = pm->block_list [b_idx];
@@ -520,11 +547,16 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
520
547
}
521
548
}
522
549
}
550
+ Kokkos::Profiling::popRegion (); // fill host output buffer
523
551
552
+ Kokkos::Profiling::pushRegion (" write variable data" );
524
553
// write data to file
525
554
HDF5WriteND (file, var_name, tmpData.data (), ndim, p_loc_offset, p_loc_cnt, p_glob_cnt,
526
555
pl_xfer, pl_dcreate);
556
+ Kokkos::Profiling::popRegion (); // write variable data
557
+ Kokkos::Profiling::popRegion (); // write variable loop
527
558
}
559
+ Kokkos::Profiling::popRegion (); // write all variable data
528
560
529
561
// names of variables
530
562
std::vector<std::string> var_names;
@@ -557,6 +589,7 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
557
589
// write SparseInfo and SparseFields (we can't write a zero-size dataset, so only write
558
590
// this if we have sparse fields)
559
591
if (num_sparse > 0 ) {
592
+ Kokkos::Profiling::pushRegion (" write sparse info" );
560
593
local_count[1 ] = global_count[1 ] = num_sparse;
561
594
562
595
HDF5Write2D (file, " SparseInfo" , sparse_allocated.get (), p_loc_offset, p_loc_cnt,
@@ -569,12 +602,14 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
569
602
570
603
const H5D dset = H5D::FromHIDCheck (H5Dopen2 (file, " SparseInfo" , H5P_DEFAULT));
571
604
HDF5WriteAttribute (" SparseFields" , names, dset);
572
- } // SparseInfo and SparseFields sections
605
+ Kokkos::Profiling::popRegion (); // write sparse info
606
+ } // SparseInfo and SparseFields sections
573
607
574
608
// -------------------------------------------------------------------------------- //
575
609
// WRITING PARTICLE DATA //
576
610
// -------------------------------------------------------------------------------- //
577
611
612
+ Kokkos::Profiling::pushRegion (" write particle data" );
578
613
AllSwarmInfo swarm_info (pm->block_list , output_params.swarms , restart_);
579
614
for (auto &[swname, swinfo] : swarm_info.all_info ) {
580
615
const H5G g_swm = MakeGroup (file, swname);
@@ -635,9 +670,14 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
635
670
pl_xfer);
636
671
}
637
672
}
673
+ Kokkos::Profiling::popRegion (); // write particle data
638
674
675
+ Kokkos::Profiling::pushRegion (" genXDMF" );
639
676
// generate XDMF companion file
640
677
XDMF::genXDMF (filename, pm, tm , nx1, nx2, nx3, all_vars_info, swarm_info);
678
+ Kokkos::Profiling::popRegion (); // genXDMF
679
+
680
+ Kokkos::Profiling::popRegion (); // WriteOutputFile???Prec
641
681
}
642
682
643
683
std::string PHDF5Output::GenerateFilename_ (ParameterInput *pin, SimTime *tm ,
0 commit comments