Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharded fields dump #1738

Merged
merged 20 commits into from
Sep 23, 2021
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f007420
Add support for fully local HDF5 files and shared dumping of meep::st…
kkg4theweb Jul 28, 2021
344fe55
Add support for fully local HDF5 files and shared dumping of meep::st…
kkg4theweb Jul 29, 2021
a33c062
Update python func docs
kkg4theweb Jul 29, 2021
2af4e6e
Merge branch 'NanoComp:master' into sharded-dump
kkg4theweb Jul 29, 2021
3b04bb1
Update python API documentation
kkg4theweb Aug 12, 2021
817a920
Merge branch 'master' into sharded-dump
kkg4theweb Aug 12, 2021
0f11d41
Dump/Load of 'fields'
kkg4theweb Aug 23, 2021
28b5f00
after merge
kkg4theweb Aug 23, 2021
16eb661
Save dft chunks
kkg4theweb Aug 24, 2021
6cab125
Remove debug log stmts
kkg4theweb Aug 24, 2021
c28eb2c
Add saving of time value and also reorg tests.
kkg4theweb Aug 24, 2021
42b90e0
Fix dft-chunk saving for the single-parallel-file mode.
kkg4theweb Aug 25, 2021
bdef5e8
Abort when trying to dump fields with non-null polarization state
kkg4theweb Sep 9, 2021
e500897
Clean up test_dump_load.py and add test_dump_fails_for_non_null_polar…
kkg4theweb Sep 9, 2021
cd5bd6c
Add new tests/dump_load to set of files to ignore
kkg4theweb Sep 9, 2021
004e303
Clean up the test to remove unnecessary stuff from the copied over test
kkg4theweb Sep 9, 2021
6064894
Also dump/load 'f_w_prev'
kkg4theweb Sep 9, 2021
6e3cb0d
Fix typo causing build breakage
kkg4theweb Sep 9, 2021
9294d64
load fields at the very end of init_sim after add_sources
kkg4theweb Sep 23, 2021
b8bcf9d
remove init_sim before loading fields since that now works.
kkg4theweb Sep 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix dft-chunk saving for the single-parallel-file mode.
kkg4theweb committed Aug 25, 2021
commit 42b90e0f1413ec187bab71a74e1d2d4cf60edbf6
9 changes: 9 additions & 0 deletions src/fields.cpp
Original file line number Diff line number Diff line change
@@ -718,6 +718,15 @@ void fields::unset_solve_cw_omega() {
chunks[i]->unset_solve_cw_omega();
}

void fields::log(const char* prefix) {
master_printf("%sFields State:\n", prefix);
master_printf("%s a = %g, dt = %g\n", prefix, a, dt);
master_printf("%s m = %g, beta = %g\n", prefix, m, beta);
master_printf("%s t = %d, phasein_time = %d, is_real = %d\n", prefix, t, phasein_time, is_real);
master_printf("\n");
master_printf("%s num_chunks = %d (shared=%d)\n", prefix, num_chunks, shared_chunks);
}

/* implement mirror boundary conditions for i outside 0..n-1: */
int mirrorindex(int i, int n) { return i >= n ? 2 * n - 1 - i : (i < 0 ? -1 - i : i); }

25 changes: 18 additions & 7 deletions src/fields_dump.cpp
Original file line number Diff line number Diff line change
@@ -108,16 +108,17 @@ void fields::dump_fields_chunk_field(h5file *h5f, bool single_parallel_file,
void fields::dump(const char *filename, bool single_parallel_file) {
if (verbosity > 0) {
printf("creating fields output file \"%s\" (%d)...\n", filename, single_parallel_file);
log();
}

h5file file(filename, h5file::WRITE, single_parallel_file, !single_parallel_file);

// Write out the current time 't'
size_t dims[1] = {1};
size_t start[1] = {0};
size_t time[1] = {(size_t)t};
size_t _t[1] = {(size_t)t};
file.create_data("t", 1, dims);
file.write_chunk(1, start, dims, time);
if (am_master() || !single_parallel_file) file.write_chunk(1, start, dims, _t);

dump_fields_chunk_field(
&file, single_parallel_file, "f",
@@ -134,7 +135,7 @@ void fields::dump(const char *filename, bool single_parallel_file) {

// Dump DFT chunks.
for (int i = 0; i < num_chunks; i++) {
if (chunks[i]->is_mine()) {
if (single_parallel_file || chunks[i]->is_mine()) {
char dataname[1024];
snprintf(dataname, 1024, "chunk%02d", i);
save_dft_hdf5(chunks[i]->dft_chunks, dataname, &file, 0, single_parallel_file);
@@ -233,11 +234,18 @@ void fields::load(const char *filename, bool single_parallel_file) {
int rank;
size_t dims[1] = {1};
size_t start[1] = {0};
size_t time[1];
size_t _t[1];
file.read_size("t", &rank, dims, 1);
if (rank != 1 || dims[0] != 1) meep::abort("time size mismatch in fields::load");
file.read_chunk(1, start, dims, time);
t = static_cast<int>(time[0]);
if (am_master() || !single_parallel_file) file.read_chunk(1, start, dims, _t);

if (single_parallel_file) {
file.prevent_deadlock();
broadcast(0, _t, dims[0]);
}

t = static_cast<int>(_t[0]);
calc_sources(time());

load_fields_chunk_field(
&file, single_parallel_file, "f",
@@ -254,12 +262,15 @@ void fields::load(const char *filename, bool single_parallel_file) {

// Load DFT chunks.
for (int i = 0; i < num_chunks; i++) {
if (chunks[i]->is_mine()) {
if (single_parallel_file || chunks[i]->is_mine()) {
char dataname[1024];
snprintf(dataname, 1024, "chunk%02d", i);
load_dft_hdf5(chunks[i]->dft_chunks, dataname, &file, 0, single_parallel_file);
}
}

if (verbosity > 0)
log();
}

} // namespace meep
1 change: 1 addition & 0 deletions src/meep.hpp
Original file line number Diff line number Diff line change
@@ -1720,6 +1720,7 @@ class fields {
void remove_susceptibilities();
void remove_fluxes();
void reset();
void log(const char* prefix = "");

// time.cpp
std::vector<double> time_spent_on(time_sink sink);