Skip to content

Commit 347f35d

Browse files
expose more parameters for configuration
1 parent 86c0609 commit 347f35d

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

eisvogel/meep/MEEPCylindricalGreensFunctionCalculator.hh

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ namespace GreensFunctionCalculator::MEEP {
2626
void Calculate(std::filesystem::path outdir, std::filesystem::path local_scratchdir, std::filesystem::path global_scratchdir,
2727
double courant_factor = 0.5, double resolution = 28, double timestep = 0.1, double pml_width = 1.0, std::size_t downsampling_on_disk = 2,
2828
scalar_t dynamic_range = 100, scalar_t abs_min_field = 1e-20, std::size_t chunk_overlap = 2, std::size_t chunk_size_linear = 800,
29-
std::size_t rechunk_cache_depth = 5);
29+
std::size_t rechunk_cache_depth = 5, std::size_t calc_chunk_size_t = 800, std::size_t calc_chunk_size_linear = 800);
3030

3131
private:
3232

3333
struct MPIChunkCalculationResult;
3434

3535
// Main steps of the Green's function calculation
3636
MPIChunkCalculationResult calculate_mpi_chunk(std::filesystem::path outdir, std::filesystem::path local_scratchdir, std::size_t padding_requested,
37-
double courant_factor, double resolution, double timestep, double pml_width,
38-
std::size_t downsampling_on_disk, scalar_t dynamic_range, scalar_t abs_min_field);
37+
double courant_factor, double resolution, double timestep, std::size_t calc_chunk_size_t,
38+
std::size_t calc_chunk_size_linear, double pml_width, std::size_t downsampling_on_disk,
39+
scalar_t dynamic_range, scalar_t abs_min_field);
3940
static void merge_mpi_chunks(std::filesystem::path outdir, const std::vector<std::filesystem::path>& indirs);
4041
static void rechunk_mpi(std::filesystem::path outdir, std::filesystem::path indir, std::filesystem::path global_scratchdir, int cur_mpi_id, int number_mpi_jobs,
4142
const RZTVector<std::size_t>& requested_chunk_size, std::size_t overlap, const RZTVector<std::size_t>& padding_pre,

eisvogel/meep/impl/MEEPCylindricalGreensFunctionCalculator.hxx

+16-15
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ struct ChunkloopData {
102102
ChunkloopData(std::size_t ind_time,
103103
spatial_chunk_t::shape_t calc_domain_shape, spatial_chunk_t::ind_t storage_domain_start_ind,
104104
spatial_chunk_t::shape_t storage_domain_shape,
105-
darr_t& fstor, fstats_t& fstats, scalar_t dynamic_range,
105+
darr_t& fstor, fstats_t& fstats, scalar_t dynamic_range, std::size_t calc_chunk_size_t, std::size_t calc_chunk_size_linear,
106106
scalar_t abs_min_field, const chunk_t::ind_t& downsampling_factor,
107107
const chunk_t::shape_t& init_field_buffer_shape, const chunk_t::shape_t& init_field_buffer_processed_shape,
108108
const fstats_t::shape_t& init_stat_buffer_shape, const chunk_t::shape_t& init_field_chunk_buffer_shape) :
109109
ind_time(ind_time),
110110
calc_domain_shape(calc_domain_shape), storage_domain_start_ind(storage_domain_start_ind), storage_domain_shape(storage_domain_shape),
111-
fstor(fstor), fstats(fstats), dynamic_range(dynamic_range), abs_min_field(abs_min_field),
112-
downsampling_factor(downsampling_factor), field_buffer(init_field_buffer_shape), field_buffer_processed(init_field_buffer_processed_shape),
113-
field_absval_buffer(init_stat_buffer_shape), field_chunk_buffer(init_field_chunk_buffer_shape) { }
111+
fstor(fstor), fstats(fstats), dynamic_range(dynamic_range), calc_chunk_size_t(calc_chunk_size_t), calc_chunk_size_linear(calc_chunk_size_linear),
112+
abs_min_field(abs_min_field), downsampling_factor(downsampling_factor), field_buffer(init_field_buffer_shape),
113+
field_buffer_processed(init_field_buffer_processed_shape), field_absval_buffer(init_stat_buffer_shape),
114+
field_chunk_buffer(init_field_chunk_buffer_shape) { }
114115

115116
std::size_t ind_time; // Time index
116117

@@ -123,6 +124,8 @@ struct ChunkloopData {
123124
fstats_t& fstats; // Reference to field statistics tracker
124125

125126
scalar_t dynamic_range; // Dynamic range of field to keep
127+
std::size_t calc_chunk_size_t; // Chunk size along the time direction that is used during Green's function calculation
128+
std::size_t calc_chunk_size_linear; // Chunk size along the spatial direction(s) used during Green's function calculation
126129
scalar_t abs_min_field; // Abs. minimum field value to keep
127130
chunk_t::ind_t downsampling_factor;
128131

@@ -301,10 +304,7 @@ namespace meep {
301304
}
302305

303306
// std::cout << "------------" << std::endl;
304-
// std::cout << "chunk #: " << ichunk << std::endl;
305-
306-
// Number of time slices before a new chunk is started
307-
std::size_t requested_chunk_size_t = 200;
307+
// std::cout << "chunk #: " << ichunk << std::endl;
308308

309309
// Make sure the buffers are of the correct size for this simulation chunk
310310
ZRVector<std::size_t> spatial_storage_chunk_shape(chunkloop_data -> sim_chunk_meta.at(ichunk).storage_chunk_shape);
@@ -396,10 +396,10 @@ namespace meep {
396396
// chunkloop_data -> field_buffer_processed.GetShape() << std::endl;
397397

398398
using shape_t = CylindricalChunkloopData::chunk_t::shape_t;
399-
shape_t requested_output_chunk_size(400);
399+
shape_t requested_output_chunk_size(chunkloop_data -> calc_chunk_size_linear);
400400

401401
// Register the processed buffer
402-
if(chunkloop_data -> ind_time % requested_chunk_size_t == 0) {
402+
if(chunkloop_data -> ind_time % chunkloop_data -> calc_chunk_size_t == 0) {
403403

404404
// Register this slice as the beginning of a new chunk ...
405405
TZRIndexVector start(0);
@@ -452,7 +452,8 @@ namespace GreensFunctionCalculator::MEEP {
452452

453453
CylindricalGreensFunctionCalculator::MPIChunkCalculationResult
454454
CylindricalGreensFunctionCalculator::calculate_mpi_chunk(std::filesystem::path outdir, std::filesystem::path local_scratchdir, std::size_t padding_requested,
455-
double courant_factor, double resolution, double timestep, double pml_width, std::size_t downsampling_on_disk,
455+
double courant_factor, double resolution, double timestep, std::size_t calc_chunk_size_t,
456+
std::size_t calc_chunk_size_linear, double pml_width, std::size_t downsampling_on_disk,
456457
scalar_t dynamic_range, scalar_t abs_min_field) {
457458

458459
// Make sure that MEEP will not silently round the domain size
@@ -561,7 +562,7 @@ namespace GreensFunctionCalculator::MEEP {
561562

562563
// Package up all the information
563564
CylindricalChunkloopData cld(0, calc_domain_shape, storage_domain_padded_start_ind, storage_domain_padded_shape,
564-
darr, fstats, dynamic_range, abs_min_field, downsampling_factor,
565+
darr, fstats, dynamic_range, calc_chunk_size_t, calc_chunk_size_linear, abs_min_field, downsampling_factor,
565566
init_field_buffer_shape, init_field_buffer_shape,
566567
init_field_absval_buffer_shape, init_field_chunk_buffer_shape);
567568

@@ -738,7 +739,7 @@ namespace GreensFunctionCalculator::MEEP {
738739
void CylindricalGreensFunctionCalculator::Calculate(std::filesystem::path outdir, std::filesystem::path local_scratchdir, std::filesystem::path global_scratchdir,
739740
double courant_factor, double resolution, double timestep, double pml_width, std::size_t downsampling_on_disk,
740741
scalar_t dynamic_range, scalar_t abs_min_field, std::size_t chunk_overlap, std::size_t chunk_size_linear,
741-
std::size_t rechunk_cache_depth) {
742+
std::size_t rechunk_cache_depth, std::size_t calc_chunk_size_t, std::size_t calc_chunk_size_linear) {
742743

743744
int number_mpi_jobs = meep::count_processors();
744745
int job_mpi_rank = meep::my_rank();
@@ -772,8 +773,8 @@ namespace GreensFunctionCalculator::MEEP {
772773
std::filesystem::path job_outdir = global_workdir / calc_job_dir(job_mpi_rank);
773774
std::size_t padding_requested = chunk_overlap; // number of additional elements that should be foreseen as padding around the calculated array
774775
MPIChunkCalculationResult mpi_calc_res = calculate_mpi_chunk(job_outdir, local_scratchdir, padding_requested,
775-
courant_factor, resolution, timestep, pml_width,
776-
downsampling_on_disk, dynamic_range, abs_min_field);
776+
courant_factor, resolution, timestep, calc_chunk_size_t, calc_chunk_size_linear,
777+
pml_width, downsampling_on_disk, dynamic_range, abs_min_field);
777778

778779
meep::all_wait(); // Wait for all processes to have finished providing their output
779780

0 commit comments

Comments
 (0)