Skip to content

Commit

Permalink
Add read report
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstratford committed Dec 25, 2024
1 parent e831fb2 commit d57ae1a
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 16 deletions.
17 changes: 10 additions & 7 deletions src/colloids.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ __host__ int colloids_info_recreate(int newcell[3], colloids_info_t ** pinfo) {
*
* colloids_memcpy
*
* FIXME: flag is unused
*
*****************************************************************************/

__host__ int colloids_memcpy(colloids_info_t * info, int flag) {
Expand All @@ -193,11 +191,16 @@ __host__ int colloids_memcpy(colloids_info_t * info, int flag) {
assert((info->target == info));
}
else {
colloid_t * tmp;
tdpAssert(tdpMemcpy(&tmp, &info->target->map_new, sizeof(colloid_t **),
tdpMemcpyDeviceToHost));
tdpAssert(tdpMemcpy(tmp, info->map_new, info->nsites*sizeof(colloid_t *),
tdpMemcpyHostToDevice));
if (flag == tdpMemcpyHostToDevice) {
colloid_t * tmp;
tdpAssert(tdpMemcpy(&tmp, &info->target->map_new, sizeof(colloid_t **),
tdpMemcpyDeviceToHost));
tdpAssert(tdpMemcpy(tmp, info->map_new, info->nsites*sizeof(colloid_t *),
tdpMemcpyHostToDevice));

Check warning on line 199 in src/colloids.c

View check run for this annotation

Codecov / codecov/patch

src/colloids.c#L194-L199

Added lines #L194 - L199 were not covered by tests
}
else {
pe_exit(info->pe, "Bad flag in colloids_memcpy()\n");

Check warning on line 202 in src/colloids.c

View check run for this annotation

Codecov / codecov/patch

src/colloids.c#L202

Added line #L202 was not covered by tests
}
}

return 0;
Expand Down
13 changes: 9 additions & 4 deletions src/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ int field_io_write(field_t * field, int timestep, io_event_t * event) {
}

io->impl->free(&io);
io_event_report(event, meta, field->name);
io_event_report_write(event, meta, field->name);
}

return ifail;
Expand All @@ -1682,8 +1682,6 @@ int field_io_write(field_t * field, int timestep, io_event_t * event) {
*
* field_io_read
*
* FIXME io_event is unused
*
*****************************************************************************/

int field_io_read(field_t * field, int timestep, io_event_t * event) {
Expand All @@ -1699,17 +1697,24 @@ int field_io_read(field_t * field, int timestep, io_event_t * event) {
assert(ifail == 0);

if (ifail == 0) {
io_event_record(event, IO_EVENT_READ);
io->impl->read(io, filename);
io_event_record(event, IO_EVENT_DISAGGR);
field_io_aggr_unpack(field, io->aggr);
io->impl->free(&io);

if (meta->options.report) {
pe_info(field->pe, "MPIIO read from %s\n", filename);
io_event_report_read(event, meta, field->name);

Check warning on line 1708 in src/field.c

View check run for this annotation

Codecov / codecov/patch

src/field.c#L1707-L1708

Added lines #L1707 - L1708 were not covered by tests
}
}

return ifail;
}

/*****************************************************************************
*
* field_graph_halo_send_create
* field_graph_halo_send_create
*
*****************************************************************************/

Expand Down
104 changes: 103 additions & 1 deletion src/io_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,45 @@ int io_event_record(io_event_t * event, io_event_record_t iorec) {
*****************************************************************************/

int io_event_report(io_event_t * event, const io_metadata_t * metadata,
const char * name) {
const char * name, io_event_record_t iorec) {

assert(event);
assert(metadata);
assert(name);

switch (iorec) {
case IO_EVENT_READ:
io_event_report_read(event, metadata, name);
break;
case IO_EVENT_WRITE:
io_event_report_write(event, metadata, name);
break;
default:

Check warning on line 63 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L56-L63

Added lines #L56 - L63 were not covered by tests
/* Internal error. */
pe_exit(metadata->cs->pe, "Bad io event in report\n");

Check warning on line 65 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L65

Added line #L65 was not covered by tests
}

return 0;

Check warning on line 68 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L68

Added line #L68 was not covered by tests
}

/*****************************************************************************
*
* io_event_report_read
*
* Report for an i/o event in parallel.
* The aggregation report might want the local data size (currently total).
* The file write is the total data size of the file.
*
* Some refinement might be wanted for multiple files.
*
*****************************************************************************/

int io_event_report_read(io_event_t * event, const io_metadata_t * metadata,

Check warning on line 83 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L83

Added line #L83 was not covered by tests
const char * name) {

assert(event);
assert(metadata);
assert(name);

Check warning on line 88 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L86-L88

Added lines #L86 - L88 were not covered by tests

/* End of event (for reporting purposes) */
event->time[IO_EVENT_REPORT] = MPI_Wtime();
Expand All @@ -64,10 +97,79 @@ int io_event_report(io_event_t * event, const io_metadata_t * metadata,
const char * units = NULL;
double dunit6 = 1.0e+06; /* Units of data size are MB */
double dunit9 = 1.0e+09; /* Units of data size are GB */

/* Times (we assume these have been collected correctly! */
/* Read, then disaggregate, then report */

double tr = event->time[IO_EVENT_DISAGGR] - event->time[IO_EVENT_READ];
double ta = event->time[IO_EVENT_REPORT] - event->time[IO_EVENT_DISAGGR];

Check warning on line 105 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L104-L105

Added lines #L104 - L105 were not covered by tests

/* Record size and total file size. */

double dr = metadata->element.datasize*metadata->element.count;
double ds = metadata->subfile.sizes[X]*metadata->subfile.sizes[Y]*
metadata->subfile.sizes[Z];
double db = dr*ds;

Check warning on line 112 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L109-L112

Added lines #L109 - L112 were not covered by tests

if (db > dunit9) {

Check warning on line 114 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L114

Added line #L114 was not covered by tests
/* Use GB */
units = "GB";
db = db/dunit9;

Check warning on line 117 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L116-L117

Added lines #L116 - L117 were not covered by tests
}
else {
/* Use MB */
units = "MB";
db = db/dunit6;

Check warning on line 122 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L121-L122

Added lines #L121 - L122 were not covered by tests
}
pe_info(pe, "- %10s read %7.3f %2s in %7.3f seconds\n",

Check warning on line 124 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L124

Added line #L124 was not covered by tests
name, db, units, tr);
pe_info(pe, "- %10s disaggregated %7.3f %2s in %7.3f seconds\n",

Check warning on line 126 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L126

Added line #L126 was not covered by tests
name, db, units, ta);
pe_info(pe, "- %10s rate %7.3f GB per second\n",
name, dr*ds/dunit9/tr);

Check warning on line 129 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L128-L129

Added lines #L128 - L129 were not covered by tests
}

return 0;

Check warning on line 132 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L132

Added line #L132 was not covered by tests
}

/*****************************************************************************
*
* io_event_report_write
*
* The aggregation report might want the local data size (currently total).
* The file write is the total data size of the file.
*
* Some refinement might be wanted for multiple files.
*
*****************************************************************************/

int io_event_report_write(io_event_t * event, const io_metadata_t * metadata,
const char * name) {

assert(event);
assert(metadata);
assert(name);


/* End of event (for reporting purposes) */
event->time[IO_EVENT_REPORT] = MPI_Wtime();

if (metadata->options.report) {

pe_t * pe = metadata->cs->pe;

Check warning on line 159 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L159

Added line #L159 was not covered by tests

const char * units = NULL;
double dunit6 = 1.0e+06; /* Units of data size are MB */
double dunit9 = 1.0e+09; /* Units of data size are GB */

Check warning on line 163 in src/io_event.c

View check run for this annotation

Codecov / codecov/patch

src/io_event.c#L161-L163

Added lines #L161 - L163 were not covered by tests

/* Times (we assume these have been collected correctly! */
/* Write: aggr is first, write is second, report last */

double ta = event->time[IO_EVENT_WRITE] - event->time[IO_EVENT_AGGR];
double tw = event->time[IO_EVENT_REPORT] - event->time[IO_EVENT_WRITE];

/* Record size and total file size. */

double dr = metadata->element.datasize*metadata->element.count;
double ds = metadata->subfile.sizes[X]*metadata->subfile.sizes[Y]*
metadata->subfile.sizes[Z];
Expand Down
10 changes: 8 additions & 2 deletions src/io_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Edinburgh Soft Matter and Statistical Physics Group and
* Edinburgh Parallel Computing Centre
*
* (c) 2022 The University of Edinburgh
* (c) 2022-2024 The University of Edinburgh
*
* Kevin Stratford ([email protected])
*
Expand All @@ -22,6 +22,8 @@

enum io_event_record_enum {
IO_EVENT_AGGR = 0,
IO_EVENT_DISAGGR,
IO_EVENT_READ,
IO_EVENT_WRITE,
IO_EVENT_REPORT,
IO_EVENT_MAX
Expand All @@ -38,6 +40,10 @@ struct io_event_s {

int io_event_record(io_event_t * event, io_event_record_t iorec);
int io_event_report(io_event_t * event, const io_metadata_t * metadata,
const char * name);
const char * name, io_event_record_t iorec);
int io_event_report_read(io_event_t * event, const io_metadata_t * metadata,
const char * name);
int io_event_report_write(io_event_t * event, const io_metadata_t * metadata,
const char * name);

#endif
2 changes: 1 addition & 1 deletion src/lb_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ int lb_io_write(lb_t * lb, int timestep, io_event_t * event) {
}

io->impl->free(&io);
io_event_report(event, meta, "dist");
io_event_report_write(event, meta, "dist");

Check warning on line 1420 in src/lb_data.c

View check run for this annotation

Codecov / codecov/patch

src/lb_data.c#L1420

Added line #L1420 was not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/noise.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ int noise_io_write(noise_t * ns, int timestep, io_event_t * event) {
if (meta->options.report) {
pe_info(ns->pe, "Wrote noise state to file: %s\n", filename);
}
io_event_report(event, meta, ns->options.filestub);
io_event_report_write(event, meta, ns->options.filestub);
}
}

Expand Down

0 comments on commit d57ae1a

Please sign in to comment.