From 3c1e76141cd063350263f2be17196b2aeeae5940 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 12 Aug 2017 10:51:48 -0700 Subject: [PATCH 01/15] If "redistributed because changed", identify whether the BoxArray or the Distribution Map has changed --- Source/NyxParticles.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/NyxParticles.cpp b/Source/NyxParticles.cpp index 7ea25208..0f237bbf 100644 --- a/Source/NyxParticles.cpp +++ b/Source/NyxParticles.cpp @@ -910,7 +910,9 @@ Nyx::particle_redistribute (int lbase, bool init) static Array ba; static Array dm; - bool changed = false; + bool changed = false; + bool dm_changed = false; + bool ba_changed = false; int flev = parent->finestLevel(); @@ -923,24 +925,31 @@ Nyx::particle_redistribute (int lbase, bool init) ba.resize(flev+1); dm.resize(flev+1); changed = true; + ba_changed = true; } else { for (int i = 0; i <= flev && !changed; i++) { if (ba[i] != parent->boxArray(i)) + { // // The BoxArrays have changed in the regridding. // changed = true; + ba_changed = true; + } if ( ! changed) { if (dm[i] != parent->getLevel(i).get_new_data(0).DistributionMap()) + { // // The DistributionMaps have changed in the regridding. // changed = true; + dm_changed = true; + } } } } @@ -953,8 +962,10 @@ Nyx::particle_redistribute (int lbase, bool init) // because of we called redistribute during a subcycle, there may be particles not in // the proper position on coarser levels. // - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Calling redistribute because changed " << '\n'; + if (verbose && ParallelDescriptor::IOProcessor() && ba_changed) + std::cout << "Calling redistribute because BoxArray changed " << '\n'; + if (verbose && ParallelDescriptor::IOProcessor() && dm_changed) + std::cout << "Calling redistribute because DistMap changed " << '\n'; DMPC->Redistribute(lbase); // From 447c8de24db86a2be8b592968ed97636508b333a Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 12 Aug 2017 11:54:24 -0700 Subject: [PATCH 02/15] Clarify print statements in particle_redistribute --- Source/NyxParticles.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/NyxParticles.cpp b/Source/NyxParticles.cpp index 0f237bbf..ca77155b 100644 --- a/Source/NyxParticles.cpp +++ b/Source/NyxParticles.cpp @@ -910,9 +910,10 @@ Nyx::particle_redistribute (int lbase, bool init) static Array ba; static Array dm; - bool changed = false; - bool dm_changed = false; - bool ba_changed = false; + bool changed = false; + bool dm_changed = false; + bool ba_changed = false; + bool ba_size_changed = false; int flev = parent->finestLevel(); @@ -922,10 +923,12 @@ Nyx::particle_redistribute (int lbase, bool init) if (ba.size() != flev+1) { + amrex::Print() << "BA SIZE " << ba.size() << std::endl; + amrex::Print() << "FLEV " << flev << std::endl; ba.resize(flev+1); dm.resize(flev+1); changed = true; - ba_changed = true; + ba_size_changed = true; } else { @@ -962,10 +965,15 @@ Nyx::particle_redistribute (int lbase, bool init) // because of we called redistribute during a subcycle, there may be particles not in // the proper position on coarser levels. // - if (verbose && ParallelDescriptor::IOProcessor() && ba_changed) - std::cout << "Calling redistribute because BoxArray changed " << '\n'; - if (verbose && ParallelDescriptor::IOProcessor() && dm_changed) - std::cout << "Calling redistribute because DistMap changed " << '\n'; + if (verbose) + { + if (ba_size_changed) + amrex::Print() << "Calling redistribute because the size of BoxArray changed " << '\n'; + else if (ba_changed) + amrex::Print() << "Calling redistribute because BoxArray changed " << '\n'; + else if (dm_changed) + amrex::Print() << "Calling redistribute because DistMap changed " << '\n'; + } DMPC->Redistribute(lbase); // @@ -979,8 +987,8 @@ Nyx::particle_redistribute (int lbase, bool init) } else { - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "NOT calling redistribute because NOT changed " << '\n'; + if (verbose) + amrex::Print() << "NOT calling redistribute because NOT changed " << '\n'; } } } From 7e4d0045c5b8ed5c090630877b2bf679340aa210 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 12 Aug 2017 15:29:12 -0700 Subject: [PATCH 03/15] Add extra lines to build with PROFILE = TRUE --- Exec/Make.Nyx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Exec/Make.Nyx b/Exec/Make.Nyx index 9aaf8436..f6f04f3d 100644 --- a/Exec/Make.Nyx +++ b/Exec/Make.Nyx @@ -102,7 +102,10 @@ VPATH_LOCATIONS += $(Blocs) #These are the directories in AMReX -Pdirs := Base AmrCore Amr Boundary Particle Extern/amrdata +Pdirs := Base AmrCore Amr Boundary Particle Extern/amrdata +ifeq ($(PROFILE), TRUE) + Pdirs += Extern/ProfParser +endif Ppack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package) Plocs += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)) @@ -153,6 +156,19 @@ all: $(executable) $(SILENT) $(RM) AMReX_buildInfo.cpp @echo SUCCESS +ifeq ($(PROFILE), TRUE) +$(executable): + +BLProfParser.tab.H BLProfParser.tab.cpp: $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.y + cat $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.y $(SED0) $(SED1) > BLProfParserNC.y + bison --defines=BLProfParser.tab.H --output=BLProfParser.tab.cpp \ + BLProfParserNC.y + rm BLProfParserNC.y + +BLProfParser.lex.yy.cpp: BLProfParser.tab.H $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.l + flex --outfile=BLProfParser.lex.yy.cpp $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.l +endif + # job_info support CEXE_sources += AMReX_buildInfo.cpp CEXE_headers += $(AMREX_HOME)/Tools/C_scripts/AMReX_buildInfo.H From e94fc5c957bb2309562781f2801112ed7f366f36 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sun, 13 Aug 2017 10:46:22 -0700 Subject: [PATCH 04/15] Replace std::cout by amrex::Print() --- Source/Gravity/Gravity.cpp | 124 ++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 71 deletions(-) diff --git a/Source/Gravity/Gravity.cpp b/Source/Gravity/Gravity.cpp index de5988bb..dd6c248a 100644 --- a/Source/Gravity/Gravity.cpp +++ b/Source/Gravity/Gravity.cpp @@ -143,11 +143,11 @@ Gravity::read_params () Real Gconst; fort_get_grav_const(&Gconst); Ggravity = -4.0 * M_PI * Gconst; - if (verbose > 0 && ParallelDescriptor::IOProcessor()) + if (verbose > 0) { - std::cout << "Getting Gconst from nyx_constants: " << Gconst + amrex::Print() << "Getting Gconst from nyx_constants: " << Gconst << '\n'; - std::cout << "Using " << Ggravity << " for 4 pi G in Gravity.cpp " + amrex::Print() << "Using " << Ggravity << " for 4 pi G in Gravity.cpp " << '\n'; } done = true; @@ -158,8 +158,8 @@ void Gravity::install_level (int level, AmrLevel* level_data_to_install) { - if (verbose > 1 && ParallelDescriptor::IOProcessor()) - std::cout << "Installing Gravity level " << level << '\n'; + if (verbose > 1) + amrex::Print() << "Installing Gravity level " << level << '\n'; LevelData[level] = level_data_to_install; @@ -280,8 +280,8 @@ Gravity::solve_for_old_phi (int level, return; #endif - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Gravity ... single level solve for old phi at level " + if (verbose) + amrex::Print() << "Gravity ... single level solve for old phi at level " << level << std::endl; MultiFab Rhs(grids[level], dmap[level], 1, 0); Rhs.setVal(0.0); @@ -315,8 +315,8 @@ Gravity::solve_for_new_phi (int level, return; #endif - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Gravity ... single level solve for new phi at level " + if (verbose) + amrex::Print() << "Gravity ... single level solve for new phi at level " << level << std::endl; MultiFab Rhs(grids[level], dmap[level], 1, 0); @@ -348,8 +348,8 @@ Gravity::solve_for_phi (int level, { BL_PROFILE("Gravity::solve_for_phi()"); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... solve for phi at level " << level << '\n'; + if (verbose) + amrex::Print() << " ... solve for phi at level " << level << '\n'; // This is a correction for fully periodic domains only if (Geometry::isAllPeriodic()) @@ -449,11 +449,9 @@ Gravity::solve_for_phi (int level, Rhs.plus(-sum, 0, 1, 0); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... subtracting " - << sum - << " to ensure solvability " - << '\n'; + if (verbose) + amrex::Print() << " ... subtracting " << sum + << " to ensure solvability " << '\n'; } } @@ -503,12 +501,10 @@ Gravity::solve_for_delta_phi (int crse_level, BL_ASSERT(grad_delta_phi.size() == num_levels); BL_ASSERT(delta_phi.size() == num_levels); - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "... solving for delta_phi at crse_level = " << crse_level - << '\n'; - std::cout << "... up to fine_level = " << fine_level - << '\n'; + amrex::Print() << "... solving for delta_phi at crse_level = " << crse_level << '\n'; + amrex::Print() << "... up to fine_level = " << fine_level << '\n'; } const Geometry& geom = parent->Geom(crse_level); @@ -595,8 +591,8 @@ Gravity::solve_for_delta_phi (int crse_level, local_correction = local_correction / grids[crse_level].numPts(); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "WARNING: Adjusting RHS in solve_for_delta_phi by " << local_correction << std::endl; + if (verbose) + amrex::Print() << "WARNING: Adjusting RHS in solve_for_delta_phi by " << local_correction << std::endl; for (int lev = crse_level; lev <= fine_level; lev++) { Rhs_p[lev-crse_level]->plus(-local_correction,0,1,0); @@ -631,10 +627,10 @@ Gravity::gravity_sync (int crse_level, int fine_level, int iteration, int ncycle BL_PROFILE("Gravity::gravity_sync()"); BL_ASSERT(parent->finestLevel()>crse_level); - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << " ... gravity_sync at crse_level " << crse_level << '\n'; - std::cout << " ... up to finest_level " << fine_level << '\n'; + amrex::Print() << " ... gravity_sync at crse_level " << crse_level << '\n'; + amrex::Print() << " ... up to finest_level " << fine_level << '\n'; } // Build Rhs for solve for delta_phi @@ -659,8 +655,8 @@ Gravity::gravity_sync (int crse_level, int fine_level, int iteration, int ncycle local_correction /= grids[crse_level].numPts(); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "WARNING: Adjusting RHS in gravity_sync solve by " << local_correction << '\n'; + if (verbose) + amrex::Print() << "WARNING: Adjusting RHS in gravity_sync solve by " << local_correction << '\n'; crse_rhs.plus(-local_correction,0,1,0); } @@ -851,8 +847,8 @@ Gravity::multilevel_solve_for_new_phi (int level, int use_previous_phi_as_guess) { BL_PROFILE("Gravity::multilevel_solve_for_new_phi()"); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Gravity ... multilevel solve for new phi at base level " << level + if (verbose) + amrex::Print() << "Gravity ... multilevel solve for new phi at base level " << level << " to finest level " << finest_level << '\n'; for (int lev = level; lev <= finest_level; lev++) @@ -877,9 +873,9 @@ Gravity::multilevel_solve_for_old_phi (int level, int use_previous_phi_as_guess) { BL_PROFILE("Gravity::multilevel_solve_for_old_phi()"); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Gravity ... multilevel solve for old phi at base level " << level - << " to finest level " << finest_level << '\n'; + if (verbose) + amrex::Print() << "Gravity ... multilevel solve for old phi at base level " << level + << " to finest level " << finest_level << '\n'; for (int lev = level; lev <= finest_level; lev++) { @@ -912,7 +908,6 @@ Gravity::actual_multilevel_solve (int level, int use_previous_phi_as_guess) { BL_PROFILE("Gravity::actual_multilevel_solve()"); - const int IOProc = ParallelDescriptor::IOProcessorNumber(); const int num_levels = finest_level - level + 1; @@ -1047,9 +1042,9 @@ Gravity::actual_multilevel_solve (int level, // This correction is for fully periodic domains only. if (Geometry::isAllPeriodic()) { - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... subtracting average density " << mass_offset - << " from RHS at each level " << '\n'; + if (verbose) + amrex::Print() << " ... subtracting average density " << mass_offset + << " from RHS at each level " << '\n'; for (int lev = 0; lev < num_levels; lev++) for (MFIter mfi(*Rhs_p[lev]); mfi.isValid(); ++mfi) @@ -1071,17 +1066,12 @@ Gravity::actual_multilevel_solve (int level, const Real eps = 1.e-10 * std::abs(mass_offset); if (std::abs(sum) > eps) { - if (ParallelDescriptor::IOProcessor()) - { - std::cout << " ... current avg differs from mass_offset by " << sum << " " << '\n'; - std::cout << " ... Gravity::actual_multilevel_solve -- total mass has changed!" - << '\n';; - } + amrex::Print() << " ... current avg differs from mass_offset by " << sum << " " << '\n'; + amrex::Print() << " ... Gravity::actual_multilevel_solve -- total mass has changed!" << '\n';; } - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... subtracting " << sum << " to ensure solvability " - << '\n'; + if (verbose) + amrex::Print() << " ... subtracting " << sum << " to ensure solvability " << '\n'; for (int lev = 0; lev < num_levels; lev++) (*Rhs_p[lev]).plus(-sum, 0, 1, 0); @@ -1671,23 +1661,19 @@ Gravity::set_mass_offset (Real time) mass_offset /= geom.ProbSize(); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "Gravity ... defining average density in Gravity::set_mass_offset to be " << mass_offset - << '\n'; + if (verbose) + amrex::Print() << "Gravity ... defining average density in Gravity::set_mass_offset to be " + << mass_offset << '\n'; } const Real diff = std::abs(mass_offset - old_mass_offset); const Real eps = 1.e-10 * std::abs(old_mass_offset); if (diff > eps && old_mass_offset > 0) { - if (ParallelDescriptor::IOProcessor()) - { - std::cout << " ... new vs old mass_offset " << mass_offset << " " - << old_mass_offset - << " ... diff is " << diff << '\n'; - std::cout << " ... Gravity::set_mass_offset -- total mass has changed!" - << '\n';; - } + amrex::Print() << " ... new vs old mass_offset " << mass_offset << " " + << old_mass_offset << " ... diff is " << diff << '\n'; + amrex::Print() << " ... Gravity::set_mass_offset -- total mass has changed!" + << '\n';; } } @@ -1896,9 +1882,9 @@ void Gravity::CorrectRhsUsingOffset(int level, MultiFab& Rhs) { BL_PROFILE("Gravity::CorrectRhsUsingOffset()"); - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... subtracting average density from RHS in solve ... " - << mass_offset << '\n'; + if (verbose) + amrex::Print() << " ... subtracting average density from RHS in solve ... " + << mass_offset << '\n'; for (MFIter mfi(Rhs); mfi.isValid(); ++mfi) Rhs[mfi].plus(-mass_offset); @@ -1912,17 +1898,13 @@ Gravity::CorrectRhsUsingOffset(int level, MultiFab& Rhs) const Real eps = 1.e-10 * std::abs(mass_offset); if (std::abs(sum) > eps) { - if (ParallelDescriptor::IOProcessor()) - { - std::cout << " ... current avg differs from mass_offset by " << sum << " " << '\n'; - std::cout << " ... Gravity : single_level solve for phi -- total mass has changed!" + amrex::Print() << " ... current avg differs from mass_offset by " << sum << " " << '\n'; + amrex::Print() << " ... Gravity : single_level solve for phi -- total mass has changed!" << '\n';; - } } - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << " ... subtracting " << sum << " to ensure solvability " - << '\n'; + if (verbose) + amrex::Print() << " ... subtracting " << sum << " to ensure solvability " << '\n'; Rhs.plus(-sum, 0, 1, 0); } @@ -2021,7 +2003,8 @@ Gravity::solve_with_HPGMG(int level, { if (ParallelDescriptor::IOProcessor()) { - std::cerr << "WARNING: Periodic boundary conditions, but f does not sum to zero... mean(f)=" << average_value_of_f << std::endl; + std::cerr << "WARNING: Periodic boundary conditions, but f does not sum to zero... mean(f)=" + << average_value_of_f << std::endl; std::cerr << "Subtracting mean(f) from RHS ..." << std::endl; } shift_vector(&level_h,VECTOR_F,VECTOR_F,-average_value_of_f); @@ -2031,8 +2014,7 @@ Gravity::solve_with_HPGMG(int level, rebuild_operator(&level_h,NULL,a,b); // i.e. calculate Dinv and lambda_max MGBuild(&MG_h,&level_h,a,b,minCoarseDim,ParallelDescriptor::Communicator()); // build the Multigrid Hierarchy //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (ParallelDescriptor::IOProcessor()) - std::cout << std::endl << std::endl << "===== STARTING SOLVE =====" << std::endl << std::flush; + amrex::Print() << std::endl << std::endl << "===== STARTING SOLVE =====" << std::endl << std::flush; MGResetTimers (&MG_h); zero_vector (MG_h.levels[0], VECTOR_U); From 7f2608dcab09eed3ef9d8aa85bd1999d58c8b398 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sun, 13 Aug 2017 12:51:03 -0700 Subject: [PATCH 05/15] Replace std::cout by amrex::Print() --- Source/NyxParticles.cpp | 86 ++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/Source/NyxParticles.cpp b/Source/NyxParticles.cpp index ca77155b..3d73594d 100644 --- a/Source/NyxParticles.cpp +++ b/Source/NyxParticles.cpp @@ -385,12 +385,12 @@ Nyx::init_particles () amrex::Abort("Nyx::init_particles(): particle_initrandom_iseed must be > 0"); } - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "\nInitializing DM with cloud of " - << particle_initrandom_count - << " random particles with initial seed: " - << particle_initrandom_iseed << "\n\n"; + amrex::Print() << "\nInitializing DM with cloud of " + << particle_initrandom_count + << " random particles with initial seed: " + << particle_initrandom_iseed << "\n\n"; } DMPC->InitRandom(particle_initrandom_count, @@ -408,12 +408,10 @@ Nyx::init_particles () amrex::Abort("Nyx::init_particles(): particle_initrandom_iseed must be > 0"); } - if (verbose && ParallelDescriptor::IOProcessor()) - { - std::cout << "\nInitializing DM with of " << particle_initrandom_count_per_box - << " random particles per box with initial seed: " - << particle_initrandom_iseed << "\n\n"; - } + if (verbose) + amrex::Print() << "\nInitializing DM with of " << particle_initrandom_count_per_box + << " random particles per box with initial seed: " + << particle_initrandom_iseed << "\n\n"; DMPC->InitRandomPerBox(particle_initrandom_count_per_box, particle_initrandom_iseed, pdata); @@ -421,21 +419,21 @@ Nyx::init_particles () } else if (particle_init_type == "RandomPerCell") { - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "\nInitializing DM with 1 random particle per cell " << "\n"; + if (verbose) + amrex::Print() << "\nInitializing DM with 1 random particle per cell " << "\n"; int n_per_cell = 1; DMPC->InitNRandomPerCell(n_per_cell, pdata); } else if (particle_init_type == "AsciiFile") { - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "\nInitializing DM particles from \"" - << ascii_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing DM particles from \"" + << ascii_particle_file << "\" ...\n\n"; if (init_with_sph_particles == 1) - std::cout << "\nInitializing SPH particles from ascii \"" - << sph_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing SPH particles from ascii \"" + << sph_particle_file << "\" ...\n\n"; } // // The second argument is how many Reals we read into `m_data[]` @@ -448,13 +446,13 @@ Nyx::init_particles () } else if (particle_init_type == "BinaryFile") { - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "\nInitializing DM particles from \"" - << binary_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing DM particles from \"" + << binary_particle_file << "\" ...\n\n"; if (init_with_sph_particles == 1) - std::cout << "\nInitializing SPH particles from binary \"" - << sph_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing SPH particles from binary \"" + << sph_particle_file << "\" ...\n\n"; } // // The second argument is how many Reals we read into `m_data[]` @@ -467,13 +465,13 @@ Nyx::init_particles () } else if (particle_init_type == "BinaryMetaFile") { - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "\nInitializing DM particles from meta file\"" - << binary_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing DM particles from meta file\"" + << binary_particle_file << "\" ...\n\n"; if (init_with_sph_particles == 1) - std::cout << "\nInitializing SPH particles from meta file\"" - << sph_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing SPH particles from meta file\"" + << sph_particle_file << "\" ...\n\n"; } // // The second argument is how many Reals we read into `m_data[]` @@ -567,9 +565,9 @@ Nyx::init_particles () NPC->SetVerbose(particle_verbose); if (particle_init_type == "AsciiFile") { - if (verbose && ParallelDescriptor::IOProcessor()) - std::cout << "\nInitializing Neutrino particles from \"" - << neutrino_particle_file << "\" ...\n\n"; + if (verbose) + amrex::Print() << "\nInitializing Neutrino particles from \"" + << neutrino_particle_file << "\" ...\n\n"; // // The second argument is how many Reals we read into `m_data[]` // after reading in `m_pos[]`. Here we're reading in the particle @@ -579,10 +577,10 @@ Nyx::init_particles () } else if (particle_init_type == "BinaryFile") { - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { - std::cout << "\nInitializing Neutrino particles from \"" - << neutrino_particle_file << "\" ...\n\n"; + amrex::Print() << "\nInitializing Neutrino particles from \"" + << neutrino_particle_file << "\" ...\n\n"; } // // The second argument is how many Reals we read into `m_data[]` @@ -609,10 +607,8 @@ Nyx::init_santa_barbara (int init_sb_vels) Real cur_time = state[State_Type].curTime(); Real a = old_a; - if (ParallelDescriptor::IOProcessor()) { - std::cout << "... time and comoving a when data is initialized at level " - << level << " " << cur_time << " " << a << '\n'; - } + amrex::Print() << "... time and comoving a when data is initialized at level " + << level << " " << cur_time << " " << a << '\n'; if (level == 0) { @@ -864,22 +860,22 @@ Nyx::particle_est_time_step (Real& est_dt) } #endif - if (verbose && ParallelDescriptor::IOProcessor()) + if (verbose) { if (est_dt_particle > 0) { - std::cout << "...estdt from particles at level " + amrex::Print() << "...estdt from particles at level " << level << ": " << est_dt_particle << '\n'; } else { - std::cout << "...there are no particles at level " + amrex::Print() << "...there are no particles at level " << level << '\n'; } #ifdef NEUTRINO_PARTICLES if (est_dt_neutrino > 0) { - std::cout << "...estdt from neutrinos at level " + amrex::Print() << "...estdt from neutrinos at level " << level << ": " << est_dt_neutrino << '\n'; } #endif @@ -1083,12 +1079,6 @@ Nyx::NyxParticlesAddProcsToComp(Amr *aptr, int nSidecarProcs, int prevSidecarPro int ioProcNumSCS, int ioProcNumAll, int scsMyId, MPI_Comm scsCommn) { -#if 0 -// What is this doing here??? -if(ParallelDescriptor::IOProcessor()) { - std::cout << "PPPPPPPP: DMPC SPC APC NPC = " << DMPC << " " << SPC << " " << APC << " " << NPC << std::endl; -} -#endif } //NyxParticleContainerBase::~NyxParticleContainerBase() {} From 8905fe07bf7f5cc0d977b09732334dac5b7aba13 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sun, 13 Aug 2017 12:52:13 -0700 Subject: [PATCH 06/15] Cleanup --- Source/Gravity/Gravity.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Gravity/Gravity.cpp b/Source/Gravity/Gravity.cpp index dd6c248a..2965563b 100644 --- a/Source/Gravity/Gravity.cpp +++ b/Source/Gravity/Gravity.cpp @@ -849,7 +849,7 @@ Gravity::multilevel_solve_for_new_phi (int level, BL_PROFILE("Gravity::multilevel_solve_for_new_phi()"); if (verbose) amrex::Print() << "Gravity ... multilevel solve for new phi at base level " << level - << " to finest level " << finest_level << '\n'; + << " to finest level " << finest_level << '\n'; for (int lev = level; lev <= finest_level; lev++) { @@ -1051,7 +1051,6 @@ Gravity::actual_multilevel_solve (int level, (*Rhs_p[lev])[mfi].plus(-mass_offset); // This is used to enforce solvability if appropriate. -// if ( grids[level].contains(parent->Geom(level).Domain()) ) if ( parent->Geom(level).Domain().numPts() == grids[level].numPts() ) { Real sum = 0; From f16c3bca40a1906efe783ac9c8f3c0d7a2f21ddd Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Mon, 14 Aug 2017 14:55:35 -0700 Subject: [PATCH 07/15] No longer need the specialized stuff here for PROFILE = TRUE -- that has been moved into the amrex build system. --- Exec/Make.Nyx | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Exec/Make.Nyx b/Exec/Make.Nyx index f6f04f3d..1d69bfef 100644 --- a/Exec/Make.Nyx +++ b/Exec/Make.Nyx @@ -156,19 +156,6 @@ all: $(executable) $(SILENT) $(RM) AMReX_buildInfo.cpp @echo SUCCESS -ifeq ($(PROFILE), TRUE) -$(executable): - -BLProfParser.tab.H BLProfParser.tab.cpp: $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.y - cat $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.y $(SED0) $(SED1) > BLProfParserNC.y - bison --defines=BLProfParser.tab.H --output=BLProfParser.tab.cpp \ - BLProfParserNC.y - rm BLProfParserNC.y - -BLProfParser.lex.yy.cpp: BLProfParser.tab.H $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.l - flex --outfile=BLProfParser.lex.yy.cpp $(AMREX_HOME)/Src/Extern/ProfParser/BLProfParser.l -endif - # job_info support CEXE_sources += AMReX_buildInfo.cpp CEXE_headers += $(AMREX_HOME)/Tools/C_scripts/AMReX_buildInfo.H From 4e9ac969c0b0f3bacb052b12d6291c24eb5d1a0b Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Tue, 15 Aug 2017 14:50:54 -0700 Subject: [PATCH 08/15] use the particle_real type here to allow for single precision. --- Source/particle_mod.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/particle_mod.f90 b/Source/particle_mod.f90 index 09dfa2a5..90ed3238 100644 --- a/Source/particle_mod.f90 +++ b/Source/particle_mod.f90 @@ -1,6 +1,6 @@ module particle_mod - use amrex_fort_module, only: c_real => amrex_real + use amrex_fort_module, only: c_real => amrex_particle_real use iso_c_binding , only: c_int implicit none From 75117b3400260a0ef03f61db3ed6b786fa46934e Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Tue, 15 Aug 2017 18:53:27 -0700 Subject: [PATCH 09/15] Remove final line referring to PROFILE. --- Exec/Make.Nyx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Exec/Make.Nyx b/Exec/Make.Nyx index 1d69bfef..4308625e 100644 --- a/Exec/Make.Nyx +++ b/Exec/Make.Nyx @@ -103,9 +103,6 @@ VPATH_LOCATIONS += $(Blocs) #These are the directories in AMReX Pdirs := Base AmrCore Amr Boundary Particle Extern/amrdata -ifeq ($(PROFILE), TRUE) - Pdirs += Extern/ProfParser -endif Ppack += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)/Make.package) Plocs += $(foreach dir, $(Pdirs), $(AMREX_HOME)/Src/$(dir)) From 40a61250329aa260f750fcc0afcbddfd64845a74 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 26 Aug 2017 13:12:02 -0700 Subject: [PATCH 10/15] Update the way we handle estdt with OMP -- before we had a serial section of code here, now we use omp parallel reduction(min:) --- Source/Nyx.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/Source/Nyx.cpp b/Source/Nyx.cpp index 0ef310d2..5e8c9849 100644 --- a/Source/Nyx.cpp +++ b/Source/Nyx.cpp @@ -807,30 +807,21 @@ Nyx::est_time_step (Real dt_old) Real dt = est_dt; #ifdef _OPENMP -#pragma omp parallel firstprivate(dt) +#pragma omp parallel reduction(min:est_dt) #endif - { - for (MFIter mfi(stateMF,true); mfi.isValid(); ++mfi) - { - const Box& box = mfi.tilebox(); - - fort_estdt - (BL_TO_FORTRAN(stateMF[mfi]), box.loVect(), box.hiVect(), dx, - &dt, &a); - } -#ifdef _OPENMP -#pragma omp critical (nyx_estdt) -#endif - { - est_dt = std::min(est_dt, dt); - } - } + for (MFIter mfi(stateMF,true); mfi.isValid(); ++mfi) + { + const Box& box = mfi.tilebox(); + fort_estdt + (BL_TO_FORTRAN(stateMF[mfi]), box.loVect(), box.hiVect(), dx, &dt, &a); + est_dt = std::min(est_dt, dt); + } + ParallelDescriptor::ReduceRealMin(est_dt); // If in comoving coordinates, then scale dt (based on u and c) by a est_dt *= a; - - ParallelDescriptor::ReduceRealMin(est_dt); est_dt *= cfl; + if (verbose && ParallelDescriptor::IOProcessor()) std::cout << "...estdt from hydro at level " << level << ": " From b6fbbdb690ecc6230ce02391eeb33720256b62e4 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 26 Aug 2017 13:26:20 -0700 Subject: [PATCH 11/15] Add omp parallel redution(max:courno) in Nyx_hydro loop --- Source/Nyx_hydro.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/Nyx_hydro.cpp b/Source/Nyx_hydro.cpp index b792fc75..274f28fc 100644 --- a/Source/Nyx_hydro.cpp +++ b/Source/Nyx_hydro.cpp @@ -128,13 +128,12 @@ Nyx::just_the_hydro (Real time, if (add_ext_src && strang_split) strang_first_step(time,dt,S_old_tmp,D_old_tmp); + FArrayBox flux[BL_SPACEDIM], u_gdnv[BL_SPACEDIM]; + Real cflLoc = -1.e+200; + #ifdef _OPENMP -#pragma omp parallel +#pragma omp parallel reduction(max:courno) #endif - { - FArrayBox flux[BL_SPACEDIM], u_gdnv[BL_SPACEDIM]; - Real cflLoc = -1.e+200; - for (MFIter mfi(S_old_tmp,true); mfi.isValid(); ++mfi) { @@ -174,6 +173,8 @@ Nyx::just_the_hydro (Real time, BL_TO_FORTRAN(flux[2]), &cflLoc, &a_old, &a_new, &se, &ske, &print_fortran_warnings, &do_grav); + courno = std::max(courno, cflLoc); + for (int i = 0; i < BL_SPACEDIM; ++i) { fluxes[i][mfi].copy(flux[i], mfi.nodaltilebox(i)); } @@ -182,15 +183,6 @@ Nyx::just_the_hydro (Real time, ke_added += ske; } // end of MFIter loop -#ifdef _OPENMP -#pragma omp critical (hydro_courno) -#endif - { - courno = std::max(courno, cflLoc); - } - - } // end of omp parallel region - // We copy old Temp and Ne to new Temp and Ne so that they can be used // as guesses when we next need them. MultiFab::Copy(D_new,D_old,0,0,2,0); From 2d7062bdd28630dd0031a80ecbff09c018e2c727 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sat, 26 Aug 2017 14:24:07 -0700 Subject: [PATCH 12/15] Revert "Add omp parallel redution(max:courno) in Nyx_hydro loop" This reverts commit b6fbbdb690ecc6230ce02391eeb33720256b62e4. --- Source/Nyx_hydro.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/Nyx_hydro.cpp b/Source/Nyx_hydro.cpp index 274f28fc..b792fc75 100644 --- a/Source/Nyx_hydro.cpp +++ b/Source/Nyx_hydro.cpp @@ -128,12 +128,13 @@ Nyx::just_the_hydro (Real time, if (add_ext_src && strang_split) strang_first_step(time,dt,S_old_tmp,D_old_tmp); - FArrayBox flux[BL_SPACEDIM], u_gdnv[BL_SPACEDIM]; - Real cflLoc = -1.e+200; - #ifdef _OPENMP -#pragma omp parallel reduction(max:courno) +#pragma omp parallel #endif + { + FArrayBox flux[BL_SPACEDIM], u_gdnv[BL_SPACEDIM]; + Real cflLoc = -1.e+200; + for (MFIter mfi(S_old_tmp,true); mfi.isValid(); ++mfi) { @@ -173,8 +174,6 @@ Nyx::just_the_hydro (Real time, BL_TO_FORTRAN(flux[2]), &cflLoc, &a_old, &a_new, &se, &ske, &print_fortran_warnings, &do_grav); - courno = std::max(courno, cflLoc); - for (int i = 0; i < BL_SPACEDIM; ++i) { fluxes[i][mfi].copy(flux[i], mfi.nodaltilebox(i)); } @@ -183,6 +182,15 @@ Nyx::just_the_hydro (Real time, ke_added += ske; } // end of MFIter loop +#ifdef _OPENMP +#pragma omp critical (hydro_courno) +#endif + { + courno = std::max(courno, cflLoc); + } + + } // end of omp parallel region + // We copy old Temp and Ne to new Temp and Ne so that they can be used // as guesses when we next need them. MultiFab::Copy(D_new,D_old,0,0,2,0); From c6a7c8a34a09a1a7fd45945e0bc7f32d7bddf174 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sat, 26 Aug 2017 14:24:24 -0700 Subject: [PATCH 13/15] Revert "Update the way we handle estdt with OMP -- before we had a serial section" This reverts commit 40a61250329aa260f750fcc0afcbddfd64845a74. --- Source/Nyx.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/Nyx.cpp b/Source/Nyx.cpp index 5e8c9849..0ef310d2 100644 --- a/Source/Nyx.cpp +++ b/Source/Nyx.cpp @@ -807,21 +807,30 @@ Nyx::est_time_step (Real dt_old) Real dt = est_dt; #ifdef _OPENMP -#pragma omp parallel reduction(min:est_dt) +#pragma omp parallel firstprivate(dt) #endif - for (MFIter mfi(stateMF,true); mfi.isValid(); ++mfi) - { - const Box& box = mfi.tilebox(); - fort_estdt - (BL_TO_FORTRAN(stateMF[mfi]), box.loVect(), box.hiVect(), dx, &dt, &a); - est_dt = std::min(est_dt, dt); - } - ParallelDescriptor::ReduceRealMin(est_dt); + { + for (MFIter mfi(stateMF,true); mfi.isValid(); ++mfi) + { + const Box& box = mfi.tilebox(); + + fort_estdt + (BL_TO_FORTRAN(stateMF[mfi]), box.loVect(), box.hiVect(), dx, + &dt, &a); + } +#ifdef _OPENMP +#pragma omp critical (nyx_estdt) +#endif + { + est_dt = std::min(est_dt, dt); + } + } // If in comoving coordinates, then scale dt (based on u and c) by a est_dt *= a; - est_dt *= cfl; + ParallelDescriptor::ReduceRealMin(est_dt); + est_dt *= cfl; if (verbose && ParallelDescriptor::IOProcessor()) std::cout << "...estdt from hydro at level " << level << ": " From b18a27213eb8b4056bbc56cd08dd1e0671be1c11 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Sat, 26 Aug 2017 14:33:09 -0700 Subject: [PATCH 14/15] omp critical --> reduction --- Source/Nyx.cpp | 12 +++--------- Source/Nyx_hydro.cpp | 7 +------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Source/Nyx.cpp b/Source/Nyx.cpp index 0ef310d2..ccf5057c 100644 --- a/Source/Nyx.cpp +++ b/Source/Nyx.cpp @@ -804,12 +804,11 @@ Nyx::est_time_step (Real dt_old) Real a = get_comoving_a(cur_time); const Real* dx = geom.CellSize(); - Real dt = est_dt; - #ifdef _OPENMP -#pragma omp parallel firstprivate(dt) +#pragma omp parallel reduction(min:est_dt) #endif { + Real dt = 1.e200; for (MFIter mfi(stateMF,true); mfi.isValid(); ++mfi) { const Box& box = mfi.tilebox(); @@ -818,12 +817,7 @@ Nyx::est_time_step (Real dt_old) (BL_TO_FORTRAN(stateMF[mfi]), box.loVect(), box.hiVect(), dx, &dt, &a); } -#ifdef _OPENMP -#pragma omp critical (nyx_estdt) -#endif - { - est_dt = std::min(est_dt, dt); - } + est_dt = std::min(est_dt, dt); } // If in comoving coordinates, then scale dt (based on u and c) by a diff --git a/Source/Nyx_hydro.cpp b/Source/Nyx_hydro.cpp index b792fc75..604ac4a4 100644 --- a/Source/Nyx_hydro.cpp +++ b/Source/Nyx_hydro.cpp @@ -129,7 +129,7 @@ Nyx::just_the_hydro (Real time, strang_first_step(time,dt,S_old_tmp,D_old_tmp); #ifdef _OPENMP -#pragma omp parallel +#pragma omp parallel reduction(max:courno) #endif { FArrayBox flux[BL_SPACEDIM], u_gdnv[BL_SPACEDIM]; @@ -182,12 +182,7 @@ Nyx::just_the_hydro (Real time, ke_added += ske; } // end of MFIter loop -#ifdef _OPENMP -#pragma omp critical (hydro_courno) -#endif - { courno = std::max(courno, cflLoc); - } } // end of omp parallel region From 32c44e5e8c8e8a524d5ed2b074e8f867a5e6b4f9 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Thu, 31 Aug 2017 13:39:57 -0700 Subject: [PATCH 15/15] Remove particles.do_tiling and particles.tile_size -- we want to use the defaults for these --- Exec/LyA/inputs | 1 - Exec/LyA/inputs.rt | 1 - Exec/Scaling/inputs | 2 -- 3 files changed, 4 deletions(-) diff --git a/Exec/LyA/inputs b/Exec/LyA/inputs index 66d4c8f3..51144b63 100644 --- a/Exec/LyA/inputs +++ b/Exec/LyA/inputs @@ -73,7 +73,6 @@ nyx.comoving_h = 0.71d0 # PARTICLES nyx.do_dm_particles = 1 -nyx.do_tiling = 1 # >>>>>>>>>>>>> PARTICLE INIT OPTIONS <<<<<<<<<<<<<<<< # "AsciiFile" "Random" "Cosmological" diff --git a/Exec/LyA/inputs.rt b/Exec/LyA/inputs.rt index 18e64339..4ecdc100 100644 --- a/Exec/LyA/inputs.rt +++ b/Exec/LyA/inputs.rt @@ -74,7 +74,6 @@ nyx.comoving_h = 0.71d0 # PARTICLES nyx.do_dm_particles = 1 -nyx.do_tiling = 1 # >>>>>>>>>>>>> PARTICLE INIT OPTIONS <<<<<<<<<<<<<<<< # "AsciiFile" "Random" "Cosmological" diff --git a/Exec/Scaling/inputs b/Exec/Scaling/inputs index ea7bd1d2..2c6b1d5c 100644 --- a/Exec/Scaling/inputs +++ b/Exec/Scaling/inputs @@ -83,8 +83,6 @@ nyx.comoving_h = 0.702d0 # PARTICLES nyx.do_dm_particles = 1 -particles.do_tiling = 1 -particles.tile_size = 2048 4 4 # >>>>>>>>>>>>> PARTICLE INIT OPTIONS <<<<<<<<<<<<<<<< # "AsciiFile" "Random" "Cosmological"