diff --git a/CMakeLists.txt b/CMakeLists.txt index 147110fb739..3ae08a600f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.13) - -project (AMReX) - -enable_language(C) +project(AMReX) enable_language(CXX) enable_language(Fortran) diff --git a/Docs/sphinx_documentation/source/Basics.rst b/Docs/sphinx_documentation/source/Basics.rst index a3727b82f25..b55078cca44 100644 --- a/Docs/sphinx_documentation/source/Basics.rst +++ b/Docs/sphinx_documentation/source/Basics.rst @@ -1996,10 +1996,10 @@ that is readable and easy to implement. An example is given below: Array4 const& src = fab1.array(); Array4 const& dst = fab2.array(); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { + for (int i = lo.x; i <= hi.x; ++i) { dst(i,j,k) = 0.5*(src(i,j,k)+src(i+1,j,k)); } } @@ -2020,7 +2020,7 @@ and :cpp:`Box::bigend` of ``bx``. Both functions return a The individual components are accessed by using :cpp:`.x`, :cpp:`.y` and :cpp:`.z`, as shown in the :cpp:`for` loops. -`BaseFab::array()` is called to obtain an :cpp:`Array4` object that is +:cpp:`BaseFab::array()` is called to obtain an :cpp:`Array4` object that is designed as an independent, :cpp:`operator()` based accessor to the :cpp:`BaseFab` data. :cpp:`Array4` is an AMReX class that contains a pointer to the :cpp:`FArrayBox` data and two :cpp:`Dim3` vectors that @@ -2041,6 +2041,10 @@ macro on loops that are not safe for vectorization will lead to a variety of errors, so if unsure about the independence of the iterations of a loop, test and verify before adding the macro. +These loops should always use :cpp:`i <= hi.x`, not :cpp:`i < hi.x`, when +defining the loop bounds. If not, the highest index cells will be left out +of the calculation. + Ghost Cells =========== diff --git a/Docs/sphinx_documentation/source/BuildingAMReX.rst b/Docs/sphinx_documentation/source/BuildingAMReX.rst index f56044eb842..d53670a6589 100644 --- a/Docs/sphinx_documentation/source/BuildingAMReX.rst +++ b/Docs/sphinx_documentation/source/BuildingAMReX.rst @@ -364,6 +364,8 @@ below. +------------------------------+-------------------------------------------------+-------------+-----------------+ | BLITZ_INSTALL_DIR | Path to Blitz installation directory | | user-defined | +------------------------------+-------------------------------------------------+-------------+-----------------+ + | ENABLE_SUNDIALS | Enable SUNDIALS3 interfaces | OFF | ON, OFF | + +------------------------------+-------------------------------------------------+-------------+-----------------+ .. raw:: latex \end{center} diff --git a/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst b/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst index 6a6b275f444..4b34915178b 100644 --- a/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst +++ b/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst @@ -13,6 +13,10 @@ its own build system and links to AMReX as an external library. Finally, AMReX can also be built with CMake, as detailed in the section on :ref:`sec:build:cmake`. +Please note that we fully support AMReX for Linux systems in general and on the +DOE supercomputers (e.g. Cori, Summit) in particular. Many of our users do build +and use AMReX on Macs but we do not have the resources to fully support Mac users. + .. toctree:: :maxdepth: 2 diff --git a/Docs/sphinx_documentation/source/ForkJoin.rst b/Docs/sphinx_documentation/source/ForkJoin.rst new file mode 100644 index 00000000000..0e34b10f66e --- /dev/null +++ b/Docs/sphinx_documentation/source/ForkJoin.rst @@ -0,0 +1,57 @@ +.. role:: cpp(code) + :language: c++ + +.. role:: fortran(code) + :language: fortran + +Fork-Join +========= + +An AMReX program consists of a set of MPI ranks cooperating together on +distributed data. +Typically, all of the ranks in a job compute in a bulk-synchronous, +data-parallel fashion, where every rank does the same sequence of +operations, each on different parts of the distributed data. + +The AMReX Fork-Join functionality described here allows the user to divide the +job's MPI ranks into subgroups (i.e. `fork`) and assign each subgroup +an independent task to compute in parallel with each other. +After all of the forked child tasks complete, they synchronize +(i.e. `join`), and the parent task continues execution as before. + +.. figure:: figs/fork_join_tasks.png + :scale: 80 % + :align: center + :alt: Fork-Join Tasks + + Example of a fork-join operation where the parent task's MPI processes (ranks) are + split into two independent child tasks that execute in parallel and + then join to resume execution of the parent task. + +The Fork-Join operation can also be invoked in a nested fashion, +creating a hierarchy of fork-join operations, where each fork further +subdivides the ranks of a task into child tasks. +This approach enables heterogeneous computation and reduces the strong +scaling penalty for operations with less inherent parallelism or with +large communication overheads. + +.. figure:: figs/nested_fork_join_tasks.png + :scale: 80 % + :align: center + :alt: Nested Fork-Join Tasks + + Example of nested fork-join operations where a child task is further + split into more subtasks. + +The fork-join operation is accomplished by: + + a) redistributing MultiFab data so that **all** of the data in each + registered MultiFab is visible to ranks within a subtask, and + + b) dividing the root MPI communicator into sub-communicators so that + each subgroup of ranks in a tasks will only synchronize with each + other during subtask collectives (e.g. for ``MPI_Allreduce``). + +When the program starts, all of the ranks in the MPI communicator are +in the root task. + diff --git a/Docs/sphinx_documentation/source/figs/fork_join_tasks.png b/Docs/sphinx_documentation/source/figs/fork_join_tasks.png new file mode 100755 index 00000000000..fc44da10460 Binary files /dev/null and b/Docs/sphinx_documentation/source/figs/fork_join_tasks.png differ diff --git a/Docs/sphinx_documentation/source/figs/nested_fork_join_tasks.png b/Docs/sphinx_documentation/source/figs/nested_fork_join_tasks.png new file mode 100755 index 00000000000..8b308bf2b18 Binary files /dev/null and b/Docs/sphinx_documentation/source/figs/nested_fork_join_tasks.png differ diff --git a/Docs/sphinx_documentation/source/index.rst b/Docs/sphinx_documentation/source/index.rst index efb2755a362..c475e0c7b71 100644 --- a/Docs/sphinx_documentation/source/index.rst +++ b/Docs/sphinx_documentation/source/index.rst @@ -3,7 +3,7 @@ Welcome to AMReX's documentation ================================ -AMReX is a software framework library containing all the functionality to write +AMReX is a software framework containing all the functionality to write massively parallel, block-structured adaptive mesh refinement (AMR) applications. AMReX is freely available `on Github `_. @@ -42,6 +42,7 @@ Documentation on migration from BoxLib is available in the AMReX repository at D AmrCore_Chapter AmrLevel_Chapter AsyncIter_Chapter + ForkJoin IO_Chapter LinearSolvers_Chapter Particle_Chapter diff --git a/Src/Amr/AMReX_Amr.H b/Src/Amr/AMReX_Amr.H index bf82c003429..0e36d28b8c1 100644 --- a/Src/Amr/AMReX_Amr.H +++ b/Src/Amr/AMReX_Amr.H @@ -73,73 +73,77 @@ public: void FinalizeInit (Real strt_time, Real stop_time); //! Set the timestep on each level. - void setDtLevel (const Vector& dt_lev); + void setDtLevel (const Vector& dt_lev) noexcept; //! Set the timestep at one level. - void setDtLevel (Real dt, int lev); + void setDtLevel (Real dt, int lev) noexcept; //! Set the dtmin on each level. - void setDtMin (const Vector& dt_lev); + void setDtMin (const Vector& dt_lev) noexcept; //! Set the cycle count on each level. - void setNCycle (const Vector& mss); + void setNCycle (const Vector& mss) noexcept; //! Subcycle in time? - int subCycle () const { return sub_cycle; } + int subCycle () const noexcept { return sub_cycle; } //! How are we subcycling? - const std::string& subcyclingMode() const { return subcycling_mode; } + const std::string& subcyclingMode() const noexcept { return subcycling_mode; } /** * \brief What is "level" in Amr::timeStep? This is only relevant if we are still in Amr::timeStep; * it is set back to -1 on leaving Amr::timeStep. */ - int level_being_advanced () const { return which_level_being_advanced; } + int level_being_advanced () const noexcept { return which_level_being_advanced; } //! Physical time. - Real cumTime () const { return cumtime; } - void setCumTime (Real t) {cumtime = t;} + Real cumTime () const noexcept { return cumtime; } + void setCumTime (Real t) noexcept {cumtime = t;} //! Physical time this simulation started - Real startTime () const { return start_time; } - void setStartTime (Real t) {start_time = t;} + Real startTime () const noexcept { return start_time; } + void setStartTime (Real t) noexcept {start_time = t;} //! Time step at specified level. - Real dtLevel (int level) const { return dt_level[level]; } + Real dtLevel (int level) const noexcept { return dt_level[level]; } //! Max time step (typically based on physics) at specified level - Real dtMin (int level) const { return dt_min[level]; } + Real dtMin (int level) const noexcept { return dt_min[level]; } //! Array of time steps at all levels. - const Vector& dtLevel () const { return dt_level; } + const Vector& dtLevel () const noexcept { return dt_level; } //! Number of subcycled time steps. - int nCycle (int level) const { return n_cycle[level]; } + int nCycle (int level) const noexcept { return n_cycle[level]; } //! Number of time steps at specified level. - int levelSteps (int lev) const { return level_steps[lev]; } + int levelSteps (int lev) const noexcept { return level_steps[lev]; } //! Number of time steps at specified level. - void setLevelSteps (int lev, int n) { level_steps[lev] = n; } + void setLevelSteps (int lev, int n) noexcept { level_steps[lev] = n; } //! Which step are we at for the specified level? - int levelCount (int lev) const { return level_count[lev]; } + int levelCount (int lev) const noexcept { return level_count[lev]; } //! Which step are we at for the specified level? - void setLevelCount (int lev, int n) { level_count[lev] = n; } + void setLevelCount (int lev, int n) noexcept { level_count[lev] = n; } //! Whether to regrid right after restart - bool RegridOnRestart () const; + bool RegridOnRestart () const noexcept; //! Interval between regridding. - int regridInt (int lev) const { return regrid_int[lev]; } + int regridInt (int lev) const noexcept { return regrid_int[lev]; } //! Number of time steps between checkpoint files. - int checkInt () const { return check_int; } + int checkInt () const noexcept { return check_int; } //! Time between checkpoint files. - Real checkPer() const { return check_per; } + Real checkPer() const noexcept { return check_per; } //! Number of time steps between plot files. - int plotInt () const { return plot_int; } + int plotInt () const noexcept { return plot_int; } //! Time between plot files. - Real plotPer () const { return plot_per; } + Real plotPer () const noexcept { return plot_per; } + //! Spacing in log10(time) of logarithmically spaced plot files + Real plotLogPer () const noexcept { return plot_log_per; } //! Number of time steps between small plot files. - int smallplotInt () const { return small_plot_int; } + int smallplotInt () const noexcept { return small_plot_int; } //! Time between plot files. - Real smallplotPer () const { return small_plot_per; } + Real smallplotPer () const noexcept { return small_plot_per; } + //! Spacing in log10(time) of logarithmically spaced small plot files + Real smallplotLogPer () const noexcept { return small_plot_log_per; } /** * \brief The names of state variables to output in the * plotfile. They can be set using the amr.plot_vars variable * in a ParmParse inputs file. */ - static const std::list& statePlotVars () { return state_plot_vars; } - static const std::list& stateSmallPlotVars () { return state_small_plot_vars; } + static const std::list& statePlotVars () noexcept { return state_plot_vars; } + static const std::list& stateSmallPlotVars () noexcept { return state_small_plot_vars; } //! Is the string the name of a variable in state_plot_vars? static bool isStatePlotVar (const std::string& name); static bool isStateSmallPlotVar (const std::string& name); @@ -164,11 +168,11 @@ public: * plotfile. They can be set using the amr.derive_plot_vars * variable in a ParmParse inputs file. */ - static const std::list& derivePlotVars () { return derive_plot_vars; } - static const std::list& deriveSmallPlotVars () { return derive_small_plot_vars; } + static const std::list& derivePlotVars () noexcept { return derive_plot_vars; } + static const std::list& deriveSmallPlotVars () noexcept { return derive_small_plot_vars; } //! Is the string the name of a variable in derive_plot_vars? - static bool isDerivePlotVar (const std::string& name); - static bool isDeriveSmallPlotVar (const std::string& name); + static bool isDerivePlotVar (const std::string& name) noexcept; + static bool isDeriveSmallPlotVar (const std::string& name) noexcept; /** * \brief If the string is not the name of a variable in * derive_plot_vars, add it to derive_plot_vars. @@ -188,28 +192,28 @@ public: static void Initialize (); static void Finalize (); //! AmrLevel lev. - AmrLevel& getLevel (int lev) { return *amr_level[lev]; } + AmrLevel& getLevel (int lev) noexcept { return *amr_level[lev]; } //! Array of AmrLevels. - Vector >& getAmrLevels (); + Vector >& getAmrLevels () noexcept; //! Total number of cells. - long cellCount (); + long cellCount () noexcept; //! Number of cells at given level. - long cellCount (int lev); + long cellCount (int lev) noexcept; //! Total number of grids. - int numGrids (); + int numGrids () noexcept; //! Number of grids at given level. - int numGrids (int lev); + int numGrids (int lev) noexcept; //! More work to be done? - int okToContinue (); + int okToContinue () noexcept; //! Regrid only! - void RegridOnly (Real time); + void RegridOnly (Real time, bool do_io = true); //! Should we regrid this level? - bool okToRegrid (int level); + bool okToRegrid (int level) noexcept; //! Array of BoxArrays read in to initially define grid hierarchy - static const BoxArray& initialBa (int level) + static const BoxArray& initialBa (int level) noexcept { BL_ASSERT(level-1 < initial_ba.size()); return initial_ba[level-1]; } //! Number of levels at which the grids are initially specified - static int initialBaLevels () { return initial_ba.size(); } + static int initialBaLevels () noexcept { return initial_ba.size(); } //! Do a complete integration cycle. virtual void coarseTimeStep (Real stop_time); @@ -221,15 +225,15 @@ public: int lev, int ngrow); //! Name of the restart chkpoint file. - const std::string& theRestartFile () const { return restart_chkfile; } + const std::string& theRestartFile () const noexcept { return restart_chkfile; } //! Name of the restart plotfile. - const std::string& theRestartPlotFile () const { return restart_pltfile; } + const std::string& theRestartPlotFile () const noexcept { return restart_pltfile; } //! The ith datalog file. Do with it what you want. std::ostream& DataLog (int i); //! The filename of the ith datalog file. - const std::string DataLogName (int i) const { return datalogname[i]; } + const std::string DataLogName (int i) const noexcept { return datalogname[i]; } //! How many datalogs have been opened - int NumDataLogs (); + int NumDataLogs () noexcept; /** * \brief Compute the optimal subcycling pattern. * This assumes that anything less than cycle_max[i] is a valid @@ -245,15 +249,15 @@ public: //! Write the plot file to be used for visualization. virtual void writePlotFile (); - int stepOfLastPlotFile () const {return last_plotfile;} + int stepOfLastPlotFile () const noexcept {return last_plotfile;} //! Write the small plot file to be used for visualization. virtual void writeSmallPlotFile (); - int stepOfLastSmallPlotFile () const {return last_smallplotfile;} + int stepOfLastSmallPlotFile () const noexcept {return last_smallplotfile;} //! Write current state into a chk* file. virtual void checkPoint (); - int stepOfLastCheckPoint () const {return last_checkpoint;} + int stepOfLastCheckPoint () const noexcept {return last_checkpoint;} - const Vector& getInitialBA(); + const Vector& getInitialBA() noexcept; /** * \brief Specialized version: @@ -264,7 +268,7 @@ public: void setBoundaryGeometry(BoundaryPointList& IntersectLoX, BoundaryPointList& IntersectHiX, BoundaryPointList& IntersectLoY, - BoundaryPointList& IntersectHiY) + BoundaryPointList& IntersectHiY) noexcept { intersect_lox = IntersectLoX; intersect_hix = IntersectHiX; @@ -284,7 +288,7 @@ public: BoundaryPointList& IntersectLoY, BoundaryPointList& IntersectHiY, BoundaryPointList& IntersectLoZ, - BoundaryPointList& IntersectHiZ) + BoundaryPointList& IntersectHiZ) noexcept { intersect_lox = IntersectLoX; intersect_hix = IntersectHiX; @@ -294,27 +298,27 @@ public: intersect_hiz = IntersectHiZ; }; - BoundaryPointList& getIntersectLoX() + BoundaryPointList& getIntersectLoX() noexcept { return intersect_lox; }; - BoundaryPointList& getIntersectHiX() + BoundaryPointList& getIntersectHiX() noexcept { return intersect_hix; }; - BoundaryPointList& getIntersectLoY() + BoundaryPointList& getIntersectLoY() noexcept { return intersect_loy; }; - BoundaryPointList& getIntersectHiY() + BoundaryPointList& getIntersectHiY() noexcept { return intersect_hiy; }; - BoundaryPointList& getIntersectLoZ() + BoundaryPointList& getIntersectLoZ() noexcept { return intersect_loz; }; - BoundaryPointList& getIntersectHiZ() + BoundaryPointList& getIntersectHiZ() noexcept { return intersect_hiz; }; @@ -326,7 +330,7 @@ public: void InstallNewDistributionMap (int lev, const DistributionMapping& newdm); - bool UsingPrecreateDirectories(); + bool UsingPrecreateDirectories () noexcept; protected: @@ -380,8 +384,8 @@ protected: { amrex::Abort("How did we get her!"); } //! Whether to write a plotfile now - bool writePlotNow (); - bool writeSmallPlotNow (); + bool writePlotNow () noexcept; + bool writeSmallPlotNow () noexcept; void printGridInfo (std::ostream& os, int min_lev, @@ -426,8 +430,10 @@ protected: int last_smallplotfile; //!< Step number of previous small plotfile. int plot_int; //!< How often plotfile (# of time steps) Real plot_per; //!< How often plotfile (in units of time) + Real plot_log_per; //!< How often plotfile (in units of log10(time)) int small_plot_int; //!< How often small plotfile (# of time steps) Real small_plot_per; //!< How often small plotfile (in units of time) + Real small_plot_log_per; //!< How often small plotfile (in units of log10(time)) int write_plotfile_with_checkpoint; //!< Write out a plotfile whenever we checkpoint int file_name_digits; //!< How many digits to use in the plotfile and checkpoint names int message_int; //!< How often checking messages touched by user, such as "stop_run" diff --git a/Src/Amr/AMReX_Amr.cpp b/Src/Amr/AMReX_Amr.cpp index f823a2607b8..823004634d3 100644 --- a/Src/Amr/AMReX_Amr.cpp +++ b/Src/Amr/AMReX_Amr.cpp @@ -128,7 +128,7 @@ namespace bool -Amr::UsingPrecreateDirectories() +Amr::UsingPrecreateDirectories () noexcept { return precreateDirectories; } @@ -188,38 +188,38 @@ Amr::DataLog (int i) } int -Amr::NumDataLogs () +Amr::NumDataLogs () noexcept { return datalog.size(); } bool -Amr::RegridOnRestart () const +Amr::RegridOnRestart () const noexcept { return regrid_on_restart; } void -Amr::setDtMin (const Vector& dt_min_in) +Amr::setDtMin (const Vector& dt_min_in) noexcept { for (int i = 0; i <= finest_level; i++) dt_min[i] = dt_min_in[i]; } Vector >& -Amr::getAmrLevels () +Amr::getAmrLevels () noexcept { return amr_level; } long -Amr::cellCount (int lev) +Amr::cellCount (int lev) noexcept { return amr_level[lev]->countCells(); } int -Amr::numGrids (int lev) +Amr::numGrids (int lev) noexcept { return amr_level[lev]->numGrids(); } @@ -655,7 +655,7 @@ Amr::deleteStatePlotVar (const std::string& name) } bool -Amr::isDerivePlotVar (const std::string& name) +Amr::isDerivePlotVar (const std::string& name) noexcept { for (std::list::const_iterator li = derive_plot_vars.begin(), End = derive_plot_vars.end(); li != End; @@ -670,7 +670,7 @@ Amr::isDerivePlotVar (const std::string& name) } bool -Amr::isDeriveSmallPlotVar (const std::string& name) +Amr::isDeriveSmallPlotVar (const std::string& name) noexcept { for (std::list::const_iterator li = derive_small_plot_vars.begin(), End = derive_small_plot_vars.end(); li != End; @@ -818,27 +818,27 @@ Amr::setRecordDataInfo (int i, const std::string& filename) } void -Amr::setDtLevel (const Vector& dt_lev) +Amr::setDtLevel (const Vector& dt_lev) noexcept { for (int i = 0; i <= finest_level; i++) dt_level[i] = dt_lev[i]; } void -Amr::setDtLevel (Real dt, int lev) +Amr::setDtLevel (Real dt, int lev) noexcept { dt_level[lev] = dt; } void -Amr::setNCycle (const Vector& ns) +Amr::setNCycle (const Vector& ns) noexcept { for (int i = 0; i <= finest_level; i++) n_cycle[i] = ns[i]; } long -Amr::cellCount () +Amr::cellCount () noexcept { long cnt = 0; for (int i = 0; i <= finest_level; i++) @@ -847,7 +847,7 @@ Amr::cellCount () } int -Amr::numGrids () +Amr::numGrids () noexcept { int cnt = 0; for (int i = 0; i <= finest_level; i++) @@ -856,7 +856,7 @@ Amr::numGrids () } int -Amr::okToContinue () +Amr::okToContinue () noexcept { int ok = true; for (int i = 0; ok && (i <= finest_level); i++) @@ -1211,11 +1211,11 @@ Amr::init (Real strt_time, initialInit(strt_time,stop_time); checkPoint(); - if(plot_int > 0 || plot_per > 0) { + if(plot_int > 0 || plot_per > 0 || plot_log_per > 0) { writePlotFile(); } - if (small_plot_int > 0 || small_plot_per > 0) + if (small_plot_int > 0 || small_plot_per > 0 || small_plot_log_per > 0) writeSmallPlotFile(); updateInSitu(); @@ -1927,7 +1927,7 @@ Amr::checkPoint () } void -Amr::RegridOnly (Real time) +Amr::RegridOnly (Real time, bool do_io) { BL_ASSERT(regrid_on_restart == 1); @@ -1936,14 +1936,18 @@ Amr::RegridOnly (Real time) for (int i = 0; i <= lev_top; i++) regrid(i,time); - if (plotfile_on_restart) - writePlotFile(); + if (do_io) { - if (checkpoint_on_restart) - checkPoint(); + if (plotfile_on_restart) + writePlotFile(); - if (insitu_on_restart) - updateInSitu(); + if (checkpoint_on_restart) + checkPoint(); + + if (insitu_on_restart) + updateInSitu(); + + } } void @@ -2602,7 +2606,7 @@ Amr::coarseTimeStep (Real stop_time) } bool -Amr::writePlotNow() +Amr::writePlotNow() noexcept { int plot_test = 0; if (plot_per > 0.0) @@ -2644,13 +2648,38 @@ Amr::writePlotNow() } + if (plot_log_per > 0.0) + { + + // Check to see if we've crossed a plot_log_per interval by comparing + // the number of intervals that have elapsed for both the current + // time and the time at the beginning of this timestep. + // This only works when cumtime > 0. + + int num_per_old = 0; + int num_per_new = 0; + + if (cumtime-dt_level[0] > 0.) { + num_per_old = log10(cumtime-dt_level[0]) / plot_log_per; + } + if (cumtime > 0.) { + num_per_new = log10(cumtime) / plot_log_per; + } + + if (num_per_old != num_per_new) + { + plot_test = 1; + } + + } + return ( (plot_int > 0 && level_steps[0] % plot_int == 0) || plot_test == 1 || amr_level[0]->writePlotNow()); } bool -Amr::writeSmallPlotNow() +Amr::writeSmallPlotNow() noexcept { int plot_test = 0; if (small_plot_per > 0.0) @@ -2692,6 +2721,31 @@ Amr::writeSmallPlotNow() } + if (small_plot_log_per > 0.0) + { + + // Check to see if we've crossed a small_plot_log_per interval by comparing + // the number of intervals that have elapsed for both the current + // time and the time at the beginning of this timestep. + // This only works when cumtime > 0. + + int num_per_old = 0; + int num_per_new = 0; + + if (cumtime-dt_level[0] > 0.) { + num_per_old = log10(cumtime-dt_level[0]) / small_plot_log_per; + } + if (cumtime > 0.) { + num_per_new = log10(cumtime) / small_plot_log_per; + } + + if (num_per_old != num_per_new) + { + plot_test = 1; + } + + } + return ( (small_plot_int > 0 && level_steps[0] % small_plot_int == 0) || plot_test == 1 || amr_level[0]->writeSmallPlotNow()); @@ -3427,6 +3481,9 @@ Amr::initPltAndChk () plot_per = -1.0; pp.query("plot_per",plot_per); + plot_log_per = -1.0; + pp.query("plot_log_per",plot_log_per); + if (plot_int > 0 && plot_per > 0) { if (ParallelDescriptor::IOProcessor()) @@ -3442,6 +3499,9 @@ Amr::initPltAndChk () small_plot_per = -1.0; pp.query("small_plot_per",small_plot_per); + small_plot_log_per = -1.0; + pp.query("small_plot_log_per",small_plot_log_per); + if (small_plot_int > 0 && small_plot_per > 0) { if (ParallelDescriptor::IOProcessor()) @@ -3474,7 +3534,7 @@ Amr::initPltAndChk () bool -Amr::okToRegrid(int level) +Amr::okToRegrid(int level) noexcept { if (regrid_int[level] < 0) return false; @@ -3529,7 +3589,7 @@ Amr::computeOptimalSubcycling(int n, int* best, Real* dt_max, Real* est_work, in return best_dt; } -const Vector& Amr::getInitialBA() +const Vector& Amr::getInitialBA() noexcept { return initial_ba; } diff --git a/Src/Amr/AMReX_AmrLevel.H b/Src/Amr/AMReX_AmrLevel.H index 7ad3967d69b..c100666b53f 100644 --- a/Src/Amr/AMReX_AmrLevel.H +++ b/Src/Amr/AMReX_AmrLevel.H @@ -66,7 +66,7 @@ public: * \brief Set if the Level_ directory was created or to clear the value. * CreateLevelDirectory sets levelDirectoryCreated = true */ - void SetLevelDirectoryCreated(bool ldc) { levelDirectoryCreated = ldc; } + void SetLevelDirectoryCreated(bool ldc) noexcept { levelDirectoryCreated = ldc; } /** * \brief A string written as the first item in writePlotFile() at * level zero. @@ -236,37 +236,37 @@ public: //! Reset data to initial time by swapping new and old time data. void reset (); //! Returns this AmrLevel. - int Level () const { return level; } + int Level () const noexcept { return level; } //! List of grids at this level. - const BoxArray& boxArray () const { return grids; } - const BoxArray& getEdgeBoxArray (int dir) const; - const BoxArray& getNodalBoxArray () const; + const BoxArray& boxArray () const noexcept { return grids; } + const BoxArray& getEdgeBoxArray (int dir) const noexcept; + const BoxArray& getNodalBoxArray () const noexcept; // - const DistributionMapping& DistributionMap () const { return dmap; } + const DistributionMapping& DistributionMap () const noexcept { return dmap; } // - const FabFactory& Factory () const { return *m_factory; } + const FabFactory& Factory () const noexcept { return *m_factory; } //! Number of grids at this level. - int numGrids () const { return grids.size(); } + int numGrids () const noexcept { return grids.size(); } //! Number of states at this level. - int numStates () const { return state.size(); } + int numStates () const noexcept { return state.size(); } //! Returns the indices defining physical domain. - const Box& Domain () const { return geom.Domain(); } + const Box& Domain () const noexcept { return geom.Domain(); } //! Timestep n at this level. - int nStep () const { return parent->levelSteps(level); } + int nStep () const noexcept { return parent->levelSteps(level); } //! Returns the geometry object. - const Geometry& Geom () const { return geom; } + const Geometry& Geom () const noexcept { return geom; } // - const IntVect& fineRatio () const { return fine_ratio; } + const IntVect& fineRatio () const noexcept { return fine_ratio; } //! Returns number of cells on level. - long countCells () const; + long countCells () const noexcept; //! Get the area not to tag. - const BoxArray& getAreaNotToTag(); - const Box& getAreaToTag(); + const BoxArray& getAreaNotToTag() noexcept; + const Box& getAreaToTag() noexcept; //! Constuct the area not to tag. void constructAreaNotToTag(); //! Set the area not to tag. - void setAreaNotToTag(BoxArray& ba); + void setAreaNotToTag(BoxArray& ba) noexcept; /** * \brief Error estimation for regridding. This is a pure virtual @@ -311,23 +311,23 @@ public: MultiFab& mf, int dcomp); //! State data object. - StateData& get_state_data (int state_indx) { return state[state_indx]; } + StateData& get_state_data (int state_indx) noexcept { return state[state_indx]; } //! State data at old time. - MultiFab& get_old_data (int state_indx) { return state[state_indx].oldData(); } + MultiFab& get_old_data (int state_indx) noexcept { return state[state_indx].oldData(); } //! State data at old time. - const MultiFab& get_old_data (int state_indx) const { return state[state_indx].oldData(); } + const MultiFab& get_old_data (int state_indx) const noexcept { return state[state_indx].oldData(); } //! State data at new time. - MultiFab& get_new_data (int state_indx) { return state[state_indx].newData(); } + MultiFab& get_new_data (int state_indx) noexcept { return state[state_indx].newData(); } //! State data at new time. - const MultiFab& get_new_data (int state_indx) const { return state[state_indx].newData(); } + const MultiFab& get_new_data (int state_indx) const noexcept { return state[state_indx].newData(); } //! Returns list of Descriptors. - static const DescriptorList& get_desc_lst () { return desc_lst; } + static const DescriptorList& get_desc_lst () noexcept { return desc_lst; } //! Returns list of derived variables. - static DeriveList& get_derive_lst (); + static DeriveList& get_derive_lst () noexcept; //! Returns whether or not we want a post-timestep regrid. - int postStepRegrid () { return post_step_regrid; } + int postStepRegrid () noexcept { return post_step_regrid; } //! Sets a new value for the post-timestep regrid trigger. - void setPostStepRegrid (int new_val) { post_step_regrid = new_val; } + void setPostStepRegrid (int new_val) noexcept { post_step_regrid = new_val; } //! Update the distribution maps in StateData based on the size of the map void UpdateDistributionMaps ( DistributionMapping& dmap ); @@ -338,8 +338,7 @@ public: int scomp, int ncomp); //! Get state data at specified index and time. - MultiFab& get_data (int state_indx, - Real time); + MultiFab& get_data (int state_indx, Real time) noexcept; //! Hack to allow override of (non-fine-fine) fillpatched boundary data virtual void set_preferred_boundary_values (MultiFab& S, int state_index, @@ -371,8 +370,7 @@ public: * \brief Returns one the TimeLevel enums. * Asserts that time is between AmrOldTime and AmrNewTime. */ - TimeLevel which_time (int state_indx, - Real time) const; + TimeLevel which_time (int state_indx, Real time) const noexcept; //! Does the AmrLevel want Amr to write a plotfile now? virtual bool writePlotNow (); @@ -404,7 +402,7 @@ public: int dcomp=0); #ifdef AMREX_USE_EB - static void SetEBMaxGrowCells (int nbasic, int nvolume, int nfull) { + static void SetEBMaxGrowCells (int nbasic, int nvolume, int nfull) noexcept { m_eb_basic_grow_cells = nbasic; m_eb_volume_grow_cells = nvolume; m_eb_full_grow_cells = nfull; @@ -418,7 +416,7 @@ public: protected: //! The constructors -- for derived classes. - AmrLevel (); + AmrLevel () noexcept; AmrLevel (Amr& papa, int lev, @@ -494,11 +492,11 @@ class FillPatchIterator ~FillPatchIterator (); - FArrayBox& operator() () { return m_fabs[MFIter::index()]; } + FArrayBox& operator() () noexcept { return m_fabs[MFIter::index()]; } - Box UngrownBox () const { return MFIter::validbox(); } + Box UngrownBox () const noexcept { return MFIter::validbox(); } - MultiFab& get_mf() { return m_fabs; } + MultiFab& get_mf() noexcept { return m_fabs; } #ifdef USE_PERILLA FillPatchIterator (AmrLevel& amrlevel, diff --git a/Src/Amr/AMReX_AmrLevel.cpp b/Src/Amr/AMReX_AmrLevel.cpp index 29dcf704a5b..a3d8abf159b 100644 --- a/Src/Amr/AMReX_AmrLevel.cpp +++ b/Src/Amr/AMReX_AmrLevel.cpp @@ -63,7 +63,7 @@ AmrLevel::set_preferred_boundary_values (MultiFab& S, {} DeriveList& -AmrLevel::get_derive_lst () +AmrLevel::get_derive_lst () noexcept { return derive_lst; } @@ -73,7 +73,7 @@ AmrLevel::manual_tags_placement (TagBoxArray& tags, const Vector& bf_lev) {} -AmrLevel::AmrLevel () +AmrLevel::AmrLevel () noexcept { BL_PROFILE("AmrLevel::AmrLevel()"); @@ -454,7 +454,7 @@ AmrLevel::isStateVariable (const std::string& name, int& typ, int& n) } long -AmrLevel::countCells () const +AmrLevel::countCells () const noexcept { return grids.numPts(); } @@ -555,8 +555,7 @@ AmrLevel::reset () } MultiFab& -AmrLevel::get_data (int state_indx, - Real time) +AmrLevel::get_data (int state_indx, Real time) noexcept { const Real old_time = state[state_indx].prevTime(); const Real new_time = state[state_indx].curTime(); @@ -577,7 +576,7 @@ AmrLevel::get_data (int state_indx, } const BoxArray& -AmrLevel::getEdgeBoxArray (int dir) const +AmrLevel::getEdgeBoxArray (int dir) const noexcept { BL_ASSERT(dir >=0 && dir < AMREX_SPACEDIM); if (edge_grids[dir].empty()) { @@ -588,7 +587,7 @@ AmrLevel::getEdgeBoxArray (int dir) const } const BoxArray& -AmrLevel::getNodalBoxArray () const +AmrLevel::getNodalBoxArray () const noexcept { if (nodal_grids.empty()) { nodal_grids = grids; @@ -1688,7 +1687,7 @@ AmrLevel::derive (const std::string& name, Real time, int ngrow) AMREX_BCREC_3D(bcr), &level,&grid_no); } else { - amrex::Error("AmeLevel::derive: no function available"); + amrex::Error("AmrLevel::derive: no function available"); } } #else @@ -1726,7 +1725,7 @@ AmrLevel::derive (const std::string& name, Real time, int ngrow) AMREX_BCREC_3D(bcr), &level,&grid_no); } else { - amrex::Error("AmeLevel::derive: no function available"); + amrex::Error("AmrLevel::derive: no function available"); } } #endif @@ -1837,7 +1836,7 @@ AmrLevel::derive (const std::string& name, Real time, MultiFab& mf, int dcomp) AMREX_BCREC_3D(bcr), &level,&idx); } else { - amrex::Error("AmeLevel::derive: no function available"); + amrex::Error("AmrLevel::derive: no function available"); } } #else @@ -1875,7 +1874,7 @@ AmrLevel::derive (const std::string& name, Real time, MultiFab& mf, int dcomp) AMREX_BCREC_3D(bcr), &level,&idx); } else { - amrex::Error("AmeLevel::derive: no function available"); + amrex::Error("AmrLevel::derive: no function available"); } } #endif @@ -2055,8 +2054,7 @@ AmrLevel::setSmallPlotVariables () } AmrLevel::TimeLevel -AmrLevel::which_time (int indx, - Real time) const +AmrLevel::which_time (int indx, Real time) const noexcept { const Real oldtime = state[indx].prevTime(); const Real newtime = state[indx].curTime(); @@ -2108,17 +2106,17 @@ AmrLevel::writeSmallPlotNow () return false; } -const BoxArray& AmrLevel::getAreaNotToTag () +const BoxArray& AmrLevel::getAreaNotToTag () noexcept { return m_AreaNotToTag; } -const Box& AmrLevel::getAreaToTag () +const Box& AmrLevel::getAreaToTag () noexcept { return m_AreaToTag; } -void AmrLevel::setAreaNotToTag (BoxArray& ba) +void AmrLevel::setAreaNotToTag (BoxArray& ba) noexcept { m_AreaNotToTag = ba; } diff --git a/Src/Amr/AMReX_AuxBoundaryData.H b/Src/Amr/AMReX_AuxBoundaryData.H index 465c5cb91f3..78719faea55 100644 --- a/Src/Amr/AMReX_AuxBoundaryData.H +++ b/Src/Amr/AMReX_AuxBoundaryData.H @@ -11,7 +11,7 @@ class AuxBoundaryData { public: - AuxBoundaryData (); + AuxBoundaryData () noexcept; AuxBoundaryData (const BoxArray& grids, int n_grow, @@ -20,6 +20,8 @@ public: AuxBoundaryData (const AuxBoundaryData& rhs); + AuxBoundaryData& operator= (const AuxBoundaryData& rhs) = delete; + void copyTo (MultiFab& destmf, int src_comp, int dst_comp, @@ -31,7 +33,7 @@ public: int num_comp, int src_ng = 0); - size_t size () const + size_t size () const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.size(); } @@ -46,44 +48,44 @@ public: int n_comp, const Geometry& geom); - const BoxArray& equivBoxArray () const + const BoxArray& equivBoxArray () const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.boxArray(); } void setVal (Real r) { BL_ASSERT(m_initialized); if (!m_empty) m_fabs.setVal(r); } - const DistributionMapping& DistributionMap () const + const DistributionMapping& DistributionMap () const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.DistributionMap(); } - FArrayBox& operator[] (const MFIter& mfi) + FArrayBox& operator[] (const MFIter& mfi) noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs[mfi]; } - const FArrayBox& operator[] (const MFIter& mfi) const + const FArrayBox& operator[] (const MFIter& mfi) const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs[mfi]; } - FArrayBox * fabPtr (const MFIter& mfi) + FArrayBox * fabPtr (const MFIter& mfi) noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.fabPtr(mfi); } - FArrayBox const* fabPtr (const MFIter& mfi) const + FArrayBox const* fabPtr (const MFIter& mfi) const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.fabPtr(mfi); } - int nGrow () const { BL_ASSERT(m_initialized); return m_ngrow; } + int nGrow () const noexcept { BL_ASSERT(m_initialized); return m_ngrow; } - int nComp () const + int nComp () const noexcept { BL_ASSERT(!m_empty); BL_ASSERT(m_initialized); return m_fabs.nComp(); } - bool isEmpty () const { return m_empty; } + bool isEmpty () const noexcept { return m_empty; } private: @@ -91,10 +93,6 @@ private: int m_ngrow; bool m_empty; bool m_initialized; - // - // Not defined -- but could be if it's needed. - // - AuxBoundaryData& operator= (const AuxBoundaryData& rhs); }; // \endcond diff --git a/Src/Amr/AMReX_AuxBoundaryData.cpp b/Src/Amr/AMReX_AuxBoundaryData.cpp index 50b62185c71..d16c262eb8b 100644 --- a/Src/Amr/AMReX_AuxBoundaryData.cpp +++ b/Src/Amr/AMReX_AuxBoundaryData.cpp @@ -8,7 +8,7 @@ namespace amrex { -AuxBoundaryData::AuxBoundaryData () +AuxBoundaryData::AuxBoundaryData () noexcept : m_ngrow(0), m_empty(false), diff --git a/Src/Amr/AMReX_Derive.H b/Src/Amr/AMReX_Derive.H index 5948d3fbf9c..42eb0d4b9b8 100644 --- a/Src/Amr/AMReX_Derive.H +++ b/Src/Amr/AMReX_Derive.H @@ -112,9 +112,9 @@ public: */ typedef Box (*DeriveBoxMap)(const Box&); - static Box TheSameBox (const Box& box); + static Box TheSameBox (const Box& box) noexcept; - static Box GrowBoxByOne (const Box& box); + static Box GrowBoxByOne (const Box& box) noexcept; /** * \brief The destructor. @@ -124,56 +124,56 @@ public: /** * \brief The name of the derived type. */ - const std::string& name () const; + const std::string& name () const noexcept; /** * \brief The names of components * * \param comp */ - const std::string& variableName (int comp) const; + const std::string& variableName (int comp) const noexcept; /** * \brief The IndexType of the derived type. */ - IndexType deriveType () const; + IndexType deriveType () const noexcept; /** * \brief The DeriveFunc used to calculate the derived type. */ - DeriveFunc derFunc () const; - DeriveFunc3D derFunc3D () const; - DeriveFuncFab derFuncFab () const; + DeriveFunc derFunc () const noexcept; + DeriveFunc3D derFunc3D () const noexcept; + DeriveFuncFab derFuncFab () const noexcept; /** * \brief Maps state data box to derived data box. */ - DeriveBoxMap boxMap () const; + DeriveBoxMap boxMap () const noexcept; /** * \brief Type of interpolater to use in computing derived type. */ - Interpolater* interp () const; + Interpolater* interp () const noexcept; /** * \brief Number of components in the derived type. */ - int numDerive () const; + int numDerive () const noexcept; /** * \brief Number of different chunks of state data needed for derived type. */ - int numRange () const; + int numRange () const noexcept; /** * \brief Total number of state variables needed for derived type. */ - int numState () const; + int numState () const noexcept; /** * \brief The boundary conditions. */ - const int* getBC () const; + const int* getBC () const noexcept; /** * \brief Sets state_indx, src_comp and num_comp for the kth @@ -341,6 +341,9 @@ public: */ DeriveList (); + DeriveList (const DeriveList&) = delete; + DeriveList& operator= (const DeriveList&) = delete; + /** * \brief Determines whether quantity identified by \ is in the registry. * @@ -456,13 +459,6 @@ public: private: - /** - * \brief Disallowed. - * - */ - DeriveList (const DeriveList&); - DeriveList& operator= (const DeriveList&); - std::list lst; }; diff --git a/Src/Amr/AMReX_Derive.cpp b/Src/Amr/AMReX_Derive.cpp index 5d52a3bc891..8b429ad859d 100644 --- a/Src/Amr/AMReX_Derive.cpp +++ b/Src/Amr/AMReX_Derive.cpp @@ -7,13 +7,13 @@ namespace amrex { Box -DeriveRec::TheSameBox (const Box& box) +DeriveRec::TheSameBox (const Box& box) noexcept { return box; } Box -DeriveRec::GrowBoxByOne (const Box& box) +DeriveRec::GrowBoxByOne (const Box& box) noexcept { return amrex::grow(box,1); } @@ -148,67 +148,67 @@ DeriveRec::~DeriveRec () } const std::string& -DeriveRec::name () const +DeriveRec::name () const noexcept { return derive_name; } IndexType -DeriveRec::deriveType () const +DeriveRec::deriveType () const noexcept { return der_type; } DeriveFunc -DeriveRec::derFunc () const +DeriveRec::derFunc () const noexcept { return func; } DeriveFunc3D -DeriveRec::derFunc3D () const +DeriveRec::derFunc3D () const noexcept { return func_3d; } DeriveFuncFab -DeriveRec::derFuncFab () const +DeriveRec::derFuncFab () const noexcept { return func_fab; } DeriveRec::DeriveBoxMap -DeriveRec::boxMap () const +DeriveRec::boxMap () const noexcept { return bx_map; } Interpolater* -DeriveRec::interp () const +DeriveRec::interp () const noexcept { return mapper; } int -DeriveRec::numDerive () const +DeriveRec::numDerive () const noexcept { return n_derive; } int -DeriveRec::numRange () const +DeriveRec::numRange () const noexcept { return nsr; } int -DeriveRec::numState () const +DeriveRec::numState () const noexcept { return n_state; } const int* -DeriveRec::getBC () const +DeriveRec::getBC () const noexcept { return bcr; } @@ -287,7 +287,7 @@ DeriveRec::buildBC (const DescriptorList& d_list) const std::string& -DeriveRec::variableName(int comp) const +DeriveRec::variableName(int comp) const noexcept { if (comp < variable_names.size()) return variable_names[comp]; diff --git a/Src/Amr/AMReX_StateData.H b/Src/Amr/AMReX_StateData.H index 470b735f106..ca77ba2014f 100644 --- a/Src/Amr/AMReX_StateData.H +++ b/Src/Amr/AMReX_StateData.H @@ -286,32 +286,32 @@ public: /** * \brief Returns the StateDescriptor. */ - const StateDescriptor* descriptor () const { return desc; } + const StateDescriptor* descriptor () const noexcept { return desc; } /** * \brief Returns the valid domain. */ - const Box& getDomain () const { return domain; } + const Box& getDomain () const noexcept { return domain; } /** * \brief Returns the BoxArray. */ - const BoxArray& boxArray () const { return grids; } + const BoxArray& boxArray () const noexcept { return grids; } - const DistributionMapping& DistributionMap () const { return dmap; } + const DistributionMapping& DistributionMap () const noexcept { return dmap; } /** * * \param new_dmap */ - void setDistributionMap ( DistributionMapping& new_dmap ) { dmap = new_dmap; } + void setDistributionMap ( DistributionMapping& new_dmap ) noexcept { dmap = new_dmap; } - const FabFactory& Factory () const { return *m_factory; } + const FabFactory& Factory () const noexcept { return *m_factory; } /** * \brief Returns the current time. */ - Real curTime () const { + Real curTime () const noexcept { return (desc->timeType() == StateDescriptor::Point) ? new_time.stop : 0.5*(new_time.start + new_time.stop); } @@ -319,7 +319,7 @@ public: /** * \brief Returns the previous time. */ - Real prevTime () const { + Real prevTime () const noexcept { return (desc->timeType() == StateDescriptor::Point) ? old_time.stop : 0.5*(old_time.start + old_time.stop); } @@ -327,36 +327,36 @@ public: /** * \brief Returns the new data. */ - MultiFab& newData () { BL_ASSERT(new_data != nullptr); return *new_data; } + MultiFab& newData () noexcept { BL_ASSERT(new_data != nullptr); return *new_data; } /** * \brief Returns the new data. */ - const MultiFab& newData () const { BL_ASSERT(new_data != nullptr); return *new_data; } + const MultiFab& newData () const noexcept { BL_ASSERT(new_data != nullptr); return *new_data; } /** * \brief Returns the old data. */ - MultiFab& oldData () { BL_ASSERT(old_data != nullptr); return *old_data; } + MultiFab& oldData () noexcept { BL_ASSERT(old_data != nullptr); return *old_data; } /** * \brief Returns the old data. */ - const MultiFab& oldData () const { BL_ASSERT(old_data != nullptr); return *old_data; } + const MultiFab& oldData () const noexcept { BL_ASSERT(old_data != nullptr); return *old_data; } /** * \brief Returns the FAB of new data at grid index `i'. * * \param i */ - FArrayBox& newGrid (int i) { BL_ASSERT(new_data != nullptr); return (*new_data)[i]; } + FArrayBox& newGrid (int i) noexcept { BL_ASSERT(new_data != nullptr); return (*new_data)[i]; } /** * \brief Returns the FAB of old data at grid index `i'. * * \param i */ - FArrayBox& oldGrid (int i) { BL_ASSERT(old_data != nullptr); return (*old_data)[i]; } + FArrayBox& oldGrid (int i) noexcept { BL_ASSERT(old_data != nullptr); return (*old_data)[i]; } /** * \brief Returns boundary conditions of specified component on the specified grid. @@ -364,7 +364,7 @@ public: * \param comp * \param i */ - BCRec getBC (int comp, int i) const; + BCRec getBC (int comp, int i) const noexcept; /** * \brief Prints out the time interval. @@ -376,12 +376,12 @@ public: /** * \brief True if there is any old data available. */ - bool hasOldData () const { return old_data != nullptr; } + bool hasOldData () const noexcept { return old_data != nullptr; } /** * \brief True if there is any new data available. */ - bool hasNewData () const { return new_data != nullptr; } + bool hasNewData () const noexcept { return new_data != nullptr; } void getData (Vector& data, Vector& datatime, diff --git a/Src/Amr/AMReX_StateData.cpp b/Src/Amr/AMReX_StateData.cpp index 7c647b46929..6d8c59f175d 100644 --- a/Src/Amr/AMReX_StateData.cpp +++ b/Src/Amr/AMReX_StateData.cpp @@ -292,7 +292,7 @@ StateData::allocOldData () } BCRec -StateData::getBC (int comp, int i) const +StateData::getBC (int comp, int i) const noexcept { BCRec bcr; amrex::setBC(grids[i],domain,desc->getBC(comp),bcr); @@ -488,6 +488,12 @@ StateData::FillBoundary (FArrayBox& dest, i++; } } + +#ifdef AMREX_USE_CUDA + // Add a synchronize here in case the user code launched kernels + // to handle the boundary fills. + AMREX_GPU_SAFE_CALL(cudaDeviceSynchronize()); +#endif } void diff --git a/Src/Amr/AMReX_StateDescriptor.H b/Src/Amr/AMReX_StateDescriptor.H index ab5d123e792..0cabac24da9 100644 --- a/Src/Amr/AMReX_StateDescriptor.H +++ b/Src/Amr/AMReX_StateDescriptor.H @@ -47,16 +47,16 @@ public: /** * \brief Bogus constructor. */ - BndryFunc () = default; + BndryFunc () noexcept = default; /** * \brief A Constructor. */ - BndryFunc (BndryFuncDefault inFunc) : m_func(inFunc) {} + BndryFunc (BndryFuncDefault inFunc) noexcept : m_func(inFunc) {} - BndryFunc (BndryFunc3DDefault inFunc) : m_func3D(inFunc) {} + BndryFunc (BndryFunc3DDefault inFunc) noexcept : m_func3D(inFunc) {} - BndryFunc (BndryFuncFabDefault inFunc) : m_funcfab(inFunc) {} + BndryFunc (BndryFuncFabDefault inFunc) noexcept : m_funcfab(inFunc) {} /** * \brief Another Constructor. @@ -64,10 +64,10 @@ public: * \param inFunc * \param gFunc */ - BndryFunc (BndryFuncDefault inFunc,BndryFuncDefault gFunc) + BndryFunc (BndryFuncDefault inFunc,BndryFuncDefault gFunc) noexcept : m_func(inFunc), m_gfunc(gFunc) {} - BndryFunc (BndryFunc3DDefault inFunc,BndryFunc3DDefault gFunc) + BndryFunc (BndryFunc3DDefault inFunc,BndryFunc3DDefault gFunc) noexcept : m_func3D(inFunc), m_gfunc3D(gFunc) {} /** @@ -124,11 +124,11 @@ public: const Vector& bcr, const int bcomp, const int scomp) const; - bool RunOnGPU () const { return m_run_on_gpu; } + bool RunOnGPU () const noexcept { return m_run_on_gpu; } - void setRunOnGPU (bool b) { m_run_on_gpu = b; } + void setRunOnGPU (bool b) noexcept { m_run_on_gpu = b; } - bool hasFabVersion () const { return m_funcfab != nullptr; } + bool hasFabVersion () const noexcept { return m_funcfab != nullptr; } private: @@ -143,7 +143,7 @@ public: /** * \brief The default constructor. */ - StateDescriptor (); + StateDescriptor () noexcept; /** * \brief Constructor that sets all data members. @@ -295,60 +295,60 @@ public: /** * \brief Returns the IndexType. */ - IndexType getType () const; + IndexType getType () const noexcept; /** * \brief Returns StateDescriptor::TimeCenter. */ - StateDescriptor::TimeCenter timeType () const; + StateDescriptor::TimeCenter timeType () const noexcept; /** * \brief Returns number of components. */ - int nComp () const; + int nComp () const noexcept; /** * \brief Returns the grow factor. */ - int nExtra () const; + int nExtra () const noexcept; /** * \brief Returns the interpolater. */ - Interpolater* interp () const; + Interpolater* interp () const noexcept; /** * \brief Returns the interpolater of specified component. * * \param i */ - Interpolater* interp (int i) const; + Interpolater* interp (int i) const noexcept; /** * \brief Returns the name of specified component. * * \param i */ - const std::string& name (int i) const; + const std::string& name (int i) const noexcept; /** * \brief Returns the BCRec of specified component. * * \param i */ - const BCRec& getBC (int i) const; + const BCRec& getBC (int i) const noexcept; /** * \brief Returns all BCRecs. */ - const Vector& getBCs () const; + const Vector& getBCs () const noexcept; /** * \brief Returns the BndryFunc of specified component. * * \param i */ - const BndryFunc& bndryFill (int i) const; + const BndryFunc& bndryFill (int i) const noexcept; /** * \brief Is sc\>=0 \&\& sc+nc\<=ncomp ? @@ -356,7 +356,7 @@ public: * \param sc * \param nc */ - int inRange (int sc, int nc) const; + int inRange (int sc, int nc) const noexcept; /** * \brief Are the interpolaters in the specified range identical? @@ -364,7 +364,7 @@ public: * \param scomp * \param ncomp */ - bool identicalInterps (int scomp, int ncomp) const; + bool identicalInterps (int scomp, int ncomp) const noexcept; // // Returns contiguous ranges of comps with identical interpolaters. // @@ -373,29 +373,31 @@ public: /** * \brief Can extrapolate in time. */ - bool extrap () const; + bool extrap () const noexcept; /** * \brief Should store this StateData in the checkpoint file */ - bool store_in_checkpoint () const; + bool store_in_checkpoint () const noexcept; - bool master (int i) const { return m_master[i]; } + bool master (int i) const noexcept { return m_master[i]; } - int groupsize (int i) const { return m_groupsize[i]; } + int groupsize (int i) const noexcept { return m_groupsize[i]; } /** * \brief will it run on gpu? */ - bool RunOnGPU () const { return bc_func[0]->RunOnGPU(); } + bool RunOnGPU () const noexcept { return bc_func[0]->RunOnGPU(); } /** * \brief has new fab version of BndryFunc? */ - bool hasBndryFuncFab () const { return bc_func[0]->hasFabVersion(); } + bool hasBndryFuncFab () const noexcept { return bc_func[0]->hasFabVersion(); } - static void setBndryFuncThreadSafety (int ext_dir_safe) { bf_ext_dir_threadsafe = ext_dir_safe; } + static void setBndryFuncThreadSafety (int ext_dir_safe) noexcept { + bf_ext_dir_threadsafe = ext_dir_safe; + } private: @@ -452,7 +454,10 @@ public: /** * \brief The constructor. */ - DescriptorList (); + DescriptorList () noexcept; + + DescriptorList (const DescriptorList&) = delete; + DescriptorList& operator= (const DescriptorList&) = delete; /** * \brief Set the list to its default state. @@ -462,7 +467,7 @@ public: /** * \brief Returns number of elements in the list. */ - int size () const; + int size () const noexcept; /** * \brief Adds new StateDescriptor at index indx to list. @@ -538,17 +543,10 @@ public: /** * Returns StateDescriptor at index k. */ - const StateDescriptor& operator[] (int k) const; + const StateDescriptor& operator[] (int k) const noexcept; private: - /** - * \brief These are disallowed. - * - */ - DescriptorList (const DescriptorList&); - DescriptorList& operator= (const DescriptorList&); - Vector > desc; }; diff --git a/Src/Amr/AMReX_StateDescriptor.cpp b/Src/Amr/AMReX_StateDescriptor.cpp index 8f4a6e38c6e..a978b039def 100644 --- a/Src/Amr/AMReX_StateDescriptor.cpp +++ b/Src/Amr/AMReX_StateDescriptor.cpp @@ -100,7 +100,7 @@ StateDescriptor::BndryFunc::operator () (Box const& bx, FArrayBox& data, m_funcfab(bx,data,dcomp,numcomp,geom,time,bcr,bcomp,scomp); } -DescriptorList::DescriptorList () +DescriptorList::DescriptorList () noexcept {} void @@ -110,7 +110,7 @@ DescriptorList::clear () } int -DescriptorList::size () const +DescriptorList::size () const noexcept { return desc.size(); } @@ -154,7 +154,7 @@ DescriptorList::setComponent (int indx, } const StateDescriptor& -DescriptorList::operator[] (int k) const +DescriptorList::operator[] (int k) const noexcept { return *desc[k]; } @@ -175,7 +175,7 @@ DescriptorList::addDescriptor (int indx, } -StateDescriptor::StateDescriptor () +StateDescriptor::StateDescriptor () noexcept : t_type(Point), id(-1), @@ -233,80 +233,80 @@ StateDescriptor::resetComponentBCs (int comp, } IndexType -StateDescriptor::getType () const +StateDescriptor::getType () const noexcept { return type; } StateDescriptor::TimeCenter -StateDescriptor::timeType () const +StateDescriptor::timeType () const noexcept { return t_type; } int -StateDescriptor::nComp () const +StateDescriptor::nComp () const noexcept { return ncomp; } int -StateDescriptor::nExtra () const +StateDescriptor::nExtra () const noexcept { return ngrow; } Interpolater* -StateDescriptor::interp () const +StateDescriptor::interp () const noexcept { return mapper; } Interpolater* -StateDescriptor::interp (int i) const +StateDescriptor::interp (int i) const noexcept { return mapper_comp[i] == 0 ? mapper : mapper_comp[i]; } const std::string& -StateDescriptor::name (int i) const +StateDescriptor::name (int i) const noexcept { return names[i]; } const BCRec& -StateDescriptor::getBC (int i) const +StateDescriptor::getBC (int i) const noexcept { return bc[i]; } const Vector& -StateDescriptor::getBCs () const +StateDescriptor::getBCs () const noexcept { return bc; } bool -StateDescriptor::extrap () const +StateDescriptor::extrap () const noexcept { return m_extrap; } bool -StateDescriptor::store_in_checkpoint () const +StateDescriptor::store_in_checkpoint () const noexcept { return m_store_in_checkpoint; } const StateDescriptor::BndryFunc& -StateDescriptor::bndryFill (int i) const +StateDescriptor::bndryFill (int i) const noexcept { return *bc_func[i]; } int -StateDescriptor::inRange (int sc, int nc) const +StateDescriptor::inRange (int sc, int nc) const noexcept { return sc>=0 && sc+nc<=ncomp; } @@ -523,7 +523,7 @@ StateDescriptor::cleanUpMaps (Interpolater**& maps, bool StateDescriptor::identicalInterps (int a_scomp, - int a_ncomp) const + int a_ncomp) const noexcept { BL_ASSERT(a_scomp >= 0); BL_ASSERT(a_ncomp >= 1); diff --git a/Src/AmrCore/AMReX_AmrCore.H b/Src/AmrCore/AMReX_AmrCore.H index ddc1f50b325..5fbfefa3bf3 100644 --- a/Src/AmrCore/AMReX_AmrCore.H +++ b/Src/AmrCore/AMReX_AmrCore.H @@ -34,7 +34,7 @@ public: virtual ~AmrCore (); #ifdef AMREX_PARTICLES - AmrParGDB* GetParGDB () const { return m_gdb.get(); } + AmrParGDB* GetParGDB () const noexcept { return m_gdb.get(); } #endif /** @@ -51,9 +51,9 @@ public: static void Initialize (); static void Finalize (); - void printGridSummary (std::ostream& os, int min_lev, int max_lev) const; + void printGridSummary (std::ostream& os, int min_lev, int max_lev) const noexcept; - int Verbose () const { return verbose; } + int Verbose () const noexcept { return verbose; } protected: diff --git a/Src/AmrCore/AMReX_AmrCore.cpp b/Src/AmrCore/AMReX_AmrCore.cpp index c2adaffee78..8baf9ccba43 100644 --- a/Src/AmrCore/AMReX_AmrCore.cpp +++ b/Src/AmrCore/AMReX_AmrCore.cpp @@ -111,7 +111,7 @@ AmrCore::regrid (int lbase, Real time, bool) void -AmrCore::printGridSummary (std::ostream& os, int min_lev, int max_lev) const +AmrCore::printGridSummary (std::ostream& os, int min_lev, int max_lev) const noexcept { for (int lev = min_lev; lev <= max_lev; lev++) { diff --git a/Src/AmrCore/AMReX_AmrMesh.H b/Src/AmrCore/AMReX_AmrMesh.H index c4e51320294..195e411aa78 100644 --- a/Src/AmrCore/AMReX_AmrMesh.H +++ b/Src/AmrCore/AMReX_AmrMesh.H @@ -24,100 +24,100 @@ public: virtual ~AmrMesh (); - int Verbose () const { return verbose; } + int Verbose () const noexcept { return verbose; } //! Return the max level - int maxLevel () const { return max_level; } + int maxLevel () const noexcept { return max_level; } //! Return the finest level - int finestLevel () const { return finest_level; } + int finestLevel () const noexcept { return finest_level; } //! Return the refinement ratio for level lev - IntVect refRatio (int lev) const { return ref_ratio[lev]; } + IntVect refRatio (int lev) const noexcept { return ref_ratio[lev]; } //! Return the maximum refinement ratio in any direction. - int MaxRefRatio (int lev) const; + int MaxRefRatio (int lev) const noexcept; //! Return refinement ratios between all levels. - const Vector& refRatio () const { return ref_ratio; } + const Vector& refRatio () const noexcept { return ref_ratio; } - const Vector& Geom () const { return geom; } - const Vector& DistributionMap () const { return dmap; } - const Vector& boxArray () const { return grids; } + const Vector& Geom () const noexcept { return geom; } + const Vector& DistributionMap () const noexcept { return dmap; } + const Vector& boxArray () const noexcept { return grids; } - const Geometry& Geom (int lev) const { return geom[lev]; } - const DistributionMapping& DistributionMap (int lev) const { return dmap[lev]; } - const BoxArray& boxArray (int lev) const { return grids[lev]; } + const Geometry& Geom (int lev) const noexcept { return geom[lev]; } + const DistributionMapping& DistributionMap (int lev) const noexcept { return dmap[lev]; } + const BoxArray& boxArray (int lev) const noexcept { return grids[lev]; } - Vector& Geom () { return geom; } - Geometry& Geom (int lev) { return geom[lev]; } + Vector& Geom () noexcept { return geom; } + Geometry& Geom (int lev) noexcept { return geom[lev]; } - void SetMaxGridSize (int new_mgs) { + void SetMaxGridSize (int new_mgs) noexcept { max_grid_size.assign(max_level+1, IntVect{AMREX_D_DECL(new_mgs,new_mgs,new_mgs)}); } - void SetMaxGridSize (const IntVect& new_mgs) { + void SetMaxGridSize (const IntVect& new_mgs) noexcept { max_grid_size.assign(max_level+1, new_mgs); } - void SetMaxGridSize (const Vector& new_mgs) { + void SetMaxGridSize (const Vector& new_mgs) noexcept { max_grid_size.resize(max_level+1); for (int i = 0; i <= max_level; ++i) { max_grid_size[i] = IntVect{AMREX_D_DECL(new_mgs[i],new_mgs[i],new_mgs[i])}; } } - void SetMaxGridSize (const Vector& new_mgs) { + void SetMaxGridSize (const Vector& new_mgs) noexcept { max_grid_size.assign(new_mgs.cbegin(), new_mgs.cbegin()+max_level+1); } - void SetBlockingFactor (int new_bf) { + void SetBlockingFactor (int new_bf) noexcept { blocking_factor.assign(max_level+1, IntVect{AMREX_D_DECL(new_bf,new_bf,new_bf)}); } - void SetBlockingFactor (const IntVect& new_bf) { + void SetBlockingFactor (const IntVect& new_bf) noexcept { blocking_factor.assign(max_level+1, new_bf); } - void SetBlockingFactor (const Vector& new_bf) { + void SetBlockingFactor (const Vector& new_bf) noexcept { blocking_factor.resize(max_level+1); for (int i = 0; i <= max_level; ++i) { blocking_factor[i] = IntVect{AMREX_D_DECL(new_bf[i],new_bf[i],new_bf[i])}; } } - void SetBlockingFactor (const Vector& new_bf) { + void SetBlockingFactor (const Vector& new_bf) noexcept { blocking_factor.assign(new_bf.cbegin(), new_bf.cend()+max_level+1); } - void SetGridEff (Real eff) { grid_eff = eff; } - void SetNProper (int n) { n_proper = n; } + void SetGridEff (Real eff) noexcept { grid_eff = eff; } + void SetNProper (int n) noexcept { n_proper = n; } //! Set ref_ratio would require rebuiling Geometry objects. - void SetFinestLevel (int new_finest_level) { finest_level = new_finest_level; } - void SetDistributionMap (int lev, const DistributionMapping& dmap_in); - void SetBoxArray (int lev, const BoxArray& ba_in); + void SetFinestLevel (int new_finest_level) noexcept { finest_level = new_finest_level; } + void SetDistributionMap (int lev, const DistributionMapping& dmap_in) noexcept; + void SetBoxArray (int lev, const BoxArray& ba_in) noexcept; - void ClearDistributionMap (int lev); - void ClearBoxArray (int lev); + void ClearDistributionMap (int lev) noexcept; + void ClearBoxArray (int lev) noexcept; //! Return the number of buffer cells in error estimator. - int nErrorBuf (int lev) const { return n_error_buf[lev]; } + int nErrorBuf (int lev) const noexcept { return n_error_buf[lev]; } //! Return the minimum allowable grid efficiency. - Real gridEff () const { return grid_eff; } + Real gridEff () const noexcept { return grid_eff; } //! Return the number of cells to define proper nesting - int nProper () const { return n_proper; } + int nProper () const noexcept { return n_proper; } //! Return the blocking factor at level lev - const IntVect& blockingFactor (int lev) const { return blocking_factor[lev]; } + const IntVect& blockingFactor (int lev) const noexcept { return blocking_factor[lev]; } //! Return the largest allowable grid. - const IntVect& maxGridSize (int lev) const { return max_grid_size[lev]; } + const IntVect& maxGridSize (int lev) const noexcept { return max_grid_size[lev]; } - bool LevelDefined (int lev); + bool LevelDefined (int lev) noexcept; //! Should we keep the coarser grids fixed (and not regrid those levels) at all? - bool useFixedCoarseGrids () const { return use_fixed_coarse_grids; } + bool useFixedCoarseGrids () const noexcept { return use_fixed_coarse_grids; } //! Up to what level should we keep the coarser grids fixed (and not regrid those levels)? - int useFixedUpToLevel () const { return use_fixed_upto_level; } + int useFixedUpToLevel () const noexcept { return use_fixed_upto_level; } //! "Try" to chop up grids so that the number of boxes in the BoxArray is greater than the target_size. void ChopGrids (int lev, BoxArray& ba, int target_size) const; @@ -157,7 +157,7 @@ public: virtual BoxArray GetAreaNotToTag (int lev) { return BoxArray(); } - long CountCells (int lev); + long CountCells (int lev) noexcept; static void Initialize (); static void Finalize (); @@ -190,18 +190,18 @@ protected: void checkInput(); - void SetIterateToFalse () + void SetIterateToFalse () noexcept { iterate_on_new_grids = false; } - void SetUseNewChop () + void SetUseNewChop () noexcept { use_new_chop = true; } private: - void InitAmrMesh (int max_level_in, const Vector& n_cell_in, - std::vector refrat = std::vector()); + void InitAmrMesh (int max_level_in, const Vector& n_cell_in, + std::vector refrat = std::vector()); static void ProjPeriodic (BoxList& bd, const Geometry& geom); }; diff --git a/Src/AmrCore/AMReX_AmrMesh.cpp b/Src/AmrCore/AMReX_AmrMesh.cpp index 1d352fc6208..d67b22f8b6a 100644 --- a/Src/AmrCore/AMReX_AmrMesh.cpp +++ b/Src/AmrCore/AMReX_AmrMesh.cpp @@ -325,7 +325,7 @@ AmrMesh::InitAmrMesh (int max_level_in, const Vector& n_cell_in, std::vecto } int -AmrMesh::MaxRefRatio (int lev) const +AmrMesh::MaxRefRatio (int lev) const noexcept { int maxval = 0; for (int n = 0; nmaxLevel()+1), m_ba(amr->maxLevel()+1) diff --git a/Src/AmrCore/AMReX_Cluster.H b/Src/AmrCore/AMReX_Cluster.H index d0c5b7a4c46..625ec689c25 100644 --- a/Src/AmrCore/AMReX_Cluster.H +++ b/Src/AmrCore/AMReX_Cluster.H @@ -29,7 +29,7 @@ public: /** * \brief The default constructor -- builds invalid Cluster. */ - Cluster (); + Cluster () noexcept; /** * \brief Construct a cluster from an array of IntVects. @@ -40,7 +40,7 @@ public: * \param len */ Cluster (IntVect* a, - long len); + long len) noexcept; /** * \brief Construct new cluster by removing all points from c that lie @@ -60,24 +60,24 @@ public: /** * \brief Return minimal box containing all tagged points. */ - const Box& box () const { return m_bx; } + const Box& box () const noexcept { return m_bx; } /** * \brief Does cluster contain any points? */ - bool ok () const { return m_ar != 0 && m_len > 0; } + bool ok () const noexcept { return m_ar != 0 && m_len > 0; } /** * \brief Returns number of tagged points in cluster. */ - long numTag () const { return m_len; } + long numTag () const noexcept { return m_len; } /** * \brief Return number of tagged points in intersection of cluster and Box b. * * \param b */ - long numTag (const Box& b) const; + long numTag (const Box& b) const noexcept; /** * \brief This operation splits a cluster into two pieces by selecting @@ -116,7 +116,7 @@ public: /** * \brief Compute ratio of tagged to total number of points in cluster. */ - Real eff () const { BL_ASSERT(ok()); return numTag()/m_bx.d_numPts(); } + Real eff () const noexcept { BL_ASSERT(ok()); return numTag()/m_bx.d_numPts(); } private: @@ -130,7 +130,7 @@ private: /** * \brief Compute and store minimal box containing tagged points. */ - void minBox (); + void minBox () noexcept; //! The data. Box m_bx; diff --git a/Src/AmrCore/AMReX_Cluster.cpp b/Src/AmrCore/AMReX_Cluster.cpp index d34aec9fa92..80b6486b572 100644 --- a/Src/AmrCore/AMReX_Cluster.cpp +++ b/Src/AmrCore/AMReX_Cluster.cpp @@ -9,11 +9,11 @@ namespace { enum CutStatus { HoleCut=0, SteepCut, BisectCut, InvalidCut }; } -Cluster::Cluster () +Cluster::Cluster () noexcept : m_ar(0) {} -Cluster::Cluster (IntVect* a, long len) +Cluster::Cluster (IntVect* a, long len) noexcept : m_ar(a), m_len(len) @@ -30,9 +30,9 @@ namespace { class InBox { public: - InBox (const Box& b) : m_box(b) {} + InBox (const Box& b) noexcept : m_box(b) {} - bool operator() (const IntVect& iv) const + bool operator() (const IntVect& iv) const noexcept { return m_box.contains(iv); } @@ -118,7 +118,7 @@ Cluster::distribute (ClusterList& clst, } long -Cluster::numTag (const Box& b) const +Cluster::numTag (const Box& b) const noexcept { long cnt = 0; for (int i = 0; i < m_len; i++) @@ -130,7 +130,7 @@ Cluster::numTag (const Box& b) const } void -Cluster::minBox () +Cluster::minBox () noexcept { if (m_len == 0) { diff --git a/Src/AmrCore/AMReX_ErrorList.H b/Src/AmrCore/AMReX_ErrorList.H index 05e103b4122..4dd9647c973 100644 --- a/Src/AmrCore/AMReX_ErrorList.H +++ b/Src/AmrCore/AMReX_ErrorList.H @@ -288,17 +288,17 @@ public: /** * \brief The name of the quantity to derive. */ - const std::string& name () const; + const std::string& name () const noexcept; /** * \brief The number of extra zones needed for derivation. */ - int nGrow () const; + int nGrow () const noexcept; /** * \brief The type of the error tagging. */ - ErrorType errType () const; + ErrorType errType () const noexcept; /** * \brief The extern "C" functions to do the error tagging. @@ -332,12 +332,12 @@ private: class ErrorList { public: - ErrorList() {} + ErrorList() noexcept {} /** * \brief The number of ErrorRecs in the list. */ - int size () const; + int size () const noexcept; /** * \brief Append a new ErrorRec to the list. @@ -358,7 +358,7 @@ public: const ErrorRec::ErrorFunc2& func); //! The kth ErrorRec. - const ErrorRec& operator[] (int k) const; + const ErrorRec& operator[] (int k) const noexcept; void clear (bool rs0 = false) { vec.clear(); if(rs0) { vec.resize(0); } } diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index 08222f78025..a41bc1a199f 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -133,19 +133,19 @@ ErrorRec::ErrorRec (const std::string& nm, {} const std::string& -ErrorRec::name () const +ErrorRec::name () const noexcept { return derive_name; } int -ErrorRec::nGrow () const +ErrorRec::nGrow () const noexcept { return ngrow; } ErrorRec::ErrorType -ErrorRec::errType () const +ErrorRec::errType () const noexcept { return err_type; } @@ -169,7 +169,7 @@ ErrorRec::~ErrorRec() } int -ErrorList::size () const +ErrorList::size () const noexcept { return vec.size(); } @@ -203,7 +203,7 @@ ErrorList::add (const std::string& name, } const ErrorRec& -ErrorList::operator[] (int k) const +ErrorList::operator[] (int k) const noexcept { BL_ASSERT(k < size()); diff --git a/Src/AmrCore/AMReX_FluxReg_1D_C.H b/Src/AmrCore/AMReX_FluxReg_1D_C.H index 7d7df1be8c5..00132d9e4e7 100644 --- a/Src/AmrCore/AMReX_FluxReg_1D_C.H +++ b/Src/AmrCore/AMReX_FluxReg_1D_C.H @@ -24,7 +24,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void fluxreg_fineadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int /*dir*/, IntVect const& ratio, const Real mult) + const int /*dir*/, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -61,7 +61,7 @@ AMREX_GPU_HOST_DEVICE inline void fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& areafab, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int /*dir*/, IntVect const& ratio, const Real mult) + const int /*dir*/, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -81,7 +81,7 @@ fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, AMREX_GPU_HOST_DEVICE inline void fluxreg_reflux (Box const& bx, FArrayBox& sfab, const int scomp, FArrayBox const& ffab, FArrayBox const& vfab, - const int ncomp, const Real mult, const Orientation face) + const int ncomp, const Real mult, const Orientation face) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_FluxReg_2D_C.H b/Src/AmrCore/AMReX_FluxReg_2D_C.H index 62ff5ee6aa4..da1cc9e4cda 100644 --- a/Src/AmrCore/AMReX_FluxReg_2D_C.H +++ b/Src/AmrCore/AMReX_FluxReg_2D_C.H @@ -25,7 +25,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void fluxreg_fineadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int dir, IntVect const& ratio, const Real mult) + const int dir, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -89,7 +89,7 @@ AMREX_GPU_HOST_DEVICE inline void fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& areafab, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int dir, IntVect const& ratio, const Real mult) + const int dir, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -138,7 +138,7 @@ fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, AMREX_GPU_HOST_DEVICE inline void fluxreg_reflux (Box const& bx, FArrayBox& sfab, const int scomp, FArrayBox const& ffab, FArrayBox const& vfab, - const int ncomp, const Real mult, const Orientation face) + const int ncomp, const Real mult, const Orientation face) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_FluxReg_3D_C.H b/Src/AmrCore/AMReX_FluxReg_3D_C.H index 81d2c7ce0fc..4e1d389ec46 100644 --- a/Src/AmrCore/AMReX_FluxReg_3D_C.H +++ b/Src/AmrCore/AMReX_FluxReg_3D_C.H @@ -25,7 +25,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void fluxreg_fineadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int dir, IntVect const& ratio, const Real mult) + const int dir, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -119,7 +119,7 @@ AMREX_GPU_HOST_DEVICE inline void fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, FArrayBox const& areafab, FArrayBox const& flxfab, const int fcomp, const int ncomp, - const int dir, IntVect const& ratio, const Real mult) + const int dir, IntVect const& ratio, const Real mult) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -198,7 +198,7 @@ fluxreg_fineareaadd (Box const& bx, FArrayBox& regfab, const int rcomp, AMREX_GPU_HOST_DEVICE inline void fluxreg_reflux (Box const& bx, FArrayBox& sfab, const int scomp, FArrayBox const& ffab, FArrayBox const& vfab, - const int ncomp, const Real mult, const Orientation face) + const int ncomp, const Real mult, const Orientation face) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_FluxRegister.H b/Src/AmrCore/AMReX_FluxRegister.H index 4dad9d2d6ad..ca651b0de75 100644 --- a/Src/AmrCore/AMReX_FluxRegister.H +++ b/Src/AmrCore/AMReX_FluxRegister.H @@ -76,27 +76,27 @@ public: /** * \brief Returns the refinement ratio. */ - const IntVect& refRatio () const; + const IntVect& refRatio () const noexcept; /** * \brief Returns the level number of the fine level. */ - int fineLevel () const; + int fineLevel () const noexcept; /** * \brief Returns the level number of the coarse level (fineLevel()-1). */ - int crseLevel () const; + int crseLevel () const noexcept; /** * \brief The number of components. */ - int nComp () const; + int nComp () const noexcept; /** * \brief The coarsened boxes. */ - const BoxArray& coarsenedBoxes () const; + const BoxArray& coarsenedBoxes () const noexcept; /** * \brief Returns the sum of the registers. @@ -245,7 +245,7 @@ public: int srccomp, int destcomp, int numcomp, - Real mult); + Real mult) noexcept; /** * \brief Increment flux correction with fine data. @@ -266,7 +266,7 @@ public: int srccomp, int destcomp, int numcomp, - Real mult); + Real mult) noexcept; /** * \brief Set flux correction data for a fine box (given by boxno) to a given value. @@ -282,7 +282,7 @@ public: int boxno, int destcomp, int numcomp, - Real val); + Real val) noexcept; /** * \brief Apply flux correction. Note that this takes the coarse Geometry. @@ -372,14 +372,6 @@ public: private: - /** - * \brief Helper member function. - * - * \param fab - * \param dir - */ - void increment (const FArrayBox& fab, int dir); - //! Refinement ratio IntVect ratio; diff --git a/Src/AmrCore/AMReX_FluxRegister.cpp b/Src/AmrCore/AMReX_FluxRegister.cpp index 672cc553d1c..3bff2d4c97d 100644 --- a/Src/AmrCore/AMReX_FluxRegister.cpp +++ b/Src/AmrCore/AMReX_FluxRegister.cpp @@ -28,31 +28,31 @@ FluxRegister::FluxRegister (const BoxArray& fine_boxes, } const IntVect& -FluxRegister::refRatio () const +FluxRegister::refRatio () const noexcept { return ratio; } int -FluxRegister::fineLevel () const +FluxRegister::fineLevel () const noexcept { return fine_level; } int -FluxRegister::crseLevel () const +FluxRegister::crseLevel () const noexcept { return fine_level-1; } int -FluxRegister::nComp () const +FluxRegister::nComp () const noexcept { return ncomp; } const BoxArray& -FluxRegister::coarsenedBoxes () const +FluxRegister::coarsenedBoxes () const noexcept { return grids; } @@ -330,7 +330,7 @@ FluxRegister::FineAdd (const FArrayBox& flux, int srccomp, int destcomp, int numcomp, - Real mult) + Real mult) noexcept { BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= flux.nComp()); BL_ASSERT(destcomp >= 0 && destcomp+numcomp <= ncomp); @@ -375,7 +375,7 @@ FluxRegister::FineAdd (const FArrayBox& flux, int srccomp, int destcomp, int numcomp, - Real mult) + Real mult) noexcept { BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= flux.nComp()); BL_ASSERT(destcomp >= 0 && destcomp+numcomp <= ncomp); @@ -420,7 +420,7 @@ FluxRegister::FineSetVal (int dir, int boxno, int destcomp, int numcomp, - Real val) + Real val) noexcept { // This routine used by FLASH does NOT run on gpu for safety. diff --git a/Src/AmrCore/AMReX_Interp_1D_C.H b/Src/AmrCore/AMReX_Interp_1D_C.H index 476583f147e..323722d122e 100644 --- a/Src/AmrCore/AMReX_Interp_1D_C.H +++ b/Src/AmrCore/AMReX_Interp_1D_C.H @@ -12,7 +12,7 @@ AMREX_GPU_HOST inline Vector ccinterp_compute_voff (Box const& cbx, IntVect const& ratio, Geometry const& cgeom, - Geometry const& fgeom) + Geometry const& fgeom) noexcept { const Box& fbx = amrex::refine(cbx,ratio); const auto& flen = amrex::length(fbx); @@ -46,7 +46,7 @@ namespace { AMREX_GPU_HOST_DEVICE AMREX_INLINE void compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView const& slopes, FabView const& u, Box const& sbox, const Dim3& slo, const Dim3& shi, - const Dim3& slen, BCRec const& bc, const int n, const int ncomp) + const Dim3& slen, BCRec const& bc, const int n, const int ncomp) noexcept { AMREX_PRAGMA_SIMD for (int i = 0; i < len.x; ++i) { @@ -81,7 +81,7 @@ compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView c AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -131,7 +131,7 @@ cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopesfab, FArrayBox const& crsefab, const int ccomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -160,7 +160,7 @@ cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const in AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -202,7 +202,7 @@ cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccfab, const int ncomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -237,7 +237,7 @@ cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccf AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alphafab, - const int ncomp, IntVect const& ratio) + const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -260,7 +260,7 @@ cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alph AMREX_GPU_HOST_DEVICE inline void pcinterp_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, - FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) + FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -280,7 +280,7 @@ pcinterp_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int n AMREX_GPU_HOST_DEVICE inline void nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, - const int icomp, const int ncomp, IntVect const& ratio) + const int icomp, const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -301,7 +301,7 @@ nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, AMREX_GPU_HOST_DEVICE inline void nodebilin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopefab, FArrayBox const& crsefab, const int ccomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_Interp_2D_C.H b/Src/AmrCore/AMReX_Interp_2D_C.H index 72788930dcc..b5380e86273 100644 --- a/Src/AmrCore/AMReX_Interp_2D_C.H +++ b/Src/AmrCore/AMReX_Interp_2D_C.H @@ -12,7 +12,7 @@ AMREX_GPU_HOST inline Vector ccinterp_compute_voff (Box const& cbx, IntVect const& ratio, Geometry const& cgeom, - Geometry const& fgeom) + Geometry const& fgeom) noexcept { const Box& fbx = amrex::refine(cbx,ratio); const auto& flen = amrex::length(fbx); @@ -60,7 +60,7 @@ namespace { AMREX_GPU_HOST_DEVICE AMREX_INLINE void compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView const& slopes, FabView const& u, Box const& sbox, const Dim3& slo, const Dim3& shi, - const Dim3& slen, BCRec const& bc, const int n, const int ncomp) + const Dim3& slen, BCRec const& bc, const int n, const int ncomp) noexcept { for (int j = 0; j < len.y; ++j) { AMREX_PRAGMA_SIMD @@ -140,7 +140,7 @@ compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView c AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -209,7 +209,7 @@ cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopesfab, FArrayBox const& crsefab, const int ccomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -243,7 +243,7 @@ cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const in AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -297,7 +297,7 @@ cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccfab, const int ncomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -336,7 +336,7 @@ cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccf AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alphafab, - const int ncomp, IntVect const& ratio) + const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -365,7 +365,7 @@ cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alph AMREX_GPU_HOST_DEVICE inline void pcinterp_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, - FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) + FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -394,7 +394,7 @@ namespace { AMREX_GPU_HOST_DEVICE inline void nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, - const int icomp, const int ncomp, IntVect const& ratio) + const int icomp, const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -423,7 +423,7 @@ nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, AMREX_GPU_HOST_DEVICE inline void nodebilin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopefab, FArrayBox const& crsefab, const int ccomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_Interp_3D_C.H b/Src/AmrCore/AMReX_Interp_3D_C.H index 0e15cd0240d..ff3980106d0 100644 --- a/Src/AmrCore/AMReX_Interp_3D_C.H +++ b/Src/AmrCore/AMReX_Interp_3D_C.H @@ -12,7 +12,7 @@ AMREX_GPU_HOST inline Vector ccinterp_compute_voff (Box const& cbx, IntVect const& ratio, Geometry const& cgeom, - Geometry const& fgeom) + Geometry const& fgeom) noexcept { const Box& fbx = amrex::refine(cbx,ratio); const auto& flen = amrex::length(fbx); @@ -61,7 +61,7 @@ namespace { AMREX_GPU_HOST_DEVICE AMREX_INLINE void compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView const& slopes, FabView const& u, Box const& sbox, const Dim3& slo, const Dim3& shi, - const Dim3& slen, BCRec const& bc, const int n, const int ncomp) + const Dim3& slen, BCRec const& bc, const int n, const int ncomp) noexcept { for (int k = 0; k < len.z; ++k) { for (int j = 0; j < len.y; ++j) { @@ -202,7 +202,7 @@ compute_slopes (const Dim3& len, const Dim3& lo, const Dim3& hi, FabView c AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -290,7 +290,7 @@ cellconslin_slopes_linlim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopesfab, FArrayBox const& crsefab, const int ccomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -329,7 +329,7 @@ cellconslin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const in AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, FArrayBox const& ufab, const int icomp, const int ncomp, - BCRec const* AMREX_RESTRICT bcr) + BCRec const* AMREX_RESTRICT bcr) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -395,7 +395,7 @@ cellconslin_slopes_mclim (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccfab, const int ncomp, - Real const* AMREX_RESTRICT voff, IntVect const& ratio) + Real const* AMREX_RESTRICT voff, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -439,7 +439,7 @@ cellconslin_fine_alpha (Box const& bx, FArrayBox& alphafab, FArrayBox const& ccf AMREX_GPU_HOST_DEVICE inline void cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alphafab, - const int ncomp, IntVect const& ratio) + const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -474,7 +474,7 @@ cellconslin_slopes_mmlim (Box const& bx, FArrayBox& ccfab, FArrayBox const& alph AMREX_GPU_HOST_DEVICE inline void pcinterp_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, - FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) + FArrayBox const& crsefab, const int ccomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -510,7 +510,7 @@ namespace { AMREX_GPU_HOST_DEVICE inline void nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, - const int icomp, const int ncomp, IntVect const& ratio) + const int icomp, const int ncomp, IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); @@ -552,7 +552,7 @@ nodebilin_slopes (Box const& bx, FArrayBox& slopefab, FArrayBox const& ufab, AMREX_GPU_HOST_DEVICE inline void nodebilin_interp (Box const& bx, FArrayBox& finefab, const int fcomp, const int ncomp, FArrayBox const& slopefab, FArrayBox const& crsefab, const int ccomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = amrex::length(bx); const auto lo = amrex::lbound(bx); diff --git a/Src/AmrCore/AMReX_TagBox.H b/Src/AmrCore/AMReX_TagBox.H index 339d5236406..28072dea816 100644 --- a/Src/AmrCore/AMReX_TagBox.H +++ b/Src/AmrCore/AMReX_TagBox.H @@ -37,7 +37,7 @@ public: /** * \brief Construct an invalid TagBox with no memory. */ - TagBox (); + TagBox () noexcept; /** * \brief Construct a TagBox on Box bx with number of components n. @@ -69,7 +69,7 @@ public: * \param ratio * \param owner */ - void coarsen (const IntVect& ratio, bool owner); + void coarsen (const IntVect& ratio, bool owner) noexcept; /** * \brief Mark neighbors of every tagged cell a distance nbuff away @@ -79,14 +79,14 @@ public: * \param nbuff * \param nwid */ - void buffer (int nbuff, int nwid); + void buffer (int nbuff, int nwid) noexcept; /** * \brief Tag cells on intersect with src if corresponding src cell is tagged. * * \param src */ - void merge (const TagBox& src); + void merge (const TagBox& src) noexcept; /** * \brief Add location of every tagged cell to IntVect array, @@ -96,26 +96,26 @@ public: * \param ar * \param start */ - long collate (Vector& ar, int start) const; + long collate (Vector& ar, int start) const noexcept; /** * \brief Returns number of tagged cells in specified Box. * * \param bx */ - long numTags (const Box& bx) const; + long numTags (const Box& bx) const noexcept; /** * \brief Returns total number of tagged cells in the TagBox. */ - long numTags () const; + long numTags () const noexcept; /** * \brief Returns Vector\ of size domain.numPts() suitable for calling * Fortran, with positions set to same value as in the TagBox * dataPtr(). */ - Vector tags () const; + Vector tags () const noexcept; /** * \brief Since a TagBox is a BaseFab\, we can use this utility @@ -125,7 +125,7 @@ public: * \param ar * \param tilebx */ - void get_itags(Vector& ar, const Box& tilebx) const; + void get_itags(Vector& ar, const Box& tilebx) const noexcept; /** * \brief Set values as specified by the array -- this only tags. @@ -133,7 +133,7 @@ public: * * \param ar */ - void tags (const Vector& ar); + void tags (const Vector& ar) noexcept; /** * \brief Set values as specified by the array -- this tags and untags. @@ -141,7 +141,7 @@ public: * * \param ar */ - void tags_and_untags (const Vector& ar); + void tags_and_untags (const Vector& ar) noexcept; /** * \brief Set values as specified by the array -- this only tags. @@ -150,7 +150,7 @@ public: * \param ar * \param tilebx */ - void tags (const Vector& ar, const Box& tilebx); + void tags (const Vector& ar, const Box& tilebx) noexcept; /** * \brief Set values as specified by the array -- this tags and untags. @@ -159,7 +159,7 @@ public: * \param ar * \param tilebx */ - void tags_and_untags (const Vector& ar, const Box& tilebx); + void tags_and_untags (const Vector& ar, const Box& tilebx) noexcept; }; @@ -199,7 +199,7 @@ public: /** * \brief Returns the grow factor for the TagBoxArray. */ - int borderSize () const; + int borderSize () const noexcept; /** * \brief Calls buffer() on all contained TagBoxes. diff --git a/Src/AmrCore/AMReX_TagBox.cpp b/Src/AmrCore/AMReX_TagBox.cpp index 31569677480..ab49462f0f7 100644 --- a/Src/AmrCore/AMReX_TagBox.cpp +++ b/Src/AmrCore/AMReX_TagBox.cpp @@ -11,7 +11,7 @@ namespace amrex { -TagBox::TagBox () {} +TagBox::TagBox () noexcept {} TagBox::TagBox (const Box& bx, int n, @@ -32,7 +32,7 @@ TagBox::TagBox (const TagBox& rhs, MakeType make_type) #endif void -TagBox::coarsen (const IntVect& ratio, bool owner) +TagBox::coarsen (const IntVect& ratio, bool owner) noexcept { BL_ASSERT(nComp() == 1); @@ -114,8 +114,7 @@ TagBox::coarsen (const IntVect& ratio, bool owner) } void -TagBox::buffer (int nbuff, - int nwid) +TagBox::buffer (int nbuff, int nwid) noexcept { // // Note: this routine assumes cell with TagBox::SET tag are in @@ -168,7 +167,7 @@ TagBox::buffer (int nbuff, } void -TagBox::merge (const TagBox& src) +TagBox::merge (const TagBox& src) noexcept { // // Compute intersections. @@ -215,7 +214,7 @@ TagBox::merge (const TagBox& src) } long -TagBox::numTags () const +TagBox::numTags () const noexcept { long nt = 0L; long len = domain.numPts(); @@ -229,7 +228,7 @@ TagBox::numTags () const } long -TagBox::numTags (const Box& b) const +TagBox::numTags (const Box& b) const noexcept { TagBox tempTagBox(b,1); tempTagBox.copy(*this); @@ -237,7 +236,7 @@ TagBox::numTags (const Box& b) const } long -TagBox::collate (Vector& ar, int start) const +TagBox::collate (Vector& ar, int start) const noexcept { BL_ASSERT(start >= 0); // @@ -271,7 +270,7 @@ TagBox::collate (Vector& ar, int start) const } Vector -TagBox::tags () const +TagBox::tags () const noexcept { Vector ar(domain.numPts(), TagBox::CLEAR); @@ -291,7 +290,7 @@ TagBox::tags () const // Set values as specified by the array -- this only tags. // It's an error if ar.length() != domain.numPts(). void -TagBox::tags (const Vector& ar) +TagBox::tags (const Vector& ar) noexcept { BL_ASSERT(ar.size() == domain.numPts()); @@ -308,7 +307,7 @@ TagBox::tags (const Vector& ar) // Set values as specified by the array -- this tags and untags. // It's an error if ar.length() != domain.numPts(). void -TagBox::tags_and_untags (const Vector& ar) +TagBox::tags_and_untags (const Vector& ar) noexcept { BL_ASSERT(ar.size() == domain.numPts()); @@ -326,7 +325,7 @@ TagBox::tags_and_untags (const Vector& ar) // function to allocate an integer array to have the same number // of elements as cells in tilebx void -TagBox::get_itags(Vector& ar, const Box& tilebx) const +TagBox::get_itags(Vector& ar, const Box& tilebx) const noexcept { auto dlen = length(); int Lbx[] = {1,1,1}; @@ -367,7 +366,7 @@ TagBox::get_itags(Vector& ar, const Box& tilebx) const // Set values as specified by the array -- this only tags. // only changes values in the tilebx region void -TagBox::tags (const Vector& ar, const Box& tilebx) +TagBox::tags (const Vector& ar, const Box& tilebx) noexcept { auto dlen = length(); int Lbx[] = {1,1,1}; @@ -401,7 +400,7 @@ TagBox::tags (const Vector& ar, const Box& tilebx) // Set values as specified by the array -- this tags and untags. // only changes values in the tilebx region void -TagBox::tags_and_untags (const Vector& ar, const Box& tilebx) +TagBox::tags_and_untags (const Vector& ar, const Box& tilebx) noexcept { auto dlen = length(); int Lbx[] = {1,1,1}; @@ -441,7 +440,7 @@ TagBoxArray::TagBoxArray (const BoxArray& ba, } int -TagBoxArray::borderSize () const +TagBoxArray::borderSize () const noexcept { return n_grow[0]; } @@ -488,7 +487,7 @@ TagBoxArray::mapPeriodic (const Geometry& geom) } long -TagBoxArray::numTags () const +TagBoxArray::numTags () const { long ntag = 0; diff --git a/Src/Base/AMReX.H b/Src/Base/AMReX.H index 5902ca6e9e4..9903f71a2ca 100644 --- a/Src/Base/AMReX.H +++ b/Src/Base/AMReX.H @@ -123,8 +123,8 @@ namespace amrex std::ostream& OutStream (); std::ostream& ErrorStream (); - int Verbose (); - void SetVerbose (int v); + int Verbose () noexcept; + void SetVerbose (int v) noexcept; // ! Get the entire command line including the executable std::string get_command (); diff --git a/Src/Base/AMReX.cpp b/Src/Base/AMReX.cpp index e59d8e7f2f9..f4796259bcd 100644 --- a/Src/Base/AMReX.cpp +++ b/Src/Base/AMReX.cpp @@ -92,9 +92,9 @@ std::string amrex::Version () #endif } -int amrex::Verbose () { return amrex::system::verbose; } +int amrex::Verbose () noexcept { return amrex::system::verbose; } -void amrex::SetVerbose (int v) { amrex::system::verbose = v; } +void amrex::SetVerbose (int v) noexcept { amrex::system::verbose = v; } void amrex::SetErrorHandler (amrex::ErrorHandler f) { amrex::system::error_handler = f; diff --git a/Src/Base/AMReX_Arena.H b/Src/Base/AMReX_Arena.H index d08d4c2c22a..8613f7d3cdc 100644 --- a/Src/Base/AMReX_Arena.H +++ b/Src/Base/AMReX_Arena.H @@ -14,6 +14,7 @@ Arena* The_Arena (); Arena* The_Device_Arena (); Arena* The_Managed_Arena (); Arena* The_Pinned_Arena (); +Arena* The_Cpu_Arena (); struct ArenaInfo { @@ -21,22 +22,22 @@ struct ArenaInfo bool device_set_readonly = false; bool device_set_preferred = false; bool device_use_hostalloc = false; - ArenaInfo& SetDeviceMemory () { + ArenaInfo& SetDeviceMemory () noexcept { device_use_managed_memory = false; device_use_hostalloc = false; return *this; } - ArenaInfo& SetReadOnly () { + ArenaInfo& SetReadOnly () noexcept { BL_ASSERT(device_use_managed_memory); device_set_readonly = true; return *this; } - ArenaInfo& SetPreferred () { + ArenaInfo& SetPreferred () noexcept { BL_ASSERT(device_use_managed_memory); device_set_preferred = true; return *this; } - ArenaInfo& SetHostAlloc () { + ArenaInfo& SetHostAlloc () noexcept { device_use_hostalloc = true; device_use_managed_memory = false; return *this; @@ -80,8 +81,8 @@ protected: union Word { void* p; - double d; - long l; + long long ll; + long double ld; void (*f) (); }; static const unsigned int align_size = sizeof(Word); diff --git a/Src/Base/AMReX_Arena.cpp b/Src/Base/AMReX_Arena.cpp index baf83eac0eb..1be44218d14 100644 --- a/Src/Base/AMReX_Arena.cpp +++ b/Src/Base/AMReX_Arena.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -19,9 +20,11 @@ namespace { Arena* the_device_arena = nullptr; Arena* the_managed_arena = nullptr; Arena* the_pinned_arena = nullptr; + Arena* the_cpu_arena = nullptr; bool use_buddy_allocator = false; long buddy_allocator_size = 0L; + long the_arena_init_size = 0L; } const unsigned int Arena::align_size; @@ -96,10 +99,12 @@ Arena::Initialize () BL_ASSERT(the_device_arena == nullptr); BL_ASSERT(the_managed_arena == nullptr); BL_ASSERT(the_pinned_arena == nullptr); + BL_ASSERT(the_cpu_arena == nullptr); ParmParse pp("amrex"); pp.query("use_buddy_allocator", use_buddy_allocator); pp.query("buddy_allocator_size", buddy_allocator_size); + pp.query("the_arena_init_size", the_arena_init_size); #ifdef AMREX_USE_GPU if (use_buddy_allocator) @@ -116,6 +121,13 @@ Arena::Initialize () { #if defined(BL_COALESCE_FABS) || defined(AMREX_USE_GPU) the_arena = new CArena(0, ArenaInfo().SetPreferred()); +#ifdef AMREX_USE_GPU + if (the_arena_init_size <= 0) { + the_arena_init_size = Gpu::Device::totalGlobalMem() / 4L * 3L; + } + void *p = the_arena->alloc(static_cast(the_arena_init_size)); + the_arena->free(p); +#endif #else the_arena = new BArena; #endif @@ -141,11 +153,9 @@ Arena::Initialize () the_pinned_arena = new BArena; #endif - std::size_t N = 1024*1024*8; - void *p = the_arena->alloc(N); - the_arena->free(p); + std::size_t N = 1024UL*1024UL*8UL; - p = the_device_arena->alloc(N); + void *p = the_device_arena->alloc(N); the_device_arena->free(p); p = the_managed_arena->alloc(N); @@ -153,6 +163,8 @@ Arena::Initialize () p = the_pinned_arena->alloc(N); the_pinned_arena->free(p); + + the_cpu_arena = new BArena; } void @@ -267,6 +279,9 @@ Arena::Finalize () delete the_pinned_arena; the_pinned_arena = nullptr; + + delete the_cpu_arena; + the_cpu_arena = nullptr; } Arena* @@ -297,4 +312,11 @@ The_Pinned_Arena () return the_pinned_arena; } +Arena* +The_Cpu_Arena () +{ + BL_ASSERT(the_cpu_arena != nullptr); + return the_cpu_arena; +} + } diff --git a/Src/Base/AMReX_Array.H b/Src/Base/AMReX_Array.H index ca0e45e9086..1bfcb259091 100644 --- a/Src/Base/AMReX_Array.H +++ b/Src/Base/AMReX_Array.H @@ -37,7 +37,7 @@ namespace amrex { template ::value> > AMREX_GPU_HOST_DEVICE - constexpr Array4 (Array4::type> const& rhs) + constexpr Array4 (Array4::type> const& rhs) noexcept : p(rhs.p), jstride(rhs.jstride), kstride(rhs.kstride), @@ -47,7 +47,7 @@ namespace amrex { {} AMREX_GPU_HOST_DEVICE - constexpr Array4 (Array4 const& rhs) + constexpr Array4 (Array4 const& rhs) noexcept : p(rhs.p), jstride(rhs.jstride), kstride(rhs.kstride), @@ -57,7 +57,7 @@ namespace amrex { {} AMREX_GPU_HOST_DEVICE - constexpr Array4 (T* a_p, Dim3 const& a_begin, Dim3 const& a_end) + constexpr Array4 (T* a_p, Dim3 const& a_begin, Dim3 const& a_end) noexcept : p(a_p), jstride(a_end.x-a_begin.x), kstride(jstride*(a_end.y-a_begin.y)), @@ -67,7 +67,7 @@ namespace amrex { {} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - T& operator() (int i, int j, int k) const { + T& operator() (int i, int j, int k) const noexcept { #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK) index_assert(i,j,k); #endif @@ -75,7 +75,7 @@ namespace amrex { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - T& operator() (int i, int j, int k, int n) const { + T& operator() (int i, int j, int k, int n) const noexcept { #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK) index_assert(i,j,k); #endif @@ -83,7 +83,7 @@ namespace amrex { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - T* ptr (int i, int j, int k) const { + T* ptr (int i, int j, int k) const noexcept { #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK) index_assert(i,j,k); #endif @@ -133,13 +133,13 @@ namespace amrex { struct GpuArray { AMREX_GPU_HOST_DEVICE - inline const T& operator [] (int i) const { return arr[i]; } + inline const T& operator [] (int i) const noexcept { return arr[i]; } AMREX_GPU_HOST_DEVICE - inline T& operator [] (int i) { return arr[i]; } + inline T& operator [] (int i) noexcept { return arr[i]; } AMREX_GPU_HOST_DEVICE - inline const T* data() const { return arr; }; + inline const T* data() const noexcept { return arr; }; AMREX_GPU_HOST_DEVICE - inline std::size_t size() const { return N; }; + inline std::size_t size() const noexcept { return N; }; T arr[N]; }; @@ -157,31 +157,31 @@ namespace amrex { namespace amrex { template - std::array GetArrOfPtrs (std::array& a) + std::array GetArrOfPtrs (std::array& a) noexcept { return {AMREX_D_DECL(&a[0], &a[1], &a[2])}; } template - std::array GetArrOfPtrs (const std::array,AMREX_SPACEDIM>& a) + std::array GetArrOfPtrs (const std::array,AMREX_SPACEDIM>& a) noexcept { return {AMREX_D_DECL(a[0].get(), a[1].get(), a[2].get())}; } template - std::array GetArrOfConstPtrs (const std::array& a) + std::array GetArrOfConstPtrs (const std::array& a) noexcept { return {AMREX_D_DECL(&a[0], &a[1], &a[2])}; } template - std::array GetArrOfConstPtrs (const std::array& a) + std::array GetArrOfConstPtrs (const std::array& a) noexcept { return {AMREX_D_DECL(a[0], a[1], a[2])}; } template - std::array GetArrOfConstPtrs (const std::array,AMREX_SPACEDIM>& a) + std::array GetArrOfConstPtrs (const std::array,AMREX_SPACEDIM>& a) noexcept { return {AMREX_D_DECL(a[0].get(), a[1].get(), a[2].get())}; } diff --git a/Src/Base/AMReX_BCRec.H b/Src/Base/AMReX_BCRec.H index 17307b23ddf..c248802051a 100644 --- a/Src/Base/AMReX_BCRec.H +++ b/Src/Base/AMReX_BCRec.H @@ -20,7 +20,7 @@ public: * \brief The default constructor, which does NOT set valid boundary types. */ AMREX_GPU_HOST_DEVICE - BCRec () + BCRec () noexcept : bc {AMREX_D_DECL(BCType::bogus,BCType::bogus,BCType::bogus), AMREX_D_DECL(BCType::bogus,BCType::bogus,BCType::bogus)} { } @@ -29,7 +29,7 @@ public: */ AMREX_GPU_HOST_DEVICE BCRec (AMREX_D_DECL(int loX, int loY, int loZ), - AMREX_D_DECL(int hiX, int hiY, int hiZ)) + AMREX_D_DECL(int hiX, int hiY, int hiZ)) noexcept : bc {AMREX_D_DECL(loX,loY,loZ), AMREX_D_DECL(hiX,hiY,hiZ)} {} @@ -37,9 +37,9 @@ public: * \brief Another constructor. */ AMREX_GPU_HOST_DEVICE - BCRec (const int* lo, const int* hi) - : bc {AMREX_D_DECL(lo[0],lo[1],lo[2]), - AMREX_D_DECL(hi[0],hi[1],hi[2])} + BCRec (const int* a_lo, const int* a_hi) noexcept + : bc {AMREX_D_DECL(a_lo[0],a_lo[1],a_lo[2]), + AMREX_D_DECL(a_hi[0],a_hi[1],a_hi[2])} {} /* * \brief Yet another constructor. Inherits bndry types from bc_domain @@ -48,7 +48,7 @@ public: AMREX_GPU_HOST_DEVICE BCRec (const Box& bx, const Box& domain, - const BCRec& bc_domain) + const BCRec& bc_domain) noexcept { const int* bxlo = bx.loVect(); const int* bxhi = bx.hiVect(); @@ -66,50 +66,50 @@ public: * \brief Explicitly set lo bndry value. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - void setLo (int dir, int bc_val) { bc[dir] = bc_val; } + void setLo (int dir, int bc_val) noexcept { bc[dir] = bc_val; } /** * \brief Explicitly set hi bndry value. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - void setHi (int dir, int bc_val) { bc[AMREX_SPACEDIM+dir] = bc_val; } + void setHi (int dir, int bc_val) noexcept { bc[AMREX_SPACEDIM+dir] = bc_val; } /** * \brief Return bndry values (used in calls to FORTRAN). */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - const int* vect () const& { return bc; } + const int* vect () const& noexcept{ return bc; } const int* vect () && = delete; AMREX_GPU_HOST_DEVICE AMREX_INLINE - const int* data () const& { return bc; } + const int* data () const& noexcept { return bc; } const int* data () && = delete; /** * \brief Return low-end boundary data. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - const int* lo () const& { return bc; } + const int* lo () const& noexcept { return bc; } const int* lo () && = delete; /** * \brief Return high-end boundary data. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - const int* hi () const& { return bc+AMREX_SPACEDIM; } + const int* hi () const& noexcept { return bc+AMREX_SPACEDIM; } const int* hi () && = delete; /** * \brief Return low-end boundary data in direction \. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - int lo (int dir) const { return bc[dir]; } + int lo (int dir) const noexcept { return bc[dir]; } /** * \brief Return high-end boundary data in direction \. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - int hi (int dir) const { return bc[AMREX_SPACEDIM+dir]; } + int hi (int dir) const noexcept { return bc[AMREX_SPACEDIM+dir]; } /** * \brief Equal test. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator== (const BCRec& rhs) const { + bool operator== (const BCRec& rhs) const noexcept { bool retval = true; for (int i = 0; i < 2*AMREX_SPACEDIM && retval; i++) { @@ -121,7 +121,7 @@ public: * \brief Not equal test. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator!= (const BCRec& rhs) const { return !(*this == rhs); } + bool operator!= (const BCRec& rhs) const noexcept { return !(*this == rhs); } /** * \brief ASCII write to ostream. */ @@ -139,7 +139,7 @@ private: */ AMREX_GPU_HOST_DEVICE AMREX_INLINE void -setBC (const Box& bx, const Box& domain, const BCRec& bc_dom, BCRec& bcr) +setBC (const Box& bx, const Box& domain, const BCRec& bc_dom, BCRec& bcr) noexcept { const int* bxlo = bx.loVect(); const int* bxhi = bx.hiVect(); @@ -162,7 +162,7 @@ setBC (const Box& bx, int dest_comp, int ncomp, const Vector& bc_dom, - Vector& bcr); + Vector& bcr) noexcept; } #endif /*_BCREC_H_*/ diff --git a/Src/Base/AMReX_BCRec.cpp b/Src/Base/AMReX_BCRec.cpp index 919b9a00e37..714c0c8dddb 100644 --- a/Src/Base/AMReX_BCRec.cpp +++ b/Src/Base/AMReX_BCRec.cpp @@ -12,7 +12,7 @@ setBC (const Box& bx, int dest_comp, int ncomp, const Vector& bc_dom, - Vector& bcr) + Vector& bcr) noexcept { const int* bxlo = bx.loVect(); const int* bxhi = bx.hiVect(); diff --git a/Src/Base/AMReX_BaseFab.H b/Src/Base/AMReX_BaseFab.H index 1001f0a4bba..227fd4f08ef 100644 --- a/Src/Base/AMReX_BaseFab.H +++ b/Src/Base/AMReX_BaseFab.H @@ -46,12 +46,12 @@ namespace amrex #pragma omp threadprivate(private_total_cells_allocated_in_fabs_hwm) #endif - long TotalBytesAllocatedInFabs(); - long TotalBytesAllocatedInFabsHWM(); - long TotalCellsAllocatedInFabs(); - long TotalCellsAllocatedInFabsHWM(); - void ResetTotalBytesAllocatedInFabsHWM(); - void update_fab_stats (long n, long s, std::size_t szt); + long TotalBytesAllocatedInFabs () noexcept; + long TotalBytesAllocatedInFabsHWM () noexcept; + long TotalCellsAllocatedInFabs () noexcept; + long TotalCellsAllocatedInFabsHWM () noexcept; + void ResetTotalBytesAllocatedInFabsHWM () noexcept; + void update_fab_stats (long n, long s, std::size_t szt) noexcept; void BaseFab_Initialize (); void BaseFab_Finalize (); @@ -67,7 +67,7 @@ struct FabView int iend, jend, kend, nend; #endif AMREX_GPU_HOST_DEVICE - AMREX_FORCE_INLINE T& operator() (int i, int j, int k, int n=0) const { + AMREX_FORCE_INLINE T& operator() (int i, int j, int k, int n=0) const noexcept { #ifdef AMREX_DEBUG AMREX_ASSERT(i AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Array4 -makeArray4 (T* p, Box const& bx) +makeArray4 (T* p, Box const& bx) noexcept { return Array4{p, amrex::begin(bx), amrex::end(bx)}; } @@ -107,7 +107,7 @@ struct BaseFabData { AMREX_GPU_HOST_DEVICE BaseFabData (T* a_dptr, Box const& a_domain, int a_nvar, - long a_truesize, bool a_ptr_owner, bool a_shared_memory) + long a_truesize, bool a_ptr_owner, bool a_shared_memory) noexcept : dptr(a_dptr), domain(a_domain), nvar(a_nvar), truesize(a_truesize), ptr_owner(a_ptr_owner), shared_memory(a_shared_memory) {} @@ -118,7 +118,7 @@ struct BaseFabData long truesize; //!< nvar*numpts that was allocated on heap. bool ptr_owner;//!< Owner of T*? bool shared_memory; //!< Is the memory allocated in shared memory? - void setOwner (bool b) { ptr_owner = b; } + void setOwner (bool b) noexcept { ptr_owner = b; } }; /** @@ -167,13 +167,32 @@ struct BaseFabData */ template +struct DataAllocator { + void* alloc (std::size_t sz) const noexcept { return The_Arena()->alloc(sz); } + void free (void* pt) const noexcept { The_Arena()->free(pt); } + Arena* arena () const noexcept { return The_Arena(); } +}; + +#ifdef AMREX_USE_GPU +template +struct CpuDataAllocator { + void* alloc (std::size_t sz) const noexcept { return The_Cpu_Arena()->alloc(sz); } + void free (void* pt) const noexcept { The_Cpu_Arena()->free(pt); } + Arena* arena () const noexcept { return The_Cpu_Arena(); } +}; +#else +template using CpuDataAllocator = DataAllocator; +#endif + +template > class BaseFab : public BaseFabData { public: - template friend class BaseFab; + template friend class BaseFab; - typedef T value_type; + typedef T value_type; + typedef Allocator allocator_type; //! Construct an empty BaseFab, which must be resized (see BaseFab::resize) before use. BaseFab (); @@ -183,10 +202,10 @@ public: bool alloc = true, bool shared = false); - BaseFab (const BaseFab& rhs, MakeType make_type, int scomp, int ncomp); + BaseFab (const BaseFab& rhs, MakeType make_type, int scomp, int ncomp); #ifdef AMREX_USE_GPU - BaseFab (const BaseFab& rhs, MakeType make_type); + BaseFab (const BaseFab& rhs, MakeType make_type); #endif /** @@ -199,14 +218,14 @@ public: //! The destructor deletes the array memory. ~BaseFab (); - BaseFab (const BaseFab& rhs) = delete; - BaseFab& operator= (const BaseFab& rhs) = delete; - BaseFab& operator= (BaseFab&& rhs) = delete; + BaseFab (const BaseFab& rhs) = delete; + BaseFab& operator= (const BaseFab& rhs) = delete; + BaseFab& operator= (BaseFab&& rhs) = delete; - BaseFab (BaseFab&& rhs) noexcept; + BaseFab (BaseFab&& rhs) noexcept; AMREX_GPU_HOST_DEVICE - BaseFab& operator= (T); + BaseFab& operator= (T) noexcept; static void Initialize(); static void Finalize(); @@ -226,66 +245,66 @@ public: int N = 1); template ::value> > - Elixir elixir (); + Elixir elixir () noexcept; /** * \brief The function returns the BaseFab to the invalid state. * The memory is freed. */ - void clear (); + void clear () noexcept; //! Returns how many bytes used AMREX_GPU_HOST_DEVICE - std::size_t nBytes () const { return this->truesize*sizeof(T); } + std::size_t nBytes () const noexcept { return this->truesize*sizeof(T); } - static bool preAllocatable () { return true; } + static bool preAllocatable () noexcept { return true; } - static bool isCopyOMPSafe () { return true; } + static bool isCopyOMPSafe () noexcept { return true; } //! Returns bytes used in the Box for those components AMREX_GPU_HOST_DEVICE - std::size_t nBytes (const Box& bx, int start_comp, int ncomps) const + std::size_t nBytes (const Box& bx, int start_comp, int ncomps) const noexcept { return bx.numPts() * sizeof(T) * ncomps; } //! Returns the number of components AMREX_GPU_HOST_DEVICE - int nComp () const { return this->nvar; } + int nComp () const noexcept { return this->nvar; } //! for calls to fortran. AMREX_GPU_HOST_DEVICE - const int* nCompPtr() const { + const int* nCompPtr() const noexcept { return &(this->nvar); } //! Returns the number of points AMREX_GPU_HOST_DEVICE - long numPts () const { return this->domain.numPts(); } + long numPts () const noexcept { return this->domain.numPts(); } //! Returns the total number of points of all components AMREX_GPU_HOST_DEVICE - long size () const { return this->nvar*this->domain.numPts(); } + long size () const noexcept { return this->nvar*this->domain.numPts(); } //! Returns the domain (box) where the array is defined AMREX_GPU_HOST_DEVICE - const Box& box () const { return this->domain; } + const Box& box () const noexcept { return this->domain; } /** * \brief Returns a pointer to an array of SPACEDIM integers * giving the length of the domain in each direction */ AMREX_GPU_HOST_DEVICE - IntVect length () const { return this->domain.length(); } + IntVect length () const noexcept { return this->domain.length(); } /** * \brief Returns the lower corner of the domain * See class Box for analogue. */ AMREX_GPU_HOST_DEVICE - const IntVect& smallEnd () const { return this->domain.smallEnd(); } + const IntVect& smallEnd () const noexcept { return this->domain.smallEnd(); } //! Returns the upper corner of the domain. See class Box for analogue. AMREX_GPU_HOST_DEVICE - const IntVect& bigEnd () const { return this->domain.bigEnd(); } + const IntVect& bigEnd () const noexcept { return this->domain.bigEnd(); } /** * \brief Returns the lower corner of the domain. @@ -296,7 +315,7 @@ public: * Fortran subroutines. */ AMREX_GPU_HOST_DEVICE - const int* loVect () const { return this->domain.loVect(); } + const int* loVect () const noexcept { return this->domain.loVect(); } /** * \brief Returns the upper corner of the domain. @@ -307,14 +326,14 @@ public: * Fortran subroutines. */ AMREX_GPU_HOST_DEVICE - const int* hiVect () const { return this->domain.hiVect(); } + const int* hiVect () const noexcept { return this->domain.hiVect(); } /** * \brief Returns true if the domain of fab is totally contained within * the domain of this BaseFab. */ AMREX_GPU_HOST_DEVICE - bool contains (const BaseFab& fab) const + bool contains (const BaseFab& fab) const noexcept { return box().contains(fab.box()) && this->nvar <= fab.nvar; } @@ -324,7 +343,7 @@ public: * within the domain of this BaseFab. */ AMREX_GPU_HOST_DEVICE - bool contains (const Box& bx) const { return box().contains(bx); } + bool contains (const Box& bx) const noexcept { return box().contains(bx); } /** * \brief Returns a pointer to an object of type T that is the @@ -336,57 +355,61 @@ public: * dataPtr returns a pointer to all the Nth components. */ AMREX_GPU_HOST_DEVICE - T* dataPtr (int n = 0) { AMREX_ASSERT(!(this->dptr == 0)); return &(this->dptr[n*this->domain.numPts()]); } + T* dataPtr (int n = 0) noexcept { AMREX_ASSERT(!(this->dptr == 0)); return &(this->dptr[n*this->domain.numPts()]); } //! Same as above except works on const FABs. AMREX_GPU_HOST_DEVICE - const T* dataPtr (int n = 0) const { AMREX_ASSERT(!(this->dptr == 0)); return &(this->dptr[n*this->domain.numPts()]); } + const T* dataPtr (int n = 0) const noexcept { AMREX_ASSERT(!(this->dptr == 0)); return &(this->dptr[n*this->domain.numPts()]); } AMREX_GPU_HOST_DEVICE - T* dataPtr (const IntVect& iv, int n = 0); + T* dataPtr (const IntVect& iv, int n = 0) noexcept; + AMREX_GPU_HOST_DEVICE - const T* dataPtr (const IntVect& iv, int n = 0) const; + const T* dataPtr (const IntVect& iv, int n = 0) const noexcept; + + void setPtr (T* p, long sz) noexcept { AMREX_ASSERT(this->dptr == 0 && this->truesize == 0); this->dptr = p; this->truesize = sz; } - void setPtr (T* p, long sz) { AMREX_ASSERT(this->dptr == 0 && this->truesize == 0); this->dptr = p; this->truesize = sz; } + void prefetchToHost () const noexcept; + void prefetchToDevice () const noexcept; AMREX_GPU_HOST_DEVICE AMREX_INLINE - Array4 array () const + Array4 array () const noexcept { return makeArray4(this->dptr, this->domain); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - Array4 array () + Array4 array () noexcept { return makeArray4(this->dptr, this->domain); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - Array4 const_array () const + Array4 const_array () const noexcept { return makeArray4(this->dptr, this->domain); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (int n = 0) const + FabView view (int n = 0) const noexcept { return view(this->domain.loVect3d(),n); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (int n = 0) + FabView view (int n = 0) noexcept { return view(this->domain.loVect3d(),n); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const IntVect& iv, int n = 0) const + FabView view (const IntVect& iv, int n = 0) const noexcept { #if (AMREX_SPACEDIM == 1) return view(GpuArray{iv[0], 0, 0}, n); @@ -399,7 +422,7 @@ public: AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const IntVect& iv, int n = 0) + FabView view (const IntVect& iv, int n = 0) noexcept { #if (AMREX_SPACEDIM == 1) return view(GpuArray{iv[0], 0, 0}, n); @@ -412,21 +435,21 @@ public: AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const Box& subbox, int n = 0) const + FabView view (const Box& subbox, int n = 0) const noexcept { return view(subbox.loVect3d(),n); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const Box& subbox, int n = 0) + FabView view (const Box& subbox, int n = 0) noexcept { return view(subbox.loVect3d(),n); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const GpuArray& slo, int n = 0) const + FabView view (const GpuArray& slo, int n = 0) const noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) AMREX_ASSERT(this->domain.numPts() < static_cast(std::numeric_limits::max())); @@ -455,7 +478,7 @@ public: AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const GpuArray& slo, int n = 0) + FabView view (const GpuArray& slo, int n = 0) noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) AMREX_ASSERT(this->domain.numPts() < static_cast(std::numeric_limits::max())); @@ -484,7 +507,7 @@ public: AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const Dim3& slo, int n = 0) const + FabView view (const Dim3& slo, int n = 0) const noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) AMREX_ASSERT(this->domain.numPts() < static_cast(std::numeric_limits::max())); @@ -513,7 +536,7 @@ public: AMREX_GPU_HOST_DEVICE AMREX_INLINE - FabView view (const Dim3& slo, int n = 0) + FabView view (const Dim3& slo, int n = 0) noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) AMREX_ASSERT(this->domain.numPts() < static_cast(std::numeric_limits::max())); @@ -542,7 +565,7 @@ public: //! Returns true if the data for the FAB has been allocated. AMREX_GPU_HOST_DEVICE - bool isAllocated () const { return this->dptr != 0; } + bool isAllocated () const noexcept { return this->dptr != 0; } /** * \brief Returns a reference to the Nth component value @@ -551,19 +574,19 @@ public: * C++ code. */ AMREX_GPU_HOST_DEVICE - T& operator() (const IntVect& p, int N); + T& operator() (const IntVect& p, int N) noexcept; //! Same as above, except returns component 0. AMREX_GPU_HOST_DEVICE - T& operator() (const IntVect& p); + T& operator() (const IntVect& p) noexcept; //! Same as above except works on const FABs. AMREX_GPU_HOST_DEVICE - const T& operator() (const IntVect& p, int N) const; + const T& operator() (const IntVect& p, int N) const noexcept; //! Same as above, except returns component 0. AMREX_GPU_HOST_DEVICE - const T& operator() (const IntVect& p) const; + const T& operator() (const IntVect& p) const noexcept; /** * \brief This function puts numcomp component values, starting at @@ -574,11 +597,11 @@ public: void getVal (T* data, const IntVect& pos, int N, - int numcomp) const; + int numcomp) const noexcept; //! Same as above, except that starts at component 0 and copies all comps. AMREX_GPU_HOST_DEVICE void getVal (T* data, - const IntVect& pos) const; + const IntVect& pos) const noexcept; /** * \brief The setVal functions set sub-regions in the BaseFab to a * constant value. This most general form specifies the sub-box, @@ -586,23 +609,23 @@ public: * to be set. */ AMREX_GPU_HOST_DEVICE - void setVal (T x, const Box& bx, int nstart, int ncomp); + void setVal (T x, const Box& bx, int nstart, int ncomp) noexcept; //! Same as above, except the number of modified components is one. N is the component to be modified. AMREX_GPU_HOST_DEVICE - void setVal (T x, const Box& bx, int N = 0); + void setVal (T x, const Box& bx, int N = 0) noexcept; //! Same as above, except the sub-box defaults to the entire domain. AMREX_GPU_HOST_DEVICE - void setVal (T x, int N); + void setVal (T x, int N) noexcept; AMREX_GPU_HOST_DEVICE - void setValIfNot (T x, const Box& bx, const BaseFab& mask, int nstart, int ncomp); + void setValIfNot (T x, const Box& bx, const BaseFab& mask, int nstart, int ncomp) noexcept; /** * \brief This function is analogous to the fourth form of * setVal above, except that instead of setting values on the * Box b, values are set on the complement of b in the domain. */ - void setComplement (T x, const Box& b, int ns, int num); + void setComplement (T x, const Box& b, int ns, int num) noexcept; /** * \brief The copy functions copy the contents of one BaseFab into @@ -621,12 +644,12 @@ public: * same and the srcbox and destbox overlap. */ AMREX_GPU_HOST_DEVICE - BaseFab& copy (const BaseFab& src, - const Box& srcbox, - int srccomp, - const Box& destbox, - int destcomp, - int numcomp); + BaseFab& copy (const BaseFab& src, + const Box& srcbox, + int srccomp, + const Box& destbox, + int destcomp, + int numcomp) noexcept; /** * \brief As above, except the destination Box and the source Box @@ -635,10 +658,10 @@ public: * class. */ AMREX_GPU_HOST_DEVICE - BaseFab& copy (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp = 1); + BaseFab& copy (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp = 1) noexcept; /** * \brief As above, except that the destination Box is specified, * but the source Box is taken to the equal to the source @@ -646,29 +669,29 @@ public: * copied. */ AMREX_GPU_HOST_DEVICE - BaseFab& copy (const BaseFab& src, - const Box& destbox); + BaseFab& copy (const BaseFab& src, + const Box& destbox) noexcept; //! Copy from the srcbox of this Fab to raw memory and return the number of bytes copied AMREX_GPU_HOST_DEVICE std::size_t copyToMem (const Box& srcbox, int srccomp, int numcomp, - void* dst) const; + void* dst) const noexcept; AMREX_GPU_HOST_DEVICE //! Copy from raw memory to the dstbox of this Fab and return the number of bytes copied std::size_t copyFromMem (const Box& dstbox, int dstcomp, int numcomp, - const void* src); + const void* src) noexcept; AMREX_GPU_HOST_DEVICE //! Add from raw memory to the dstbox of this Fab and return the number of bytes copied std::size_t addFromMem (const Box& dstbox, int dstcomp, int numcomp, - const void* src); + const void* src) noexcept; /** * \brief Perform shifts upon the domain of the BaseFab. They are @@ -676,31 +699,31 @@ public: * There is no effect upon the array memory. */ AMREX_GPU_HOST_DEVICE - BaseFab& shift (const IntVect& v); + BaseFab& shift (const IntVect& v) noexcept; /** * \brief Perform shifts upon the domain of the BaseFab. They are * completely analogous to the corresponding Box functions. * There is no effect upon the array memory. */ AMREX_GPU_HOST_DEVICE - BaseFab& shift (int idir, int n_cell); + BaseFab& shift (int idir, int n_cell) noexcept; /** * \brief Perform shifts upon the domain of the BaseFab. They are * completely analogous to the corresponding Box functions. * There is no effect upon the array memory. */ AMREX_GPU_HOST_DEVICE - BaseFab& shiftHalf (int dir, int num_halfs); + BaseFab& shiftHalf (int dir, int num_halfs) noexcept; /** * \brief Perform shifts upon the domain of the BaseFab. They are * completely analogous to the corresponding Box functions. * There is no effect upon the array memory. */ AMREX_GPU_HOST_DEVICE - BaseFab& shiftHalf (const IntVect& num_halfs); + BaseFab& shiftHalf (const IntVect& num_halfs) noexcept; AMREX_GPU_HOST_DEVICE - Real norminfmask (const Box& subbox, const BaseFab& mask, int scomp=0, int ncomp=1) const; + Real norminfmask (const Box& subbox, const BaseFab& mask, int scomp=0, int ncomp=1) const noexcept; /** * \brief Compute the Lp-norm of this FAB using components (scomp : scomp+ncomp-1). @@ -711,61 +734,61 @@ public: AMREX_GPU_HOST_DEVICE Real norm (int p, int scomp = 0, - int ncomp = 1) const; + int ncomp = 1) const noexcept; //! Same as above except only on given subbox. AMREX_GPU_HOST_DEVICE Real norm (const Box& subbox, int p, int scomp = 0, - int ncomp = 1) const; + int ncomp = 1) const noexcept; //!Compute absolute value for all components of this FAB. AMREX_GPU_HOST_DEVICE - void abs (); + void abs () noexcept; //! Same as above except only for components (comp: comp+numcomp-1) AMREX_GPU_HOST_DEVICE void abs (int comp, - int numcomp=1); + int numcomp=1) noexcept; /** * \brief Calculate abs() on subbox for given component range. */ AMREX_GPU_HOST_DEVICE void abs (const Box& subbox, int comp = 0, - int numcomp=1); + int numcomp=1) noexcept; /** * \return Minimum value of given component. */ AMREX_GPU_HOST_DEVICE - T min (int comp = 0) const; + T min (int comp = 0) const noexcept; /** * \return Minimum value of given component in given subbox. */ AMREX_GPU_HOST_DEVICE T min (const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return Maximum value of given component. */ AMREX_GPU_HOST_DEVICE - T max (int comp = 0) const; + T max (int comp = 0) const noexcept; /** * \return Maximum value of given component in given subbox. */ AMREX_GPU_HOST_DEVICE T max (const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return Maximum of the absolute value of given component. */ AMREX_GPU_HOST_DEVICE - T maxabs (int comp = 0) const; + T maxabs (int comp = 0) const noexcept; /** * \return Maximum of the absolute value of given component in given subbox. */ AMREX_GPU_HOST_DEVICE T maxabs (const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return location of a cell containing the specified value @@ -774,20 +797,20 @@ public: AMREX_GPU_HOST_DEVICE IntVect indexFromValue (Real value, const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return location of minimum value in given component. */ AMREX_GPU_HOST_DEVICE - IntVect minIndex (int comp = 0) const; + IntVect minIndex (int comp = 0) const noexcept; /** * \return location of minimum value in given component in * given subbox. */ AMREX_GPU_HOST_DEVICE IntVect minIndex (const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return return mininum value and location to allow * efficient looping over multiple boxes. @@ -796,20 +819,20 @@ public: void minIndex (const Box& subbox, Real& min_val, IntVect& min_idx, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return location of maximum value in given component. */ AMREX_GPU_HOST_DEVICE - IntVect maxIndex (int comp = 0) const; + IntVect maxIndex (int comp = 0) const noexcept; /** * \return location of maximum value in given component in given * subbox. */ AMREX_GPU_HOST_DEVICE IntVect maxIndex (const Box& subbox, - int comp = 0) const; + int comp = 0) const noexcept; /** * \return return maximum value and location to allow * efficient looping over multiple boxes. @@ -818,7 +841,7 @@ public: void maxIndex (const Box& subbox, Real& max_value, IntVect& max_index, - int comp = 0) const; + int comp = 0) const noexcept; /** @@ -830,71 +853,71 @@ public: AMREX_GPU_HOST_DEVICE int maskLT (BaseFab& mask, T val, - int comp = 0) const; + int comp = 0) const noexcept; //! Same as above except mark cells with value less than or equal to val. AMREX_GPU_HOST_DEVICE int maskLE (BaseFab& mask, T val, - int comp = 0) const; + int comp = 0) const noexcept; //! Same as above except mark cells with value equal to val. AMREX_GPU_HOST_DEVICE int maskEQ (BaseFab& mask, T val, - int comp = 0) const; + int comp = 0) const noexcept; //! Same as above except mark cells with value greater than val. AMREX_GPU_HOST_DEVICE int maskGT (BaseFab& mask, T val, - int comp = 0) const; + int comp = 0) const noexcept; //! Same as above except mark cells with value greater than or equal to val. AMREX_GPU_HOST_DEVICE int maskGE (BaseFab& mask, T val, - int comp = 0) const; + int comp = 0) const noexcept; //! Returns sum of given component of FAB state vector. AMREX_GPU_HOST_DEVICE T sum (int comp, - int numcomp = 1) const; + int numcomp = 1) const noexcept; //! Compute sum of given component of FAB state vector in given subbox. AMREX_GPU_HOST_DEVICE T sum (const Box& subbox, int comp, - int numcomp = 1) const; + int numcomp = 1) const noexcept; //! Most general version, specify subbox and which components. AMREX_GPU_HOST_DEVICE - BaseFab& invert (T v, - const Box& subbox, - int comp=0, - int numcomp=1); + BaseFab& invert (T v, + const Box& subbox, + int comp=0, + int numcomp=1) noexcept; //! As above except on entire domain. AMREX_GPU_HOST_DEVICE - BaseFab& invert (T v, - int comp, - int numcomp=1); + BaseFab& invert (T v, + int comp, + int numcomp=1) noexcept; //! Negate BaseFab, most general. AMREX_GPU_HOST_DEVICE - BaseFab& negate (const Box& subbox, - int comp=0, - int numcomp=1); + BaseFab& negate (const Box& subbox, + int comp=0, + int numcomp=1) noexcept; //! As above, except on entire domain. AMREX_GPU_HOST_DEVICE - BaseFab& negate (int comp, - int numcomp=1); + BaseFab& negate (int comp, + int numcomp=1) noexcept; //! Scalar addition (a[i] <- a[i] + r), most general. AMREX_GPU_HOST_DEVICE - BaseFab& plus (T r, - const Box& b, - int comp=0, - int numcomp=1); + BaseFab& plus (T r, + const Box& b, + int comp=0, + int numcomp=1) noexcept; //! As above, except on entire domain. AMREX_GPU_HOST_DEVICE - BaseFab& plus (T r, - int comp, - int numcomp=1); + BaseFab& plus (T r, + int comp, + int numcomp=1) noexcept; /** * \brief Add src components (srccomp:srccomp+numcomp-1) to @@ -902,36 +925,36 @@ public: * where the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& plus (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& plus (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Same as above except addition is restricted to intersection * of subbox and src FAB. NOTE: subbox must be contained in this * FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& plus (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& plus (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Add srcbox region of src FAB to destbox region of this FAB. * The srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& plus (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& plus (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! Atomic FAB addition (a[i] <- a[i] + b[i]). AMREX_GPU_HOST_DEVICE - BaseFab& atomicAdd (const BaseFab& src); + BaseFab& atomicAdd (const BaseFab& src) noexcept; /** * \brief Atomically add src components (srccomp:srccomp+numcomp-1) to @@ -939,63 +962,63 @@ public: * where the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& atomicAdd (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& atomicAdd (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Same as above except addition is restricted to intersection * of subbox and src FAB. NOTE: subbox must be contained in this * FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& atomicAdd (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& atomicAdd (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Atomically add srcbox region of src FAB to destbox region of this FAB. * The srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& atomicAdd (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& atomicAdd (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! FAB SAXPY (y[i] <- y[i] + a * x[i]), in place. AMREX_GPU_HOST_DEVICE - BaseFab& saxpy (T a, const BaseFab& x, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& saxpy (T a, const BaseFab& x, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! FAB SAXPY (y[i] <- y[i] + a * x[i]), in place. All components. AMREX_GPU_HOST_DEVICE - BaseFab& saxpy (T a, const BaseFab& x); + BaseFab& saxpy (T a, const BaseFab& x) noexcept; //! FAB XPAY (y[i] <- x[i] + a * y[i]) AMREX_GPU_HOST_DEVICE - BaseFab& xpay (T a, const BaseFab& x, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& xpay (T a, const BaseFab& x, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! y[i] <- y[i] + x1[i] * x2[i]) AMREX_GPU_HOST_DEVICE - BaseFab& addproduct (const Box& destbox, - int destcomp, - int numcomp, - const BaseFab& src1, - int comp1, - const BaseFab& src2, - int comp2); + BaseFab& addproduct (const Box& destbox, + int destcomp, + int numcomp, + const BaseFab& src1, + int comp1, + const BaseFab& src2, + int comp2) noexcept; /** * \brief Subtract src components (srccomp:srccomp+numcomp-1) to @@ -1003,46 +1026,46 @@ public: * the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& minus (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& minus (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Same as above except subtraction is restricted to intersection * of subbox and src FAB. NOTE: subbox must be contained in * this FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& minus (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& minus (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Subtract srcbox region of src FAB from destbox region * of this FAB. srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& minus (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& minus (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! Scalar multiplication, except control which components are multiplied. AMREX_GPU_HOST_DEVICE - BaseFab& mult (T r, - int comp, - int numcomp=1); + BaseFab& mult (T r, + int comp, + int numcomp=1) noexcept; /** * \brief As above, except specify sub-box. */ AMREX_GPU_HOST_DEVICE - BaseFab& mult (T r, - const Box& b, - int comp=0, - int numcomp=1); + BaseFab& mult (T r, + const Box& b, + int comp=0, + int numcomp=1) noexcept; /** * \brief Multiply src components (srccomp:srccomp+numcomp-1) with @@ -1050,10 +1073,10 @@ public: * the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& mult (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& mult (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Same as above except multiplication is restricted to @@ -1061,36 +1084,36 @@ public: * contained in this FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& mult (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& mult (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Multiply srcbox region of src FAB with destbox region * of this FAB. The srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& mult (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& mult (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; //! As above except specify which components. AMREX_GPU_HOST_DEVICE - BaseFab& divide (T r, - int comp, - int numcomp=1); + BaseFab& divide (T r, + int comp, + int numcomp=1) noexcept; //! As above except specify sub-box. AMREX_GPU_HOST_DEVICE - BaseFab& divide (T r, - const Box& b, - int comp=0, - int numcomp=1); + BaseFab& divide (T r, + const Box& b, + int comp=0, + int numcomp=1) noexcept; /** * \brief This FAB is numerator, src FAB is denominator @@ -1099,37 +1122,37 @@ public: * where the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& divide (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& divide (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Same as above except division is restricted to * intersection of subbox and src FAB. NOTE: subbox must be * contained in this FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& divide (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& divide (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief destbox region of this FAB is numerator. srcbox regions of * src FAB is denominator. srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& divide (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& divide (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Divide wherever "src" is "true" or "non-zero". */ AMREX_GPU_HOST_DEVICE - BaseFab& protected_divide (const BaseFab& src); + BaseFab& protected_divide (const BaseFab& src) noexcept; /** * \brief Divide wherever "src" is "true" or "non-zero". @@ -1139,10 +1162,10 @@ public: * where the two FABs intersect. */ AMREX_GPU_HOST_DEVICE - BaseFab& protected_divide (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& protected_divide (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Divide wherever "src" is "true" or "non-zero". @@ -1151,11 +1174,11 @@ public: * contained in this FAB. */ AMREX_GPU_HOST_DEVICE - BaseFab& protected_divide (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& protected_divide (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * Divide wherever "src" is "true" or "non-zero". @@ -1163,12 +1186,12 @@ public: * src FAB is denominator. srcbox and destbox must be same size. */ AMREX_GPU_HOST_DEVICE - BaseFab& protected_divide (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp=1); + BaseFab& protected_divide (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp=1) noexcept; /** * \brief Linear interpolation / extrapolation. @@ -1181,31 +1204,31 @@ public: * This FAB is returned as a reference for chaining. */ AMREX_GPU_HOST_DEVICE - BaseFab& linInterp (const BaseFab& f1, - const Box& b1, - int comp1, - const BaseFab& f2, - const Box& b2, - int comp2, - Real t1, - Real t2, - Real t, - const Box& b, - int comp, - int numcomp = 1); + BaseFab& linInterp (const BaseFab& f1, + const Box& b1, + int comp1, + const BaseFab& f2, + const Box& b2, + int comp2, + Real t1, + Real t2, + Real t, + const Box& b, + int comp, + int numcomp = 1) noexcept; AMREX_GPU_HOST_DEVICE //! Version of linInterp() in which b, b1, & b2 are the same. - BaseFab& linInterp (const BaseFab& f1, - int comp1, - const BaseFab& f2, - int comp2, - Real t1, - Real t2, - Real t, - const Box& b, - int comp, - int numcomp = 1); + BaseFab& linInterp (const BaseFab& f1, + int comp1, + const BaseFab& f2, + int comp2, + Real t1, + Real t2, + Real t, + const Box& b, + int comp, + int numcomp = 1) noexcept; /** * \brief Linear combination. Result is alpha*f1 + beta*f2. @@ -1217,65 +1240,65 @@ public: * This FAB is returned as a reference for chaining. */ AMREX_GPU_HOST_DEVICE - BaseFab& linComb (const BaseFab& f1, - const Box& b1, - int comp1, - const BaseFab& f2, - const Box& b2, - int comp2, - Real alpha, - Real beta, - const Box& b, - int comp, - int numcomp = 1); + BaseFab& linComb (const BaseFab& f1, + const Box& b1, + int comp1, + const BaseFab& f2, + const Box& b2, + int comp2, + Real alpha, + Real beta, + const Box& b, + int comp, + int numcomp = 1) noexcept; //! Dot product of x (i.e.,this) and y AMREX_GPU_HOST_DEVICE T dot (const Box& xbx, int xcomp, - const BaseFab& y, const Box& ybx, int ycomp, - int numcomp = 1) const; + const BaseFab& y, const Box& ybx, int ycomp, + int numcomp = 1) const noexcept; AMREX_GPU_HOST_DEVICE T dotmask (const BaseFab& mask, const Box& xbx, int xcomp, - const BaseFab& y, const Box& ybx, int ycomp, - int numcomp) const; + const BaseFab& y, const Box& ybx, int ycomp, + int numcomp) const noexcept; //! Change the Box type without change the length AMREX_GPU_HOST_DEVICE - void SetBoxType (const IndexType& typ) { this->domain.setType(typ); } + void SetBoxType (const IndexType& typ) noexcept { this->domain.setType(typ); } template //!< AMREX_GPU_HOST_DEVICE - void ForEach (const Box& b, int c, int nc, F f) { + void ForEach (const Box& b, int c, int nc, F f) noexcept { ForEachImpl(*this, b, c, nc, f); } template //!< AMREX_GPU_HOST_DEVICE - void ForEach (const Box& b, int c, int nc, F f) const { + void ForEach (const Box& b, int c, int nc, F f) const noexcept { ForEachImpl(*this, b, c, nc, f); } template //!< AMREX_GPU_HOST_DEVICE - void ForEachIV (const Box& b, int c, int nc, F f) { + void ForEachIV (const Box& b, int c, int nc, F f) noexcept { ForEachIVImpl(*this, b, c, nc, f); } template //!< AMREX_GPU_HOST_DEVICE - void ForEachIV (const Box& b, int c, int nc, F f) const { + void ForEachIV (const Box& b, int c, int nc, F f) const noexcept { ForEachIVImpl(*this, b, c, nc, f); } template //!< AMREX_GPU_HOST_DEVICE void ForEach (const Box& dstbox, int dstcomp, int numcomp, - const BaseFab& src, int srccomp, F f); + const BaseFab& src, int srccomp, F f) noexcept; template //!< AMREX_GPU_HOST_DEVICE void ForEach (const Box& dstbox, int dstcomp, int numcomp, - const BaseFab& src, const Box& srcbox, int srccomp, F f); + const BaseFab& src, const Box& srcbox, int srccomp, F f) noexcept; template //!< AMREX_GPU_HOST_DEVICE - P Accumulate (const Box& b, int c, int nc, P init, F f) const; + P Accumulate (const Box& b, int c, int nc, P init, F f) const noexcept; template //!< AMREX_GPU_HOST_DEVICE - void Transform (T* dst, const Box& b, int c, int nc, F f) const; + void Transform (T* dst, const Box& b, int c, int nc, F f) const noexcept; template //!< AMREX_GPU_HOST_DEVICE - void Transform (const Box& b, int c, int nc, T const* src, F f); + void Transform (const Box& b, int c, int nc, T const* src, F f) noexcept; // // New interfaces @@ -1283,28 +1306,28 @@ public: //! Set value on the whole domain and all components AMREX_GPU_HOST_DEVICE - void setVal (T val); + void setVal (T val) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - void setVal (T val, Box bx, DestComp dcomp, NumComps ncomp); + void setVal (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept; AMREX_GPU_HOST_DEVICE - void setValIf (T val, const BaseFab& mask); + void setValIf (T val, const BaseFab& mask) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - void setValIf (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp); + void setValIf (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) noexcept; AMREX_GPU_HOST_DEVICE - void setValIfNot (T val, const BaseFab& mask); + void setValIfNot (T val, const BaseFab& mask) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - void setValIfNot (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp); + void setValIfNot (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) noexcept; //! setVal on the complement of bx in the fab's domain - void setComplement (T val, Box const& bx, DestComp dcomp, NumComps ncomp); + void setComplement (T val, Box const& bx, DestComp dcomp, NumComps ncomp) noexcept; /** * copy is performed on the intersection of dest and src fabs. @@ -1312,141 +1335,141 @@ public: * components (more is OK). */ AMREX_GPU_HOST_DEVICE - BaseFab& copy (const BaseFab& src); + BaseFab& copy (const BaseFab& src) noexcept; // //! Do nothing if bx does not intersect with src fab. AMREX_GPU_HOST_DEVICE - BaseFab& copy (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp); + BaseFab& copy (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept; //! Scalar addition on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& plus (T val); + BaseFab& plus (T val) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator+= (T val); + BaseFab& operator+= (T val) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - BaseFab& plus (T val, Box bx, DestComp dcomp, NumComps ncomp); + BaseFab& plus (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept; /** * Fab addition is performed on the intersection of dest and src fabs. * All components of dest fab are copied. src fab must have enough * components (more is OK). */ AMREX_GPU_HOST_DEVICE - BaseFab& plus (const BaseFab& src); + BaseFab& plus (const BaseFab& src) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator+= (const BaseFab& src); + BaseFab& operator+= (const BaseFab& src) noexcept; // //! Do nothing if bx does not intersect with src fab. AMREX_GPU_HOST_DEVICE - BaseFab& plus (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp); + BaseFab& plus (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept; //! Scalar subtraction on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& minus (T val); + BaseFab& minus (T val) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator-= (T val); + BaseFab& operator-= (T val) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - BaseFab& minus (T val, Box bx, DestComp dcomp, NumComps ncomp); + BaseFab& minus (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept; /** * Fab subtraction is performed on the intersection of dest and src fabs. * All components of dest fab are copied. src fab must have enough * components (more is OK). */ AMREX_GPU_HOST_DEVICE - BaseFab& minus (const BaseFab& src); + BaseFab& minus (const BaseFab& src) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator-= (const BaseFab& src); + BaseFab& operator-= (const BaseFab& src) noexcept; // //! Do nothing if bx does not intersect with src fab. AMREX_GPU_HOST_DEVICE - BaseFab& minus (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp); + BaseFab& minus (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept; //! Scalar multiplication on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& mult (T val); + BaseFab& mult (T val) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator*= (T val); + BaseFab& operator*= (T val) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - BaseFab& mult (T val, Box bx, DestComp dcomp, NumComps ncomp); + BaseFab& mult (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept; /** * Fab multiplication is performed on the intersection of dest and src fabs. * All components of dest fab are copied. src fab must have enough * components (more is OK). */ AMREX_GPU_HOST_DEVICE - BaseFab& mult (const BaseFab& src); + BaseFab& mult (const BaseFab& src) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator*= (const BaseFab& src); + BaseFab& operator*= (const BaseFab& src) noexcept; // //! Do nothing if bx does not intersect with src fab. AMREX_GPU_HOST_DEVICE - BaseFab& mult (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp); + BaseFab& mult (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept; //! Scalar division on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& divide (T val); + BaseFab& divide (T val) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator/= (T val); + BaseFab& operator/= (T val) noexcept; // //! Do nothing if bx is empty. AMREX_GPU_HOST_DEVICE - BaseFab& divide (T val, Box bx, DestComp dcomp, NumComps ncomp); + BaseFab& divide (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept; /** * Fab division is performed on the intersection of dest and src fabs. * All components of dest fab are copied. src fab must have enough * components (more is OK). */ AMREX_GPU_HOST_DEVICE - BaseFab& divide (const BaseFab& src); + BaseFab& divide (const BaseFab& src) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& operator/= (const BaseFab& src); + BaseFab& operator/= (const BaseFab& src) noexcept; // //! Do nothing if bx does not intersect with src fab. AMREX_GPU_HOST_DEVICE - BaseFab& divide (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp); + BaseFab& divide (const BaseFab& src, Box bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept; //! on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& negate (); + BaseFab& negate () noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& negate (const Box& bx, DestComp dcomp, NumComps ncomp); + BaseFab& negate (const Box& bx, DestComp dcomp, NumComps ncomp) noexcept; //! Fab <- Fab/r on the whole domain and all components AMREX_GPU_HOST_DEVICE - BaseFab& invert (T r); + BaseFab& invert (T r) noexcept; // AMREX_GPU_HOST_DEVICE - BaseFab& invert (T r, const Box& bx, DestComp dcomp, NumComps ncomp); + BaseFab& invert (T r, const Box& bx, DestComp dcomp, NumComps ncomp) noexcept; //! Sum AMREX_GPU_HOST_DEVICE - T sum (const Box& bx, DestComp dcomp, NumComps ncomp) const; + T sum (const Box& bx, DestComp dcomp, NumComps ncomp) const noexcept; //! Dot product of two Fabs AMREX_GPU_HOST_DEVICE - T dot (const BaseFab& src, const Box& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) const; + T dot (const BaseFab& src, const Box& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) const noexcept; //! Dot product of two Fabs with mask AMREX_GPU_HOST_DEVICE - T dotmask (const BaseFab& src, const Box& bx, const BaseFab& mask, - SrcComp scomp, DestComp dcomp, NumComps ncomp) const; + T dotmask (const BaseFab& src, const Box& bx, const BaseFab& mask, + SrcComp scomp, DestComp dcomp, NumComps ncomp) const noexcept; protected: - //! Allocates memory for the BaseFab. + //! Allocates memory for the BaseFab. void define (); #ifdef USE_PERILLA @@ -1464,7 +1487,7 @@ template //AMREX_GPU_HOST_DEVICE inline void -ForEachImpl (B& fab, const Box& b, int c, int nc, F f) +ForEachImpl (B& fab, const Box& b, int c, int nc, F f) noexcept { AMREX_ASSERT(fab.contains(b)); AMREX_ASSERT(c >= 0 && c + nc <= fab.nComp()); @@ -1490,7 +1513,7 @@ template inline //AMREX_GPU_HOST_DEVICE void -ForEachIVImpl (B& fab, const Box& b, int c, int nc, F f) +ForEachIVImpl (B& fab, const Box& b, int c, int nc, F f) noexcept { AMREX_ASSERT(fab.contains(b)); AMREX_ASSERT(c >= 0 && c + nc <= fab.nComp()); @@ -1514,11 +1537,11 @@ ForEachIVImpl (B& fab, const Box& b, int c, int nc, F f) } } -template +template template void -BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, - const BaseFab& src, const Box& srcbox, int srccomp, F f) +BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, + const BaseFab& src, const Box& srcbox, int srccomp, F f) noexcept { AMREX_ASSERT(contains(dstbox)); AMREX_ASSERT(src.contains(srcbox)); @@ -1548,11 +1571,11 @@ BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, } } -template +template template void -BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, - const BaseFab& src, int srccomp, F f) +BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, + const BaseFab& src, int srccomp, F f) noexcept { AMREX_ASSERT(contains(dstbox)); AMREX_ASSERT(src.contains(dstbox)); @@ -1577,10 +1600,10 @@ BaseFab::ForEach (const Box& dstbox, int dstcomp, int numcomp, } } -template +template template P -BaseFab::Accumulate (const Box& b, int c, int nc, P init, F f) const +BaseFab::Accumulate (const Box& b, int c, int nc, P init, F f) const noexcept { const auto len3 = b.length3d(); const int* blo = b.loVect(); @@ -1600,10 +1623,10 @@ BaseFab::Accumulate (const Box& b, int c, int nc, P init, F f) const return init; } -template +template template void -BaseFab::Transform (T* dst, const Box& b, int c, int nc, F f) const +BaseFab::Transform (T* dst, const Box& b, int c, int nc, F f) const noexcept { AMREX_ASSERT(contains(b)); AMREX_ASSERT(c >= 0 && c + nc <= nComp()); @@ -1625,10 +1648,10 @@ BaseFab::Transform (T* dst, const Box& b, int c, int nc, F f) const } } -template +template template void -BaseFab::Transform (const Box& b, int c, int nc, T const* src, F f) +BaseFab::Transform (const Box& b, int c, int nc, T const* src, F f) noexcept { AMREX_ASSERT(contains(b)); AMREX_ASSERT(c >= 0 && c + nc <= nComp()); @@ -1650,10 +1673,10 @@ BaseFab::Transform (const Box& b, int c, int nc, T const* src, F f) } } -template +template inline T* -BaseFab::dataPtr (const IntVect& p, int n) +BaseFab::dataPtr (const IntVect& p, int n) noexcept { AMREX_ASSERT(n >= 0); AMREX_ASSERT(n < this->nvar); @@ -1663,10 +1686,10 @@ BaseFab::dataPtr (const IntVect& p, int n) return this->dptr + (this->domain.index(p)+n*this->domain.numPts()); } -template +template inline const T* -BaseFab::dataPtr (const IntVect& p, int n) const +BaseFab::dataPtr (const IntVect& p, int n) const noexcept { AMREX_ASSERT(n >= 0); AMREX_ASSERT(n < this->nvar); @@ -1676,11 +1699,34 @@ BaseFab::dataPtr (const IntVect& p, int n) const return this->dptr + (this->domain.index(p)+n*this->domain.numPts()); } -template +template +void +BaseFab::prefetchToHost () const noexcept +{ +#ifdef AMREX_USE_CUDA + std::size_t s = sizeof(T)*this->nvar*this->domain.numPts(); + AMREX_GPU_SAFE_CALL(cudaMemPrefetchAsync(this->dptr, s, + cudaCpuDeviceId, + Cuda::Device::cudaStream())); +#endif +} + +template +void +BaseFab::prefetchToDevice () const noexcept +{ +#ifdef AMREX_USE_CUDA + std::size_t s = sizeof(T)*this->nvar*this->domain.numPts(); + AMREX_GPU_SAFE_CALL(cudaMemPrefetchAsync(this->dptr, s, + Cuda::Device::deviceId(), + Cuda::Device::cudaStream())); +#endif +} + +template inline T& -BaseFab::operator() (const IntVect& p, - int n) +BaseFab::operator() (const IntVect& p, int n) noexcept { AMREX_ASSERT(n >= 0); AMREX_ASSERT(n < this->nvar); @@ -1690,10 +1736,10 @@ BaseFab::operator() (const IntVect& p, return this->dptr[this->domain.index(p)+n*this->domain.numPts()]; } -template +template inline T& -BaseFab::operator() (const IntVect& p) +BaseFab::operator() (const IntVect& p) noexcept { AMREX_ASSERT(!(this->dptr == 0)); AMREX_ASSERT(this->domain.contains(p)); @@ -1701,11 +1747,10 @@ BaseFab::operator() (const IntVect& p) return this->dptr[this->domain.index(p)]; } -template +template inline const T& -BaseFab::operator() (const IntVect& p, - int n) const +BaseFab::operator() (const IntVect& p, int n) const noexcept { AMREX_ASSERT(n >= 0); AMREX_ASSERT(n < this->nvar); @@ -1715,10 +1760,10 @@ BaseFab::operator() (const IntVect& p, return this->dptr[this->domain.index(p)+n*this->domain.numPts()]; } -template +template inline const T& -BaseFab::operator() (const IntVect& p) const +BaseFab::operator() (const IntVect& p) const noexcept { AMREX_ASSERT(!(this->dptr == 0)); AMREX_ASSERT(this->domain.contains(p)); @@ -1726,12 +1771,12 @@ BaseFab::operator() (const IntVect& p) const return this->dptr[this->domain.index(p)]; } -template +template void -BaseFab::getVal (T* data, - const IntVect& pos, - int n, - int numcomp) const +BaseFab::getVal (T* data, + const IntVect& pos, + int n, + int numcomp) const noexcept { const int loc = this->domain.index(pos); const long sz = this->domain.numPts(); @@ -1743,84 +1788,82 @@ BaseFab::getVal (T* data, data[k] = this->dptr[loc+(n+k)*sz]; } -template +template void -BaseFab::getVal (T* data, - const IntVect& pos) const +BaseFab::getVal (T* data, + const IntVect& pos) const noexcept { getVal(data,pos,0,this->nvar); } -template -BaseFab& -BaseFab::shift (const IntVect& v) +template +BaseFab& +BaseFab::shift (const IntVect& v) noexcept { this->domain += v; return *this; } -template -BaseFab& -BaseFab::shift (int idir, - int n_cell) +template +BaseFab& +BaseFab::shift (int idir, int n_cell) noexcept { this->domain.shift(idir,n_cell); return *this; } -template -BaseFab & -BaseFab::shiftHalf (const IntVect& v) +template +BaseFab & +BaseFab::shiftHalf (const IntVect& v) noexcept { this->domain.shiftHalf(v); return *this; } -template -BaseFab & -BaseFab::shiftHalf (int idir, - int n_cell) +template +BaseFab & +BaseFab::shiftHalf (int idir, int n_cell) noexcept { this->domain.shiftHalf(idir,n_cell); return *this; } -template +template void -BaseFab::setVal (T x, const Box& bx, int n) +BaseFab::setVal (T x, const Box& bx, int n) noexcept { this->setVal(x, bx, DestComp{n}, NumComps{1}); } -template +template void -BaseFab::setVal (T x, int n) +BaseFab::setVal (T x, int n) noexcept { this->setVal(x, this->domain, DestComp{n}, NumComps{1}); } -template +template void -BaseFab::setVal (T x, const Box& bx, int dcomp, int ncomp) +BaseFab::setVal (T x, const Box& bx, int dcomp, int ncomp) noexcept { this->setVal(x, bx, DestComp{dcomp}, NumComps{ncomp}); } -template +template void -BaseFab::setValIfNot (T val, const Box& bx, const BaseFab& mask, int ns, int num) +BaseFab::setValIfNot (T val, const Box& bx, const BaseFab& mask, int ns, int num) noexcept { this->setValIfNot(val, bx, mask, DestComp{ns}, NumComps{num}); } -template -BaseFab& -BaseFab::copy (const BaseFab& src, - const Box& srcbox, - int srccomp, - const Box& destbox, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::copy (const BaseFab& src, + const Box& srcbox, + int srccomp, + const Box& destbox, + int destcomp, + int numcomp) noexcept { AMREX_ASSERT(destbox.ok()); AMREX_ASSERT(srcbox.sameSize(destbox)); @@ -1849,23 +1892,23 @@ BaseFab::copy (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::copy (const BaseFab& src, const Box& destbox) +template +BaseFab& +BaseFab::copy (const BaseFab& src, const Box& destbox) noexcept { return this->copy(src, destbox, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::copy (const BaseFab& src, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::copy (const BaseFab& src, int srccomp, int destcomp, int numcomp) noexcept { return copy(src, this->domain, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template +template void -BaseFab::define () +BaseFab::define () { AMREX_ASSERT(this->nvar > 0); AMREX_ASSERT(this->dptr == 0); @@ -1878,7 +1921,7 @@ BaseFab::define () this->truesize = this->nvar*this->domain.numPts(); this->ptr_owner = true; - this->dptr = static_cast(amrex::The_Arena()->alloc(this->truesize*sizeof(T))); + this->dptr = static_cast(Allocator{}.alloc(this->truesize*sizeof(T))); // // Now call T::T() on the raw memory so we have valid Ts. // @@ -1894,23 +1937,23 @@ BaseFab::define () amrex::update_fab_stats(this->domain.numPts(), this->truesize, sizeof(T)); } -template -BaseFab::BaseFab () +template +BaseFab::BaseFab () : BaseFabData{nullptr, Box(), 0, 0L, false, false} {} -template -BaseFab::BaseFab (const Box& bx, - int n, - bool alloc, - bool shared) +template +BaseFab::BaseFab (const Box& bx, + int n, + bool alloc, + bool shared) : BaseFabData{nullptr, bx, n, 0L, false, shared} { if (!this->shared_memory && alloc) define(); } -template -BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type, int scomp, int ncomp) +template +BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type, int scomp, int ncomp) : BaseFabData{const_cast(rhs.dataPtr(scomp)), rhs.domain, ncomp, ncomp*rhs.domain.numPts(), false, false} { @@ -1928,8 +1971,8 @@ BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type, int scomp, int n } #ifdef AMREX_USE_GPU -template -BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type) +template +BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type) { auto dst = static_cast*>(this); auto src = static_castconst*>(&rhs); @@ -1958,20 +2001,20 @@ BaseFab::BaseFab (const BaseFab& rhs, MakeType make_type) } #endif -template -BaseFab::BaseFab (const Box& bx, int ncomp, T* p) +template +BaseFab::BaseFab (const Box& bx, int ncomp, T* p) : BaseFabData{p, bx, ncomp, bx.numPts()*ncomp, false, false} { } -template -BaseFab::~BaseFab () +template +BaseFab::~BaseFab () { clear(); } -template -BaseFab::BaseFab (BaseFab&& rhs) noexcept +template +BaseFab::BaseFab (BaseFab&& rhs) noexcept : BaseFabData{rhs.dptr, rhs.domain, rhs.nvar,rhs.truesize, rhs.ptr_owner, rhs.shared_memory} { @@ -1979,18 +2022,17 @@ BaseFab::BaseFab (BaseFab&& rhs) noexcept rhs.ptr_owner = false; } -template -BaseFab& -BaseFab::operator= (T t) +template +BaseFab& +BaseFab::operator= (T t) noexcept { setVal(t); return *this; } -template +template void -BaseFab::resize (const Box& b, - int n) +BaseFab::resize (const Box& b, int n) { this->nvar = n; this->domain = b; @@ -2014,10 +2056,10 @@ BaseFab::resize (const Box& b, } } -template +template template Elixir -BaseFab::elixir () +BaseFab::elixir () noexcept { bool o; if (Gpu::inLaunchRegion()) { @@ -2033,12 +2075,12 @@ BaseFab::elixir () } else { o = false; } - return Elixir((o ? this->dptr : nullptr), amrex::The_Arena()); + return Elixir((o ? this->dptr : nullptr), Allocator{}.arena()); } -template +template void -BaseFab::clear () +BaseFab::clear () noexcept { if (this->dptr) { @@ -2059,7 +2101,7 @@ BaseFab::clear () ptr->~T(); } - amrex::The_Arena()->free(this->dptr); + Allocator{}.free(this->dptr); if (this->nvar > 1) { amrex::update_fab_stats(-this->truesize/this->nvar, -this->truesize, sizeof(T)); @@ -2073,12 +2115,12 @@ BaseFab::clear () } } -template +template std::size_t -BaseFab::copyToMem (const Box& srcbox, - int srccomp, - int numcomp, - void* dst) const +BaseFab::copyToMem (const Box& srcbox, + int srccomp, + int numcomp, + void* dst) const noexcept { BL_ASSERT(box().contains(srcbox)); BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= nComp()); @@ -2111,12 +2153,12 @@ BaseFab::copyToMem (const Box& srcbox, } } -template +template std::size_t -BaseFab::copyFromMem (const Box& dstbox, - int dstcomp, - int numcomp, - const void* src) +BaseFab::copyFromMem (const Box& dstbox, + int dstcomp, + int numcomp, + const void* src) noexcept { BL_ASSERT(box().contains(dstbox)); BL_ASSERT(dstcomp >= 0 && dstcomp+numcomp <= nComp()); @@ -2149,12 +2191,12 @@ BaseFab::copyFromMem (const Box& dstbox, } } -template +template std::size_t -BaseFab::addFromMem (const Box& dstbox, - int dstcomp, - int numcomp, - const void* src) +BaseFab::addFromMem (const Box& dstbox, + int dstcomp, + int numcomp, + const void* src) noexcept { BL_ASSERT(box().contains(dstbox)); BL_ASSERT(dstcomp >= 0 && dstcomp+numcomp <= nComp()); @@ -2187,33 +2229,32 @@ BaseFab::addFromMem (const Box& dstbox, } } -template +template void -BaseFab::setComplement (T x, const Box& b, int ns, int num) +BaseFab::setComplement (T x, const Box& b, int ns, int num) noexcept { setComplement(x, b, DestComp{ns}, NumComps{num}); } -template +template void -BaseFab::abs () +BaseFab::abs () noexcept { this->abs(this->domain,0,this->nvar); } -template +template void -BaseFab::abs (int comp, - int numcomp) +BaseFab::abs (int comp, int numcomp) noexcept { this->abs(this->domain,comp,numcomp); } -template +template void -BaseFab::abs (const Box& subbox, - int comp, - int numcomp) +BaseFab::abs (const Box& subbox, + int comp, + int numcomp) noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2231,10 +2272,10 @@ BaseFab::abs (const Box& subbox, } } -template +template Real -BaseFab::norminfmask (const Box& subbox, const BaseFab& mask, - int scomp, int ncomp) const +BaseFab::norminfmask (const Box& subbox, const BaseFab& mask, + int scomp, int ncomp) const noexcept { BL_ASSERT(this->domain.contains(subbox)); BL_ASSERT(scomp >= 0 && scomp + ncomp <= this->nvar); @@ -2262,21 +2303,21 @@ BaseFab::norminfmask (const Box& subbox, const BaseFab& mask, return r; } -template +template Real -BaseFab::norm (int p, - int comp, - int numcomp) const +BaseFab::norm (int p, + int comp, + int numcomp) const noexcept { return norm(this->domain,p,comp,numcomp); } -template +template Real -BaseFab::norm (const Box& subbox, - int p, - int comp, - int numcomp) const +BaseFab::norm (const Box& subbox, + int p, + int comp, + int numcomp) const noexcept { BL_ASSERT(this->domain.contains(subbox)); BL_ASSERT(comp >= 0 && comp + numcomp <= this->nvar); @@ -2327,22 +2368,22 @@ BaseFab::norm (const Box& subbox, } else { - amrex::Error("BaseFab::norm: wrong p"); + amrex::Error("BaseFab::norm: wrong p"); } return nrm; } -template +template T -BaseFab::min (int comp) const +BaseFab::min (int comp) const noexcept { return this->min(this->domain,comp); } -template +template T -BaseFab::min (const Box& subbox, int comp) const +BaseFab::min (const Box& subbox, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2365,16 +2406,16 @@ BaseFab::min (const Box& subbox, int comp) const return r; } -template +template T -BaseFab::max (int comp) const +BaseFab::max (int comp) const noexcept { return this->max(this->domain,comp); } -template +template T -BaseFab::max (const Box& subbox, int comp) const +BaseFab::max (const Box& subbox, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2398,16 +2439,16 @@ BaseFab::max (const Box& subbox, int comp) const return r; } -template +template T -BaseFab::maxabs (int comp) const +BaseFab::maxabs (int comp) const noexcept { return this->maxabs(this->domain,comp); } -template +template T -BaseFab::maxabs (const Box& subbox, int comp) const +BaseFab::maxabs (const Box& subbox, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2432,16 +2473,16 @@ BaseFab::maxabs (const Box& subbox, int comp) const } -template +template IntVect -BaseFab::minIndex (int comp) const +BaseFab::minIndex (int comp) const noexcept { return this->minIndex(this->domain,comp); } -template +template IntVect -BaseFab::minIndex (const Box& subbox, int comp) const +BaseFab::minIndex (const Box& subbox, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2469,9 +2510,9 @@ BaseFab::minIndex (const Box& subbox, int comp) const return IntVect(AMREX_D_DECL(imin+lo.x,jmin+lo.y,kmin+lo.z)); } -template +template IntVect -BaseFab::indexFromValue (Real value, const Box& subbox, int comp) const +BaseFab::indexFromValue (Real value, const Box& subbox, int comp) const noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) AMREX_D_DECL(int imin = std::numeric_limits::lowest(), @@ -2498,9 +2539,9 @@ BaseFab::indexFromValue (Real value, const Box& subbox, int comp) const return IntVect(AMREX_D_DECL(imin+lo.x,jmin+lo.y,kmin+lo.z)); } -template +template void -BaseFab::minIndex (const Box& subbox, Real& min_val, IntVect& min_idx, int comp) const +BaseFab::minIndex (const Box& subbox, Real& min_val, IntVect& min_idx, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2519,17 +2560,17 @@ BaseFab::minIndex (const Box& subbox, Real& min_val, IntVect& min_idx, int co AMREX_D_TERM(min_idx[0] += lo.x;, min_idx[1] += lo.y;, min_idx[2] += lo.z); } -template +template IntVect -BaseFab::maxIndex (int comp) const +BaseFab::maxIndex (int comp) const noexcept { return this->maxIndex(this->domain,comp); } -template +template IntVect -BaseFab::maxIndex (const Box& subbox, - int comp) const +BaseFab::maxIndex (const Box& subbox, + int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2557,9 +2598,9 @@ BaseFab::maxIndex (const Box& subbox, return IntVect(AMREX_D_DECL(imax+lo.x,jmax+lo.y,kmax+lo.z)); } -template +template void -BaseFab::maxIndex (const Box& subbox, Real& max_val, IntVect& max_idx, int comp) const +BaseFab::maxIndex (const Box& subbox, Real& max_val, IntVect& max_idx, int comp) const noexcept { const auto len = amrex::length(subbox); const auto lo = amrex::lbound(subbox); @@ -2578,11 +2619,11 @@ BaseFab::maxIndex (const Box& subbox, Real& max_val, IntVect& max_idx, int co AMREX_D_TERM(max_idx[0] += lo.x;, max_idx[1] += lo.y;, max_idx[2] += lo.z); } -template +template int -BaseFab::maskLT (BaseFab& mask, - T val, - int comp) const +BaseFab::maskLT (BaseFab& mask, + T val, + int comp) const noexcept { mask.resize(this->domain,1); mask.setVal(0); @@ -2608,11 +2649,11 @@ BaseFab::maskLT (BaseFab& mask, return cnt; } -template +template int -BaseFab::maskLE (BaseFab& mask, - T val, - int comp) const +BaseFab::maskLE (BaseFab& mask, + T val, + int comp) const noexcept { mask.resize(this->domain,1); mask.setVal(0); @@ -2638,11 +2679,11 @@ BaseFab::maskLE (BaseFab& mask, return cnt; } -template +template int -BaseFab::maskEQ (BaseFab& mask, - T val, - int comp) const +BaseFab::maskEQ (BaseFab& mask, + T val, + int comp) const noexcept { mask.resize(this->domain,1); mask.setVal(0); @@ -2668,11 +2709,11 @@ BaseFab::maskEQ (BaseFab& mask, return cnt; } -template +template int -BaseFab::maskGT (BaseFab& mask, - T val, - int comp) const +BaseFab::maskGT (BaseFab& mask, + T val, + int comp) const noexcept { mask.resize(this->domain,1); mask.setVal(0); @@ -2698,11 +2739,11 @@ BaseFab::maskGT (BaseFab& mask, return cnt; } -template +template int -BaseFab::maskGE (BaseFab& mask, - T val, - int comp) const +BaseFab::maskGE (BaseFab& mask, + T val, + int comp) const noexcept { mask.resize(this->domain,1); mask.setVal(0); @@ -2728,20 +2769,20 @@ BaseFab::maskGE (BaseFab& mask, return cnt; } -template -BaseFab& -BaseFab::atomicAdd (const BaseFab& x) +template +BaseFab& +BaseFab::atomicAdd (const BaseFab& x) noexcept { Box ovlp(this->domain); ovlp &= x.domain; return ovlp.ok() ? this->atomicAdd(x,ovlp,ovlp,0,0,this->nvar) : *this; } -template -BaseFab& -BaseFab::saxpy (T a, const BaseFab& x, - const Box& srcbox, const Box& destbox, - int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::saxpy (T a, const BaseFab& x, + const Box& srcbox, const Box& destbox, + int srccomp, int destcomp, int numcomp) noexcept { BL_ASSERT(srcbox.ok()); BL_ASSERT(x.box().contains(srcbox)); @@ -2771,20 +2812,20 @@ BaseFab::saxpy (T a, const BaseFab& x, return *this; } -template -BaseFab& -BaseFab::saxpy (T a, const BaseFab& x) +template +BaseFab& +BaseFab::saxpy (T a, const BaseFab& x) noexcept { Box ovlp(this->domain); ovlp &= x.domain; return ovlp.ok() ? saxpy(a,x,ovlp,ovlp,0,0,this->nvar) : *this; } -template -BaseFab& -BaseFab::xpay (T a, const BaseFab& x, - const Box& srcbox, const Box& destbox, - int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::xpay (T a, const BaseFab& x, + const Box& srcbox, const Box& destbox, + int srccomp, int destcomp, int numcomp) noexcept { BL_ASSERT(srcbox.ok()); BL_ASSERT(x.box().contains(srcbox)); @@ -2814,11 +2855,11 @@ BaseFab::xpay (T a, const BaseFab& x, return *this; } -template -BaseFab& -BaseFab::addproduct (const Box& destbox, int destcomp, int numcomp, - const BaseFab& src1, int comp1, - const BaseFab& src2, int comp2) +template +BaseFab& +BaseFab::addproduct (const Box& destbox, int destcomp, int numcomp, + const BaseFab& src1, int comp1, + const BaseFab& src2, int comp2) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(box().contains(destbox)); @@ -2846,12 +2887,12 @@ BaseFab::addproduct (const Box& destbox, int destcomp, int numcomp, return *this; } -template -BaseFab& -BaseFab::linComb (const BaseFab& f1, const Box& b1, int comp1, - const BaseFab& f2, const Box& b2, int comp2, - Real alpha, Real beta, const Box& b, - int comp, int numcomp) +template +BaseFab& +BaseFab::linComb (const BaseFab& f1, const Box& b1, int comp1, + const BaseFab& f2, const Box& b2, int comp2, + Real alpha, Real beta, const Box& b, + int comp, int numcomp) noexcept { BL_ASSERT(b1.ok()); BL_ASSERT(f1.box().contains(b1)); @@ -2887,11 +2928,11 @@ BaseFab::linComb (const BaseFab& f1, const Box& b1, int comp1, return *this; } -template +template T -BaseFab::dot (const Box& xbx, int xcomp, - const BaseFab& y, const Box& ybx, int ycomp, - int numcomp) const +BaseFab::dot (const Box& xbx, int xcomp, + const BaseFab& y, const Box& ybx, int ycomp, + int numcomp) const noexcept { BL_ASSERT(xbx.ok()); BL_ASSERT(box().contains(xbx)); @@ -2924,11 +2965,11 @@ BaseFab::dot (const Box& xbx, int xcomp, return r; } -template +template T -BaseFab::dotmask (const BaseFab& mask, const Box& xbx, int xcomp, - const BaseFab& y, const Box& ybx, int ycomp, - int numcomp) const +BaseFab::dotmask (const BaseFab& mask, const Box& xbx, int xcomp, + const BaseFab& y, const Box& ybx, int ycomp, + int numcomp) const noexcept { BL_ASSERT(xbx.ok()); BL_ASSERT(box().contains(xbx)); @@ -2960,99 +3001,99 @@ BaseFab::dotmask (const BaseFab& mask, const Box& xbx, int xcomp, return r; } -template +template T -BaseFab::sum (int comp, int numcomp) const +BaseFab::sum (int comp, int numcomp) const noexcept { return this->sum(this->domain, DestComp{comp}, NumComps{numcomp}); } -template +template T -BaseFab::sum (const Box& subbox, int comp, int numcomp) const +BaseFab::sum (const Box& subbox, int comp, int numcomp) const noexcept { return this->sum(subbox, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::negate (int comp, int numcomp) +template +BaseFab& +BaseFab::negate (int comp, int numcomp) noexcept { return this->negate(this->domain, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::negate (const Box& b, int comp, int numcomp) +template +BaseFab& +BaseFab::negate (const Box& b, int comp, int numcomp) noexcept { return this->negate(b, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::invert (T r, int comp, int numcomp) +template +BaseFab& +BaseFab::invert (T r, int comp, int numcomp) noexcept { return this->invert(r, this->domain, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::invert (T r, const Box& b, int comp, int numcomp) +template +BaseFab& +BaseFab::invert (T r, const Box& b, int comp, int numcomp) noexcept { return this->invert(r, b, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::plus (T r, int comp, int numcomp) +template +BaseFab& +BaseFab::plus (T r, int comp, int numcomp) noexcept { return this->plus(r, this->domain, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::plus (T r, const Box& b, int comp, int numcomp) +template +BaseFab& +BaseFab::plus (T r, const Box& b, int comp, int numcomp) noexcept { return this->plus(r, b, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::plus (const BaseFab& src, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::plus (const BaseFab& src, int srccomp, int destcomp, int numcomp) noexcept { return this->plus(src, this->domain, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::atomicAdd (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::atomicAdd (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp) noexcept { Box ovlp(this->domain); ovlp &= src.domain; return ovlp.ok() ? this->atomicAdd(src,ovlp,ovlp,srccomp,destcomp,numcomp) : *this; } -template -BaseFab& -BaseFab::plus (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::plus (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp) noexcept { return this->plus(src, subbox, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::atomicAdd (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::atomicAdd (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp) noexcept { Box ovlp(this->domain); ovlp &= src.domain; @@ -3060,14 +3101,14 @@ BaseFab::atomicAdd (const BaseFab& src, return ovlp.ok() ? this->atomicAdd(src,ovlp,ovlp,srccomp,destcomp,numcomp) : *this; } -template -BaseFab& -BaseFab::plus (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::plus (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3096,14 +3137,14 @@ BaseFab::plus (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::atomicAdd (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::atomicAdd (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3146,28 +3187,28 @@ BaseFab::atomicAdd (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::minus (const BaseFab& src, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::minus (const BaseFab& src, int srccomp, int destcomp, int numcomp) noexcept { return this->minus(src, this->domain, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::minus (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::minus (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) noexcept { return this->minus(src, subbox, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::minus (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::minus (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3196,42 +3237,42 @@ BaseFab::minus (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::mult (T r, int comp, int numcomp) +template +BaseFab& +BaseFab::mult (T r, int comp, int numcomp) noexcept { return this->mult(r, this->domain, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::mult (T r, const Box& b, int comp, int numcomp) +template +BaseFab& +BaseFab::mult (T r, const Box& b, int comp, int numcomp) noexcept { return this->mult(r, b, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::mult (const BaseFab& src, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::mult (const BaseFab& src, int srccomp, int destcomp, int numcomp) noexcept { return this->mult(src, this->domain, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::mult (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::mult (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) noexcept { return this->mult(src, subbox, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::mult (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::mult (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3260,42 +3301,42 @@ BaseFab::mult (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::divide (T r, int comp, int numcomp) +template +BaseFab& +BaseFab::divide (T r, int comp, int numcomp) noexcept { return this->divide(r, this->domain, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::divide (T r, const Box& b, int comp, int numcomp) +template +BaseFab& +BaseFab::divide (T r, const Box& b, int comp, int numcomp) noexcept { return this->divide(r, b, DestComp{comp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::divide (const BaseFab& src, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::divide (const BaseFab& src, int srccomp, int destcomp, int numcomp) noexcept { return this->divide(src, this->domain, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::divide (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) +template +BaseFab& +BaseFab::divide (const BaseFab& src, const Box& subbox, int srccomp, int destcomp, int numcomp) noexcept { return this->divide(src, subbox, SrcComp{srccomp}, DestComp{destcomp}, NumComps{numcomp}); } -template -BaseFab& -BaseFab::divide (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::divide (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3324,34 +3365,34 @@ BaseFab::divide (const BaseFab& src, return *this; } -template -BaseFab& -BaseFab::protected_divide (const BaseFab& src) +template +BaseFab& +BaseFab::protected_divide (const BaseFab& src) noexcept { Box ovlp(this->domain); ovlp &= src.domain; return ovlp.ok() ? this->protected_divide(src,ovlp,ovlp,0,0,this->nvar) : *this; } -template -BaseFab& -BaseFab::protected_divide (const BaseFab& src, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::protected_divide (const BaseFab& src, + int srccomp, + int destcomp, + int numcomp) noexcept { Box ovlp(this->domain); ovlp &= src.domain; return ovlp.ok() ? this->protected_divide(src,ovlp,ovlp,srccomp,destcomp,numcomp) : *this; } -template -BaseFab& -BaseFab::protected_divide (const BaseFab& src, - const Box& subbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::protected_divide (const BaseFab& src, + const Box& subbox, + int srccomp, + int destcomp, + int numcomp) noexcept { Box ovlp(this->domain); ovlp &= src.domain; @@ -3359,14 +3400,14 @@ BaseFab::protected_divide (const BaseFab& src, return ovlp.ok() ? this->protected_divide(src,ovlp,ovlp,srccomp,destcomp,numcomp) : *this; } -template -BaseFab& -BaseFab::protected_divide (const BaseFab& src, - const Box& srcbox, - const Box& destbox, - int srccomp, - int destcomp, - int numcomp) +template +BaseFab& +BaseFab::protected_divide (const BaseFab& src, + const Box& srcbox, + const Box& destbox, + int srccomp, + int destcomp, + int numcomp) noexcept { BL_ASSERT(destbox.ok()); BL_ASSERT(src.box().contains(srcbox)); @@ -3408,38 +3449,38 @@ BaseFab::protected_divide (const BaseFab& src, * This fab is returned as a reference for chaining. */ -template -BaseFab& -BaseFab::linInterp (const BaseFab& f1, - const Box& b1, - int comp1, - const BaseFab& f2, - const Box& b2, - int comp2, - Real t1, - Real t2, - Real t, - const Box& b, - int comp, - int numcomp) +template +BaseFab& +BaseFab::linInterp (const BaseFab& f1, + const Box& b1, + int comp1, + const BaseFab& f2, + const Box& b2, + int comp2, + Real t1, + Real t2, + Real t, + const Box& b, + int comp, + int numcomp) noexcept { Real alpha = (t2-t)/(t2-t1); Real beta = (t-t1)/(t2-t1); return linComb(f1,b1,comp1,f2,b2,comp2,alpha,beta,b,comp,numcomp); } -template -BaseFab& -BaseFab::linInterp (const BaseFab& f1, - int comp1, - const BaseFab& f2, - int comp2, - Real t1, - Real t2, - Real t, - const Box& b, - int comp, - int numcomp) +template +BaseFab& +BaseFab::linInterp (const BaseFab& f1, + int comp1, + const BaseFab& f2, + int comp2, + Real t1, + Real t2, + Real t, + const Box& b, + int comp, + int numcomp) noexcept { Real tol = 1.0e-16; if(std::abs(t2-t1) > tol) @@ -3460,16 +3501,16 @@ BaseFab::linInterp (const BaseFab& f1, // New interfaces // -template +template void -BaseFab::setVal (T val) +BaseFab::setVal (T val) noexcept { this->setVal(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template +template void -BaseFab::setVal (T x, Box bx, DestComp dcomp, NumComps ncomp) +BaseFab::setVal (T x, Box bx, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3489,16 +3530,16 @@ BaseFab::setVal (T x, Box bx, DestComp dcomp, NumComps ncomp) } } -template +template void -BaseFab::setValIf (T val, const BaseFab& mask) +BaseFab::setValIf (T val, const BaseFab& mask) noexcept { this->setValIf(val, this->domain, mask, DestComp{0}, NumComps{this->nvar}); } -template +template void -BaseFab::setValIf (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) +BaseFab::setValIf (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3519,16 +3560,16 @@ BaseFab::setValIf (T val, Box bx, const BaseFab& mask, DestComp dcomp, N } } -template +template void -BaseFab::setValIfNot (T val, const BaseFab& mask) +BaseFab::setValIfNot (T val, const BaseFab& mask) noexcept { this->setValIfNot(val, this->domain, mask, DestComp{0}, NumComps{this->nvar}); } -template +template void -BaseFab::setValIfNot (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) +BaseFab::setValIfNot (T val, Box bx, const BaseFab& mask, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3549,9 +3590,9 @@ BaseFab::setValIfNot (T val, Box bx, const BaseFab& mask, DestComp dcomp } } -template +template void -BaseFab::setComplement (T x, const Box& bx, DestComp dcomp, NumComps ncomp) +BaseFab::setComplement (T x, const Box& bx, DestComp dcomp, NumComps ncomp) noexcept { const BoxList b_lst = amrex::boxDiff(this->domain,bx); for (auto const& b : b_lst) { @@ -3559,18 +3600,18 @@ BaseFab::setComplement (T x, const Box& bx, DestComp dcomp, NumComps ncomp) } } -template -BaseFab& -BaseFab::copy (const BaseFab& src) +template +BaseFab& +BaseFab::copy (const BaseFab& src) noexcept { this->copy(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); return *this; } -template -BaseFab& -BaseFab::copy (const BaseFab& src, Box bx, - SrcComp scomp, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::copy (const BaseFab& src, Box bx, + SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -3597,23 +3638,23 @@ BaseFab::copy (const BaseFab& src, Box bx, return *this; } -template -BaseFab& -BaseFab::plus (T val) +template +BaseFab& +BaseFab::plus (T val) noexcept { return this->plus(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator+= (T val) +template +BaseFab& +BaseFab::operator+= (T val) noexcept { return this->plus(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::plus (T val, Box bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::plus (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3635,24 +3676,24 @@ BaseFab::plus (T val, Box bx, DestComp dcomp, NumComps ncomp) return *this; } -template -BaseFab& -BaseFab::plus (const BaseFab& src) +template +BaseFab& +BaseFab::plus (const BaseFab& src) noexcept { return this->plus(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator+= (const BaseFab& src) +template +BaseFab& +BaseFab::operator+= (const BaseFab& src) noexcept { return this->plus(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::plus (const BaseFab& src, Box bx, - SrcComp scomp, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::plus (const BaseFab& src, Box bx, + SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -3679,23 +3720,23 @@ BaseFab::plus (const BaseFab& src, Box bx, return *this; } -template -BaseFab& -BaseFab::minus (T val) +template +BaseFab& +BaseFab::minus (T val) noexcept { return this->minus(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator-= (T val) +template +BaseFab& +BaseFab::operator-= (T val) noexcept { return this->minus(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::minus (T val, Box bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::minus (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3717,24 +3758,24 @@ BaseFab::minus (T val, Box bx, DestComp dcomp, NumComps ncomp) return *this; } -template -BaseFab& -BaseFab::minus (const BaseFab& src) +template +BaseFab& +BaseFab::minus (const BaseFab& src) noexcept { return this->minus(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator-= (const BaseFab& src) +template +BaseFab& +BaseFab::operator-= (const BaseFab& src) noexcept { return this->minus(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::minus (const BaseFab& src, Box bx, - SrcComp scomp, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::minus (const BaseFab& src, Box bx, + SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -3761,23 +3802,23 @@ BaseFab::minus (const BaseFab& src, Box bx, return *this; } -template -BaseFab& -BaseFab::mult (T val) +template +BaseFab& +BaseFab::mult (T val) noexcept { return this->mult(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator*= (T val) +template +BaseFab& +BaseFab::operator*= (T val) noexcept { return this->mult(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::mult (T val, Box bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::mult (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3799,24 +3840,24 @@ BaseFab::mult (T val, Box bx, DestComp dcomp, NumComps ncomp) return *this; } -template -BaseFab& -BaseFab::mult (const BaseFab& src) +template +BaseFab& +BaseFab::mult (const BaseFab& src) noexcept { return this->mult(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator*= (const BaseFab& src) +template +BaseFab& +BaseFab::operator*= (const BaseFab& src) noexcept { return this->mult(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::mult (const BaseFab& src, Box bx, - SrcComp scomp, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::mult (const BaseFab& src, Box bx, + SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -3843,23 +3884,23 @@ BaseFab::mult (const BaseFab& src, Box bx, return *this; } -template -BaseFab& -BaseFab::divide (T val) +template +BaseFab& +BaseFab::divide (T val) noexcept { return this->divide(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator/= (T val) +template +BaseFab& +BaseFab::operator/= (T val) noexcept { return this->divide(val, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::divide (T val, Box bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::divide (T val, Box bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3881,24 +3922,24 @@ BaseFab::divide (T val, Box bx, DestComp dcomp, NumComps ncomp) return *this; } -template -BaseFab& -BaseFab::divide (const BaseFab& src) +template +BaseFab& +BaseFab::divide (const BaseFab& src) noexcept { return this->divide(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::operator/= (const BaseFab& src) +template +BaseFab& +BaseFab::operator/= (const BaseFab& src) noexcept { return this->divide(src, this->domain, SrcComp{0}, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::divide (const BaseFab& src, Box bx, - SrcComp scomp, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::divide (const BaseFab& src, Box bx, + SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -3925,16 +3966,16 @@ BaseFab::divide (const BaseFab& src, Box bx, return *this; } -template -BaseFab& -BaseFab::negate () +template +BaseFab& +BaseFab::negate () noexcept { return this->negate(this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::negate (const Box& bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::negate (const Box& bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3956,16 +3997,16 @@ BaseFab::negate (const Box& bx, DestComp dcomp, NumComps ncomp) return *this; } -template -BaseFab& -BaseFab::invert (T r) +template +BaseFab& +BaseFab::invert (T r) noexcept { return this->invert(r, this->domain, DestComp{0}, NumComps{this->nvar}); } -template -BaseFab& -BaseFab::invert (T r, const Box& bx, DestComp dcomp, NumComps ncomp) +template +BaseFab& +BaseFab::invert (T r, const Box& bx, DestComp dcomp, NumComps ncomp) noexcept { BL_ASSERT(dcomp.i >= 0 && dcomp.i + ncomp.n <= this->nvar); @@ -3987,9 +4028,9 @@ BaseFab::invert (T r, const Box& bx, DestComp dcomp, NumComps ncomp) return *this; } -template +template T -BaseFab::sum (const Box& bx, DestComp dcomp, NumComps ncomp) const +BaseFab::sum (const Box& bx, DestComp dcomp, NumComps ncomp) const noexcept { AMREX_ASSERT(dcomp.i >= 0 && dcomp.i+ncomp.n <= this->nvar); @@ -4013,9 +4054,9 @@ BaseFab::sum (const Box& bx, DestComp dcomp, NumComps ncomp) const return r; } -template +template T -BaseFab::dot (const BaseFab& src, const Box& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) const +BaseFab::dot (const BaseFab& src, const Box& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) const noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(scomp.i >= 0 && scomp.i+ncomp.n <= src.nvar); @@ -4043,10 +4084,10 @@ BaseFab::dot (const BaseFab& src, const Box& bx, SrcComp scomp, DestComp d return r; } -template +template T -BaseFab::dotmask (const BaseFab& src, const Box& bx, const BaseFab& mask, - SrcComp scomp, DestComp dcomp, NumComps ncomp) const +BaseFab::dotmask (const BaseFab& src, const Box& bx, const BaseFab& mask, + SrcComp scomp, DestComp dcomp, NumComps ncomp) const noexcept { AMREX_ASSERT(this->domain.sameType(src.domain)); AMREX_ASSERT(this->domain.sameType(mask.domain)); diff --git a/Src/Base/AMReX_BaseFab.cpp b/Src/Base/AMReX_BaseFab.cpp index ed93d62f1b3..9f3561897bd 100644 --- a/Src/Base/AMReX_BaseFab.cpp +++ b/Src/Base/AMReX_BaseFab.cpp @@ -64,7 +64,7 @@ BaseFab_Finalize() long -TotalBytesAllocatedInFabs() +TotalBytesAllocatedInFabs () noexcept { #ifdef _OPENMP long r=0; @@ -79,7 +79,7 @@ TotalBytesAllocatedInFabs() } long -TotalBytesAllocatedInFabsHWM() +TotalBytesAllocatedInFabsHWM () noexcept { #ifdef _OPENMP long r=0; @@ -94,7 +94,7 @@ TotalBytesAllocatedInFabsHWM() } long -TotalCellsAllocatedInFabs() +TotalCellsAllocatedInFabs () noexcept { #ifdef _OPENMP long r=0; @@ -109,7 +109,7 @@ TotalCellsAllocatedInFabs() } long -TotalCellsAllocatedInFabsHWM() +TotalCellsAllocatedInFabsHWM () noexcept { #ifdef _OPENMP long r=0; @@ -124,7 +124,7 @@ TotalCellsAllocatedInFabsHWM() } void -ResetTotalBytesAllocatedInFabsHWM() +ResetTotalBytesAllocatedInFabsHWM () noexcept { #ifdef _OPENMP #pragma omp parallel @@ -135,7 +135,7 @@ ResetTotalBytesAllocatedInFabsHWM() } void -update_fab_stats (long n, long s, size_t szt) +update_fab_stats (long n, long s, size_t szt) noexcept { long tst = s*szt; amrex::private_total_bytes_allocated_in_fabs += tst; diff --git a/Src/Base/AMReX_BaseFabUtility.H b/Src/Base/AMReX_BaseFabUtility.H index 5e3eb944c53..a908938dd4e 100644 --- a/Src/Base/AMReX_BaseFabUtility.H +++ b/Src/Base/AMReX_BaseFabUtility.H @@ -9,7 +9,7 @@ template AMREX_GPU_HOST_DEVICE void cast (BaseFab& tofab, BaseFab const& fromfab, - Box const& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) + Box const& bx, SrcComp scomp, DestComp dcomp, NumComps ncomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); diff --git a/Src/Base/AMReX_Box.H b/Src/Base/AMReX_Box.H index fdd1dc92d2f..39e9fa52d75 100644 --- a/Src/Base/AMReX_Box.H +++ b/Src/Base/AMReX_Box.H @@ -42,7 +42,7 @@ public: * DO NOT CHANGE THIS BEHAVIOR! */ AMREX_GPU_HOST_DEVICE - constexpr Box () + constexpr Box () noexcept : smallend(1), bigend(0), btype() @@ -50,14 +50,14 @@ public: //! Construct cell-centered type Box. AMREX_GPU_HOST_DEVICE - constexpr Box (const IntVect& small, const IntVect& big) + constexpr Box (const IntVect& small, const IntVect& big) noexcept : smallend(small), bigend(big) {} //! Construct box with specified lengths. AMREX_GPU_HOST_DEVICE - Box (const IntVect& small, const int* vec_len) + Box (const IntVect& small, const int* vec_len) noexcept : smallend(small), bigend(AMREX_D_DECL(small[0]+vec_len[0]-1, small[1]+vec_len[1]-1, @@ -69,7 +69,7 @@ public: * to be consistent with given type. */ AMREX_GPU_HOST_DEVICE - Box (const IntVect& small, const IntVect& big, const IntVect& typ) + Box (const IntVect& small, const IntVect& big, const IntVect& typ) noexcept : smallend(small), bigend(big), btype(typ) @@ -79,7 +79,7 @@ public: //! Construct dimension specific Boxes. AMREX_GPU_HOST_DEVICE - Box (const IntVect& small, const IntVect& big, IndexType t) + Box (const IntVect& small, const IntVect& big, IndexType t) noexcept : smallend(small), bigend(big), btype(t) @@ -89,37 +89,37 @@ public: //! Get the smallend of the box. AMREX_GPU_HOST_DEVICE - const IntVect& smallEnd () const& { return smallend; } + const IntVect& smallEnd () const& noexcept { return smallend; } const IntVect& smallEnd () && = delete; //! Returns the coordinate of the low end in the given direction. AMREX_GPU_HOST_DEVICE - int smallEnd (int dir) const& { return smallend[dir]; } + int smallEnd (int dir) const& noexcept { return smallend[dir]; } //! Get the bigend. AMREX_GPU_HOST_DEVICE - const IntVect& bigEnd () const& { return bigend; } + const IntVect& bigEnd () const& noexcept { return bigend; } const IntVect& bigEnd () && = delete; //! Returns the coordinate of the high end in the given direction. AMREX_GPU_HOST_DEVICE - int bigEnd (int dir) const { return bigend[dir]; } + int bigEnd (int dir) const noexcept { return bigend[dir]; } //! Returns the indexing type. AMREX_GPU_HOST_DEVICE - IndexType ixType () const { return btype; } + IndexType ixType () const noexcept { return btype; } //! Returns the indexing type. AMREX_GPU_HOST_DEVICE - IntVect type () const { return btype.ixType(); } + IntVect type () const noexcept { return btype.ixType(); } //! Returns the indexing type in the specified direction. AMREX_GPU_HOST_DEVICE - IndexType::CellIndex type (int dir) const { return btype.ixType(dir); } + IndexType::CellIndex type (int dir) const noexcept { return btype.ixType(dir); } //! Return the length of the Box. AMREX_GPU_HOST_DEVICE - IntVect size () const + IntVect size () const noexcept { return IntVect(AMREX_D_DECL(bigend[0]-smallend[0] + 1, bigend[1]-smallend[1] + 1, @@ -128,7 +128,7 @@ public: //! Return the length of the Box. AMREX_GPU_HOST_DEVICE - IntVect length () const + IntVect length () const noexcept { return IntVect(AMREX_D_DECL(bigend[0]-smallend[0] + 1, bigend[1]-smallend[1] + 1, @@ -137,10 +137,10 @@ public: //! Return the length of the Box in given direction. AMREX_GPU_HOST_DEVICE - int length (int dir) const { return bigend[dir] - smallend[dir] + 1; } + int length (int dir) const noexcept { return bigend[dir] - smallend[dir] + 1; } AMREX_GPU_HOST_DEVICE - GpuArray length3d () const { + GpuArray length3d () const noexcept { #if (AMREX_SPACEDIM == 1) return {bigend[0]-smallend[0]+1, 1, 1}; #elif (AMREX_SPACEDIM == 2) @@ -151,7 +151,7 @@ public: } AMREX_GPU_HOST_DEVICE - GpuArray loVect3d () const { + GpuArray loVect3d () const noexcept { #if (AMREX_SPACEDIM == 1) return {smallend[0], 0, 0}; #elif (AMREX_SPACEDIM == 2) @@ -162,7 +162,7 @@ public: } AMREX_GPU_HOST_DEVICE - GpuArray hiVect3d () const { + GpuArray hiVect3d () const noexcept { #if (AMREX_SPACEDIM == 1) return {bigend[0], 0, 0}; #elif (AMREX_SPACEDIM == 2) @@ -174,39 +174,39 @@ public: //! Returns a constant pointer the array of low end coordinates. Useful for calls to FORTRAN. AMREX_GPU_HOST_DEVICE - const int* loVect () const& { return smallend.getVect(); } + const int* loVect () const& noexcept { return smallend.getVect(); } AMREX_GPU_HOST_DEVICE const int* loVect () && = delete; //! Returns a constant pointer the array of high end coordinates. Useful for calls to FORTRAN. AMREX_GPU_HOST_DEVICE - const int* hiVect () const& { return bigend.getVect(); } + const int* hiVect () const& noexcept { return bigend.getVect(); } AMREX_GPU_HOST_DEVICE const int* hiVect () && = delete; //! Returns the coordinate normal to given face. AMREX_GPU_HOST_DEVICE - int operator[] (Orientation face) const { + int operator[] (Orientation face) const noexcept { const int dir = face.coordDir(); return face.isLow() ? smallend[dir] : bigend[dir]; } //! Checks if it is an empty box. AMREX_GPU_HOST_DEVICE - bool isEmpty () const { return !ok(); } + bool isEmpty () const noexcept { return !ok(); } //! Checks if it is a proper Box (including a valid type). AMREX_GPU_HOST_DEVICE - bool ok () const { return bigend.allGE(smallend) && btype.ok(); } + bool ok () const noexcept { return bigend.allGE(smallend) && btype.ok(); } //! Returns true if argument is contained within Box. AMREX_GPU_HOST_DEVICE - bool contains (const IntVect& p) const { return p.allGE(smallend) && p.allLE(bigend); } + bool contains (const IntVect& p) const noexcept { return p.allGE(smallend) && p.allLE(bigend); } /** \brief Returns true if argument is contained within Box. * It is an error if the Boxes have different types. */ AMREX_GPU_HOST_DEVICE - bool contains (const Box& b) const + bool contains (const Box& b) const noexcept { BL_ASSERT(sameType(b)); return b.smallend.allGE(smallend) && b.bigend.allLE(bigend); @@ -214,14 +214,14 @@ public: //! Returns true if argument is strictly contained within Box. AMREX_GPU_HOST_DEVICE - bool strictly_contains (const IntVect& p) const { return p.allGT(smallend) && p.allLT(bigend); } + bool strictly_contains (const IntVect& p) const noexcept { return p.allGT(smallend) && p.allLT(bigend); } /** * \brief Returns true if argument is strictly contained within Box. * It is an error if the Boxes have different types. */ AMREX_GPU_HOST_DEVICE - bool strictly_contains (const Box& b) const + bool strictly_contains (const Box& b) const noexcept { BL_ASSERT(sameType(b)); return b.smallend.allGT(smallend) && b.bigend.allLT(bigend); @@ -231,14 +231,14 @@ public: * It is an error if the Boxes have different types. */ AMREX_GPU_HOST_DEVICE - bool intersects (const Box& b) const { Box isect(*this); isect &= b; return isect.ok(); } + bool intersects (const Box& b) const noexcept { Box isect(*this); isect &= b; return isect.ok(); } /** * \brief Returns true is Boxes same size, ie translates of each other,. * It is an error if they have different types. */ AMREX_GPU_HOST_DEVICE - bool sameSize (const Box& b) const { + bool sameSize (const Box& b) const noexcept { BL_ASSERT(sameType(b)); return AMREX_D_TERM(length(0) == b.length(0), && length(1) == b.length(1), @@ -247,18 +247,18 @@ public: //! Returns true if Boxes have same type. AMREX_GPU_HOST_DEVICE - bool sameType (const Box &b) const { return btype == b.btype; } + bool sameType (const Box &b) const noexcept { return btype == b.btype; } //! Returns true if Boxes are identical (including type). AMREX_GPU_HOST_DEVICE - bool operator== (const Box& b) const { return smallend == b.smallend && bigend == b.bigend && b.btype == btype; } + bool operator== (const Box& b) const noexcept { return smallend == b.smallend && bigend == b.bigend && b.btype == btype; } //! Returns true if Boxes differ (including type). AMREX_GPU_HOST_DEVICE - bool operator!= (const Box& b) const { return !operator==(b); } + bool operator!= (const Box& b) const noexcept { return !operator==(b); } AMREX_GPU_HOST_DEVICE - bool operator< (const Box& rhs) const + bool operator< (const Box& rhs) const noexcept { return btype < rhs.btype || ((btype == rhs.btype) && @@ -266,28 +266,28 @@ public: ((smallend == rhs.smallend) && (bigend < rhs.bigend)) )); } AMREX_GPU_HOST_DEVICE - bool operator <= (const Box& rhs) const { + bool operator <= (const Box& rhs) const noexcept { return !(rhs < *this); } AMREX_GPU_HOST_DEVICE - bool operator> (const Box& rhs) const { + bool operator> (const Box& rhs) const noexcept { return rhs < *this; } AMREX_GPU_HOST_DEVICE - bool operator>= (const Box& rhs) const { + bool operator>= (const Box& rhs) const noexcept { return !(*this < rhs); } //! Returns true if Box is cell-centered in all indexing directions. AMREX_GPU_HOST_DEVICE - bool cellCentered () const { return !btype.any(); } + bool cellCentered () const noexcept { return !btype.any(); } /** * \brief Returns the number of points contained in the Box, else * abort()s if the number cannot be represented in a long. */ AMREX_GPU_HOST_DEVICE - long numPts () const { + long numPts () const noexcept { auto r = AMREX_D_TERM( static_cast(length(0)), *static_cast(length(1)), *static_cast(length(2))); @@ -299,7 +299,7 @@ public: * This is intended for use only in diagnostic messages. */ AMREX_GPU_HOST_DEVICE - double d_numPts () const { + double d_numPts () const noexcept { BL_ASSERT(ok()); return AMREX_D_TERM(double(length(0)), *double(length(1)), *double(length(2))); } @@ -311,7 +311,7 @@ public: * cannot be represented in a long. */ AMREX_GPU_HOST_DEVICE - long volume () const { + long volume () const noexcept { return AMREX_D_TERM( static_cast(length(0)-btype[0]), *static_cast(length(1)-btype[1]), *static_cast(length(2)-btype[2])); @@ -322,7 +322,7 @@ public: * direction with longest side: 0...SPACEDIM-1. Ignores type. */ AMREX_GPU_HOST_DEVICE - int longside (int& dir) const { + int longside (int& dir) const noexcept { int maxlen = length(0); dir = 0; for (int i = 1; i < AMREX_SPACEDIM; i++) @@ -338,7 +338,7 @@ public: //! Returns length of longest side. Ignores type. AMREX_GPU_HOST_DEVICE - int longside () const { + int longside () const noexcept { int ignore = 0; return longside(ignore); } @@ -348,7 +348,7 @@ public: * direction with shortest side: 0...SPACEDIM-1. Ignores type. */ AMREX_GPU_HOST_DEVICE - int shortside (int& dir) const { + int shortside (int& dir) const noexcept { int minlen = length(0); dir = 0; for (int i = 1; i < AMREX_SPACEDIM; i++) @@ -364,7 +364,7 @@ public: //! Returns length of shortest side. Ignores type. AMREX_GPU_HOST_DEVICE - int shortside () const { + int shortside () const noexcept { int ignore = 0; return shortside(ignore); } @@ -375,30 +375,30 @@ public: * Is used in accessing FArrayBox. */ AMREX_GPU_HOST_DEVICE - long index (const IntVect& v) const; + long index (const IntVect& v) const noexcept; //! Given the offset, compute IntVect AMREX_GPU_HOST_DEVICE - IntVect atOffset (long offset) const; + IntVect atOffset (long offset) const noexcept; AMREX_GPU_HOST_DEVICE - GpuArray atOffset3d (long offset) const; + GpuArray atOffset3d (long offset) const noexcept; //! Redefine the small end of the Box. AMREX_GPU_HOST_DEVICE - Box& setSmall (const IntVect& sm) { smallend = sm; return *this; } + Box& setSmall (const IntVect& sm) noexcept { smallend = sm; return *this; } //! Redefine the small end of the Box. AMREX_GPU_HOST_DEVICE - Box& setSmall (int dir, int sm_index) { smallend.setVal(dir,sm_index); return *this; } + Box& setSmall (int dir, int sm_index) noexcept { smallend.setVal(dir,sm_index); return *this; } //! Redefine the big end of the Box. AMREX_GPU_HOST_DEVICE - Box& setBig (const IntVect& bg) { bigend = bg; return *this; } + Box& setBig (const IntVect& bg) noexcept { bigend = bg; return *this; } //! Redefine the big end of the Box. AMREX_GPU_HOST_DEVICE - Box& setBig (int dir, int bg_index) { bigend.setVal(dir,bg_index); return *this; } + Box& setBig (int dir, int bg_index) noexcept { bigend.setVal(dir,bg_index); return *this; } /** * \brief Set the entire range in a given direction, starting at @@ -408,19 +408,19 @@ public: AMREX_GPU_HOST_DEVICE Box& setRange (int dir, int sm_index, - int n_cells = 1); + int n_cells = 1) noexcept; //! Set indexing type AMREX_GPU_HOST_DEVICE - Box& setType (const IndexType& t) { btype = t; return *this; } + Box& setType (const IndexType& t) noexcept { btype = t; return *this; } //! Shift this Box nzones indexing positions in coordinate direction dir. AMREX_GPU_HOST_DEVICE - Box& shift (int dir, int nzones) { smallend.shift(dir,nzones); bigend.shift(dir,nzones); return *this; } + Box& shift (int dir, int nzones) noexcept { smallend.shift(dir,nzones); bigend.shift(dir,nzones); return *this; } //! Equivalent to b.shift(0,iv[0]).shift(1,iv[1]) .... AMREX_GPU_HOST_DEVICE - Box& shift (const IntVect& iv) { smallend.shift(iv); bigend.shift(iv); return *this; } + Box& shift (const IntVect& iv) noexcept { smallend.shift(iv); bigend.shift(iv); return *this; } /** * \brief This member shifts the Box by "half" indicies, thereby @@ -432,11 +432,11 @@ public: * This is: b.shifthalf(4) == b.shift(2). */ AMREX_GPU_HOST_DEVICE - Box& shiftHalf (int dir, int num_halfs); + Box& shiftHalf (int dir, int num_halfs) noexcept; //! Equivalent to b.shiftHalf(0,iv[0]).shiftHalf(1,iv[1]) ... AMREX_GPU_HOST_DEVICE - Box& shiftHalf (const IntVect& iv); + Box& shiftHalf (const IntVect& iv) noexcept; /** * \brief Convert the Box from the current type into the @@ -446,7 +446,7 @@ public: * other type mappings make no change. */ AMREX_GPU_HOST_DEVICE - Box& convert (IndexType typ); + Box& convert (IndexType typ) noexcept; /** * \brief Convert the Box from the current type into the @@ -456,34 +456,34 @@ public: * other type mappings make no change. */ AMREX_GPU_HOST_DEVICE - Box& convert (const IntVect& typ); + Box& convert (const IntVect& typ) noexcept; //! Convert to NODE type in all directions. AMREX_GPU_HOST_DEVICE - Box& surroundingNodes (); + Box& surroundingNodes () noexcept; //! Convert to NODE type in given direction. AMREX_GPU_HOST_DEVICE - Box& surroundingNodes (int dir); + Box& surroundingNodes (int dir) noexcept; //! Convert to CELL type in all directions. AMREX_GPU_HOST_DEVICE - Box& enclosedCells (); + Box& enclosedCells () noexcept; //! Convert to CELL type in given direction. AMREX_GPU_HOST_DEVICE - Box& enclosedCells (int dir); + Box& enclosedCells (int dir) noexcept; /** * \brief Return Box that is intersection of this Box * and argument. The Boxes MUST be of same type. */ AMREX_GPU_HOST_DEVICE - Box operator& (const Box& rhs) const { Box lhs(*this); lhs &= rhs; return lhs; } + Box operator& (const Box& rhs) const noexcept { Box lhs(*this); lhs &= rhs; return lhs; } //! Intersect this Box with its argument. The Boxes MUST be of the same type. AMREX_GPU_HOST_DEVICE - Box& operator&= (const Box& rhs) + Box& operator&= (const Box& rhs) noexcept { BL_ASSERT(sameType(rhs)); smallend.max(rhs.smallend); @@ -492,15 +492,15 @@ public: } //! for serialization - static size_t linearSize() + static size_t linearSize() noexcept { size_t retval = 2*IntVect::linearSize(); return retval; } //! for serialization - void linearOut(void* a_buffer ) const; - void linearIn(void* a_buffer ); + void linearOut(void* a_buffer ) const noexcept; + void linearIn(void* a_buffer ) noexcept; /** * \brief Modify Box to that of the minimum Box containing both @@ -508,7 +508,7 @@ public: * Both Boxes must have identical type. */ AMREX_GPU_HOST_DEVICE - Box& minBox (const Box& b) { + Box& minBox (const Box& b) noexcept { // BoxArray may call this with not ok boxes. BL_ASSERT(b.ok() && ok()); BL_ASSERT(sameType(b)); smallend.min(b.smallend); @@ -518,19 +518,19 @@ public: //! Shift Box (relative) by given IntVect. AMREX_GPU_HOST_DEVICE - Box& operator+= (const IntVect& v) { smallend += v; bigend += v; return *this; } + Box& operator+= (const IntVect& v) noexcept { smallend += v; bigend += v; return *this; } //! Shift Box (relative) by given IntVect. AMREX_GPU_HOST_DEVICE - Box operator+ (const IntVect& v) const { Box r(*this); r += v; return r; } + Box operator+ (const IntVect& v) const noexcept { Box r(*this); r += v; return r; } //! Shift Box (relative) by given IntVect. AMREX_GPU_HOST_DEVICE - Box& operator-= (const IntVect& v) { smallend -= v; bigend -= v; return *this; } + Box& operator-= (const IntVect& v) noexcept { smallend -= v; bigend -= v; return *this; } //! Shift Box (relative) by given IntVect. AMREX_GPU_HOST_DEVICE - Box operator- (const IntVect& v) const { Box r(*this); r -= v; return r; } + Box operator- (const IntVect& v) const noexcept { Box r(*this); r -= v; return r; } /** * \brief Chop the Box at the chop_pnt in the dir direction @@ -545,32 +545,32 @@ public: * chop_pnt is an end node of the Box. */ AMREX_GPU_HOST_DEVICE - Box chop (int dir, int chop_pnt); + Box chop (int dir, int chop_pnt) noexcept; /* * \brief Grow Box in all directions by given amount. * NOTE: n_cell negative shrinks the Box by that number of cells. */ AMREX_GPU_HOST_DEVICE - Box& grow (int i) { smallend.diagShift(-i); bigend.diagShift(i); return *this; } + Box& grow (int i) noexcept { smallend.diagShift(-i); bigend.diagShift(i); return *this; } //! Grow Box in each direction by specified amount. AMREX_GPU_HOST_DEVICE - Box& grow (const IntVect& v) { smallend -= v; bigend += v; return *this;} + Box& grow (const IntVect& v) noexcept { smallend -= v; bigend += v; return *this;} /** * \brief Grow the Box on the low and high end by n_cell cells * in direction idir. */ AMREX_GPU_HOST_DEVICE - Box& grow (int idir, int n_cell) { smallend.shift(idir, -n_cell); bigend.shift(idir, n_cell); return *this; } + Box& grow (int idir, int n_cell) noexcept { smallend.shift(idir, -n_cell); bigend.shift(idir, n_cell); return *this; } /** * \brief Grow the Box on the low end by n_cell cells in direction idir. * NOTE: n_cell negative shrinks the Box by that number of cells. */ AMREX_GPU_HOST_DEVICE - Box& growLo (int idir, int n_cell = 1) { smallend.shift(idir, -n_cell); return *this; } + Box& growLo (int idir, int n_cell = 1) noexcept { smallend.shift(idir, -n_cell); return *this; } /** * \brief Grow the Box on the high end by n_cell cells in @@ -578,11 +578,11 @@ public: * number of cells. */ AMREX_GPU_HOST_DEVICE - Box& growHi (int idir, int n_cell = 1) { bigend.shift(idir,n_cell); return *this; } + Box& growHi (int idir, int n_cell = 1) noexcept { bigend.shift(idir,n_cell); return *this; } //! Grow in the direction of the given face. AMREX_GPU_HOST_DEVICE - Box& grow (Orientation face, int n_cell = 1) { + Box& grow (Orientation face, int n_cell = 1) noexcept { int idir = face.coordDir(); if (face.isLow()) smallend.shift(idir, -n_cell); @@ -599,7 +599,7 @@ public: * hi <- hi*ratio. */ AMREX_GPU_HOST_DEVICE - Box& refine (int ref_ratio) { + Box& refine (int ref_ratio) noexcept { return this->refine(IntVect(ref_ratio)); } @@ -611,7 +611,7 @@ public: * hi <- hi*ratio. */ AMREX_GPU_HOST_DEVICE - Box& refine (const IntVect& ref_ratio); + Box& refine (const IntVect& ref_ratio) noexcept; /** * \brief Coarsen Box by given (positive) refinement ratio. @@ -623,7 +623,7 @@ public: * the original Box. */ AMREX_GPU_HOST_DEVICE - Box& coarsen (int ref_ratio) { + Box& coarsen (int ref_ratio) noexcept { return this->coarsen(IntVect(ref_ratio)); } @@ -637,14 +637,14 @@ public: * the original Box. */ AMREX_GPU_HOST_DEVICE - Box& coarsen (const IntVect& ref_ratio); + Box& coarsen (const IntVect& ref_ratio) noexcept; /** * \brief Step through the rectangle. It is a runtime error to give * a point not inside rectangle. Iteration may not be efficient. */ AMREX_GPU_HOST_DEVICE - void next (IntVect &) const; + void next (IntVect &) const noexcept; /** * \brief This static member function returns a constant reference to @@ -652,20 +652,20 @@ public: * AMREX_SPACEDIM-dimensional space. */ AMREX_GPU_HOST_DEVICE - static Box TheUnitBox () { + static Box TheUnitBox () noexcept { return Box(IntVect::TheZeroVector(),IntVect::TheZeroVector()); } AMREX_GPU_HOST_DEVICE - bool isSquare() const; + bool isSquare() const noexcept; AMREX_GPU_HOST_DEVICE - bool coarsenable(int refrat, int min_width=1) const { + bool coarsenable(int refrat, int min_width=1) const noexcept { return coarsenable(IntVect(refrat),min_width); } AMREX_GPU_HOST_DEVICE - bool coarsenable(const IntVect& refrat, int min_width=1) const + bool coarsenable(const IntVect& refrat, int min_width=1) const noexcept { if (!size().allGE(refrat*min_width)) { return false; @@ -678,7 +678,7 @@ public: } AMREX_GPU_HOST_DEVICE - void normalize () + void normalize () noexcept { for (int idim=0; idim < AMREX_SPACEDIM; ++idim) { if (this->length(idim) == 0) { @@ -687,11 +687,11 @@ public: } } - AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 lbound (Box const& box); - AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 ubound (Box const& box); - AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 begin (Box const& box); - AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 end (Box const& box); - AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 length (Box const& box); + AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 lbound (Box const& box) noexcept; + AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 ubound (Box const& box) noexcept; + AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 begin (Box const& box) noexcept; + AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 end (Box const& box) noexcept; + AMREX_GPU_HOST_DEVICE friend AMREX_FORCE_INLINE Dim3 length (Box const& box) noexcept; private: IntVect smallend; @@ -702,7 +702,7 @@ private: AMREX_GPU_HOST_DEVICE inline Box& -Box::refine (const IntVect& ref_ratio) +Box::refine (const IntVect& ref_ratio) noexcept { if (ref_ratio != 1) { IntVect shft(1); @@ -718,7 +718,7 @@ Box::refine (const IntVect& ref_ratio) AMREX_GPU_HOST_DEVICE inline Box& -Box::coarsen (const IntVect& ref_ratio) +Box::coarsen (const IntVect& ref_ratio) noexcept { if (ref_ratio != 1) { @@ -748,7 +748,7 @@ Box::coarsen (const IntVect& ref_ratio) AMREX_GPU_HOST_DEVICE inline Box& -Box::convert (const IntVect& typ) +Box::convert (const IntVect& typ) noexcept { BL_ASSERT(typ.allGE(IntVect::TheZeroVector()) && typ.allLE(IntVect::TheUnitVector())); IntVect shft(typ - btype.ixType()); @@ -760,7 +760,7 @@ Box::convert (const IntVect& typ) AMREX_GPU_HOST_DEVICE inline Box& -Box::convert (IndexType t) +Box::convert (IndexType t) noexcept { for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { @@ -776,7 +776,7 @@ Box::convert (IndexType t) AMREX_GPU_HOST_DEVICE inline Box& -Box::surroundingNodes (int dir) +Box::surroundingNodes (int dir) noexcept { if (!(btype[dir])) { @@ -792,7 +792,7 @@ Box::surroundingNodes (int dir) AMREX_GPU_HOST_DEVICE inline Box& -Box::surroundingNodes () +Box::surroundingNodes () noexcept { for (int i = 0; i < AMREX_SPACEDIM; ++i) if ((btype[i] == 0)) @@ -804,7 +804,7 @@ Box::surroundingNodes () AMREX_GPU_HOST_DEVICE inline Box& -Box::enclosedCells (int dir) +Box::enclosedCells (int dir) noexcept { if (btype[dir]) { @@ -820,7 +820,7 @@ Box::enclosedCells (int dir) AMREX_GPU_HOST_DEVICE inline Box& -Box::enclosedCells () +Box::enclosedCells () noexcept { for (int i = 0 ; i < AMREX_SPACEDIM; ++i) if (btype[i]) @@ -832,7 +832,7 @@ Box::enclosedCells () AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE long -Box::index (const IntVect& v) const +Box::index (const IntVect& v) const noexcept { long result = v[0]-smallend[0]; #if AMREX_SPACEDIM==2 @@ -847,7 +847,7 @@ Box::index (const IntVect& v) const AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVect -Box::atOffset (long offset) const +Box::atOffset (long offset) const noexcept { auto len = this->length3d(); auto lo = this->loVect3d(); @@ -862,7 +862,7 @@ Box::atOffset (long offset) const AMREX_GPU_HOST_DEVICE inline GpuArray -Box::atOffset3d (long offset) const +Box::atOffset3d (long offset) const noexcept { auto len = this->length3d(); auto lo = this->loVect3d(); @@ -879,7 +879,7 @@ inline Box& Box::setRange (int dir, int sm_index, - int n_cells) + int n_cells) noexcept { smallend.setVal(dir,sm_index); bigend.setVal(dir,sm_index+n_cells-1); @@ -888,7 +888,7 @@ Box::setRange (int dir, inline void -Box::linearOut(void* a_buffer ) const +Box::linearOut(void* a_buffer ) const noexcept { unsigned char* buf = (unsigned char*) a_buffer; const IntVect& ivlo = this->smallEnd(); @@ -901,7 +901,7 @@ Box::linearOut(void* a_buffer ) const inline void -Box::linearIn(void* a_buffer ) +Box::linearIn(void* a_buffer ) noexcept { unsigned char* buf = (unsigned char*) a_buffer; IntVect ivlo; @@ -917,7 +917,7 @@ Box::linearIn(void* a_buffer ) AMREX_GPU_HOST_DEVICE inline void -Box::next (IntVect& p) const +Box::next (IntVect& p) const noexcept { BL_ASSERT(contains(p)); @@ -942,7 +942,7 @@ Box::next (IntVect& p) const AMREX_GPU_HOST_DEVICE inline bool -Box::isSquare () const +Box::isSquare () const noexcept { const IntVect& sz = this->size(); #if AMREX_SPACEDIM==1 @@ -963,7 +963,7 @@ Box::isSquare () const AMREX_GPU_HOST_DEVICE inline Box -Box::chop (int dir, int chop_pnt) +Box::chop (int dir, int chop_pnt) noexcept { // // Define new high end Box including chop_pnt. @@ -999,8 +999,7 @@ Box::chop (int dir, int chop_pnt) AMREX_GPU_HOST_DEVICE inline Box& -Box::shiftHalf (int dir, - int nzones) +Box::shiftHalf (int dir, int nzones) noexcept { const int nbit = (nzones<0 ? -nzones : nzones)%2; int nshift = nzones/2; @@ -1022,7 +1021,7 @@ Box::shiftHalf (int dir, AMREX_GPU_HOST_DEVICE inline Box& -Box::shiftHalf (const IntVect& nz) +Box::shiftHalf (const IntVect& nz) noexcept { for (int i = 0; i < AMREX_SPACEDIM; i++) shiftHalf(i,nz[i]); @@ -1035,14 +1034,14 @@ public: explicit BoxCommHelper (const Box& bx, int* p_ = 0); - int* data () const& { return p; } + int* data () const& noexcept { return p; } int* data () && = delete; - Box make_box () const { + Box make_box () const noexcept { return Box(IntVect(p), IntVect(p+AMREX_SPACEDIM), IntVect(p+2*AMREX_SPACEDIM)); } - static int size () { return 3*AMREX_SPACEDIM; } + static int size () noexcept { return 3*AMREX_SPACEDIM; } private: int* p; @@ -1067,7 +1066,7 @@ void AllGatherBoxes (Vector& bxs); */ AMREX_GPU_HOST_DEVICE inline -Box grow (const Box& b, int i) +Box grow (const Box& b, int i) noexcept { Box result = b; result.grow(i); @@ -1077,7 +1076,7 @@ Box grow (const Box& b, int i) //! Grow Box in each direction by specified amount. AMREX_GPU_HOST_DEVICE inline -Box grow (const Box& b, const IntVect& v) +Box grow (const Box& b, const IntVect& v) noexcept { Box result = b; result.grow(v); @@ -1087,7 +1086,7 @@ Box grow (const Box& b, const IntVect& v) //! Grow Box in direction idir be n_cell cells AMREX_GPU_HOST_DEVICE inline -Box grow (const Box& b, int idir, int n_cell) +Box grow (const Box& b, int idir, int n_cell) noexcept { Box result = b; result.grow(idir, n_cell); @@ -1096,7 +1095,7 @@ Box grow (const Box& b, int idir, int n_cell) AMREX_GPU_HOST_DEVICE inline -Box growLo (const Box& b, int idir, int n_cell) +Box growLo (const Box& b, int idir, int n_cell) noexcept { Box result = b; result.growLo(idir, n_cell); @@ -1105,7 +1104,7 @@ Box growLo (const Box& b, int idir, int n_cell) AMREX_GPU_HOST_DEVICE inline -Box growHi (const Box& b, int idir, int n_cell) +Box growHi (const Box& b, int idir, int n_cell) noexcept { Box result = b; result.growHi(idir, n_cell); @@ -1123,7 +1122,7 @@ Box growHi (const Box& b, int idir, int n_cell) */ AMREX_GPU_HOST_DEVICE inline -Box coarsen (const Box& b, int ref_ratio) +Box coarsen (const Box& b, int ref_ratio) noexcept { Box result = b; result.coarsen(IntVect(ref_ratio)); @@ -1141,7 +1140,7 @@ Box coarsen (const Box& b, int ref_ratio) */ AMREX_GPU_HOST_DEVICE inline -Box coarsen (const Box& b, const IntVect& ref_ratio) +Box coarsen (const Box& b, const IntVect& ref_ratio) noexcept { Box result = b; result.coarsen(ref_ratio); @@ -1157,7 +1156,7 @@ Box coarsen (const Box& b, const IntVect& ref_ratio) */ AMREX_GPU_HOST_DEVICE inline -Box refine (const Box& b, int ref_ratio) +Box refine (const Box& b, int ref_ratio) noexcept { Box result = b; result.refine(IntVect(ref_ratio)); @@ -1173,7 +1172,7 @@ Box refine (const Box& b, int ref_ratio) */ AMREX_GPU_HOST_DEVICE inline -Box refine (const Box& b, const IntVect& ref_ratio) +Box refine (const Box& b, const IntVect& ref_ratio) noexcept { Box result = b; result.refine(ref_ratio); @@ -1183,7 +1182,7 @@ Box refine (const Box& b, const IntVect& ref_ratio) //! Return a Box with indices shifted by nzones in dir direction. AMREX_GPU_HOST_DEVICE inline -Box shift (const Box& b, int dir, int nzones) +Box shift (const Box& b, int dir, int nzones) noexcept { Box result = b; result.shift(dir, nzones); @@ -1192,7 +1191,7 @@ Box shift (const Box& b, int dir, int nzones) AMREX_GPU_HOST_DEVICE inline -Box shift (const Box& b, const IntVect& nzones) +Box shift (const Box& b, const IntVect& nzones) noexcept { Box result = b; result.shift(nzones); @@ -1206,7 +1205,7 @@ Box shift (const Box& b, const IntVect& nzones) */ AMREX_GPU_HOST_DEVICE inline -Box surroundingNodes (const Box& b, int dir) +Box surroundingNodes (const Box& b, int dir) noexcept { Box bx(b); bx.surroundingNodes(dir); @@ -1219,7 +1218,7 @@ Box surroundingNodes (const Box& b, int dir) */ AMREX_GPU_HOST_DEVICE inline -Box surroundingNodes (const Box& b) +Box surroundingNodes (const Box& b) noexcept { Box bx(b); bx.surroundingNodes(); @@ -1229,7 +1228,7 @@ Box surroundingNodes (const Box& b) //! Returns a Box with different type AMREX_GPU_HOST_DEVICE inline -Box convert (const Box& b, const IntVect& typ) +Box convert (const Box& b, const IntVect& typ) noexcept { Box bx(b); bx.convert(typ); @@ -1238,7 +1237,7 @@ Box convert (const Box& b, const IntVect& typ) AMREX_GPU_HOST_DEVICE inline -Box convert (const Box& b, const IndexType& typ) +Box convert (const Box& b, const IndexType& typ) noexcept { Box bx(b); bx.convert(typ); @@ -1253,7 +1252,7 @@ Box convert (const Box& b, const IndexType& typ) */ AMREX_GPU_HOST_DEVICE inline -Box enclosedCells (const Box& b, int dir) +Box enclosedCells (const Box& b, int dir) noexcept { Box bx(b); bx.enclosedCells(dir); @@ -1266,7 +1265,7 @@ Box enclosedCells (const Box& b, int dir) */ AMREX_GPU_HOST_DEVICE inline -Box enclosedCells (const Box& b) +Box enclosedCells (const Box& b) noexcept { Box bx(b); bx.enclosedCells(); @@ -1279,7 +1278,7 @@ Box enclosedCells (const Box& b) */ AMREX_GPU_HOST_DEVICE inline -Box bdryLo (const Box& b, int dir, int len=1) +Box bdryLo (const Box& b, int dir, int len=1) noexcept { IntVect low(b.smallEnd()); IntVect hi(b.bigEnd()); @@ -1300,7 +1299,7 @@ Box bdryLo (const Box& b, int dir, int len=1) */ AMREX_GPU_HOST_DEVICE inline -Box bdryHi (const Box& b, int dir, int len=1) +Box bdryHi (const Box& b, int dir, int len=1) noexcept { IntVect low(b.smallEnd()); IntVect hi(b.bigEnd()); @@ -1322,7 +1321,7 @@ Box bdryHi (const Box& b, int dir, int len=1) */ AMREX_GPU_HOST_DEVICE inline -Box bdryNode (const Box& b, Orientation face, int len=1) +Box bdryNode (const Box& b, Orientation face, int len=1) noexcept { int dir = face.coordDir(); IntVect low(b.smallEnd()); @@ -1362,7 +1361,7 @@ Box bdryNode (const Box& b, Orientation face, int len=1) */ AMREX_GPU_HOST_DEVICE inline -Box adjCellLo (const Box& b, int dir, int len=1) +Box adjCellLo (const Box& b, int dir, int len=1) noexcept { BL_ASSERT(len > 0); IntVect low(b.smallEnd()); @@ -1381,7 +1380,7 @@ Box adjCellLo (const Box& b, int dir, int len=1) //! Similar to adjCellLo but builds an adjacent Box on the high end. AMREX_GPU_HOST_DEVICE inline -Box adjCellHi (const Box& b, int dir, int len=1) +Box adjCellHi (const Box& b, int dir, int len=1) noexcept { BL_ASSERT(len > 0); IntVect low(b.smallEnd()); @@ -1401,7 +1400,7 @@ Box adjCellHi (const Box& b, int dir, int len=1) //! Similar to adjCellLo and adjCellHi; operates on given face. AMREX_GPU_HOST_DEVICE inline -Box adjCell (const Box& b, Orientation face, int len=1) +Box adjCell (const Box& b, Orientation face, int len=1) noexcept { BL_ASSERT(len > 0); IntVect low(b.smallEnd()); @@ -1435,7 +1434,7 @@ Box adjCell (const Box& b, Orientation face, int len=1) */ AMREX_GPU_HOST_DEVICE inline -Box minBox (const Box& b1, const Box& b2) +Box minBox (const Box& b1, const Box& b2) noexcept { Box result = b1; result.minBox(b2); @@ -1450,7 +1449,7 @@ std::istream& operator>> (std::istream& os, Box& bx); AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Dim3 lbound (Box const& box) +Dim3 lbound (Box const& box) noexcept { #if (AMREX_SPACEDIM == 1) return {box.smallend[0], 0, 0}; @@ -1463,7 +1462,7 @@ Dim3 lbound (Box const& box) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Dim3 ubound (Box const& box) +Dim3 ubound (Box const& box) noexcept { #if (AMREX_SPACEDIM == 1) return {box.bigend[0], 0, 0}; @@ -1476,7 +1475,7 @@ Dim3 ubound (Box const& box) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Dim3 begin (Box const& box) +Dim3 begin (Box const& box) noexcept { #if (AMREX_SPACEDIM == 1) return {box.smallend[0], 0, 0}; @@ -1489,7 +1488,7 @@ Dim3 begin (Box const& box) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Dim3 end (Box const& box) +Dim3 end (Box const& box) noexcept { #if (AMREX_SPACEDIM == 1) return {box.bigend[0]+1, 1, 1}; @@ -1502,7 +1501,7 @@ Dim3 end (Box const& box) AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -Dim3 length (Box const& box) +Dim3 length (Box const& box) noexcept { #if (AMREX_SPACEDIM == 1) return {box.bigend[0]-box.smallend[0]+1, 1, 1}; @@ -1518,7 +1517,7 @@ Dim3 length (Box const& box) AMREX_GPU_HOST_DEVICE AMREX_INLINE -Dim3 length (Box index_bounds, Box const& work_domain) +Dim3 length (Box index_bounds, Box const& work_domain) noexcept { index_bounds.setType(work_domain.ixType()); index_bounds &= work_domain; @@ -1527,7 +1526,7 @@ Dim3 length (Box index_bounds, Box const& work_domain) AMREX_GPU_HOST_DEVICE AMREX_INLINE -Box getThreadBox (Box index_bounds, Box const& work_domain) +Box getThreadBox (Box index_bounds, Box const& work_domain) noexcept { index_bounds.setType(work_domain.ixType()); index_bounds &= work_domain; @@ -1541,7 +1540,7 @@ Box getThreadBox (Box index_bounds, Box const& work_domain) * meaning. */ inline -Box getIndexBounds (Box const& b1, Box const& b2) +Box getIndexBounds (Box const& b1, Box const& b2) noexcept { Box b = b1; b.setType(b2.ixType()); @@ -1550,20 +1549,20 @@ Box getIndexBounds (Box const& b1, Box const& b2) } inline -Box getIndexBounds (Box const& b1, Box const& b2, Box const& b3) +Box getIndexBounds (Box const& b1, Box const& b2, Box const& b3) noexcept { return getIndexBounds(getIndexBounds(b1,b2),b3); } inline -Box getIndexBounds (Box const& b1) +Box getIndexBounds (Box const& b1) noexcept { return b1; } AMREX_GPU_HOST_DEVICE AMREX_INLINE -IntVect getCell (Box const* boxes, int nboxes, long icell) +IntVect getCell (Box const* boxes, int nboxes, long icell) noexcept { int ibox; long ncells_subtotal = 0; diff --git a/Src/Base/AMReX_BoxArray.H b/Src/Base/AMReX_BoxArray.H index a4bddbfd819..e9a69752f92 100644 --- a/Src/Base/AMReX_BoxArray.H +++ b/Src/Base/AMReX_BoxArray.H @@ -257,19 +257,19 @@ public: void resize (long len); //! Return the number of boxes in the BoxArray. - long size () const { return m_ref->m_abox.size(); } + long size () const noexcept { return m_ref->m_abox.size(); } //! Return the number of boxes that can be held in the current allocated storage - long capacity () const { return m_ref->m_abox.capacity(); } + long capacity () const noexcept { return m_ref->m_abox.capacity(); } //! Return whether the BoxArray is empty - bool empty () const { return m_ref->m_abox.empty(); } + bool empty () const noexcept { return m_ref->m_abox.empty(); } //! Returns the total number of cells contained in all boxes in the BoxArray. - long numPts() const; + long numPts() const noexcept; //! Returns the total number of cells (in double type) contained in all boxes in the BoxArray. - double d_numPts () const; + double d_numPts () const noexcept; /** * \brief Initialize the BoxArray from the supplied istream. * It is an error if the BoxArray has already been initialized. @@ -282,13 +282,13 @@ public: std::ostream& writeOn (std::ostream&) const; //! Are the BoxArrays equal? - bool operator== (const BoxArray& rhs) const; + bool operator== (const BoxArray& rhs) const noexcept; //! Are the BoxArrays not equal? - bool operator!= (const BoxArray& rhs) const; + bool operator!= (const BoxArray& rhs) const noexcept; //! Are the BoxArrays equal after conversion to cell-centered - bool CellEqual (const BoxArray& rhs) const; + bool CellEqual (const BoxArray& rhs) const noexcept; //! Forces each Box in BoxArray to have sides <= block_size. BoxArray& maxSize (int block_size); @@ -370,7 +370,7 @@ public: void set (int i, const Box& ibox); //! Return element index of this BoxArray. - Box operator[] (int index) const { + Box operator[] (int index) const noexcept { Box r = m_ref->m_abox[index]; if (m_simple) { r.coarsen(m_crse_ratio).convert(m_typ); @@ -381,13 +381,13 @@ public: } //! Return element index of this BoxArray. - Box operator[] (const MFIter& mfi) const; + Box operator[] (const MFIter& mfi) const noexcept; //! Return element index of this BoxArray. - Box get (int index) const { return operator[](index); } + Box get (int index) const noexcept { return operator[](index); } //! Return cell-centered box at element index of this BoxArray. - Box getCellCenteredBox (int index) const { + Box getCellCenteredBox (int index) const noexcept { return amrex::coarsen(m_ref->m_abox[index],m_crse_ratio); } @@ -459,24 +459,24 @@ public: static bool SameRefs (const BoxArray& lhs, const BoxArray& rhs) { return lhs.m_ref == rhs.m_ref; } struct RefID { - RefID () : data(nullptr) {} - explicit RefID (BARef* data_) : data(data_) {} - bool operator< (const RefID& rhs) const { return std::less()(data,rhs.data); } - bool operator== (const RefID& rhs) const { return data == rhs.data; } - bool operator!= (const RefID& rhs) const { return data != rhs.data; } + RefID () noexcept : data(nullptr) {} + explicit RefID (BARef* data_) noexcept : data(data_) {} + bool operator< (const RefID& rhs) const noexcept { return std::less()(data,rhs.data); } + bool operator== (const RefID& rhs) const noexcept { return data == rhs.data; } + bool operator!= (const RefID& rhs) const noexcept { return data != rhs.data; } friend std::ostream& operator<< (std::ostream& os, const RefID& id); private: BARef* data; }; //! Return a unique ID of the reference - RefID getRefID () const { return RefID { m_ref.get() }; } + RefID getRefID () const noexcept { return RefID { m_ref.get() }; } //! Return index type of this BoxArray - IndexType ixType () const { return m_typ; } + IndexType ixType () const noexcept { return m_typ; } //! Return crse ratio of this BoxArray - IntVect crseRatio () const { return m_crse_ratio; } + IntVect crseRatio () const noexcept { return m_crse_ratio; } static void Initialize (); static void Finalize (); @@ -491,9 +491,8 @@ private: BARef::HashType& getHashMap () const; - - IntVect getDoiLo () const; - IntVect getDoiHi () const; + IntVect getDoiLo () const noexcept; + IntVect getDoiHi () const noexcept; std::unique_ptr m_transformer; IndexType m_typ; diff --git a/Src/Base/AMReX_BoxArray.cpp b/Src/Base/AMReX_BoxArray.cpp index 875ff37a9ad..a867338df61 100644 --- a/Src/Base/AMReX_BoxArray.cpp +++ b/Src/Base/AMReX_BoxArray.cpp @@ -426,7 +426,7 @@ BoxArray::resize (long len) } long -BoxArray::numPts () const +BoxArray::numPts () const noexcept { long result = 0; const int N = size(); @@ -441,7 +441,7 @@ BoxArray::numPts () const } double -BoxArray::d_numPts () const +BoxArray::d_numPts () const noexcept { double result = 0; const int N = size(); @@ -490,7 +490,7 @@ BoxArray::writeOn (std::ostream& os) const } bool -BoxArray::operator== (const BoxArray& rhs) const +BoxArray::operator== (const BoxArray& rhs) const noexcept { if (m_simple && rhs.m_simple) { return m_typ == rhs.m_typ && m_crse_ratio == rhs.m_crse_ratio && @@ -505,13 +505,13 @@ BoxArray::operator== (const BoxArray& rhs) const } bool -BoxArray::operator!= (const BoxArray& rhs) const +BoxArray::operator!= (const BoxArray& rhs) const noexcept { return !operator==(rhs); } bool -BoxArray::CellEqual (const BoxArray& rhs) const +BoxArray::CellEqual (const BoxArray& rhs) const noexcept { return m_crse_ratio == rhs.m_crse_ratio && (m_ref == rhs.m_ref || m_ref->m_abox == rhs.m_ref->m_abox); @@ -804,7 +804,7 @@ BoxArray::set (int i, } Box -BoxArray::operator[] (const MFIter& mfi) const +BoxArray::operator[] (const MFIter& mfi) const noexcept { return (*this)[mfi.index()]; } @@ -1338,13 +1338,13 @@ BoxArray::type_update () } IntVect -BoxArray::getDoiLo () const +BoxArray::getDoiLo () const noexcept { return m_simple ? IntVect::TheZeroVector() : m_transformer->doiLo(); } IntVect -BoxArray::getDoiHi () const +BoxArray::getDoiHi () const noexcept { return m_simple ? m_typ.ixType() : m_transformer->doiHi(); } diff --git a/Src/Base/AMReX_BoxIterator.H b/Src/Base/AMReX_BoxIterator.H index daa5f4e5cb9..3d72438dee5 100644 --- a/Src/Base/AMReX_BoxIterator.H +++ b/Src/Base/AMReX_BoxIterator.H @@ -35,7 +35,7 @@ namespace amrex Default constructor. This constructs an invalid iterator. The user must call define before using. */ - BoxIterator(); + BoxIterator() noexcept; /// /** @@ -43,9 +43,9 @@ namespace amrex Arguments: a_bx (not modified) the Box to iterate over. */ - BoxIterator(const Box& a_bx); + BoxIterator(const Box& a_bx) noexcept; - void setBox(const Box& a_bx); + void setBox(const Box& a_bx) noexcept; /// /** @@ -53,7 +53,7 @@ namespace amrex Arguments: a_bx (not modified) the Box to iterate over. */ - void define(const Box& a_bx); + void define(const Box& a_bx) noexcept; /// /** @@ -61,7 +61,7 @@ namespace amrex Arguments: a_iterIn (not modified) the BoxIterator to copy. */ - BoxIterator(const BoxIterator& a_iterIn); + BoxIterator(const BoxIterator& a_iterIn) noexcept; /// ~BoxIterator () @@ -74,7 +74,7 @@ namespace amrex definition of the "first" IntVect is implementation-dependent. */ - void begin(); + void begin() noexcept; /// /** @@ -82,7 +82,7 @@ namespace amrex definition of the "first" IntVect is implementation-dependent. */ - void reset(); + void reset() noexcept; /// /** @@ -90,22 +90,22 @@ namespace amrex Box. The definition of the "next location" of a Box is implementation-dependent. */ - void operator ++ (); + void operator ++ () noexcept; - void next(); + void next() noexcept; /// /** Returns the value of the InVect for the current location of this BoxIterator. */ - const IntVect& operator () () const; + const IntVect& operator () () const noexcept; /// /** Returns true if this BoxIterator's location is within its Box. */ - bool ok(); + bool ok() noexcept; protected: IntVect m_current; @@ -114,7 +114,7 @@ namespace amrex }; inline - BoxIterator::BoxIterator() + BoxIterator::BoxIterator() noexcept { m_current = IntVect::TheUnitVector(); m_boxLo = IntVect::TheUnitVector(); @@ -122,13 +122,13 @@ namespace amrex } inline - BoxIterator::BoxIterator(const Box& a_bx) + BoxIterator::BoxIterator(const Box& a_bx) noexcept { define(a_bx); } inline - BoxIterator::BoxIterator(const BoxIterator& a_iterIn) + BoxIterator::BoxIterator(const BoxIterator& a_iterIn) noexcept { m_current = a_iterIn.m_current; m_boxLo = a_iterIn.m_boxLo; @@ -136,25 +136,25 @@ namespace amrex } inline - void BoxIterator::begin() + void BoxIterator::begin() noexcept { if (m_boxLo <= m_boxHi) m_current = m_boxLo; } inline - void BoxIterator::reset() + void BoxIterator::reset() noexcept { begin(); } inline - void BoxIterator::operator ++ () + void BoxIterator::operator ++ () noexcept { next(); } inline - void BoxIterator::next() + void BoxIterator::next() noexcept { m_current[0]++; #if AMREX_SPACEDIM >= 2 @@ -174,7 +174,7 @@ namespace amrex } inline - const IntVect& BoxIterator::operator () () const + const IntVect& BoxIterator::operator () () const noexcept { BL_ASSERT(m_current <= m_boxHi); BL_ASSERT(m_current >= m_boxLo); @@ -182,7 +182,7 @@ namespace amrex } inline - bool BoxIterator::ok() + bool BoxIterator::ok() noexcept { return (m_current <= m_boxHi); } diff --git a/Src/Base/AMReX_BoxIterator.cpp b/Src/Base/AMReX_BoxIterator.cpp index cba337f1f22..cac86769a81 100644 --- a/Src/Base/AMReX_BoxIterator.cpp +++ b/Src/Base/AMReX_BoxIterator.cpp @@ -2,7 +2,7 @@ namespace amrex { - void BoxIterator::define (const Box& a_bx) + void BoxIterator::define (const Box& a_bx) noexcept { if (a_bx.ok() && a_bx.smallEnd() <= a_bx.bigEnd()) { @@ -18,7 +18,7 @@ namespace amrex } } - void BoxIterator::setBox(const Box& a_bx) + void BoxIterator::setBox(const Box& a_bx) noexcept { define(a_bx); } diff --git a/Src/Base/AMReX_BoxList.H b/Src/Base/AMReX_BoxList.H index 2c34c3136bd..8943de4e82a 100644 --- a/Src/Base/AMReX_BoxList.H +++ b/Src/Base/AMReX_BoxList.H @@ -91,9 +91,9 @@ public: //! Append a Box to this BoxList. void push_back (const Box& bn) { BL_ASSERT(ixType() == bn.ixType()); m_lbox.push_back(bn); } - Box& front () { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } + Box& front () noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } - const Box& front () const { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } + const Box& front () const noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } //! Join the BoxList to ourselves. void join (const BoxList& blist); @@ -105,29 +105,29 @@ public: //! Remove all Boxes from this BoxList. void clear (); //! The number of Boxes in this BoxList. - int size () const { return m_lbox.size(); } + int size () const noexcept { return m_lbox.size(); } - std::size_t capacity () const { return m_lbox.capacity(); } + std::size_t capacity () const noexcept { return m_lbox.capacity(); } - iterator begin () { return m_lbox.begin(); } - const_iterator begin () const { return m_lbox.begin(); } + iterator begin () noexcept { return m_lbox.begin(); } + const_iterator begin () const noexcept { return m_lbox.begin(); } - iterator end () { return m_lbox.end(); } - const_iterator end () const { return m_lbox.end(); } + iterator end () noexcept { return m_lbox.end(); } + const_iterator end () const noexcept { return m_lbox.end(); } /** * \brief True if this BoxList is valid; i.e. all the Boxes are * valid and they all have the same IndexType. Also returns * true if the BoxList is empty. */ - bool ok () const; + bool ok () const noexcept; //! Is this BoxList equal to rhs? bool operator== (const BoxList& rhs) const; //! Is this BoxList notequal to rhs? bool operator!= (const BoxList& rhs) const; //! Is this BoxList empty? - bool isEmpty () const { return m_lbox.empty(); } + bool isEmpty () const noexcept { return m_lbox.empty(); } //! Is this BoxList not empty? - bool isNotEmpty () const { return !m_lbox.empty(); } + bool isNotEmpty () const noexcept { return !m_lbox.empty(); } //! True if the set of intersecting Boxes is empty. bool isDisjoint () const; //! True if all Boxes in bl are contained in this BoxList. @@ -180,30 +180,30 @@ public: //! Returns smallest Box that contains all Boxes in this BoxList. Box minimalBox () const; //! Returns the IndexType of Boxes in this BoxList. - IndexType ixType () const { return btype; } + IndexType ixType () const noexcept { return btype; } //! Set the type of the BoxList. It's an error if the BoxList isn't empty. - void set (IndexType ixtyp) { BL_ASSERT(m_lbox.empty()); btype = ixtyp; } + void set (IndexType ixtyp) noexcept { BL_ASSERT(m_lbox.empty()); btype = ixtyp; } /** * \brief Applies surroundingNodes(Box) to each Box in BoxArray. * See the documentation of Box for details. */ - BoxList& surroundingNodes (); + BoxList& surroundingNodes () noexcept; /** * \brief Applies surroundingNodes(Box,int) to each Box in * BoxList. See the documentation of Box for details. */ - BoxList& surroundingNodes (int dir); + BoxList& surroundingNodes (int dir) noexcept; //! Applies Box::enclosedCells() to each Box in the BoxList. - BoxList& enclosedCells (); + BoxList& enclosedCells () noexcept; //! Applies Box::enclosedCells(int) to each Box in the BoxList. - BoxList& enclosedCells (int dir); + BoxList& enclosedCells (int dir) noexcept; //! Applies Box::convert(IndexType) to each Box in the BoxList. - BoxList& convert (IndexType typ); + BoxList& convert (IndexType typ) noexcept; //! Returns a reference to the Vector. - Vector& data() { return m_lbox; } + Vector& data() noexcept { return m_lbox; } //! Returns a constant reference to the Vector. - const Vector& data() const { return m_lbox; } + const Vector& data() const noexcept { return m_lbox; } void swap (BoxList& rhs) { std::swap(m_lbox, rhs.m_lbox); diff --git a/Src/Base/AMReX_BoxList.cpp b/Src/Base/AMReX_BoxList.cpp index b416c8c47c6..8f70bbb974d 100644 --- a/Src/Base/AMReX_BoxList.cpp +++ b/Src/Base/AMReX_BoxList.cpp @@ -239,7 +239,7 @@ BoxList::BoxList (const Box& bx, int nboxes, Direction dir) } bool -BoxList::ok () const +BoxList::ok () const noexcept { for (const auto& b : *this) { if (!b.ok()) return false; @@ -722,7 +722,7 @@ BoxList::maxSize (int chunk) } BoxList& -BoxList::surroundingNodes () +BoxList::surroundingNodes () noexcept { for (auto& bx : m_lbox) { @@ -732,7 +732,7 @@ BoxList::surroundingNodes () } BoxList& -BoxList::surroundingNodes (int dir) +BoxList::surroundingNodes (int dir) noexcept { for (auto& bx : m_lbox) { @@ -742,7 +742,7 @@ BoxList::surroundingNodes (int dir) } BoxList& -BoxList::enclosedCells () +BoxList::enclosedCells () noexcept { for (auto& bx : m_lbox) { @@ -752,7 +752,7 @@ BoxList::enclosedCells () } BoxList& -BoxList::enclosedCells (int dir) +BoxList::enclosedCells (int dir) noexcept { for (auto& bx : m_lbox) { @@ -762,7 +762,7 @@ BoxList::enclosedCells (int dir) } BoxList& -BoxList::convert (IndexType typ) +BoxList::convert (IndexType typ) noexcept { btype = typ; for (auto& bx : m_lbox) diff --git a/Src/Base/AMReX_CArena.H b/Src/Base/AMReX_CArena.H index 15216372e64..20c01f5f287 100644 --- a/Src/Base/AMReX_CArena.H +++ b/Src/Base/AMReX_CArena.H @@ -13,7 +13,7 @@ namespace amrex { /** -* \brief A Concrete Class for Dynamic Memory Management +* \brief A Concrete Class for Dynamic Memory Management using first fit. * This is a coalescing memory manager. It allocates (possibly) large * chunks of heap space and apportions it out as requested. It merges * together neighboring chunks on each free(). @@ -38,16 +38,16 @@ public: virtual ~CArena () override; //! Allocate some memory. - virtual void* alloc (std::size_t nbytes) override; + virtual void* alloc (std::size_t nbytes) override final; /** * \brief Free up allocated memory. Merge neighboring free memory chunks * into largest possible chunk. */ - virtual void free (void* ap) override; + virtual void free (void* ap) override final; //! The current amount of heap space used by the CArena object. - std::size_t heap_space_used () const; + std::size_t heap_space_used () const noexcept; //! The default memory hunk size to grab from the heap. enum { DefaultHunkSize = 1024*1024*8 }; @@ -57,37 +57,37 @@ protected: class Node { public: - Node (void* a_block, void* a_owner, std::size_t a_size) + Node (void* a_block, void* a_owner, std::size_t a_size) noexcept : m_block(a_block), m_owner(a_owner), m_size(a_size) {} //! The "less-than" operator. - bool operator< (const Node& rhs) const + bool operator< (const Node& rhs) const noexcept { return m_block < rhs.m_block; } //! The equality operator. - bool operator== (const Node& rhs) const + bool operator== (const Node& rhs) const noexcept { return m_block == rhs.m_block; } //! The block address. - void* block () const { return m_block; } + void* block () const noexcept { return m_block; } //! Set block address. - void block (void* blk) { m_block = blk; } + void block (void* blk) noexcept { m_block = blk; } //! The size of the memory block. - std::size_t size () const { return m_size; } + std::size_t size () const noexcept { return m_size; } //! Set size. - void size (std::size_t sz) { m_size = sz; } + void size (std::size_t sz) noexcept { m_size = sz; } - void* owner () const { return m_owner; } + void* owner () const noexcept { return m_owner; } - bool coalescable (const Node& rhs) const { + bool coalescable (const Node& rhs) const noexcept { return m_owner == rhs.m_owner; } @@ -127,7 +127,7 @@ protected: */ // NL m_busylist; std::unordered_set m_busylist; - //! The minimal size of hunks to request via ::operator new(). + //! The minimal size of hunks to request from system std::size_t m_hunk; //! The amount of heap space currently allocated. std::size_t m_used; diff --git a/Src/Base/AMReX_CArena.cpp b/Src/Base/AMReX_CArena.cpp index 51f86a0111a..699193fd96d 100644 --- a/Src/Base/AMReX_CArena.cpp +++ b/Src/Base/AMReX_CArena.cpp @@ -183,7 +183,7 @@ CArena::free (void* vp) } std::size_t -CArena::heap_space_used () const +CArena::heap_space_used () const noexcept { return m_used; } diff --git a/Src/Base/AMReX_COORDSYS_1D_C.H b/Src/Base/AMReX_COORDSYS_1D_C.H index db33b875265..0c90cf16c20 100644 --- a/Src/Base/AMReX_COORDSYS_1D_C.H +++ b/Src/Base/AMReX_COORDSYS_1D_C.H @@ -13,7 +13,7 @@ inline void amrex_setvol (Box const& bx, Array4 const& vol, GpuArray const& offset, - GpuArray const& dx, const int coord) + GpuArray const& dx, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -55,7 +55,7 @@ inline void amrex_setarea (Box const& bx, Array4 const& area, GpuArray const& offset, - GpuArray const& dx, const int /*dir*/, const int coord) + GpuArray const& dx, const int /*dir*/, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -94,7 +94,7 @@ inline void amrex_setdloga (Box const& bx, Array4 const& dloga, GpuArray const& offset, - GpuArray const& dx, const int /*dir*/, const int coord) + GpuArray const& dx, const int /*dir*/, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/Base/AMReX_COORDSYS_2D_C.H b/Src/Base/AMReX_COORDSYS_2D_C.H index 358adae9a50..dcc2c66875d 100644 --- a/Src/Base/AMReX_COORDSYS_2D_C.H +++ b/Src/Base/AMReX_COORDSYS_2D_C.H @@ -13,7 +13,7 @@ inline void amrex_setvol (Box const& bx, Array4 const& vol, GpuArray const& offset, - GpuArray const& dx, const int coord) + GpuArray const& dx, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -64,7 +64,7 @@ inline void amrex_setarea (Box const& bx, Array4 const& area, GpuArray const& offset, - GpuArray const& dx, const int dir, const int coord) + GpuArray const& dx, const int dir, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -144,7 +144,7 @@ inline void amrex_setdloga (Box const& bx, Array4 const& dloga, GpuArray const& offset, - GpuArray const& dx, const int dir, const int coord) + GpuArray const& dx, const int dir, const int coord) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/Base/AMReX_CoordSys.H b/Src/Base/AMReX_CoordSys.H index 3675031d8eb..1cba3e3ca84 100644 --- a/Src/Base/AMReX_CoordSys.H +++ b/Src/Base/AMReX_CoordSys.H @@ -47,126 +47,126 @@ public: static void SetCoord (CoordType coord) { c_sys = coord; } //! Returns the CoordType. - static CoordType Coord (); + static CoordType Coord () noexcept { return c_sys; } //! Returns the CoordType as an int. - static int CoordInt (); + static int CoordInt () noexcept; //! Is CoordType == SPHERICAL? - static bool IsSPHERICAL (); + static bool IsSPHERICAL () noexcept; //! Is CoordType == RZ? - static bool IsRZ (); + static bool IsRZ () noexcept; //! Is CoordType == cartesion? - static bool IsCartesian () { BL_ASSERT(c_sys != undef); return (c_sys == cartesian); } + static bool IsCartesian () noexcept { BL_ASSERT(c_sys != undef); return (c_sys == cartesian); } //! Sets the offset for each coordinate direction. static void SetOffset (const Real* x_lo); //! Returns the offset. - static const Real* Offset () { return offset; } + static const Real* Offset () noexcept { return offset; } //! Returns the offset for the specified coordinate direction. - static Real Offset (int dir) { return offset[dir]; } + static Real Offset (int dir) noexcept { return offset[dir]; } //! Returns the cellsize for each coordinate direction. - const Real* CellSize () const { BL_ASSERT(ok); return dx; } + const Real* CellSize () const noexcept { BL_ASSERT(ok); return dx; } //! Returns the cellsize for the specified coordinate direction. - Real CellSize (int dir) const { BL_ASSERT(ok); return dx[dir]; } + Real CellSize (int dir) const noexcept { BL_ASSERT(ok); return dx[dir]; } - GpuArray CellSizeArray () const { + GpuArray CellSizeArray () const noexcept { BL_ASSERT(ok); return { AMREX_D_DECL(dx[0],dx[1],dx[2]) }; } //! Returns the inverse cellsize for each coordinate direction. - const Real* InvCellSize () const { BL_ASSERT(ok); return inv_dx; } + const Real* InvCellSize () const noexcept { BL_ASSERT(ok); return inv_dx; } //! Returns the inverse cellsize for the specified coordinate direction. - Real InvCellSize (int dir) const { BL_ASSERT(ok); return inv_dx[dir]; } + Real InvCellSize (int dir) const noexcept { BL_ASSERT(ok); return inv_dx[dir]; } - GpuArray InvCellSizeArray () const { + GpuArray InvCellSizeArray () const noexcept { BL_ASSERT(ok); return { AMREX_D_DECL(inv_dx[0],inv_dx[1],inv_dx[2]) }; } //! Returns location of cell center in specified direction. - Real CellCenter (int point, int dir) const + Real CellCenter (int point, int dir) const noexcept { BL_ASSERT(ok); return offset[dir] + dx[dir]*(0.5+ (Real)point); } //! Return location of cell center. - void CellCenter (const IntVect& point, Vector& loc) const; + void CellCenter (const IntVect& point, Vector& loc) const noexcept; //! Return location of cell center. - void CellCenter (const IntVect& point, Real* loc) const; + void CellCenter (const IntVect& point, Real* loc) const noexcept; //! Returns location of lo edge in specified direction. - Real LoEdge (int point, int dir) const + Real LoEdge (int point, int dir) const noexcept { BL_ASSERT(ok); return offset[dir] + dx[dir]*point; } //! Equivalent to LoEdge(point[dir], dir). - Real LoEdge (const IntVect& point, int dir) const + Real LoEdge (const IntVect& point, int dir) const noexcept { BL_ASSERT(ok); return offset[dir] + dx[dir]*point[dir]; } //! Returns location of hi edge in specified direction. - Real HiEdge (int point, int dir) const + Real HiEdge (int point, int dir) const noexcept { BL_ASSERT(ok); return offset[dir] + dx[dir]*(point + 1); } //! Equivalent to HiEdge(point[dir], dir). - Real HiEdge (const IntVect& point, int dir) const + Real HiEdge (const IntVect& point, int dir) const noexcept { BL_ASSERT(ok); return offset[dir] + dx[dir]*(point[dir] + 1); } //! Sets location of lo face into loc. - void LoFace (const IntVect& point, int dir, Vector& loc) const; + void LoFace (const IntVect& point, int dir, Vector& loc) const noexcept; //! Sets location of lo face into loc. - void LoFace (const IntVect& point, int dir, Real* loc) const; + void LoFace (const IntVect& point, int dir, Real* loc) const noexcept; //! Sets location of hi face into loc. - void HiFace (const IntVect& point, int dir, Vector& loc) const; + void HiFace (const IntVect& point, int dir, Vector& loc) const noexcept; //! Sets location of hi face into loc. - void HiFace (const IntVect& point, int dir, Real* loc) const; + void HiFace (const IntVect& point, int dir, Real* loc) const noexcept; //! Return location of lower left hand corner. - void LoNode (const IntVect& point, Vector& loc) const; + void LoNode (const IntVect& point, Vector& loc) const noexcept; //! Return location of lower left hand corner. - void LoNode (const IntVect& point, Real* loc) const; + void LoNode (const IntVect& point, Real* loc) const noexcept; //! Return location of upper right hand corner. - void HiNode (const IntVect& point, Vector& loc) const; + void HiNode (const IntVect& point, Vector& loc) const noexcept; //! Return location of upper right hand corner. - void HiNode (const IntVect& point, Real* loc) const; + void HiNode (const IntVect& point, Real* loc) const noexcept; /** * \brief Returns cell centered index of cell containing point. * This may return undesired results if point * is on a cell boundary. */ - IntVect CellIndex (const Real* point) const; + IntVect CellIndex (const Real* point) const noexcept; /** * \brief Returns node centered index of lower left hand corner of * cell containing this point. */ - IntVect LowerIndex (const Real* point) const; + IntVect LowerIndex (const Real* point) const noexcept; /** * \brief Returns node centered index of upper right hand corner of * cell containing this point. */ - IntVect UpperIndex (const Real* point) const; + IntVect UpperIndex (const Real* point) const noexcept; /** * \brief Compute cell volumes in given region and place them into * input FAB. @@ -228,10 +228,10 @@ public: FArrayBox* GetFaceArea (const Box& region, int dir) const; //! Returns lo face area of given cell in direction dir. - Real AreaLo (const IntVect& point, int dir) const; + Real AreaLo (const IntVect& point, int dir) const noexcept; //! Returns hi face area of given cell in direction dir. - Real AreaHi (const IntVect& point, int dir) const; + Real AreaHi (const IntVect& point, int dir) const noexcept; /** * \brief Return array of physical locations of cell edges @@ -270,7 +270,7 @@ protected: inline bool -CoordSys::IsSPHERICAL () +CoordSys::IsSPHERICAL () noexcept { BL_ASSERT(c_sys != undef); #if (AMREX_SPACEDIM <= 2) @@ -283,7 +283,7 @@ CoordSys::IsSPHERICAL () inline bool -CoordSys::IsRZ () +CoordSys::IsRZ () noexcept { BL_ASSERT(c_sys != undef); #if (AMREX_SPACEDIM <= 2) diff --git a/Src/Base/AMReX_CoordSys.cpp b/Src/Base/AMReX_CoordSys.cpp index 6b19ec87581..76919620e1d 100644 --- a/Src/Base/AMReX_CoordSys.cpp +++ b/Src/Base/AMReX_CoordSys.cpp @@ -21,14 +21,8 @@ CoordSys::CoordType CoordSys::c_sys = CoordSys::undef; Real CoordSys::offset[AMREX_SPACEDIM]; -CoordSys::CoordType -CoordSys::Coord () -{ - return c_sys; -} - int -CoordSys::CoordInt () +CoordSys::CoordInt () noexcept { switch (c_sys) { @@ -81,8 +75,7 @@ CoordSys::CoordSys (const Real* cell_dx) } void -CoordSys::CellCenter (const IntVect& point, - Real* loc) const +CoordSys::CellCenter (const IntVect& point, Real* loc) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(loc != 0); @@ -93,8 +86,7 @@ CoordSys::CellCenter (const IntVect& point, } void -CoordSys::CellCenter (const IntVect& point, - Vector& loc) const +CoordSys::CellCenter (const IntVect& point, Vector& loc) const noexcept { AMREX_ASSERT(ok); loc.resize(AMREX_SPACEDIM); @@ -104,7 +96,7 @@ CoordSys::CellCenter (const IntVect& point, void CoordSys::LoFace (const IntVect& point, int dir, - Real* loc) const + Real* loc) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(loc != 0); @@ -118,7 +110,7 @@ CoordSys::LoFace (const IntVect& point, void CoordSys::LoFace (const IntVect& point, int dir, - Vector& loc) const + Vector& loc) const noexcept { loc.resize(AMREX_SPACEDIM); LoFace(point,dir, loc.dataPtr()); @@ -127,7 +119,7 @@ CoordSys::LoFace (const IntVect& point, void CoordSys::HiFace (const IntVect& point, int dir, - Real* loc) const + Real* loc) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(loc != 0); @@ -141,7 +133,7 @@ CoordSys::HiFace (const IntVect& point, void CoordSys::HiFace (const IntVect& point, int dir, - Vector& loc) const + Vector& loc) const noexcept { loc.resize(AMREX_SPACEDIM); HiFace(point,dir, loc.dataPtr()); @@ -149,7 +141,7 @@ CoordSys::HiFace (const IntVect& point, void CoordSys::LoNode (const IntVect& point, - Real* loc) const + Real* loc) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(loc != 0); @@ -161,7 +153,7 @@ CoordSys::LoNode (const IntVect& point, void CoordSys::LoNode (const IntVect& point, - Vector& loc) const + Vector& loc) const noexcept { loc.resize(AMREX_SPACEDIM); LoNode(point, loc.dataPtr()); @@ -169,7 +161,7 @@ CoordSys::LoNode (const IntVect& point, void CoordSys::HiNode (const IntVect& point, - Real* loc) const + Real* loc) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(loc != 0); @@ -181,14 +173,14 @@ CoordSys::HiNode (const IntVect& point, void CoordSys::HiNode (const IntVect& point, - Vector& loc) const + Vector& loc) const noexcept { loc.resize(AMREX_SPACEDIM); HiNode(point, loc.dataPtr()); } IntVect -CoordSys::CellIndex (const Real* point) const +CoordSys::CellIndex (const Real* point) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(point != 0); @@ -201,7 +193,7 @@ CoordSys::CellIndex (const Real* point) const } IntVect -CoordSys::LowerIndex (const Real* point) const +CoordSys::LowerIndex (const Real* point) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(point != 0); @@ -214,7 +206,7 @@ CoordSys::LowerIndex (const Real* point) const } IntVect -CoordSys::UpperIndex(const Real* point) const +CoordSys::UpperIndex(const Real* point) const noexcept { AMREX_ASSERT(ok); AMREX_ASSERT(point != 0); @@ -547,8 +539,7 @@ CoordSys::Volume (const Real xlo[AMREX_SPACEDIM], } Real -CoordSys::AreaLo (const IntVect& point, - int dir) const +CoordSys::AreaLo (const IntVect& point, int dir) const noexcept { #if (AMREX_SPACEDIM==2) Real xlo[AMREX_SPACEDIM]; @@ -583,8 +574,7 @@ CoordSys::AreaLo (const IntVect& point, } Real -CoordSys::AreaHi (const IntVect& point, - int dir) const +CoordSys::AreaHi (const IntVect& point, int dir) const noexcept { #if (AMREX_SPACEDIM==2) Real xhi[AMREX_SPACEDIM]; diff --git a/Src/Base/AMReX_CudaAllocators.H b/Src/Base/AMReX_CudaAllocators.H index 68fa245b294..0d7094fdc6a 100644 --- a/Src/Base/AMReX_CudaAllocators.H +++ b/Src/Base/AMReX_CudaAllocators.H @@ -14,6 +14,7 @@ #include #include #include +#include #endif // AMREX_USE_CUDA namespace amrex { @@ -194,7 +195,7 @@ namespace amrex { namespace Cuda { - ThrustDeviceAllocator& The_ThrustCachedAllocator (); + ThrustManagedAllocator& The_ThrustCachedAllocator (); } // When not using CUDA, replace with standard allocator. diff --git a/Src/Base/AMReX_CudaAllocators.cpp b/Src/Base/AMReX_CudaAllocators.cpp index 8e8002536dd..4af2bea4cd7 100644 --- a/Src/Base/AMReX_CudaAllocators.cpp +++ b/Src/Base/AMReX_CudaAllocators.cpp @@ -6,12 +6,12 @@ namespace amrex namespace { - ThrustDeviceAllocator g_cached_allocator; + ThrustManagedAllocator g_cached_allocator; } namespace Cuda { - ThrustDeviceAllocator& The_ThrustCachedAllocator () { return g_cached_allocator; }; + ThrustManagedAllocator& The_ThrustCachedAllocator () { return g_cached_allocator; }; } } diff --git a/Src/Base/AMReX_CudaAsyncArray.H b/Src/Base/AMReX_CudaAsyncArray.H index 41982eceff9..b0f81b68b1f 100644 --- a/Src/Base/AMReX_CudaAsyncArray.H +++ b/Src/Base/AMReX_CudaAsyncArray.H @@ -56,8 +56,8 @@ public: ~AsyncArray () { clear(); } - T const* data () const { return (d_data != nullptr) ? d_data : h_data; } - T* data () { return (d_data != nullptr) ? d_data : h_data; } + T const* data () const noexcept { return (d_data != nullptr) ? d_data : h_data; } + T* data () noexcept { return (d_data != nullptr) ? d_data : h_data; } void clear () { #ifdef AMREX_USE_CUDA diff --git a/Src/Base/AMReX_CudaAsyncFab.H b/Src/Base/AMReX_CudaAsyncFab.H index da3da9e554d..ae4ee369d1a 100644 --- a/Src/Base/AMReX_CudaAsyncFab.H +++ b/Src/Base/AMReX_CudaAsyncFab.H @@ -42,12 +42,12 @@ public: // Not allowed because it contains cuda api calls void resize (Box const& bx, int ncomp); void clear (); - AMREX_GPU_HOST_DEVICE FArrayBox* fabPtr () const { return m_fab; } - AMREX_GPU_HOST_DEVICE FArrayBox& fab () const { return *m_fab; } - FArrayBox& hostFab () const; + AMREX_GPU_HOST_DEVICE FArrayBox* fabPtr () const noexcept { return m_fab; } + AMREX_GPU_HOST_DEVICE FArrayBox& fab () const noexcept { return *m_fab; } + FArrayBox& hostFab () const noexcept; - Array4 array () const; - Array4 array (); + Array4 array () const noexcept; + Array4 array () noexcept; static void Initialize (); static void Finalize (); diff --git a/Src/Base/AMReX_CudaAsyncFab.cpp b/Src/Base/AMReX_CudaAsyncFab.cpp index 00e4900719d..4a3548679cf 100644 --- a/Src/Base/AMReX_CudaAsyncFab.cpp +++ b/Src/Base/AMReX_CudaAsyncFab.cpp @@ -73,19 +73,19 @@ AsyncFab::clear () } FArrayBox& -AsyncFab::hostFab () const +AsyncFab::hostFab () const noexcept { return m_impl->hostFab(); } Array4 -AsyncFab::array () const +AsyncFab::array () const noexcept { return m_impl->hostFab().const_array(); } Array4 -AsyncFab::array () +AsyncFab::array () noexcept { return m_impl->hostFab().array(); } diff --git a/Src/Base/AMReX_CudaAsyncFabImpl.H b/Src/Base/AMReX_CudaAsyncFabImpl.H index 0bf172d3f8f..43c992220f7 100644 --- a/Src/Base/AMReX_CudaAsyncFabImpl.H +++ b/Src/Base/AMReX_CudaAsyncFabImpl.H @@ -19,8 +19,8 @@ public: AsyncFabImpl (AsyncFabImpl const&) = delete; void operator= (AsyncFabImpl const&) = delete; - FArrayBox* fabPtr (); - FArrayBox& hostFab (); + FArrayBox* fabPtr () noexcept; + FArrayBox& hostFab () noexcept; static void Initialize (); static void Finalize (); diff --git a/Src/Base/AMReX_CudaAsyncFabImpl.cpp b/Src/Base/AMReX_CudaAsyncFabImpl.cpp index e46628d2ead..c37bb33f11c 100644 --- a/Src/Base/AMReX_CudaAsyncFabImpl.cpp +++ b/Src/Base/AMReX_CudaAsyncFabImpl.cpp @@ -36,13 +36,13 @@ AsyncFabImpl::AsyncFabImpl (FArrayBox& /*a_fab*/, Box const& bx, int ncomp) AsyncFabImpl::~AsyncFabImpl () {} FArrayBox* -AsyncFabImpl::fabPtr () +AsyncFabImpl::fabPtr () noexcept { AMREX_ASSERT(m_gpu_fab != nullptr); return m_gpu_fab.get(); } -FArrayBox& AsyncFabImpl::hostFab () { return *m_gpu_fab; } +FArrayBox& AsyncFabImpl::hostFab () noexcept { return *m_gpu_fab; } #else @@ -154,14 +154,14 @@ AsyncFabImpl::~AsyncFabImpl () } FArrayBox* -AsyncFabImpl::fabPtr () +AsyncFabImpl::fabPtr () noexcept { AMREX_ASSERT(m_gpu_fab != nullptr); return m_gpu_fab.get(); } FArrayBox& -AsyncFabImpl::hostFab () +AsyncFabImpl::hostFab () noexcept { return m_cpu_fab; } @@ -212,9 +212,9 @@ AsyncFabImpl::AsyncFabImpl (FArrayBox& a_fab, Box const& bx, int ncomp) AsyncFabImpl::~AsyncFabImpl () {} -FArrayBox* AsyncFabImpl::fabPtr () { return m_cpu_fab_alias; } +FArrayBox* AsyncFabImpl::fabPtr () noexcept { return m_cpu_fab_alias; } -FArrayBox& AsyncFabImpl::hostFab () { return *m_cpu_fab_alias; } +FArrayBox& AsyncFabImpl::hostFab () noexcept { return *m_cpu_fab_alias; } }} diff --git a/Src/Base/AMReX_CudaDevice.H b/Src/Base/AMReX_CudaDevice.H index 06ce7ccb151..33e66e2dbca 100644 --- a/Src/Base/AMReX_CudaDevice.H +++ b/Src/Base/AMReX_CudaDevice.H @@ -21,12 +21,12 @@ public: static void Finalize (); #if defined(AMREX_USE_CUDA) - static cudaStream_t cudaStream () { return cuda_stream; } + static cudaStream_t cudaStream () noexcept { return cuda_stream; } #endif - static void setStreamIndex (const int idx); - static void resetStreamIndex () { setStreamIndex(-1); } + static void setStreamIndex (const int idx) noexcept; + static void resetStreamIndex () noexcept { setStreamIndex(-1); } - static int deviceId (); + static int deviceId () noexcept; static void synchronize (); static void streamSynchronize (); @@ -40,18 +40,19 @@ public: static void mem_advise_set_readonly (void* p, const std::size_t sz); #if defined(AMREX_USE_CUDA) - static void n_threads_and_blocks (const long N, dim3& numBlocks, dim3& numThreads); + static void setNumThreadsMin (int nx, int ny, int nz) noexcept; + static void n_threads_and_blocks (const long N, dim3& numBlocks, dim3& numThreads) noexcept; static void c_comps_threads_and_blocks (const int* lo, const int* hi, const int comps, - dim3& numBlocks, dim3& numThreads); - static void c_threads_and_blocks (const int* lo, const int* hi, dim3& numBlocks, dim3& numThreads); - static void grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads); - - static std::size_t totalGlobalMem () { return device_prop.totalGlobalMem; } - static int numMultiProcessors () { return device_prop.multiProcessorCount; } - static int maxThreadsPerMultiProcessor () { return device_prop.maxThreadsPerMultiProcessor; } - static int maxThreadsPerBlock () { return device_prop.maxThreadsPerBlock; } - static int maxThreadsPerBlock (int dir) { return device_prop.maxThreadsDim[dir]; } - static int maxBlocksPerGrid (int dir) { return device_prop.maxGridSize[dir]; } + dim3& numBlocks, dim3& numThreads) noexcept; + static void c_threads_and_blocks (const int* lo, const int* hi, dim3& numBlocks, dim3& numThreads) noexcept; + static void grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads) noexcept; + + static std::size_t totalGlobalMem () noexcept { return device_prop.totalGlobalMem; } + static int numMultiProcessors () noexcept { return device_prop.multiProcessorCount; } + static int maxThreadsPerMultiProcessor () noexcept { return device_prop.maxThreadsPerMultiProcessor; } + static int maxThreadsPerBlock () noexcept { return device_prop.maxThreadsPerBlock; } + static int maxThreadsPerBlock (int dir) noexcept { return device_prop.maxThreadsDim[dir]; } + static int maxBlocksPerGrid (int dir) noexcept { return device_prop.maxGridSize[dir]; } #endif static std::size_t freeMemAvailable (); diff --git a/Src/Base/AMReX_CudaDevice.cpp b/Src/Base/AMReX_CudaDevice.cpp index 48bacfcf50a..f0179511ef9 100644 --- a/Src/Base/AMReX_CudaDevice.cpp +++ b/Src/Base/AMReX_CudaDevice.cpp @@ -61,6 +61,10 @@ Device::Initialize () pp.query("v", verbose); pp.query("verbose", verbose); + if (amrex::Verbose()) { + amrex::Print() << "Initializing CUDA...\n"; + } + // Count the number of CUDA visible devices. int cuda_device_count; @@ -270,13 +274,13 @@ Device::initialize_cuda () } int -Device::deviceId () +Device::deviceId () noexcept { return device_id; } void -Device::setStreamIndex (const int idx) +Device::setStreamIndex (const int idx) noexcept { #ifdef AMREX_USE_CUDA if (idx < 0) { @@ -360,7 +364,14 @@ Device::mem_advise_set_readonly (void* p, const std::size_t sz) { #if defined(AMREX_USE_CUDA) void -Device::n_threads_and_blocks (const long N, dim3& numBlocks, dim3& numThreads) +Device::setNumThreadsMin (int nx, int ny, int nz) noexcept { + numThreadsMin.x = nx; + numThreadsMin.y = ny; + numThreadsMin.z = nz; +} + +void +Device::n_threads_and_blocks (const long N, dim3& numBlocks, dim3& numThreads) noexcept { numThreads = AMREX_CUDA_MAX_THREADS; numBlocks = std::max((N + AMREX_CUDA_MAX_THREADS - 1) / AMREX_CUDA_MAX_THREADS, 1L); // in case N = 0 @@ -368,14 +379,14 @@ Device::n_threads_and_blocks (const long N, dim3& numBlocks, dim3& numThreads) void Device::c_comps_threads_and_blocks (const int* lo, const int* hi, const int comps, - dim3& numBlocks, dim3& numThreads) + dim3& numBlocks, dim3& numThreads) noexcept { c_threads_and_blocks(lo, hi, numBlocks, numThreads); numBlocks.x *= static_cast(comps); } void -Device::c_threads_and_blocks (const int* lo, const int* hi, dim3& numBlocks, dim3& numThreads) +Device::c_threads_and_blocks (const int* lo, const int* hi, dim3& numBlocks, dim3& numThreads) noexcept { // Our threading strategy will be to allocate thread blocks //preferring the x direction first to guarantee coalesced accesses. @@ -433,7 +444,7 @@ Device::c_threads_and_blocks (const int* lo, const int* hi, dim3& numBlocks, dim } void -Device::grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads) +Device::grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads) noexcept { int num_SMs = device_prop.multiProcessorCount; @@ -441,7 +452,6 @@ Device::grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads) if (num_SMs > 0) { - numBlocks.x = 1; numBlocks.y = SM_mult_factor; numBlocks.z = num_SMs; @@ -456,9 +466,32 @@ Device::grid_stride_threads_and_blocks (dim3& numBlocks, dim3& numThreads) } - numThreads.x = std::max((int) numThreadsMin.x, 16); - numThreads.y = std::max((int) numThreadsMin.y, 16); - numThreads.z = std::max((int) numThreadsMin.z, 1); +#if (AMREX_SPACEDIM == 1) + + numThreads.x = std::min(static_cast(device_prop.maxThreadsDim[0]), AMREX_CUDA_MAX_THREADS); + numThreads.x = std::max(numThreads.x, numThreadsMin.x); + numThreads.y = 1; + numThreads.z = 1; + +#elif (AMREX_SPACEDIM == 2) + + numThreads.x = std::min(static_cast(device_prop.maxThreadsDim[0]), AMREX_CUDA_MAX_THREADS / numThreadsMin.y); + numThreads.y = std::min(static_cast(device_prop.maxThreadsDim[1]), AMREX_CUDA_MAX_THREADS / numThreads.x); + numThreads.x = std::max(numThreadsMin.x, numThreads.x); + numThreads.y = std::max(numThreadsMin.y, numThreads.y); + numThreads.z = 1; + +#else + + numThreads.x = std::min(static_cast(device_prop.maxThreadsDim[0]), AMREX_CUDA_MAX_THREADS / (numThreadsMin.y * numThreadsMin.z)); + numThreads.y = std::min(static_cast(device_prop.maxThreadsDim[1]), AMREX_CUDA_MAX_THREADS / (numThreads.x * numThreadsMin.z)); + numThreads.z = std::min(static_cast(device_prop.maxThreadsDim[2]), AMREX_CUDA_MAX_THREADS / (numThreads.x * numThreads.y )); + + numThreads.x = std::max(numThreadsMin.x, numThreads.x); + numThreads.y = std::max(numThreadsMin.y, numThreads.y); + numThreads.z = std::max(numThreadsMin.z, numThreads.z); + +#endif // Allow the user to override these at runtime. diff --git a/Src/Base/AMReX_CudaElixir.H b/Src/Base/AMReX_CudaElixir.H index f2c978337ed..9325d5f6783 100644 --- a/Src/Base/AMReX_CudaElixir.H +++ b/Src/Base/AMReX_CudaElixir.H @@ -10,21 +10,21 @@ class Elixir { public: - Elixir () : m_p(nullptr), m_arena(nullptr) {} + Elixir () noexcept : m_p(nullptr), m_arena(nullptr) {} - Elixir (void* p, Arena* arena) : m_p(p), m_arena(arena) {} + Elixir (void* p, Arena* arena) noexcept : m_p(p), m_arena(arena) {} Elixir (Elixir const&) = delete; void operator= (Elixir const&) = delete; - Elixir (Elixir && rhs) + Elixir (Elixir && rhs) noexcept : m_p(rhs.m_p), m_arena(rhs.m_arena) { rhs.m_p = nullptr; rhs.m_arena = nullptr; } - void operator= (Elixir && rhs) + void operator= (Elixir && rhs) noexcept { clear(); m_p = rhs.m_p; @@ -35,7 +35,7 @@ public: ~Elixir () { clear(); } - void clear (); + void clear () noexcept; private: void* m_p; diff --git a/Src/Base/AMReX_CudaElixir.cpp b/Src/Base/AMReX_CudaElixir.cpp index 16f0a25deae..7a996e6ff98 100644 --- a/Src/Base/AMReX_CudaElixir.cpp +++ b/Src/Base/AMReX_CudaElixir.cpp @@ -29,7 +29,7 @@ extern "C" { } void -Elixir::clear () +Elixir::clear () noexcept { #ifdef AMREX_USE_CUDA if (inLaunchRegion()) diff --git a/Src/Base/AMReX_CudaLaunch.H b/Src/Base/AMReX_CudaLaunch.H index 6ecd8d00266..8a105bc1c32 100644 --- a/Src/Base/AMReX_CudaLaunch.H +++ b/Src/Base/AMReX_CudaLaunch.H @@ -29,7 +29,7 @@ long amrex_i_npts = BX.numPts(); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_npts); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (auto const amrex_i_i : amrex::Cuda::Range(amrex_i_npts)) { \ const auto IV = BX.atOffset(amrex_i_i); \ block \ @@ -51,7 +51,7 @@ long amrex_i_npts = BX.numPts(); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_npts); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (auto const amrex_i_i : amrex::Cuda::Range(amrex_i_npts)) { \ const auto IV = BX.atOffset(amrex_i_i); \ block \ @@ -68,7 +68,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(TN); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (auto const TI : amrex::Cuda::Range(TN)) { \ block \ } \ @@ -91,7 +91,7 @@ amrex_i_ec2.numBlocks.x); \ amrex_i_nblocks.y = 2; \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ switch (blockIdx.y) { \ case 0: for (auto const TI1 : amrex::Cuda::Range(TN1)) { \ block1 \ @@ -125,7 +125,7 @@ amrex_i_ec3.numBlocks.x); \ amrex_i_nblocks.y = 3; \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ switch (blockIdx.y) { \ case 0: for (auto const TI1 : amrex::Cuda::Range(TN1)) { \ block1 \ @@ -159,7 +159,7 @@ { \ auto amrex_i_ec = amrex::Cuda::ExecutionConfig(TN); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (auto const TI : amrex::Cuda::Range(TN)) { \ block \ } \ @@ -180,7 +180,7 @@ amrex_i_ec2.numBlocks.x); \ amrex_i_nblocks.y = 2; \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ switch (blockIdx.y) { \ case 0: for (auto const TI1 : amrex::Cuda::Range(TN1)) { \ block1 \ @@ -209,7 +209,7 @@ amrex_i_ec3.numBlocks.x); \ amrex_i_nblocks.y = 3; \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ switch (blockIdx.y) { \ case 0: for (auto const TI1 : amrex::Cuda::Range(TN1)) { \ block1 \ @@ -234,7 +234,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(bbb); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ long amrex_i_numpts = bbb.numPts(); \ long amrex_i_tid = blockDim.x*blockIdx.x + threadIdx.x; \ long amrex_i_wid = amrex_i_tid / AMREX_CUDA_WARP_SIZE; \ @@ -258,7 +258,7 @@ { \ auto amrex_i_ec = amrex::Cuda::ExecutionConfig(bbb); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ long amrex_i_numpts = bbb.numPts(); \ long amrex_i_tid = blockDim.x*blockIdx.x + threadIdx.x; \ long amrex_i_wid = amrex_i_tid / AMREX_CUDA_WARP_SIZE; \ @@ -284,7 +284,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(bbb); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ long amrex_i_numpts = bbb.numPts(); \ long amrex_i_tid = blockDim.x*blockIdx.x + threadIdx.x; \ long amrex_i_wid = amrex_i_tid / AMREX_CUDA_WARP_SIZE; \ @@ -308,7 +308,7 @@ long max_pts = std::max(bbx.numPts(), std::max(bby.numPts(), bbz.numPts())); \ const auto amrex_i_ec = Cuda::ExecutionConfig(max_pts); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ long amrex_i_tid = blockDim.x*blockIdx.x + threadIdx.x; \ long amrex_i_wid = amrex_i_tid / AMREX_CUDA_WARP_SIZE; \ long amrex_i_lid = amrex_i_tid - amrex_i_wid*AMREX_CUDA_WARP_SIZE; \ @@ -349,7 +349,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ const auto amrex_i_lo = bbb.loVect3d(); \ const auto amrex_i_hi = bbb.hiVect3d(); \ for (int amrex_i_k = amrex_i_lo[2] + blockIdx.z * blockDim.z + threadIdx.z; amrex_i_k <= amrex_i_hi[2]; amrex_i_k += blockDim.z * gridDim.z) { \ @@ -411,7 +411,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(n); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int i = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ i < n; i += amrex_i_stride) { \ block \ @@ -428,7 +428,7 @@ { \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(n); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int i = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ i < n; i += amrex_i_stride) { \ block \ @@ -449,7 +449,7 @@ const auto amrex_i_len = amrex::length(box); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_ncells); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int amrex_i_icell = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ amrex_i_icell < amrex_i_ncells; amrex_i_icell += amrex_i_stride) { \ int k = amrex_i_icell / (amrex_i_len.x*amrex_i_len.y); \ @@ -481,7 +481,7 @@ const auto amrex_i_len = amrex::length(box); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_ncells); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int amrex_i_icell = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ amrex_i_icell < amrex_i_ncells; amrex_i_icell += amrex_i_stride) { \ int k = amrex_i_icell / (amrex_i_len.x*amrex_i_len.y); \ @@ -508,7 +508,7 @@ const auto amrex_i_len = amrex::length(box); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_ncells); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int amrex_i_icell = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ amrex_i_icell < amrex_i_ncells; amrex_i_icell += amrex_i_stride) { \ int k = amrex_i_icell / (amrex_i_len.x*amrex_i_len.y); \ @@ -541,7 +541,7 @@ const auto amrex_i_len = amrex::length(box); \ const auto amrex_i_ec = amrex::Cuda::ExecutionConfig(amrex_i_ncells); \ amrex::launch_global<<>>( \ - [=] AMREX_GPU_DEVICE () { \ + [=] AMREX_GPU_DEVICE () noexcept { \ for (int amrex_i_icell = blockDim.x*blockIdx.x+threadIdx.x, amrex_i_stride = blockDim.x*gridDim.x; \ amrex_i_icell < amrex_i_ncells; amrex_i_icell += amrex_i_stride) { \ int k = amrex_i_icell / (amrex_i_len.x*amrex_i_len.y); \ @@ -724,18 +724,18 @@ namespace amrex { AMREX_GPU_GLOBAL void launch_global (L f0, Lambdas... fs) { f0(); call_device(fs...); } template - AMREX_GPU_DEVICE void call_device (L f0) { f0(); } + AMREX_GPU_DEVICE void call_device (L f0) noexcept { f0(); } template - AMREX_GPU_DEVICE void call_device (L f0, Lambdas... fs) { f0(); call_device(fs...); } + AMREX_GPU_DEVICE void call_device (L f0, Lambdas... fs) noexcept { f0(); call_device(fs...); } // CPU variation template - void launch_host (L&& f0) { std::forward(f0)(); } + void launch_host (L&& f0) noexcept { std::forward(f0)(); } template - void launch_host (L&& f0, Lambdas&&... fs) { + void launch_host (L&& f0, Lambdas&&... fs) noexcept { std::forward(f0)(); launch_host(std::forward(fs)...); } @@ -766,7 +766,7 @@ namespace Cuda { AMREX_GPU_HOST_DEVICE inline - Box getThreadBox (const Box& bx, long offset) + Box getThreadBox (const Box& bx, long offset) noexcept { #if defined(AMREX_USE_CUDA) && defined(__CUDA_ARCH__) const auto len = bx.length3d(); @@ -787,10 +787,10 @@ namespace Cuda { #if defined(AMREX_USE_CUDA) && defined(__CUDACC__) struct ExecutionConfig { - ExecutionConfig () { + ExecutionConfig () noexcept { Cuda::Device::grid_stride_threads_and_blocks(numBlocks,numThreads); } - ExecutionConfig (const Box& box) { + ExecutionConfig (const Box& box) noexcept { // If we change this, we must make sure it doesn't break say getGridSize, which // assumes the decomposition is 1D. FabArrayUtility Reduce* as well. Cuda::Device::n_threads_and_blocks( ((box.numPts()+AMREX_CUDA_NCELLS_PER_THREAD-1)/AMREX_CUDA_NCELLS_PER_THREAD), numBlocks, numThreads ); @@ -801,14 +801,15 @@ namespace Cuda { Cuda::Device::c_threads_and_blocks(b.loVect(), b.hiVect(), numBlocks, numThreads); #endif } - ExecutionConfig (const Box& box, int comps) { + ExecutionConfig (const Box& box, int comps) noexcept { const Box& b = amrex::surroundingNodes(box); Cuda::Device::c_comps_threads_and_blocks(b.loVect(), b.hiVect(), comps, numBlocks, numThreads); } - ExecutionConfig (long N) { + ExecutionConfig (long N) noexcept { Cuda::Device::n_threads_and_blocks(N, numBlocks, numThreads); } - ExecutionConfig (dim3 nb, dim3 nt, std::size_t sm=0) : numBlocks(nb), numThreads(nt), sharedMem(sm) {} + ExecutionConfig (dim3 nb, dim3 nt, std::size_t sm=0) noexcept + : numBlocks(nb), numThreads(nt), sharedMem(sm) {} dim3 numBlocks; dim3 numThreads; @@ -821,11 +822,11 @@ namespace Cuda { #ifdef AMREX_USE_CUDA template -void launch (T const& n, L f) +void launch (T const& n, L f) noexcept { const auto ec = Cuda::ExecutionConfig(n); amrex::launch_global<<>>( - [=] AMREX_GPU_DEVICE () { + [=] AMREX_GPU_DEVICE () noexcept { for (auto const i : Cuda::Range(n)) { f(i); } @@ -834,11 +835,11 @@ void launch (T const& n, L f) } template ::value> > -void For (T n, L f) +void For (T n, L f) noexcept { const auto ec = Cuda::ExecutionConfig(n); amrex::launch_global<<>>( - [=] AMREX_GPU_DEVICE () { + [=] AMREX_GPU_DEVICE () noexcept { for (T i = blockDim.x*blockIdx.x+threadIdx.x, stride = blockDim.x*gridDim.x; i < n; i += stride) { f(i); @@ -848,20 +849,20 @@ void For (T n, L f) } template ::value> > -void ParallelFor (T n, L f) +void ParallelFor (T n, L f) noexcept { For(n,f); } template -void For (Box const& box, L f) +void For (Box const& box, L f) noexcept { int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); const auto ec = Cuda::ExecutionConfig(ncells); amrex::launch_global<<>>( - [=] AMREX_GPU_DEVICE () { + [=] AMREX_GPU_DEVICE () noexcept { for (int icell = blockDim.x*blockIdx.x+threadIdx.x, stride = blockDim.x*gridDim.x; icell < ncells; icell += stride) { int k = icell / (len.x*len.y); @@ -877,20 +878,20 @@ void For (Box const& box, L f) } template -void ParallelFor (Box const& box, L f) +void ParallelFor (Box const& box, L f) noexcept { For(box,f); } template ::value> > -void For (Box const& box, T ncomp, L f) +void For (Box const& box, T ncomp, L f) noexcept { int ncells = box.numPts(); const auto lo = amrex::lbound(box); const auto len = amrex::length(box); const auto ec = Cuda::ExecutionConfig(ncells); amrex::launch_global<<>>( - [=] AMREX_GPU_DEVICE () { + [=] AMREX_GPU_DEVICE () noexcept { for (int icell = blockDim.x*blockIdx.x+threadIdx.x, stride = blockDim.x*gridDim.x; icell < ncells; icell += stride) { int k = icell / (len.x*len.y); @@ -908,7 +909,7 @@ void For (Box const& box, T ncomp, L f) } template ::value> > -void ParallelFor (Box const& box, T ncomp, L f) +void ParallelFor (Box const& box, T ncomp, L f) noexcept { For(box,ncomp,f); } @@ -917,14 +918,14 @@ void ParallelFor (Box const& box, T ncomp, L f) template AMREX_FORCE_INLINE -void launch (T const& n, L&& f) +void launch (T const& n, L&& f) noexcept { std::forward(f)(n); } template ::value> > AMREX_FORCE_INLINE -void For (T n, L&& f) +void For (T n, L&& f) noexcept { for (T i = 0; i < n; ++i) { std::forward(f)(i); @@ -933,7 +934,7 @@ void For (T n, L&& f) template ::value> > AMREX_FORCE_INLINE -void ParallelFor (T n, L&& f) +void ParallelFor (T n, L&& f) noexcept { AMREX_PRAGMA_SIMD for (T i = 0; i < n; ++i) { @@ -943,7 +944,7 @@ void ParallelFor (T n, L&& f) template AMREX_FORCE_INLINE -void For (Box const& box, L&& f) +void For (Box const& box, L&& f) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -956,7 +957,7 @@ void For (Box const& box, L&& f) template AMREX_FORCE_INLINE -void ParallelFor (Box const& box, L&& f) +void ParallelFor (Box const& box, L&& f) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -970,7 +971,7 @@ void ParallelFor (Box const& box, L&& f) template ::value> > AMREX_FORCE_INLINE -void For (Box const& box, T ncomp, L&& f) +void For (Box const& box, T ncomp, L&& f) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -985,7 +986,7 @@ void For (Box const& box, T ncomp, L&& f) template ::value> > AMREX_FORCE_INLINE -void ParallelFor (Box const& box, T ncomp, L&& f) +void ParallelFor (Box const& box, T ncomp, L&& f) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/Base/AMReX_CudaMemory.H b/Src/Base/AMReX_CudaMemory.H index 17a9e0d9f65..c394b3b5b87 100644 --- a/Src/Base/AMReX_CudaMemory.H +++ b/Src/Base/AMReX_CudaMemory.H @@ -159,7 +159,7 @@ private: template struct SharedMemory { - AMREX_GPU_DEVICE T* dataPtr () { + AMREX_GPU_DEVICE T* dataPtr () noexcept { static_assert(sizeof(T) < 0, "We must specialize struct SharedMemory"); return nullptr; } @@ -168,7 +168,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE double* dataPtr () { + AMREX_GPU_DEVICE double* dataPtr () noexcept { extern __shared__ double amrex_sm_double[]; return amrex_sm_double; } @@ -177,7 +177,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE float* dataPtr () { + AMREX_GPU_DEVICE float* dataPtr () noexcept { extern __shared__ float amrex_sm_float[]; return amrex_sm_float; } @@ -186,7 +186,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE long* dataPtr () { + AMREX_GPU_DEVICE long* dataPtr () noexcept { extern __shared__ long amrex_sm_long[]; return amrex_sm_long; } @@ -195,7 +195,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE int* dataPtr () { + AMREX_GPU_DEVICE int* dataPtr () noexcept { extern __shared__ int amrex_sm_int[]; return amrex_sm_int; } @@ -204,7 +204,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE short* dataPtr () { + AMREX_GPU_DEVICE short* dataPtr () noexcept { extern __shared__ short amrex_sm_short[]; return amrex_sm_short; } @@ -213,7 +213,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE char* dataPtr () { + AMREX_GPU_DEVICE char* dataPtr () noexcept { extern __shared__ char amrex_sm_char[]; return amrex_sm_char; } @@ -222,7 +222,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE unsigned long* dataPtr () { + AMREX_GPU_DEVICE unsigned long* dataPtr () noexcept { extern __shared__ unsigned long amrex_sm_ulong[]; return amrex_sm_ulong; } @@ -231,7 +231,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE unsigned int* dataPtr () { + AMREX_GPU_DEVICE unsigned int* dataPtr () noexcept { extern __shared__ unsigned int amrex_sm_uint[]; return amrex_sm_uint; } @@ -240,7 +240,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE unsigned short* dataPtr () { + AMREX_GPU_DEVICE unsigned short* dataPtr () noexcept { extern __shared__ unsigned short amrex_sm_ushort[]; return amrex_sm_ushort; } @@ -249,7 +249,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE unsigned char* dataPtr () { + AMREX_GPU_DEVICE unsigned char* dataPtr () noexcept { extern __shared__ unsigned char amrex_sm_uchar[]; return amrex_sm_uchar; } @@ -258,7 +258,7 @@ struct SharedMemory template <> struct SharedMemory { - AMREX_GPU_DEVICE bool* dataPtr () { + AMREX_GPU_DEVICE bool* dataPtr () noexcept { extern __shared__ bool amrex_sm_bool[]; return amrex_sm_bool; } diff --git a/Src/Base/AMReX_CudaRange.H b/Src/Base/AMReX_CudaRange.H index 750b02f1100..64cbed4d551 100644 --- a/Src/Base/AMReX_CudaRange.H +++ b/Src/Base/AMReX_CudaRange.H @@ -14,15 +14,15 @@ namespace range_detail { //! integer version template ::value> > AMREX_GPU_HOST_DEVICE -long size (T const& b) { return static_cast(b); } +long size (T const& b) noexcept { return static_cast(b); } template ::value> > AMREX_GPU_HOST_DEVICE -long at (T const& b, long offset) { return offset; } +long at (T const& b, long offset) noexcept { return offset; } //! Box version AMREX_GPU_HOST_DEVICE -AMREX_INLINE long size (Box const& b) +AMREX_INLINE long size (Box const& b) noexcept { #ifdef __CUDA_ARCH__ return b.numPts(); @@ -32,7 +32,7 @@ AMREX_INLINE long size (Box const& b) } AMREX_GPU_HOST_DEVICE -AMREX_INLINE Box at (Box const& b, long offset) +AMREX_INLINE Box at (Box const& b, long offset) noexcept { #ifdef __CUDA_ARCH__ auto len = b.length3d(); @@ -53,21 +53,21 @@ template struct range_impl { AMREX_GPU_HOST_DEVICE - range_impl (T const& b) : m_b(b), m_n(range_detail::size(b)) {} + range_impl (T const& b) noexcept : m_b(b), m_n(range_detail::size(b)) {} struct iterator { AMREX_GPU_HOST_DEVICE - iterator (T const& b, long i, long s) : mi_b(b), mi_i(i), mi_s(s) {} + iterator (T const& b, long i, long s) noexcept : mi_b(b), mi_i(i), mi_s(s) {} AMREX_GPU_HOST_DEVICE - void operator++ () { mi_i += mi_s; } + void operator++ () noexcept { mi_i += mi_s; } AMREX_GPU_HOST_DEVICE - bool operator!= (iterator const& rhs) const { return mi_i < rhs.mi_i; } + bool operator!= (iterator const& rhs) const noexcept { return mi_i < rhs.mi_i; } AMREX_GPU_HOST_DEVICE - T operator* () const { return range_detail::at(mi_b,mi_i); } + T operator* () const noexcept { return range_detail::at(mi_b,mi_i); } private: T const& mi_b; @@ -76,7 +76,7 @@ struct range_impl }; AMREX_GPU_HOST_DEVICE - iterator begin () const { + iterator begin () const noexcept { #ifdef __CUDA_ARCH__ return iterator(m_b, blockDim.x*blockIdx.x+threadIdx.x, blockDim.x*gridDim.x); #else @@ -85,7 +85,7 @@ struct range_impl } AMREX_GPU_HOST_DEVICE - iterator end () const { return iterator(m_b,m_n,0); } + iterator end () const noexcept { return iterator(m_b,m_n,0); } private: T m_b; @@ -95,7 +95,7 @@ private: template AMREX_GPU_HOST_DEVICE -range_detail::range_impl Range(T const& b) { return range_detail::range_impl(b); } +range_detail::range_impl Range(T const& b) noexcept { return range_detail::range_impl(b); } }} diff --git a/Src/Base/AMReX_CudaReduce.H b/Src/Base/AMReX_CudaReduce.H index 1c725d2df40..99b038d0afe 100644 --- a/Src/Base/AMReX_CudaReduce.H +++ b/Src/Base/AMReX_CudaReduce.H @@ -14,7 +14,7 @@ namespace Cuda { template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceSum_lt7 (volatile T* data, int tid) +void warpReduceSum_lt7 (volatile T* data, int tid) noexcept { #if __CUDA_ARCH__ < 700 if (blockSize >= 64) data[tid] += data[tid + 32]; @@ -28,7 +28,7 @@ void warpReduceSum_lt7 (volatile T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceSum_ge7 (T* data, int tid) +void warpReduceSum_ge7 (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 if (blockSize >= 64) { if (tid < 32) { data[tid] += data[tid + 32]; } __syncwarp(); } @@ -42,7 +42,7 @@ void warpReduceSum_ge7 (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceSum (T* data, int tid) +void warpReduceSum (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 warpReduceSum_ge7(data, tid); @@ -53,7 +53,7 @@ void warpReduceSum (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void blockReduceSum (T* data, T& sum) +void blockReduceSum (T* data, T& sum) noexcept { int tid = threadIdx.x; if (blockSize >= 1024) { @@ -75,7 +75,7 @@ void blockReduceSum (T* data, T& sum) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMin_lt7 (volatile T* data, int tid) +void warpReduceMin_lt7 (volatile T* data, int tid) noexcept { #if __CUDA_ARCH__ < 700 if (blockSize >= 64) data[tid] = amrex::min(data[tid],data[tid + 32]); @@ -89,7 +89,7 @@ void warpReduceMin_lt7 (volatile T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMin_ge7 (T* data, int tid) +void warpReduceMin_ge7 (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 if (blockSize >= 64) { if (tid < 32) { data[tid] = amrex::min(data[tid],data[tid + 32]); } __syncwarp(); } @@ -103,7 +103,7 @@ void warpReduceMin_ge7 (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMin (T* data, int tid) +void warpReduceMin (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 warpReduceMin_ge7(data, tid); @@ -114,7 +114,7 @@ void warpReduceMin (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void blockReduceMin (T* data, T& dmin) +void blockReduceMin (T* data, T& dmin) noexcept { int tid = threadIdx.x; if (blockSize >= 1024) { @@ -136,7 +136,7 @@ void blockReduceMin (T* data, T& dmin) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMax_lt7 (volatile T* data, int tid) +void warpReduceMax_lt7 (volatile T* data, int tid) noexcept { #if __CUDA_ARCH__ < 700 if (blockSize >= 64) data[tid] = amrex::max(data[tid],data[tid + 32]); @@ -150,7 +150,7 @@ void warpReduceMax_lt7 (volatile T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMax_ge7 (T* data, int tid) +void warpReduceMax_ge7 (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 if (blockSize >= 64) { if (tid < 32) { data[tid] = amrex::max(data[tid],data[tid + 32]); } __syncwarp(); } @@ -164,7 +164,7 @@ void warpReduceMax_ge7 (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceMax (T* data, int tid) +void warpReduceMax (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 warpReduceMax_ge7(data, tid); @@ -175,7 +175,7 @@ void warpReduceMax (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void blockReduceMax (T* data, T& dmax) +void blockReduceMax (T* data, T& dmax) noexcept { int tid = threadIdx.x; if (blockSize >= 1024) { @@ -197,7 +197,7 @@ void blockReduceMax (T* data, T& dmax) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceAnd_lt7 (volatile T* data, int tid) +void warpReduceAnd_lt7 (volatile T* data, int tid) noexcept { #if __CUDA_ARCH__ < 700 if (blockSize >= 64) data[tid] = data[tid] && data[tid + 32]; @@ -211,7 +211,7 @@ void warpReduceAnd_lt7 (volatile T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceAnd_ge7 (T* data, int tid) +void warpReduceAnd_ge7 (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 if (blockSize >= 64) { if (tid < 32) { data[tid] = data[tid] && data[tid + 32]; } __syncwarp(); } @@ -225,7 +225,7 @@ void warpReduceAnd_ge7 (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceAnd (T* data, int tid) +void warpReduceAnd (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 warpReduceAnd_ge7(data, tid); @@ -236,7 +236,7 @@ void warpReduceAnd (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void blockReduceAnd (T* data, T& r) +void blockReduceAnd (T* data, T& r) noexcept { int tid = threadIdx.x; if (blockSize >= 1024) { @@ -258,7 +258,7 @@ void blockReduceAnd (T* data, T& r) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceOr_lt7 (volatile T* data, int tid) +void warpReduceOr_lt7 (volatile T* data, int tid) noexcept { #if __CUDA_ARCH__ < 700 if (blockSize >= 64) data[tid] = data[tid] || data[tid + 32]; @@ -272,7 +272,7 @@ void warpReduceOr_lt7 (volatile T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceOr_ge7 (T* data, int tid) +void warpReduceOr_ge7 (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 if (blockSize >= 64) { if (tid < 32) { data[tid] = data[tid] || data[tid + 32]; } __syncwarp(); } @@ -286,7 +286,7 @@ void warpReduceOr_ge7 (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void warpReduceOr (T* data, int tid) +void warpReduceOr (T* data, int tid) noexcept { #if __CUDA_ARCH__ >= 700 warpReduceOr_ge7(data, tid); @@ -297,7 +297,7 @@ void warpReduceOr (T* data, int tid) template AMREX_GPU_DEVICE AMREX_INLINE -void blockReduceOr (T* data, T& r) +void blockReduceOr (T* data, T& r) noexcept { int tid = threadIdx.x; if (blockSize >= 1024) { diff --git a/Src/Base/AMReX_CudaUtility.H b/Src/Base/AMReX_CudaUtility.H index 5606a838551..bdf721a1617 100644 --- a/Src/Base/AMReX_CudaUtility.H +++ b/Src/Base/AMReX_CudaUtility.H @@ -10,6 +10,7 @@ #include #ifdef AMREX_USE_CUDA #include +#include #endif namespace amrex { @@ -17,7 +18,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - T LDG (Array4 const& a, int i, int j, int k) { + T LDG (Array4 const& a, int i, int j, int k) noexcept { #ifdef __CUDA_ARCH__ return __ldg(a.ptr(i,j,k,n)); #else @@ -27,7 +28,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - T LDG (Array4 const& a, int i, int j, int k, int n) { + T LDG (Array4 const& a, int i, int j, int k, int n) noexcept { #ifdef __CUDA_ARCH__ return __ldg(a.ptr(i,j,k,n)); #else @@ -35,7 +36,7 @@ namespace Cuda { #endif } - inline bool isManaged (void const* p) { + inline bool isManaged (void const* p) noexcept { #ifdef AMREX_USE_CUDA CUpointer_attribute attrib = CU_POINTER_ATTRIBUTE_IS_MANAGED; unsigned int is_managed = 0; @@ -47,7 +48,7 @@ namespace Cuda { #endif } - inline bool isDevicePtr (void const* p) { + inline bool isDevicePtr (void const* p) noexcept { #ifdef AMREX_USE_CUDA CUpointer_attribute attrib = CU_POINTER_ATTRIBUTE_MEMORY_TYPE; CUmemorytype mem_type = static_cast(0); @@ -59,7 +60,7 @@ namespace Cuda { #endif } - inline bool isPinnedPtr (void const* p) { + inline bool isPinnedPtr (void const* p) noexcept { #ifdef AMREX_USE_CUDA CUpointer_attribute attrib = CU_POINTER_ATTRIBUTE_MEMORY_TYPE; CUmemorytype mem_type = static_cast(0); @@ -71,7 +72,7 @@ namespace Cuda { #endif } - inline bool isGpuPtr (void const* p) { + inline bool isGpuPtr (void const* p) noexcept { #ifdef AMREX_USE_CUDA CUpointer_attribute attrib = CU_POINTER_ATTRIBUTE_MEMORY_TYPE; CUmemorytype mem_type = static_cast(0); @@ -93,7 +94,7 @@ namespace Cuda { namespace detail { AMREX_GPU_DEVICE AMREX_FORCE_INLINE - float atomicMax(float* address, float val) + float atomicMax(float* address, float val) noexcept { int* address_as_i = (int*) address; int old = *address_as_i, assumed; @@ -106,7 +107,7 @@ namespace Cuda { } AMREX_GPU_DEVICE AMREX_FORCE_INLINE - double atomicMax(double* address, double val) + double atomicMax(double* address, double val) noexcept { unsigned long long int* address_as_ull = (unsigned long long int*) address; @@ -120,7 +121,7 @@ namespace Cuda { } AMREX_GPU_DEVICE AMREX_FORCE_INLINE - float atomicMin(float* address, float val) + float atomicMin(float* address, float val) noexcept { int* address_as_i = (int*) address; int old = *address_as_i, assumed; @@ -133,7 +134,7 @@ namespace Cuda { } AMREX_GPU_DEVICE AMREX_FORCE_INLINE - double atomicMin(double* address, double val) + double atomicMin(double* address, double val) noexcept { unsigned long long int* address_as_ull = (unsigned long long int*) address; @@ -150,7 +151,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Add (T* sum, T value) + void Add (T* sum, T value) noexcept { #if defined(__CUDA_ARCH__) atomicAdd(sum, value); @@ -160,7 +161,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Add (long* sum, long value) + void Add (long* sum, long value) noexcept { #if defined(__CUDA_ARCH__) atomicAdd((unsigned long long*)sum, static_cast(value)); @@ -171,7 +172,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Min (T* m, T value) + void Min (T* m, T value) noexcept { #if defined(__CUDA_ARCH__) detail::atomicMin(m, value); @@ -181,7 +182,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Min (int* m, int value) + void Min (int* m, int value) noexcept { #if defined(__CUDA_ARCH__) atomicMin(m, value); @@ -191,7 +192,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Min (unsigned int* m, unsigned int value) + void Min (unsigned int* m, unsigned int value) noexcept { #if defined(__CUDA_ARCH__) atomicMin(m, value); @@ -201,7 +202,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Min (unsigned long long int* m, unsigned long long int value) + void Min (unsigned long long int* m, unsigned long long int value) noexcept { #if defined(__CUDA_ARCH__) atomicMin(m, value); @@ -212,7 +213,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Max (T* m, T value) + void Max (T* m, T value) noexcept { #if defined(__CUDA_ARCH__) detail::atomicMax(m, value); @@ -222,7 +223,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Max (int* m, int value) + void Max (int* m, int value) noexcept { #if defined(__CUDA_ARCH__) atomicMax(m, value); @@ -232,7 +233,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Max (unsigned int* m, unsigned int value) + void Max (unsigned int* m, unsigned int value) noexcept { #if defined(__CUDA_ARCH__) atomicMax(m, value); @@ -242,7 +243,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Max (unsigned long long int* m, unsigned long long int value) + void Max (unsigned long long int* m, unsigned long long int value) noexcept { #if defined(__CUDA_ARCH__) atomicMax(m, value); @@ -252,7 +253,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void Or (int* m, int value) + void Or (int* m, int value) noexcept { #if defined(__CUDA_ARCH__) atomicOr(m, value); @@ -262,7 +263,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - void And (int* m, int value) + void And (int* m, int value) noexcept { #if defined(__CUDA_ARCH__) atomicAnd(m, value); @@ -272,7 +273,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - unsigned int Inc (unsigned int* m, unsigned int value) + unsigned int Inc (unsigned int* m, unsigned int value) noexcept { #if defined(__CUDA_ARCH__) return atomicInc(m, value); @@ -282,7 +283,7 @@ namespace Cuda { } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - unsigned int Dec (unsigned int* m, unsigned int value) + unsigned int Dec (unsigned int* m, unsigned int value) noexcept { #if defined(__CUDA_ARCH__) return atomicDec(m, value); @@ -295,7 +296,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - bool isnan(T m) + bool isnan(T m) noexcept { #if defined(__CUDA_ARCH__) return isnan(m); @@ -306,7 +307,7 @@ namespace Cuda { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - bool isinf(T m) + bool isinf(T m) noexcept { #ifdef __CUDA_ARCH__ return isinf(m); @@ -318,7 +319,7 @@ namespace Cuda { class StreamIter { public: - StreamIter (const int n, bool is_thread_safe=true); + StreamIter (const int n, bool is_thread_safe=true) noexcept; ~StreamIter (); StreamIter (StreamIter const&) = delete; @@ -326,14 +327,14 @@ namespace Cuda { void operator= (StreamIter const&) = delete; void operator= (StreamIter &&) = delete; - int operator() () const { return m_i; } + int operator() () const noexcept { return m_i; } - bool isValid () const { return m_i < m_n; } + bool isValid () const noexcept { return m_i < m_n; } #if !defined(AMREX_USE_CUDA) - void operator++ () { ++m_i; } + void operator++ () noexcept { ++m_i; } #else - void operator++ (); + void operator++ () noexcept; #endif private: diff --git a/Src/Base/AMReX_CudaUtility.cpp b/Src/Base/AMReX_CudaUtility.cpp index 3287db4f17c..35a8b82f0a2 100644 --- a/Src/Base/AMReX_CudaUtility.cpp +++ b/Src/Base/AMReX_CudaUtility.cpp @@ -20,7 +20,7 @@ operator<< (std::ostream& os, const dim3& d) namespace Cuda { -StreamIter::StreamIter (const int n, bool is_thread_safe) +StreamIter::StreamIter (const int n, bool is_thread_safe) noexcept : m_n(n), m_i(0), m_threadsafe(is_thread_safe) { #if defined(AMREX_USE_CUDA) @@ -52,7 +52,7 @@ StreamIter::~StreamIter () { #ifdef AMREX_USE_CUDA void -StreamIter::operator++ () +StreamIter::operator++ () noexcept { ++m_i; if (m_threadsafe) { diff --git a/Src/Base/AMReX_DistributionMapping.H b/Src/Base/AMReX_DistributionMapping.H index d0cb19b172f..93300b26ff9 100644 --- a/Src/Base/AMReX_DistributionMapping.H +++ b/Src/Base/AMReX_DistributionMapping.H @@ -93,18 +93,18 @@ class DistributionMapping * ProcessorMap()[i] is an integer in the interval [0, NCPU) where * NCPU is the number of CPUs being used. */ - const Vector& ProcessorMap () const; + const Vector& ProcessorMap () const noexcept; //! Length of the underlying processor map. - long size () const { return m_ref->m_pmap.size(); } - long capacity () const { return m_ref->m_pmap.capacity(); } - bool empty () const { return m_ref->m_pmap.empty(); } + long size () const noexcept { return m_ref->m_pmap.size(); } + long capacity () const noexcept { return m_ref->m_pmap.capacity(); } + bool empty () const noexcept { return m_ref->m_pmap.empty(); } //! Number of references to this DistributionMapping - long linkCount () const { return m_ref.use_count(); } + long linkCount () const noexcept { return m_ref.use_count(); } //! Equivalent to ProcessorMap()[index]. - int operator[] (int index) const { return m_ref->m_pmap[index]; } + int operator[] (int index) const noexcept { return m_ref->m_pmap[index]; } //! Set/get the distribution strategy. static void strategy (Strategy how); @@ -117,10 +117,10 @@ class DistributionMapping static int SFC_Threshold (); //! Are the distributions equal? - bool operator== (const DistributionMapping& rhs) const; + bool operator== (const DistributionMapping& rhs) const noexcept; //! Are the distributions different? - bool operator!= (const DistributionMapping& rhs) const; + bool operator!= (const DistributionMapping& rhs) const noexcept; void SFCProcessorMap(const BoxArray& boxes, const std::vector& wgts, int nprocs, bool sort=true); @@ -178,7 +178,7 @@ private: struct LIpairLT { bool operator () (const LIpair& lhs, - const LIpair& rhs) const + const LIpair& rhs) const noexcept { return lhs.first < rhs.first; } @@ -187,7 +187,7 @@ private: struct LIpairGT { bool operator () (const LIpair& lhs, - const LIpair& rhs) const + const LIpair& rhs) const noexcept { return lhs.first > rhs.first; } @@ -237,7 +237,7 @@ private: friend class DistributionMapping; //! Constructors to match those in DistributionMapping .... - Ref () {} + Ref () noexcept {} explicit Ref (int len) : m_pmap(len) {} @@ -259,12 +259,12 @@ private: public: struct RefID { - RefID () : data(nullptr) {} - explicit RefID (Ref* data_) : data(data_) {} - bool operator< (const RefID& rhs) const { return std::less()(data,rhs.data); } - bool operator== (const RefID& rhs) const { return data == rhs.data; } - bool operator!= (const RefID& rhs) const { return data != rhs.data; } - const Ref *dataPtr() const { return data; } + RefID () noexcept : data(nullptr) {} + explicit RefID (Ref* data_) noexcept : data(data_) {} + bool operator< (const RefID& rhs) const noexcept { return std::less()(data,rhs.data); } + bool operator== (const RefID& rhs) const noexcept { return data == rhs.data; } + bool operator!= (const RefID& rhs) const noexcept { return data != rhs.data; } + const Ref *dataPtr() const noexcept { return data; } void PrintPtr(std::ostream &os) const { os << data << '\n'; } friend std::ostream& operator<< (std::ostream& os, const RefID& id); private: @@ -272,7 +272,7 @@ public: }; //! This gives a unique ID of the reference, which is different from dmID above. - RefID getRefID () const { return RefID { m_ref.get() }; } + RefID getRefID () const noexcept { return RefID { m_ref.get() }; } }; //! Our output operator. diff --git a/Src/Base/AMReX_DistributionMapping.cpp b/Src/Base/AMReX_DistributionMapping.cpp index 29a2fe32e55..dcb4c041c31 100644 --- a/Src/Base/AMReX_DistributionMapping.cpp +++ b/Src/Base/AMReX_DistributionMapping.cpp @@ -45,7 +45,7 @@ DistributionMapping::Strategy DistributionMapping::m_Strategy = DistributionMapp DistributionMapping::PVMF DistributionMapping::m_BuildMap = 0; const Vector& -DistributionMapping::ProcessorMap () const +DistributionMapping::ProcessorMap () const noexcept { return m_ref->m_pmap; } @@ -93,13 +93,13 @@ DistributionMapping::SFC_Threshold () } bool -DistributionMapping::operator== (const DistributionMapping& rhs) const +DistributionMapping::operator== (const DistributionMapping& rhs) const noexcept { return m_ref == rhs.m_ref || m_ref->m_pmap == rhs.m_ref->m_pmap; } bool -DistributionMapping::operator!= (const DistributionMapping& rhs) const +DistributionMapping::operator!= (const DistributionMapping& rhs) const noexcept { return !operator==(rhs); } diff --git a/Src/Base/AMReX_EArena.H b/Src/Base/AMReX_EArena.H new file mode 100644 index 00000000000..df513988735 --- /dev/null +++ b/Src/Base/AMReX_EArena.H @@ -0,0 +1,117 @@ +#ifndef AMREX_EARENA_H_ +#define AMREX_EARENA_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace amrex { + +/** +* \brief A Concrete Class for Dynamic Memory Management using best fit. +* This is a coalescing memory manager. It allocates (possibly) large +* chunks of heap space and apportions it out as requested. It merges +* together neighboring chunks on each free(). +*/ + +class EArena + : + public Arena +{ +public: + + EArena (std::size_t hunk_size = 0, ArenaInfo info = ArenaInfo()); + EArena (const EArena& rhs) = delete; + EArena& operator= (const EArena& rhs) = delete; + virtual ~EArena () override; + + virtual void* alloc (std::size_t nbytes) override final; + virtual void free (void* vp) override final; + + //! The current amount of heap space used by the EArena object. + std::size_t heap_space_used () const noexcept; + //! Free space available in the arena + std::size_t free_space_available () const noexcept; + + //! The default memory hunk size to grab from the heap. + enum { DefaultHunkSize = 1024*1024*8 }; + +protected: + + struct Node + { + Node (void* block, void* owner, std::size_t size) + : m_block(reinterpret_cast(block)), + m_owner(reinterpret_cast(owner)), + m_size(size) + {} + + Node (std::size_t size) + : m_block(0), m_owner(0), m_size(size) + {} + + uintptr_t m_block; + uintptr_t m_owner; + std::size_t m_size; + + struct CompareSize { + bool operator () (Node const& lhs, Node const& rhs) const noexcept { + return (lhs.m_size < rhs.m_size) + || ((lhs.m_size == rhs.m_size) + && (lhs.m_block < rhs.m_block)); + } + }; + + struct CompareAddr { + bool operator () (Node const& lhs, Node const& rhs) const noexcept { + return (lhs.m_owner < rhs.m_owner) + || ((lhs.m_owner == rhs.m_owner) + && (lhs.m_block < rhs.m_block)); + } + }; + + struct hash { + std::size_t operator() (Node const& n) const noexcept { + return std::hash{}(n.m_block); + } + }; + + struct equal { + bool operator() (Node const& lhs, Node const& rhs) const noexcept { + return lhs.m_block == rhs.m_block; + } + }; + }; + + std::vector m_alloc; + + using FreeList = std::set; + FreeList m_freelist; + + // This store the same nodes as FreeList, but in different order + using MergeList = std::set; + MergeList m_mergelist; + + using BusyList = std::unordered_set; + BusyList m_busylist; + + //! The minimal size of hunks to request from system + std::size_t m_hunk; + //! The amount of heap space currently allocated from system. + std::size_t m_used_size; + //! The amount of free space in arena + std::size_t m_free_size; + + std::mutex earena_mutex; +}; + +} + +#endif diff --git a/Src/Base/AMReX_EArena.cpp b/Src/Base/AMReX_EArena.cpp new file mode 100644 index 00000000000..4da0248461a --- /dev/null +++ b/Src/Base/AMReX_EArena.cpp @@ -0,0 +1,154 @@ + +#include +#include + +#include +#include +#include + +namespace amrex { + +EArena::EArena (std::size_t hunk_size, ArenaInfo info) +{ + arena_info = info; + m_hunk = Arena::align(hunk_size == 0 ? DefaultHunkSize : hunk_size); + m_used_size = 0; + m_free_size = 0; + + AMREX_ASSERT(m_hunk >= hunk_size); + AMREX_ASSERT(m_hunk%Arena::align_size == 0); +} + +EArena::~EArena () +{ + for (unsigned int i = 0, N = m_alloc.size(); i < N; i++) { + deallocate_system(m_alloc[i]); + } +} + +void* +EArena::alloc (std::size_t nbytes) +{ + std::lock_guard lock(earena_mutex); + + nbytes = Arena::align(nbytes == 0 ? 1 : nbytes); + + auto fit = m_freelist.lower_bound(Node{nbytes}); + + void* vp = nullptr; + + if (fit == m_freelist.end()) + { // We have to allocate from the system + const std::size_t N = nbytes < m_hunk ? m_hunk : nbytes; + vp = allocate_system(N); + m_used_size += N; + m_alloc.push_back(vp); + + if (nbytes < N) { // add leftover to free list + void* block = static_cast(vp) + nbytes; + m_freelist.emplace(block, vp, N-nbytes); + m_mergelist.emplace(block, vp, N-nbytes); + m_free_size += N-nbytes; + } + + m_busylist.emplace(vp, vp, nbytes); + } + else + { // found free block + AMREX_ASSERT(fit->m_size >= nbytes); + AMREX_ASSERT(m_busylist.find(*fit) == m_busylist.end()); + + vp = reinterpret_cast(fit->m_block); + void* op = reinterpret_cast(fit->m_owner); + m_busylist.emplace(vp, op, nbytes); + + if (fit->m_size > nbytes) { + void* bp = static_cast(vp) + nbytes; + m_freelist.emplace(bp,op,fit->m_size-nbytes); + m_mergelist.emplace(bp,op,fit->m_size-nbytes); + m_free_size += fit->m_size-nbytes; + } + + m_free_size -= fit->m_size; + m_mergelist.erase(*fit); + m_freelist.erase(fit); + } + + AMREX_ASSERT(vp != nullptr); + return vp; +} + +void +EArena::free (void* vp) +{ + std::lock_guard lock(earena_mutex); + if (vp == nullptr) return; + + auto bit = m_busylist.find(Node{vp,nullptr,0}); + AMREX_ASSERT(bit != m_busylist.end()); // assert pointer is in busy list + AMREX_ASSERT(m_freelist.find(*bit) == m_freelist.end()); // assert not in free list + + auto pair_fitb = m_freelist.insert(*bit); + auto pair_mitb = m_mergelist.insert(*bit); + m_free_size += bit->m_size; + AMREX_ASSERT(pair_fitb.second == true && pair_mitb.second); + auto fit = pair_fitb.first; + auto mit = pair_mitb.first; + + m_busylist.erase(bit); + + // try to merge + if (mit != m_mergelist.begin()) + { + auto lo_it = mit; + --lo_it; + if (lo_it->m_owner == mit->m_owner) + { + void* plo = reinterpret_cast(lo_it->m_block); + void* phi = reinterpret_cast(mit->m_block); + void* addr = static_cast(plo) + lo_it->m_size; + if (addr == phi) + { + m_freelist.erase(*lo_it); + m_freelist.erase(*mit); + Node* node = const_cast(&(*lo_it)); + node->m_size = lo_it->m_size + mit->m_size; + m_mergelist.erase(mit); + mit = lo_it; + m_freelist.insert(*mit); + } + } + } + + auto hi_it = mit; + ++hi_it; + if (hi_it != m_mergelist.end() && mit->m_owner == hi_it->m_owner) + { + void* plo = reinterpret_cast(mit->m_block); + void* phi = reinterpret_cast(hi_it->m_block); + void* addr = static_cast(plo) + mit->m_size; + if (addr == phi) + { + m_freelist.erase(*mit); + m_freelist.erase(*hi_it); + Node* node = const_cast(&(*mit)); + node->m_size = mit->m_size + hi_it->m_size; + m_mergelist.erase(hi_it); + m_freelist.insert(*mit); + } + } +} + +std::size_t +EArena::heap_space_used () const noexcept +{ + return m_used_size; +} + +std::size_t +EArena::free_space_available () const noexcept +{ + return m_free_size; +} + +} diff --git a/Src/Base/AMReX_FArrayBox.H b/Src/Base/AMReX_FArrayBox.H index caeaa72d392..df087618617 100644 --- a/Src/Base/AMReX_FArrayBox.H +++ b/Src/Base/AMReX_FArrayBox.H @@ -202,7 +202,7 @@ class FArrayBox friend class FABio; public: //! Construct an invalid FAB with no memory. - FArrayBox (); + FArrayBox () noexcept; /** * \brief Construct an initial FAB with the data space allocated but @@ -220,7 +220,7 @@ public: FArrayBox (const FArrayBox& rhs, MakeType make_type); #endif - FArrayBox (const Box& b, int ncomp, Real* p); + FArrayBox (const Box& b, int ncomp, Real* p) noexcept; //! The destructor. ~FArrayBox () = default; @@ -232,53 +232,53 @@ public: FArrayBox& operator= (FArrayBox&&) = delete; //! Set the fab to the value r. - FArrayBox& operator= (Real r); + FArrayBox& operator= (Real r) noexcept; // - void initVal (); + void initVal () noexcept; /** * \brief Are there any NaNs in the FAB? * This may return false, even if the FAB contains NaNs, if the machine * doesn't support the appropriate NaN testing functions. */ AMREX_GPU_HOST_DEVICE - bool contains_nan () const; + bool contains_nan () const noexcept; AMREX_GPU_HOST_DEVICE - bool contains_nan (const Box& bx, int scomp, int ncomp) const; + bool contains_nan (const Box& bx, int scomp, int ncomp) const noexcept; /** * \brief These versions return the cell index (though not the component) of * the first location of a NaN if there is one. */ AMREX_GPU_HOST_DEVICE - bool contains_nan (IntVect& where) const; + bool contains_nan (IntVect& where) const noexcept; AMREX_GPU_HOST_DEVICE - bool contains_nan (const Box& bx, int scomp, int ncomp, IntVect& where) const; + bool contains_nan (const Box& bx, int scomp, int ncomp, IntVect& where) const noexcept; /** * \brief Are there any Infs in the FAB? * This may return false, even if the FAB contains Infs, if the machine * doesn't support the appropriate Inf testing functions. */ AMREX_GPU_HOST_DEVICE - bool contains_inf () const; + bool contains_inf () const noexcept; AMREX_GPU_HOST_DEVICE - bool contains_inf (const Box& bx, int scomp, int ncomp) const; + bool contains_inf (const Box& bx, int scomp, int ncomp) const noexcept; /** * \brief These versions return the cell index (though not the component) of * the first location of an Inf if there is one. */ AMREX_GPU_HOST_DEVICE - bool contains_inf (IntVect& where) const; + bool contains_inf (IntVect& where) const noexcept; AMREX_GPU_HOST_DEVICE - bool contains_inf (const Box& bx, int scomp, int ncomp, IntVect& where) const; + bool contains_inf (const Box& bx, int scomp, int ncomp, IntVect& where) const noexcept; //! For debugging purposes we hide BaseFab version and do some extra work. void resize (const Box& b, int N = 1); - FabType getType () const { return m_type; } + FabType getType () const noexcept { return m_type; } //! Write FABs in ASCII form. friend std::ostream& operator<< (std::ostream& os, @@ -418,7 +418,7 @@ using FArrayBoxFactory = DefaultFabFactory; AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_nan () const +FArrayBox::contains_nan () const noexcept { const Real* dp = dptr; const long n = numPts()*nvar; @@ -433,7 +433,7 @@ FArrayBox::contains_nan () const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp) const +FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp) const noexcept { BL_ASSERT(scomp >= 0); BL_ASSERT(ncomp >= 1); @@ -456,7 +456,7 @@ FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp) const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_nan (IntVect& where) const +FArrayBox::contains_nan (IntVect& where) const noexcept { return contains_nan(domain, 0, nComp(), where); } @@ -464,7 +464,7 @@ FArrayBox::contains_nan (IntVect& where) const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp, IntVect& where) const +FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp, IntVect& where) const noexcept { BL_ASSERT(scomp >= 0); BL_ASSERT(ncomp >= 1); @@ -490,7 +490,7 @@ FArrayBox::contains_nan (const Box& bx, int scomp, int ncomp, IntVect& where) co AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_inf () const +FArrayBox::contains_inf () const noexcept { const Real* dp = dptr; const long n = numPts()*nvar; @@ -505,7 +505,7 @@ FArrayBox::contains_inf () const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_inf (const Box& bx, int scomp, int ncomp) const +FArrayBox::contains_inf (const Box& bx, int scomp, int ncomp) const noexcept { BL_ASSERT(scomp >= 0); BL_ASSERT(ncomp >= 1); @@ -528,7 +528,7 @@ FArrayBox::contains_inf (const Box& bx, int scomp, int ncomp) const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_inf (IntVect& where) const +FArrayBox::contains_inf (IntVect& where) const noexcept { return contains_inf(domain,0,nComp(),where); } @@ -536,7 +536,7 @@ FArrayBox::contains_inf (IntVect& where) const AMREX_GPU_HOST_DEVICE inline bool -FArrayBox::contains_inf (const Box& bx, int scomp, int ncomp, IntVect& where) const +FArrayBox::contains_inf (const Box& bx, int scomp, int ncomp, IntVect& where) const noexcept { BL_ASSERT(scomp >= 0); BL_ASSERT(ncomp >= 1); diff --git a/Src/Base/AMReX_FArrayBox.cpp b/Src/Base/AMReX_FArrayBox.cpp index 0148b2a7494..f73ea7e8dff 100644 --- a/Src/Base/AMReX_FArrayBox.cpp +++ b/Src/Base/AMReX_FArrayBox.cpp @@ -139,7 +139,7 @@ FABio::write_header (std::ostream& os, const FArrayBox& f, int nvar) const { - BL_PROFILE("FABio::write_header"); +// BL_PROFILE("FABio::write_header"); BL_ASSERT(nvar <= f.nComp()); amrex::StreamRetry sr(os, "FABio_write_header", 4); while(sr.TryOutput()) { @@ -151,7 +151,7 @@ FABio::Format FArrayBox::format; FABio* FArrayBox::fabio = 0; -FArrayBox::FArrayBox () {} +FArrayBox::FArrayBox () noexcept {} FArrayBox::FArrayBox (const Box& b, int n, @@ -177,21 +177,21 @@ FArrayBox::FArrayBox (const FArrayBox& rhs, MakeType make_type) } #endif -FArrayBox::FArrayBox (const Box& b, int ncomp, Real* p) +FArrayBox::FArrayBox (const Box& b, int ncomp, Real* p) noexcept : BaseFab(b,ncomp,p) { } FArrayBox& -FArrayBox::operator= (Real v) +FArrayBox::operator= (Real v) noexcept { BaseFab::operator=(v); return *this; } void -FArrayBox::initVal () +FArrayBox::initVal () noexcept { if (init_snan) { #ifdef BL_USE_DOUBLE @@ -473,7 +473,7 @@ FABio* FABio::read_header (std::istream& is, FArrayBox& f) { - BL_PROFILE("FArrayBox::read_header_is"); +// BL_PROFILE("FArrayBox::read_header_is"); int nvar; Box bx; FABio* fio = 0; @@ -550,7 +550,7 @@ FABio::read_header (std::istream& is, int compIndex, int& nCompAvailable) { - BL_PROFILE("FArrayBox::read_header_is_i"); +// BL_PROFILE("FArrayBox::read_header_is_i"); int nvar; Box bx; FABio *fio = 0; @@ -629,7 +629,7 @@ FArrayBox::writeOn (std::ostream& os, int comp, int num_comp) const { - BL_PROFILE("FArrayBox::writeOn"); +// BL_PROFILE("FArrayBox::writeOn"); BL_ASSERT(comp >= 0 && num_comp >= 1 && (comp+num_comp) <= nComp()); fabio->write_header(os, *this, num_comp); os.flush(); // 2016-08-30: Titan requires this flush() (probably due to a bug). @@ -639,7 +639,7 @@ FArrayBox::writeOn (std::ostream& os, void FArrayBox::readFrom (std::istream& is) { - BL_PROFILE("FArrayBox::readFrom_is"); +// BL_PROFILE("FArrayBox::readFrom_is"); FABio* fabrd = FABio::read_header(is, *this); fabrd->read(is, *this); delete fabrd; @@ -649,7 +649,7 @@ FArrayBox::readFrom (std::istream& is) int FArrayBox::readFrom (std::istream& is, int compIndex) { - BL_PROFILE("FArrayBox::readFrom_is_i"); +// BL_PROFILE("FArrayBox::readFrom_is_i"); int nCompAvailable; FABio* fabrd = FABio::read_header(is, *this, compIndex, nCompAvailable); BL_ASSERT(compIndex >= 0 && compIndex < nCompAvailable); @@ -891,7 +891,7 @@ FABio_binary::write_header (std::ostream& os, const FArrayBox& f, int nvar) const { - BL_PROFILE("FABio_binary::write_header"); +// BL_PROFILE("FABio_binary::write_header"); os << "FAB " << *realDesc; FABio::write_header(os, f, nvar); } @@ -900,7 +900,7 @@ void FABio_binary::read (std::istream& is, FArrayBox& f) const { - BL_PROFILE("FABio_binary::read"); +// BL_PROFILE("FABio_binary::read"); const long base_siz = f.box().numPts(); Real* comp_ptr = f.dataPtr(0); const long siz = base_siz*f.nComp(); @@ -916,7 +916,7 @@ FABio_binary::write (std::ostream& os, int comp, int num_comp) const { - BL_PROFILE("FABio_binary::write"); +// BL_PROFILE("FABio_binary::write"); BL_ASSERT(comp >= 0 && num_comp >= 1 && (comp+num_comp) <= f.nComp()); const long base_siz = f.box().numPts(); diff --git a/Src/Base/AMReX_FabArray.H b/Src/Base/AMReX_FabArray.H index 18c010e0d24..a4700096c6b 100644 --- a/Src/Base/AMReX_FabArray.H +++ b/Src/Base/AMReX_FabArray.H @@ -106,7 +106,7 @@ namespace amrex { // struct MFInfo { bool alloc = true; - MFInfo& SetAlloc(bool a) { alloc = a; return *this; } + MFInfo& SetAlloc(bool a) noexcept { alloc = a; return *this; } }; template @@ -214,9 +214,9 @@ public: const FabFactory& factory = DefaultFabFactory()); #endif - const FabFactory& Factory () const { return *m_factory; } + const FabFactory& Factory () const noexcept { return *m_factory; } - bool hasEBFabFactory () const { + bool hasEBFabFactory () const noexcept { #ifdef AMREX_USE_EB const auto f = dynamic_cast(m_factory.get()); return (f != nullptr); @@ -234,66 +234,72 @@ public: bool ok () const; //! Return a constant reference to the FAB associated with mfi. - const FAB& operator[] (const MFIter& mfi) const { return *(this->fabHostPtr(mfi)); } + const FAB& operator[] (const MFIter& mfi) const noexcept { return *(this->fabHostPtr(mfi)); } //! Return a constant reference to the FAB associated with mfi. - const FAB& get (const MFIter& mfi) const { return *(this->fabHostPtr(mfi)); } + const FAB& get (const MFIter& mfi) const noexcept { return *(this->fabHostPtr(mfi)); } //! Returns a reference to the FAB associated mfi. - FAB& operator[] (const MFIter& mfi) { return *(this->fabHostPtr(mfi)); } + FAB& operator[] (const MFIter& mfi) noexcept { return *(this->fabHostPtr(mfi)); } //! Returns a reference to the FAB associated mfi. - FAB& get (const MFIter& mfi) { return *(this->fabHostPtr(mfi)); } + FAB& get (const MFIter& mfi) noexcept { return *(this->fabHostPtr(mfi)); } //! Return a constant reference to the FAB associated with the Kth element. - const FAB& operator[] (int K) const { return *(this->fabHostPtr(K)); } + const FAB& operator[] (int K) const noexcept { return *(this->fabHostPtr(K)); } //! Return a constant reference to the FAB associated with the Kth element. - const FAB& get (int K) const { return *(this->fabHostPtr(K)); } + const FAB& get (int K) const noexcept { return *(this->fabHostPtr(K)); } //! Return a reference to the FAB associated with the Kth element. - FAB& operator[] (int K) { return *(this->fabHostPtr(K)); } + FAB& operator[] (int K) noexcept { return *(this->fabHostPtr(K)); } //! Return a reference to the FAB associated with the Kth element. - FAB& get (int K) { return *(this->fabHostPtr(K)); } + FAB& get (int K) noexcept { return *(this->fabHostPtr(K)); } //! Return pointer to FAB - FAB * fabPtr (const MFIter& mfi); - FAB const* fabPtr (const MFIter& mfi) const; - FAB * fabPtr (int K); - FAB const* fabPtr (int K) const; + FAB * fabPtr (const MFIter& mfi) noexcept; + FAB const* fabPtr (const MFIter& mfi) const noexcept; + FAB * fabPtr (int K) noexcept; + FAB const* fabPtr (int K) const noexcept; - FAB * fabHostPtr (const MFIter& mfi); - FAB const* fabHostPtr (const MFIter& mfi) const; - FAB * fabHostPtr (int K); - FAB const* fabHostPtr (int K) const; + FAB * fabHostPtr (const MFIter& mfi) noexcept; + FAB const* fabHostPtr (const MFIter& mfi) const noexcept; + FAB * fabHostPtr (int K) noexcept; + FAB const* fabHostPtr (int K) const noexcept; - FAB * fabDevicePtr (const MFIter& mfi); - FAB const* fabDevicePtr (const MFIter& mfi) const; - FAB * fabDevicePtr (int K); - FAB const* fabDevicePtr (int K) const; + FAB * fabDevicePtr (const MFIter& mfi) noexcept; + FAB const* fabDevicePtr (const MFIter& mfi) const noexcept; + FAB * fabDevicePtr (int K) noexcept; + FAB const* fabDevicePtr (int K) const noexcept; + + template ::value> > + void prefetchToHost (const MFIter& mfi) const noexcept; + + template ::value> > + void prefetchToDevice (const MFIter& mfi) const noexcept; template ::value,int>::type = 0 > - bool checkDataPtrConsistence (T const* d, T const* h) const { + bool checkDataPtrConsistence (T const* d, T const* h) const noexcept { return true; } // template ::value,int>::type = 0 > - bool checkDataPtrConsistence (T const* d, T const* h) const { + bool checkDataPtrConsistence (T const* d, T const* h) const noexcept { return d->dataPtr() == h->dataPtr(); } template ::value> > - Array4::value_type const> array (const MFIter& mfi) const; + Array4::value_type const> array (const MFIter& mfi) const noexcept; // template ::value> > - Array4::value_type> array (const MFIter& mfi); + Array4::value_type> array (const MFIter& mfi) noexcept; // template ::value> > - Array4::value_type const> array (int K) const; + Array4::value_type const> array (int K) const noexcept; // template ::value> > - Array4::value_type> array (int K); + Array4::value_type> array (int K) noexcept; //! Explicitly set the Kth FAB in the FabArray to point to elem. void setFab (int K, FAB* elem); @@ -575,8 +581,8 @@ public: //! Shift the boxarray by vector v void shift (const IntVect& v); - bool defined (int i) const; - bool defined (const MFIter& mfi) const; + bool defined (int i) const noexcept; + bool defined (const MFIter& mfi) const noexcept; /** * \brief Copy on intersection within a FabArray. Data is copied from @@ -648,7 +654,7 @@ protected: //! for shared memory struct ShMem { - ShMem () : alloc(false), n_values(0), n_points(0) + ShMem () noexcept : alloc(false), n_values(0), n_points(0) #if defined(BL_USE_MPI3) , win(MPI_WIN_NULL) #endif @@ -698,7 +704,7 @@ protected: }; ShMem shmem; - bool SharedMemory () const { return shmem.alloc; } + bool SharedMemory () const noexcept { return shmem.alloc; } private: typedef typename std::vector::iterator Iterator; @@ -762,7 +768,7 @@ public: template bool -FabArray::defined (int K) const +FabArray::defined (int K) const noexcept { int li = localindex(K); if (li >= 0 && li < m_fabs_v.size() && m_fabs_v[li] != 0) { @@ -775,7 +781,7 @@ FabArray::defined (int K) const template bool -FabArray::defined (const MFIter& mfi) const +FabArray::defined (const MFIter& mfi) const noexcept { int li = mfi.LocalIndex(); if (li < static_cast(m_fabs_v.size()) && m_fabs_v[li] != 0) { @@ -788,7 +794,7 @@ FabArray::defined (const MFIter& mfi) const template FAB* -FabArray::fabDevicePtr (const MFIter& mfi) +FabArray::fabDevicePtr (const MFIter& mfi) noexcept { BL_ASSERT(mfi.LocalIndex() < indexArray.size()); BL_ASSERT(DistributionMap() == mfi.DistributionMap()); @@ -799,7 +805,7 @@ FabArray::fabDevicePtr (const MFIter& mfi) template FAB const* -FabArray::fabDevicePtr (const MFIter& mfi) const +FabArray::fabDevicePtr (const MFIter& mfi) const noexcept { BL_ASSERT(mfi.LocalIndex() < indexArray.size()); BL_ASSERT(DistributionMap() == mfi.DistributionMap()); @@ -810,7 +816,7 @@ FabArray::fabDevicePtr (const MFIter& mfi) const template FAB* -FabArray::fabDevicePtr (int K) +FabArray::fabDevicePtr (int K) noexcept { int li = localindex(K); BL_ASSERT(li >=0 && li < indexArray.size()); @@ -820,7 +826,7 @@ FabArray::fabDevicePtr (int K) template FAB const* -FabArray::fabDevicePtr (int K) const +FabArray::fabDevicePtr (int K) const noexcept { int li = localindex(K); BL_ASSERT(li >=0 && li < indexArray.size()); @@ -829,7 +835,7 @@ FabArray::fabDevicePtr (int K) const template FAB* -FabArray::fabHostPtr (const MFIter& mfi) +FabArray::fabHostPtr (const MFIter& mfi) noexcept { BL_ASSERT(mfi.LocalIndex() < indexArray.size()); BL_ASSERT(DistributionMap() == mfi.DistributionMap()); @@ -844,7 +850,7 @@ FabArray::fabHostPtr (const MFIter& mfi) template FAB const* -FabArray::fabHostPtr (const MFIter& mfi) const +FabArray::fabHostPtr (const MFIter& mfi) const noexcept { BL_ASSERT(mfi.LocalIndex() < indexArray.size()); BL_ASSERT(DistributionMap() == mfi.DistributionMap()); @@ -859,7 +865,7 @@ FabArray::fabHostPtr (const MFIter& mfi) const template FAB* -FabArray::fabHostPtr (int K) +FabArray::fabHostPtr (int K) noexcept { int li = localindex(K); BL_ASSERT(li >=0 && li < indexArray.size()); @@ -873,7 +879,7 @@ FabArray::fabHostPtr (int K) template FAB const* -FabArray::fabHostPtr (int K) const +FabArray::fabHostPtr (int K) const noexcept { int li = localindex(K); BL_ASSERT(li >=0 && li < indexArray.size()); @@ -887,7 +893,7 @@ FabArray::fabHostPtr (int K) const template FAB* -FabArray::fabPtr (const MFIter& mfi) +FabArray::fabPtr (const MFIter& mfi) noexcept { #if AMREX_USE_GPU return (Gpu::inLaunchRegion()) ? this->fabDevicePtr(mfi) : this->fabHostPtr(mfi); @@ -898,7 +904,7 @@ FabArray::fabPtr (const MFIter& mfi) template FAB const* -FabArray::fabPtr (const MFIter& mfi) const +FabArray::fabPtr (const MFIter& mfi) const noexcept { #if AMREX_USE_GPU return (Gpu::inLaunchRegion()) ? this->fabDevicePtr(mfi) : this->fabHostPtr(mfi); @@ -909,7 +915,7 @@ FabArray::fabPtr (const MFIter& mfi) const template FAB* -FabArray::fabPtr (int K) +FabArray::fabPtr (int K) noexcept { #if AMREX_USE_GPU return (Gpu::inLaunchRegion()) ? this->fabDevicePtr(K) : this->fabHostPtr(K); @@ -920,7 +926,7 @@ FabArray::fabPtr (int K) template FAB const* -FabArray::fabPtr (int K) const +FabArray::fabPtr (int K) const noexcept { #if AMREX_USE_GPU return (Gpu::inLaunchRegion()) ? this->fabDevicePtr(K) : this->fabHostPtr(K); @@ -929,10 +935,30 @@ FabArray::fabPtr (int K) const #endif } +template +template +void +FabArray::prefetchToHost (const MFIter& mfi) const noexcept +{ +#ifdef AMREX_USE_CUDA + this->fabHostPtr(mfi)->prefetchToHost(); +#endif +} + +template +template +void +FabArray::prefetchToDevice (const MFIter& mfi) const noexcept +{ +#ifdef AMREX_USE_CUDA + this->fabHostPtr(mfi)->prefetchToDevice(); +#endif +} + template template Array4::value_type const> -FabArray::array (const MFIter& mfi) const +FabArray::array (const MFIter& mfi) const noexcept { return fabHostPtr(mfi)->array(); } @@ -940,7 +966,7 @@ FabArray::array (const MFIter& mfi) const template template Array4::value_type> -FabArray::array (const MFIter& mfi) +FabArray::array (const MFIter& mfi) noexcept { return fabHostPtr(mfi)->array(); } @@ -948,7 +974,7 @@ FabArray::array (const MFIter& mfi) template template Array4::value_type const> -FabArray::array (int K) const +FabArray::array (int K) const noexcept { return fabHostPtr(K)->array(); } @@ -956,7 +982,7 @@ FabArray::array (int K) const template template Array4::value_type> -FabArray::array (int K) +FabArray::array (int K) noexcept { return fabHostPtr(K)->array(); } diff --git a/Src/Base/AMReX_FabArrayBase.H b/Src/Base/AMReX_FabArrayBase.H index b6d2de4cdc5..fb1fed35a3d 100644 --- a/Src/Base/AMReX_FabArrayBase.H +++ b/Src/Base/AMReX_FabArrayBase.H @@ -61,48 +61,48 @@ public: const IntVect& ngrow); //! Return the grow factor that defines the region of definition. - int nGrow () const { return n_grow[0]; } + int nGrow () const noexcept { return n_grow[0]; } - IntVect nGrowVect () const { return n_grow; } + IntVect nGrowVect () const noexcept { return n_grow; } //! Return number of variables (aka components) associated with each point. - int nComp () const { return n_comp; } + int nComp () const noexcept { return n_comp; } //! Return index type. - IndexType ixType () const { return boxarray.ixType(); } + IndexType ixType () const noexcept { return boxarray.ixType(); } //Return whether this FabArray is empty - bool empty () const { return boxarray.empty(); } + bool empty () const noexcept { return boxarray.empty(); } /** * \brief Return a constant reference to the BoxArray that defines the * valid region associated with this FabArray. */ - const BoxArray& boxArray () const { return boxarray; } + const BoxArray& boxArray () const noexcept { return boxarray; } /** * \brief Return the Kth Box in the BoxArray. * That is, the valid region of the Kth grid. */ - Box box (int K) const { return boxarray[K]; } + Box box (int K) const noexcept { return boxarray[K]; } /** * \brief Return the Kth FABs Box in the FabArray. * That is, the region the Kth fab is actually defined on. */ - Box fabbox (int K) const; + Box fabbox (int K) const noexcept; //! Return the number of FABs in the FabArray. - int size () const { return boxarray.size(); } + int size () const noexcept { return boxarray.size(); } //! Return the number of local FABs in the FabArray. - int local_size () const { return indexArray.size(); } + int local_size () const noexcept { return indexArray.size(); } //! Return constant reference to indices in the FabArray that we have access. - const Vector &IndexArray () const { return indexArray; } + const Vector &IndexArray () const noexcept { return indexArray; } //! Return local index in the vector of FABs. - int localindex (int K) const { + int localindex (int K) const noexcept { std::vector::const_iterator low = std::lower_bound(indexArray.begin(), indexArray.end(), K); if (low != indexArray.end() && *low == K) { @@ -114,7 +114,7 @@ public: } //! Return constant reference to associated DistributionMapping. - const DistributionMapping& DistributionMap () const { return distributionMap; } + const DistributionMapping& DistributionMap () const noexcept { return distributionMap; } // struct CacheStats @@ -131,18 +131,18 @@ public: CacheStats (const std::string& name_) : size(0),maxsize(0),maxuse(0),nuse(0),nbuild(0),nerase(0), bytes(0L),bytes_hwm(0L),name(name_) {;} - void recordBuild () { + void recordBuild () noexcept { ++size; ++nbuild; maxsize = std::max(maxsize, size); } - void recordErase (int n) { + void recordErase (int n) noexcept { // n: how many times the item to be deleted has been used. --size; ++nerase; maxuse = std::max(maxuse, n); } - void recordUse () { ++nuse; } + void recordUse () noexcept { ++nuse; } void print () { amrex::Print(Print::AllProcs) << "### " << name << " ###\n" << " tot # of builds : " << nbuild << "\n" @@ -160,10 +160,10 @@ public: Box sbox; int dstIndex; int srcIndex; - CopyComTag () {} - CopyComTag (const Box& db, const Box& sb, int didx, int sidx) + CopyComTag () noexcept {} + CopyComTag (const Box& db, const Box& sb, int didx, int sidx) noexcept : dbox(db), sbox(sb), dstIndex(didx), srcIndex(sidx) {} - bool operator< (const CopyComTag& rhs) const { + bool operator< (const CopyComTag& rhs) const noexcept { return (srcIndex < rhs.srcIndex) || ((srcIndex == rhs.srcIndex) && ( (sbox.smallEnd() < rhs.sbox.smallEnd() || ((sbox.smallEnd() == rhs.sbox.smallEnd()) && ( @@ -191,17 +191,17 @@ public: * Objects with the same references have the same key. */ struct BDKey { - BDKey () = default; - BDKey (const BoxArray::RefID& baid, const DistributionMapping::RefID& dmid) + BDKey () noexcept = default; + BDKey (const BoxArray::RefID& baid, const DistributionMapping::RefID& dmid) noexcept : m_ba_id(baid), m_dm_id(dmid) {} - bool operator< (const BDKey& rhs) const { + bool operator< (const BDKey& rhs) const noexcept { return (m_ba_id < rhs.m_ba_id) || ((m_ba_id == rhs.m_ba_id) && (m_dm_id < rhs.m_dm_id)); } - bool operator== (const BDKey& rhs) const { + bool operator== (const BDKey& rhs) const noexcept { return m_ba_id == rhs.m_ba_id && m_dm_id == rhs.m_dm_id; } - bool operator!= (const BDKey& rhs) const { + bool operator!= (const BDKey& rhs) const noexcept { return m_ba_id != rhs.m_ba_id || m_dm_id != rhs.m_dm_id; } friend std::ostream& operator<< (std::ostream& os, const BDKey& id); @@ -210,7 +210,7 @@ public: DistributionMapping::RefID m_dm_id; }; - BDKey getBDKey () const { + BDKey getBDKey () const noexcept { return {boxarray.getRefID(), distributionMap.getRefID()}; } @@ -226,7 +226,7 @@ public: Vector localIndexMap; Vector localTileIndexMap; Vector tileArray; - TileArray () : nuse(-1) {;} + TileArray () noexcept : nuse(-1) {;} long bytes () const; }; @@ -248,7 +248,7 @@ public: int procThatHasData; Box box; - FabComTag () + FabComTag () noexcept : fromProc(0), toProc(0), @@ -385,15 +385,13 @@ protected: void clear (); - DistributionMapping& ModifyDistributionMap () { return distributionMap; } - /** * \brief Return owenership of fabs. The concept of ownership only applies when UPC++ * team is used. In that case, each fab is shared by team workers, with one * taking the ownership. */ - const std::vector& OwnerShip () const { return ownership; } - bool isOwner (int li) const { return ownership[li]; } + const std::vector& OwnerShip () const noexcept { return ownership; } + bool isOwner (int li) const noexcept { return ownership[li]; } // // The data ... @@ -546,20 +544,20 @@ protected: int max_num_boxarrays; int max_num_ba_use; long num_build; - FabArrayStats () : num_fabarrays(0), max_num_fabarrays(0), max_num_boxarrays(0), + FabArrayStats () noexcept : num_fabarrays(0), max_num_fabarrays(0), max_num_boxarrays(0), max_num_ba_use(1), num_build(0) {;} - void recordBuild () { + void recordBuild () noexcept { ++num_fabarrays; ++num_build; max_num_fabarrays = std::max(max_num_fabarrays, num_fabarrays); } - void recordDelete () { + void recordDelete () noexcept { --num_fabarrays; } - void recordMaxNumBoxArrays (int n) { + void recordMaxNumBoxArrays (int n) noexcept { max_num_boxarrays = std::max(max_num_boxarrays, n); } - void recordMaxNumBAUse (int n) { + void recordMaxNumBAUse (int n) noexcept { max_num_ba_use = std::max(max_num_ba_use, n); } void print () { diff --git a/Src/Base/AMReX_FabArrayBase.cpp b/Src/Base/AMReX_FabArrayBase.cpp index 4feffcf42d6..92656c0e940 100644 --- a/Src/Base/AMReX_FabArrayBase.cpp +++ b/Src/Base/AMReX_FabArrayBase.cpp @@ -197,7 +197,7 @@ FabArrayBase::clear () } Box -FabArrayBase::fabbox (int K) const +FabArrayBase::fabbox (int K) const noexcept { return amrex::grow(boxarray[K], n_grow); } @@ -359,7 +359,7 @@ FabArrayBase::CPC::define (const BoxArray& ba_dst, const DistributionMapping& dm auto& recv_tags = *m_RcvTags; - BaseFab localtouch, remotetouch; + BaseFab > localtouch, remotetouch; bool check_local = false, check_remote = false; #if defined(_OPENMP) if (omp_get_max_threads() > 1) { @@ -672,7 +672,7 @@ FabArrayBase::FB::define_fb(const FabArrayBase& fa) auto& recv_tags = *m_RcvTags; - BaseFab localtouch, remotetouch; + BaseFab > localtouch, remotetouch; bool check_local = false, check_remote = false; #if defined(_OPENMP) if (omp_get_max_threads() > 1) { @@ -879,7 +879,7 @@ FabArrayBase::FB::define_epo (const FabArrayBase& fa) auto& recv_tags = *m_RcvTags; - BaseFab localtouch, remotetouch; + BaseFab > localtouch, remotetouch; bool check_local = false, check_remote = false; #if defined(_OPENMP) if (omp_get_max_threads() > 1) { diff --git a/Src/Base/AMReX_FabFactory.H b/Src/Base/AMReX_FabFactory.H index 7e1e54dc479..0cd439fc043 100644 --- a/Src/Base/AMReX_FabFactory.H +++ b/Src/Base/AMReX_FabFactory.H @@ -24,12 +24,12 @@ struct FabInfo bool alloc = true; bool shared = false; - FabInfo& SetAlloc (bool a) { + FabInfo& SetAlloc (bool a) noexcept { alloc = a; return *this; } - FabInfo& SetShared (bool s) { + FabInfo& SetShared (bool s) noexcept { shared = s; return *this; } diff --git a/Src/Base/AMReX_FilCC_1D_C.H b/Src/Base/AMReX_FilCC_1D_C.H index a5d413bccfe..544cb8e6033 100644 --- a/Src/Base/AMReX_FilCC_1D_C.H +++ b/Src/Base/AMReX_FilCC_1D_C.H @@ -14,7 +14,7 @@ filcc_cell (const IntVect& iv, FArrayBox& dest_fab, const int dcomp, const int numcomp, GeometryData const& geom, const Real time, const BCRec* bcr, const int bcomp, - const int orig_comp) + const int orig_comp) noexcept { const int i = iv[0]; const auto q = dest_fab.view(iv,dcomp); diff --git a/Src/Base/AMReX_FilCC_2D_C.H b/Src/Base/AMReX_FilCC_2D_C.H index d0a5fa1ccbe..d3754251ad5 100644 --- a/Src/Base/AMReX_FilCC_2D_C.H +++ b/Src/Base/AMReX_FilCC_2D_C.H @@ -14,7 +14,7 @@ filcc_cell (const IntVect& iv, FArrayBox& dest_fab, const int dcomp, const int numcomp, GeometryData const& geom, const Real time, const BCRec* bcr, const int bcomp, - const int orig_comp) + const int orig_comp) noexcept { const int i = iv[0]; const int j = iv[1]; diff --git a/Src/Base/AMReX_FilCC_3D_C.H b/Src/Base/AMReX_FilCC_3D_C.H index 98cf3a7ddbe..9d21b76a623 100644 --- a/Src/Base/AMReX_FilCC_3D_C.H +++ b/Src/Base/AMReX_FilCC_3D_C.H @@ -14,7 +14,7 @@ filcc_cell (const IntVect& iv, FArrayBox& dest_fab, const int dcomp, const int numcomp, GeometryData const& geom, const Real time, const BCRec* bcr, const int bcomp, - const int orig_comp) + const int orig_comp) noexcept { const int i = iv[0]; const int j = iv[1]; diff --git a/Src/Base/AMReX_Geometry.H b/Src/Base/AMReX_Geometry.H index 3f392aba545..6d431794903 100644 --- a/Src/Base/AMReX_Geometry.H +++ b/Src/Base/AMReX_Geometry.H @@ -31,30 +31,30 @@ struct GeometryData { //! Returns the cellsize for each coordinate direction. AMREX_GPU_HOST_DEVICE AMREX_INLINE - const Real* CellSize () const { return dx; } + const Real* CellSize () const noexcept { return dx; } // AMREX_GPU_HOST_DEVICE AMREX_INLINE - Real CellSize (int dir) const { return dx[dir]; } + Real CellSize (int dir) const noexcept { return dx[dir]; } //! Returns the lo end of the problem domain in each dimension. AMREX_GPU_HOST_DEVICE AMREX_INLINE - const Real* ProbLo () const { return prob_domain.lo(); } + const Real* ProbLo () const noexcept { return prob_domain.lo(); } // AMREX_GPU_HOST_DEVICE AMREX_INLINE - Real ProbLo (int dir) const { return prob_domain.lo(dir); } + Real ProbLo (int dir) const noexcept { return prob_domain.lo(dir); } //! Returns the hi end of the problem domain in each dimension. AMREX_GPU_HOST_DEVICE AMREX_INLINE - const Real* ProbHi () const { return prob_domain.hi(); } + const Real* ProbHi () const noexcept { return prob_domain.hi(); } // AMREX_GPU_HOST_DEVICE AMREX_INLINE - Real ProbHi (int dir) const { return prob_domain.hi(dir); } + Real ProbHi (int dir) const noexcept { return prob_domain.hi(dir); } //! Returns our rectangular domain. AMREX_GPU_HOST_DEVICE AMREX_INLINE - const Box& Domain () const { return domain; } + const Box& Domain () const noexcept { return domain; } //! Returns whether the domain is periodic in the given direction. AMREX_GPU_HOST_DEVICE AMREX_INLINE - int isPeriodic (const int i) const { return is_periodic[i]; } + int isPeriodic (const int i) const noexcept { return is_periodic[i]; } //! Coordinates type - int Coord () const { return coord; } + int Coord () const noexcept { return coord; } public: RealBox prob_domain; @@ -70,23 +70,23 @@ class Geometry { public: //! The default constructor. - Geometry (); + Geometry () noexcept; //! Constructor taking the rectangular domain. explicit Geometry (const Box& dom, const RealBox* rb = nullptr, int coord = -1, - int const* is_per = nullptr); + int const* is_per = nullptr) noexcept; Geometry (const Box& dom, const RealBox& rb, int coord, - Array const& is_per); + Array const& is_per) noexcept; ~Geometry () = default; Geometry (const Geometry& rhs) = default; Geometry (Geometry&& rhs) noexcept = default; Geometry& operator= (const Geometry& rhs) = default; - Geometry& operator= (Geometry&& rhs) = default; + Geometry& operator= (Geometry&& rhs) noexcept = default; //! Returns non-static copy of geometry's stored data. - GeometryData data() const { + GeometryData data() const noexcept { return { prob_domain, domain, {AMREX_D_DECL(dx[0],dx[1],dx[2])}, {AMREX_D_DECL(is_periodic[0], is_periodic[1], is_periodic[2])}, static_cast(c_sys) }; @@ -98,41 +98,41 @@ public: //! Set the rectangular domain after using default constructor. void define (const Box& dom, const RealBox* rb = 0, int coord = -1, int const* is_per = nullptr); //! Returns the problem domain. - static const RealBox& ProbDomain () { return prob_domain; } + static const RealBox& ProbDomain () noexcept { return prob_domain; } //! Sets the problem domain. - static void ProbDomain (const RealBox& rb) + static void ProbDomain (const RealBox& rb) noexcept { prob_domain = rb; SetOffset(rb.lo()); } //! Returns the lo end of the problem domain in each dimension. - static const Real* ProbLo () { return prob_domain.lo(); } + static const Real* ProbLo () noexcept { return prob_domain.lo(); } //! Returns the hi end of the problem domain in each dimension. - static const Real* ProbHi () { return prob_domain.hi(); } + static const Real* ProbHi () noexcept { return prob_domain.hi(); } //! Returns the lo end of the problem domain in specified direction. - static Real ProbLo (int dir) { return prob_domain.lo(dir); } + static Real ProbLo (int dir) noexcept { return prob_domain.lo(dir); } //! Returns the hi end of the problem domain in specified direction. - static Real ProbHi (int dir) { return prob_domain.hi(dir); } + static Real ProbHi (int dir) noexcept { return prob_domain.hi(dir); } - static GpuArray ProbLoArray () { + static GpuArray ProbLoArray () noexcept { return {AMREX_D_DECL(prob_domain.lo(0),prob_domain.lo(1),prob_domain.lo(2))}; } - static GpuArray ProbHiArray () { + static GpuArray ProbHiArray () noexcept { return {AMREX_D_DECL(prob_domain.hi(0),prob_domain.hi(1),prob_domain.hi(2))}; } //! Returns the overall size of the domain by multiplying the ProbLength's together - static Real ProbSize () + static Real ProbSize () noexcept { return AMREX_D_TERM(prob_domain.length(0),*prob_domain.length(1),*prob_domain.length(2)); } //! Returns length of problem domain in specified dimension. - static Real ProbLength (int dir) { return prob_domain.length(dir); } + static Real ProbLength (int dir) noexcept { return prob_domain.length(dir); } //! Returns our rectangular domain. - const Box& Domain () const { return domain; } + const Box& Domain () const noexcept { return domain; } //! Sets our rectangular domain. - void Domain (const Box& bx) { domain = bx; } + void Domain (const Box& bx) noexcept { domain = bx; } //! Define a multifab of areas and volumes with given grow factor. void GetVolume (MultiFab& vol, const BoxArray& grds, @@ -173,32 +173,32 @@ public: int dir, int grow) const; //! Is the domain periodic in the specified direction? - static bool isPeriodic (int dir) { return is_periodic[dir] != 0; } + static bool isPeriodic (int dir) noexcept { return is_periodic[dir] != 0; } //! Is domain periodic in any direction? - static bool isAnyPeriodic () + static bool isAnyPeriodic () noexcept { return AMREX_D_TERM(isPeriodic(0),||isPeriodic(1),||isPeriodic(2)); } //! Is domain periodic in all directions? - static bool isAllPeriodic () + static bool isAllPeriodic () noexcept { return AMREX_D_TERM(isPeriodic(0),&&isPeriodic(1),&&isPeriodic(2)); } - static GpuArray isPeriodicArray () { + static GpuArray isPeriodicArray () noexcept { return {AMREX_D_DECL(static_cast(is_periodic[0]), static_cast(is_periodic[1]), static_cast(is_periodic[2]))}; } //! What's period in specified direction? - int period (int dir) const { BL_ASSERT(is_periodic[dir]); return domain.length(dir); } + int period (int dir) const noexcept { BL_ASSERT(is_periodic[dir]); return domain.length(dir); } - Periodicity periodicity () const { + Periodicity periodicity () const noexcept { return Periodicity(IntVect(AMREX_D_DECL(domain.length(0) * is_periodic[0], domain.length(1) * is_periodic[1], domain.length(2) * is_periodic[2]))); } - static Periodicity periodicity (const Box& b) { + static Periodicity periodicity (const Box& b) noexcept { AMREX_ASSERT(b.cellCentered()); return Periodicity(IntVect(AMREX_D_DECL(b.length(0) * is_periodic[0], b.length(1) * is_periodic[1], @@ -215,17 +215,17 @@ public: */ void periodicShift (const Box& target, const Box& src, - Vector& out) const; + Vector& out) const noexcept; //! Return domain box with non-periodic directions grown by ngrow. - Box growNonPeriodicDomain (int ngrow) const; + Box growNonPeriodicDomain (int ngrow) const noexcept; //! Return domain box with periodic directions grown by ngrow. - Box growPeriodicDomain (int ngrow) const; + Box growPeriodicDomain (int ngrow) const noexcept; //! Set periodicity flags and return the old flags. //! Note that, unlike Periodicity class, the flags are just boolean. //! - static Array setPeriodicity (Array const& period) { + static Array setPeriodicity (Array const& period) noexcept { Array r{AMREX_D_DECL(is_periodic[0], is_periodic[1], is_periodic[2])}; diff --git a/Src/Base/AMReX_Geometry.cpp b/Src/Base/AMReX_Geometry.cpp index 3c5e782391a..811c86dc285 100644 --- a/Src/Base/AMReX_Geometry.cpp +++ b/Src/Base/AMReX_Geometry.cpp @@ -49,18 +49,18 @@ operator>> (std::istream& is, return is; } -Geometry::Geometry () {} +Geometry::Geometry () noexcept {} Geometry::Geometry (const Box& dom, const RealBox* rb, int coord, - int const* is_per) + int const* is_per) noexcept { define(dom,rb,coord,is_per); } Geometry::Geometry (const Box& dom, const RealBox& rb, int coord, - Array const& is_per) + Array const& is_per) noexcept { define(dom, &rb, coord, is_per.data()); } @@ -254,7 +254,7 @@ Geometry::GetFaceArea (FArrayBox& area, void Geometry::periodicShift (const Box& target, const Box& src, - Vector& out) const + Vector& out) const noexcept { out.resize(0); @@ -330,7 +330,7 @@ Geometry::periodicShift (const Box& target, } Box -Geometry::growNonPeriodicDomain (int ngrow) const +Geometry::growNonPeriodicDomain (int ngrow) const noexcept { Box b = Domain(); for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { @@ -342,7 +342,7 @@ Geometry::growNonPeriodicDomain (int ngrow) const } Box -Geometry::growPeriodicDomain (int ngrow) const +Geometry::growPeriodicDomain (int ngrow) const noexcept { Box b = Domain(); for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { diff --git a/Src/Base/AMReX_GpuControl.H b/Src/Base/AMReX_GpuControl.H index 42aec3b9a83..8b6ce76b14c 100644 --- a/Src/Base/AMReX_GpuControl.H +++ b/Src/Base/AMReX_GpuControl.H @@ -12,10 +12,10 @@ namespace Cuda { extern bool in_launch_region; - inline bool inLaunchRegion () { return in_launch_region; } - inline bool notInLaunchRegion () { return !in_launch_region; } + inline bool inLaunchRegion () noexcept { return in_launch_region; } + inline bool notInLaunchRegion () noexcept { return !in_launch_region; } - inline bool setLaunchRegion (bool launch) { + inline bool setLaunchRegion (bool launch) noexcept { bool r = in_launch_region; in_launch_region = launch; return r; @@ -23,7 +23,7 @@ namespace Cuda { struct LaunchSafeGuard { - LaunchSafeGuard (bool flag) + LaunchSafeGuard (bool flag) noexcept : m_old(setLaunchRegion(in_launch_region && flag)) {} ~LaunchSafeGuard () { setLaunchRegion(m_old); } private: diff --git a/Src/Base/AMReX_GpuError.H b/Src/Base/AMReX_GpuError.H index 0ba95d02bfd..1f92b00a2ef 100644 --- a/Src/Base/AMReX_GpuError.H +++ b/Src/Base/AMReX_GpuError.H @@ -7,7 +7,7 @@ #if defined(AMREX_USE_CUDA) && !defined(AMREX_GPU_NO_ERROR_CHECK) namespace amrex { namespace Cuda { - inline void ErrorCheck (const char* file, int line) + inline void ErrorCheck (const char* file, int line) noexcept { cudaError_t err = cudaGetLastError(); if (cudaSuccess != err) { diff --git a/Src/Base/AMReX_IArrayBox.H b/Src/Base/AMReX_IArrayBox.H index b2904bb8da1..06e308d5bcb 100644 --- a/Src/Base/AMReX_IArrayBox.H +++ b/Src/Base/AMReX_IArrayBox.H @@ -36,7 +36,7 @@ class IArrayBox { public: //! Construct an invalid FAB with no memory. - IArrayBox (); + IArrayBox () noexcept; /** * \brief Construct an initial FAB with the data space allocated but * not inititialized. ncomp is the number of components @@ -63,7 +63,7 @@ public: IArrayBox& operator= (IArrayBox&&) = delete; //! Set the fab to the value r. - IArrayBox& operator= (int r); + IArrayBox& operator= (int r) noexcept; //! For debugging purposes we hide BaseFab version and do some extra work. void resize (const Box& b, diff --git a/Src/Base/AMReX_IArrayBox.cpp b/Src/Base/AMReX_IArrayBox.cpp index a7744c88fc4..e381366f3a2 100644 --- a/Src/Base/AMReX_IArrayBox.cpp +++ b/Src/Base/AMReX_IArrayBox.cpp @@ -43,7 +43,7 @@ IArrayBox::Finalize () initialized = false; } -IArrayBox::IArrayBox () {} +IArrayBox::IArrayBox () noexcept {} IArrayBox::IArrayBox (const Box& b, int n, @@ -73,7 +73,7 @@ IArrayBox::IArrayBox (const IArrayBox& rhs, MakeType make_type) #endif IArrayBox& -IArrayBox::operator= (int v) +IArrayBox::operator= (int v) noexcept { BaseFab::operator=(v); return *this; diff --git a/Src/Base/AMReX_IndexType.H b/Src/Base/AMReX_IndexType.H index 7249aa4197a..b40380abcac 100644 --- a/Src/Base/AMReX_IndexType.H +++ b/Src/Base/AMReX_IndexType.H @@ -28,10 +28,10 @@ public: enum CellIndex { CELL = 0, NODE = 1 }; //! The default constructor AMREX_GPU_HOST_DEVICE - constexpr IndexType () : itype(0) {} + constexpr IndexType () noexcept : itype(0) {} //! Construct an IndexType identical to an IntVect. AMREX_GPU_HOST_DEVICE - explicit IndexType (const IntVect& iv) + explicit IndexType (const IntVect& iv) noexcept : itype(AMREX_D_TERM((iv[0]?1:0), | ((iv[1]?1:0)<<1), | ((iv[2]?1:0)<<2))) {} /** @@ -40,67 +40,67 @@ public: * to take AMREX_SPACEDIM arguments. */ AMREX_GPU_HOST_DEVICE - constexpr IndexType (AMREX_D_DECL(CellIndex i, CellIndex j, CellIndex k)) + constexpr IndexType (AMREX_D_DECL(CellIndex i, CellIndex j, CellIndex k)) noexcept : itype(AMREX_D_TERM(i, | (j<<1), | (k<<2))) {} // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated. //! Set IndexType to be NODE based in direction dir. AMREX_GPU_HOST_DEVICE AMREX_INLINE - void set (int dir) { itype |= mask(dir); } + void set (int dir) noexcept { itype |= mask(dir); } //! Set IndexType to be CELL based in direction dir. AMREX_GPU_HOST_DEVICE AMREX_INLINE - void unset (int dir) { itype &= ~mask(dir); } + void unset (int dir) noexcept { itype &= ~mask(dir); } //! True if IndexType is NODE based in direction dir. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool test (int dir) const { return (itype & mask(dir)) != 0; } + bool test (int dir) const noexcept { return (itype & mask(dir)) != 0; } //! Set NODE based in all directions. AMREX_GPU_HOST_DEVICE AMREX_INLINE - void setall () { itype = (1 << AMREX_SPACEDIM) - 1; } + void setall () noexcept { itype = (1 << AMREX_SPACEDIM) - 1; } //! Set CELL based in all directions. AMREX_GPU_HOST_DEVICE AMREX_INLINE - void clear () { itype = 0; } + void clear () noexcept { itype = 0; } //! True if this IndexType is NODE based in any direction. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool any () const { return itype != 0; } + bool any () const noexcept { return itype != 0; } //! True if IndexType is valid. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool ok () const { return itype < (1 << AMREX_SPACEDIM); } + bool ok () const noexcept { return itype < (1 << AMREX_SPACEDIM); } //! Change from CELL to NODE or NODE to CELL in direction dir. AMREX_GPU_HOST_DEVICE AMREX_INLINE - void flip (int i) { itype ^= mask(i); } + void flip (int i) noexcept { itype ^= mask(i); } //! True if IndexTypes are identical. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator== (const IndexType& t) const { return t.itype == itype; } + bool operator== (const IndexType& t) const noexcept { return t.itype == itype; } //! True if IndexTypes are not identical. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator!= (const IndexType& t) const { return t.itype != itype; } + bool operator!= (const IndexType& t) const noexcept { return t.itype != itype; } AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator< (const IndexType& t) const { return itype < t.itype; } + bool operator< (const IndexType& t) const noexcept { return itype < t.itype; } //! True if the IndexType is CELL based in all directions. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool cellCentered () const { return itype == 0; } + bool cellCentered () const noexcept { return itype == 0; } //! True if the IndexType is CELL based in dir-direction. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool cellCentered (int dir) const { return (itype & mask(dir)) == 0; } + bool cellCentered (int dir) const noexcept { return (itype & mask(dir)) == 0; } //! True if the IndexType is NODE based in all directions. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool nodeCentered () const { return itype == (1<> dir); } + CellIndex ixType (int dir) const noexcept { return (CellIndex) ((itype & (1<> dir); } //! Return an integer representing the IndexType in direction dir. AMREX_GPU_HOST_DEVICE AMREX_INLINE - int operator[] (int dir) const { return test(dir); } + int operator[] (int dir) const noexcept { return test(dir); } //! Fill an IntVect of size AMREX_SPACEDIM with IndexTypes. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect ixType () const { return IntVect(AMREX_D_DECL(itype&1, (itype>>1)&1, (itype>>2)&1)); } + IntVect ixType () const noexcept { return IntVect(AMREX_D_DECL(itype&1, (itype>>1)&1, (itype>>2)&1)); } /** * \brief This static member function returns an IndexType object of value * IndexType::CELL. It is provided as a convenience to our users @@ -108,7 +108,7 @@ public: * IndexType::CELL. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IndexType TheCellType () { + static constexpr IndexType TheCellType () noexcept { return IndexType(AMREX_D_DECL(IndexType::CELL, IndexType::CELL, IndexType::CELL)); @@ -120,7 +120,7 @@ public: * IndexType::NODE. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IndexType TheNodeType () { + static constexpr IndexType TheNodeType () noexcept { return IndexType(AMREX_D_DECL(IndexType::NODE, IndexType::NODE, IndexType::NODE)); @@ -129,7 +129,7 @@ public: private: //! Returns 1<=8 ? 20 : 10; static constexpr unsigned shift2 = sizeof(size_t)>=8 ? 40 : 20; public: - std::size_t operator()(const IntVect& vec) const + std::size_t operator()(const IntVect& vec) const noexcept { AMREX_D_DECL(std::size_t ret0 = vec[0], ret1 = vec[1], ret2 = vec[2]); #if AMREX_SPACEDIM == 1 @@ -71,7 +71,7 @@ public: * \brief Construct an IntVect whose components are all zero. */ AMREX_GPU_HOST_DEVICE - constexpr IntVect () : vect{AMREX_D_DECL(0,0,0)} {} + constexpr IntVect () noexcept : vect{AMREX_D_DECL(0,0,0)} {} /** * \brief Construct an IntVect given the specific values for its @@ -79,11 +79,11 @@ public: * to take AMREX_SPACEDIM arguments. */ AMREX_GPU_HOST_DEVICE - constexpr IntVect (AMREX_D_DECL(int i, int j, int k)) : vect{AMREX_D_DECL(i,j,k)} {} + constexpr IntVect (AMREX_D_DECL(int i, int j, int k)) noexcept : vect{AMREX_D_DECL(i,j,k)} {} #if (AMREX_SPACEDIM > 1) AMREX_GPU_HOST_DEVICE - explicit constexpr IntVect (int i) : vect{AMREX_D_DECL(i,i,i)} {} + explicit constexpr IntVect (int i) noexcept : vect{AMREX_D_DECL(i,i,i)} {} #endif /** @@ -91,21 +91,21 @@ public: * corresponding values in the integer array a. */ AMREX_GPU_HOST_DEVICE - explicit IntVect (const int* a) : vect{AMREX_D_DECL(a[0],a[1],a[2])} {} + explicit IntVect (const int* a) noexcept : vect{AMREX_D_DECL(a[0],a[1],a[2])} {} /** * \brief Construct an IntVect from an Vector. It is an error if * the Vector doesn' t have the same dimension as this * IntVect. */ - explicit IntVect (const Vector& a) : vect{AMREX_D_DECL(a[0],a[1],a[2])} { + explicit IntVect (const Vector& a) noexcept : vect{AMREX_D_DECL(a[0],a[1],a[2])} { BL_ASSERT(a.size() == AMREX_SPACEDIM); } // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated. AMREX_GPU_HOST_DEVICE AMREX_INLINE - Dim3 dim3 () const { + Dim3 dim3 () const noexcept { #if (AMREX_SPACEDIM == 1) return Dim3{vect[0],0,0}; #elif (AMREX_SPACEDIM == 2) @@ -120,7 +120,7 @@ public: Sum of all components of this IntVect. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - int sum () const + int sum () const noexcept { int retval = AMREX_D_TERM((*this)[0], + (*this)[1], +(*this)[2]); return retval; @@ -128,7 +128,7 @@ public: //! maximum (no absolute values) value AMREX_GPU_HOST_DEVICE AMREX_INLINE - int max() const + int max() const noexcept { #if (AMREX_SPACEDIM == 1) return vect[0]; @@ -142,7 +142,7 @@ public: //! minimum (no absolute values) value AMREX_GPU_HOST_DEVICE AMREX_INLINE - int min() const + int min() const noexcept { #if (AMREX_SPACEDIM == 1) return vect[0]; @@ -156,19 +156,19 @@ public: //return coordinate with largest value AMREX_GPU_HOST_DEVICE AMREX_INLINE - int maxDir(bool a_doAbsValue) const; + int maxDir(bool a_doAbsValue) const noexcept; //! Returns a reference to the i'th coordinate of the IntVect. AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - int& operator[] (int i) { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } + int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } //! Returns the i'th coordinate of the IntVect. AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - const int& operator[] (int i) const { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } + const int& operator[] (int i) const noexcept { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } //! Set i'th coordinate of IntVect to val. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& setVal (int i, int val) + IntVect& setVal (int i, int val) noexcept { BL_ASSERT(i >=0 && i < AMREX_SPACEDIM); vect[i] = val; return *this; } @@ -178,41 +178,41 @@ public: * IntVect. Useful for arguments to FORTRAN calls. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - const int* getVect () const& { return vect; } + const int* getVect () const& noexcept { return vect; } AMREX_GPU_HOST_DEVICE AMREX_INLINE - int* getVect () & { return vect; } + int* getVect () & noexcept { return vect; } AMREX_GPU_HOST_DEVICE int* getVect () && = delete; //! Returns true if all components are equal to the argument val. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator== (int val) const + bool operator== (int val) const noexcept { return AMREX_D_TERM(vect[0] == val, && vect[1] == val, && vect[2] == val); } //! Returns true if any component is not equal to the argument val. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator!= (int val) const + bool operator!= (int val) const noexcept { return AMREX_D_TERM(vect[0] != val, || vect[1] != val, || vect[2] != val); } //! Returns true if this is equivalent to rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator== (const IntVect& rhs) const + bool operator== (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] == rhs[0], && vect[1] == rhs[1], && vect[2] == rhs[2]); } //! Returns true if this is different from rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator!= (const IntVect& rhs) const + bool operator!= (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] != rhs[0], || vect[1] != rhs[1], || vect[2] != rhs[2]); } //! Return ture if this is lexicographically less than rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator< (const IntVect& rhs) const + bool operator< (const IntVect& rhs) const noexcept { #if (AMREX_SPACEDIM == 1) return vect[0] < rhs[0]; @@ -225,19 +225,19 @@ public: } //! Return true if this is lexicographically less than or equal to rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator<= (const IntVect& rhs) const + bool operator<= (const IntVect& rhs) const noexcept { return !(rhs < *this); } //! Retrun true if this is lexicographically greater than rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator> (const IntVect& rhs) const + bool operator> (const IntVect& rhs) const noexcept { return rhs < *this; } //! Retrun true if this is lexicographically greater than or equal to rhs. AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool operator>= (const IntVect& rhs) const + bool operator>= (const IntVect& rhs) const noexcept { return !(*this < rhs); } @@ -246,7 +246,7 @@ public: * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool allLT (const IntVect& rhs) const + bool allLT (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] < rhs[0], && vect[1] < rhs[1], && vect[2] < rhs[2]); } @@ -255,7 +255,7 @@ public: * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool allLE (const IntVect& rhs) const + bool allLE (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] <= rhs[0], && vect[1] <= rhs[1], && vect[2] <= rhs[2]); } @@ -264,7 +264,7 @@ public: * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool allGT (const IntVect& rhs) const + bool allGT (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] > rhs[0], && vect[1] > rhs[1], && vect[2] > rhs[2]); } @@ -273,115 +273,115 @@ public: * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - bool allGE (const IntVect& rhs) const + bool allGE (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] >= rhs[0], && vect[1] >= rhs[1], && vect[2] >= rhs[2]); } //! Unary plus -- for completeness. AMREX_GPU_HOST_DEVICE AMREX_INLINE - const IntVect operator+ () const { return *this; } + const IntVect operator+ () const noexcept { return *this; } //! Unary Minus -- negates all components. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator- () const { return IntVect(AMREX_D_DECL(-vect[0], -vect[1], -vect[2] )); } + IntVect operator- () const noexcept { return IntVect(AMREX_D_DECL(-vect[0], -vect[1], -vect[2] )); } //! Modifies IntVect by addition of a scalar to each component. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator+= (int s) + IntVect& operator+= (int s) noexcept { AMREX_D_EXPR(vect[0] += s, vect[1] += s, vect[2] += s); return *this; } //! Modifies IntVect by component-wise addition with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator+= (const IntVect& p) + IntVect& operator+= (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] += p[0], vect[1] += p[1], vect[2] += p[2]); return *this; } //! Modifies IntVect by multiplication of a scalar to each component. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator*= (int s) + IntVect& operator*= (int s) noexcept { AMREX_D_EXPR(vect[0] *= s, vect[1] *= s, vect[2] *= s); return *this; } //! Modifies IntVect by component-wise multiplication with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator*= (const IntVect& p) + IntVect& operator*= (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] *= p[0], vect[1] *= p[1], vect[2] *= p[2]); return *this; } //! Modifies IntVect by division by a scalar to each component. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator/= (int s) + IntVect& operator/= (int s) noexcept { AMREX_D_EXPR(vect[0] /= s, vect[1] /= s, vect[2] /= s); return *this; } //! Modifies IntVect by component-wise division with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator/= (const IntVect& p) + IntVect& operator/= (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] /= p[0], vect[1] /= p[1], vect[2] /= p[2]); return *this; } //! Modifies IntVect by subtraction of a scalar to each component. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator-= (int s) + IntVect& operator-= (int s) noexcept { AMREX_D_EXPR(vect[0] -= s, vect[1] -= s, vect[2] -= s); return *this; } //! Modifies IntVect by component-wise subtraction with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& operator-= (const IntVect& p) + IntVect& operator-= (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] -= p[0], vect[1] -= p[1], vect[2] -= p[2]); return *this; } //! Returns component-wise sum of IntVect and argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator+ (const IntVect& p) const + IntVect operator+ (const IntVect& p) const noexcept { return IntVect(AMREX_D_DECL(vect[0] + p[0], vect[1] + p[1], vect[2] + p[2])); } //! Return an IntVect that is this IntVect + s. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator+ (int s) const + IntVect operator+ (int s) const noexcept { return IntVect(AMREX_D_DECL(vect[0] + s, vect[1] + s, vect[2] + s)); } //! Returns component-wise difference of IntVect and argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator- (const IntVect& p) const + IntVect operator- (const IntVect& p) const noexcept { return IntVect(AMREX_D_DECL(vect[0] - p[0], vect[1] - p[1], vect[2] - p[2])); } //! Return an IntVect that is this IntVect - s. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator- (int s) const + IntVect operator- (int s) const noexcept { return IntVect(AMREX_D_DECL(vect[0] - s, vect[1] - s, vect[2] - s)); } //! Returns component-wise product of IntVect and argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator* (const IntVect& p) const + IntVect operator* (const IntVect& p) const noexcept { return IntVect(AMREX_D_DECL(vect[0] * p[0], vect[1] * p[1], vect[2] * p[2])); } //! Returns component-wise product of IntVect and s. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator* (int s) const + IntVect operator* (int s) const noexcept { return IntVect(AMREX_D_DECL(vect[0] * s, vect[1] * s, vect[2] * s)); } //! Returns component-wise division of IntVect by argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator/ (const IntVect& p) const + IntVect operator/ (const IntVect& p) const noexcept { return IntVect(AMREX_D_DECL(vect[0] / p[0], vect[1] / p[1], vect[2] / p[2])); } //! Returns component-wise division of IntVect by s. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect operator/ (int s) const + IntVect operator/ (int s) const noexcept { return IntVect(AMREX_D_DECL(vect[0] / s, vect[1] / s, vect[2] / s)); } //! Modifies IntVect by taking component-wise min with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& min (const IntVect& p) + IntVect& min (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] = (vect[0] < p.vect[0] ? vect[0] : p.vect[0]), vect[1] = (vect[1] < p.vect[1] ? vect[1] : p.vect[1]), @@ -390,7 +390,7 @@ public: } //! Modifies IntVect by taking component-wise max with argument. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& max (const IntVect& p) + IntVect& max (const IntVect& p) noexcept { AMREX_D_EXPR(vect[0] = (vect[0] > p.vect[0] ? vect[0] : p.vect[0]), vect[1] = (vect[1] > p.vect[1] ? vect[1] : p.vect[1]), @@ -399,13 +399,13 @@ public: } //! Modify IntVect by multiplying each coordinate by s. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& scale (int s) { AMREX_D_EXPR(vect[0] *= s, vect[1] *= s, vect[2] *= s); return *this; } + IntVect& scale (int s) noexcept { AMREX_D_EXPR(vect[0] *= s, vect[1] *= s, vect[2] *= s); return *this; } /** * \brief Modify IntVect by reflecting it in the plane defined by * the index ref_ix and with normal in the direction of idir. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& reflect (int ref_ix, int idir) + IntVect& reflect (int ref_ix, int idir) noexcept { BL_ASSERT(idir >= 0 && idir < AMREX_SPACEDIM); vect[idir] = -vect[idir] + 2*ref_ix; @@ -413,37 +413,37 @@ public: } //! Modify IntVect by adding s to given coordinate. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& shift (int coord, int s) + IntVect& shift (int coord, int s) noexcept { BL_ASSERT(coord >= 0 && coord < AMREX_SPACEDIM); vect[coord] += s; return *this; } //! Equivalent to shift(0,iv[0]).shift(1,iv[1]) ... AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& shift (const IntVect& iv) { *this += iv; return *this; } + IntVect& shift (const IntVect& iv) noexcept { *this += iv; return *this; } //! Modify IntVect by adding s to each coordinate. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& diagShift (int s) + IntVect& diagShift (int s) noexcept { AMREX_D_EXPR(vect[0] += s, vect[1] += s, vect[2] += s); return *this; } //! Modify IntVect by component-wise integer projection. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& coarsen (const IntVect& p); + IntVect& coarsen (const IntVect& p) noexcept; //! Modify IntVect by component-wise integer projection. AMREX_GPU_HOST_DEVICE AMREX_INLINE - IntVect& coarsen (int p); + IntVect& coarsen (int p) noexcept; //! for serialization static size_t AMREX_INLINE - linearSize() + linearSize() noexcept { size_t retval = AMREX_SPACEDIM*sizeof(int); return retval; } //! for serialization - void linearOut(void* a_buffer ) const; - void linearIn(void* a_buffer ); + void linearOut(void* a_buffer ) const noexcept; + void linearIn(void* a_buffer ) noexcept; /** * \brief This static member function returns a reference to a constant IntVect @@ -452,7 +452,7 @@ public: * It is provided as a convenient way to specify the zero vector. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheZeroVector () { + static constexpr IntVect TheZeroVector () noexcept { return IntVect(0); } /** @@ -462,7 +462,7 @@ public: * It is provided as a convenient way to specify the unit vector. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheUnitVector () { + static constexpr IntVect TheUnitVector () noexcept { return IntVect(1); } /** @@ -471,7 +471,7 @@ public: * the d-direction is set to one. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheDimensionVector (int d) { + static constexpr IntVect TheDimensionVector (int d) noexcept { return (d==0) ? IntVect(AMREX_D_DECL(1,0,0)) : ((d==1) ? IntVect(AMREX_D_DECL(0,1,0)) : IntVect(AMREX_D_DECL(0,0,1))); @@ -482,7 +482,7 @@ public: * It is provided as a convenience to our users when defining Boxes. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheNodeVector () { + static constexpr IntVect TheNodeVector () noexcept { return IntVect(1); } /** @@ -491,12 +491,12 @@ public: * It is provided as a convenience to our users when defining Boxes. */ AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheCellVector () { + static constexpr IntVect TheCellVector () noexcept { return IntVect(0); } AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheMaxVector () { + static constexpr IntVect TheMaxVector () noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) return IntVect(std::numeric_limits::max()); #else @@ -504,7 +504,7 @@ public: #endif } AMREX_GPU_HOST_DEVICE AMREX_INLINE - static constexpr IntVect TheMinVector () { + static constexpr IntVect TheMinVector () noexcept { #if !defined(__CUDACC__) || (__CUDACC_VER_MAJOR__ != 9) || (__CUDACC_VER_MINOR__ != 2) return IntVect(std::numeric_limits::lowest()); #else @@ -522,7 +522,7 @@ private: AMREX_INLINE IntVect& -IntVect::coarsen (int s) +IntVect::coarsen (int s) noexcept { BL_ASSERT(s > 0); return this->coarsen(IntVect(AMREX_D_DECL(s,s,s))); @@ -530,7 +530,7 @@ IntVect::coarsen (int s) AMREX_INLINE IntVect& -IntVect::coarsen (const IntVect& p) +IntVect::coarsen (const IntVect& p) noexcept { BL_ASSERT(p.allGT(IntVect::TheZeroVector())); if (p != 1) { @@ -545,7 +545,7 @@ IntVect::coarsen (const IntVect& p) AMREX_INLINE int -IntVect::maxDir(bool a_doAbsValue) const +IntVect::maxDir(bool a_doAbsValue) const noexcept { int retval = 0; if(a_doAbsValue) @@ -579,7 +579,7 @@ IntVect::maxDir(bool a_doAbsValue) const AMREX_INLINE void -IntVect::linearOut(void* a_buffer ) const +IntVect::linearOut(void* a_buffer ) const noexcept { int* intbuf = (int *) a_buffer; const IntVect& iv = *this; @@ -592,7 +592,7 @@ IntVect::linearOut(void* a_buffer ) const AMREX_INLINE void -IntVect::linearIn(void* a_buffer ) +IntVect::linearIn(void* a_buffer ) noexcept { int* intbuf = (int *) a_buffer; IntVect& iv = *this; @@ -606,7 +606,7 @@ IntVect::linearIn(void* a_buffer ) //! Returns p + s. AMREX_GPU_HOST_DEVICE AMREX_INLINE -IntVect operator+ (int s, const IntVect& p) +IntVect operator+ (int s, const IntVect& p) noexcept { return IntVect(AMREX_D_DECL(p[0] + s, p[1] + s, p[2] + s)); } @@ -614,14 +614,14 @@ IntVect operator+ (int s, const IntVect& p) AMREX_GPU_HOST_DEVICE AMREX_INLINE AMREX_GPU_HOST_DEVICE -IntVect operator- (int s, const IntVect& p) +IntVect operator- (int s, const IntVect& p) noexcept { return IntVect(AMREX_D_DECL(s - p[0], s - p[1], s - p[2])); } //! Returns p * s. AMREX_GPU_HOST_DEVICE AMREX_INLINE -IntVect operator* (int s, const IntVect& p) +IntVect operator* (int s, const IntVect& p) noexcept { return IntVect(AMREX_D_DECL(s * p[0], s * p[1], s * p[2])); } @@ -633,8 +633,7 @@ IntVect operator* (int s, const IntVect& p) AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -min (const IntVect& p1, - const IntVect& p2) +min (const IntVect& p1, const IntVect& p2) noexcept { IntVect p(p1); p.min(p2); @@ -648,8 +647,7 @@ min (const IntVect& p1, AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -max (const IntVect& p1, - const IntVect& p2) +max (const IntVect& p1, const IntVect& p2) noexcept { IntVect p(p1); p.max(p2); @@ -664,7 +662,7 @@ max (const IntVect& p1, AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -BASISV (int dir) +BASISV (int dir) noexcept { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); IntVect tmp; @@ -679,7 +677,7 @@ BASISV (int dir) AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -scale (const IntVect& p, int s) +scale (const IntVect& p, int s) noexcept { return IntVect(AMREX_D_DECL(s * p[0], s * p[1], s * p[2])); } @@ -692,9 +690,7 @@ scale (const IntVect& p, int s) AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -reflect (const IntVect& a, - int ref_ix, - int idir) +reflect (const IntVect& a, int ref_ix, int idir) noexcept { BL_ASSERT(idir >= 0 && idir < AMREX_SPACEDIM); IntVect b(a); @@ -709,7 +705,7 @@ reflect (const IntVect& a, AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -diagShift (const IntVect& p, int s) +diagShift (const IntVect& p, int s) noexcept { return IntVect(AMREX_D_DECL(p[0] + s, p[1] + s, p[2] + s)); } @@ -721,8 +717,7 @@ diagShift (const IntVect& p, int s) AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -coarsen (const IntVect& p, - int s) +coarsen (const IntVect& p, int s) noexcept { BL_ASSERT(s > 0); IntVect v = p; @@ -737,8 +732,7 @@ coarsen (const IntVect& p, AMREX_GPU_HOST_DEVICE AMREX_INLINE IntVect -coarsen (const IntVect& p1, - const IntVect& p2) +coarsen (const IntVect& p1, const IntVect& p2) noexcept { IntVect v = p1; v.coarsen(p2); @@ -746,7 +740,7 @@ coarsen (const IntVect& p1, } AMREX_GPU_HOST_DEVICE AMREX_INLINE -Dim3 refine (Dim3 const& coarse, IntVect const& ratio) +Dim3 refine (Dim3 const& coarse, IntVect const& ratio) noexcept { #if (AMREX_SPACEDIM == 1) return {coarse.x*ratio[0], coarse.y, coarse.z}; @@ -758,13 +752,13 @@ Dim3 refine (Dim3 const& coarse, IntVect const& ratio) } AMREX_GPU_HOST_DEVICE AMREX_INLINE -int coarsen (int i, int ratio) +int coarsen (int i, int ratio) noexcept { return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio; } AMREX_GPU_HOST_DEVICE AMREX_INLINE -Dim3 coarsen (Dim3 const& fine, IntVect const& ratio) +Dim3 coarsen (Dim3 const& fine, IntVect const& ratio) noexcept { #if (AMREX_SPACEDIM == 1) return {amrex::coarsen(fine.x,ratio[0]), fine.y, fine.z}; diff --git a/Src/Base/AMReX_LayoutData.H b/Src/Base/AMReX_LayoutData.H index afe2334180e..949c5cb56ce 100644 --- a/Src/Base/AMReX_LayoutData.H +++ b/Src/Base/AMReX_LayoutData.H @@ -80,7 +80,7 @@ namespace amrex return *this; } - T& operator[](const MFIter& a_mfi) + T& operator[](const MFIter& a_mfi) noexcept { BL_ASSERT(a_mfi.LocalIndex() < m_data.size()); BL_ASSERT(DistributionMap() == a_mfi.DistributionMap()); @@ -88,14 +88,14 @@ namespace amrex } - const T& operator[](const MFIter& a_mfi) const + const T& operator[](const MFIter& a_mfi) const noexcept { BL_ASSERT(a_mfi.LocalIndex() < m_data.size()); BL_ASSERT(DistributionMap() == a_mfi.DistributionMap()); return (m_data[a_mfi.LocalIndex()]); } - T& operator[](int a_box_index) + T& operator[](int a_box_index) noexcept { int local_index = this->localindex(a_box_index); BL_ASSERT(local_index < m_data.size()); @@ -103,7 +103,7 @@ namespace amrex } - const T& operator[](int a_box_index) const + const T& operator[](int a_box_index) const noexcept { int local_index = this->localindex(a_box_index); BL_ASSERT(local_index < m_data.size()); diff --git a/Src/Base/AMReX_MFIter.H b/Src/Base/AMReX_MFIter.H index 63eb810cc1c..fcab0185a4e 100644 --- a/Src/Base/AMReX_MFIter.H +++ b/Src/Base/AMReX_MFIter.H @@ -18,9 +18,9 @@ namespace amrex { #ifdef AMREX_USE_GPU - inline bool TilingIfNotGPU () { return Gpu::notInLaunchRegion(); } + inline bool TilingIfNotGPU () noexcept { return Gpu::notInLaunchRegion(); } #else - inline constexpr bool TilingIfNotGPU () { return true; } + inline constexpr bool TilingIfNotGPU () noexcept { return true; } #endif template class FabArray; @@ -30,14 +30,14 @@ struct MFItInfo bool do_tiling; bool dynamic; IntVect tilesize; - MFItInfo () + MFItInfo () noexcept : do_tiling(false), dynamic(false), tilesize(IntVect::TheZeroVector()) {} - MFItInfo& EnableTiling (const IntVect& ts = FabArrayBase::mfiter_tile_size) { + MFItInfo& EnableTiling (const IntVect& ts = FabArrayBase::mfiter_tile_size) noexcept { do_tiling = true; tilesize = ts; return *this; } - MFItInfo& SetDynamic (bool f) { + MFItInfo& SetDynamic (bool f) noexcept { dynamic = f; return *this; } @@ -100,50 +100,50 @@ public: ~MFIter (); //! Return the tile Box at the current index. - Box tilebox () const; + Box tilebox () const noexcept; //! Return the tilebox with provided nodal flag - Box tilebox (const IntVect& nodal) const; + Box tilebox (const IntVect& nodal) const noexcept; //! Return the tilebox with provided nodal flag and grown cells - Box tilebox (const IntVect& nodal, const IntVect& ngrow) const; + Box tilebox (const IntVect& nodal, const IntVect& ngrow) const noexcept; //! Return the dir-nodal (or all nodal if dir<0) Box at the current index. - Box nodaltilebox (int dir=-1) const; + Box nodaltilebox (int dir=-1) const noexcept; //! Return the tile box at the current index grown to include ghost cells. - Box growntilebox (int ng=-1000000) const; + Box growntilebox (int ng=-1000000) const noexcept; - Box growntilebox (const IntVect& ng) const; + Box growntilebox (const IntVect& ng) const noexcept; //! Return the dir-nodal (or all nodal if dir<0) box grown to include ghost cells. - Box grownnodaltilebox (int dir=-1, int ng=-1000000) const; + Box grownnodaltilebox (int dir=-1, int ng=-1000000) const noexcept; - Box grownnodaltilebox (int dir, const IntVect& ng) const; + Box grownnodaltilebox (int dir, const IntVect& ng) const noexcept; //! Return the valid Box in which the current tile resides. - Box validbox () const { return fabArray.box((*index_map)[currentIndex]); } + Box validbox () const noexcept { return fabArray.box((*index_map)[currentIndex]); } //! Return the Box of the FAB at which we currently point. - Box fabbox () const { return fabArray.fabbox((*index_map)[currentIndex]); } + Box fabbox () const noexcept { return fabArray.fabbox((*index_map)[currentIndex]); } //! Increment iterator to the next tile we own. - void operator++ (); + void operator++ () noexcept; //! Is the iterator valid i.e. is it associated with a FAB? - bool isValid () const { return currentIndex < endIndex; } + bool isValid () const noexcept { return currentIndex < endIndex; } //! The index into the underlying BoxArray of the current FAB. - int index () const { return (*index_map)[currentIndex]; } + int index () const noexcept { return (*index_map)[currentIndex]; } //! The number of indices. - int length () const { return (endIndex - beginIndex); } + int length () const noexcept { return (endIndex - beginIndex); } //! The current local tile index in the current grid; - int LocalTileIndex () const {return local_tile_index_map ? (*local_tile_index_map)[currentIndex] : 0;} + int LocalTileIndex () const noexcept {return local_tile_index_map ? (*local_tile_index_map)[currentIndex] : 0;} //! The the number of tiles in the current grid; - int numLocalTiles() const {return num_local_tiles ? (*num_local_tiles)[currentIndex] : 1;} + int numLocalTiles() const noexcept {return num_local_tiles ? (*num_local_tiles)[currentIndex] : 1;} #ifdef AMREX_USE_GPU //! Maintain a list of values to reduce. @@ -160,14 +160,14 @@ public: * \brief Return local index into the vector of fab pointers, m_fabs_v * When AllBoxes is on, local_index_map is a nullptr and local index is current index. */ - int LocalIndex () const { return local_index_map ? (*local_index_map)[currentIndex] : currentIndex; } + int LocalIndex () const noexcept { return local_index_map ? (*local_index_map)[currentIndex] : currentIndex; } //! Constant reference to FabArray over which we're iterating. - const FabArrayBase& theFabArrayBase () const { return fabArray; } + const FabArrayBase& theFabArrayBase () const noexcept { return fabArray; } - int tileIndex () const {return currentIndex;} + int tileIndex () const noexcept {return currentIndex;} - const DistributionMapping& DistributionMap () const { return fabArray.DistributionMap(); } + const DistributionMapping& DistributionMap () const noexcept { return fabArray.DistributionMap(); } protected: @@ -218,7 +218,7 @@ private: FabArrayBase::TileArray lta; }; -inline Arena* The_MFIter_Arena () { return The_Device_Arena(); } +inline Arena* The_MFIter_Arena () noexcept { return The_Device_Arena(); } } diff --git a/Src/Base/AMReX_MFIter.cpp b/Src/Base/AMReX_MFIter.cpp index b013425e374..f2d27078dac 100644 --- a/Src/Base/AMReX_MFIter.cpp +++ b/Src/Base/AMReX_MFIter.cpp @@ -299,7 +299,7 @@ MFIter::Initialize () } Box -MFIter::tilebox () const +MFIter::tilebox () const noexcept { BL_ASSERT(tile_array != 0); Box bx((*tile_array)[currentIndex]); @@ -320,7 +320,7 @@ MFIter::tilebox () const } Box -MFIter::tilebox (const IntVect& nodal) const +MFIter::tilebox (const IntVect& nodal) const noexcept { BL_ASSERT(tile_array != 0); Box bx((*tile_array)[currentIndex]); @@ -342,7 +342,7 @@ MFIter::tilebox (const IntVect& nodal) const } Box -MFIter::tilebox (const IntVect& nodal, const IntVect& ngrow) const +MFIter::tilebox (const IntVect& nodal, const IntVect& ngrow) const noexcept { Box bx = tilebox(nodal); const Box& vbx = validbox(); @@ -358,7 +358,7 @@ MFIter::tilebox (const IntVect& nodal, const IntVect& ngrow) const } Box -MFIter::nodaltilebox (int dir) const +MFIter::nodaltilebox (int dir) const noexcept { BL_ASSERT(dir < AMREX_SPACEDIM); BL_ASSERT(tile_array != 0); @@ -386,7 +386,7 @@ MFIter::nodaltilebox (int dir) const // Note that a small negative ng is supported. Box -MFIter::growntilebox (int a_ng) const +MFIter::growntilebox (int a_ng) const noexcept { Box bx = tilebox(); IntVect ngv{a_ng}; @@ -404,7 +404,7 @@ MFIter::growntilebox (int a_ng) const } Box -MFIter::growntilebox (const IntVect& ng) const +MFIter::growntilebox (const IntVect& ng) const noexcept { Box bx = tilebox(); const Box& vbx = validbox(); @@ -420,7 +420,7 @@ MFIter::growntilebox (const IntVect& ng) const } Box -MFIter::grownnodaltilebox (int dir, int a_ng) const +MFIter::grownnodaltilebox (int dir, int a_ng) const noexcept { IntVect ngv(a_ng); if (a_ng < -100) ngv = fabArray.nGrowVect(); @@ -428,7 +428,7 @@ MFIter::grownnodaltilebox (int dir, int a_ng) const } Box -MFIter::grownnodaltilebox (int dir, IntVect const& a_ng) const +MFIter::grownnodaltilebox (int dir, IntVect const& a_ng) const noexcept { BL_ASSERT(dir < AMREX_SPACEDIM); Box bx = nodaltilebox(dir); @@ -445,7 +445,7 @@ MFIter::grownnodaltilebox (int dir, IntVect const& a_ng) const } void -MFIter::operator++ () +MFIter::operator++ () noexcept { #ifdef _OPENMP int numOmpThreads = omp_get_num_threads(); diff --git a/Src/Base/AMReX_MultiFab.H b/Src/Base/AMReX_MultiFab.H index 0f57d69afa6..f593c57cbc0 100644 --- a/Src/Base/AMReX_MultiFab.H +++ b/Src/Base/AMReX_MultiFab.H @@ -37,7 +37,7 @@ public: * time using the define member functions inherited * from FabArray. */ - MultiFab (); + MultiFab () noexcept; /** * \brief * Constructs a MultiFab @@ -580,15 +580,15 @@ public: /** * \brief This tests on whether the MultiFab is fully nodal. */ - bool is_nodal () const; + bool is_nodal () const noexcept; /** * \brief This tests on whether the MultiFab is nodal in direction dir. */ - bool is_nodal (int dir) const; + bool is_nodal (int dir) const noexcept; /** * \brief This tests on whether the MultiFab is cell-centered. */ - bool is_cell_centered () const; + bool is_cell_centered () const noexcept; bool contains_inf (int scomp, int ncomp, int ngrow = 0, bool local=false) const; /** diff --git a/Src/Base/AMReX_MultiFab.cpp b/Src/Base/AMReX_MultiFab.cpp index f53c79354d2..85ba263b21e 100644 --- a/Src/Base/AMReX_MultiFab.cpp +++ b/Src/Base/AMReX_MultiFab.cpp @@ -463,7 +463,7 @@ MultiFab::Finalize () initialized = false; } -MultiFab::MultiFab () +MultiFab::MultiFab () noexcept { #ifdef BL_MEM_PROFILING ++num_multifabs; @@ -627,19 +627,19 @@ MultiFab::contains_inf (bool local) const } bool -MultiFab::is_nodal () const +MultiFab::is_nodal () const noexcept { return boxArray().ixType().nodeCentered(); } bool -MultiFab::is_nodal (int dir) const +MultiFab::is_nodal (int dir) const noexcept { return boxArray().ixType().nodeCentered(dir); } bool -MultiFab::is_cell_centered () const +MultiFab::is_cell_centered () const noexcept { return boxArray().ixType().cellCentered(); } diff --git a/Src/Base/AMReX_MultiFabUtil_1D_C.H b/Src/Base/AMReX_MultiFabUtil_1D_C.H index 42bb882eb48..a884b2f1210 100644 --- a/Src/Base/AMReX_MultiFabUtil_1D_C.H +++ b/Src/Base/AMReX_MultiFabUtil_1D_C.H @@ -12,7 +12,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void amrex_avg_nd_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& ndfab, - int cccomp, int ndcomp, int ncomp) + int cccomp, int ndcomp, int ncomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -29,7 +29,7 @@ void amrex_avg_nd_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& ndfab AMREX_GPU_HOST_DEVICE inline -void amrex_avg_eg_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& exfab, int cccomp) +void amrex_avg_eg_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& exfab, int cccomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -45,7 +45,7 @@ void amrex_avg_eg_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& exfab AMREX_GPU_HOST_DEVICE inline void amrex_avg_fc_to_cc (Box const& bx, FArrayBox& ccfab, - FArrayBox const& fxfab, int cccomp, GeometryData const& gd) + FArrayBox const& fxfab, int cccomp, GeometryData const& gd) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -98,7 +98,7 @@ void amrex_avg_fc_to_cc (Box const& bx, FArrayBox& ccfab, AMREX_GPU_HOST_DEVICE inline void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, FArrayBox& fxfab, - FArrayBox const& ccfab, GeometryData const& gd) + FArrayBox const& ccfab, GeometryData const& gd) noexcept { const auto lo = lbound(ndbx); const auto fx = fxfab.view(lo); @@ -152,7 +152,7 @@ void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, FArrayBox& fxfab, AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -172,7 +172,7 @@ void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -197,7 +197,7 @@ void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -224,7 +224,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_with_vol (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, FArrayBox const& finevolfab, int ccomp, int fcomp, int ncomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -251,7 +251,7 @@ void amrex_avgdown_with_vol (Box const& bx, FArrayBox& crsefab, FArrayBox const& AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_nodes (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -272,7 +272,7 @@ void amrex_avgdown_nodes (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_compute_divergence (Box const& bx, FArrayBox& divufab, FArrayBox const& ufab, - GpuArray const& dxinv) + GpuArray const& dxinv) noexcept { const auto len = length(bx); const auto lo = lbound(bx); diff --git a/Src/Base/AMReX_MultiFabUtil_2D_C.H b/Src/Base/AMReX_MultiFabUtil_2D_C.H index 97bc8d7fcfa..e3d0d8998f5 100644 --- a/Src/Base/AMReX_MultiFabUtil_2D_C.H +++ b/Src/Base/AMReX_MultiFabUtil_2D_C.H @@ -11,7 +11,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void amrex_avg_nd_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& ndfab, - int cccomp, int ndcomp, int ncomp) + int cccomp, int ndcomp, int ncomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -32,7 +32,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_eg_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& exfab, FArrayBox const& eyfab, - int cccomp) + int cccomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -53,7 +53,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_fc_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& fxfab, FArrayBox const& fyfab, - int cccomp) + int cccomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -74,7 +74,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, Box const& ybx, FArrayBox& fxfab, FArrayBox& fyfab, - FArrayBox const& ccfab) + FArrayBox const& ccfab) noexcept { const auto lo = lbound(ndbx); const auto fx = fxfab.view(lo); @@ -101,7 +101,7 @@ void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, Box const& ybx, AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -155,7 +155,7 @@ void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -209,7 +209,7 @@ void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -241,7 +241,7 @@ void amrex_avgdown (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_nodes (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -267,7 +267,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_with_vol (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, FArrayBox const& finevolfab, int ccomp, int fcomp, int ncomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -301,7 +301,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_compute_divergence (Box const& bx, FArrayBox& divufab, FArrayBox const& ufab, FArrayBox const& vfab, - GpuArray const& dxinv) + GpuArray const& dxinv) noexcept { const auto len = length(bx); const auto lo = lbound(bx); diff --git a/Src/Base/AMReX_MultiFabUtil_3D_C.H b/Src/Base/AMReX_MultiFabUtil_3D_C.H index 7452544ac98..d224635149e 100644 --- a/Src/Base/AMReX_MultiFabUtil_3D_C.H +++ b/Src/Base/AMReX_MultiFabUtil_3D_C.H @@ -11,7 +11,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE inline void amrex_avg_nd_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& ndfab, - int cccomp, int ndcomp, int ncomp) + int cccomp, int ndcomp, int ncomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -35,7 +35,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_eg_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& exfab, FArrayBox const& eyfab, FArrayBox const& ezfab, - int cccomp) + int cccomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -60,7 +60,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_fc_to_cc (Box const& bx, FArrayBox& ccfab, FArrayBox const& fxfab, FArrayBox const& fyfab, FArrayBox const& fzfab, - int cccomp) + int cccomp) noexcept { const auto len = length(bx); const auto lo = lbound(bx); @@ -85,7 +85,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, Box const& ybx, Box const& zbx, FArrayBox& fxfab, FArrayBox& fyfab, FArrayBox& fzfab, - FArrayBox const& ccfab) + FArrayBox const& ccfab) noexcept { const auto lo = lbound(ndbx); const auto fx = fxfab.view(lo); @@ -127,7 +127,7 @@ void amrex_avg_cc_to_fc (Box const& ndbx, Box const& xbx, Box const& ybx, Box co AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -215,7 +215,7 @@ void amrex_avgdown_faces (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) + int ccomp, int fcomp, int ncomp, IntVect const& ratio, int idir) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -297,7 +297,7 @@ void amrex_avgdown_edges (Box const& bx, FArrayBox& crsefab, FArrayBox const& fi AMREX_GPU_HOST_DEVICE inline void amrex_avgdown (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -336,7 +336,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_with_vol (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, FArrayBox const& finevolfab, int ccomp, int fcomp, int ncomp, - IntVect const& ratio) + IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -375,7 +375,7 @@ void amrex_avgdown_with_vol (Box const& bx, FArrayBox& crsefab, FArrayBox const& AMREX_GPU_HOST_DEVICE inline void amrex_avgdown_nodes (Box const& bx, FArrayBox& crsefab, FArrayBox const& finefab, - int ccomp, int fcomp, int ncomp, IntVect const& ratio) + int ccomp, int fcomp, int ncomp, IntVect const& ratio) noexcept { const auto len = length(bx); const auto clo = lbound(bx); @@ -405,7 +405,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_compute_divergence (Box const& bx, FArrayBox& divufab, FArrayBox const& ufab, FArrayBox const& vfab, FArrayBox const& wfab, - GpuArray const& dxinv) + GpuArray const& dxinv) noexcept { const auto len = length(bx); const auto lo = lbound(bx); diff --git a/Src/Base/AMReX_MultiFabUtil_nd_C.H b/Src/Base/AMReX_MultiFabUtil_nd_C.H index c1a6a712384..9320c0c8157 100644 --- a/Src/Base/AMReX_MultiFabUtil_nd_C.H +++ b/Src/Base/AMReX_MultiFabUtil_nd_C.H @@ -13,7 +13,7 @@ AMREX_GPU_HOST_DEVICE inline void amrex_fill_slice_interp (Box const& bx, FArrayBox & slicefab, FArrayBox const& fullfab, int scomp, int fcomp, int ncomp, - int dir, Real coord, GeometryData const& gd) + int dir, Real coord, GeometryData const& gd) noexcept { const auto len = length(bx); const auto lo = lbound(bx); diff --git a/Src/Base/AMReX_Orientation.H b/Src/Base/AMReX_Orientation.H index acb13a62af9..e6735e8d6fd 100644 --- a/Src/Base/AMReX_Orientation.H +++ b/Src/Base/AMReX_Orientation.H @@ -34,12 +34,12 @@ public: enum Side { low = 0, high = 1 }; //! The default constructor. AMREX_GPU_HOST_DEVICE - constexpr Orientation () + constexpr Orientation () noexcept : val(-1) {} //! Set the orientation of a side. AMREX_GPU_HOST_DEVICE - Orientation (int dir, Side side) + Orientation (int dir, Side side) noexcept : val(AMREX_SPACEDIM*side + dir) { @@ -47,54 +47,54 @@ public: } //! Logical equality. AMREX_GPU_HOST_DEVICE - bool operator== (const Orientation& o) const { return val == o.val; } + bool operator== (const Orientation& o) const noexcept { return val == o.val; } //! Logical inequality. AMREX_GPU_HOST_DEVICE - bool operator!= (const Orientation& o) const { return val != o.val; } + bool operator!= (const Orientation& o) const noexcept { return val != o.val; } //! Less-than. AMREX_GPU_HOST_DEVICE - bool operator< (const Orientation& o) const { return val < o.val; } + bool operator< (const Orientation& o) const noexcept { return val < o.val; } //! Less-than or equal. AMREX_GPU_HOST_DEVICE - bool operator<= (const Orientation& o) const { return val <= o.val; } + bool operator<= (const Orientation& o) const noexcept { return val <= o.val; } //! Greater-than. AMREX_GPU_HOST_DEVICE - bool operator> (const Orientation& o) const { return val > o.val; } + bool operator> (const Orientation& o) const noexcept { return val > o.val; } //! Greater-than or equal. AMREX_GPU_HOST_DEVICE - bool operator>= (const Orientation& o) const { return val >= o.val; } + bool operator>= (const Orientation& o) const noexcept { return val >= o.val; } /** * \brief This conversion operator maps an orientation into a * unique integer in the range [0 .. 2*AMREX_SPACEDIM-1] * according to the above ordering. */ AMREX_GPU_HOST_DEVICE - operator int () const { return val; } + operator int () const noexcept { return val; } //! Return opposite orientation. AMREX_GPU_HOST_DEVICE - Orientation flip () const + Orientation flip () const noexcept { return Orientation(val < AMREX_SPACEDIM ? val+AMREX_SPACEDIM : val-AMREX_SPACEDIM); } //! Returns the coordinate direction. AMREX_GPU_HOST_DEVICE - int coordDir () const { return val%AMREX_SPACEDIM; } + int coordDir () const noexcept { return val%AMREX_SPACEDIM; } //! Returns the orientation of the face -- low or high. AMREX_GPU_HOST_DEVICE - Side faceDir () const { return Side(val/AMREX_SPACEDIM); } + Side faceDir () const noexcept { return Side(val/AMREX_SPACEDIM); } //! Returns true if Orientation is low. AMREX_GPU_HOST_DEVICE - bool isLow () const { return val < AMREX_SPACEDIM; } + bool isLow () const noexcept { return val < AMREX_SPACEDIM; } //! Returns true if Orientation is high. AMREX_GPU_HOST_DEVICE - bool isHigh () const { return val >= AMREX_SPACEDIM; } + bool isHigh () const noexcept { return val >= AMREX_SPACEDIM; } //! Read from an istream. friend std::istream& operator>> (std::istream& os, Orientation& o); private: //! Used internally. AMREX_GPU_HOST_DEVICE - Orientation (int v) : val(v) {} + Orientation (int v) noexcept : val(v) {} // //! The data. int val; @@ -111,50 +111,50 @@ class OrientationIter public: //! The default constructor. AMREX_GPU_HOST_DEVICE - constexpr OrientationIter () + constexpr OrientationIter () noexcept : face(0) {} //! Construct an iterator on the Orientation. AMREX_GPU_HOST_DEVICE - OrientationIter (const Orientation& _face) + OrientationIter (const Orientation& _face) noexcept : face(_face) {} //! Reset (rewind) the iterator. AMREX_GPU_HOST_DEVICE - void rewind () { face = 0; } + void rewind () noexcept { face = 0; } //! Return the orientation of the face. AMREX_GPU_HOST_DEVICE - Orientation operator() () const { BL_ASSERT(ok()); return Orientation(face); } + Orientation operator() () const noexcept { BL_ASSERT(ok()); return Orientation(face); } //! Cast to void*. Used to test if iterator is valid. AMREX_GPU_HOST_DEVICE - operator void* () { return 0 <= face && face < 2*AMREX_SPACEDIM ? this : 0; } + operator void* () noexcept { return 0 <= face && face < 2*AMREX_SPACEDIM ? this : 0; } //! Pre-decrement. AMREX_GPU_HOST_DEVICE - OrientationIter& operator-- () { BL_ASSERT(ok()); --face; return *this; } + OrientationIter& operator-- () noexcept { BL_ASSERT(ok()); --face; return *this; } //! Pre-increment. AMREX_GPU_HOST_DEVICE - OrientationIter& operator++ () { BL_ASSERT(ok()); ++face; return *this; } + OrientationIter& operator++ () noexcept { BL_ASSERT(ok()); ++face; return *this; } //! Post-decrement. AMREX_GPU_HOST_DEVICE - OrientationIter operator-- (int) + OrientationIter operator-- (int) noexcept { BL_ASSERT(ok()); OrientationIter it(face); --face; return it; } //! Post-increment. AMREX_GPU_HOST_DEVICE - OrientationIter operator++ (int) + OrientationIter operator++ (int) noexcept { BL_ASSERT(ok()); OrientationIter it(face); ++face; return it; } //! The equality operator. AMREX_GPU_HOST_DEVICE - bool operator== (const OrientationIter& oi) const + bool operator== (const OrientationIter& oi) const noexcept { BL_ASSERT(ok() && oi.ok()); return face == oi.face; } //! The inequality operator. AMREX_GPU_HOST_DEVICE - bool operator!= (const OrientationIter& oi) const + bool operator!= (const OrientationIter& oi) const noexcept { BL_ASSERT(ok() && oi.ok()); return face != oi.face; } @@ -164,10 +164,10 @@ private: int face; //! Construct an iterator on the face. AMREX_GPU_HOST_DEVICE - OrientationIter (int _face) : face(_face) {} + OrientationIter (int _face) noexcept : face(_face) {} //! Is the iterator valid? AMREX_GPU_HOST_DEVICE - bool ok () const { return 0 <= face && face < 2*AMREX_SPACEDIM; } + bool ok () const noexcept { return 0 <= face && face < 2*AMREX_SPACEDIM; } }; } diff --git a/Src/Base/AMReX_ParallelContext.H b/Src/Base/AMReX_ParallelContext.H index 03c7577b66e..eb279e708df 100644 --- a/Src/Base/AMReX_ParallelContext.H +++ b/Src/Base/AMReX_ParallelContext.H @@ -20,10 +20,10 @@ public: Frame (Frame && rhs) noexcept; ~Frame (); - int MyID () const { return m_id; } - int MyProc () const { return m_rank_me; } - int NProcs () const { return m_nranks; } - int IOProc () const { return m_io_rank; } + int MyID () const noexcept { return m_id; } + int MyProc () const noexcept { return m_rank_me; } + int NProcs () const noexcept { return m_nranks; } + int IOProc () const noexcept { return m_io_rank; } int local_to_global_rank (int lrank) const; void local_to_global_rank (int* global, const int* local, std::size_t n) const; void global_to_local_rank (int* local, const int* global, std::size_t n) const; @@ -49,43 +49,43 @@ private: extern Vector frames; //!< stack of communicator frames //! world communicator -inline MPI_Comm CommunicatorAll () { return frames[0].comm; } +inline MPI_Comm CommunicatorAll () noexcept { return frames[0].comm; } //! world group -inline MPI_Group GroupAll () { return frames[0].group; } +inline MPI_Group GroupAll () noexcept { return frames[0].group; } //! number of ranks in world communicator -inline int NProcsAll () { return frames[0].NProcs(); } +inline int NProcsAll () noexcept { return frames[0].NProcs(); } //! my rank in world communicator -inline int MyProcAll () { return frames[0].MyProc(); } +inline int MyProcAll () noexcept { return frames[0].MyProc(); } //! IO rank in world communicator -inline int IOProcessorNumberAll () { return frames[0].IOProc(); } +inline int IOProcessorNumberAll () noexcept { return frames[0].IOProc(); } //! Am IO processor for world communicator? -inline bool IOProcessorAll () { return MyProcAll() == IOProcessorNumberAll(); } +inline bool IOProcessorAll () noexcept { return MyProcAll() == IOProcessorNumberAll(); } //! Pointer to ofstream -inline std::ofstream * OFSPtrAll () { return frames[0].get_ofs_ptr(); } +inline std::ofstream * OFSPtrAll () noexcept { return frames[0].get_ofs_ptr(); } //! sub-communicator for current frame -inline MPI_Comm CommunicatorSub () { return frames.back().comm; } +inline MPI_Comm CommunicatorSub () noexcept { return frames.back().comm; } //! sub-group for current frame -inline MPI_Group GroupSub () { return frames.back().group; } +inline MPI_Group GroupSub () noexcept { return frames.back().group; } //! number of ranks in current frame -inline int NProcsSub () { return frames.back().NProcs(); } +inline int NProcsSub () noexcept { return frames.back().NProcs(); } //! my sub-rank in current frame -inline int MyProcSub () { return frames.back().MyProc(); } +inline int MyProcSub () noexcept { return frames.back().MyProc(); } //! IO sub-rank in current frame -inline int IOProcessorNumberSub () { return frames.back().IOProc(); } +inline int IOProcessorNumberSub () noexcept { return frames.back().IOProc(); } //! Am IO processor for current frame? -inline bool IOProcessorSub () { return MyProcSub() == IOProcessorNumberSub(); } +inline bool IOProcessorSub () noexcept { return MyProcSub() == IOProcessorNumberSub(); } //! Pointer to ofstream -inline std::ofstream * OFSPtrSub () { return frames.back().get_ofs_ptr(); } +inline std::ofstream * OFSPtrSub () noexcept { return frames.back().get_ofs_ptr(); } //! get and increment mpi tag in current frame -inline int get_inc_mpi_tag () { return frames.back().get_inc_mpi_tag(); } +inline int get_inc_mpi_tag () noexcept { return frames.back().get_inc_mpi_tag(); } //! translate between local rank and global rank -inline int local_to_global_rank (int rank) { return frames.back().local_to_global_rank(rank); } -inline void local_to_global_rank (int* global, const int* local, int n) +inline int local_to_global_rank (int rank) noexcept { return frames.back().local_to_global_rank(rank); } +inline void local_to_global_rank (int* global, const int* local, int n) noexcept { frames.back().local_to_global_rank(global, local, n); } -inline int global_to_local_rank (int rank) { return frames.back().global_to_local_rank(rank); } -inline void global_to_local_rank (int* local, const int* global, int n) +inline int global_to_local_rank (int rank) noexcept { return frames.back().global_to_local_rank(rank); } +inline void global_to_local_rank (int* local, const int* global, int n) noexcept { frames.back().global_to_local_rank(local, global, n); } inline void push (MPI_Comm c) { frames.emplace_back(c); } diff --git a/Src/Base/AMReX_ParallelDescriptor.H b/Src/Base/AMReX_ParallelDescriptor.H index 4feb79eb689..d19519928f8 100644 --- a/Src/Base/AMReX_ParallelDescriptor.H +++ b/Src/Base/AMReX_ParallelDescriptor.H @@ -106,12 +106,12 @@ namespace ParallelDescriptor //! return the rank number local to the current Parallel Context inline int - MyProc () + MyProc () noexcept { return ParallelContext::MyProcAll(); } inline int - MyProc (MPI_Comm comm) + MyProc (MPI_Comm comm) noexcept { #ifdef BL_USE_MPI int r; @@ -186,12 +186,12 @@ namespace ParallelDescriptor extern ProcessTeam m_Team; extern int m_MinTag, m_MaxTag; - inline int MinTag () { return m_MinTag; } - inline int MaxTag () { return m_MaxTag; } + inline int MinTag () noexcept { return m_MinTag; } + inline int MaxTag () noexcept { return m_MaxTag; } //! return the number of MPI ranks local to the current Parallel Context inline int - NProcs () + NProcs () noexcept { return ParallelContext::NProcsAll(); } @@ -201,7 +201,7 @@ namespace ParallelDescriptor */ extern const int ioProcessor; inline int - IOProcessorNumber () + IOProcessorNumber () noexcept { return ioProcessor; } @@ -210,73 +210,73 @@ namespace ParallelDescriptor * To get the rank number, call IOProcessorNumber() */ inline bool - IOProcessor () + IOProcessor () noexcept { return MyProc() == IOProcessorNumber(); } // inline int - TeamSize () + TeamSize () noexcept { return m_Team.m_size; } inline int - NTeams () + NTeams () noexcept { return m_Team.m_numTeams; } inline int - MyTeamColor () + MyTeamColor () noexcept { return m_Team.m_color; } inline int - MyTeamLead () + MyTeamLead () noexcept { return m_Team.m_lead; } inline int - MyRankInTeam () + MyRankInTeam () noexcept { return m_Team.m_rankInTeam; } inline int - TeamLead (int rank) + TeamLead (int rank) noexcept { return (rank >= 0) ? (rank - rank % m_Team.m_size) : MPI_PROC_NULL; } inline bool - isTeamLead () + isTeamLead () noexcept { return MyRankInTeam() == 0; } inline bool - sameTeam (int rank) + sameTeam (int rank) noexcept { return MyTeamLead() == TeamLead(rank); } inline bool - sameTeam (int rankA, int rankB) + sameTeam (int rankA, int rankB) noexcept { return TeamLead(rankA) == TeamLead(rankB); } inline int - RankInLeadComm (int rank) + RankInLeadComm (int rank) noexcept { return (rank >= 0) ? (rank / m_Team.m_size) : MPI_PROC_NULL; } inline bool - doTeamReduce () + doTeamReduce () noexcept { return m_Team.m_do_team_reduce; } inline const ProcessTeam& - MyTeam () + MyTeam () noexcept { return m_Team; } inline std::pair - team_range (int begin, int end, int rit = -1, int nworkers = 0) + team_range (int begin, int end, int rit = -1, int nworkers = 0) noexcept { int rb, re; { @@ -344,7 +344,7 @@ namespace ParallelDescriptor } } extern MPI_Comm m_comm; - inline MPI_Comm Communicator () { return m_comm; } + inline MPI_Comm Communicator () noexcept { return m_comm; } void Barrier (const std::string& message = Unnamed); void Barrier (const MPI_Comm &comm, const std::string& message = Unnamed); @@ -357,7 +357,7 @@ namespace ParallelDescriptor //! ErrorString return string associated with error internal error condition const char* ErrorString (int errcode); //! Returns wall-clock seconds since start of execution. - double second (); + double second () noexcept; //! And-wise boolean reduction. void ReduceBoolAnd (bool& rvar); @@ -471,7 +471,7 @@ namespace ParallelDescriptor * \brief Returns sequential message sequence numbers, usually used as * tags for send/recv. */ - inline int SeqNum () { return ParallelContext::get_inc_mpi_tag(); } + inline int SeqNum () noexcept { return ParallelContext::get_inc_mpi_tag(); } template Message Asend(const T*, size_t n, int pid, int tag); template Message Asend(const T*, size_t n, int pid, int tag, MPI_Comm comm); diff --git a/Src/Base/AMReX_ParallelDescriptor.cpp b/Src/Base/AMReX_ParallelDescriptor.cpp index 6d4432f163a..c5cf4326d4b 100644 --- a/Src/Base/AMReX_ParallelDescriptor.cpp +++ b/Src/Base/AMReX_ParallelDescriptor.cpp @@ -345,7 +345,7 @@ ParallelDescriptor::EndParallel () } double -ParallelDescriptor::second () +ParallelDescriptor::second () noexcept { return MPI_Wtime(); } @@ -1801,7 +1801,7 @@ void ParallelDescriptor::ReduceBoolOr (bool&,int) {} void ParallelDescriptor::Bcast(void *, int, MPI_Datatype, int, MPI_Comm) {} double -ParallelDescriptor::second () +ParallelDescriptor::second () noexcept { return amrex::second(); } diff --git a/Src/Base/AMReX_Periodicity.H b/Src/Base/AMReX_Periodicity.H index 989d19c0c15..010f86e0eea 100644 --- a/Src/Base/AMReX_Periodicity.H +++ b/Src/Base/AMReX_Periodicity.H @@ -15,25 +15,25 @@ namespace amrex { class Periodicity { public: - Periodicity () : period(AMREX_D_DECL(0,0,0)) {} - explicit Periodicity (const IntVect& v) : period(v) {} + Periodicity () noexcept : period(AMREX_D_DECL(0,0,0)) {} + explicit Periodicity (const IntVect& v) noexcept : period(v) {} - bool isAnyPeriodic () const + bool isAnyPeriodic () const noexcept { return AMREX_D_TERM(period[0]>0, || period[1]>0, || period[2]>0); } - bool isAllPeriodic () const + bool isAllPeriodic () const noexcept { return AMREX_D_TERM(period[0]>0, && period[1]>0, && period[2]>0); } - bool isPeriodic (int dir) const + bool isPeriodic (int dir) const noexcept { return period[dir]>0; } - bool operator==(const Periodicity& rhs) const + bool operator==(const Periodicity& rhs) const noexcept { return period == rhs.period; } //! Cell-centered domain Box "infinitely" long in non-periodic directions. - Box Domain () const; + Box Domain () const noexcept; std::vector shiftIntVect () const; - static const Periodicity& NonPeriodic (); + static const Periodicity& NonPeriodic () noexcept; private: IntVect period; diff --git a/Src/Base/AMReX_Periodicity.cpp b/Src/Base/AMReX_Periodicity.cpp index 9bfe55c2480..8e9cf5e4ffb 100644 --- a/Src/Base/AMReX_Periodicity.cpp +++ b/Src/Base/AMReX_Periodicity.cpp @@ -30,7 +30,7 @@ Periodicity::shiftIntVect () const } Box -Periodicity::Domain () const +Periodicity::Domain () const noexcept { Box pdomain; for (int i = 0; i < AMREX_SPACEDIM; ++i) { @@ -46,7 +46,7 @@ Periodicity::Domain () const } const Periodicity& -Periodicity::NonPeriodic () +Periodicity::NonPeriodic () noexcept { static const Periodicity np(IntVect(AMREX_D_DECL(0,0,0))); return np; diff --git a/Src/Base/AMReX_PhysBCFunct.H b/Src/Base/AMReX_PhysBCFunct.H index 108a2191c55..32ee0c6a12a 100644 --- a/Src/Base/AMReX_PhysBCFunct.H +++ b/Src/Base/AMReX_PhysBCFunct.H @@ -32,9 +32,9 @@ typedef void (*UserFillBox) (Box const& bx, FArrayBox& dest, class BndryFuncArray { public: - BndryFuncArray () {} - BndryFuncArray (BndryFuncDefault inFunc) : m_func(inFunc) {} - BndryFuncArray (BndryFunc3DDefault inFunc) : m_func3D(inFunc) {} + BndryFuncArray () noexcept {} + BndryFuncArray (BndryFuncDefault inFunc) noexcept : m_func(inFunc) {} + BndryFuncArray (BndryFunc3DDefault inFunc) noexcept : m_func3D(inFunc) {} void operator() (Box const& bx, FArrayBox& dest, const int dcomp, const int numcomp, @@ -42,8 +42,8 @@ public: const Vector& bcr, const int bcomp, const int orig_comp); - bool RunOnGPU () const { return m_run_on_gpu; } - void setRunOnGPU (bool b) { m_run_on_gpu = b; } + bool RunOnGPU () const noexcept { return m_run_on_gpu; } + void setRunOnGPU (bool b) noexcept { m_run_on_gpu = b; } protected: BndryFuncDefault m_func = nullptr; diff --git a/Src/Base/AMReX_PlotFileUtil.H b/Src/Base/AMReX_PlotFileUtil.H index a2fdb2feb6e..984efa30f3e 100644 --- a/Src/Base/AMReX_PlotFileUtil.H +++ b/Src/Base/AMReX_PlotFileUtil.H @@ -150,40 +150,40 @@ namespace amrex public: PlotFileData (std::string const& plotfile_name) : m_impl(new PlotFileDataImpl(plotfile_name)) {} - int spaceDim () const { return m_impl->spaceDim(); } + int spaceDim () const noexcept { return m_impl->spaceDim(); } - Real time () const { return m_impl->time(); } + Real time () const noexcept { return m_impl->time(); } - int finestLevel () const { return m_impl->finestLevel(); } + int finestLevel () const noexcept { return m_impl->finestLevel(); } - int refRatio (int level) const { return m_impl->refRatio(level); } + int refRatio (int level) const noexcept { return m_impl->refRatio(level); } - int levelStep (int level) const { return m_impl->levelStep(level); } + int levelStep (int level) const noexcept { return m_impl->levelStep(level); } - const BoxArray& boxArray (int level) const { return m_impl->boxArray(level); } + const BoxArray& boxArray (int level) const noexcept { return m_impl->boxArray(level); } - const DistributionMapping& DistributionMap (int level) const { return m_impl->DistributionMap(level); } + const DistributionMapping& DistributionMap (int level) const noexcept { return m_impl->DistributionMap(level); } void syncDistributionMap (PlotFileData const& src) { m_impl->syncDistributionMap(*src.m_impl); } void syncDistributionMap (int level, PlotFileData const& src) { m_impl->syncDistributionMap(level, *src.m_impl); } - int coordSys () const { return m_impl->coordSys(); } + int coordSys () const noexcept { return m_impl->coordSys(); } - Box probDomain (int level) const { return m_impl->probDomain(level); } + Box probDomain (int level) const noexcept { return m_impl->probDomain(level); } - Array probSize () const { return m_impl->probSize(); } - Array probLo () const { return m_impl->probLo(); } - Array probHi () const { return m_impl->probHi(); } - Array cellSize (int level) const { return m_impl->cellSize(level); } + Array probSize () const noexcept { return m_impl->probSize(); } + Array probLo () const noexcept { return m_impl->probLo(); } + Array probHi () const noexcept { return m_impl->probHi(); } + Array cellSize (int level) const noexcept { return m_impl->cellSize(level); } - const Vector& varNames () const { return m_impl->varNames(); } + const Vector& varNames () const noexcept { return m_impl->varNames(); } - int nComp () const { return m_impl->nComp(); } - IntVect nGrowVect (int level) const { return m_impl->nGrowVect(level); } + int nComp () const noexcept { return m_impl->nComp(); } + IntVect nGrowVect (int level) const noexcept { return m_impl->nGrowVect(level); } - MultiFab get (int level) { return m_impl->get(level); } - MultiFab get (int level, std::string const& varname) { return m_impl->get(level, varname); } + MultiFab get (int level) noexcept { return m_impl->get(level); } + MultiFab get (int level, std::string const& varname) noexcept { return m_impl->get(level, varname); } private: std::unique_ptr m_impl; diff --git a/Src/Base/AMReX_RealBox.H b/Src/Base/AMReX_RealBox.H index 696db9ff11f..7d5463b2b9a 100644 --- a/Src/Base/AMReX_RealBox.H +++ b/Src/Base/AMReX_RealBox.H @@ -20,60 +20,60 @@ class RealBox // : public Gpu::Managed public: //! The default constructor. Builds invalid RealBox. AMREX_GPU_HOST_DEVICE - constexpr RealBox () : xlo{AMREX_D_DECL(0.,0.,0.)}, xhi{AMREX_D_DECL(-1.,-1.,-1.)} {} + constexpr RealBox () noexcept : xlo{AMREX_D_DECL(0.,0.,0.)}, xhi{AMREX_D_DECL(-1.,-1.,-1.)} {} //! Construct region given diagonal points. AMREX_GPU_HOST_DEVICE - RealBox (const Real* a_lo, const Real* a_hi) + RealBox (const Real* a_lo, const Real* a_hi) noexcept : xlo{AMREX_D_DECL(a_lo[0],a_lo[1],a_lo[2])}, xhi{AMREX_D_DECL(a_hi[0],a_hi[1],a_hi[2])} {} RealBox (const std::array& a_lo, - const std::array& a_hi); + const std::array& a_hi) noexcept; /** * \brief Construct region given index box, cell spacing * and physical location of index (0,0,0). */ - RealBox (const Box& bx, const Real* dx, const Real* base); + RealBox (const Box& bx, const Real* dx, const Real* base) noexcept; //! Explicit dimension specific constructors. AMREX_GPU_HOST_DEVICE RealBox (AMREX_D_DECL(Real x0, Real y0, Real z0), - AMREX_D_DECL(Real x1, Real y1, Real z1)) + AMREX_D_DECL(Real x1, Real y1, Real z1)) noexcept : xlo{AMREX_D_DECL(x0,y0,z0)}, xhi{AMREX_D_DECL(x1,y1,z1)} {} //! Returns lo side. AMREX_GPU_HOST_DEVICE - const Real* lo () const& { return xlo; } + const Real* lo () const& noexcept { return xlo; } AMREX_GPU_HOST_DEVICE const Real* lo () && = delete; //! Returns hide side. AMREX_GPU_HOST_DEVICE - const Real* hi () const& { return xhi; } + const Real* hi () const& noexcept { return xhi; } AMREX_GPU_HOST_DEVICE const Real* hi () && = delete; //! Returns length in specified direction. AMREX_GPU_HOST_DEVICE - Real lo (int dir) const { return xlo[dir]; } + Real lo (int dir) const noexcept { return xlo[dir]; } //! Returns hi side in specified direction. AMREX_GPU_HOST_DEVICE - Real hi (int dir) const { return xhi[dir]; } + Real hi (int dir) const noexcept { return xhi[dir]; } //! Returns length in specified direction. AMREX_GPU_HOST_DEVICE - Real length (int dir) const { return xhi[dir]-xlo[dir]; } + Real length (int dir) const noexcept { return xhi[dir]-xlo[dir]; } //! Sets lo side. - void setLo (const Real* a_lo) { AMREX_D_EXPR(xlo[0] = a_lo[0], xlo[1] = a_lo[1], xlo[2] = a_lo[2]); } + void setLo (const Real* a_lo) noexcept { AMREX_D_EXPR(xlo[0] = a_lo[0], xlo[1] = a_lo[1], xlo[2] = a_lo[2]); } //! Sets lo side. - void setLo (const Vector& a_lo) { AMREX_D_EXPR(xlo[0] = a_lo[0], xlo[1] = a_lo[1], xlo[2] = a_lo[2]); } + void setLo (const Vector& a_lo) noexcept { AMREX_D_EXPR(xlo[0] = a_lo[0], xlo[1] = a_lo[1], xlo[2] = a_lo[2]); } //! Sets lo side in specified direction. - void setLo (int dir, Real a_lo) { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); xlo[dir] = a_lo; } + void setLo (int dir, Real a_lo) noexcept { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); xlo[dir] = a_lo; } //! Sets hi side. - void setHi (const Real* a_hi) { AMREX_D_EXPR(xhi[0] = a_hi[0], xhi[1] = a_hi[1], xhi[2] = a_hi[2]); } + void setHi (const Real* a_hi) noexcept { AMREX_D_EXPR(xhi[0] = a_hi[0], xhi[1] = a_hi[1], xhi[2] = a_hi[2]); } //! Sets hi side. - void setHi (const Vector& a_hi) { AMREX_D_EXPR(xhi[0] = a_hi[0], xhi[1] = a_hi[1], xhi[2] = a_hi[2]); } + void setHi (const Vector& a_hi) noexcept { AMREX_D_EXPR(xhi[0] = a_hi[0], xhi[1] = a_hi[1], xhi[2] = a_hi[2]); } //! Sets hi side in specified direction. - void setHi (int dir, Real a_hi) { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); xhi[dir] = a_hi; } + void setHi (int dir, Real a_hi) noexcept { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); xhi[dir] = a_hi; } //! Is the RealBox OK; i.e. does it have non-negative volume? AMREX_GPU_HOST_DEVICE - bool ok () const { + bool ok () const noexcept { return (length(0) >= 0.0) #if (AMREX_SPACEDIM > 1) && (length(1) >= 0.0) @@ -86,27 +86,27 @@ public: //! Returns the volume of the RealBox. If this RealBox is invalid, //! it's volume is considered to be zero. AMREX_GPU_HOST_DEVICE - Real volume () const { + Real volume () const noexcept { if (ok()) return AMREX_D_TERM(length(0), *length(1), *length(2)); return 0.0; } //! Is the specified point contained in the RealBox? AMREX_GPU_HOST_DEVICE - bool contains (const Real* point, Real eps=0.0) const { + bool contains (const Real* point, Real eps=0.0) const noexcept { return AMREX_D_TERM((xlo[0]-eps < point[0]) && (point[0] < xhi[0]+eps), && (xlo[1]-eps < point[1]) && (point[1] < xhi[1]+eps), && (xlo[2]-eps < point[2]) && (point[2] < xhi[2]+eps)); } - bool contains (const RealVect& rv, Real eps=0.0) const { return contains(rv.dataPtr(), eps); } + bool contains (const RealVect& rv, Real eps=0.0) const noexcept { return contains(rv.dataPtr(), eps); } //! Is the specified RealBox contained in this RealBox? AMREX_GPU_HOST_DEVICE - bool contains (const RealBox& rb, Real eps=0.0) const { + bool contains (const RealBox& rb, Real eps=0.0) const noexcept { return contains(rb.xlo, eps) && contains(rb.xhi, eps); } //! Does the specified RealBox intersect with this RealBox? AMREX_GPU_HOST_DEVICE - bool intersects (const RealBox& bx) const { + bool intersects (const RealBox& bx) const noexcept { return ! (AMREX_D_TERM((xlo[0] > bx.xhi[0]) || (xhi[0] < bx.xlo[0]), || (xlo[1] > bx.xhi[1]) || (xhi[1] < bx.xlo[1]), || (xlo[2] > bx.xhi[2]) || (xhi[2] < bx.xlo[2]))); diff --git a/Src/Base/AMReX_RealBox.cpp b/Src/Base/AMReX_RealBox.cpp index 7210a25956d..781819b24b1 100644 --- a/Src/Base/AMReX_RealBox.cpp +++ b/Src/Base/AMReX_RealBox.cpp @@ -8,7 +8,7 @@ namespace amrex { RealBox::RealBox (const Box& bx, const Real* dx, - const Real* base) + const Real* base) noexcept { const int* blo = bx.loVect(); const int* bhi = bx.hiVect(); @@ -21,7 +21,7 @@ RealBox::RealBox (const Box& bx, } RealBox::RealBox (const std::array& a_lo, - const std::array& a_hi) + const std::array& a_hi) noexcept { AMREX_D_EXPR(xlo[0] = a_lo[0] , xlo[1] = a_lo[1] , xlo[2] = a_lo[2]); AMREX_D_EXPR(xhi[0] = a_hi[0] , xhi[1] = a_hi[1] , xhi[2] = a_hi[2]); diff --git a/Src/Base/AMReX_RealVect.H b/Src/Base/AMReX_RealVect.H index 9c745aa73df..600f92b8bf1 100644 --- a/Src/Base/AMReX_RealVect.H +++ b/Src/Base/AMReX_RealVect.H @@ -45,9 +45,9 @@ public: /** Construct a RealVect whose components are zero. */ - RealVect (); + RealVect () noexcept; - explicit RealVect (const std::vector&); + explicit RealVect (const std::vector&) noexcept; /// /** @@ -55,13 +55,13 @@ public: coordinates. AMREX_D_DECL is a macro that sets the constructor to take AMREX_SPACEDIM arguments. */ - RealVect (AMREX_D_DECL(Real i, Real j, Real k)); + RealVect (AMREX_D_DECL(Real i, Real j, Real k)) noexcept; /// /** The copy constructor. */ - RealVect (const RealVect& rhs); + RealVect (const RealVect& rhs) noexcept; /// @@ -69,7 +69,7 @@ public: Construct a RealVect from an IntVect by coercing each component from int to Real. */ - RealVect (const IntVect & iv) + RealVect (const IntVect & iv) noexcept { for (int d=0 ; di'th coordinate of the RealVect. */ inline - const Real& operator[] (int i) const; + const Real& operator[] (int i) const noexcept; /*@}*/ @@ -110,14 +110,14 @@ public: Returns true if this RealVect is equivalent to argument RealVect. All comparisons between analogous components must be satisfied. */ - bool operator== (const RealVect& p) const; + bool operator== (const RealVect& p) const noexcept; /// /** Returns true if this RealVect is different from argument RealVect. All comparisons between analogous components must be satisfied. */ - bool operator!= (const RealVect& p) const; + bool operator!= (const RealVect& p) const noexcept; /// /** @@ -127,7 +127,7 @@ public: an RealVect to be neither greater than, less than, nor equal to another. */ - bool operator< (const RealVect& p) const; + bool operator< (const RealVect& p) const noexcept; /// /** @@ -137,7 +137,7 @@ public: is possible for an RealVect to be neither greater than or equal to, less than or equal to, nor equal to another. */ - bool operator<= (const RealVect& p) const; + bool operator<= (const RealVect& p) const noexcept; /// /** @@ -147,7 +147,7 @@ public: for an RealVect to be neither greater than, less than, nor equal to another. */ - bool operator> (const RealVect& p) const; + bool operator> (const RealVect& p) const noexcept; /// /** @@ -158,7 +158,7 @@ public: to, less than or equal to, nor equal to another. */ - bool operator>= (const RealVect& p) const; + bool operator>= (const RealVect& p) const noexcept; /*@}*/ @@ -171,58 +171,58 @@ public: /** Modifies this RealVect by addition of a scalar to each component. */ - RealVect& operator+= (Real s); + RealVect& operator+= (Real s) noexcept; /// /** Returns a RealVect that is this RealVect with a scalar s added to each component. */ - RealVect operator+ (Real s) const; + RealVect operator+ (Real s) const noexcept; /// /** Modifies this RealVect by component-wise addition by argument. */ - RealVect& operator+= (const RealVect& p); + RealVect& operator+= (const RealVect& p) noexcept; /// /** Modifies this RealVect by subtraction of a scalar from each component. */ - RealVect& operator-= (Real s); + RealVect& operator-= (Real s) noexcept; /// /** Modifies this RealVect by component-wise subtraction by argument. */ - RealVect& operator-= (const RealVect& p); + RealVect& operator-= (const RealVect& p) noexcept; /// /** Returns a RealVect that is this RealVect with a scalar s subtracted from each component. */ - RealVect operator- (Real s) const; + RealVect operator- (Real s) const noexcept; /// /** Modifies this RealVect by multiplying each component by a scalar. */ - RealVect& operator*= (Real s); + RealVect& operator*= (Real s) noexcept; /// /** */ - Real dotProduct(const RealVect& a_rhs) const; + Real dotProduct(const RealVect& a_rhs) const noexcept; /// /** Modifies this RealVect by component-wise multiplication by argument. */ - RealVect& operator*= (const RealVect& p); + RealVect& operator*= (const RealVect& p) noexcept; //XXX /// //XXX /** @@ -235,19 +235,19 @@ public: Returns a RealVect that is this RealVect with each component multiplied by a scalar. */ - RealVect operator* (Real s) const; + RealVect operator* (Real s) const noexcept; /// /** Modifies this RealVect by dividing each component by a scalar. */ - RealVect& operator/= (Real s); + RealVect& operator/= (Real s) noexcept; /// /** Modifies this RealVect by component-wise division by argument. */ - RealVect& operator/= (const RealVect& p); + RealVect& operator/= (const RealVect& p) noexcept; //XXX /// //XXX /** @@ -260,13 +260,13 @@ public: Returns a RealVect that is this RealVect with each component divided by a scalar. */ - RealVect operator/ (Real s) const; + RealVect operator/ (Real s) const noexcept; /// /** Modifies this RealVect by multiplying each component by a scalar. */ - RealVect& scale (Real s); + RealVect& scale (Real s) noexcept; /*@}*/ @@ -280,7 +280,7 @@ public: Modifies this RealVect by taking component-wise min with RealVect argument. */ - RealVect& min (const RealVect& p); + RealVect& min (const RealVect& p) noexcept; /// /** @@ -288,14 +288,14 @@ public: argument RealVects. */ friend inline RealVect min (const RealVect& p1, - const RealVect& p2); + const RealVect& p2) noexcept; /// /** Modifies this RealVect by taking component-wise max with RealVect argument. */ - RealVect& max (const RealVect& p); + RealVect& max (const RealVect& p) noexcept; /// /** @@ -303,7 +303,7 @@ public: argument RealVects. */ friend inline RealVect max (const RealVect& p1, - const RealVect& p2); + const RealVect& p2) noexcept; /*@}*/ @@ -316,51 +316,51 @@ public: /** Unary plus -- for completeness. */ - RealVect operator+ () const; + RealVect operator+ () const noexcept; /// /** Unary minus -- negates all components of this RealVect. */ - RealVect operator- () const; + RealVect operator- () const noexcept; /// /** Sum of all components of this RealVect. */ - Real sum () const; + Real sum () const noexcept; /// /** sqrt(sum squares) */ - Real vectorLength() const; + Real vectorLength() const noexcept; /// /** sum squares--no square root */ - Real radSquared() const; + Real radSquared() const noexcept; /// /** Product of all components of this RealVect. */ - Real product () const; + Real product () const noexcept; /// /** Component with the minimum value of this RealVect (returns 0 if they are all the same). a_doAbs : if true then take the absolute value before comparing */ - int minDir(const bool& a_doAbs) const; + int minDir(const bool& a_doAbs) const noexcept; /// /** Component with the maximum value of this RealVect (returns 0 if they are all the same). a_doAbs : if true then take the absolute value before comparing */ - int maxDir(const bool& a_doAbs) const; + int maxDir(const bool& a_doAbs) const noexcept; /*@}*/ @@ -373,13 +373,13 @@ public: /** Only for sending stuff to Fortran */ - const Real* dataPtr() const; + const Real* dataPtr() const noexcept; /// /** Only for sending stuff to Fortran */ - Real* dataPtr() ; + Real* dataPtr() noexcept; /*@}*/ @@ -400,7 +400,7 @@ public: BASISREALV(2) == (0.,0.,1.).
Note that the coordinate directions are based at zero. */ - friend RealVect BASISREALV(int dir); + friend RealVect BASISREALV(int dir) noexcept; /// /** @@ -427,14 +427,14 @@ public: a scalar s added to each component. */ friend RealVect operator+ (Real s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns s - p. */ friend RealVect operator- (Real s, - const RealVect& p); + const RealVect& p) noexcept; /// /** @@ -442,41 +442,41 @@ public: multiplied by a scalar s. */ friend RealVect operator* (Real s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns a RealVect that is a RealVect p with each component divided by a scalar s. */ friend RealVect operator/ (Real s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns component-wise sum of RealVects s and p. */ friend RealVect operator+ (const RealVect& s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns s - p. */ friend RealVect operator- (const RealVect& s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns component-wise product of s and p. */ friend RealVect operator* (const RealVect& s, - const RealVect& p); + const RealVect& p) noexcept; /// /** Returns component-wise quotient p / s. */ friend RealVect operator/ (const RealVect& s, - const RealVect& p); + const RealVect& p) noexcept; /// /** @@ -484,7 +484,7 @@ public: of the given RealVect by a scalar. */ friend inline RealVect scale (const RealVect& p, - Real s); + Real s) noexcept; /*@}*/ @@ -496,7 +496,6 @@ public: const RealVect& p); friend std::istream& operator>> (std::istream& is, RealVect& iv); - friend class HDF5Handle; protected: @@ -507,26 +506,26 @@ protected: }; -inline Real& RealVect::operator[] (int i) +inline Real& RealVect::operator[] (int i) noexcept { assert(i>=0 && i < SpaceDim); return vect[i]; } -inline const Real& RealVect::operator[] (int i) const +inline const Real& RealVect::operator[] (int i) const noexcept { assert(i>=0 && i < SpaceDim); return vect[i]; } -inline RealVect::RealVect (const RealVect &iv) +inline RealVect::RealVect (const RealVect &iv) noexcept { AMREX_D_EXPR(vect[0]=iv.vect[0], vect[1]=iv.vect[1], vect[2]=iv.vect[2]); } inline RealVect& -RealVect::operator-= (Real s) +RealVect::operator-= (Real s) noexcept { AMREX_D_EXPR(vect[0] -= s, vect[1] -= s, vect[2] -= s); return *this; @@ -534,7 +533,7 @@ RealVect::operator-= (Real s) inline RealVect& -RealVect::operator-= (const RealVect& p) +RealVect::operator-= (const RealVect& p) noexcept { AMREX_D_EXPR(vect[0] -= p[0], vect[1] -= p[1], vect[2] -= p[2]); @@ -543,21 +542,21 @@ RealVect::operator-= (const RealVect& p) inline RealVect -RealVect::operator+ () const +RealVect::operator+ () const noexcept { return RealVect(*this); } inline RealVect -RealVect::operator- () const +RealVect::operator- () const noexcept { return RealVect(AMREX_D_DECL(-vect[0], -vect[1], -vect[2])); } inline RealVect& -RealVect::scale (Real s) +RealVect::scale (Real s) noexcept { AMREX_D_EXPR(vect[0] *= s, vect[1] *= s, vect[2] *= s); return *this; @@ -565,14 +564,14 @@ RealVect::scale (Real s) inline Real -RealVect::sum () const +RealVect::sum () const noexcept { return AMREX_D_TERM(vect[0], + vect[1], + vect[2]); } inline Real -RealVect::vectorLength () const +RealVect::vectorLength () const noexcept { Real len = this->radSquared(); len = std::sqrt(len); @@ -582,7 +581,7 @@ RealVect::vectorLength () const inline Real -RealVect::radSquared() const +RealVect::radSquared() const noexcept { Real len = 0; for (int idir = 0; idir < SpaceDim; idir++) @@ -595,7 +594,7 @@ RealVect::radSquared() const inline Real -RealVect::product () const +RealVect::product () const noexcept { return AMREX_D_TERM(vect[0], * vect[1], * vect[2]); } @@ -603,42 +602,42 @@ RealVect::product () const inline RealVect scale (const RealVect& p, - Real s) + Real s) noexcept { return RealVect(AMREX_D_DECL(s * p[0], s * p[1], s * p[2])); } inline bool -RealVect::operator< (const RealVect& p) const +RealVect::operator< (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] < p[0], && vect[1] < p[1], && vect[2] < p[2]); } inline bool -RealVect::operator<= (const RealVect& p) const +RealVect::operator<= (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] <= p[0], && vect[1] <= p[1], && vect[2] <= p[2]); } inline bool -RealVect::operator> (const RealVect& p) const +RealVect::operator> (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] > p[0], && vect[1] > p[1], && vect[2] > p[2]); } inline bool -RealVect::operator>= (const RealVect& p) const +RealVect::operator>= (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] >= p[0], && vect[1] >= p[1], && vect[2] >= p[2]); } inline RealVect& -RealVect::min (const RealVect& p) +RealVect::min (const RealVect& p) noexcept { AMREX_D_EXPR(vect[0] = std::min(vect[0], p.vect[0]), vect[1] = std::min(vect[1], p.vect[1]), @@ -649,7 +648,7 @@ RealVect::min (const RealVect& p) inline RealVect& -RealVect::max (const RealVect& p) +RealVect::max (const RealVect& p) noexcept { AMREX_D_EXPR(vect[0] = std::max(vect[0], p.vect[0]), vect[1] = std::max(vect[1], p.vect[1]), @@ -660,7 +659,7 @@ RealVect::max (const RealVect& p) inline RealVect min (const RealVect& p1, - const RealVect& p2) + const RealVect& p2) noexcept { RealVect p(p1); return p.min(p2); @@ -669,13 +668,13 @@ min (const RealVect& p1, inline RealVect max (const RealVect& p1, - const RealVect& p2) + const RealVect& p2) noexcept { RealVect p(p1); return p.max(p2); } -extern RealVect BASISREALV(int idir); +extern RealVect BASISREALV(int idir) noexcept; } diff --git a/Src/Base/AMReX_RealVect.cpp b/Src/Base/AMReX_RealVect.cpp index 013e8925a38..953d3948e64 100644 --- a/Src/Base/AMReX_RealVect.cpp +++ b/Src/Base/AMReX_RealVect.cpp @@ -13,41 +13,41 @@ namespace amrex const RealVect RealVect::Zero(AMREX_D_DECL(0.0,0.0,0.0)); const Real* - RealVect::dataPtr() const + RealVect::dataPtr() const noexcept { return vect; } Real* - RealVect::dataPtr() + RealVect::dataPtr() noexcept { return vect; } - RealVect::RealVect (AMREX_D_DECL(Real i, Real j, Real k)) + RealVect::RealVect (AMREX_D_DECL(Real i, Real j, Real k)) noexcept { AMREX_D_EXPR(vect[0] = i, vect[1] = j, vect[2] = k); } - RealVect::RealVect (const std::vector& vr ) + RealVect::RealVect (const std::vector& vr ) noexcept { AMREX_D_EXPR(vect[0]=vr[0], vect[1]=vr[1], vect[2] = vr[2]); } - RealVect::RealVect () + RealVect::RealVect () noexcept { AMREX_D_EXPR(vect[0]=0.0, vect[1]=0.0, vect[2] = 0.0); } RealVect& - RealVect::operator= (const RealVect &iv) + RealVect::operator= (const RealVect &iv) noexcept { AMREX_D_EXPR(vect[0]=iv.vect[0], vect[1]=iv.vect[1], vect[2]=iv.vect[2]); return *this; } - Real RealVect::dotProduct(const RealVect& a_rhs) const + Real RealVect::dotProduct(const RealVect& a_rhs) const noexcept { return AMREX_D_TERM(vect[0]*a_rhs.vect[0], + vect[1]*a_rhs.vect[1], + @@ -55,89 +55,89 @@ namespace amrex } bool - RealVect::operator== (const RealVect& p) const + RealVect::operator== (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] == p[0], && vect[1] == p[1], && vect[2] == p[2]); } bool - RealVect::operator!= (const RealVect& p) const + RealVect::operator!= (const RealVect& p) const noexcept { return AMREX_D_TERM(vect[0] != p[0], || vect[1] != p[1], || vect[2] != p[2]); } RealVect& - RealVect::operator+= (Real s) + RealVect::operator+= (Real s) noexcept { AMREX_D_EXPR(vect[0] += s, vect[1] += s, vect[2] += s); return *this; } RealVect& - RealVect::operator+= (const RealVect& p) + RealVect::operator+= (const RealVect& p) noexcept { AMREX_D_EXPR(vect[0] += p[0], vect[1] += p[1], vect[2] += p[2]); return *this; } RealVect& - RealVect::operator*= (Real s) + RealVect::operator*= (Real s) noexcept { AMREX_D_EXPR(vect[0] *= s, vect[1] *= s, vect[2] *= s); return *this; } RealVect& - RealVect::operator*= (const RealVect &p) + RealVect::operator*= (const RealVect &p) noexcept { AMREX_D_EXPR(vect[0] *= p[0], vect[1] *= p[1], vect[2] *= p[2]); return *this; } RealVect - RealVect::operator* (Real s) const + RealVect::operator* (Real s) const noexcept { RealVect v(AMREX_D_DECL(vect[0]*s, vect[1]*s, vect[2]*s)); return v; } RealVect - RealVect::operator- (Real s) const + RealVect::operator- (Real s) const noexcept { RealVect v(AMREX_D_DECL(vect[0]-s, vect[1]-s, vect[2]-s)); return v; } RealVect - RealVect::operator+ (Real s) const + RealVect::operator+ (Real s) const noexcept { RealVect v(AMREX_D_DECL(vect[0]+s, vect[1]+s, vect[2]+s)); return v; } RealVect& - RealVect::operator/= (Real s) + RealVect::operator/= (Real s) noexcept { AMREX_D_EXPR(vect[0] /= s, vect[1] /= s, vect[2] /= s); return *this; } RealVect& - RealVect::operator/= (const RealVect& p) + RealVect::operator/= (const RealVect& p) noexcept { AMREX_D_EXPR(vect[0] /= p[0], vect[1] /= p[1], vect[2] /= p[2]); return *this; } RealVect - RealVect::operator/ (Real s) const + RealVect::operator/ (Real s) const noexcept { RealVect result( AMREX_D_DECL( vect[0] / s, vect[1] / s, vect[2] / s)); return result ; } int - RealVect::minDir(const bool& a_doAbs) const + RealVect::minDir(const bool& a_doAbs) const noexcept { int mDir = 0; for (int idir=0; idir= 0 && dir < SpaceDim); RealVect tmp = RealVect::Zero ; @@ -195,55 +195,55 @@ namespace amrex RealVect operator/ (Real s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(s/p[0], s/p[1], s/p[2])); } RealVect operator+ (Real s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(p[0] + s, p[1] + s, p[2] + s)); } RealVect operator- (Real s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(s - p[0], s - p[1], s - p[2])); } RealVect operator* (Real s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(s * p[0], s * p[1], s * p[2])); } RealVect operator/ (const RealVect& s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(s[0] / p[0], s[1] /p[1], s[2] / p[2])); } RealVect operator+ (const RealVect& s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(p[0] + s[0], p[1] +s[1], p[2] + s[2])); } RealVect operator- (const RealVect& s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(s[0] - p[0], s[1] - p[1], s[2] - p[2])); } RealVect operator* (const RealVect& s, - const RealVect& p) + const RealVect& p) noexcept { return RealVect(AMREX_D_DECL(p[0] * s[0], p[1] *s[1], p[2] * s[2])); } diff --git a/Src/Base/AMReX_TinyProfiler.H b/Src/Base/AMReX_TinyProfiler.H index 2eb834ac52d..38657f56eb3 100644 --- a/Src/Base/AMReX_TinyProfiler.H +++ b/Src/Base/AMReX_TinyProfiler.H @@ -20,26 +20,26 @@ namespace amrex { class TinyProfiler { public: - TinyProfiler (std::string funcname); - TinyProfiler (std::string funcname, bool start_); - TinyProfiler (const char* funcname); - TinyProfiler (const char* funcname, bool start_); + TinyProfiler (std::string funcname) noexcept; + TinyProfiler (std::string funcname, bool start_) noexcept; + TinyProfiler (const char* funcname) noexcept; + TinyProfiler (const char* funcname, bool start_) noexcept; ~TinyProfiler (); - void start (); - void stop (); + void start () noexcept; + void stop () noexcept; - static void Initialize (); - static void Finalize (bool bFlushing = false); + static void Initialize () noexcept; + static void Finalize (bool bFlushing = false) noexcept; - static void StartRegion (std::string regname); - static void StopRegion (const std::string& regname); + static void StartRegion (std::string regname) noexcept; + static void StopRegion (const std::string& regname) noexcept; private: //! stats on a single process struct Stats { - Stats () : depth(0), n(0L), dtin(0.0), dtex(0.0) { } + Stats () noexcept : depth(0), n(0L), dtin(0.0), dtex(0.0) { } int depth; //!< recursive depth long n; //!< number of calls double dtin; //!< inclusive dt @@ -86,8 +86,8 @@ private: class TinyProfileRegion { public: - TinyProfileRegion (std::string a_regname); - TinyProfileRegion (const char* a_regname); + TinyProfileRegion (std::string a_regname) noexcept; + TinyProfileRegion (const char* a_regname) noexcept; ~TinyProfileRegion (); private: std::string regname; diff --git a/Src/Base/AMReX_TinyProfiler.cpp b/Src/Base/AMReX_TinyProfiler.cpp index 28569f8acd5..defad755928 100644 --- a/Src/Base/AMReX_TinyProfiler.cpp +++ b/Src/Base/AMReX_TinyProfiler.cpp @@ -29,25 +29,25 @@ namespace { static constexpr char mainregion[] = "main"; } -TinyProfiler::TinyProfiler (std::string funcname) +TinyProfiler::TinyProfiler (std::string funcname) noexcept : fname(std::move(funcname)) { start(); } -TinyProfiler::TinyProfiler (std::string funcname, bool start_) +TinyProfiler::TinyProfiler (std::string funcname, bool start_) noexcept : fname(std::move(funcname)) { if (start_) start(); } -TinyProfiler::TinyProfiler (const char* funcname) +TinyProfiler::TinyProfiler (const char* funcname) noexcept : fname(funcname) { start(); } -TinyProfiler::TinyProfiler (const char* funcname, bool start_) +TinyProfiler::TinyProfiler (const char* funcname, bool start_) noexcept : fname(funcname) { if (start_) start(); @@ -59,7 +59,7 @@ TinyProfiler::~TinyProfiler () } void -TinyProfiler::start () +TinyProfiler::start () noexcept { #ifdef _OPENMP #pragma omp master @@ -85,7 +85,7 @@ TinyProfiler::start () } void -TinyProfiler::stop () +TinyProfiler::stop () noexcept { #ifdef _OPENMP #pragma omp master @@ -136,14 +136,14 @@ TinyProfiler::stop () } void -TinyProfiler::Initialize () +TinyProfiler::Initialize () noexcept { regionstack.push_back(mainregion); t_init = amrex::second(); } void -TinyProfiler::Finalize (bool bFlushing) +TinyProfiler::Finalize (bool bFlushing) noexcept { static bool finalized = false; if (!bFlushing) { // If flushing, don't make this the last time! @@ -378,7 +378,7 @@ TinyProfiler::PrintStats (std::map& regstats, double dt_max) } void -TinyProfiler::StartRegion (std::string regname) +TinyProfiler::StartRegion (std::string regname) noexcept { if (std::find(regionstack.begin(), regionstack.end(), regname) == regionstack.end()) { regionstack.emplace_back(std::move(regname)); @@ -386,14 +386,14 @@ TinyProfiler::StartRegion (std::string regname) } void -TinyProfiler::StopRegion (const std::string& regname) +TinyProfiler::StopRegion (const std::string& regname) noexcept { if (regname == regionstack.back()) { regionstack.pop_back(); } } -TinyProfileRegion::TinyProfileRegion (std::string a_regname) +TinyProfileRegion::TinyProfileRegion (std::string a_regname) noexcept : regname(std::move(a_regname)), tprof(std::string("REG::")+regname, false) { @@ -401,7 +401,7 @@ TinyProfileRegion::TinyProfileRegion (std::string a_regname) tprof.start(); } -TinyProfileRegion::TinyProfileRegion (const char* a_regname) +TinyProfileRegion::TinyProfileRegion (const char* a_regname) noexcept : regname(a_regname), tprof(std::string("REG::")+std::string(a_regname), false) { diff --git a/Src/Base/AMReX_TypeTraits.H b/Src/Base/AMReX_TypeTraits.H index 93967174d03..abfbf3c38f7 100644 --- a/Src/Base/AMReX_TypeTraits.H +++ b/Src/Base/AMReX_TypeTraits.H @@ -12,14 +12,15 @@ namespace amrex { - template class BaseFab; + template class BaseFab; template class FabArray; template struct IsBaseFab : std::false_type {}; // template struct IsBaseFab, + std::is_base_of, D>::value>::type> : std::true_type {}; diff --git a/Src/Base/AMReX_Utility.H b/Src/Base/AMReX_Utility.H index 3314261107c..537042847e9 100644 --- a/Src/Base/AMReX_Utility.H +++ b/Src/Base/AMReX_Utility.H @@ -1,4 +1,3 @@ - #ifndef BL_UTILITY_H #define BL_UTILITY_H @@ -22,6 +21,8 @@ #include #include + + namespace amrex { /** @@ -186,7 +187,7 @@ namespace amrex * uniformly distributed on [0,1)-interval for each call. * */ - double Random (); // [0,1) + AMREX_GPU_HOST_DEVICE double Random (); // [0,1) /** * \brief Generate a psuedo-random int using C++11's mt19937. @@ -242,14 +243,23 @@ namespace amrex int CRRBetweenLevels(int fromlevel, int tolevel, const Vector &refratios); - /* \brief Create a semi-unique hash output to compare Distribution Maps. - Use multiple hashes of different sizes to ensure uniqueness. */ - int HashDistributionMap(const DistributionMapping & dm, int hashSize); + /** + * \brief Set the seeds of the random number generator for each CUDA thread . + * An in-built CUDA library, curand_init is used here. + * The pseusorandom sequence currently implemented is obtained + * from the XORWOW and MRG32k3a generator + */ + void InitRandSeedOnDevice(int N); + + + /** + * \brief Resize seed array and copy address to global symbol + */ + void ResizeRandomSeed(int N); - /* \brief Create a semi-unique hash output to compare BoxArrays - Use multiple hashes of different sizes to ensure uniqueness. */ - int HashBoxArray(const BoxArray & ba, int hashSize); + void CheckSeedArraySizeAndResize (int N); + void DeallocateRandomSeedDevArray(); class expect; std::istream& operator>>(std::istream&, const expect& exp); @@ -316,35 +326,35 @@ namespace amrex using MaxResSteadyClock = std::conditional::type; - double second (); + double second () noexcept; - template void hash_combine (uint64_t & seed, const T & val); - template uint64_t hash_vector (const Vector & vec, uint64_t seed = 0xDEADBEEFDEADBEEF); + template void hash_combine (uint64_t & seed, const T & val) noexcept; + template uint64_t hash_vector (const Vector & vec, uint64_t seed = 0xDEADBEEFDEADBEEF) noexcept; template AMREX_GPU_HOST_DEVICE - AMREX_INLINE const T& min (const T& a, const T& b) + AMREX_INLINE const T& min (const T& a, const T& b) noexcept { return (b < a) ? b : a; } template AMREX_GPU_HOST_DEVICE - AMREX_INLINE const T& min (const T& a, const T& b, const Ts& ... c) + AMREX_INLINE const T& min (const T& a, const T& b, const Ts& ... c) noexcept { return min(min(a,b),c...); } template AMREX_GPU_HOST_DEVICE - AMREX_INLINE const T& max (const T& a, const T& b) + AMREX_INLINE const T& max (const T& a, const T& b) noexcept { return (a < b) ? b : a; } template AMREX_GPU_HOST_DEVICE - AMREX_INLINE const T& max (const T& a, const T& b, const Ts& ... c) + AMREX_INLINE const T& max (const T& a, const T& b, const Ts& ... c) noexcept { return max(max(a,b),c...); } @@ -478,14 +488,14 @@ DEALINGS IN THE SOFTWARE. */ template void -amrex::hash_combine (uint64_t & seed, const T & val) +amrex::hash_combine (uint64_t & seed, const T & val) noexcept { seed ^= std::hash()(val) + 0x9e3779b9 + (seed<<6) + (seed>>2); } template uint64_t -amrex::hash_vector (const Vector & vec, uint64_t seed) +amrex::hash_vector (const Vector & vec, uint64_t seed) noexcept { for (const auto & x: vec) { hash_combine(seed, x); diff --git a/Src/Base/AMReX_Utility.cpp b/Src/Base/AMReX_Utility.cpp index aef3e91a1b1..51be9a8330d 100644 --- a/Src/Base/AMReX_Utility.cpp +++ b/Src/Base/AMReX_Utility.cpp @@ -1,4 +1,3 @@ - #include #include #include @@ -36,8 +35,10 @@ #include #include + using std::ostringstream; + namespace { const char* path_sep_str = "/"; } @@ -363,6 +364,17 @@ namespace int nthreads; amrex::Vector generators; + +#ifdef AMREX_USE_CUDA + /** + * \brief The random seed array is allocated with an extra buffer space to + * reduce the computational cost of dynamic memory allocation and + * random seed generation. + */ + __device__ curandState_t *glo_RandStates; + amrex::Gpu::DeviceVector dev_RandStates_Seed; +#endif + } void @@ -405,18 +417,38 @@ amrex::RandomNormal (double mean, double stddev) return distribution(generators[tid]); } -double +AMREX_GPU_HOST_DEVICE double amrex::Random () { + double rand; + +#ifdef __CUDA_ARCH__ + + int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; + + int tid = blockId * (blockDim.x * blockDim.y * blockDim.z) + + (threadIdx.z * (blockDim.x * blockDim.y)) + + (threadIdx.y * blockDim.x) + threadIdx.x ; + + rand = curand_uniform_double(&glo_RandStates[tid]); + + +#else + #ifdef _OPENMP int tid = omp_get_thread_num(); #else int tid = 0; #endif std::uniform_real_distribution distribution(0.0, 1.0); - return distribution(generators[tid]); + rand = distribution(generators[tid]); + +#endif + + return rand; } + unsigned long amrex::Random_int(unsigned long n) { @@ -481,6 +513,63 @@ amrex::UniqueRandomSubset (Vector &uSet, int setSize, int poolSize, } } + +void +amrex::InitRandSeedOnDevice (int N) +{ + ResizeRandomSeed(N); +} + +void +amrex::CheckSeedArraySizeAndResize (int N) +{ +#ifdef AMREX_USE_CUDA + if ( dev_RandStates_Seed.size() < N) { + ResizeRandomSeed(N); + } +#endif +} + +void +amrex::ResizeRandomSeed (int N) +{ + +#ifdef AMREX_USE_CUDA + + int Nbuffer = N * 2; + + int PrevSize = dev_RandStates_Seed.size(); + + const int MyProc = amrex::ParallelDescriptor::MyProc(); + int SizeDiff = Nbuffer - PrevSize; + + dev_RandStates_Seed.resize(Nbuffer); + curandState_t *d_RS_Seed = dev_RandStates_Seed.dataPtr(); + cudaMemcpyToSymbol(glo_RandStates,&d_RS_Seed,sizeof(curandState_t *)); + + AMREX_PARALLEL_FOR_1D (SizeDiff, idx, + { + unsigned long seed = MyProc*1234567UL + 12345UL ; + int seqstart = idx + 10 * idx ; + int loc = idx + PrevSize; + curand_init(seed, seqstart, 0, &glo_RandStates[loc]); + }); + +#endif + +} + +void +amrex::DeallocateRandomSeedDevArray() +{ +#ifdef AMREX_USE_CUDA + dev_RandStates_Seed.resize(0); + dev_RandStates_Seed.shrink_to_fit(); +#endif +} + + + void amrex::NItemsPerBin (int totalItems, Vector &binCounts) { @@ -521,79 +610,6 @@ int amrex::CRRBetweenLevels(int fromlevel, int tolevel, return rr; } -// ------------------------------------------------------------------- -int amrex::HashDistributionMap(const DistributionMapping &dm, int hashSize) -{ - BL_ASSERT(hashSize > 0); - - const Vector &dmArrayMap = dm.ProcessorMap(); - Vector hash(hashSize, 0); - - // Create hash by summing processer map over - // a looped hash array of given size. - for (int i=0; i 0); - - Vector hash(hashSize, 0); - int hashSum(0), hashCount(0); - - // Create hash by summing smallEnd, bigEnd and type - // over a looped hash array of given size. - // For any empty boxes, skip AMREX_SPACEDIM inputs. - // For an empty box array, hash=0, regardless of size. - if (!ba.empty()) - { - for (int i=0; i > (amrex::MaxResSteadyClock::now() - clock_time_begin).count(); diff --git a/Src/Base/AMReX_Vector.H b/Src/Base/AMReX_Vector.H index 2c7bdd67ef1..9a47d9ce451 100644 --- a/Src/Base/AMReX_Vector.H +++ b/Src/Base/AMReX_Vector.H @@ -34,22 +34,22 @@ public: using std::vector::vector; - T& operator[] (std::size_t i) + T& operator[] (std::size_t i) noexcept { BL_ASSERT(static_cast(i) < this->size()); return this->std::vector::operator[](i); } - const T& operator[] (std::size_t i) const + const T& operator[] (std::size_t i) const noexcept { BL_ASSERT(static_cast(i) < this->size()); return this->std::vector::operator[](i); } //! get access to the underlying data pointer - T* dataPtr () { return this->data(); } + T* dataPtr () noexcept { return this->data(); } //! get access to the underlying data pointer - const T* dataPtr () const { return this->data(); } + const T* dataPtr () const noexcept { return this->data(); } long size() const {return static_cast(std::vector::size());} diff --git a/Src/Base/AMReX_VisMF.cpp b/Src/Base/AMReX_VisMF.cpp index 7d8d548fc66..3376958eea3 100644 --- a/Src/Base/AMReX_VisMF.cpp +++ b/Src/Base/AMReX_VisMF.cpp @@ -619,7 +619,7 @@ VisMF::Write (const FArrayBox& fab, std::ostream& os, long& bytes) { - BL_PROFILE("VisMF::Write_fab"); +// BL_PROFILE("VisMF::Write_fab"); VisMF::FabOnDisk fab_on_disk(filename, VisMF::FileOffset(os)); fab.writeOn(os); @@ -656,7 +656,7 @@ VisMF::Header::Header (const FabArray& mf, m_ba(mf.boxArray()), m_fod(m_ba.size()) { - BL_PROFILE("VisMF::Header"); +// BL_PROFILE("VisMF::Header"); if(version == NoFabHeader_v1) { m_min.clear(); @@ -696,7 +696,7 @@ void VisMF::Header::CalculateMinMax (const FabArray& mf, int procToWrite) { - BL_PROFILE("VisMF::CalculateMinMax"); +// BL_PROFILE("VisMF::CalculateMinMax"); m_min.resize(m_ba.size()); m_max.resize(m_ba.size()); @@ -859,7 +859,7 @@ VisMF::WriteHeader (const std::string &mf_name, VisMF::Header &hdr, int procToWrite) { - BL_PROFILE("VisMF::WriteHeader"); +// BL_PROFILE("VisMF::WriteHeader"); long bytesWritten(0); if(ParallelDescriptor::MyProc() == procToWrite) { @@ -1083,7 +1083,7 @@ VisMF::WriteOnlyHeader (const FabArray & mf, const std::string & mf_name, VisMF::How how) { - BL_PROFILE("VisMF::WriteOnlyHeader(FabArray)"); +// BL_PROFILE("VisMF::WriteOnlyHeader(FabArray)"); BL_ASSERT(mf_name[mf_name.length() - 1] != '/'); BL_ASSERT(currentVersion != VisMF::Header::Undefined_v1); @@ -1120,7 +1120,7 @@ VisMF::FindOffsets (const FabArray &mf, VisMF::Header::Version whichVersion, NFilesIter &nfi) { - BL_PROFILE("VisMF::FindOffsets"); +// BL_PROFILE("VisMF::FindOffsets"); const int myProc(ParallelDescriptor::MyProc()); const int nProcs(ParallelDescriptor::NProcs()); @@ -1349,7 +1349,7 @@ VisMF::readFAB (int idx, const VisMF::Header &hdr, int whichComp) { - BL_PROFILE("VisMF::readFAB_idx"); +// BL_PROFILE("VisMF::readFAB_idx"); Box fab_box(hdr.m_ba[idx]); if(hdr.m_ngrow.max() > 0) { fab_box.grow(hdr.m_ngrow); @@ -1404,7 +1404,7 @@ VisMF::readFAB (FabArray &mf, const std::string& mf_name, const VisMF::Header& hdr) { - BL_PROFILE("VisMF::readFAB_mf"); +// BL_PROFILE("VisMF::readFAB_mf"); FArrayBox &fab = mf[idx]; std::string FullName(VisMF::DirName(mf_name)); @@ -1892,7 +1892,7 @@ void VisMF::ReadFAHeader (const std::string &fafabName, Vector &faHeader) { - BL_PROFILE("VisMF::ReadFAHeader()"); +// BL_PROFILE("VisMF::ReadFAHeader()"); std::string FullHdrFileName(fafabName + TheMultiFabHdrFileSuffix); ParallelDescriptor::ReadAndBcastFile(FullHdrFileName, faHeader); @@ -1902,7 +1902,7 @@ VisMF::ReadFAHeader (const std::string &fafabName, bool VisMF::Check (const std::string& mf_name) { - BL_PROFILE("VisMF::Check()"); +// BL_PROFILE("VisMF::Check()"); int isOk(true); // ---- int to broadcast int v1(true); diff --git a/Src/Base/AMReX_filcc_mod.F90 b/Src/Base/AMReX_filcc_mod.F90 index 44be69ba8c0..3239c6688a5 100644 --- a/Src/Base/AMReX_filcc_mod.F90 +++ b/Src/Base/AMReX_filcc_mod.F90 @@ -133,6 +133,8 @@ subroutine amrex_filccn(lo, hi, q, q_lo, q_hi, ncomp, domlo, domhi, dx, xlo, bc) integer :: i, j, k, n integer :: imin, imax, jmin, jmax, kmin, kmax + !$gpu + is = max(q_lo(1), domlo(1)) ie = min(q_hi(1), domhi(1)) ilo = domlo(1) @@ -278,6 +280,15 @@ subroutine amrex_filccn(lo, hi, q, q_lo, q_hi, ncomp, domlo, domhi, dx, xlo, bc) end if + ! For CUDA we need to synchronize the threadblock after each + ! dimension, since the results for the corners depend + ! on the i, j, and k directions being done in order. + ! Note: this will only work if the threadblock size is + ! larger in each dimension than the number of ghost zones. + +#if defined(AMREX_USE_CUDA) && defined(AMREX_USE_GPU_PRAGMA) + call syncthreads() +#endif #if AMREX_SPACEDIM >= 2 @@ -406,6 +417,10 @@ subroutine amrex_filccn(lo, hi, q, q_lo, q_hi, ncomp, domlo, domhi, dx, xlo, bc) end if #endif +#if defined(AMREX_USE_CUDA) && defined(AMREX_USE_GPU_PRAGMA) + call syncthreads() +#endif + #if AMREX_SPACEDIM == 3 @@ -535,6 +550,10 @@ subroutine amrex_filccn(lo, hi, q, q_lo, q_hi, ncomp, domlo, domhi, dx, xlo, bc) end if #endif +#if defined(AMREX_USE_CUDA) && defined(AMREX_USE_GPU_PRAGMA) + call syncthreads() +#endif + #if AMREX_SPACEDIM >= 2 diff --git a/Src/Base/AMReX_iMultiFab.H b/Src/Base/AMReX_iMultiFab.H index 1ef76f4c5ce..aec8a45046b 100644 --- a/Src/Base/AMReX_iMultiFab.H +++ b/Src/Base/AMReX_iMultiFab.H @@ -507,20 +507,6 @@ public: const FabFactory& factory = DefaultFabFactory()) override; #endif - const IArrayBox& operator[] (int K) const; - - IArrayBox& operator[] (int K); - - const IArrayBox& operator[] (const MFIter& mfi) const { - return this->FabArray::get(mfi); } - - const IArrayBox& get (const MFIter& mfi) const { return operator[](mfi); } - - IArrayBox& operator[] (const MFIter& mfi) { - return this->FabArray::get(mfi); } - - IArrayBox& get (const MFIter& mfi) { return operator[](mfi); } - static void Initialize (); static void Finalize (); }; diff --git a/Src/Base/AMReX_iMultiFab.cpp b/Src/Base/AMReX_iMultiFab.cpp index 04e1a09005f..9568860519e 100644 --- a/Src/Base/AMReX_iMultiFab.cpp +++ b/Src/Base/AMReX_iMultiFab.cpp @@ -211,26 +211,6 @@ iMultiFab::define (const BoxArray& bxs, { this->FabArray::define(bxs,dm,nvar,ngrow,info, factory); } - -const IArrayBox& -iMultiFab::operator[] (int K) const -{ - BL_ASSERT(defined(K)); - - const IArrayBox& fab = this->FabArray::get(K); - - return fab; -} - -IArrayBox& -iMultiFab::operator[] (int K) -{ - BL_ASSERT(defined(K)); - - IArrayBox& fab = this->FabArray::get(K); - - return fab; -} int iMultiFab::min (int comp, diff --git a/Src/Base/CMakeLists.txt b/Src/Base/CMakeLists.txt index 0ffe36416a9..b885a7d8e1a 100644 --- a/Src/Base/CMakeLists.txt +++ b/Src/Base/CMakeLists.txt @@ -24,8 +24,8 @@ add_sources( AMReX_ParallelReduce.H ) add_sources( AMReX_ForkJoin.H AMReX_ParallelContext.H ) add_sources( AMReX_ForkJoin.cpp AMReX_ParallelContext.cpp ) -add_sources( AMReX_VisMF.cpp AMReX_Arena.cpp AMReX_BArena.cpp AMReX_CArena.cpp AMReX_DArena.cpp ) -add_sources( AMReX_VisMF.H AMReX_Arena.H AMReX_BArena.H AMReX_CArena.H AMReX_DArena.H ) +add_sources( AMReX_VisMF.cpp AMReX_Arena.cpp AMReX_BArena.cpp AMReX_CArena.cpp AMReX_DArena.cpp AMReX_EArena.cpp ) +add_sources( AMReX_VisMF.H AMReX_Arena.H AMReX_BArena.H AMReX_CArena.H AMReX_DArena.H AMReX_EArena.H ) add_sources( AMReX_FabAllocator.H ) add_sources( AMReX_FabAllocator.cpp ) diff --git a/Src/Base/Make.package b/Src/Base/Make.package index ccfe2bc0c06..e7ddfa81946 100644 --- a/Src/Base/Make.package +++ b/Src/Base/Make.package @@ -26,8 +26,8 @@ C$(AMREX_BASE)_headers += AMReX_ParallelReduce.H C$(AMREX_BASE)_headers += AMReX_ForkJoin.H AMReX_ParallelContext.H C$(AMREX_BASE)_sources += AMReX_ForkJoin.cpp AMReX_ParallelContext.cpp -C$(AMREX_BASE)_sources += AMReX_VisMF.cpp AMReX_Arena.cpp AMReX_BArena.cpp AMReX_CArena.cpp AMReX_DArena.cpp -C$(AMREX_BASE)_headers += AMReX_VisMF.H AMReX_Arena.H AMReX_BArena.H AMReX_CArena.H AMReX_DArena.H +C$(AMREX_BASE)_sources += AMReX_VisMF.cpp AMReX_Arena.cpp AMReX_BArena.cpp AMReX_CArena.cpp AMReX_DArena.cpp AMReX_EArena.cpp +C$(AMREX_BASE)_headers += AMReX_VisMF.H AMReX_Arena.H AMReX_BArena.H AMReX_CArena.H AMReX_DArena.H AMReX_EArena.H C$(AMREX_BASE)_sources += AMReX_FabAllocator.cpp C$(AMREX_BASE)_headers += AMReX_FabAllocator.H @@ -173,9 +173,6 @@ ifneq ($(BL_NO_FORT),TRUE) f90$(AMREX_BASE)_sources += AMReX_constants_mod.f90 F90$(AMREX_BASE)_sources += AMReX_filcc_mod.F90 - ifeq ($(USE_CUDA),TRUE) - CUDA_MAXREGCOUNT_AMReX_filcc_mod.F90 := 128 - endif F90$(AMREX_BASE)_sources += AMReX_omp_mod.F90 AMReX_acc_mod.F90 F90$(AMREX_BASE)_sources += AMReX_fort_mod.F90 AMReX_error_mod.F90 diff --git a/Src/Boundary/AMReX_BndryData.H b/Src/Boundary/AMReX_BndryData.H index b4a6852a15e..3c6beb05d1f 100644 --- a/Src/Boundary/AMReX_BndryData.H +++ b/Src/Boundary/AMReX_BndryData.H @@ -53,7 +53,7 @@ public: enum MaskVal { covered = 0, not_covered = 1, outside_domain = 2, NumMaskVals = 3 }; //! Default constructor - BndryData(); + BndryData() noexcept; /** * \brief constructor specifying number of components and box of physical @@ -82,10 +82,10 @@ public: int ncomp, const Geometry& geom); // - const MultiMask& bndryMasks (Orientation face) const { return masks[face]; } + const MultiMask& bndryMasks (Orientation face) const noexcept { return masks[face]; } //! Return FabSet on given face. - const FabSet& bndryValues (Orientation face) const { return bndry[face]; } + const FabSet& bndryValues (Orientation face) const noexcept { return bndry[face]; } //! Some useful typedefs using RealTuple = Tuple; @@ -95,53 +95,53 @@ public: * It's an error if we don't own that grid. * RealTuple is indexed with Orientation. */ - const RealTuple& bndryLocs (int igrid) const; - const RealTuple& bndryLocs (const MFIter& mfi) const; + const RealTuple& bndryLocs (int igrid) const noexcept; + const RealTuple& bndryLocs (const MFIter& mfi) const noexcept; /** * \brief Return boundary type specifier on given face for grids we own. * It's an error if we don't own that grid. */ - const Vector< Vector >& bndryConds (int igrid) const; - const Vector< Vector >& bndryConds (const MFIter& mfi) const; + const Vector< Vector >& bndryConds (int igrid) const noexcept; + const Vector< Vector >& bndryConds (const MFIter& mfi) const noexcept; //! return number of components for which this object is intended - int nComp () const { return m_ncomp; } + int nComp () const noexcept { return m_ncomp; } //! return domain used to define masks - const Box& getDomain () const { return geom.Domain(); } + const Box& getDomain () const noexcept { return geom.Domain(); } //! return geometry used to define masks - const Geometry& getGeom () const { return geom; } + const Geometry& getGeom () const noexcept { return geom; } //! set values of boundary Fab for given orientation on nth grid - void setValue (Orientation face, int n, Real val); + void setValue (Orientation face, int n, Real val) noexcept; //! set boundary type specifier for given orientation on nth grid void setBoundCond (Orientation face, int n, int comp, - const BoundCond& bcn); + const BoundCond& bcn) noexcept; void setBoundCond (Orientation face, const MFIter& mfi, int comp, - const BoundCond& bcn); + const BoundCond& bcn) noexcept; //! set boundary location for given orientation on nth grid void setBoundLoc (Orientation face, int n, - Real val); + Real val) noexcept; void setBoundLoc (Orientation face, const MFIter& mfi, - Real val); + Real val) noexcept; //! implement public access to const BndryRegister::operator[] - const FabSet& operator[] (Orientation face) const { return BndryRegister::bndry[face]; } + const FabSet& operator[] (Orientation face) const noexcept { return BndryRegister::bndry[face]; } //! implement public access to BndryRegister::operator[] - FabSet& operator[] (Orientation face) { return BndryRegister::bndry[face]; } + FabSet& operator[] (Orientation face) noexcept { return BndryRegister::bndry[face]; } protected: //! Helper function for copy constructor and assigment operator. diff --git a/Src/Boundary/AMReX_BndryData.cpp b/Src/Boundary/AMReX_BndryData.cpp index 8070e1a5a8b..d1db525f07e 100644 --- a/Src/Boundary/AMReX_BndryData.cpp +++ b/Src/Boundary/AMReX_BndryData.cpp @@ -12,7 +12,7 @@ namespace amrex { // int BndryData::NTangHalfWidth = 5; // ref_ratio + 1, so won't work if ref_ratio > 4 -BndryData::BndryData () +BndryData::BndryData () noexcept : m_ncomp(-1), m_defined(false) {} @@ -32,7 +32,7 @@ void BndryData::setBoundCond (Orientation _face, int _n, int _comp, - const BoundCond& _bcn) + const BoundCond& _bcn) noexcept { bcond[_n][_face][_comp] = _bcn; } @@ -41,7 +41,7 @@ void BndryData::setBoundCond (Orientation _face, const MFIter& mfi, int _comp, - const BoundCond& _bcn) + const BoundCond& _bcn) noexcept { bcond[mfi][_face][_comp] = _bcn; } @@ -49,7 +49,7 @@ BndryData::setBoundCond (Orientation _face, void BndryData::setBoundLoc (Orientation _face, int _n, - Real _val) + Real _val) noexcept { bcloc[_n][_face] = _val; } @@ -57,31 +57,31 @@ BndryData::setBoundLoc (Orientation _face, void BndryData::setBoundLoc (Orientation _face, const MFIter& mfi, - Real _val) + Real _val) noexcept { bcloc[mfi][_face] = _val; } const Vector< Vector >& -BndryData::bndryConds (int igrid) const +BndryData::bndryConds (int igrid) const noexcept { return bcond[igrid]; } const Vector< Vector >& -BndryData::bndryConds (const MFIter& mfi) const +BndryData::bndryConds (const MFIter& mfi) const noexcept { return bcond[mfi]; } const BndryData::RealTuple& -BndryData::bndryLocs (int igrid) const +BndryData::bndryLocs (int igrid) const noexcept { return bcloc[igrid]; } const BndryData::RealTuple& -BndryData::bndryLocs (const MFIter& mfi) const +BndryData::bndryLocs (const MFIter& mfi) const noexcept { return bcloc[mfi]; } @@ -191,7 +191,7 @@ BndryData::define (const BoxArray& _grids, } void -BndryData::setValue (Orientation face, int n, Real val) +BndryData::setValue (Orientation face, int n, Real val) noexcept { auto& fab = bndry[face][n]; auto arr = fab.array(); diff --git a/Src/Boundary/AMReX_BndryRegister.H b/Src/Boundary/AMReX_BndryRegister.H index 7e8846cf1a1..da9186adb27 100644 --- a/Src/Boundary/AMReX_BndryRegister.H +++ b/Src/Boundary/AMReX_BndryRegister.H @@ -24,7 +24,7 @@ struct BndryBATransformer virtual Box operator() (const Box& bx) const override; - bool operator== (const BndryBATransformer& rhs) const; + bool operator== (const BndryBATransformer& rhs) const noexcept; private: int m_dir; @@ -68,7 +68,7 @@ class BndryRegister public: //! The default constructor. - BndryRegister (); + BndryRegister () noexcept; //! The constructor, given number of cells in/out, extent and number of components (assumes cell-centered boxes, and allocates cell-centered FABs) BndryRegister (const BoxArray& grids_, @@ -109,16 +109,16 @@ public: void clear (); //! Get box domain (as an array of boxes). - const BoxArray& boxes () const { return grids; } + const BoxArray& boxes () const noexcept { return grids; } //! Return the number of grids in this domain. - int size () const { return grids.size(); } + int size () const noexcept { return grids.size(); } //! Return const set of FABs bounding the domain grid boxes on a given orientation - const FabSet& operator[] (Orientation face) const { return bndry[face]; } + const FabSet& operator[] (Orientation face) const noexcept { return bndry[face]; } //! Return set of FABs bounding the domain grid boxes on a given orientation - FabSet& operator[] (Orientation face) { return bndry[face]; } + FabSet& operator[] (Orientation face) noexcept { return bndry[face]; } //! Set all boundary FABs to given value. void setVal (Real v); @@ -158,7 +158,7 @@ public: void setBoxes (const BoxArray& grids); //! Returns constant reference to associated DistributionMapping. - const DistributionMapping& DistributionMap () const { return bndry[0].DistributionMap(); } + const DistributionMapping& DistributionMap () const noexcept { return bndry[0].DistributionMap(); } //! Write (used for writing to checkpoint) void write (const std::string& name, std::ostream& os) const; diff --git a/Src/Boundary/AMReX_BndryRegister.cpp b/Src/Boundary/AMReX_BndryRegister.cpp index 44df5ad934e..e21eb8334c3 100644 --- a/Src/Boundary/AMReX_BndryRegister.cpp +++ b/Src/Boundary/AMReX_BndryRegister.cpp @@ -10,7 +10,7 @@ namespace { static const Real BL_SAFE_BOGUS = std::numeric_limits::quiet_NaN(); } -BndryRegister::BndryRegister () {} +BndryRegister::BndryRegister () noexcept {} BndryRegister::~BndryRegister () {} @@ -165,7 +165,7 @@ BndryBATransformer::operator() (const Box& a_bx) const } bool -BndryBATransformer::operator== (const BndryBATransformer& rhs) const +BndryBATransformer::operator== (const BndryBATransformer& rhs) const noexcept { // Note that m_nodal_shft is computed form m_typ, so no need to compare it. return m_typ == rhs.m_typ diff --git a/Src/Boundary/AMReX_BoundCond.H b/Src/Boundary/AMReX_BoundCond.H index ae2488dde0d..5ecb0647a4b 100644 --- a/Src/Boundary/AMReX_BoundCond.H +++ b/Src/Boundary/AMReX_BoundCond.H @@ -21,21 +21,21 @@ class BoundCond public: // //! Initializes boundary condition type to default. - BoundCond () : bctype(-1) {} + BoundCond () noexcept : bctype(-1) {} // //! Initializes boundary condition type to specified value. - BoundCond (int _bctype) : bctype(_bctype) {} + BoundCond (int _bctype) noexcept : bctype(_bctype) {} // //! Return index of boundary condition type. AMREX_GPU_HOST_DEVICE - operator int () const + operator int () const noexcept { BL_ASSERT(bctype != -1); return bctype; } // //! Set index of boundary condition type. - BoundCond& operator= (const int _bctype) + BoundCond& operator= (const int _bctype) noexcept { bctype = _bctype; return *this; diff --git a/Src/Boundary/AMReX_FabSet.H b/Src/Boundary/AMReX_FabSet.H index 9b68d448f10..d29cebc7138 100644 --- a/Src/Boundary/AMReX_FabSet.H +++ b/Src/Boundary/AMReX_FabSet.H @@ -41,7 +41,7 @@ class FabSet public: // //! The default constructor -- you must later call define(). - FabSet (); + FabSet () noexcept; // //! Construct a FabSet of specified number of components on the grids. FabSet (const BoxArray& grids, const DistributionMapping& dmap, int ncomp); @@ -58,41 +58,41 @@ public: //! Define a FabSet constructed via default constructor. void define (const BoxArray& grids, const DistributionMapping& dmap, int ncomp); - FArrayBox const& operator[] (const MFIter& mfi) const { return m_mf[mfi]; } - FArrayBox & operator[] (const MFIter& mfi) { return m_mf[mfi]; } - FArrayBox const& operator[] (int i) const { return m_mf[i]; } - FArrayBox & operator[] (int i) { return m_mf[i]; } + FArrayBox const& operator[] (const MFIter& mfi) const noexcept { return m_mf[mfi]; } + FArrayBox & operator[] (const MFIter& mfi) noexcept { return m_mf[mfi]; } + FArrayBox const& operator[] (int i) const noexcept { return m_mf[i]; } + FArrayBox & operator[] (int i) noexcept { return m_mf[i]; } - FArrayBox const* fabPtr (const MFIter& mfi) const { return m_mf.fabPtr(mfi); } - FArrayBox * fabPtr (const MFIter& mfi) { return m_mf.fabPtr(mfi); } - FArrayBox const* fabPtr (int i) const { return m_mf.fabPtr(i); } - FArrayBox * fabPtr (int i) { return m_mf.fabPtr(i); } + FArrayBox const* fabPtr (const MFIter& mfi) const noexcept { return m_mf.fabPtr(mfi); } + FArrayBox * fabPtr (const MFIter& mfi) noexcept { return m_mf.fabPtr(mfi); } + FArrayBox const* fabPtr (int i) const noexcept { return m_mf.fabPtr(i); } + FArrayBox * fabPtr (int i) noexcept { return m_mf.fabPtr(i); } - FArrayBox const* fabHostPtr (const MFIter& mfi) const { return m_mf.fabHostPtr(mfi); } - FArrayBox * fabHostPtr (const MFIter& mfi) { return m_mf.fabHostPtr(mfi); } - FArrayBox const* fabHostPtr (int i) const { return m_mf.fabHostPtr(i); } - FArrayBox * fabHostPtr (int i) { return m_mf.fabHostPtr(i); } + FArrayBox const* fabHostPtr (const MFIter& mfi) const noexcept { return m_mf.fabHostPtr(mfi); } + FArrayBox * fabHostPtr (const MFIter& mfi) noexcept { return m_mf.fabHostPtr(mfi); } + FArrayBox const* fabHostPtr (int i) const noexcept { return m_mf.fabHostPtr(i); } + FArrayBox * fabHostPtr (int i) noexcept { return m_mf.fabHostPtr(i); } - FArrayBox const* fabDevicePtr (const MFIter& mfi) const { return m_mf.fabDevicePtr(mfi); } - FArrayBox * fabDevicePtr (const MFIter& mfi) { return m_mf.fabDevicePtr(mfi); } - FArrayBox const* fabDevicePtr (int i) const { return m_mf.fabDevicePtr(i); } - FArrayBox * fabDevicePtr (int i) { return m_mf.fabDevicePtr(i); } + FArrayBox const* fabDevicePtr (const MFIter& mfi) const noexcept { return m_mf.fabDevicePtr(mfi); } + FArrayBox * fabDevicePtr (const MFIter& mfi) noexcept { return m_mf.fabDevicePtr(mfi); } + FArrayBox const* fabDevicePtr (int i) const noexcept { return m_mf.fabDevicePtr(i); } + FArrayBox * fabDevicePtr (int i) noexcept { return m_mf.fabDevicePtr(i); } - Array4 array (const MFIter& mfi) const { return m_mf.array(mfi); } - Array4 array (const MFIter& mfi) { return m_mf.array(mfi); } - Array4 array (int i) const { return m_mf.array(i); } - Array4 array (int i) { return m_mf.array(i); } + Array4 array (const MFIter& mfi) const noexcept { return m_mf.array(mfi); } + Array4 array (const MFIter& mfi) noexcept { return m_mf.array(mfi); } + Array4 array (int i) const noexcept { return m_mf.array(i); } + Array4 array (int i) noexcept { return m_mf.array(i); } - Box fabbox (int K) const { return m_mf.fabbox(K); } + Box fabbox (int K) const noexcept { return m_mf.fabbox(K); } - int size () const { return m_mf.size(); } + int size () const noexcept { return m_mf.size(); } - const BoxArray& boxArray () const { return m_mf.boxArray(); } + const BoxArray& boxArray () const noexcept { return m_mf.boxArray(); } - const DistributionMapping& DistributionMap () const + const DistributionMapping& DistributionMap () const noexcept { return m_mf.DistributionMap(); } - int nComp () const { return m_mf.nComp(); } + int nComp () const noexcept { return m_mf.nComp(); } void clear () { m_mf.clear(); } diff --git a/Src/Boundary/AMReX_FabSet.cpp b/Src/Boundary/AMReX_FabSet.cpp index a72bf7ae2e2..b7abe7278c1 100644 --- a/Src/Boundary/AMReX_FabSet.cpp +++ b/Src/Boundary/AMReX_FabSet.cpp @@ -10,7 +10,7 @@ namespace amrex { -FabSet::FabSet () {} +FabSet::FabSet () noexcept {} FabSet::FabSet (const BoxArray& grids, const DistributionMapping& dmap, int ncomp) : diff --git a/Src/Boundary/AMReX_InterpBndryData.H b/Src/Boundary/AMReX_InterpBndryData.H index 56c3fa3bff3..7671c362af7 100644 --- a/Src/Boundary/AMReX_InterpBndryData.H +++ b/Src/Boundary/AMReX_InterpBndryData.H @@ -46,7 +46,7 @@ public: /** * \brief default constructor */ - InterpBndryData (); + InterpBndryData () noexcept; /** * \brief constructor for given BoxArray, etc diff --git a/Src/Boundary/AMReX_InterpBndryData.cpp b/Src/Boundary/AMReX_InterpBndryData.cpp index c025780a915..e5a11be9d08 100644 --- a/Src/Boundary/AMReX_InterpBndryData.cpp +++ b/Src/Boundary/AMReX_InterpBndryData.cpp @@ -10,7 +10,7 @@ namespace amrex { // int InterpBndryData::IBD_max_order_DEF = 3; -InterpBndryData::InterpBndryData () +InterpBndryData::InterpBndryData () noexcept : BndryData() {} diff --git a/Src/Boundary/AMReX_InterpBndryData_1D_K.H b/Src/Boundary/AMReX_InterpBndryData_1D_K.H index b801600a3c7..1510d993d77 100644 --- a/Src/Boundary/AMReX_InterpBndryData_1D_K.H +++ b/Src/Boundary/AMReX_InterpBndryData_1D_K.H @@ -10,7 +10,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o1 (int islo, int ic, int /*jc*/, int /*kc*/, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, - Dim3 const& r) + Dim3 const& r) noexcept { const int i = ic*r.x + islo*(r.x-1); bdry(i,0,0,n+nb) = crse(ic,0,0,n+nc); @@ -20,7 +20,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o3 (int islo, int ic, int /*jc*/, int /*kc*/, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { const int i = ic*r.x + islo*(r.x-1); bdry(i,0,0,n+nb) = crse(ic,0,0,n+nc); diff --git a/Src/Boundary/AMReX_InterpBndryData_2D_K.H b/Src/Boundary/AMReX_InterpBndryData_2D_K.H index 45d791edea0..dace5fcb737 100644 --- a/Src/Boundary/AMReX_InterpBndryData_2D_K.H +++ b/Src/Boundary/AMReX_InterpBndryData_2D_K.H @@ -10,7 +10,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o1 (int islo, int ic, int jc, int /*kc*/, int n, Array4 const& bdry, int nb, - Array4 const& crse, int nc, Dim3 const& r) + Array4 const& crse, int nc, Dim3 const& r) noexcept { Real c = crse(ic,jc,0,n+nc); const int i = ic*r.x + islo*(r.x-1); @@ -23,7 +23,7 @@ void interpbndrydata_x_o1 (int islo, int ic, int jc, int /*kc*/, int n, AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_y_o1 (int islo, int ic, int jc, int /*kc*/, int n, Array4 const& bdry, int nb, - Array4 const& crse, int nc, Dim3 const& r) + Array4 const& crse, int nc, Dim3 const& r) noexcept { Real c = crse(ic,jc,0,n+nc); const int j = jc*r.y + islo*(r.y-1); @@ -37,7 +37,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o3 (int islo, int ic, int jc, int /*kc*/, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { const int i = ic*r.x + islo*(r.x-1); int j = jc*r.y; @@ -86,7 +86,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_y_o3 (int islo, int ic, int jc, int /*kc*/, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { int i = ic*r.x; const int j = jc*r.y + islo*(r.y-1); diff --git a/Src/Boundary/AMReX_InterpBndryData_3D_K.H b/Src/Boundary/AMReX_InterpBndryData_3D_K.H index cc858153aec..5444431b8b0 100644 --- a/Src/Boundary/AMReX_InterpBndryData_3D_K.H +++ b/Src/Boundary/AMReX_InterpBndryData_3D_K.H @@ -9,7 +9,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o1 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, - Array4 const& crse, int nc, Dim3 const& r) + Array4 const& crse, int nc, Dim3 const& r) noexcept { Real c = crse(ic,jc,kc,n+nc); const int i = ic*r.x + islo*(r.x-1); @@ -25,7 +25,7 @@ void interpbndrydata_x_o1 (int islo, int ic, int jc, int kc, int n, AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_y_o1 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, - Array4 const& crse, int nc, Dim3 const& r) + Array4 const& crse, int nc, Dim3 const& r) noexcept { Real c = crse(ic,jc,kc,n+nc); const int j = jc*r.y + islo*(r.y-1); @@ -41,7 +41,7 @@ void interpbndrydata_y_o1 (int islo, int ic, int jc, int kc, int n, AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_z_o1 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, - Array4 const& crse, int nc, Dim3 const& r) + Array4 const& crse, int nc, Dim3 const& r) noexcept { Real c = crse(ic,jc,kc,n+nc); const int k = kc*r.z + islo*(r.z-1); @@ -58,7 +58,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_x_o3 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { const int i = ic*r.x + islo*(r.x-1); int j = jc*r.y; @@ -97,7 +97,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_y_o3 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { int i = ic*r.x; const int j = jc*r.y + islo*(r.y-1); @@ -136,7 +136,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void interpbndrydata_z_o3 (int islo, int ic, int jc, int kc, int n, Array4 const& bdry, int nb, Array4 const& crse, int nc, Dim3 const& r, - Array4 const& mask, int not_covered) + Array4 const& mask, int not_covered) noexcept { int i = ic*r.x; int j = jc*r.y; diff --git a/Src/Boundary/AMReX_LOUtil_K.H b/Src/Boundary/AMReX_LOUtil_K.H index 3b767f3e951..24229696328 100644 --- a/Src/Boundary/AMReX_LOUtil_K.H +++ b/Src/Boundary/AMReX_LOUtil_K.H @@ -19,7 +19,7 @@ namespace amrex { // P(xInt) = sum_(i=1)^(N) y[i]*c[i] AMREX_GPU_HOST_DEVICE AMREX_INLINE -void poly_interp_coeff (Real xInt, Real const* AMREX_RESTRICT x, int N, Real* AMREX_RESTRICT c) +void poly_interp_coeff (Real xInt, Real const* AMREX_RESTRICT x, int N, Real* AMREX_RESTRICT c) noexcept { for (int j = 0; j < N; ++j) { Real num = 1.0, den = 1.0; diff --git a/Src/Boundary/AMReX_MacBndry.H b/Src/Boundary/AMReX_MacBndry.H index d50cf742b46..d69288d4c7c 100644 --- a/Src/Boundary/AMReX_MacBndry.H +++ b/Src/Boundary/AMReX_MacBndry.H @@ -35,10 +35,10 @@ public: void setHomogValues (const BCRec& bc, const IntVect& ratio); - int phys_bc_lo (int dir) const {return m_phys_bc.lo(dir);} - int phys_bc_hi (int dir) const {return m_phys_bc.hi(dir);} + int phys_bc_lo (int dir) const noexcept {return m_phys_bc.lo(dir);} + int phys_bc_hi (int dir) const noexcept {return m_phys_bc.hi(dir);} - const BCRec& PhysBC () const { return m_phys_bc; } + const BCRec& PhysBC () const noexcept { return m_phys_bc; } private: diff --git a/Src/Boundary/AMReX_Mask.H b/Src/Boundary/AMReX_Mask.H index f6dc2ee3c7c..a3ca29aba73 100644 --- a/Src/Boundary/AMReX_Mask.H +++ b/Src/Boundary/AMReX_Mask.H @@ -31,7 +31,7 @@ public: /** * \brief default constructor */ - Mask (); + Mask () noexcept; /** * \brief allocating constructor (nc=number of components) @@ -92,7 +92,7 @@ public: // //! in-place And operator AMREX_GPU_HOST_DEVICE - Mask& operator&= (const Mask& src) { return And(src); } + Mask& operator&= (const Mask& src) noexcept { return And(src); } /** * \brief in-place And @@ -100,7 +100,7 @@ public: * \param src */ AMREX_GPU_HOST_DEVICE - Mask& And (const Mask& src); + Mask& And (const Mask& src) noexcept; /** * \brief as above, but specify source/destination/number of components @@ -114,7 +114,7 @@ public: Mask& And (const Mask& src, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; /** * \brief as above, and specify subregion * @@ -129,7 +129,7 @@ public: const Box& subbox, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; /** * \brief in-pace And, over source components to destination components, * and on intersection of source and destination boxes @@ -147,10 +147,10 @@ public: const Box& destbox, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; //! in-place Or operator AMREX_GPU_HOST_DEVICE - Mask& operator|= (const Mask& src) { return Or(src); } + Mask& operator|= (const Mask& src) noexcept { return Or(src); } /** * \brief in-place Or @@ -158,7 +158,7 @@ public: * \param src */ AMREX_GPU_HOST_DEVICE - Mask& Or (const Mask& src); + Mask& Or (const Mask& src) noexcept; /** * \brief as above, but specify source/destination/number of components @@ -172,7 +172,7 @@ public: Mask& Or (const Mask& src, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; /** * \brief as above, and specify subregion * @@ -187,7 +187,7 @@ public: const Box& subbox, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; /** * \brief in-pace Or, over source components to destination components, * and on intersection of source and destination boxes @@ -205,12 +205,12 @@ public: const Box& destbox, int srccomp, int destcomp, - int numcomp = 1); + int numcomp = 1) noexcept; }; AMREX_GPU_HOST_DEVICE AMREX_INLINE Mask& -Mask::And (const Mask& src) +Mask::And (const Mask& src) noexcept { return this->And(src,domain,domain,0,0,nvar); } @@ -220,7 +220,7 @@ Mask& Mask::And (const Mask& src, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { return this->And(src,domain,domain,srccomp,destcomp,numcomp); } @@ -231,7 +231,7 @@ Mask::And (const Mask& src, const Box& subbox, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { return this->And(src,subbox,subbox,srccomp,destcomp,numcomp); } @@ -243,7 +243,7 @@ Mask::And (const Mask& src, const Box& destbox, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { const auto len = amrex::length(destbox); const auto dlo = amrex::lbound(destbox); @@ -267,7 +267,7 @@ Mask::And (const Mask& src, AMREX_GPU_HOST_DEVICE AMREX_INLINE Mask& -Mask::Or (const Mask& src) +Mask::Or (const Mask& src) noexcept { return this->Or(src,domain,domain,0,0,nvar); } @@ -277,7 +277,7 @@ Mask& Mask::Or (const Mask& src, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { return this->Or(src,domain,domain,srccomp,destcomp,numcomp); } @@ -288,7 +288,7 @@ Mask::Or (const Mask& src, const Box& subbox, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { return this->Or(src,subbox,subbox,srccomp,destcomp,numcomp); } @@ -300,7 +300,7 @@ Mask::Or (const Mask& src, const Box& destbox, int srccomp, int destcomp, - int numcomp) + int numcomp) noexcept { const auto len = amrex::length(destbox); const auto dlo = amrex::lbound(destbox); diff --git a/Src/Boundary/AMReX_Mask.cpp b/Src/Boundary/AMReX_Mask.cpp index 20858e95dcd..1e052a1da0e 100644 --- a/Src/Boundary/AMReX_Mask.cpp +++ b/Src/Boundary/AMReX_Mask.cpp @@ -5,7 +5,7 @@ namespace amrex { -Mask::Mask () +Mask::Mask () noexcept : BaseFab() {} diff --git a/Src/Boundary/AMReX_MultiMask.H b/Src/Boundary/AMReX_MultiMask.H index cc0556bd656..7a2b355da32 100644 --- a/Src/Boundary/AMReX_MultiMask.H +++ b/Src/Boundary/AMReX_MultiMask.H @@ -33,17 +33,17 @@ public: void define (const BoxArray& regba, const DistributionMapping& dm, const Geometry& geom, Orientation face, int in_rad, int out_rad, int extent_rad, int ncomp, bool initval); - Mask& operator[] (const MFIter& mfi) { return m_fa[mfi]; } - const Mask& operator[] (const MFIter& mfi) const { return m_fa[mfi]; } + Mask& operator[] (const MFIter& mfi) noexcept { return m_fa[mfi]; } + const Mask& operator[] (const MFIter& mfi) const noexcept { return m_fa[mfi]; } - Array4 array (const MFIter& mfi) const { return m_fa.array(mfi); } - Array4 array (const MFIter& mfi) { return m_fa.array(mfi); } + Array4 array (const MFIter& mfi) const noexcept { return m_fa.array(mfi); } + Array4 array (const MFIter& mfi) noexcept { return m_fa.array(mfi); } - int nComp () const { return m_fa.nComp(); } + int nComp () const noexcept { return m_fa.nComp(); } - const BoxArray& boxArray () const { return m_fa.boxArray(); } + const BoxArray& boxArray () const noexcept { return m_fa.boxArray(); } - const DistributionMapping& DistributionMap () const { return m_fa.DistributionMap(); } + const DistributionMapping& DistributionMap () const noexcept { return m_fa.DistributionMap(); } static void Copy (MultiMask& dst, const MultiMask& src); diff --git a/Src/Boundary/AMReX_YAFluxRegister.H b/Src/Boundary/AMReX_YAFluxRegister.H index a825af2677e..b257905490c 100644 --- a/Src/Boundary/AMReX_YAFluxRegister.H +++ b/Src/Boundary/AMReX_YAFluxRegister.H @@ -39,19 +39,19 @@ public: void CrseAdd (const MFIter& mfi, const std::array& flux, - const Real* dx, Real dt); + const Real* dx, Real dt) noexcept; void FineAdd (const MFIter& mfi, const std::array& flux, - const Real* dx, Real dt); + const Real* dx, Real dt) noexcept; void Reflux (MultiFab& state, int dc = 0); - bool CrseHasWork (const MFIter& mfi) const { + bool CrseHasWork (const MFIter& mfi) const noexcept { return m_crse_fab_flag[mfi.LocalIndex()] != crse_cell; } - bool FineHasWork (const MFIter& mfi) const { + bool FineHasWork (const MFIter& mfi) const noexcept { return !(m_cfp_fab[mfi.LocalIndex()].empty()); } diff --git a/Src/Boundary/AMReX_YAFluxRegister.cpp b/Src/Boundary/AMReX_YAFluxRegister.cpp index 6d25d8ab595..e3a2d28a555 100644 --- a/Src/Boundary/AMReX_YAFluxRegister.cpp +++ b/Src/Boundary/AMReX_YAFluxRegister.cpp @@ -238,7 +238,7 @@ YAFluxRegister::reset () void YAFluxRegister::CrseAdd (const MFIter& mfi, const std::array& flux, - const Real* dx, Real dt) + const Real* dx, Real dt) noexcept { BL_ASSERT(m_crse_data.nComp() == flux[0]->nComp()); @@ -277,7 +277,7 @@ YAFluxRegister::CrseAdd (const MFIter& mfi, void YAFluxRegister::FineAdd (const MFIter& mfi, const std::array& a_flux, - const Real* dx, Real dt) + const Real* dx, Real dt) noexcept { BL_ASSERT(m_cfpatch.nComp() == a_flux[0]->nComp()); diff --git a/Src/Boundary/AMReX_YAFluxRegister_1D_K.H b/Src/Boundary/AMReX_YAFluxRegister_1D_K.H index 27225c0f5fb..3dfd7cd6ae3 100644 --- a/Src/Boundary/AMReX_YAFluxRegister_1D_K.H +++ b/Src/Boundary/AMReX_YAFluxRegister_1D_K.H @@ -7,7 +7,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 const& flag, - FArrayBox const& fxfab, Real dtdx, int nc) + FArrayBox const& fxfab, Real dtdx, int nc) noexcept { auto const fx = fxfab.array(); @@ -32,7 +32,7 @@ void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_fineadd (Box const& bx, Array4 const& d, FArrayBox const& ffab, - Real dtdx, int nc, int dirside, Dim3 const& rr) + Real dtdx, int nc, int dirside, Dim3 const& rr) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/Boundary/AMReX_YAFluxRegister_2D_K.H b/Src/Boundary/AMReX_YAFluxRegister_2D_K.H index 884346a8579..5ec439fb06f 100644 --- a/Src/Boundary/AMReX_YAFluxRegister_2D_K.H +++ b/Src/Boundary/AMReX_YAFluxRegister_2D_K.H @@ -8,7 +8,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 const& flag, FArrayBox const& fxfab, FArrayBox const& fyfab, - Real dtdx, Real dtdy, int nc) + Real dtdx, Real dtdy, int nc) noexcept { auto const fx = fxfab.array(); auto const fy = fyfab.array(); @@ -45,7 +45,7 @@ void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_fineadd (Box const& bx, Array4 const& d, FArrayBox const& ffab, - Real dtdx, int nc, int dirside, Dim3 const& rr) + Real dtdx, int nc, int dirside, Dim3 const& rr) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/Boundary/AMReX_YAFluxRegister_3D_K.H b/Src/Boundary/AMReX_YAFluxRegister_3D_K.H index 73f6440c793..fa0a45db6b3 100644 --- a/Src/Boundary/AMReX_YAFluxRegister_3D_K.H +++ b/Src/Boundary/AMReX_YAFluxRegister_3D_K.H @@ -8,7 +8,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 const& flag, FArrayBox const& fxfab, FArrayBox const& fyfab, FArrayBox const& fzfab, - Real dtdx, Real dtdy, Real dtdz, int nc) + Real dtdx, Real dtdy, Real dtdz, int nc) noexcept { auto const fx = fxfab.array(); auto const fy = fyfab.array(); @@ -57,7 +57,7 @@ void yafluxreg_crseadd (Box const& bx, Array4 const& d, Array4 AMREX_GPU_HOST_DEVICE AMREX_INLINE void yafluxreg_fineadd (Box const& bx, Array4 const& d, FArrayBox const& ffab, - Real dtdx, int nc, int dirside, Dim3 const& rr) + Real dtdx, int nc, int dirside, Dim3 const& rr) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 5cc880d3170..a9e8692171f 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -95,6 +95,13 @@ if (ENABLE_SENSEI_INSITU) include(Extern/SENSEI/CMakeLists.txt) endif () +if (ENABLE_SUNDIALS) + include(Extern/SUNDIALS3/CMakeLists.txt) +endif () + +if (ENABLE_CONDUIT) + include (Extern/Conduit/CMakeLists.txt) +endif () # # Here we generate AMReX_BuildInfo.cpp diff --git a/Src/EB/AMReX_EBMultiFabUtil_2d.F90 b/Src/EB/AMReX_EBMultiFabUtil_2d.F90 index 181f02e18cc..433fb12cc44 100644 --- a/Src/EB/AMReX_EBMultiFabUtil_2d.F90 +++ b/Src/EB/AMReX_EBMultiFabUtil_2d.F90 @@ -8,7 +8,9 @@ module amrex_eb_util_module private public :: amrex_eb_avgdown_sv, amrex_eb_avgdown, amrex_eb_avgdown_faces, & amrex_eb_avgdown_boundaries, amrex_compute_eb_divergence, & - amrex_eb_avg_fc_to_cc, amrex_eb_set_covered_nodes + amrex_eb_avg_fc_to_cc, amrex_eb_set_covered_nodes, & + amrex_eb_interpolate_to_face_centroid, & + amrex_eb_interpolate_to_face_centroid_per_cell contains @@ -311,4 +313,179 @@ subroutine amrex_eb_set_covered_nodes (lo, hi, d, dlo, dhi, f, flo, fhi, v, nc) end subroutine amrex_eb_set_covered_nodes + ! Interpolate face-based variable from face center to face centroid -- this version + ! does one face on all grids + subroutine amrex_eb_interpolate_to_face_centroid ( lo, hi, ivar, var, vlo, vhi, ncomp, & + areafrac, alo, ahi, cent, clo, chi, flags, flo, fhi, face_type ) & + bind(c,name='amrex_eb_interpolate_to_face_centroid') + + use amrex_ebcellflag_module, only: is_covered_cell, get_neighbor_cells + + ! Tile bounds ( face centered ) + integer, intent(in ) :: lo(2), hi(2) + + ! Array Bounds + integer, intent(in ) :: vlo(2), vhi(2) + integer, intent(in ) :: alo(2), ahi(2) + integer, intent(in ) :: clo(2), chi(2) + integer, intent(in ) :: flo(2), fhi(2) + integer, intent(in ) :: ncomp + + ! Type of face (1=x, 2=y) + integer, intent(in ) :: face_type + + ! Arrays + real(amrex_real), intent(inout) :: & + & ivar(vlo(1):vhi(1),vlo(2):vhi(2),ncomp) ! Interpolated Variable + + real(amrex_real), intent(inout) :: & + & var(vlo(1):vhi(1),vlo(2):vhi(2),ncomp), & + & areafrac(alo(1):ahi(1),alo(2):ahi(2) ), & + & cent(clo(1):chi(1),clo(2):chi(2), 2) + + integer, intent(in ) :: & + & flags(flo(1):fhi(1),flo(2):fhi(2)) + + ! Local variables + integer :: i, j, n, nbr(-1:1,-1:1) + real(amrex_real) :: fracx, fracy + + select case ( face_type ) + case(1) ! >>>>>>>>>>>>>>>>>>>>>> X-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + do n = 1, ncomp + do j = lo(2), hi(2) + do i = lo(1), hi(1) + if ( ( areafrac(i,j) > zero ) .and. ( areafrac(i,j) < one ) ) then + + call get_neighbor_cells( flags(i,j), nbr ) + + if ( cent(i,j,1) < zero ) then + fracy = - cent(i,j,1) * nbr(0,-1) + ivar(i,j,n) = fracy * var(i,j-1,n) + (one-fracy) * var(i,j,n) + else + fracy = cent(i,j,1) * nbr(0,1) + ivar(i,j,n) = fracy * var(i,j+1,n) + (one-fracy) * var(i,j,n) + end if + else + ivar(i,j,n) = var(i,j,n) + end if + end do + end do + end do + + case(2) ! >>>>>>>>>>>>>>>>>>>>>> Y-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + do n = 1, ncomp + do j = lo(2), hi(2) + do i = lo(1), hi(1) + if ( ( areafrac(i,j) > zero ) .and. ( areafrac(i,j) < one ) ) then + + call get_neighbor_cells( flags(i,j), nbr ) + + if ( cent(i,j,1) < zero ) then + fracx = - cent(i,j,1) * nbr(-1,0) + ivar(i,j,n) = fracx * var(i-1,j,n) + (one-fracx) * var(i,j,n) + else + fracx = cent(i,j,1) * nbr(1,0) + ivar(i,j,n) = fracx * var(i+1,j,n) + (one-fracx) * var(i,j,n) + end if + else + ivar(i,j,n) = var(i,j,n) + end if + end do + end do + end do + + + case default + + write(*,*) "amrex_eb_interpolate_to_face_centroid(): face_type = ", face_type, " but valid values are 1,2" + stop + + end select + + end subroutine amrex_eb_interpolate_to_face_centroid + + ! + ! Returns flux at face centroid in direction dir for just cell (i,j) -- + ! note nbr is passed in + ! + function amrex_eb_interpolate_to_face_centroid_per_cell ( i, j, dir, var, vlo, n, & + afrac, alo, cent, clo, nbr ) result(ivar) + + use amrex_ebcellflag_module, only: is_covered_cell + use amrex_error_module, only: amrex_abort + + ! Face indices: these must be consistent with a staggered indexing + ! and therefore consistent with the value of dir + integer, intent(in ) :: i, j + + ! Direction of staggering (1=x, 2=y): this specify how (i,j) must + ! be interpreted, i.e. which staggered numbering the indexing refer to + integer, intent(in ) :: dir + + ! The component to interpolate + integer, intent(in ) :: n + + ! Array Bounds ( only start index ) + integer, intent(in ) :: vlo(2), alo(2), clo(2) + + ! Arrays + real(amrex_real), intent(in ) :: & + & var(vlo(1):, vlo(2):, 1:), & + & afrac(alo(1):, alo(2): ), & + & cent(clo(1):, clo(2):, 1:) + + ! Neighbors information + integer, intent(in ) :: nbr(-1:1,-1:1) + + ! Output: the interpolated value + real(amrex_real) :: ivar + + ! Local variables + real(amrex_real) :: fracx, fracy + + select case ( dir ) + case(1) ! >>>>>>>>>>>>>>>>>>>>>> X-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + if ( afrac(i,j) == zero ) then + ivar = zero + else if ( afrac(i,j) == one ) then + ivar = var(i,j,n) + else + if ( cent(i,j,1) < zero ) then + fracy = - cent(i,j,1) * nbr(0,-1) + ivar = fracy * var(i,j-1,n) + (one-fracy) * var(i,j,n) + else + fracy = cent(i,j,1) * nbr(0,1) + ivar = fracy * var(i,j+1,n) + (one-fracy) * var(i,j,n) + end if + end if + + + case(2) ! >>>>>>>>>>>>>>>>>>>>>> Y-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + if ( afrac(i,j) == zero ) then + ivar = zero + else if ( afrac(i,j) == one ) then + ivar = var(i,j,n) + else + if ( cent(i,j,1) < zero ) then + fracx = - cent(i,j,1) * nbr(-1,0) + ivar = fracx * var(i-1,j,n) + (one-fracx) * var(i,j,n) + else + fracx = cent(i,j,1) * nbr(1,0) + ivar = fracx * var(i+1,j,n) + (one-fracx) * var(i,j,n) + end if + end if + + case default + + call amrex_abort( "interpolate_to_face_centroid(): value of 'dir'"& + //" is invalid. Must be either 1 or 2") + + end select + + end function amrex_eb_interpolate_to_face_centroid_per_cell + end module amrex_eb_util_module diff --git a/Src/EB/AMReX_EBMultiFabUtil_3d.F90 b/Src/EB/AMReX_EBMultiFabUtil_3d.F90 index 43fe265775a..f8e896e0803 100644 --- a/Src/EB/AMReX_EBMultiFabUtil_3d.F90 +++ b/Src/EB/AMReX_EBMultiFabUtil_3d.F90 @@ -7,7 +7,9 @@ module amrex_eb_util_module private public :: amrex_eb_avgdown_sv, amrex_eb_avgdown, amrex_eb_avgdown_faces, & amrex_eb_avgdown_boundaries, amrex_compute_eb_divergence, & - amrex_eb_avg_fc_to_cc, amrex_eb_set_covered_nodes + amrex_eb_avg_fc_to_cc, amrex_eb_set_covered_nodes, & + amrex_eb_interpolate_to_face_centroid, & + amrex_eb_interpolate_to_face_centroid_per_cell contains @@ -427,7 +429,8 @@ subroutine amrex_eb_set_covered_nodes (lo, hi, d, dlo, dhi, f, flo, fhi, v, nc) end subroutine amrex_eb_set_covered_nodes - ! Interpolate face-based variable from face center to face centroid + ! Interpolate face-based variable from face center to face centroid -- this version + ! does one face on all grids subroutine amrex_eb_interpolate_to_face_centroid ( lo, hi, ivar, var, vlo, vhi, ncomp, & areafrac, alo, ahi, cent, clo, chi, flags, flo, fhi, face_type ) & bind(c,name='amrex_eb_interpolate_to_face_centroid') @@ -528,8 +531,8 @@ subroutine amrex_eb_interpolate_to_face_centroid ( lo, hi, ivar, var, vlo, vhi, if ( cent(i,j,k,2) <= zero ) then fracz = - cent(i,j,k,2) * nbr(0,0,-1) ivar(i,j,k,n) = (one-fracz) * ( fracx * var(i-1,j,k ,n) + & - & (one-fracx) * var(i-1,j,k ,n)) + & - & fracz * ( fracx * var(i ,j,k-1,n) + & + & (one-fracx) * var(i ,j,k ,n)) + & + & fracz * ( fracx * var(i-1,j,k-1,n) + & & (one-fracx) * var(i ,j,k-1,n)) else fracz = cent(i,j,k,2) * nbr(0,0,1) @@ -620,4 +623,175 @@ subroutine amrex_eb_interpolate_to_face_centroid ( lo, hi, ivar, var, vlo, vhi, end subroutine amrex_eb_interpolate_to_face_centroid + ! + ! Returns flux at face centroid in direction dir for just cell (i,j,k) -- + ! note nbr is passed in + ! + function amrex_eb_interpolate_to_face_centroid_per_cell ( i, j, k, dir, var, vlo, n, & + afrac, alo, cent, clo, nbr ) result(ivar) + + use amrex_ebcellflag_module, only: is_covered_cell + use amrex_error_module, only: amrex_abort + + ! Face indices: these must be consistent with a staggered indexing + ! and therefore consistent with the value of dir + integer, intent(in ) :: i, j, k + + ! Direction of staggering (1=x, 2=y, 3=z): this specify how (i,j,k) must + ! be interpreted, i.e. which staggered numbering the indexing refer to + integer, intent(in ) :: dir + + ! The component to interpolate + integer, intent(in ) :: n + + ! Array Bounds ( only start index ) + integer, intent(in ) :: vlo(3), alo(3), clo(3) + + ! Arrays + real(amrex_real), intent(in ) :: & + & var(vlo(1):, vlo(2):, vlo(3):,1:), & + & afrac(alo(1):, alo(2):, alo(3):), & + & cent(clo(1):, clo(2):, clo(3):,1:) + + ! Neighbors information + integer, intent(in ) :: nbr(-1:1,-1:1,-1:1) + + ! Output: the interpolated value + real(amrex_real) :: ivar + + ! Local variables + real(amrex_real) :: fracx, fracy, fracz + + select case ( dir ) + case(1) ! >>>>>>>>>>>>>>>>>>>>>> X-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + if ( afrac(i,j,k) == zero ) then + ivar = zero + else if ( afrac(i,j,k) == one ) then + ivar = var(i,j,k,n) + else + if ( cent(i,j,k,1) < zero ) then + fracy = - cent(i,j,k,1) * nbr(0,-1,0) + if ( cent(i,j,k,2) <= zero ) then + fracz = - cent(i,j,k,2) * nbr(0,0,-1) + ivar = (one-fracz) * ( fracy * var(i,j-1,k ,n) + & + & (one-fracy) * var(i,j ,k ,n)) + & + & fracz * ( fracy * var(i,j-1,k-1,n) + & + & (one-fracy) * var(i,j ,k-1,n)) + else + fracz = cent(i,j,k,2) * nbr(0,0,1) + ivar = (one-fracz) * ( fracy * var(i,j-1,k ,n) + & + & (one-fracy) * var(i,j ,k ,n)) + & + & fracz * ( fracy * var(i,j-1,k+1,n) + & + & (one-fracy) * var(i,j ,k+1,n)) + endif + else + fracy = cent(i,j,k,1) * nbr(0,1,0) + if ( cent(i,j,k,2) <= zero ) then + fracz = - cent(i,j,k,2) * nbr(0,0,-1) + ivar = (one-fracz) * ( fracy * var(i,j+1,k ,n) + & + & (one-fracy) * var(i,j ,k ,n)) + & + & fracz * ( fracy * var(i,j+1,k-1,n) + & + & (one-fracy) * var(i,j ,k-1,n)) + else + fracz = cent(i,j,k,2) * nbr(0,0,1) + ivar= (one-fracz) * ( fracy * var(i,j+1,k ,n) + & + & (one-fracy) * var(i,j ,k ,n)) + & + & fracz * ( fracy * var(i,j+1,k+1,n) + & + & (one-fracy) * var(i,j ,k+1,n)) + endif + end if + end if + + + case(2) ! >>>>>>>>>>>>>>>>>>>>>> Y-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + if ( afrac(i,j,k) == zero ) then + ivar = zero + else if ( afrac(i,j,k) == one ) then + ivar = var(i,j,k,n) + else + if ( cent(i,j,k,1) < zero ) then + fracx = - cent(i,j,k,1) * nbr(-1,0,0) + if ( cent(i,j,k,2) <= zero ) then + fracz = - cent(i,j,k,2) * nbr(0,0,-1) + ivar = (one-fracz) * ( fracx * var(i-1,j,k ,n) + & + & (one-fracx) * var(i ,j,k ,n)) + & + & fracz * ( fracx * var(i-1,j,k-1,n) + & + & (one-fracx) * var(i ,j,k-1,n)) + else + fracz = cent(i,j,k,2) * nbr(0,0,1) + ivar = (one-fracz) * ( fracx * var(i-1,j,k ,n) + & + & (one-fracx) * var(i ,j,k ,n)) + & + & fracz * ( fracx * var(i-1,j,k+1,n) + & + & (one-fracx) * var(i ,j,k+1,n)) + endif + else + fracx = cent(i,j,k,1) * nbr(1,0,0) + if ( cent(i,j,k,2) <= zero ) then + fracz = - cent(i,j,k,2) * nbr(0,0,-1) + ivar = (one-fracz) * ( fracx * var(i+1,j,k ,n) + & + & (one-fracx) * var(i ,j,k ,n)) + & + & fracz * ( fracx * var(i+1,j,k-1,n) + & + & (one-fracx) * var(i ,j,k-1,n)) + else + fracz = cent(i,j,k,2) * nbr(0,0,1) + ivar = (one-fracz) * ( fracx * var(i+1,j,k ,n) + & + & (one-fracx) * var(i ,j,k ,n)) + & + & fracz * ( fracx * var(i+1,j,k+1,n) + & + & (one-fracx) * var(i ,j,k+1,n)) + endif + end if + end if + + + case(3) ! >>>>>>>>>>>>>>>>>>>>>> Z-face <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ! + + if ( afrac(i,j,k) == zero ) then + ivar = zero + else if ( afrac(i,j,k) == one ) then + ivar = var(i,j,k,n) + else + if ( cent(i,j,k,1) < zero ) then + fracx = - cent(i,j,k,1) * nbr(-1,0,0) + if ( cent(i,j,k,2) <= zero ) then + fracy = - cent(i,j,k,2) * nbr(0,-1,0) + ivar = (one-fracy) * ( fracx * var(i-1,j ,k,n) + & + & (one-fracx) * var(i ,j ,k,n)) + & + & fracy * ( fracx * var(i-1,j-1,k,n) + & + & (one-fracx) * var(i ,j-1,k,n)) + else + fracy = cent(i,j,k,2) * nbr(0,1,0) + ivar = (one-fracy) * ( fracx * var(i-1,j ,k,n) + & + & (one-fracx) * var(i ,j ,k,n)) + & + & fracy * ( fracx * var(i-1,j+1,k,n) + & + & (one-fracx) * var(i ,j+1,k,n)) + endif + else + fracx = cent(i,j,k,1) * nbr(1,0,0) + if ( cent(i,j,k,2) <= zero ) then + fracy = - cent(i,j,k,2) * nbr(0,-1,0) + ivar = (one-fracy) * ( fracx * var(i+1,j ,k,n) + & + & (one-fracx) * var(i ,j ,k,n)) + & + & fracy * ( fracx * var(i+1,j-1,k,n) + & + & (one-fracx) * var(i ,j-1,k,n)) + else + fracy = cent(i,j,k,2) * nbr(0,1,0) + ivar = (one-fracy) * ( fracx * var(i+1,j ,k,n) + & + & (one-fracx) * var(i ,j ,k,n)) + & + & fracy * ( fracx * var(i+1,j+1,k,n) + & + & (one-fracx) * var(i ,j+1,k,n)) + endif + end if + end if + + case default + + call amrex_abort( "interpolate_to_face_centroid(): value of 'dir'"& + //" is invalid. Must be either 1,2, or 3") + + end select + + end function amrex_eb_interpolate_to_face_centroid_per_cell + end module amrex_eb_util_module diff --git a/Src/Extern/Conduit/CMakeLists.txt b/Src/Extern/Conduit/CMakeLists.txt new file mode 100644 index 00000000000..aad821dc423 --- /dev/null +++ b/Src/Extern/Conduit/CMakeLists.txt @@ -0,0 +1,3 @@ +# TODO: Particles PR merges another file +add_sources ( AMReX_Conduit_Blueprint.H AMReX_Conduit_Blueprint.cpp) + diff --git a/Src/Extern/SUNDIALS3/CMakeLists.txt b/Src/Extern/SUNDIALS3/CMakeLists.txt new file mode 100644 index 00000000000..74da8a47108 --- /dev/null +++ b/Src/Extern/SUNDIALS3/CMakeLists.txt @@ -0,0 +1,32 @@ +set(_sundials_components nvecserial;cvode;arkode) + +if (ENABLE_OMP) + list(APPEND _sundials_components nvecopenmp) +endif () + +if (ENABLE_CUDA) + list(APPEND _sundials_components nveccuda) +endif () + +if (ENABLE_FORTRAN_INTERFACES) + add_sources(fnvector_serial.f90 fnvector_serial_fprefix.f90) + add_sources(fsunlinsol_dense.f90 fsunmat_dense.f90) + + # Arkcode interfaces + add_sources(arkode_interface.f90 farkode.f90) + + # CVODe interfaces + add_sources(cvode_interface.f90 fcvode.f90 ) +endif () + +# +# We link to libraries and always include nvecserial (in case app code needs it) +# +find_package(SUNDIALS REQUIRED COMPONENTS ${_sundials_components}) +foreach(_comp ${_sundials_components}) + target_link_libraries(amrex PUBLIC SUNDIALS::${_comp}) +endforeach () +target_compile_definitions(amrex PUBLIC AMREX_USE_SUNDIALS_3x4x) + + + diff --git a/Src/LinearSolvers/MLMG/AMReX_MG_1D_K.H b/Src/LinearSolvers/MLMG/AMReX_MG_1D_K.H index f7c938cb1a1..3e2c22bc888 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MG_1D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MG_1D_K.H @@ -7,7 +7,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mg_cc_interp (int i, int /*j*/, int /*k*/, int n, - Array4 const& f, Array4 const& c) + Array4 const& f, Array4 const& c) noexcept { int i2 = 2*i; int i2p1 = i2+1; diff --git a/Src/LinearSolvers/MLMG/AMReX_MG_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MG_2D_K.H index 97af27efd43..419b1c40178 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MG_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MG_2D_K.H @@ -7,7 +7,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mg_cc_interp (int i, int j, int /*k*/, int n, - Array4 const& f, Array4 const& c) + Array4 const& f, Array4 const& c) noexcept { int i2 = 2*i; int j2 = 2*j; diff --git a/Src/LinearSolvers/MLMG/AMReX_MG_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MG_3D_K.H index 37040a638f7..a94127d2b39 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MG_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MG_3D_K.H @@ -7,7 +7,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mg_cc_interp (int i, int j, int k, int n, - Array4 const& f, Array4 const& c) + Array4 const& f, Array4 const& c) noexcept { int i2 = 2*i; int j2 = 2*j; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_1D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_1D_K.H index eb7ed1f0f72..d4e8526056d 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_1D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_1D_K.H @@ -9,7 +9,7 @@ void mlabeclap_adotx (Box const& box, Array4 const& y, Array4 const& a, Array4 const& bX, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; @@ -29,7 +29,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, Array4 const& a, Array4 const& bX, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; @@ -44,7 +44,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac) + Array4 const& bx, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -57,7 +57,7 @@ void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac, int xlen) + Array4 const& bx, Real fac, int xlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -75,7 +75,7 @@ void abec_gsrb (Box const& box, Array4 const& phi, Array4 const& bX, Array4 const& f0, Array4 const& m0, Array4 const& f1, Array4 const& m1, - Box const& vbox, int nc, int redblack) + Box const& vbox, int nc, int redblack) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_2D_K.H index c38871c8be2..3b40676fe3a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_2D_K.H @@ -10,7 +10,7 @@ void mlabeclap_adotx (Box const& box, Array4 const& y, Array4 const& bX, Array4 const& bY, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -36,7 +36,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, Array4 const& bX, Array4 const& bY, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -56,7 +56,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac) + Array4 const& bx, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -71,7 +71,7 @@ void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac, int xlen) + Array4 const& bx, Real fac, int xlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -86,7 +86,7 @@ void mlabeclap_flux_xface (Box const& box, Array4 const& fx, Array4 const& fy, Array4 const& sol, - Array4 const& by, Real fac) + Array4 const& by, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -101,7 +101,7 @@ void mlabeclap_flux_y (Box const& box, Array4 const& fy, Array4 const& fy, Array4 const& sol, - Array4 const& by, Real fac, int ylen) + Array4 const& by, Real fac, int ylen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -128,7 +128,7 @@ void abec_gsrb (Box const& box, Array4 const& phi, Array4 const& f1, Array4 const& m1, Array4 const& f2, Array4 const& m2, Array4 const& f3, Array4 const& m3, - Box const& vbox, int nc, int redblack) + Box const& vbox, int nc, int redblack) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_3D_K.H index 1d77e458a35..a4be08c8006 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLap_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLap_3D_K.H @@ -11,7 +11,7 @@ void mlabeclap_adotx (Box const& box, Array4 const& y, Array4 const& bY, Array4 const& bZ, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -43,7 +43,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, Array4 const& bY, Array4 const& bZ, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -67,7 +67,7 @@ void mlabeclap_normalize (Box const& box, Array4 const& x, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac) + Array4 const& bx, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -84,7 +84,7 @@ void mlabeclap_flux_x (Box const& box, Array4 const& fx, Array4 const& fx, Array4 const& sol, - Array4 const& bx, Real fac, int xlen) + Array4 const& bx, Real fac, int xlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -101,7 +101,7 @@ void mlabeclap_flux_xface (Box const& box, Array4 const& fx, Array4 const& fy, Array4 const& sol, - Array4 const& by, Real fac) + Array4 const& by, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -118,7 +118,7 @@ void mlabeclap_flux_y (Box const& box, Array4 const& fy, Array4 const& fy, Array4 const& sol, - Array4 const& by, Real fac, int ylen) + Array4 const& by, Real fac, int ylen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -139,7 +139,7 @@ void mlabeclap_flux_yface (Box const& box, Array4 const& fy, Array4 const& fz, Array4 const& sol, - Array4 const& bz, Real fac) + Array4 const& bz, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -156,7 +156,7 @@ void mlabeclap_flux_z (Box const& box, Array4 const& fz, Array4 const& fz, Array4 const& sol, - Array4 const& bz, Real fac, int zlen) + Array4 const& bz, Real fac, int zlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -191,7 +191,7 @@ void abec_gsrb (Box const& box, Array4 const& phi, Array4 const& f3, Array4 const& m3, Array4 const& f4, Array4 const& m4, Array4 const& f5, Array4 const& m5, - Box const& vbox, int nc, int redblack) + Box const& vbox, int nc, int redblack) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H index d48eadb79a7..5f6ea14dfb1 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H @@ -33,7 +33,7 @@ public: const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}); - void setScalars (Real a, Real b); + void setScalars (Real a, Real b) noexcept; void setACoeffs (int amrlev, const MultiFab& alpha); void setBCoeffs (int amrlev, const Array& beta); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.cpp index 4a7535f5493..09d30e74787 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.cpp @@ -53,7 +53,7 @@ MLABecLaplacian::~MLABecLaplacian () {} void -MLABecLaplacian::setScalars (Real a, Real b) +MLABecLaplacian::setScalars (Real a, Real b) noexcept { m_a_scalar = a; m_b_scalar = b; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALap_1D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLALap_1D_K.H index 8d521cc5709..d4679bcfd94 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALap_1D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLALap_1D_K.H @@ -11,8 +11,7 @@ void mlalap_adotx (Box const& box, Array4 const& y, Real alpha, Real beta, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) - + int rlo) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; @@ -34,7 +33,7 @@ void mlalap_normalize (Box const& box, Array4 const& x, Real alpha, Real beta, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; @@ -49,7 +48,7 @@ void mlalap_normalize (Box const& box, Array4 const& x, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, - Real fac, Real const* AMREX_RESTRICT re, int rlo) + Real fac, Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -62,7 +61,7 @@ void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_xface (Box const& box, Array4 const& fx, Array4 const& sol, - Real fac, int xlen, Real const* AMREX_RESTRICT re, int rlo) + Real fac, int xlen, Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -82,7 +81,7 @@ void mlalap_gsrb (Box const& box, Array4 const& phi, Box const& vbox, int redblack, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALap_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLALap_2D_K.H index 0422c347bb6..7c1e42f329b 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALap_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLALap_2D_K.H @@ -11,7 +11,7 @@ void mlalap_adotx (Box const& box, Array4 const& y, Real alpha, Real beta, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -37,8 +37,7 @@ void mlalap_normalize (Box const& box, Array4 const& x, Real alpha, Real beta, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) - + int rlo) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -58,7 +57,7 @@ void mlalap_normalize (Box const& box, Array4 const& x, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, - Real fac, Real const* AMREX_RESTRICT re, int rlo) + Real fac, Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -73,7 +72,7 @@ void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_xface (Box const& box, Array4 const& fx, Array4 const& sol, - Real fac, int xlen, Real const* AMREX_RESTRICT re, int rlo) + Real fac, int xlen, Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -88,7 +87,7 @@ void mlalap_flux_xface (Box const& box, Array4 const& fx, Array4 const& fy, Array4 const& sol, - Real fac, Real const* AMREX_RESTRICT rc, int rlo) + Real fac, Real const* AMREX_RESTRICT rc, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -103,7 +102,7 @@ void mlalap_flux_y (Box const& box, Array4 const& fy, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_yface (Box const& box, Array4 const& fy, Array4 const& sol, - Real fac, int ylen, Real const* AMREX_RESTRICT rc, int rlo) + Real fac, int ylen, Real const* AMREX_RESTRICT rc, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -131,7 +130,7 @@ void mlalap_gsrb (Box const& box, Array4 const& phi, Box const& vbox, int redblack, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALap_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLALap_3D_K.H index 0c0d7fcc501..8d5c17f1e7b 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALap_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLALap_3D_K.H @@ -8,7 +8,7 @@ void mlalap_adotx (Box const& box, Array4 const& y, Array4 const& x, Array4 const& a, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -34,7 +34,7 @@ AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_normalize (Box const& box, Array4 const& x, Array4 const& a, GpuArray const& dxinv, - Real alpha, Real beta) + Real alpha, Real beta) noexcept { const Real dhx = beta*dxinv[0]*dxinv[0]; const Real dhy = beta*dxinv[1]*dxinv[1]; @@ -55,7 +55,7 @@ void mlalap_normalize (Box const& box, Array4 const& x, } AMREX_GPU_HOST_DEVICE AMREX_INLINE -void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, Real fac) +void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -72,7 +72,7 @@ void mlalap_flux_x (Box const& box, Array4 const& fx, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_xface (Box const& box, Array4 const& fx, Array4 const& sol, - Real fac, int xlen) + Real fac, int xlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -88,7 +88,7 @@ void mlalap_flux_xface (Box const& box, Array4 const& fx, Array4 const& fy, Array4 const& sol, Real fac) +void mlalap_flux_y (Box const& box, Array4 const& fy, Array4 const& sol, Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -105,7 +105,7 @@ void mlalap_flux_y (Box const& box, Array4 const& fy, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_yface (Box const& box, Array4 const& fy, Array4 const& sol, - Real fac, int ylen) + Real fac, int ylen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -126,7 +126,7 @@ void mlalap_flux_yface (Box const& box, Array4 const& fy, Array4 const& fz, Array4 const& sol, - Real fac) + Real fac) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -143,7 +143,7 @@ void mlalap_flux_z (Box const& box, Array4 const& fz, Array4 c AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlalap_flux_zface (Box const& box, Array4 const& fz, Array4 const& sol, - Real fac, int zlen) + Real fac, int zlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -175,7 +175,7 @@ void mlalap_gsrb (Box const& box, Array4 const& phi, Array4 const& f3, Array4 const& m3, Array4 const& f4, Array4 const& m4, Array4 const& f5, Array4 const& m5, - Box const& vbox, int redblack) + Box const& vbox, int redblack) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H index 523de8cb8ea..c6b9948c66a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H @@ -31,7 +31,7 @@ public: const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}); - void setScalars (Real a, Real b); + void setScalars (Real a, Real b) noexcept; void setACoeffs (int amrlev, const MultiFab& alpha); virtual void prepareForSolve () final override; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.cpp index 626c5f54058..d0db16177b2 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.cpp @@ -43,7 +43,7 @@ MLALaplacian::~MLALaplacian () {} void -MLALaplacian::setScalars (Real a, Real b) +MLALaplacian::setScalars (Real a, Real b) noexcept { m_a_scalar = a; m_b_scalar = b; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H b/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H index d6232191b33..5200b769e4e 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H @@ -24,7 +24,7 @@ public: MLCGSolver (const MLCGSolver& rhs) = delete; MLCGSolver& operator= (const MLCGSolver& rhs) = delete; - void setSolver (Type _typ) { solver_type = _typ; } + void setSolver (Type _typ) noexcept { solver_type = _typ; } /** * solve the system, Lp(solnL)=rhsL to relative err, tolerance diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H index c4620dffe89..263b6fd1b83 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H @@ -147,16 +147,16 @@ protected: struct MetricFactor { MetricFactor (const BoxArray& ba, const DistributionMapping& dm, const Geometry& geom, bool null_metric); - const Vector& cellCenters (const MFIter& mfi) const { + const Vector& cellCenters (const MFIter& mfi) const noexcept { return r_cellcenter[mfi]; } - const Vector& cellEdges (const MFIter& mfi) const { + const Vector& cellEdges (const MFIter& mfi) const noexcept { return r_celledge[mfi]; } - const Vector& invCellCenters (const MFIter& mfi) const { + const Vector& invCellCenters (const MFIter& mfi) const noexcept { return inv_r_cellcenter[mfi]; } - const Vector& invCellEdges (const MFIter& mfi) const { + const Vector& invCellEdges (const MFIter& mfi) const noexcept { return inv_r_celledge[mfi]; } LayoutData > r_cellcenter; @@ -186,10 +186,10 @@ protected: const Array& lobc, const Array& hibc, int ratio, const RealVect& a_loc); - const BCTuple& bndryConds (const MFIter& mfi) const { + const BCTuple& bndryConds (const MFIter& mfi) const noexcept { return bcond[mfi]; } - const RealTuple& bndryLocs (const MFIter& mfi) const { + const RealTuple& bndryLocs (const MFIter& mfi) const noexcept { return bcloc[mfi]; } private: diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H index 24bf6fd450d..15372233a55 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H @@ -126,8 +126,8 @@ private: // // functions // - bool isEBDirichlet () const { return m_eb_phi[0] != nullptr; } - bool isHOEBDirichlet () const { return m_is_eb_ho_dir;} + bool isEBDirichlet () const noexcept { return m_eb_phi[0] != nullptr; } + bool isHOEBDirichlet () const noexcept { return m_is_eb_ho_dir;} void averageDownCoeffsSameAmrLevel (Vector& a, Vector >& b, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp index f7a6e6062c9..6626a6a3f67 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp @@ -616,7 +616,6 @@ MLEBABecLap::Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, } else { - FArrayBox const& phiebfab = (is_eb_dirichlet && m_is_eb_inhomog) ? (*m_eb_phi[amrlev])[mfi] : foo; FArrayBox const& bebfab = (is_eb_dirichlet) ? (*m_eb_b_coeffs[amrlev][mglev])[mfi] : foo; amrex_mlebabeclap_gsrb(BL_TO_FORTRAN_BOX(tbx), @@ -651,7 +650,6 @@ MLEBABecLap::Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, BL_TO_FORTRAN_ANYD((*bcent)[mfi]), BL_TO_FORTRAN_ANYD(bebfab), is_dirichlet, is_ho_dirichlet, - BL_TO_FORTRAN_ANYD(phiebfab), m_is_eb_inhomog, dxinv, m_a_scalar, m_b_scalar, redblack); } } diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_2d.F90 b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_2d.F90 index 95bbddb3b51..59736bdb39a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_2d.F90 +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_2d.F90 @@ -243,7 +243,6 @@ subroutine amrex_mlebabeclap_adotx(lo, hi, y, ylo, yhi, x, xlo, xhi, a, alo, ahi end subroutine amrex_mlebabeclap_adotx - subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, ahi, & bx, bxlo, bxhi, by, bylo, byhi, & ccm, cmlo, cmhi, & @@ -254,18 +253,18 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, flag, flo, fhi, vfrc, vlo, vhi, & apx, axlo, axhi, apy, aylo, ayhi, fcx, cxlo, cxhi, fcy, cylo, cyhi, & ba, balo, bahi, bc, bclo, bchi, beb, elo, ehi, & - is_dirichlet, is_ho_dirichlet, phieb, p_lo, p_hi, & - is_inhomog, dxinv, alpha, beta, redblack) & + is_dirichlet, is_ho_dirichlet, & + dxinv, alpha, beta, redblack) & bind(c,name='amrex_mlebabeclap_gsrb') integer, dimension(2), intent(in) :: lo, hi, hlo, hhi, rlo, rhi, alo, ahi, bxlo, bxhi, bylo, byhi, & cmlo, cmhi, m0lo, m0hi, m1lo, m1hi, m2lo, m2hi, m3lo, m3hi, & f0lo, f0hi, f1lo, f1hi, f2lo, f2hi, f3lo, f3hi, & flo, fhi, vlo, vhi, axlo, axhi, aylo, ayhi, cxlo, cxhi, cylo, cyhi, & - balo, bahi, bclo, bchi, elo, ehi, p_lo, p_hi + balo, bahi, bclo, bchi, elo, ehi real(amrex_real), intent(in) :: dxinv(2) - integer , intent(in ) :: is_dirichlet, is_ho_dirichlet, is_inhomog + integer , value, intent(in) :: is_dirichlet, is_ho_dirichlet real(amrex_real), value, intent(in) :: alpha, beta integer, value, intent(in) :: redblack real(amrex_real), intent(inout) :: phi( hlo(1): hhi(1), hlo(2): hhi(2)) @@ -291,7 +290,6 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, real(amrex_real), intent(in ) :: ba(balo(1):bahi(1),balo(2):bahi(2)) real(amrex_real), intent(in ) :: bc(bclo(1):bchi(1),bclo(2):bchi(2),2) real(amrex_real), intent(in ) :: beb( elo(1): ehi(1), elo(2): ehi(2)) - real(amrex_real), intent(in ) ::phieb(p_lo(1):p_hi(1),p_lo(2):p_hi(2)) integer :: i,j,ioff,ii,jj real(amrex_real) :: cf0, cf1, cf2, cf3, delta, gamma, rho, res, vfrcinv @@ -305,9 +303,6 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, real(amrex_real), parameter :: omega = 1._amrex_real real(amrex_real) :: dphidn - logical :: is_inhomogeneous - - is_inhomogeneous = is_inhomog .ne. 0 dhx = beta*dxinv(1)*dxinv(1) dhy = beta*dxinv(2)*dxinv(2) @@ -405,11 +400,8 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, anrmx = (apx(i,j)-apx(i+1,j)) * anorminv anrmy = (apy(i,j)-apy(i,j+1)) * anorminv - if (is_inhomogeneous) then - phib = phieb(i,j) - else - phib = zero - end if + ! In gsrb we are always in residual-correction form so phib = 0 + phib = zero call compute_dphidn_2d(dphidn, dxinv, i, j, & phi, hlo, hhi, & @@ -496,14 +488,8 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, phig_gamma = w1*phig1_gamma phig = w1*phig1 + w2*phig2 - if (is_inhomogeneous) then - phib = phieb(i,j) - else - phib = zero - end if - feb_gamma = -phig_gamma/dg * ba(i,j) * beb(i,j) - feb = (phib-phig)/dg * ba(i,j) * beb(i,j) + feb = ( -phig)/dg * ba(i,j) * beb(i,j) gamma = gamma + vfrcinv*(-dhx)*feb_gamma rho = rho - vfrcinv*(-dhx)*feb @@ -837,7 +823,6 @@ subroutine compute_dphidn_2d (dudn, dxinv, i, j, & real(amrex_real), intent( out) :: dudn ! Local variable - real(amrex_real) :: dapx, dapy real(amrex_real) :: anrm real(amrex_real) :: xit, yit, s, s2 real(amrex_real) :: d1, d2, ddinv diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_3d.F90 b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_3d.F90 index 890828978ce..7fea635d397 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_3d.F90 +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_3d.F90 @@ -275,8 +275,8 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, flag, flo, fhi, vfrc, vlo, vhi, & apx, axlo, axhi, apy, aylo, ayhi, apz, azlo, azhi, fcx, cxlo, cxhi, fcy, cylo, cyhi, & fcz, czlo, czhi, ba, balo, bahi, bc, bclo, bchi, beb, elo, ehi, & - is_dirichlet, is_ho_dirichlet, phieb, p_lo, p_hi, & - is_inhomog, dxinv, alpha, beta, redblack) & + is_dirichlet, is_ho_dirichlet, & + dxinv, alpha, beta, redblack) & bind(c,name='amrex_mlebabeclap_gsrb') integer, dimension(3), intent(in) :: lo, hi, hlo, hhi, rlo, rhi, alo, ahi, bxlo, bxhi, bylo, byhi, & @@ -284,9 +284,9 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, m0lo, m0hi, m1lo, m1hi, m2lo, m2hi, m3lo, m3hi, m4lo, m4hi, m5lo, m5hi, & f0lo, f0hi, f1lo, f1hi, f2lo, f2hi, f3lo, f3hi, f4lo, f4hi ,f5lo, f5hi, flo, fhi, vlo, vhi,& axlo, axhi, aylo, ayhi, azlo, azhi, cxlo, cxhi, cylo, cyhi, czlo, czhi, & - balo, bahi, bclo, bchi, elo, ehi, p_lo, p_hi + balo, bahi, bclo, bchi, elo, ehi real(amrex_real), intent(in) :: dxinv(3) - integer , value, intent(in) :: is_dirichlet, is_ho_dirichlet, is_inhomog + integer , value, intent(in) :: is_dirichlet, is_ho_dirichlet real(amrex_real), value, intent(in) :: alpha, beta integer , value, intent(in) :: redblack real(amrex_real), intent(inout) :: phi( hlo(1): hhi(1), hlo(2): hhi(2), hlo(3): hhi(3) ) @@ -319,7 +319,6 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, real(amrex_real), intent(in ) :: ba (balo(1):bahi(1),balo(2):bahi(2),balo(3):bahi(3)) real(amrex_real), intent(in ) :: bc (bclo(1):bchi(1),bclo(2):bchi(2),bclo(3):bchi(3),3) real(amrex_real), intent(in ) :: beb( elo(1): ehi(1), elo(2): ehi(2), elo(3): ehi(3)) - real(amrex_real), intent(in ) ::phieb(p_lo(1):p_hi(1),p_lo(2):p_hi(2),p_lo(3):p_hi(3)) integer :: i, j, k, ioff, ii, jj, kk real(amrex_real) :: cf0, cf1, cf2, cf3, cf4, cf5, delta, gamma, rho, res, vfrcinv @@ -329,13 +328,10 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, real(amrex_real) :: feb_gamma, phig_gamma real(amrex_real) :: anrmx, anrmy, anrmz, anorm, anorminv, sx, sy, sz real(amrex_real) :: bctx, bcty, bctz - logical :: is_inhomogeneous real(amrex_real), parameter :: omega = 1.15_amrex_real ! over-relaxation real(amrex_real) :: dphidn, phib - is_inhomogeneous = is_inhomog .ne. 0 - dhx = beta*dxinv(1)*dxinv(1) dhy = beta*dxinv(2)*dxinv(2) dhz = beta*dxinv(3)*dxinv(3) @@ -504,6 +500,9 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, anrmy = (apy(i,j,k)-apy(i,j+1,k)) * anorminv anrmz = (apz(i,j,k)-apz(i,j,k+1)) * anorminv + ! In gsrb we are always in residual-correction form so phib = 0 + phib = zero + call compute_dphidn_3d(dphidn, dxinv, i, j, k, & phi, hlo, hhi, & flag, flo, fhi, & @@ -555,14 +554,8 @@ subroutine amrex_mlebabeclap_gsrb(lo, hi, phi, hlo, hhi, rhs, rlo, rhi, a, alo, + (gxy + gxyz) * phi(ii,jj,k) & + (-gxyz) * phi(ii,jj,kk) - if (is_inhomogeneous) then - phib = phieb(i,j,k) - else - phib = zero - end if - feb_gamma = -phig_gamma/dg * ba(i,j,k) * beb(i,j,k) - feb = (phib-phig)/dg * ba(i,j,k) * beb(i,j,k) + feb = ( -phig)/dg * ba(i,j,k) * beb(i,j,k) gamma = gamma + vfrcinv*(-dhx)*feb_gamma rho = rho - vfrcinv*(-dhx)*feb @@ -1047,28 +1040,12 @@ subroutine compute_dphidn_3d (dudn, dxinv, i, j, k, & real(amrex_real), intent( out) :: dudn ! Local variable - real(amrex_real) :: dapx, dapy, dapz real(amrex_real) :: anrm real(amrex_real) :: xit, yit, zit, s, s2 real(amrex_real) :: d1, d2, ddinv real(amrex_real) :: u1, u2 integer :: ixit, iyit, izit, is, is2, ivar - ! dapx = apx(i+1,j,k)-apx(i,j,k) - ! dapy = apy(i,j+1,k)-apy(i,j,k) - ! dapz = apz(i,j,k+1)-apz(i,j,k) - - ! apnorm = sqrt(dapx**2+dapy**2+dapz**2) - - ! if ( apnorm == zero ) then - ! call amrex_abort("compute_diff_wallflux: we are in trouble.") - ! end if - - ! apnorminv = one/apnorm - ! anrmx = -dapx * apnorminv ! unit vector pointing toward the wall - ! anrmy = -dapy * apnorminv - ! anrmz = -dapz * apnorminv - if (abs(anrmx).ge.abs(anrmy) .and. abs(anrmx).ge.abs(anrmz)) then anrm = anrmx ivar = 1 diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.H b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.H index f6c27e54668..3b3e4d3ce83 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.H @@ -103,8 +103,7 @@ extern "C" { const amrex_real* bc, const int* bclo, const int* bchi, const amrex_real* beb, const int* elo, const int* ehi, const int is_dirichlet, const int is_ho_dirichlet, - const amrex_real* phieb, const int* plo, const int* phi, - const int is_inhomog, const amrex_real* dxinv, + const amrex_real* dxinv, const amrex_real alpha, const amrex_real beta, const int redblack); void amrex_mlebabeclap_flux( const int* lo, const int* hi, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H index 70b4932e716..45adfecefb9 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H @@ -32,12 +32,12 @@ struct LPInfo bool has_metric_term = true; int max_coarsening_level = 30; - LPInfo& setAgglomeration (bool x) { do_agglomeration = x; return *this; } - LPInfo& setConsolidation (bool x) { do_consolidation = x; return *this; } - LPInfo& setAgglomerationGridSize (int x) { agg_grid_size = x; return *this; } - LPInfo& setConsolidationGridSize (int x) { con_grid_size = x; return *this; } - LPInfo& setMetricTerm (bool x) { has_metric_term = x; return *this; } - LPInfo& setMaxCoarseningLevel (int n) { max_coarsening_level = n; return *this; } + LPInfo& setAgglomeration (bool x) noexcept { do_agglomeration = x; return *this; } + LPInfo& setConsolidation (bool x) noexcept { do_consolidation = x; return *this; } + LPInfo& setAgglomerationGridSize (int x) noexcept { agg_grid_size = x; return *this; } + LPInfo& setConsolidationGridSize (int x) noexcept { con_grid_size = x; return *this; } + LPInfo& setMetricTerm (bool x) noexcept { has_metric_term = x; return *this; } + LPInfo& setMaxCoarseningLevel (int n) noexcept { max_coarsening_level = n; return *this; } }; class MLLinOp @@ -82,7 +82,7 @@ public: * \param hibc */ void setDomainBC (const Array& lobc, - const Array& hibc); + const Array& hibc) noexcept; /** @@ -91,7 +91,7 @@ public: * supplying Dirichlet bc at coarse/fine boundary, even when the * domain bc is not Dirichlet. */ - bool needsCoarseDataForBC () const { return m_needs_coarse_data_for_bc; } + bool needsCoarseDataForBC () const noexcept { return m_needs_coarse_data_for_bc; } /** @@ -104,7 +104,7 @@ public: * \param crse * \param crse_ratio */ - void setCoarseFineBC (const MultiFab* crse, int crse_ratio); + void setCoarseFineBC (const MultiFab* crse, int crse_ratio) noexcept; /** @@ -124,10 +124,10 @@ public: */ virtual void setLevelBC (int amrlev, const MultiFab* levelbcdata) = 0; - void setVerbose (int v) { verbose = v; } + void setVerbose (int v) noexcept { verbose = v; } - void setMaxOrder (int o) { maxorder = o; } - int getMaxOrder () const { return maxorder; } + void setMaxOrder (int o) noexcept { maxorder = o; } + int getMaxOrder () const noexcept { return maxorder; } virtual int getNComp() const { return 1; } @@ -229,7 +229,7 @@ protected: MPI_Comm m_bottom_comm = MPI_COMM_NULL; struct CommContainer { MPI_Comm comm; - CommContainer (MPI_Comm m) : comm(m) {} + CommContainer (MPI_Comm m) noexcept : comm(m) {} CommContainer (const CommContainer&) = delete; CommContainer (CommContainer&&) = delete; void operator= (const CommContainer&) = delete; @@ -255,23 +255,23 @@ protected: /** * \brief functions */ - int NAMRLevels () const { return m_num_amr_levels; } - int NMGLevels (int amrlev) const { return m_num_mg_levels[amrlev]; } - const Vector& AMRRefRatio () const { return m_amr_ref_ratio; } - int AMRRefRatio (int amr_lev) const { return m_amr_ref_ratio[amr_lev]; } + int NAMRLevels () const noexcept { return m_num_amr_levels; } + int NMGLevels (int amrlev) const noexcept { return m_num_mg_levels[amrlev]; } + const Vector& AMRRefRatio () const noexcept { return m_amr_ref_ratio; } + int AMRRefRatio (int amr_lev) const noexcept { return m_amr_ref_ratio[amr_lev]; } - const Geometry& Geom (int amr_lev, int mglev=0) const { return m_geom[amr_lev][mglev]; } - FabFactory const* Factory (int amr_lev, int mglev=0) const { + const Geometry& Geom (int amr_lev, int mglev=0) const noexcept { return m_geom[amr_lev][mglev]; } + FabFactory const* Factory (int amr_lev, int mglev=0) const noexcept { return m_factory[amr_lev][mglev].get(); } #ifdef BL_USE_MPI - bool isBottomActive () const { return m_bottom_comm != MPI_COMM_NULL; } + bool isBottomActive () const noexcept { return m_bottom_comm != MPI_COMM_NULL; } #else - bool isBottomActive () const { return true; } + bool isBottomActive () const noexcept { return true; } #endif - MPI_Comm BottomCommunicator () const { return m_bottom_comm; } - MPI_Comm Communicator (int amrlev, int mglev) const { + MPI_Comm BottomCommunicator () const noexcept { return m_bottom_comm; } + MPI_Comm Communicator (int amrlev, int mglev) const noexcept { if (amrlev == 0 && mglev == NMGLevels(0)-1) { return m_bottom_comm; } else { @@ -279,12 +279,12 @@ protected: } } - void setCoarseFineBCLocation (const RealVect& cloc) { m_coarse_bc_loc = cloc; } + void setCoarseFineBCLocation (const RealVect& cloc) noexcept { m_coarse_bc_loc = cloc; } - bool doAgglomeration () const { return m_do_agglomeration; } - bool doConsolidation () const { return m_do_consolidation; } + bool doAgglomeration () const noexcept { return m_do_agglomeration; } + bool doConsolidation () const noexcept { return m_do_consolidation; } - bool isCellCentered () const { return m_ixtype == 0; } + bool isCellCentered () const noexcept { return m_ixtype == 0; } void make (Vector >& mf, int nc, int ng) const; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.cpp b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.cpp index 131ef7b8b29..9dee679ca47 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.cpp @@ -459,7 +459,7 @@ MLLinOp::make (Vector >& mf, int nc, int ng) const void MLLinOp::setDomainBC (const Array& a_lobc, - const Array& a_hibc) + const Array& a_hibc) noexcept { m_lobc = a_lobc; m_hibc = a_hibc; @@ -476,7 +476,7 @@ MLLinOp::setDomainBC (const Array& a_lobc, } void -MLLinOp::setCoarseFineBC (const MultiFab* crse, int crse_ratio) +MLLinOp::setCoarseFineBC (const MultiFab* crse, int crse_ratio) noexcept { m_coarse_data_for_bc = crse; m_coarse_data_crse_ratio = crse_ratio; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLLinOp_K.H b/Src/LinearSolvers/MLMG/AMReX_MLLinOp_K.H index b7a7908e0c9..a0292139061 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLLinOp_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLLinOp_K.H @@ -14,7 +14,7 @@ void mllinop_apply_bc_x (int side, Box const& box, int blen, Array4 const& mask, BoundCond bct, Real bcl, Array4 const& bcval, - int maxorder, Real dxinv, int inhomog, int ncomp) + int maxorder, Real dxinv, int inhomog, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -84,7 +84,7 @@ void mllinop_apply_bc_y (int side, Box const& box, int blen, Array4 const& mask, BoundCond bct, Real bcl, Array4 const& bcval, - int maxorder, Real dyinv, int inhomog, int ncomp) + int maxorder, Real dyinv, int inhomog, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -154,7 +154,7 @@ void mllinop_apply_bc_z (int side, Box const& box, int blen, Array4 const& mask, BoundCond bct, Real bcl, Array4 const& bcval, - int maxorder, Real dzinv, int inhomog, int ncomp) + int maxorder, Real dzinv, int inhomog, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -223,7 +223,7 @@ void mllinop_comp_interp_coef0_x (int side, Box const& box, int blen, Array4 const& f, Array4 const& mask, BoundCond bct, Real bcl, - int maxorder, Real dxinv, int ncomp) + int maxorder, Real dxinv, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -279,7 +279,7 @@ void mllinop_comp_interp_coef0_y (int side, Box const& box, int blen, Array4 const& f, Array4 const& mask, BoundCond bct, Real bcl, - int maxorder, Real dyinv, int ncomp) + int maxorder, Real dyinv, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -335,7 +335,7 @@ void mllinop_comp_interp_coef0_z (int side, Box const& box, int blen, Array4 const& f, Array4 const& mask, BoundCond bct, Real bcl, - int maxorder, Real dzinv, int ncomp) + int maxorder, Real dzinv, int ncomp) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG.H b/Src/LinearSolvers/MLMG/AMReX_MLMG.H index 0335f00e400..e6a48fd57fc 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG.H @@ -60,35 +60,35 @@ public: */ void apply (const Vector& out, const Vector& in); - void setVerbose (int v) { verbose = v; } - void setMaxIter (int n) { max_iters = n; } - void setMaxFmgIter (int n) { max_fmg_iters = n; } - void setFixedIter (int nit) { do_fixed_number_of_iters = nit; } + void setVerbose (int v) noexcept { verbose = v; } + void setMaxIter (int n) noexcept { max_iters = n; } + void setMaxFmgIter (int n) noexcept { max_fmg_iters = n; } + void setFixedIter (int nit) noexcept { do_fixed_number_of_iters = nit; } - void setPreSmooth (int n) { nu1 = n; } - void setPostSmooth (int n) { nu2 = n; } - void setFinalSmooth (int n) { nuf = n; } - void setBottomSmooth (int n) { nub = n; } + void setPreSmooth (int n) noexcept { nu1 = n; } + void setPostSmooth (int n) noexcept { nu2 = n; } + void setFinalSmooth (int n) noexcept { nuf = n; } + void setBottomSmooth (int n) noexcept { nub = n; } - void setBottomSolver (BottomSolver s) { bottom_solver = s; } - void setBottomVerbose (int v) { bottom_verbose = v; } - void setBottomMaxIter (int n) { bottom_maxiter = n; } - void setBottomTolerance (Real t) { bottom_reltol = t; } - void setCGVerbose (int v) { bottom_verbose = v; } - void setCGMaxIter (int n) { bottom_maxiter = n; } - void setCGTolerance (Real t) { bottom_reltol = t; } + void setBottomSolver (BottomSolver s) noexcept { bottom_solver = s; } + void setBottomVerbose (int v) noexcept { bottom_verbose = v; } + void setBottomMaxIter (int n) noexcept { bottom_maxiter = n; } + void setBottomTolerance (Real t) noexcept { bottom_reltol = t; } + void setCGVerbose (int v) noexcept { bottom_verbose = v; } + void setCGMaxIter (int n) noexcept { bottom_maxiter = n; } + void setCGTolerance (Real t) noexcept { bottom_reltol = t; } - void setAlwaysUseBNorm (int flag) { always_use_bnorm = flag; } + void setAlwaysUseBNorm (int flag) noexcept { always_use_bnorm = flag; } - void setFinalFillBC (int flag) { final_fill_bc = flag; } + void setFinalFillBC (int flag) noexcept { final_fill_bc = flag; } - int numAMRLevels () const { return namrlevs; } + int numAMRLevels () const noexcept { return namrlevs; } - void setNSolve (int flag) { do_nsolve = flag; } - void setNSolveGridSize (int s) { nsolve_grid_size = s; } + void setNSolve (int flag) noexcept { do_nsolve = flag; } + void setNSolveGridSize (int s) noexcept { nsolve_grid_size = s; } #ifdef AMREX_USE_HYPRE - void setHypreInterface (Hypre::Interface f) { + void setHypreInterface (Hypre::Interface f) noexcept { // must use ij interface for EB #ifndef AMREX_USE_EB hypre_interface = f; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG_1D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLMG_1D_K.H index 300dea2b381..b71cafb57a1 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG_1D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG_1D_K.H @@ -5,7 +5,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -22,7 +22,7 @@ void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r4 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLMG_2D_K.H index fcc3d1649a9..4e4eaab3b93 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG_2D_K.H @@ -5,7 +5,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -30,7 +30,7 @@ void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r4 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLMG_3D_K.H index f8ee804deef..66b2ed77a97 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG_3D_K.H @@ -5,7 +5,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -37,7 +37,7 @@ void mlmg_lin_cc_interp_r2 (Box const& bx, Array4 const& ff, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlmg_lin_cc_interp_r4 (Box const& bx, Array4 const& ff, - Array4 const& cc, int nc) + Array4 const& cc, int nc) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H index c7bae5e0f60..8d345edc84e 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H @@ -15,7 +15,7 @@ public : enum struct CoarseningStrategy { Sigma, RAP }; - MLNodeLaplacian () {} + MLNodeLaplacian () noexcept {} MLNodeLaplacian (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, @@ -49,7 +49,7 @@ public : const Vector& a_factory); #endif - void setRZCorrection (bool rz) { m_is_rz = rz; } + void setRZCorrection (bool rz) noexcept { m_is_rz = rz; } void setSigma (int amrlev, const MultiFab& a_sigma); @@ -68,10 +68,10 @@ public : void compSyncResidualFine (MultiFab& sync_resid, const MultiFab& phi, const MultiFab& vold, const MultiFab* rhcc); - void setGaussSeidel (bool flag) { m_use_gauss_seidel = flag; } - void setHarmonicAverage (bool flag) { m_use_harmonic_average = flag; } + void setGaussSeidel (bool flag) noexcept { m_use_gauss_seidel = flag; } + void setHarmonicAverage (bool flag) noexcept { m_use_harmonic_average = flag; } - void setCoarseningStrategy (CoarseningStrategy cs) { m_coarsening_strategy = cs; } + void setCoarseningStrategy (CoarseningStrategy cs) noexcept { m_coarsening_strategy = cs; } virtual void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final override; virtual void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final override; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLPoisson.H b/Src/LinearSolvers/MLMG/AMReX_MLPoisson.H index dada7fecec3..9db086ec5db 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLPoisson.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLPoisson.H @@ -14,7 +14,7 @@ class MLPoisson { public: - MLPoisson () {} + MLPoisson () noexcept {} MLPoisson (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_1D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_1D_K.H index 6dd494ce93f..e963a5597e5 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_1D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_1D_K.H @@ -8,7 +8,7 @@ void mlpoisson_adotx (int i, int /*j*/, int /*k*/, Array4 const& y, Array4 const& x, Real dhx, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { y(i,0,0) = dhx * (re[i-rlo]*x(i-1,0,0) - (re[i-rlo]+re[i+1-rlo])*x(i,0,0) @@ -18,7 +18,7 @@ void mlpoisson_adotx (int i, int /*j*/, int /*k*/, Array4 const& y, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, Real dxinv, - Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -32,7 +32,7 @@ void mlpoisson_flux_x (Box const& box, Array4 const& fx, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_xface (Box const& box, Array4 const& fx, Array4 const& sol, Real dxinv, int xlen, - Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -49,7 +49,7 @@ void mlpoisson_gsrb (Box const& box, Array4 const& phi, Array4 Array4 const& f0, Array4 const& m0, Array4 const& f1, Array4 const& m1, Box const& vbox, int redblack, - Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -78,7 +78,7 @@ void mlpoisson_gsrb (Box const& box, Array4 const& phi, Array4 AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_normalize (Box const& box, Array4 const& x, - Real const* AMREX_RESTRICT re, int rlo, Real dhx) + Real const* AMREX_RESTRICT re, int rlo, Real dhx) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H index ff2b310546d..f85fd46a44c 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H @@ -9,7 +9,7 @@ void mlpoisson_adotx (int i, int j, int /*k*/, Array4 const& y, Real dhx, Real dhy, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, - int rlo) + int rlo) noexcept { y(i,j,0) = dhx * (re[i-rlo]*x(i-1,j,0) - (re[i-rlo]+re[i+1-rlo])*x(i,j,0) @@ -20,7 +20,7 @@ void mlpoisson_adotx (int i, int j, int /*k*/, Array4 const& y, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_x (Box const& box, Array4 const& fx, Array4 const& sol, Real dxinv, - Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -36,7 +36,7 @@ void mlpoisson_flux_x (Box const& box, Array4 const& fx, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_xface (Box const& box, Array4 const& fx, Array4 const& sol, Real dxinv, int xlen, - Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -52,7 +52,7 @@ void mlpoisson_flux_xface (Box const& box, Array4 const& fx, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_y (Box const& box, Array4 const& fy, Array4 const& sol, Real dyinv, - Real const* AMREX_RESTRICT rc, int rlo) + Real const* AMREX_RESTRICT rc, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -68,7 +68,7 @@ void mlpoisson_flux_y (Box const& box, Array4 const& fy, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_yface (Box const& box, Array4 const& fy, Array4 const& sol, Real dyinv, int ylen, - Real const* AMREX_RESTRICT rc, int rlo) + Real const* AMREX_RESTRICT rc, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -93,7 +93,7 @@ void mlpoisson_gsrb (Box const& box, Array4 const& phi, Array4 Array4 const& f2, Array4 const& m2, Array4 const& f3, Array4 const& m3, Box const& vbox, int redblack, - Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, int rlo) + Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, int rlo) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -130,7 +130,7 @@ void mlpoisson_gsrb (Box const& box, Array4 const& phi, Array4 AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_normalize (Box const& box, Array4 const& x, Real const* AMREX_RESTRICT rc, Real const* AMREX_RESTRICT re, int rlo, - Real dhx, Real dhy) + Real dhx, Real dhy) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_3D_K.H index e4f3ef06ad2..821c7ae0c53 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_3D_K.H @@ -6,7 +6,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void mlpoisson_adotx (int i, int j, int k, Array4 const& y, Array4 const& x, - Real dhx, Real dhy, Real dhz) + Real dhx, Real dhy, Real dhz) noexcept { y(i,j,k) = dhx * (x(i-1,j,k) - 2.0*x(i,j,k) + x(i+1,j,k)) + dhy * (x(i,j-1,k) - 2.0*x(i,j,k) + x(i,j+1,k)) @@ -15,7 +15,7 @@ void mlpoisson_adotx (int i, int j, int k, Array4 const& y, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_x (Box const& box, Array4 const& fx, - Array4 const& sol, Real dxinv) + Array4 const& sol, Real dxinv) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -32,7 +32,7 @@ void mlpoisson_flux_x (Box const& box, Array4 const& fx, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_xface (Box const& box, Array4 const& fx, - Array4 const& sol, Real dxinv, int xlen) + Array4 const& sol, Real dxinv, int xlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -49,7 +49,7 @@ void mlpoisson_flux_xface (Box const& box, Array4 const& fx, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_y (Box const& box, Array4 const& fy, - Array4 const& sol, Real dyinv) + Array4 const& sol, Real dyinv) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -66,7 +66,7 @@ void mlpoisson_flux_y (Box const& box, Array4 const& fy, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_yface (Box const& box, Array4 const& fy, - Array4 const& sol, Real dyinv, int ylen) + Array4 const& sol, Real dyinv, int ylen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -87,7 +87,7 @@ void mlpoisson_flux_yface (Box const& box, Array4 const& fy, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_z (Box const& box, Array4 const& fz, - Array4 const& sol, Real dzinv) + Array4 const& sol, Real dzinv) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -104,7 +104,7 @@ void mlpoisson_flux_z (Box const& box, Array4 const& fz, AMREX_GPU_HOST_DEVICE AMREX_INLINE void mlpoisson_flux_zface (Box const& box, Array4 const& fz, - Array4 const& sol, Real dzinv, int zlen) + Array4 const& sol, Real dzinv, int zlen) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); @@ -136,7 +136,7 @@ void mlpoisson_gsrb (Box const& box, Array4 const& phi, Array4 const& f3, Array4 const& m3, Array4 const& f4, Array4 const& m4, Array4 const& f5, Array4 const& m5, - Box const& vbox, int redblack) + Box const& vbox, int redblack) noexcept { const auto lo = amrex::lbound(box); const auto hi = amrex::ubound(box); diff --git a/Src/LinearSolvers/MLMG/AMReX_MacProjector.H b/Src/LinearSolvers/MLMG/AMReX_MacProjector.H index b9695a1d7c9..50e0df3c245 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MacProjector.H +++ b/Src/LinearSolvers/MLMG/AMReX_MacProjector.H @@ -25,12 +25,12 @@ public: void project (const Vector& phi_in, Real reltol, Real atol = 0.0 ); void project (Real reltol, Real atol = 0.0 ); - void setVerbose (int v) { m_verbose = v; } + void setVerbose (int v) noexcept { m_verbose = v; } - void setBottomSolver (MLMG::BottomSolver bottom_solver_type_in) + void setBottomSolver (MLMG::BottomSolver bottom_solver_type_in) noexcept { bottom_solver_type = bottom_solver_type_in;} - MLLinOp& getLinOp () { return *m_linop; } + MLLinOp& getLinOp () noexcept { return *m_linop; } private: diff --git a/Src/Particle/AMReX_ParticleContainerI.H b/Src/Particle/AMReX_ParticleContainerI.H index 4e917dad342..8d0349d2da8 100644 --- a/Src/Particle/AMReX_ParticleContainerI.H +++ b/Src/Particle/AMReX_ParticleContainerI.H @@ -937,7 +937,6 @@ ParticleContainer::SortParticles ParticleVector aos_r; RealVector rdata_r; IntVector idata_r; - Gpu::ManagedDeviceVector grids_r; for(MFIter mfi(*redistribute_mask_ptr, false); mfi.isValid(); ++mfi) { @@ -1052,24 +1051,24 @@ ParticleContainer } // temporaries - ParticleVector aos_r; - RealVector rdata_r; - IntVector idata_r; - Gpu::ManagedDeviceVector grids_r; - - Gpu::ManagedDeviceVector lo; - Gpu::ManagedDeviceVector hi; - Gpu::ManagedDeviceVector output; - - Gpu::ManagedDeviceVector grids_tmp; - Gpu::ManagedDeviceVector index_sequence_tmp; - - ParticleVector aos_to_redistribute; - std::array< RealVector, NArrayReal> real_arrays_to_redistribute; - std::array< IntVector, NArrayInt > int_arrays_to_redistribute; - Gpu::ManagedDeviceVector grids_to_redistribute; + m_aos_r.resize(0); + m_rdata_r.resize(0); + m_idata_r.resize(0); + m_grids_r.resize(0); + + m_lo.resize(0); + m_hi.resize(0); + m_output.resize(0); + + m_grids_tmp.resize(0); + m_index_sequence_tmp.resize(0); + + m_aos_to_redistribute.resize(0); + for (int k = 0; k < NArrayReal; ++k) m_real_arrays_to_redistribute[k].resize(0); + for (int k = 0; k < NArrayInt; ++k) m_int_arrays_to_redistribute[k].resize(0); + m_grids_to_redistribute.resize(0); - std::map not_ours; + m_not_ours.clear(); // // First pass - figure out what grid each particle should be on, and copy @@ -1086,8 +1085,8 @@ ParticleContainer if (old_np == 0) continue; - grids_tmp.resize(old_np); - index_sequence_tmp.resize(old_np); + m_grids_tmp.resize(old_np); + m_index_sequence_tmp.resize(old_np); constexpr bool do_custom_partition = true; size_t old_size, new_size, new_np, num_moved; @@ -1095,15 +1094,15 @@ ParticleContainer if (do_custom_partition) { - lo.resize(old_np); - hi.resize(old_np); - output.resize(old_np); + m_lo.resize(old_np); + m_hi.resize(old_np); + m_output.resize(old_np); - int* grids_ptr = thrust::raw_pointer_cast(grids_tmp.data()); - int* index_ptr = thrust::raw_pointer_cast(index_sequence_tmp.data()); - int* lo_ptr = thrust::raw_pointer_cast(lo.data()); - int* hi_ptr = thrust::raw_pointer_cast(hi.data()); - int* output_ptr = thrust::raw_pointer_cast(output.data()); + int* grids_ptr = thrust::raw_pointer_cast(m_grids_tmp.data()); + int* index_ptr = thrust::raw_pointer_cast(m_index_sequence_tmp.data()); + int* lo_ptr = thrust::raw_pointer_cast(m_lo.data()); + int* hi_ptr = thrust::raw_pointer_cast(m_hi.data()); + int* output_ptr = thrust::raw_pointer_cast(m_output.data()); BaseFab* mask_ptr = redistribute_mask_ptr->fabPtr(mfi); ParticleType* p_ptr = &(aos[0]); @@ -1139,15 +1138,15 @@ ParticleContainer }); thrust::exclusive_scan(thrust::cuda::par(Cuda::The_ThrustCachedAllocator()), - thrust::make_zip_iterator(thrust::make_tuple(lo.begin(), hi.begin())), - thrust::make_zip_iterator(thrust::make_tuple(lo.end(), hi.end())), - thrust::make_zip_iterator(thrust::make_tuple(lo.begin(), hi.begin())), + thrust::make_zip_iterator(thrust::make_tuple(m_lo.begin(), m_hi.begin())), + thrust::make_zip_iterator(thrust::make_tuple(m_lo.end(), m_hi.end())), + thrust::make_zip_iterator(thrust::make_tuple(m_lo.begin(), m_hi.begin())), thrust::tuple(0, 0), functors::tupleAdd()); - if (grids_tmp[old_np-1] == gid) { - new_np = lo[old_np-1] + 1; + if (m_grids_tmp[old_np-1] == gid) { + new_np = m_lo[old_np-1] + 1; } else { - new_np = lo[old_np-1]; + new_np = m_lo[old_np-1]; } num_moved = old_np - new_np; @@ -1165,20 +1164,20 @@ ParticleContainer output_ptr[hi_ptr[i] + new_np] = index_ptr[i]; } }); - index_sequence_tmp.swap(output); + m_index_sequence_tmp.swap(m_output); - old_size = aos_to_redistribute.size(); + old_size = m_aos_to_redistribute.size(); new_size = old_size + num_moved; } else { - thrust::sequence(thrust::device, index_sequence_tmp.begin(), index_sequence_tmp.end()); + thrust::sequence(thrust::device, m_index_sequence_tmp.begin(), m_index_sequence_tmp.end()); // // Compute the grid each particle belongs to // - thrust::transform(thrust::device, aos().begin(), aos().end(), grids_tmp.begin(), + thrust::transform(thrust::device, aos().begin(), aos().end(), m_grids_tmp.begin(), functors::assignParticleGrid(geom.data(), (*redistribute_mask_ptr)[mfi].box(), redistribute_mask_ptr->fabPtr(mfi))); @@ -1188,64 +1187,64 @@ ParticleContainer // those that move go to the end. // auto mid = thrust::partition(thrust::cuda::par(Cuda::The_ThrustCachedAllocator()), - index_sequence_tmp.begin(), - index_sequence_tmp.end(), - grids_tmp.begin(), + m_index_sequence_tmp.begin(), + m_index_sequence_tmp.end(), + m_grids_tmp.begin(), functors::grid_is(gid)); - num_moved = thrust::distance(mid, index_sequence_tmp.end()); + num_moved = thrust::distance(mid, m_index_sequence_tmp.end()); new_np = old_np - num_moved; if (num_moved == 0) continue; // early exit if everything is already in right place - old_size = aos_to_redistribute.size(); + old_size = m_aos_to_redistribute.size(); new_size = old_size + num_moved; } - aos_to_redistribute.resize(new_size); - for (int k = 0; k < NArrayReal; ++k) real_arrays_to_redistribute[k].resize(new_size); - for (int k = 0; k < NArrayInt; ++k) int_arrays_to_redistribute[k].resize(new_size); - grids_to_redistribute.resize(new_size); + m_aos_to_redistribute.resize(new_size); + for (int k = 0; k < NArrayReal; ++k) m_real_arrays_to_redistribute[k].resize(new_size); + for (int k = 0; k < NArrayInt; ++k) m_int_arrays_to_redistribute[k].resize(new_size); + m_grids_to_redistribute.resize(new_size); // // Reorder the particle data based on the partition we just computed // { // reorder structs - aos_r.resize(old_np); + m_aos_r.resize(old_np); thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - aos().begin(), aos_r.begin()); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + aos().begin(), m_aos_r.begin()); // reorder grids - grids_r.resize(old_np); + m_grids_r.resize(old_np); thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - grids_tmp.begin(), grids_r.begin()); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + m_grids_tmp.begin(), m_grids_r.begin()); - aos().swap(aos_r); - grids_tmp.swap(grids_r); + aos().swap(m_aos_r); + m_grids_tmp.swap(m_grids_r); // reorder real arrays - rdata_r.resize(old_np); + m_rdata_r.resize(old_np); for (int j = 0; j < NArrayReal; ++j) { auto& rdata = ptile.GetStructOfArrays().GetRealData(j); thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - rdata.begin(), rdata_r.begin()); - rdata.swap(rdata_r); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + rdata.begin(), m_rdata_r.begin()); + rdata.swap(m_rdata_r); } // reorder int arrays - idata_r.resize(old_np); + m_idata_r.resize(old_np); for (int j = 0; j < NArrayInt; ++j) { auto& idata = ptile.GetStructOfArrays().GetIntData(j); thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - idata.begin(), idata_r.begin()); - idata.swap(idata_r); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + idata.begin(), m_idata_r.begin()); + idata.swap(m_idata_r); } } @@ -1253,27 +1252,27 @@ ParticleContainer // copy the particle data to be moved into temp buffers // { - auto& dst = aos_to_redistribute; + auto& dst = m_aos_to_redistribute; thrust::copy(thrust::device, aos().begin() + new_np, aos().begin() + old_np, dst.begin() + old_size); } { thrust::copy(thrust::device, - grids_tmp.begin() + new_np, - grids_tmp.begin() + old_np, - grids_to_redistribute.begin() + old_size); + m_grids_tmp.begin() + new_np, + m_grids_tmp.begin() + old_np, + m_grids_to_redistribute.begin() + old_size); } for (int j = 0; j < NArrayReal; ++j) { auto& src = soa.GetRealData(j); - auto& dst = real_arrays_to_redistribute[j]; + auto& dst = m_real_arrays_to_redistribute[j]; thrust::copy(thrust::device, src.begin() + new_np, src.begin() + old_np, dst.begin() + old_size); } for (int j = 0; j < NArrayInt; ++j) { auto& src = soa.GetIntData(j); - auto& dst = int_arrays_to_redistribute[j]; + auto& dst = m_int_arrays_to_redistribute[j]; thrust::copy(thrust::device, src.begin() + new_np, src.begin() + old_np, dst.begin() + old_size); } @@ -1288,52 +1287,52 @@ ParticleContainer // periodic direction - we remove those from the simulation volume here. // const int num_grids = ba.size(); - const int num_to_move = grids_to_redistribute.size(); + const int num_to_move = m_grids_to_redistribute.size(); if (num_to_move > 0) { Gpu::ManagedDeviceVector grid_begin(num_grids+1); Gpu::ManagedDeviceVector grid_end(num_grids+1); - index_sequence_tmp.resize(num_to_move); - thrust::sequence(thrust::device, index_sequence_tmp.begin(), index_sequence_tmp.end()); + m_index_sequence_tmp.resize(num_to_move); + thrust::sequence(thrust::device, m_index_sequence_tmp.begin(), m_index_sequence_tmp.end()); thrust::sort_by_key(thrust::cuda::par(Cuda::The_ThrustCachedAllocator()), - grids_to_redistribute.begin(), - grids_to_redistribute.end(), - index_sequence_tmp.begin()); + m_grids_to_redistribute.begin(), + m_grids_to_redistribute.end(), + m_index_sequence_tmp.begin()); // // Reorder particle data using the computed sequence // { // reorder structs - auto& aos = aos_to_redistribute; - aos_r.resize(num_to_move); + auto& aos = m_aos_to_redistribute; + m_aos_r.resize(num_to_move); thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - aos.begin(), aos_r.begin()); - aos.swap(aos_r); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + aos.begin(), m_aos_r.begin()); + aos.swap(m_aos_r); // reorder real arrays - rdata_r.resize(num_to_move); + m_rdata_r.resize(num_to_move); for (int j = 0; j < NArrayReal; ++j) { - auto& rdata = real_arrays_to_redistribute[j]; + auto& rdata = m_real_arrays_to_redistribute[j]; thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - rdata.begin(), rdata_r.begin()); - rdata.swap(rdata_r); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + rdata.begin(), m_rdata_r.begin()); + rdata.swap(m_rdata_r); } // reorder int arrays - idata_r.resize(num_to_move); + m_idata_r.resize(num_to_move); for (int j = 0; j < NArrayInt; ++j) { - auto& idata = int_arrays_to_redistribute[j]; + auto& idata = m_int_arrays_to_redistribute[j]; thrust::gather(thrust::device, - index_sequence_tmp.begin(), index_sequence_tmp.end(), - idata.begin(), idata_r.begin()); - idata.swap(idata_r); + m_index_sequence_tmp.begin(), m_index_sequence_tmp.end(), + idata.begin(), m_idata_r.begin()); + idata.swap(m_idata_r); } } @@ -1342,15 +1341,15 @@ ParticleContainer // thrust::counting_iterator search_begin(-1); thrust::lower_bound(thrust::device, - grids_to_redistribute.begin(), - grids_to_redistribute.end(), + m_grids_to_redistribute.begin(), + m_grids_to_redistribute.end(), search_begin, search_begin + num_grids + 1, grid_begin.begin()); thrust::upper_bound(thrust::device, - grids_to_redistribute.begin(), - grids_to_redistribute.end(), + m_grids_to_redistribute.begin(), + m_grids_to_redistribute.end(), search_begin, search_begin + num_grids + 1, grid_end.begin()); @@ -1392,7 +1391,7 @@ ParticleContainer // copy structs { - auto& src = aos_to_redistribute; + auto& src = m_aos_to_redistribute; auto& dst = ptile.GetArrayOfStructs(); thrust::copy(thrust::device, src.begin() + start[i+1], src.begin() + stop[i+1], @@ -1402,7 +1401,7 @@ ParticleContainer // copy real arrays for (int j = 0; j < NArrayReal; ++j) { - auto& src = real_arrays_to_redistribute[j]; + auto& src = m_real_arrays_to_redistribute[j]; auto& dst = ptile.GetStructOfArrays().GetRealData(j); thrust::copy(thrust::device, src.begin() + start[i+1], src.begin() + stop[i+1], @@ -1412,7 +1411,7 @@ ParticleContainer // copy int arrays for (int j = 0; j < NArrayInt; ++j) { - auto& src = int_arrays_to_redistribute[j]; + auto& src = m_int_arrays_to_redistribute[j]; auto& dst = ptile.GetStructOfArrays().GetIntData(j); thrust::copy(thrust::device, src.begin() + start[i+1], src.begin() + stop[i+1], @@ -1422,21 +1421,21 @@ ParticleContainer else // this is the non-local case { char* dst; - const size_t old_size = not_ours[dest_proc].size(); + const size_t old_size = m_not_ours[dest_proc].size(); const size_t new_size = old_size + num_to_add*superparticle_size + sizeof(size_t) + 2*sizeof(int); if (old_size == 0) { - not_ours[dest_proc].resize(new_size + sizeof(size_t)); - cudaMemcpyAsync(thrust::raw_pointer_cast(not_ours[dest_proc].data()), + m_not_ours[dest_proc].resize(new_size + sizeof(size_t)); + cudaMemcpyAsync(thrust::raw_pointer_cast(m_not_ours[dest_proc].data()), &grid_counts[dest_proc], sizeof(size_t), cudaMemcpyHostToHost); dst = thrust::raw_pointer_cast( - not_ours[dest_proc].data() + old_size + sizeof(size_t)); + m_not_ours[dest_proc].data() + old_size + sizeof(size_t)); } else { - not_ours[dest_proc].resize(new_size); - dst = thrust::raw_pointer_cast(not_ours[dest_proc].data() + old_size); + m_not_ours[dest_proc].resize(new_size); + dst = thrust::raw_pointer_cast(m_not_ours[dest_proc].data() + old_size); } cudaMemcpyAsync(thrust::raw_pointer_cast(dst), @@ -1452,7 +1451,7 @@ ParticleContainer // pack structs { - auto& aos = aos_to_redistribute; + auto& aos = m_aos_to_redistribute; cudaMemcpyAsync(thrust::raw_pointer_cast(dst), thrust::raw_pointer_cast(aos.data() + start[i+1]), num_to_add*sizeof(ParticleType), cudaMemcpyDeviceToHost); @@ -1463,7 +1462,7 @@ ParticleContainer for (int j = 0; j < NArrayReal; ++j) { if (not communicate_real_comp[j]) continue; - auto& attrib = real_arrays_to_redistribute[j]; + auto& attrib = m_real_arrays_to_redistribute[j]; cudaMemcpyAsync(thrust::raw_pointer_cast(dst), thrust::raw_pointer_cast(attrib.data() + start[i+1]), num_to_add*sizeof(Real), cudaMemcpyDeviceToHost); @@ -1474,7 +1473,7 @@ ParticleContainer for (int j = 0; j < NArrayInt; ++j) { if (not communicate_int_comp[j]) continue; - auto& attrib = int_arrays_to_redistribute[j]; + auto& attrib = m_int_arrays_to_redistribute[j]; cudaMemcpyAsync(thrust::raw_pointer_cast(dst), thrust::raw_pointer_cast(attrib.data() + start[i+1]), num_to_add*sizeof(int), cudaMemcpyDeviceToHost); @@ -1484,11 +1483,13 @@ ParticleContainer } } + // amrex::Arena::PrintUsage(); + if (ParallelDescriptor::NProcs() == 1) { - BL_ASSERT(not_ours.empty()); + BL_ASSERT(m_not_ours.empty()); } else { - RedistributeMPIGPU(not_ours); + RedistributeMPIGPU(m_not_ours); } EnforcePeriodicGPU(); @@ -2359,8 +2360,8 @@ ParticleContainer::OKGPU (int le } } - ParallelDescriptor::ReduceLongMax(total_np); - ParallelDescriptor::ReduceLongMax(total_wrong); + ParallelDescriptor::ReduceLongSum(total_np); + ParallelDescriptor::ReduceLongSum(total_wrong); amrex::Print() << "I have " << total_np << " particles in OK(). \n"; amrex::Print() << "I have " << total_wrong << " particles in the wrong place. \n"; @@ -2780,7 +2781,7 @@ ParticleContainer if (gotsome && doUnlink) { - BL_PROFILE_VAR("PC::Checkpoint:unlink", unlink); +// BL_PROFILE_VAR("PC::Checkpoint:unlink", unlink); // // Unlink any zero-length data files. // @@ -2910,7 +2911,7 @@ ParticleContainer const bool gotsome = (nParticlesAtLevelPrePost[lev] > 0); if(gotsome && doUnlink) { - BL_PROFILE_VAR("PC::Checkpoint:unlink", unlink_post); +// BL_PROFILE_VAR("PC::Checkpoint:unlink", unlink_post); // Unlink any zero-length data files. Vector cnt(nOutFilesPrePost,0); diff --git a/Src/Particle/AMReX_Particles.H b/Src/Particle/AMReX_Particles.H index b8584c7b1c3..2b71258e5af 100644 --- a/Src/Particle/AMReX_Particles.H +++ b/Src/Particle/AMReX_Particles.H @@ -759,6 +759,27 @@ protected: mutable std::string HdrFileNamePrePost; mutable Vector filePrefixPrePost; +#ifdef AMREX_USE_CUDA + ParticleVector m_aos_r; + RealVector m_rdata_r; + IntVector m_idata_r; + Gpu::ManagedDeviceVector m_grids_r; + + Gpu::ManagedDeviceVector m_lo; + Gpu::ManagedDeviceVector m_hi; + Gpu::ManagedDeviceVector m_output; + + Gpu::ManagedDeviceVector m_grids_tmp; + Gpu::ManagedDeviceVector m_index_sequence_tmp; + + ParticleVector m_aos_to_redistribute; + std::array< RealVector, NArrayReal> m_real_arrays_to_redistribute; + std::array< IntVector, NArrayInt > m_int_arrays_to_redistribute; + Gpu::ManagedDeviceVector m_grids_to_redistribute; + + std::map m_not_ours; +#endif + private: virtual void particlePostLocate(ParticleType& p, const ParticleLocData& pld, const int lev) {}; diff --git a/Tests/GPU/RandomNumberGeneration/GNUmakefile b/Tests/GPU/RandomNumberGeneration/GNUmakefile new file mode 100644 index 00000000000..9ab92001f75 --- /dev/null +++ b/Tests/GPU/RandomNumberGeneration/GNUmakefile @@ -0,0 +1,21 @@ +AMREX_HOME ?= ../../../ + +DEBUG = FALSE + +DIM = 3 + +COMP = gcc + +USE_CUDA = TRUE +USE_ACC = FALSE +USE_OMP_OFFLOAD = FALSE + +USE_MPI = FALSE +USE_OMP = FALSE + +include $(AMREX_HOME)/Tools/GNUMake/Make.defs + +include ./Make.package +include $(AMREX_HOME)/Src/Base/Make.package + +include $(AMREX_HOME)/Tools/GNUMake/Make.rules diff --git a/Tests/GPU/RandomNumberGeneration/Make.package b/Tests/GPU/RandomNumberGeneration/Make.package new file mode 100644 index 00000000000..7f43e5e87cb --- /dev/null +++ b/Tests/GPU/RandomNumberGeneration/Make.package @@ -0,0 +1,2 @@ +CEXE_sources += main.cpp + diff --git a/Tests/GPU/RandomNumberGeneration/main.cpp b/Tests/GPU/RandomNumberGeneration/main.cpp new file mode 100644 index 00000000000..4c55d84a202 --- /dev/null +++ b/Tests/GPU/RandomNumberGeneration/main.cpp @@ -0,0 +1,129 @@ +#include +#include +#include +#include +#include +#include + +using namespace amrex; + + +void RandomNumGen(); + +int main (int argc, char* argv[]) +{ + + amrex::Initialize(argc,argv); + RandomNumGen(); + amrex::Finalize(); + +} + +void RandomNumGen () +{ + int N = 1E5; + +#ifdef AMREX_USE_CUDA + amrex::InitRandSeedOnDevice(N); + amrex::Print() << amrex::Gpu::Device::deviceId() << "\n"; + amrex::Print() << amrex::ParallelDescriptor::MyProc() << "\n"; + + Gpu::DeviceVector d_xpos(N); + Gpu::DeviceVector d_ypos(N); + Gpu::DeviceVector d_zpos(N); + + double *dxpos = d_xpos.dataPtr(); + double *dypos = d_ypos.dataPtr(); + double *dzpos = d_zpos.dataPtr(); +#else + amrex::InitRandom(1024UL,1); +#endif + + amrex::Vector hx(N); + amrex::Vector hy(N); + amrex::Vector hz(N); + double *hxpos = hx.dataPtr(); + double *hypos = hy.dataPtr(); + double *hzpos = hz.dataPtr(); + + + int timesteps = 10; // just for example + for (int i=0; i -#include #include #include #include -#include #include #include #include #include #include -#include #include #include -#include +#include // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& diff --git a/Tests/GPU/Test/main.cpp b/Tests/GPU/Test/main.cpp index b111b49c1eb..f899398914b 100644 --- a/Tests/GPU/Test/main.cpp +++ b/Tests/GPU/Test/main.cpp @@ -1,19 +1,16 @@ -#include -#include +//#include +//#include #include #include #include -#include -#include #include #include #include #include #include -#include -#include +#include // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& @@ -48,14 +45,14 @@ struct PinnedData { return d_d; } - +/* T hostValue () const { T t; // cudaMemcpy(&t, d_d, sizeof(T), cudaMemDeviceToHost); return t; } - +*/ void updateDevice(const T &t) { // cudaMemcpy(d_d, &t, sizeof(T), cudaMemHostToDevice); @@ -87,6 +84,8 @@ int main (int argc, char* argv[]) amrex::Print() << "Hello world from AMReX version " << amrex::Version() << ". GPU devices: " << devices << "\n"; amrex::Print() << "**********************************\n"; + amrex::Cuda::ExecutionConfig simple_config(1,1); + // Malloc { @@ -100,8 +99,8 @@ int main (int argc, char* argv[]) std::cout << "n before = " << n << std::endl; - AMREX_SIMPLE_L_LAUNCH(1,1, - [=] AMREX_CUDA_DEVICE () mutable + amrex::launch_global<<<1,1>>>( + [=] AMREX_GPU_DEVICE () mutable { *n_d = *n_d / 10; printf("n during = %i\n", *n_d); @@ -109,7 +108,7 @@ int main (int argc, char* argv[]) cudaMemcpy(&n, n_d, sizeof(int), cudaMemcpyDeviceToHost); cudaFree(n_d); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); std::cout << "n after = " << n << std::endl << std::endl; } @@ -125,14 +124,14 @@ int main (int argc, char* argv[]) std::cout << "n before = " << *n << std::endl; - AMREX_SIMPLE_L_LAUNCH(1,1, - [=] AMREX_CUDA_DEVICE () mutable + amrex::launch_global<<<1,1>>>( + [=] AMREX_GPU_DEVICE () mutable { *n = *n / 10; printf("n during = %i\n", *n); }); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); std::cout << "n after = " << *n << std::endl << std::endl; @@ -152,14 +151,14 @@ int main (int argc, char* argv[]) std::cout << "n before = " << *n << std::endl; - AMREX_SIMPLE_L_LAUNCH(1,1, - [=] AMREX_CUDA_DEVICE () mutable + amrex::launch_global<<<1,1>>>( + [=] AMREX_GPU_DEVICE () mutable { *n = *n / 10; printf("n during = %i\n", *n); }); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); std::cout << "n after = " << *n << std::endl << std::endl; @@ -173,12 +172,12 @@ int main (int argc, char* argv[]) PinnedData n; PinnedData n5; - int *p = n.data(); - auto q = n5.data(); + int *p = n.devicePtr(); + auto q = n5.devicePtr(); std::cout << "n before = " << *p << std::endl; - AMREX_SIMPLE_L_LAUNCH(1,1, - [=] AMREX_CUDA_DEVICE () mutable + amrex::launch_global<<<1,1>>>( + [=] AMREX_GPU_DEVICE () mutable { (*q)[0] = 4; (*q)[1] = 3; @@ -190,7 +189,7 @@ int main (int argc, char* argv[]) printf("n during = %i\n", *p); }); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); for (int i=0;i<5;i++) { diff --git a/Tests/GPU/TestB/main.cpp b/Tests/GPU/TestB/main.cpp index 8726a8e145e..2c3d48b58a7 100644 --- a/Tests/GPU/TestB/main.cpp +++ b/Tests/GPU/TestB/main.cpp @@ -1,26 +1,23 @@ -#include -#include +//#include +//#include #include #include #include -#include -#include #include #include #include #include #include -#include -#include +#include // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& extern "C" { - AMREX_CUDA_DEVICE + AMREX_GPU_DEVICE long fort_return_test (long* mallocd); } @@ -52,8 +49,8 @@ int main (int argc, char* argv[]) std::cout << "n before = " << n << std::endl << std::endl; - AMREX_SIMPLE_L_LAUNCH(1,1, - [=] AMREX_CUDA_DEVICE () mutable + amrex::launch_global<<<1,1>>>( + [=] AMREX_GPU_DEVICE () mutable { long returned = 0; @@ -67,7 +64,7 @@ int main (int argc, char* argv[]) cudaMemcpy(&n, n_d, sizeof(long), cudaMemcpyDeviceToHost); cudaFree(n_d); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); std::cout << "n after = " << n << std::endl; } diff --git a/Tests/GPU/TestC/main.cpp b/Tests/GPU/TestC/main.cpp index 7b3a7012eca..067c50a0512 100644 --- a/Tests/GPU/TestC/main.cpp +++ b/Tests/GPU/TestC/main.cpp @@ -1,20 +1,14 @@ -#include -#include - #include #include #include #include #include -#include -#include #include #include #include #include -#include -#include +#include // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& @@ -44,7 +38,10 @@ int main (int argc, char* argv[]) amrex::Print() << "n_cpy before = " << *n_cpy << std::endl << std::endl; - AMREX_SIMPLE_L_LAUNCH(RunOn::CPU, 1, 1, + amrex::Gpu::setLaunchRegion(false); + + + amrex::launch_global<<<1,1>>>( [=] AMREX_GPU_HOST_DEVICE () { *n_cpy = 1; @@ -52,18 +49,20 @@ int main (int argc, char* argv[]) }); int n; - Device::synchronize(); + amrex::Gpu::Device::synchronize(); cudaMemcpy(&n, n_cpy, sizeof(int), cudaMemcpyDeviceToHost); amrex::Print() << "n after CPU = " << n << std::endl << std::endl; - AMREX_SIMPLE_L_LAUNCH(RunOn::GPU, 1, 1, + amrex::Gpu::setLaunchRegion(true); + + amrex::launch_global<<<1,1>>>( [=] AMREX_GPU_HOST_DEVICE () { *n_cpy = 3; printf("n_cpy during GPU = %i\n", *n_cpy); }); - Device::synchronize(); + amrex::Gpu::Device::synchronize(); cudaMemcpy(&n, n_cpy, sizeof(int), cudaMemcpyDeviceToHost); amrex::Print() << "n after GPU = " << n << std::endl << std::endl; diff --git a/Tools/CMake/AMReXConfig.cmake.in b/Tools/CMake/AMReXConfig.cmake.in index ab127bd5b0a..4d200732dda 100644 --- a/Tools/CMake/AMReXConfig.cmake.in +++ b/Tools/CMake/AMReXConfig.cmake.in @@ -20,6 +20,11 @@ set(AMREX_BUILD_TYPE @CMAKE_BUILD_TYPE@) # set(AMREX_GIT_VERSION \"@AMREX_GIT_VERSION@\") +# +# Add AMReX modules to app code CMake +# +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@CMAKE_INSTALL_PREFIX@/Tools/CMake/") + # # AMReX CMake modules PATH # @@ -47,6 +52,9 @@ set(AMREX_ENABLE_PARTICLES @ENABLE_PARTICLES@) set(AMREX_ENABLE_DP_PARTICLES @ENABLE_DP_PARTICLES@) set(AMREX_ENABLE_SENSEI_INSITU @ENABLE_SENSEI_INSITU@) set(AMREX_ENABLE_3D_NODAL_MLMG @ENABLE_3D_NODAL_MLMG@) +set(AMREX_ENABLE_CONDUIT @ENABLE_CONDUIT@) +set(AMREX_ENABLE_ASCENT @ENABLE_ASCENT@) + # Compilation options set(AMREX_ENABLE_FPE @ENABLE_FPE@) @@ -61,11 +69,15 @@ set(AMREX_ENABLE_COMM_PROFILE @ENABLE_COMM_PROFILE@) set(AMREX_ENABLE_BACKTRACE @ENABLE_BACKTRACE@) set(AMREX_ENABLE_PROFPARSER @ENABLE_PROFPARSER@) +# SUNDIALS support +set(AMREX_ENABLE_SUNDIALS @ENABLE_SUNDIALS@) + if (AMREX_ENABLE_MPI) find_dependency(MPI REQUIRED) endif() +# Find dependencies if needed if (AMREX_ENABLE_3D_NODAL_MLMG) # External libs set(BLITZ_INSTALL_PREFIX @BLITZ_INSTALL_PREFIX@) @@ -80,6 +92,10 @@ if (AMREX_ENABLE_3D_NODAL_MLMG) endif () endif () +if (AMREX_ENABLE_SUNDIALS) + include(CMakeFindDependencyMacro) + find_dependency(SUNDIALS COMPONENTS nvecserial cvode arkode REQUIRED ) +endif () # This two lines are suggested on the internet diff --git a/Tools/CMake/AMReX_Config.cmake b/Tools/CMake/AMReX_Config.cmake index a22a2b29951..c0455d1528e 100644 --- a/Tools/CMake/AMReX_Config.cmake +++ b/Tools/CMake/AMReX_Config.cmake @@ -129,10 +129,14 @@ function (configure_amrex) set_target_properties ( amrex PROPERTIES POSITION_INDEPENDENT_CODE True ) endif () - if (ENABLE_CUDA OR BUILD_SHARED_LIBS) - set_target_properties( amrex PROPERTIES INTERFACE_LINK_OPTIONS "-Wl,--warn-unresolved-symbols") - endif () - + if ( BUILD_SHARED_LIBS OR ENABLE_CUDA ) + if(APPLE) + target_link_options(amrex PUBLIC -Wl,-undefined,warning) + else() + target_link_options(amrex PUBLIC -Wl,--warn-unresolved-symbols) + endif() + endif() + # # Location of Fortran modules # @@ -190,6 +194,11 @@ function (configure_amrex) target_link_libraries( amrex PUBLIC sensei ) endif() + # + # Setup other third party libs + # + include(AMReX_SetupThirdPartyLibs) + # # Print out summary # diff --git a/Tools/CMake/AMReX_Defines.cmake b/Tools/CMake/AMReX_Defines.cmake index fe80506991d..515861cb40d 100644 --- a/Tools/CMake/AMReX_Defines.cmake +++ b/Tools/CMake/AMReX_Defines.cmake @@ -109,6 +109,15 @@ function ( set_amrex_defines ) add_amrex_define( AMREX_FORT_USE_${FORTLINK} ) + # SENSEI Insitu + add_amrex_define( AMREX_USE_SENSEI_INSITU IF ENABLE_SENSEI_INSITU ) + + # Conduit Support + add_amrex_define( AMREX_USE_CONDUIT IF ENABLE_CONDUIT ) + + # Ascent Support + add_amrex_define( AMREX_USE_ASCENT IF ENABLE_ASCENT ) + # # CUDA # diff --git a/Tools/CMake/AMReX_Options.cmake b/Tools/CMake/AMReX_Options.cmake index ad4bb7df26c..19e27f742ef 100644 --- a/Tools/CMake/AMReX_Options.cmake +++ b/Tools/CMake/AMReX_Options.cmake @@ -143,6 +143,19 @@ endif () option( ENABLE_SENSEI_INSITU "Enable SENSEI in situ infrastructure" OFF ) print_option( ENABLE_SENSEI_INSITU ) + +# +# Conduit Support (for features in Src/Extern/Conduit) +# Note: ENABLE_CONDUIT = ON, requires CONDUIT_DIR. +# +option ( ENABLE_CONDUIT "Enable Conduit support" OFF ) +print_option ( ENABLE_CONDUIT ) + +option ( ENABLE_ASCENT "Enable Ascent support" OFF ) +print_option ( ENABLE_ASCENT ) + + + if (ENABLE_LINEAR_SOLVERS AND (DIM EQUAL 3) AND (NOT USE_XSDK_DEFAULTS) ) option(ENABLE_3D_NODAL_MLMG "Enable 3D nodal MLMG" OFF) print_option(ENABLE_3D_NODAL_MLMG) @@ -150,6 +163,12 @@ else () set(ENABLE_3D_NODAL_MLMG OFF CACHE INTERNAL "Enable 3D nodal MLMG") endif () +# +# External packages +# +option(ENABLE_SUNDIALS "Enable SUNDIALS3 interfaces" OFF) +print_option(ENABLE_SUNDIALS) + # # This options are paths to external libraries installation directories # diff --git a/Tools/CMake/AMReX_SetupThirdPartyLibs.cmake b/Tools/CMake/AMReX_SetupThirdPartyLibs.cmake new file mode 100644 index 00000000000..db8d8859336 --- /dev/null +++ b/Tools/CMake/AMReX_SetupThirdPartyLibs.cmake @@ -0,0 +1,65 @@ + +if (NOT TARGET amrex) + message(FATAL_ERROR "Target amrex must be defined before including AMReX_SetupThirdpartyLibs.cmake") +endif () + + +# +# Check for Conduit Support +# +if ( ENABLE_CONDUIT ) + if (NOT CONDUIT_DIR) + message(FATAL_ERROR "Conduit support requires CONDUIT_DIR") + endif () + + if(NOT EXISTS ${CONDUIT_DIR}/lib/cmake/ConduitConfig.cmake) + MESSAGE(FATAL_ERROR "Could not find Conduit CMake include file (${CONDUIT_DIR}/lib/cmake/ConduitConfig.cmake)") + endif() + + # + # Use CMake's find_package to import conduit's targets + # + find_package(Conduit REQUIRED QUIET + NO_DEFAULT_PATH + PATHS ${CONDUIT_DIR}/lib/cmake) + + target_link_libraries( amrex PUBLIC conduit::conduit) + + if( ENABLE_MPI ) + target_link_libraries( amrex PUBLIC conduit::conduit_mpi ) + endif () + + MESSAGE(STATUS "Found Conduit at ${CONDUIT_DIR}" ) + +endif () + + +# +# Check for Ascent Support +# +if ( ENABLE_ASCENT ) + if (NOT ASCENT_DIR) + message(FATAL_ERROR "Ascent support requires ASCENT_DIR") + endif () + + if(NOT EXISTS ${ASCENT_DIR}/lib/cmake/AscentConfig.cmake) + MESSAGE(FATAL_ERROR "Could not find Ascent CMake include file (${ASCENT_DIR}/lib/cmake/AscentConfig.cmake)") + endif() + + # + # Use CMake's find_package to import ascent's targets + # + find_package(Ascent REQUIRED QUIET + NO_DEFAULT_PATH + PATHS ${ASCENT_DIR}/lib/cmake) + + + if( NOT ENABLE_MPI ) + target_link_libraries( amrex PUBLIC ascent::ascent ) + else() + target_link_libraries( amrex PUBLIC ascent::ascent_mpi ) + endif () + + MESSAGE(STATUS "Found Ascent at ${ASCENT_DIR}" ) + +endif () diff --git a/Tools/CMake/FindSUNDIALS.cmake b/Tools/CMake/FindSUNDIALS.cmake new file mode 100644 index 00000000000..efc2e8cd83b --- /dev/null +++ b/Tools/CMake/FindSUNDIALS.cmake @@ -0,0 +1,134 @@ +#[=======================================================================[: +FindSUNDIALS +------- + +Finds the SUNDIALS libraries. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``SUNDIALS::`` + The library + +where is the selected component. +If no component is specified, this module will search for ``nvecserial`` only. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``SUNDIALS_FOUND`` + True if all the selected components have been found. +``SUNDIALS_VERSION`` + The version of the SUNDIALS library which was found. +``SUNDIALS__INCLUDE_DIRS`` + Include directories needed to use component . +``SUNDIALS__LIBRARY`` + Libraries needed to link to component . +#]=======================================================================] + +# +# Find package version +# +set(_version_file_name sundials_config.h) + +find_path(_version_file_path + NAMES "${_version_file_name}" + PATH_SUFFIXES include;sundials ) + +if (_version_file_path) + file(STRINGS "${_version_file_path}/${_version_file_name}" + _strings_with_version_regex REGEX "SUNDIALS_VERSION") + list(GET _strings_with_version_regex 0 _version_string) + string(REGEX MATCHALL "[0-9]" _version "${_version_string}") + string(REPLACE ";" "." SUNDIALS_VERSION "${_version}") +endif () + +# +# Include directory is only the top level one, i.e. "include" +# Find path by using directory "sundials" as reference +# +find_path(_sundials_include_path NAMES sundials PATH_SUFFIXES include) + +# +# +# +include(FindPackageHandleStandardArgs) + +# +# Valid components +# +set(_valid_components + nvecserial + nvecparallel + nvecopenmp + nvecopenmpdev + nveccuda + cvode + arkode + ) + +# +# Search for a default library (nvecserial) or for all the +# required components +# +if (NOT SUNDIALS_FIND_COMPONENTS) + set(_sundials_findlist nvecserial ) +else () + set(_sundials_findlist ${SUNDIALS_FIND_COMPONENTS}) +endif () + +list(REMOVE_DUPLICATES _sundials_findlist) + +# +# Setup one imported target per component +# +set(_SUNDIALS_REQUIRED_VARS) +foreach(_comp IN LISTS _sundials_findlist) + + string( TOLOWER "${_comp}" _comp_lower ) + string( TOUPPER "${_comp}" _comp_upper ) + + # Check whether component is in valid list + if (NOT (${_comp_lower} IN_LIST _valid_components)) + message(FATAL_ERROR "Invalid component ${_comp_lower}") + endif () + + # Include path is always the path to the top-level "include" directory in the install tree + # App codes should include headers by using relative paths + set(SUNDIALS_${_comp_upper}_INCLUDE_DIRS ${_sundials_include_path}) + find_library(SUNDIALS_${_comp_upper}_LIBRARY NAMES sundials_${_comp_lower} PATH_SUFFIXES lib) + + find_package_handle_standard_args(SUNDIALS_${_comp_upper} + REQUIRED_VARS + SUNDIALS_${_comp_upper}_LIBRARY + SUNDIALS_${_comp_upper}_INCLUDE_DIRS + VERSION_VAR SUNDIALS_VERSION + ) + + mark_as_advanced(SUNDIALS_${_comp_upper}_LIBRARY SUNDIALS_${_comp_upper}_INCLUDE_DIRS) + + list(APPEND _SUNDIALS_REQUIRED_VARS "SUNDIALS_${_comp_upper}_FOUND") + + # Create imported target + set(_target SUNDIALS::${_comp_lower}) + if (SUNDIALS_${_comp_upper}_FOUND AND NOT TARGET ${_target}) + add_library(${_target} UNKNOWN IMPORTED) + set_target_properties(${_target} PROPERTIES + IMPORTED_LOCATION "${SUNDIALS_${_comp_upper}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SUNDIALS_${_comp_upper}_INCLUDE_DIRS}" + ) + endif () + +endforeach() + +# +# Set +# +find_package_handle_standard_args(SUNDIALS + REQUIRED_VARS ${_SUNDIALS_REQUIRED_VARS} + VERSION_VAR SUNDIALS_VERSION + ) diff --git a/Tools/C_util/Convergence/RichardsonConvergenceTest.cpp b/Tools/C_util/Convergence/RichardsonConvergenceTest.cpp index b43c5ac64bc..a97752ab901 100644 --- a/Tools/C_util/Convergence/RichardsonConvergenceTest.cpp +++ b/Tools/C_util/Convergence/RichardsonConvergenceTest.cpp @@ -53,8 +53,8 @@ PrintUsage (const char* progName) std::cout << " coarFile= coarse file name (input)" << '\n'; std::cout << " mediFile= medium plot file (input)" << '\n'; std::cout << " fineFile= finest plot file (input)" << '\n'; - std::cout << " mediError = medium error file (output)" << '\n'; - std::cout << " coarError = coarse error file (output)" << '\n'; + std::cout << " mediError = medium error file (optional output)" << '\n'; + std::cout << " coarError = coarse error file (optional output)" << '\n'; std::cout << " [-help]" << '\n'; std::cout << " [-verbose]" << '\n'; std::cout << '\n'; @@ -138,7 +138,8 @@ getErrorNorms(Vector& a_norms, //one for each comp const string& a_fineFile, const string& a_coarFile, const string& a_errFile, - const int& a_norm) + const int& a_norm, + bool verbose) { // // Scan the arguments. @@ -150,11 +151,9 @@ getErrorNorms(Vector& a_norms, //one for each comp difFile = a_errFile; norm = a_norm; - bool verbose = true; - DataServices::SetBatchMode(); Amrvis::FileType fileType(Amrvis::NEWPLT); - + DataServices dataServices1(iFile1, fileType); DataServices dataServices2(iFile2, fileType); @@ -162,13 +161,13 @@ getErrorNorms(Vector& a_norms, //one for each comp amrex::Abort("ERROR: Dataservices not OK"); // - // Generate AmrData Objects + // Generate AmrData Objects // AmrData& amrData1 = dataServices1.AmrDataRef(); AmrData& amrData2 = dataServices2.AmrDataRef(); // - // Initial Tests + // Initial Tests // if (amrData1.FinestLevel() != amrData2.FinestLevel()) amrex::Abort("ERROR: Finest level is not the same in the two plotfiles"); @@ -177,7 +176,7 @@ getErrorNorms(Vector& a_norms, //one for each comp int nComp2 = amrData2.NComp(); int nComp = std::min(nComp1,nComp2); - + if (!amrDatasHaveSameDerives(amrData1,amrData2)) { std::cout << "Warning: Plotfiles do not have the same state variables" << std::endl; @@ -189,19 +188,19 @@ getErrorNorms(Vector& a_norms, //one for each comp int finestLevel = amrData1.FinestLevel(); Vector destComps(nComp); - for (int i = 0; i < nComp; i++) + for (int i = 0; i < nComp; i++) destComps[i] = i; - + // // Compute the error // Vector error(finestLevel+1); - + if (ParallelDescriptor::IOProcessor()) std::cout << "Level L"<< norm << " norm of Error in Each Component" << std::endl << "-----------------------------------------------" << std::endl; - + Vector sum_norms(nComp); for (int iComp = 0; iComp < nComp; iComp++) sum_norms[iComp] = 0.0; @@ -262,7 +261,7 @@ getErrorNorms(Vector& a_norms, //one for each comp baf = BoxArray(amrData1.boxArray(iLevel+1)).coarsen(refine_ratio); } - + // Copy the data at the coarse level one component at a time new_data1.copy(data1,0,0,1); @@ -275,11 +274,11 @@ getErrorNorms(Vector& a_norms, //one for each comp // Create the Coarsened version of data2 // int index = mfi.index(); - + const Box& bx = ba2Coarse[index]; FArrayBox data2Coarse(bx, 1); int ncCoarse = 1; - + FORT_CV_AVGDOWN(data2Coarse.dataPtr(), @@ -287,12 +286,12 @@ getErrorNorms(Vector& a_norms, //one for each comp &ncCoarse, data2Fine[mfi].dataPtr(), ARLIM(data2Fine[mfi].loVect()), - ARLIM(data2Fine[mfi].hiVect()), + ARLIM(data2Fine[mfi].hiVect()), bx.loVect(), bx.hiVect(), refine_ratio.getVect()); - // + // // Calculate the errors on this FAB for this component // @@ -302,11 +301,11 @@ getErrorNorms(Vector& a_norms, //one for each comp if (iLevel > isects = baf.intersections(bx); - + for (int ii = 0; ii < isects.size(); ii++) (*error[iLevel])[mfi].setVal(0,isects[ii].second,iComp,1); } - + Real grdL2 = (*error[iLevel])[mfi].norm(norm, iComp, 1); if (norm != 0) @@ -337,8 +336,8 @@ getErrorNorms(Vector& a_norms, //one for each comp if (proc != ParallelDescriptor::IOProcessorNumber()) { MPI_Status stat; - int rc = MPI_Recv(tmp.dataPtr(), nComp, datatype, - MPI_ANY_SOURCE, proc, ParallelDescriptor::Communicator(), + int rc = MPI_Recv(tmp.dataPtr(), nComp, datatype, + MPI_ANY_SOURCE, proc, ParallelDescriptor::Communicator(), &stat); if (rc != MPI_SUCCESS) @@ -357,7 +356,7 @@ getErrorNorms(Vector& a_norms, //one for each comp } else { - int rc = MPI_Send(norms.dataPtr(), nComp, datatype, + int rc = MPI_Send(norms.dataPtr(), nComp, datatype, ParallelDescriptor::IOProcessorNumber(), ParallelDescriptor::MyProc(), ParallelDescriptor::Communicator()); @@ -382,21 +381,24 @@ getErrorNorms(Vector& a_norms, //one for each comp norms[iComp] = pow(norms[iComp], (1.0/norm)); } - std::cout << norms[iComp] << " "; + if (verbose) + std::cout << norms[iComp] << " "; + sum_norms[iComp] = sum_norms[iComp] + norms[iComp]; } - - std::cout << std::endl; + + if (verbose) + std::cout << std::endl; } } - if (ParallelDescriptor::IOProcessor()) - std::cout << " Sum "; - if (ParallelDescriptor::IOProcessor()) - { - for (int iComp = 0; iComp < nComp; iComp++) - { - std::cout << sum_norms[iComp] << " "; + if (verbose) { + if (ParallelDescriptor::IOProcessor()) { + std::cout << " Sum "; + for (int iComp = 0; iComp < nComp; iComp++) + { + std::cout << sum_norms[iComp] << " "; + } } } @@ -406,7 +408,7 @@ getErrorNorms(Vector& a_norms, //one for each comp { WritePlotFile(error, amrData1, difFile, verbose); } - + for (int iLevel = 0; iLevel <= finestLevel; ++iLevel) { delete error[iLevel]; @@ -428,6 +430,10 @@ main (int argc, if (pp.contains("help")) PrintUsage(argv[0]); + bool verbose = false; + if (pp.contains("verbose")) + verbose = true; + FArrayBox::setFormat(FABio::FAB_IEEE_32); // // Scan the arguments. @@ -450,19 +456,15 @@ main (int argc, pp.query("mediError", mediError); - if (mediError.empty()) - amrex::Abort("You must specify mediError"); - pp.query("coarError", coarError); - if (coarError.empty()) - amrex::Abort("You must specify coarError"); + //l2 is not supported for(int inorm = 0; inorm <=1; inorm++) { Vector normsMedi, normsCoar; Vector namesMedi, namesCoar; - getErrorNorms(normsMedi, namesMedi, fineFile, mediFile, mediError, inorm); - getErrorNorms(normsCoar, namesCoar, mediFile, coarFile, coarError, inorm); + getErrorNorms(normsMedi, namesMedi, fineFile, mediFile, mediError, inorm, verbose); + getErrorNorms(normsCoar, namesCoar, mediFile, coarFile, coarError, inorm, verbose); int ncompMedi = normsMedi.size(); int ncompCoar = normsCoar.size(); int ncomp = std::min(ncompMedi, ncompCoar); diff --git a/Tools/F_scripts/write_cuda_headers.py b/Tools/F_scripts/write_cuda_headers.py index d2d17d65b5c..e3c691e7317 100755 --- a/Tools/F_scripts/write_cuda_headers.py +++ b/Tools/F_scripts/write_cuda_headers.py @@ -29,6 +29,7 @@ import shutil import find_files_vpath as ffv import preprocess +from multiprocessing import Pool TEMPLATE = """ @@ -220,436 +221,441 @@ def find_targets_from_pragmas(outdir, cxx_files, macro_list, cpp): return targets -def convert_headers(outdir, targets, macro_list, header_files, cpp): +def convert_headers(inputs): """rewrite the C++ headers that contain the Fortran routines""" + header_file = inputs[0] + outdir = inputs[1] + targets = inputs[2] + macro_list = inputs[3] + cpp = inputs[4] + print('looking for targets: {}'.format(list(targets))) - print('looking in header files: {}'.format(header_files)) + print('looking in header file: {}'.format(header_file)) - # first preprocess all the headers and store them in a temporary - # location. The preprocessed headers will only be used for the + # first preprocess the header and store it in a temporary + # location. The preprocessed header will only be used for the # search for the signature, not as the basis for writing the final # CUDA header - pheaders = [] - - for h in header_files: - hdr = "/".join([h[1], h[0]]) - hf = HeaderFile(hdr) - # preprocess -- this will create a new file in our temp_dir that - # was run through cpp and has the name CPP-filename - cpp.preprocess(hf, add_name="CPP") + hdr = "/".join([header_file[1], header_file[0]]) + hf = HeaderFile(hdr) - pheaders.append(hf) + # preprocess -- this will create a new file in our temp_dir that + # was run through cpp and has the name CPP-filename + cpp.preprocess(hf, add_name="CPP") # now scan the preprocessed headers and find any of our function # signatures and output to a new unpreprocessed header - for h in pheaders: - # open the preprocessed header file -- this is what we'll scan - try: - hin = open(h.cpp_name, "r") - except IOError: - sys.exit("Cannot open header {}".format(h.cpp_name)) + # open the preprocessed header file -- this is what we'll scan + try: + hin = open(hf.cpp_name, "r") + except IOError: + sys.exit("Cannot open header {}".format(hf.cpp_name)) + + # we'll keep track of the signatures that we need to mangle + signatures = {} + + line = hin.readline() + while line: + + # if the line does not start a function signature that + # matches one of our targets, then we ignore it. + # Otherwise, we need to capture the function signature + found = None + + # strip comments + idx = line.find("//") + tline = line[:idx] + + for target in list(targets): + target_match = fortran_binding_re.search(tline) + if target_match: + if target == target_match.group(3): + found = target + print('found target {} in header {}'.format(target, hf.cpp_name)) + break + + # we found a target function, so capture the entire + # signature, which may span multiple lines + if found is not None: + launch_sig = "" + sig_end = False + while not line.strip().endswith(";"): + launch_sig += line + line = hin.readline() + launch_sig += line - # we'll keep track of the signatures that we need to mangle - signatures = {} + signatures[found] = [launch_sig, targets[found]] line = hin.readline() - while line: - - # if the line does not start a function signature that - # matches one of our targets, then we ignore it. - # Otherwise, we need to capture the function signature - found = None - - # strip comments - idx = line.find("//") - tline = line[:idx] - - for target in list(targets): - target_match = fortran_binding_re.search(tline) - if target_match: - if target == target_match.group(3): - found = target - print('found target {} in header {}'.format(target, h.cpp_name)) - break - - # we found a target function, so capture the entire - # signature, which may span multiple lines - if found is not None: - launch_sig = "" - sig_end = False - while not line.strip().endswith(";"): - launch_sig += line - line = hin.readline() - launch_sig += line - signatures[found] = [launch_sig, targets[found]] + hin.close() - line = hin.readline() + # we've now finished going through the header. Note: there may + # be more signatures here than we really need, because some may + # have come in via '#includes' in the preprocessing. - hin.close() - # we've now finished going through the header. Note: there may - # be more signatures here than we really need, because some may - # have come in via '#includes' in the preprocessing. + # Now we'll go back to the original file, parse it, making note + # of any of the signatures we find, but using the preprocessed + # version in the final output. + # open the CUDA header for output + _, tail = os.path.split(hf.name) + ofile = os.path.join(outdir, tail) + try: + hout = open(ofile, "w") + except IOError: + sys.exit("Cannot open output file {}".format(ofile)) - # Now we'll go back to the original file, parse it, making note - # of any of the signatures we find, but using the preprocessed - # version in the final output. + # and back to the original file (not preprocessed) for the input + try: + hin = open(hf.name, "r") + except IOError: + sys.exit("Cannot open output file {}".format(ofile)) - # open the CUDA header for output - _, tail = os.path.split(h.name) - ofile = os.path.join(outdir, tail) - try: - hout = open(ofile, "w") - except IOError: - sys.exit("Cannot open output file {}".format(ofile)) + signatures_needed = {} - # and back to the original file (not preprocessed) for the input - try: - hin = open(h.name, "r") - except IOError: - sys.exit("Cannot open output file {}".format(ofile)) - - signatures_needed = {} + line = hin.readline() + while line: - line = hin.readline() - while line: + # if the line does not start a function signature that we + # need, then we ignore it + found = None - # if the line does not start a function signature that we - # need, then we ignore it - found = None + # strip comments + idx = line.find("//") + tline = line[:idx] - # strip comments - idx = line.find("//") - tline = line[:idx] + # if the line is not a function signature that we already + # captured then we just write it out + for target in list(signatures): - # if the line is not a function signature that we already - # captured then we just write it out - for target in list(signatures): + target_match = fortran_binding_re.search(tline) + if target_match: + if target == target_match.group(3): + found = target + signatures_needed[found] = signatures[found] - target_match = fortran_binding_re.search(tline) - if target_match: - if target == target_match.group(3): - found = target - signatures_needed[found] = signatures[found] + print('found target {} in unprocessed header {}'.format(target, hf.name)) + break - print('found target {} in unprocessed header {}'.format(target, h.name)) - break - - if found is not None: + if found is not None: + hout.write(line) + launch_sig = "" + line + sig_end = False + while not sig_end: + line = hin.readline() hout.write(line) - launch_sig = "" + line - sig_end = False - while not sig_end: - line = hin.readline() - hout.write(line) - launch_sig += line - if line.strip().endswith(";"): - sig_end = True + launch_sig += line + if line.strip().endswith(";"): + sig_end = True - else: - # this was not one of our device headers - hout.write(line) + else: + # this was not one of our device headers + hout.write(line) - line = hin.readline() + line = hin.readline() - # we are done with the pass through the header and we know all - # of the signatures that need to be CUDAed + # we are done with the pass through the header and we know all + # of the signatures that need to be CUDAed - # remove any dupes in the signatures needed - signatures_needed = list(set(signatures_needed)) + # remove any dupes in the signatures needed + signatures_needed = list(set(signatures_needed)) - # now do the CUDA signatures - hout.write("\n") - hout.write("#include \n") - hout.write("#include \n") - hout.write("#include \n") - hout.write("\n") + # now do the CUDA signatures + hout.write("\n") + hout.write("#include \n") + hout.write("#include \n") + hout.write("#include \n") + hout.write("\n") - hdrmh = os.path.basename(h.name).strip(".H") + hdrmh = os.path.basename(hf.name).strip(".H") - # Add an include guard -- do we still need this? - hout.write("#ifndef _cuda_" + hdrmh + "_\n") - hout.write("#define _cuda_" + hdrmh + "_\n\n") + # Add an include guard -- do we still need this? + hout.write("#ifndef _cuda_" + hdrmh + "_\n") + hout.write("#define _cuda_" + hdrmh + "_\n\n") - # Wrap the device declarations in extern "C" - hout.write("#ifdef AMREX_USE_GPU_PRAGMA\n") - hout.write("extern \"C\" {\n\n") + # Wrap the device declarations in extern "C" + hout.write("#ifdef AMREX_USE_GPU_PRAGMA\n") + hout.write("extern \"C\" {\n\n") - for name in list(signatures_needed): + for name in list(signatures_needed): - func_sig = signatures[name][0] + func_sig = signatures[name][0] - # First write out the device signature - device_sig = "__device__ {};\n\n".format(func_sig) + # First write out the device signature + device_sig = "__device__ {};\n\n".format(func_sig) - idx = func_sig.find(name) + idx = func_sig.find(name) - # here's the case-sensitive name - case_name = func_sig[idx:idx+len(name)] + # here's the case-sensitive name + case_name = func_sig[idx:idx+len(name)] - # Add _device to the function name. + # Add _device to the function name. - device_sig = device_sig.replace(case_name, case_name + "_device") + device_sig = device_sig.replace(case_name, case_name + "_device") - # Now write out the global signature. This involves - # getting rid of the data type definitions and also - # replacing the lo and hi (which must be in the function - # definition) with blo and bhi. - dd = decls_re.search(func_sig) - vars = [] + # Now write out the global signature. This involves + # getting rid of the data type definitions and also + # replacing the lo and hi (which must be in the function + # definition) with blo and bhi. + dd = decls_re.search(func_sig) + vars = [] - has_lo = False - has_hi = False + has_lo = False + has_hi = False - intvect_vars = [] - real_vars = [] + intvect_vars = [] + real_vars = [] - for n, v in enumerate(dd.group(3).split(",")): + for n, v in enumerate(dd.group(3).split(",")): - # we will assume that our function signatures _always_ include - # the name of the variable - _tmp = v.split() - var = _tmp[-1].replace("*", "").replace("&", "").strip() + # we will assume that our function signatures _always_ include + # the name of the variable + _tmp = v.split() + var = _tmp[-1].replace("*", "").replace("&", "").strip() - # Replace AMReX Fortran macros - var = var.replace("BL_FORT_FAB_ARG_3D", "BL_FORT_FAB_VAL_3D") - var = var.replace("BL_FORT_IFAB_ARG_3D", "BL_FORT_FAB_VAL_3D") + # Replace AMReX Fortran macros + var = var.replace("BL_FORT_FAB_ARG_3D", "BL_FORT_FAB_VAL_3D") + var = var.replace("BL_FORT_IFAB_ARG_3D", "BL_FORT_FAB_VAL_3D") - # Get the list of all arguments which contain each macro. + # Get the list of all arguments which contain each macro. - args = signatures[name][0].split('(', 1)[1].rsplit(')', 1)[0].split(',') + args = signatures[name][0].split('(', 1)[1].rsplit(')', 1)[0].split(',') - for i, arg_positions in enumerate(signatures[name][1]): + for i, arg_positions in enumerate(signatures[name][1]): - if arg_positions != []: + if arg_positions != []: - if macro_list[i] == 'AMREX_INT_ANYD': + if macro_list[i] == 'AMREX_INT_ANYD': - # Replace AMREX_INT_ANYD with the necessary machinery, a set - # of three constant ints which will be passed by value. - # We only want to do this replacement once, otherwise it will - # replace every time for each argument position, so we will - # semi-arbitrarily do it in the loop index corresponding to - # the actual argument position. + # Replace AMREX_INT_ANYD with the necessary machinery, a set + # of three constant ints which will be passed by value. + # We only want to do this replacement once, otherwise it will + # replace every time for each argument position, so we will + # semi-arbitrarily do it in the loop index corresponding to + # the actual argument position. - for arg_position in arg_positions: + for arg_position in arg_positions: - if n == arg_position: - arg = args[arg_position] - v = arg.split()[-1] - func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) - device_sig = device_sig.replace(arg, "const int* {}".format(v)) - intvect_vars.append(v) + if n == arg_position: + arg = args[arg_position] + v = arg.split()[-1] + func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) + device_sig = device_sig.replace(arg, "const int* {}".format(v)) + intvect_vars.append(v) - elif macro_list[i] == 'AMREX_REAL_ANYD': + elif macro_list[i] == 'AMREX_REAL_ANYD': - # Same as the above, but with reals. + # Same as the above, but with reals. - for arg_position in arg_positions: + for arg_position in arg_positions: - if n == arg_position: - arg = args[arg_position] - v = arg.split()[-1] - func_sig = func_sig.replace(arg, "const amrex::Real {}_1, const amrex::Real {}_2, const amrex::Real {}_3".format(v, v, v)) - device_sig = device_sig.replace(arg, "const amrex::Real* {}".format(v)) - real_vars.append(v) + if n == arg_position: + arg = args[arg_position] + v = arg.split()[-1] + func_sig = func_sig.replace(arg, "const amrex::Real {}_1, const amrex::Real {}_2, const amrex::Real {}_3".format(v, v, v)) + device_sig = device_sig.replace(arg, "const amrex::Real* {}".format(v)) + real_vars.append(v) - elif macro_list[i] == 'BL_TO_FORTRAN_ANYD' or macro_list[i] == 'BL_TO_FORTRAN_N_ANYD' or macro_list[i] == 'BL_TO_FORTRAN_FAB': + elif macro_list[i] == 'BL_TO_FORTRAN_ANYD' or macro_list[i] == 'BL_TO_FORTRAN_N_ANYD' or macro_list[i] == 'BL_TO_FORTRAN_FAB': - # Treat this as a real* followed by two copies of AMREX_INT_ANYD, - # corresponding to the lo and hi bounds of the box. BL_TO_FORTRAN_FAB - # has a fourth argument corresponding to the number of components, - # which can be ignored for this logic. + # Treat this as a real* followed by two copies of AMREX_INT_ANYD, + # corresponding to the lo and hi bounds of the box. BL_TO_FORTRAN_FAB + # has a fourth argument corresponding to the number of components, + # which can be ignored for this logic. - for arg_position in arg_positions: - if n == arg_position: - for pos in [1, 2]: - arg = args[arg_position+pos] - v = arg.split()[-1] - func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) - device_sig = device_sig.replace(arg, "const int* {}".format(v)) - intvect_vars.append(v) + for arg_position in arg_positions: + if n == arg_position: + for pos in [1, 2]: + arg = args[arg_position+pos] + v = arg.split()[-1] + func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) + device_sig = device_sig.replace(arg, "const int* {}".format(v)) + intvect_vars.append(v) - elif macro_list[i] == 'BL_TO_FORTRAN_BOX': + elif macro_list[i] == 'BL_TO_FORTRAN_BOX': - # This is two copies of AMREX_INT_ANYD. + # This is two copies of AMREX_INT_ANYD. - for arg_position in arg_positions: - if n == arg_position: - for pos in [0, 1]: - arg = args[arg_position+pos] - v = arg.split()[-1] - func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) - device_sig = device_sig.replace(arg, "const int* {}".format(v)) - intvect_vars.append(v) + for arg_position in arg_positions: + if n == arg_position: + for pos in [0, 1]: + arg = args[arg_position+pos] + v = arg.split()[-1] + func_sig = func_sig.replace(arg, "const int {}_1, const int {}_2, const int {}_3".format(v, v, v)) + device_sig = device_sig.replace(arg, "const int* {}".format(v)) + intvect_vars.append(v) - if var == "lo": - var = "blo" - has_lo = True + if var == "lo": + var = "blo" + has_lo = True - elif var == "hi": - var = "bhi" - has_hi = True + elif var == "hi": + var = "bhi" + has_hi = True - vars.append(var) + vars.append(var) - if not has_lo or not has_hi: - sys.exit("ERROR: function signature must have variables lo and hi defined:\n--- function name:\n {} \n--- function signature:\n {}\n---".format(name, func_sig)) + if not has_lo or not has_hi: + sys.exit("ERROR: function signature must have variables lo and hi defined:\n--- function name:\n {} \n--- function signature:\n {}\n---".format(name, func_sig)) - # reassemble the function sig - all_vars = ", ".join(vars) - new_call = "{}({})".format(case_name + "_device", all_vars) + # reassemble the function sig + all_vars = ", ".join(vars) + new_call = "{}({})".format(case_name + "_device", all_vars) - # Collate all the IntVects that we are going to make - # local copies of. + # Collate all the IntVects that we are going to make + # local copies of. - intvects = "" + intvects = "" - if len(intvect_vars) > 0: - for intvect in intvect_vars: - intvects += " int {}[3] = {{{}_1, {}_2, {}_3}};\n".format(intvect, intvect, intvect, intvect) + if len(intvect_vars) > 0: + for intvect in intvect_vars: + intvects += " int {}[3] = {{{}_1, {}_2, {}_3}};\n".format(intvect, intvect, intvect, intvect) - # Same for reals. + # Same for reals. - reals = "" + reals = "" - if len(real_vars) > 0: - for real in real_vars: - reals += " amrex::Real {}[3] = {{{}_1, {}_2, {}_3}};\n".format(real, real, real, real) + if len(real_vars) > 0: + for real in real_vars: + reals += " amrex::Real {}[3] = {{{}_1, {}_2, {}_3}};\n".format(real, real, real, real) - hout.write(device_sig) - hout.write(TEMPLATE.format(func_sig[idx:].replace(';',''), intvects, reals, new_call)) - hout.write("\n") + hout.write(device_sig) + hout.write(TEMPLATE.format(func_sig[idx:].replace(';',''), intvects, reals, new_call)) + hout.write("\n") - # Close out the extern "C" region - hout.write("\n}\n") - hout.write("#endif\n") + # Close out the extern "C" region + hout.write("\n}\n") + hout.write("#endif\n") - # Close out the include guard - hout.write("\n") - hout.write("#endif\n") + # Close out the include guard + hout.write("\n") + hout.write("#endif\n") - hin.close() - hout.close() + hin.close() + hout.close() -def convert_cxx(outdir, cxx_files, cpp, defines): +def convert_cxx(inputs): """look through the C++ files for "#pragma gpu" and switch it to the appropriate CUDA launch macro""" - print('looking in C++ files: {}'.format(cxx_files)) - - for c in cxx_files: - cxx = "/".join([c[1], c[0]]) - - # open the original C++ file - try: - hin = open(cxx, "r") - except IOError: - sys.exit("Cannot open header {}".format(cxx)) - - # open the C++ file for output - _, tail = os.path.split(cxx) - ofile = os.path.join(outdir, tail) - try: - hout = open(ofile, "w") - except IOError: - sys.exit("Cannot open output file {}".format(ofile)) - - print("Working on file {}".format(ofile)) - - # look for the appropriate pragma, and once found, capture the - # function call following it - line = hin.readline() - while line: - - # if the line starts with "#pragma gpu", then we need - # to take action - if line.startswith("#pragma gpu"): - # we don't need to reproduce the pragma line in the - # output, but we need to capture the whole function - # call that follows - func_call = "" + cxx_file = inputs[0] + outdir = inputs[1] + cpp = inputs[2] + defines = inputs[3] + + print('looking in C++ file: {}'.format(cxx_file)) + + cxx = "/".join([cxx_file[1], cxx_file[0]]) + + # open the original C++ file + try: + hin = open(cxx, "r") + except IOError: + sys.exit("Cannot open header {}".format(cxx)) + + # open the C++ file for output + _, tail = os.path.split(cxx) + ofile = os.path.join(outdir, tail) + try: + hout = open(ofile, "w") + except IOError: + sys.exit("Cannot open output file {}".format(ofile)) + + print("Working on file {}".format(ofile)) + + # look for the appropriate pragma, and once found, capture the + # function call following it + line = hin.readline() + while line: + + # if the line starts with "#pragma gpu", then we need + # to take action + if line.startswith("#pragma gpu"): + # we don't need to reproduce the pragma line in the + # output, but we need to capture the whole function + # call that follows + func_call = "" + line = hin.readline() + while not line.strip().endswith(";"): + func_call += line line = hin.readline() - while not line.strip().endswith(";"): - func_call += line - line = hin.readline() - # last line -- remove the semi-colon - func_call += line.rstrip()[:-1] + # last line -- remove the semi-colon + func_call += line.rstrip()[:-1] - # now split it into the function name and the - # arguments - dd = decls_re.search(func_call) - func_name = dd.group(1).strip().replace(" ", "") - args = dd.group(3) + # now split it into the function name and the + # arguments + dd = decls_re.search(func_call) + func_name = dd.group(1).strip().replace(" ", "") + args = dd.group(3) - # Convert BL_TO_FORTRAN* to a form that we know will copy in - # the box indices by value. This is necessary to be in sync - # with what we did above to the headers. - args = args.replace('BL_TO_FORTRAN', 'BL_TO_FORTRAN_GPU') + # Convert BL_TO_FORTRAN* to a form that we know will copy in + # the box indices by value. This is necessary to be in sync + # with what we did above to the headers. + args = args.replace('BL_TO_FORTRAN', 'BL_TO_FORTRAN_GPU') - # Finally output the code in the form we want, with - # the device launch. We'll also have an option to - # drop back to a host launch; this is primarily for - # debugging at this time, but could be used later - # for dividing the work between the host and device. + # Finally output the code in the form we want, with + # the device launch. We'll also have an option to + # drop back to a host launch; this is primarily for + # debugging at this time, but could be used later + # for dividing the work between the host and device. - hout.write("#if defined(__CUDA_ARCH__)\n") + hout.write("#if defined(__CUDA_ARCH__)\n") - # For the device launch, we need to replace certain macros. - host_args = args - host_args = host_args.replace("AMREX_INT_ANYD", "AMREX_ARLIM_3D") - host_args = host_args.replace("AMREX_REAL_ANYD", "AMREX_ZFILL") - host_args = host_args.replace("BL_TO_FORTRAN_GPU", "BL_TO_FORTRAN") + # For the device launch, we need to replace certain macros. + host_args = args + host_args = host_args.replace("AMREX_INT_ANYD", "AMREX_ARLIM_3D") + host_args = host_args.replace("AMREX_REAL_ANYD", "AMREX_ZFILL") + host_args = host_args.replace("BL_TO_FORTRAN_GPU", "BL_TO_FORTRAN") - hout.write("{}_device\n ({});\n".format(func_name, host_args)) + hout.write("{}_device\n ({});\n".format(func_name, host_args)) - hout.write("#else\n") + hout.write("#else\n") - hout.write("if (amrex::Gpu::inLaunchRegion()) {\n") - hout.write(" dim3 {}numBlocks, {}numThreads;\n".format(func_name, func_name)) - hout.write(" amrex::Cuda::Device::grid_stride_threads_and_blocks({}numBlocks, {}numThreads);\n".format(func_name, func_name)) - hout.write("#if ((__CUDACC_VER_MAJOR__ > 9) || (__CUDACC_VER_MAJOR__ == 9 && __CUDACC_VER_MINOR__ >= 1))\n" \ - " AMREX_GPU_SAFE_CALL(cudaFuncSetAttribute(&cuda_{}, cudaFuncAttributePreferredSharedMemoryCarveout, 0));\n" \ - "#endif\n".format(func_name)) - hout.write(" cuda_{}<<<{}numBlocks, {}numThreads, 0, amrex::Cuda::Device::cudaStream()>>>\n ({});\n".format(func_name, func_name, func_name, args)) + hout.write("if (amrex::Gpu::inLaunchRegion()) {\n") + hout.write(" dim3 {}numBlocks, {}numThreads;\n".format(func_name, func_name)) + hout.write(" amrex::Cuda::Device::grid_stride_threads_and_blocks({}numBlocks, {}numThreads);\n".format(func_name, func_name)) + hout.write("#if ((__CUDACC_VER_MAJOR__ > 9) || (__CUDACC_VER_MAJOR__ == 9 && __CUDACC_VER_MINOR__ >= 1))\n" \ + " AMREX_GPU_SAFE_CALL(cudaFuncSetAttribute(&cuda_{}, cudaFuncAttributePreferredSharedMemoryCarveout, 0));\n" \ + "#endif\n".format(func_name)) + hout.write(" cuda_{}<<<{}numBlocks, {}numThreads, 0, amrex::Cuda::Device::cudaStream()>>>\n ({});\n".format(func_name, func_name, func_name, args)) - # Catch errors in the launch configuration. + # Catch errors in the launch configuration. - hout.write(" AMREX_GPU_SAFE_CALL(cudaGetLastError());\n") + hout.write(" AMREX_GPU_SAFE_CALL(cudaGetLastError());\n") - if 'AMREX_DEBUG' in defines: - hout.write("AMREX_GPU_SAFE_CALL(cudaDeviceSynchronize());\n") + if 'AMREX_DEBUG' in defines: + hout.write("AMREX_GPU_SAFE_CALL(cudaDeviceSynchronize());\n") - # For the host launch, we need to replace certain macros. - host_args = args - host_args = host_args.replace("AMREX_INT_ANYD", "AMREX_ARLIM_3D") - host_args = host_args.replace("AMREX_REAL_ANYD", "AMREX_ZFILL") - host_args = host_args.replace("BL_TO_FORTRAN_GPU", "BL_TO_FORTRAN") + # For the host launch, we need to replace certain macros. + host_args = args + host_args = host_args.replace("AMREX_INT_ANYD", "AMREX_ARLIM_3D") + host_args = host_args.replace("AMREX_REAL_ANYD", "AMREX_ZFILL") + host_args = host_args.replace("BL_TO_FORTRAN_GPU", "BL_TO_FORTRAN") - hout.write("} else {\n") - hout.write(" {}\n ({});\n".format(func_name, host_args)) - hout.write("}\n") + hout.write("} else {\n") + hout.write(" {}\n ({});\n".format(func_name, host_args)) + hout.write("}\n") - hout.write("#endif\n") + hout.write("#endif\n") - else: - # we didn't find a pragma - hout.write(line) + else: + # we didn't find a pragma + hout.write(line) - line = hin.readline() + line = hin.readline() - hout.close() + hout.close() - cpp.preprocess(CppFile(ofile), add_name="CPP") + cpp.preprocess(CppFile(ofile), add_name="CPP") if __name__ == "__main__": @@ -674,6 +680,9 @@ def convert_cxx(outdir, cxx_files, cpp, defines): parser.add_argument("--exclude_defines", help="space separated string of directives to remove from defines", default="") + parser.add_argument("--num_workers", + help="number of parallel workers", + default="1") args = parser.parse_args() @@ -696,6 +705,8 @@ def convert_cxx(outdir, cxx_files, cpp, defines): headers, _ = ffv.find_files(args.vpath, args.headers) cxx, _ = ffv.find_files(args.vpath, args.cxx) + num_workers = int(args.num_workers) + pool = Pool(num_workers) # part I: we need to find the names of the Fortran routines that # are called from C++ so we can modify the header in the @@ -710,9 +721,12 @@ def convert_cxx(outdir, cxx_files, cpp, defines): # copy the headers to the output directory, replacing the # signatures of the target Fortran routines with the CUDA pair - convert_headers(args.output_dir, targets, macro_list, headers, cpp_pass) - + inputs = [[header, args.output_dir, targets, macro_list, cpp_pass] for header in headers] + pool.map(convert_headers, inputs) # part II: for each C++ file, we need to expand the `#pragma gpu` - convert_cxx(args.output_dir, cxx, cpp_pass, defines) + inputs = [[cxx_file, args.output_dir, cpp_pass, defines] for cxx_file in cxx] + pool.map(convert_cxx, inputs) + pool.close() + pool.join() diff --git a/Tools/F_scripts/write_probin.py b/Tools/F_scripts/write_probin.py index 01f8dafa093..2a5104cab43 100755 --- a/Tools/F_scripts/write_probin.py +++ b/Tools/F_scripts/write_probin.py @@ -221,7 +221,7 @@ def write_probin(probin_template, param_A_files, param_B_files, fout.write("{}!$acc declare create({})\n".format(indent, pm[n].var)) elif type == "character": - fout.write("{}character (len=256), allocatable, public :: {}\n".format( + fout.write("{}character (len=256), public :: {}\n".format( indent, pm[n].var, pm[n].value)) fout.write("{}!$acc declare create({})\n".format(indent, pm[n].var)) @@ -275,13 +275,15 @@ def write_probin(probin_template, param_A_files, param_B_files, elif keyword == "cudaattributesB": pm = paramsB for pmi in pm: - fout.write("{}attributes(managed) :: {}\n".format(indent, pmi.var)) + if pmi.type != "character": + fout.write("{}attributes(managed) :: {}\n".format(indent, pmi.var)) elif keyword == "allocations": if managed: pm = paramsA + paramsB for pmi in pm: - fout.write("{}allocate({})\n".format(indent, pmi.var)) + if pmi.type != "character": + fout.write("{}allocate({})\n".format(indent, pmi.var)) elif keyword == "initialize": if managed: @@ -293,7 +295,8 @@ def write_probin(probin_template, param_A_files, param_B_files, if managed: pm = paramsA + paramsB for pmi in pm: - fout.write("{}deallocate({})\n".format(indent, pmi.var)) + if pmi.type != "character": + fout.write("{}deallocate({})\n".format(indent, pmi.var)) elif keyword == "namelist": diff --git a/Tools/GNUMake/Make.machines b/Tools/GNUMake/Make.machines index e496de2ece5..65d40800c2a 100644 --- a/Tools/GNUMake/Make.machines +++ b/Tools/GNUMake/Make.machines @@ -109,6 +109,10 @@ ifeq ($(findstring eagle, $(NREL_CLUSTER)), eagle) which_site := nrel which_computer := eagle endif +ifeq ($(findstring rhodes, $(NREL_CLUSTER)), rhodes) + which_site := nrel + which_computer := rhodes +endif ifeq ($(findstring daint, $(host_name)), daint) which_site := cscs diff --git a/Tools/GNUMake/Make.rules b/Tools/GNUMake/Make.rules index 43e121ba727..1ceb8436065 100644 --- a/Tools/GNUMake/Make.rules +++ b/Tools/GNUMake/Make.rules @@ -227,15 +227,31 @@ ifeq ($(USE_GPU_PRAGMA),TRUE) @if [ ! -d $(srcTempDir) ]; then mkdir -p $(srcTempDir); fi @$(SHELL) -ec 'cp $< $(srcTempDir)' $(AMREX_HOME)/Tools/F_scripts/gpu_fortran.py --fortran "$(srcTempDir)/$(> (std::istream& stream, ParticleHeader& header) { @@ -252,6 +254,8 @@ std::istream& operator>> (std::istream& stream, ParticleHeader& header) { header.offsets[i].push_back(num); } } + + return stream; } std::string getDataFileName(const std::string& prefix, int level, int file_num) { diff --git a/Tools/libamrex/mkconfig.py b/Tools/libamrex/mkconfig.py index 922543265ec..900143b7b81 100755 --- a/Tools/libamrex/mkconfig.py +++ b/Tools/libamrex/mkconfig.py @@ -25,6 +25,8 @@ def doit(defines, undefines, comp, allow_diff_comp, use_omp): print("#undef",undefines) + print("#ifdef __cplusplus"); + if comp == "gnu" or comp == "nag": print("#ifndef __GNUC__") print('static_assert(false,"libamrex was built with GNU");') @@ -67,6 +69,8 @@ def doit(defines, undefines, comp, allow_diff_comp, use_omp): else: sys.exit("ERROR: unknown use_omp flag "+use_omp+" in mkconfig.py") + print("#endif") # ifdef __cplusplus + print("#endif") if __name__ == "__main__": diff --git a/Tutorials/Amr/Advection_AmrCore/CMakeLists.txt b/Tutorials/Amr/Advection_AmrCore/CMakeLists.txt index 5ecb37d681f..ee346295ebc 100644 --- a/Tutorials/Amr/Advection_AmrCore/CMakeLists.txt +++ b/Tutorials/Amr/Advection_AmrCore/CMakeLists.txt @@ -1,10 +1,3 @@ -# -# Does not work if amrex is built in shared mode -# -if (BUILD_SHARED_LIBS) - return() -endif () - # # This test works for both 2D and 3D builds # diff --git a/Tutorials/Basic/HeatEquation_EX1_C/CMakeLists.txt b/Tutorials/Basic/HeatEquation_EX1_C/CMakeLists.txt index c163a180c90..4e23b4ac829 100644 --- a/Tutorials/Basic/HeatEquation_EX1_C/CMakeLists.txt +++ b/Tutorials/Basic/HeatEquation_EX1_C/CMakeLists.txt @@ -1,10 +1,3 @@ -# -# This one does not work if amrex is build in shared mode -# -if (BUILD_SHARED_LIBS) - return() -endif () - get_filename_component ( DIRNAME ${CMAKE_CURRENT_LIST_DIR} NAME ) set ( TESTNAME ${DIRNAME} ) diff --git a/Tutorials/CMakeLists.txt b/Tutorials/CMakeLists.txt index 6500a9cc359..417b60e9fde 100644 --- a/Tutorials/CMakeLists.txt +++ b/Tutorials/CMakeLists.txt @@ -1,6 +1,7 @@ set ( AMREX_TUTORIALS_DIR ${CMAKE_CURRENT_LIST_DIR} ) -set ( AMREX_TUTORIALS_SUBDIRS Amr Basic GPU) # For now only Amr + +set ( AMREX_TUTORIALS_SUBDIRS Amr Basic CVODE GPU) # For now only Amr prepend ( AMREX_TUTORIALS_SUBDIRS ${AMREX_TUTORIALS_DIR}) diff --git a/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/CMakeLists.txt b/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/CMakeLists.txt new file mode 100644 index 00000000000..b26f421ac85 --- /dev/null +++ b/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/CMakeLists.txt @@ -0,0 +1,41 @@ +# +# Does not work if amrex is built in shared mode +# +if (NOT (ENABLE_SUNDIALS) ) + return() +endif () + +set( EXENAME "sundials3_cvode_cpp_ex1_serial.exe" ) + +add_executable( ${EXENAME} EXCLUDE_FROM_ALL "" ) + +target_sources( ${EXENAME} PRIVATE + SetIC.f90 + main.cpp + myfunc_F.H + ) + +set_target_properties( ${EXENAME} PROPERTIES + INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_BINARY_DIR}/mod_files" + Fortran_MODULE_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/mod_files + RUNTIME_OUTPUT_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR} ) + +target_link_libraries( ${EXENAME} amrex ) + +# +# Find input files +# +file( GLOB_RECURSE inputs LIST_DIRECTORIES false ${CMAKE_CURRENT_LIST_DIR}/input* ) + +# +# Copy input files to corresponding build dir +# +file( COPY ${inputs} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) + +# +# Add to the "tutorial" target +# +add_tutorial(${EXENAME}) diff --git a/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/main.cpp b/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/main.cpp index d3c201e7ae3..8ecd0d64a15 100644 --- a/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/main.cpp +++ b/Tutorials/CVODE/SUNDIALS3_cppversion/EX1_SERIAL_NVEC/main.cpp @@ -6,19 +6,11 @@ #include #include #include -#if !defined(BL_NO_FORT) -#include -#endif - -#include - #include /* prototypes for CVODE fcts., consts. */ #include /* access to SPGMR SUNLinearSolver */ #include /* access to CVSpils interface */ #include /* definition of type realtype */ #include /* definition of ABS and EXP */ - -#include #include #include "myfunc_F.H" diff --git a/Tutorials/CVODE/SUNDIALS3_finterface/EX1/CMakeLists.txt b/Tutorials/CVODE/SUNDIALS3_finterface/EX1/CMakeLists.txt new file mode 100644 index 00000000000..90bf02bc98a --- /dev/null +++ b/Tutorials/CVODE/SUNDIALS3_finterface/EX1/CMakeLists.txt @@ -0,0 +1,43 @@ +# +# Does not work if amrex is built in shared mode +# +if (NOT (ENABLE_SUNDIALS AND ENABLE_SUNDIALS_CVODE) ) + return() +endif () + +set( EXENAME "sundials3_cvode_finterface_ex1.exe" ) + +add_executable( ${EXENAME} EXCLUDE_FROM_ALL "" ) + +target_sources( ${EXENAME} PRIVATE + integrate_ode.f90 + main.cpp + myfunc_F.H + ode_mod.f90 + ) + +set_target_properties( ${EXENAME} PROPERTIES + INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_BINARY_DIR}/mod_files" + Fortran_MODULE_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/mod_files + RUNTIME_OUTPUT_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR} ) + +target_link_libraries( ${EXENAME} amrex ) + +# +# Find input files +# +file( GLOB_RECURSE inputs LIST_DIRECTORIES false ${CMAKE_CURRENT_LIST_DIR}/input* ) + +# +# Copy input files to corresponding build dir +# +file( COPY ${inputs} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} ) + +# +# Add to the "tutorial" target +# +add_tutorial(${EXENAME}) + diff --git a/Tutorials/CVODE/SUNDIALS3_finterface/EX1/main.cpp b/Tutorials/CVODE/SUNDIALS3_finterface/EX1/main.cpp index b63ac690545..5b347bdd612 100644 --- a/Tutorials/CVODE/SUNDIALS3_finterface/EX1/main.cpp +++ b/Tutorials/CVODE/SUNDIALS3_finterface/EX1/main.cpp @@ -19,142 +19,142 @@ using namespace amrex; int main (int argc, char* argv[]) { amrex::Initialize(argc,argv); - - // What time is it now? We'll use this to compute total run time. - Real strt_time = ParallelDescriptor::second(); - - std::cout << std::setprecision(15); - - int n_cell, max_grid_size; - int cvode_meth, cvode_itmeth, write_plotfile; - bool do_tiling; - - // inputs parameters - { - // ParmParse is way of reading inputs from the inputs file - ParmParse pp; - - // We need to get n_cell from the inputs file - this is the number of - // cells on each side of a square (or cubic) domain. - pp.get("n_cell",n_cell); - - // Default nsteps to 0, allow us to set it to something else in the - // inputs file - pp.get("max_grid_size",max_grid_size); - - // Select CVODE solve method. - // 1 = Adams (for non-stiff problems) - // 2 = BDF (for stiff problems) - pp.get("cvode_meth",cvode_meth); - // Select CVODE solver iteration method. - // 1 = Functional iteration - // 2 = Newton iteration - pp.get("cvode_itmeth",cvode_itmeth); - - pp.get("write_plotfile",write_plotfile); - pp.get("do_tiling",do_tiling); - } - - if (cvode_meth < 1) - amrex::Abort("Unknown cvode_meth"); - if (cvode_itmeth < 1) - amrex::Abort("Unknown cvode_itmeth"); - - amrex::Print() << "This is AMReX version " << amrex::Version() << std::endl; - amrex::Print() << "Problem domain size: nx = ny = nz = " << n_cell << std::endl; - amrex::Print() << "Max grid size: " << max_grid_size << std::endl; - amrex::Print() << "CVODE method: "; - if (cvode_meth == 1) { - amrex::Print() << "Adams (non-stiff)"; - } else if (cvode_meth == 2) { - amrex::Print() << "BDF (stiff)"; - } - amrex::Print() << std::endl; - amrex::Print() << "CVODE iteration method: "; - if (cvode_itmeth == 1) { - amrex::Print() << "Functional"; - } else if (cvode_itmeth == 2) { - amrex::Print() << "Newton"; - } - amrex::Print() << std::endl; - - // make BoxArray and Geometry - BoxArray ba; - Geometry geom; { - IntVect dom_lo(IntVect(D_DECL(0,0,0))); - IntVect dom_hi(IntVect(D_DECL(n_cell-1, n_cell-1, n_cell-1))); - Box domain(dom_lo, dom_hi); - - // Initialize the boxarray "ba" from the single box "bx" - ba.define(domain); - - // Break up boxarray "ba" into chunks no larger than "max_grid_size" - // along a direction - ba.maxSize(max_grid_size); - - // This defines the physical size of the box. Right now the box is - // [-1,1] in each direction. - RealBox real_box; - for (int n = 0; n < BL_SPACEDIM; n++) { - real_box.setLo(n,-1.0); - real_box.setHi(n, 1.0); - } - - // This sets the boundary conditions to be doubly or triply periodic - int is_periodic[BL_SPACEDIM]; - for (int i = 0; i < BL_SPACEDIM; i++) { - is_periodic[i] = 1; - } - - // This defines a Geometry object - geom.define(domain,&real_box,CoordSys::cartesian,is_periodic); - } - - // Ncomp = number of components for each array - int Ncomp = 1; - - // time = starting time in the simulation - Real time = 0.0; - - DistributionMapping dm(ba); - - // Create MultiFab with no ghost cells. - MultiFab mf(ba, dm, Ncomp, 0); + // What time is it now? We'll use this to compute total run time. + Real strt_time = ParallelDescriptor::second(); + + std::cout << std::setprecision(15); + + int n_cell, max_grid_size; + int cvode_meth, cvode_itmeth, write_plotfile; + bool do_tiling; + + // inputs parameters + { + // ParmParse is way of reading inputs from the inputs file + ParmParse pp; + + // We need to get n_cell from the inputs file - this is the number of + // cells on each side of a square (or cubic) domain. + pp.get("n_cell",n_cell); + + // Default nsteps to 0, allow us to set it to something else in the + // inputs file + pp.get("max_grid_size",max_grid_size); + + // Select CVODE solve method. + // 1 = Adams (for non-stiff problems) + // 2 = BDF (for stiff problems) + pp.get("cvode_meth",cvode_meth); + // Select CVODE solver iteration method. + // 1 = Functional iteration + // 2 = Newton iteration + pp.get("cvode_itmeth",cvode_itmeth); + + pp.get("write_plotfile",write_plotfile); + pp.get("do_tiling",do_tiling); + } + + if (cvode_meth < 1) + amrex::Abort("Unknown cvode_meth"); + if (cvode_itmeth < 1) + amrex::Abort("Unknown cvode_itmeth"); + + amrex::Print() << "This is AMReX version " << amrex::Version() << std::endl; + amrex::Print() << "Problem domain size: nx = ny = nz = " << n_cell << std::endl; + amrex::Print() << "Max grid size: " << max_grid_size << std::endl; + amrex::Print() << "CVODE method: "; + if (cvode_meth == 1) { + amrex::Print() << "Adams (non-stiff)"; + } else if (cvode_meth == 2) { + amrex::Print() << "BDF (stiff)"; + } + amrex::Print() << std::endl; + amrex::Print() << "CVODE iteration method: "; + if (cvode_itmeth == 1) { + amrex::Print() << "Functional"; + } else if (cvode_itmeth == 2) { + amrex::Print() << "Newton"; + } + amrex::Print() << std::endl; + + // make BoxArray and Geometry + BoxArray ba; + Geometry geom; + { + IntVect dom_lo(IntVect(D_DECL(0,0,0))); + IntVect dom_hi(IntVect(D_DECL(n_cell-1, n_cell-1, n_cell-1))); + Box domain(dom_lo, dom_hi); + + // Initialize the boxarray "ba" from the single box "bx" + ba.define(domain); + + // Break up boxarray "ba" into chunks no larger than "max_grid_size" + // along a direction + ba.maxSize(max_grid_size); + + // This defines the physical size of the box. Right now the box is + // [-1,1] in each direction. + RealBox real_box; + for (int n = 0; n < BL_SPACEDIM; n++) { + real_box.setLo(n,-1.0); + real_box.setHi(n, 1.0); + } + + // This sets the boundary conditions to be doubly or triply periodic + int is_periodic[BL_SPACEDIM]; + for (int i = 0; i < BL_SPACEDIM; i++) { + is_periodic[i] = 1; + } + + // This defines a Geometry object + geom.define(domain,&real_box,CoordSys::cartesian,is_periodic); + } + + // Ncomp = number of components for each array + int Ncomp = 1; + + // time = starting time in the simulation + Real time = 0.0; + + DistributionMapping dm(ba); + + // Create MultiFab with no ghost cells. + MultiFab mf(ba, dm, Ncomp, 0); #ifdef _OPENMP #pragma omp parallel #endif - for ( MFIter mfi(mf, do_tiling); mfi.isValid(); ++mfi ) - { - const Box& tbx = mfi.tilebox(); - - integrate_ode(mf[mfi].dataPtr(), - tbx.loVect(), - tbx.hiVect(), - &cvode_meth, - &cvode_itmeth); + for ( MFIter mfi(mf, do_tiling); mfi.isValid(); ++mfi ) + { + const Box& tbx = mfi.tilebox(); + + integrate_ode(mf[mfi].dataPtr(), + tbx.loVect(), + tbx.hiVect(), + &cvode_meth, + &cvode_itmeth); + } + + if (write_plotfile) + { + amrex::WriteSingleLevelPlotfile("PLT_OUTPUT", + mf, + {"y1"}, + geom, + time, + 0); + } + + // Call the timer again and compute the maximum difference between the start time and stop time + // over all processors + Real stop_time = ParallelDescriptor::second() - strt_time; + const int IOProc = ParallelDescriptor::IOProcessorNumber(); + ParallelDescriptor::ReduceRealMax(stop_time,IOProc); + + // Tell the I/O Processor to write out the "run time" + amrex::Print() << "Run time = " << stop_time << std::endl; } - - if (write_plotfile) - { - amrex::WriteSingleLevelPlotfile("PLT_OUTPUT", - mf, - {"y1"}, - geom, - time, - 0); - } - - // Call the timer again and compute the maximum difference between the start time and stop time - // over all processors - Real stop_time = ParallelDescriptor::second() - strt_time; - const int IOProc = ParallelDescriptor::IOProcessorNumber(); - ParallelDescriptor::ReduceRealMax(stop_time,IOProc); - - // Tell the I/O Processor to write out the "run time" - amrex::Print() << "Run time = " << stop_time << std::endl; - amrex::Finalize(); return 0; } diff --git a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/GNUmakefile b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/GNUmakefile index 4961cb71bab..180153fb9dc 100644 --- a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/GNUmakefile +++ b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/GNUmakefile @@ -13,6 +13,7 @@ COMP = gnu USE_MPI = TRUE USE_OMP = FALSE +USE_CUDA = TRUE USE_SENSEI_INSITU = FALSE diff --git a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/Prob.H b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/Prob.H index 569354cbb87..3d373692bfd 100644 --- a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/Prob.H +++ b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/Prob.H @@ -3,7 +3,6 @@ #include -#include #include #include #include @@ -24,12 +23,12 @@ initdata(Box const& bx, Array4 const& phi, GeometryData const& geomdata) #ifdef _OPENMP #pragma omp parallel for collapse(2) if (GPU::notInLaunchRegion) #endif - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { Real z = prob_lo[2] + (0.5+k) * dx[2]; Real y = prob_lo[1] + (0.5+j) * dx[1]; AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { + for (int i = lo.x; i <= hi.x; ++i) { Real x = prob_lo[0] + (0.5+i) * dx[0]; #if (AMREX_SPACEDIM == 2) Real r2 = (pow(x-0.5, 2) + pow((y-0.75),2)) / 0.01; diff --git a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/face_velocity.H b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/face_velocity.H index 8454a3d45a8..028d13e88ae 100644 --- a/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/face_velocity.H +++ b/Tutorials/GPU/Advection_AmrCore/Exec/SingleVortex/face_velocity.H @@ -1,7 +1,6 @@ #ifndef _FACE_VELOCITY_H_ #define _FACE_VELOCITY_H_ -#include #include #include #include @@ -22,10 +21,10 @@ void get_face_velocity_psi(Box const& bx, const Real* AMREX_RESTRICT prob_lo = geomdata.ProbLo(); const Real* AMREX_RESTRICT dx = geomdata.CellSize(); - for (int j = lo.y; j < hi.y; ++j) { + for (int j = lo.y; j <= hi.y; ++j) { Real y = dx[1]*(0.5+j) + prob_lo[1]; AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { + for (int i = lo.x; i <= hi.x; ++i) { Real x = dx[0]*(0.5+i) + prob_lo[0]; psi(i,j,0) = pow(sin(M_PI*x), 2) * pow(sin(M_PI*y), 2) * cos(M_PI*time/2.0) * 1.0/M_PI; @@ -35,68 +34,35 @@ void get_face_velocity_psi(Box const& bx, AMREX_GPU_DEVICE AMREX_INLINE -void get_face_velocity_x(Box const& bx, +void get_face_velocity_x(int i, int j, int k, Array4 const& vx, Array4 const& psi, - GeometryData const& geomdata) + GpuArray prob_lo, + GpuArray dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - const Real* AMREX_RESTRICT prob_lo = geomdata.ProbLo(); - const Real* AMREX_RESTRICT dx = geomdata.CellSize(); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { - vx(i,j,k) = -( (psi(i,j+1,0)+psi(i-1,j+1,0)) - (psi(i,j-1,0)+psi(i-1,j-1,0)) ) * (0.25/dx[1]); - } - } - } + vx(i,j,k) = -( (psi(i,j+1,0)+psi(i-1,j+1,0)) - (psi(i,j-1,0)+psi(i-1,j-1,0)) ) * (0.25/dx[1]); } AMREX_GPU_DEVICE AMREX_INLINE -void get_face_velocity_y(Box const& bx, +void get_face_velocity_y(int i, int j, int k, Array4 const& vy, Array4 const& psi, - GeometryData const& geomdata) + GpuArray prob_lo, + GpuArray dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - const Real* AMREX_RESTRICT prob_lo = geomdata.ProbLo(); - const Real* AMREX_RESTRICT dx = geomdata.CellSize(); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { - vy(i,j,k) = ( (psi(i+1,j,0)+psi(i+1,j-1,0)) - (psi(i-1,j,0)+psi(i-1,j-1,0)) ) * (0.25/dx[0]); - } - } - } + vy(i,j,k) = ( (psi(i+1,j,0)+psi(i+1,j-1,0)) - (psi(i-1,j,0)+psi(i-1,j-1,0)) ) * (0.25/dx[0]); } AMREX_GPU_DEVICE AMREX_INLINE -void get_face_velocity_z(Box const& bx, +void get_face_velocity_z(int i, int j, int k, Array4 const& vz, Array4 const& psi, - GeometryData const& geomdata) + GpuArray prob_lo, + GpuArray dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - AMREX_PRAGMA_SIMD - for (int i = lo.x; i < hi.x; ++i) { - vz(i,j,k) = 1.0; - } - } - } + vz(i,j,k) = 1.0; } #endif diff --git a/Tutorials/GPU/Advection_AmrCore/Source/AmrCoreAdv.cpp b/Tutorials/GPU/Advection_AmrCore/Source/AmrCoreAdv.cpp index 6f220a664b9..5152f35bb3d 100644 --- a/Tutorials/GPU/Advection_AmrCore/Source/AmrCoreAdv.cpp +++ b/Tutorials/GPU/Advection_AmrCore/Source/AmrCoreAdv.cpp @@ -663,34 +663,33 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) AsyncFab psifab(psibox, 1); Array4 psi = psifab.array(); GeometryData geomdata = geom[lev].data(); + auto prob_lo = geom[lev].ProbLoArray(); + auto dx = geom[lev].CellSizeArray(); - AMREX_LAUNCH_DEVICE_LAMBDA(psibox, tbx, + amrex::launch(psibox, + [=] AMREX_GPU_DEVICE (const Box& tbx) { get_face_velocity_psi(tbx, ctr_time, - psi, - geomdata); + psi, geomdata); }); AMREX_D_TERM( - AMREX_LAUNCH_DEVICE_LAMBDA(ngbxx, tbx, + amrex::ParallelFor(ngbxx, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_x(tbx, - vel[0], psi, - geomdata); + get_face_velocity_x(i, j, k, vel[0], psi, prob_lo, dx); });, - AMREX_LAUNCH_DEVICE_LAMBDA(ngbxy, tbx, + amrex::ParallelFor(ngbxy, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_y(tbx, - vel[1], psi, - geomdata); + get_face_velocity_y(i, j, k, vel[1], psi, prob_lo, dx); });, - AMREX_LAUNCH_DEVICE_LAMBDA(ngbxz, tbx, + amrex::ParallelFor(ngbxz, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_z(tbx, - vel[2], psi, - geomdata); + get_face_velocity_z(i, j, k, vel[2], psi, prob_lo, dx); }); ); @@ -724,57 +723,66 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) AsyncFab phixfab (gbx, 1); Array4 phix = phixfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(dqbxx, tbx, + amrex::launch(dqbxx, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopex2(tbx, statein, slope2); }); - AMREX_LAUNCH_DEVICE_LAMBDA(gbx, tbx, + amrex::launch(gbx, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopex4(tbx, statein, slope2, slope4); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growLo(gbx, 0, -1), tbx, + amrex::ParallelFor(amrex::growLo(gbx, 0, -1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_x(tbx, statein, vel[0], phix, slope4, dtdx); + flux_x(i, j, k, statein, vel[0], phix, slope4, dtdx); }); // y ------------------------- AsyncFab phiyfab (gbx, 1); Array4 phiy = phiyfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(dqbxy, tbx, + amrex::launch(dqbxy, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopey2(tbx, statein, slope2); }); - AMREX_LAUNCH_DEVICE_LAMBDA(gbx, tbx, + amrex::launch(gbx, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopey4(tbx, statein, slope2, slope4); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growLo(gbx, 1, -1), tbx, + amrex::ParallelFor(amrex::growLo(gbx, 1, -1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_y(tbx, statein, vel[1], phiy, slope4, dtdx); + flux_y(i, j, k, statein, vel[1], phiy, slope4, dtdx); }); // z ------------------------- AsyncFab phizfab (gbx, 1); Array4 phiz = phizfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(dqbxz, tbx, + amrex::launch(dqbxz, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopez2(tbx, statein, slope2); }); - AMREX_LAUNCH_DEVICE_LAMBDA(gbx, tbx, + amrex::launch(gbx, + [=] AMREX_GPU_DEVICE (const Box& tbx) { slopez4(tbx, statein, slope2, slope4); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growLo(gbx, 2, -1), tbx, + amrex::ParallelFor(amrex::growLo(gbx, 2, -1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_z(tbx, statein, vel[2], phiz, slope4, dtdx); + flux_z(i, j, k, statein, vel[2], phiz, slope4, dtdx); }); slope2fab.clear(); @@ -793,17 +801,19 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) Array4 phix_y = phix_yfab.array(); Array4 phix_z = phix_zfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxz, 0, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxz, 0, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_xy(tbx, + flux_xy(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phix_y, dtdx); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxy, 0, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxy, 0, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_xz(tbx, + flux_xz(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phix_z, dtdx); @@ -815,17 +825,19 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) Array4 phiy_x = phiy_xfab.array(); Array4 phiy_z = phiy_zfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxz, 1, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxz, 1, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_yx(tbx, + flux_yx(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phiy_x, dtdx); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxx, 1, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxx, 1, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_yz(tbx, + flux_yz(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phiy_z, dtdx); @@ -837,17 +849,19 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) Array4 phiz_x = phiz_xfab.array(); Array4 phiz_y = phiz_yfab.array(); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxy, 2, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxy, 2, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_zx(tbx, + flux_zx(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phiz_x, dtdx); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(gbxx, 2, 1), tbx, + amrex::ParallelFor(amrex::growHi(gbxx, 2, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_zy(tbx, + flux_zy(i, j, k, AMREX_D_DECL(vel[0], vel[1], vel[2]), AMREX_D_DECL(phix, phiy, phiz), phiz_y, dtdx); @@ -855,25 +869,28 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) // final edge states // =========================== - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 0, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 0, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - combine_flux_x(tbx, + combine_flux_x(i, j, k, vel[0], vel[1], vel[2], phix, phiy_z, phiz_y, flux[0], dtdx); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 1, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 1, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - combine_flux_y(tbx, + combine_flux_y(i, j, k, vel[0], vel[1], vel[2], phiy, phix_z, phiz_x, flux[1], dtdx); }); - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 2, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 2, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - combine_flux_z(tbx, + combine_flux_z(i, j, k, vel[0], vel[1], vel[2], phiz, phix_y, phiy_x, flux[2], dtdx); @@ -894,44 +911,46 @@ AmrCoreAdv::Advance (int lev, Real time, Real dt_lev, int iteration, int ncycle) // =========================== // Do a conservative update - AMREX_LAUNCH_DEVICE_LAMBDA(bx, tbx, + amrex::ParallelFor(bx, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - conservative(tbx, statein, stateout, - AMREX_D_DECL(flux[0], flux[1], flux[2]), + conservative(i, j, k, + statein, stateout, + AMREX_D_DECL(flux[0], flux[1], flux[2]), dtdx); }); // Scale by face area in order to correctly reflux AMREX_D_TERM( - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 0, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 0, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_scale_x(tbx, flux[0], dt_lev, dx); + flux_scale_x(i, j, k, flux[0], dt_lev, dx); });, - - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 1, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 1, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_scale_y(tbx, flux[1], dt_lev, dx); + flux_scale_y(i, j, k, flux[1], dt_lev, dx); });, - AMREX_LAUNCH_DEVICE_LAMBDA(amrex::growHi(bx, 2, 1), tbx, + amrex::ParallelFor(amrex::growHi(bx, 2, 1), + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - flux_scale_z(tbx, flux[2], dt_lev, dx); + flux_scale_z(i, j, k, flux[2], dt_lev, dx); }); ); - GpuArray fluxout{ AMREX_D_DECL(fluxes[0].fabPtr(mfi), - fluxes[1].fabPtr(mfi), - fluxes[2].fabPtr(mfi)) }; - GpuArray fluxes{ AMREX_D_DECL(fluxcalc[0].fabPtr(mfi), - fluxcalc[1].fabPtr(mfi), - fluxcalc[2].fabPtr(mfi)) }; + GpuArray, AMREX_SPACEDIM> fluxout{ AMREX_D_DECL(fluxes[0].array(mfi), + fluxes[1].array(mfi), + fluxes[2].array(mfi)) }; if (do_reflux) { for (int i = 0; i < BL_SPACEDIM; i++) { - AMREX_LAUNCH_DEVICE_LAMBDA(nbx[i], tbx, + amrex::ParallelFor(nbx[i], + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - fluxout[i]->copy(*fluxes[i], tbx); + fluxout[i](i,j,k) = flux[i](i,j,k); }); } } @@ -1045,13 +1064,6 @@ AmrCoreAdv::EstTimeStep (int lev, bool local) const GpuArray, AMREX_SPACEDIM> vel { AMREX_D_DECL(facevel[0].array(mfi), facevel[1].array(mfi), facevel[2].array(mfi)) }; -/* - // Setup for size of psi FArrayBox in Fortran, for reference. - plo(1) = min(vx_l1-1, vy_l1-1) - plo(2) = min(vx_l2-1, vy_l2-1) - phi(1) = max(vx_h1 , vy_h1+1) - phi(2) = max(vx_h2+1, vy_h2 ) -*/ const Box& psibox = Box(IntVect(AMREX_D_DECL(std::min(nbxx.smallEnd(0)-1, nbxy.smallEnd(0)-1), std::min(nbxx.smallEnd(1)-1, nbxy.smallEnd(0)-1), @@ -1063,38 +1075,32 @@ AmrCoreAdv::EstTimeStep (int lev, bool local) const AsyncFab psifab(psibox, 1); Array4 psi = psifab.array(); GeometryData geomdata = geom[lev].data(); + auto prob_lo = geom[lev].ProbLoArray(); + auto dx = geom[lev].CellSizeArray(); amrex::launch(psibox, [=] AMREX_GPU_DEVICE (Box const& tbx) { - get_face_velocity_psi(tbx, cur_time, - psi, - geomdata); + get_face_velocity_psi(tbx, cur_time, psi, geomdata); }); AMREX_D_TERM( - amrex::launch(nbxx, - [=] AMREX_GPU_DEVICE (Box const& tbx) + amrex::ParallelFor(nbxx, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_x(tbx, - vel[0], psi, - geomdata); + get_face_velocity_x(i, j, k, vel[0], psi, prob_lo, dx); });, - amrex::launch(nbxy, - [=] AMREX_GPU_DEVICE (Box const& tbx) + amrex::ParallelFor(nbxy, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_y(tbx, - vel[1], psi, - geomdata); + get_face_velocity_y(i, j, k, vel[1], psi, prob_lo, dx); });, - amrex::launch(nbxz, - [=] AMREX_GPU_DEVICE (Box const& tbx) + amrex::ParallelFor(nbxz, + [=] AMREX_GPU_DEVICE (int i, int j, int k) { - get_face_velocity_z(tbx, - vel[2], psi, - geomdata); + get_face_velocity_z(i, j, k, vel[2], psi, prob_lo, dx); }); ); diff --git a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/Adv_3d.H b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/Adv_3d.H index 4a403d46640..bc87b6d5692 100644 --- a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/Adv_3d.H +++ b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/Adv_3d.H @@ -1,7 +1,6 @@ #ifndef _Adv_3d_H_ #define _Adv_3d_H_ -#include #include #include #include @@ -11,7 +10,7 @@ using namespace amrex; AMREX_GPU_DEVICE AMREX_INLINE -void conservative(Box const& bx, +void conservative(int i, int j, int k, Array4 const& uin, Array4 const& uout, AMREX_D_DECL(Array4 const& flxx, @@ -19,76 +18,40 @@ void conservative(Box const& bx, Array4 const& flxz), const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - uout(i,j,k) = uin(i,j,k) + - ( (flxx(i,j,k) - flxx(i+1,j,k)) * dtdx[0] - + (flxy(i,j,k) - flxy(i,j+1,k)) * dtdx[1] - + (flxz(i,j,k) - flxz(i,j,k+1)) * dtdx[2] ); - } - } - } + uout(i,j,k) = uin(i,j,k) + + ( (flxx(i,j,k) - flxx(i+1,j,k)) * dtdx[0] + + (flxy(i,j,k) - flxy(i,j+1,k)) * dtdx[1] + + (flxz(i,j,k) - flxz(i,j,k+1)) * dtdx[2] ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_scale_x(Box const& bx, +void flux_scale_x(int i, int j, int k, Array4 const& flxx, Real dt, const GpuArray& dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - flxx(i,j,k) = flxx(i,j,k) * (dt * dx[1]*dx[2]); - } - } - } + flxx(i,j,k) = flxx(i,j,k) * (dt * dx[1]*dx[2]); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_scale_y(Box const& bx, +void flux_scale_y(int i, int j, int k, Array4 const& flxy, Real dt, const GpuArray& dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - flxy(i,j,k) = flxy(i,j,k) * (dt * dx[0]*dx[2]); - } - } - } + flxy(i,j,k) = flxy(i,j,k) * (dt * dx[0]*dx[2]); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_scale_z(Box const& bx, - Array4 const& flxz, - Real dt, - const GpuArray& dx) +void flux_scale_z(int i, int j ,int k, + Array4 const& flxz, + Real dt, + const GpuArray& dx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - flxz(i,j,k) = flxz(i,j,k) * (dt * dx[0]*dx[1]); - } - } - } + flxz(i,j,k) = flxz(i,j,k) * (dt * dx[0]*dx[1]); } #endif diff --git a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/compute_flux_3d.H b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/compute_flux_3d.H index 81d34516950..85fa81786ee 100644 --- a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/compute_flux_3d.H +++ b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/compute_flux_3d.H @@ -10,76 +10,49 @@ using namespace amrex; AMREX_GPU_DEVICE AMREX_INLINE -void flux_x(Box const& bx, +void flux_x(int i, int j, int k, Array4 const& phi, Array4 const& vx, Array4 const& px, Array4 const& slope, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - px(i,j,k) = ( (vx(i,j,k) < 0) ? - phi(i ,j,k) - slope(i ,j,k)*(0.5 + 0.5*dtdx[0]*vx(i,j,k)) : - phi(i-1,j,k) + slope(i-1,j,k)*(0.5 - 0.5*dtdx[0]*vx(i,j,k)) ); - } - } - } + px(i,j,k) = ( (vx(i,j,k) < 0) ? + phi(i ,j,k) - slope(i ,j,k)*(0.5 + 0.5*dtdx[0]*vx(i,j,k)) : + phi(i-1,j,k) + slope(i-1,j,k)*(0.5 - 0.5*dtdx[0]*vx(i,j,k)) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_y(Box const& bx, +void flux_y(int i, int j, int k, Array4 const& phi, Array4 const& vy, Array4 const& py, Array4 const& slope, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - py(i,j,k) = ( (vy(i,j,k) < 0) ? - phi(i,j ,k) - slope(i,j ,k)*(0.5 + 0.5*dtdx[0]*vy(i,j,k)) : - phi(i,j-1,k) + slope(i,j-1,k)*(0.5 - 0.5*dtdx[0]*vy(i,j,k)) ); - } - } - } + py(i,j,k) = ( (vy(i,j,k) < 0) ? + phi(i,j ,k) - slope(i,j ,k)*(0.5 + 0.5*dtdx[0]*vy(i,j,k)) : + phi(i,j-1,k) + slope(i,j-1,k)*(0.5 - 0.5*dtdx[0]*vy(i,j,k)) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_z(Box const& bx, +void flux_z(int i, int j, int k, Array4 const& phi, Array4 const& vz, Array4 const& pz, Array4 const& slope, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pz(i,j,k) = ( (vz(i,j,k) < 0) ? - phi(i,j,k ) - slope(i,j,k )*(0.5 + 0.5*dtdx[0]*vz(i,j,k)) : - phi(i,j,k-1) + slope(i,j,k-1)*(0.5 - 0.5*dtdx[0]*vz(i,j,k)) ); - } - } - } + pz(i,j,k) = ( (vz(i,j,k) < 0) ? + phi(i,j,k ) - slope(i,j,k )*(0.5 + 0.5*dtdx[0]*vz(i,j,k)) : + phi(i,j,k-1) + slope(i,j,k-1)*(0.5 - 0.5*dtdx[0]*vz(i,j,k)) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_xy(Box const& bx, +void flux_xy(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -89,23 +62,14 @@ void flux_xy(Box const& bx, Array4 const& pxy, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pxy(i,j,k) = ( (vx(i,j,k) < 0) ? - px(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i, j+1,k) + vy(i ,j,k)) * (py(i ,j+1,k) - py(i ,j,k))) : - px(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i-1,j+1,k) + vy(i-1,j,k)) * (py(i-1,j+1,k) - py(i-1,j,k))) ); - } - } - } + pxy(i,j,k) = ( (vx(i,j,k) < 0) ? + px(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i, j+1,k) + vy(i ,j,k)) * (py(i ,j+1,k) - py(i ,j,k))) : + px(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i-1,j+1,k) + vy(i-1,j,k)) * (py(i-1,j+1,k) - py(i-1,j,k))) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_xz(Box const& bx, +void flux_xz(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -115,23 +79,14 @@ void flux_xz(Box const& bx, Array4 const& pxz, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pxz(i,j,k) = ( (vx(i,j,k) < 0) ? - px(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i ,j,k)) * (pz(i ,j,k+1) - pz(i ,j,k))) : - px(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i-1,j,k+1) + vz(i-1,j,k)) * (pz(i-1,j,k+1) - pz(i-1,j,k))) ); - } - } - } + pxz(i,j,k) = ( (vx(i,j,k) < 0) ? + px(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i ,j,k)) * (pz(i ,j,k+1) - pz(i ,j,k))) : + px(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i-1,j,k+1) + vz(i-1,j,k)) * (pz(i-1,j,k+1) - pz(i-1,j,k))) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_yx(Box const& bx, +void flux_yx(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -141,23 +96,14 @@ void flux_yx(Box const& bx, Array4 const& pyx, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pyx(i,j,k) = ( (vy(i,j,k) < 0) ? - py(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j ,k) + vx(i,j ,k)) * (px(i+1,j ,k) - px(i,j ,k))) : - py(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j-1,k) + vx(i,j-1,k)) * (px(i+1,j-1,k) - px(i,j-1,k))) ); - } - } - } -}; + pyx(i,j,k) = ( (vy(i,j,k) < 0) ? + py(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j ,k) + vx(i,j ,k)) * (px(i+1,j ,k) - px(i,j ,k))) : + py(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j-1,k) + vx(i,j-1,k)) * (px(i+1,j-1,k) - px(i,j-1,k))) ); +} AMREX_GPU_DEVICE AMREX_INLINE -void flux_yz(Box const& bx, +void flux_yz(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -167,23 +113,14 @@ void flux_yz(Box const& bx, Array4 const& pyz, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pyz(i,j,k) = ( (vy(i,j,k) < 0) ? - py(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i,j ,k)) * (pz(i,j ,k+1) - pz(i,j ,k))) : - py(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i,j-1,k+1) + vz(i,j-1,k)) * (pz(i,j-1,k+1) - pz(i,j-1,k))) ); - } - } - } + pyz(i,j,k) = ( (vy(i,j,k) < 0) ? + py(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i,j ,k)) * (pz(i,j ,k+1) - pz(i,j ,k))) : + py(i,j,k) - dtdx[2]/3.0 * ( 0.5*(vz(i,j-1,k+1) + vz(i,j-1,k)) * (pz(i,j-1,k+1) - pz(i,j-1,k))) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_zx(Box const& bx, +void flux_zx(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -193,23 +130,14 @@ void flux_zx(Box const& bx, Array4 const& pzx, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pzx(i,j,k) = ( (vz(i,j,k) < 0) ? - pz(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j,k ) + vx(i,j,k )) * (px(i+1,j,k ) - px(i,j,k ))) : - pz(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j,k-1) + vx(i,j,k-1)) * (px(i+1,j,k-1) - px(i,j,k-1))) ); - } - } - } + pzx(i,j,k) = ( (vz(i,j,k) < 0) ? + pz(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j,k ) + vx(i,j,k )) * (px(i+1,j,k ) - px(i,j,k ))) : + pz(i,j,k) - dtdx[0]/3.0 * ( 0.5*(vx(i+1,j,k-1) + vx(i,j,k-1)) * (px(i+1,j,k-1) - px(i,j,k-1))) ); } AMREX_GPU_DEVICE AMREX_INLINE -void flux_zy(Box const& bx, +void flux_zy(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -219,26 +147,14 @@ void flux_zy(Box const& bx, Array4 const& pzy, const GpuArray& dtdx) { - - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - - pzy(i,j,k) = ( (vz(i,j,k) < 0) ? - pz(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i,j+1,k ) + vy(i,j,k )) * (py(i,j+1,k ) - py(i,j,k ))) : - pz(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i,j+1,k-1) + vy(i,j,k-1)) * (py(i,j+1,k-1) - py(i,j,k-1))) ); - - } - } - } + pzy(i,j,k) = ( (vz(i,j,k) < 0) ? + pz(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i,j+1,k ) + vy(i,j,k )) * (py(i,j+1,k ) - py(i,j,k ))) : + pz(i,j,k) - dtdx[1]/3.0 * ( 0.5*(vy(i,j+1,k-1) + vy(i,j,k-1)) * (py(i,j+1,k-1) - py(i,j,k-1))) ); } AMREX_GPU_DEVICE AMREX_INLINE -void combine_flux_x(Box const& bx, +void combine_flux_x(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -248,29 +164,18 @@ void combine_flux_x(Box const& bx, Array4 const& fx, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + px(i,j,k) = ( (vx(i,j,k) < 0) ? + px(i,j,k) - 0.5*dtdx[1] * ( 0.5*(vy(i ,j+1,k ) + vy(i ,j,k)) * (pyz(i ,j+1,k )-pyz(i ,j,k))) + - 0.5*dtdx[2] * ( 0.5*(vz(i ,j ,k+1) + vz(i ,j,k)) * (pzy(i ,j ,k+1)-pzy(i ,j,k))) : + px(i,j,k) - 0.5*dtdx[1] * ( 0.5*(vy(i-1,j+1,k ) + vy(i-1,j,k)) * (pyz(i-1,j+1,k )-pyz(i-1,j,k))) + - 0.5*dtdx[2] * ( 0.5*(vz(i-1,j ,k+1) + vz(i-1,j,k)) * (pzy(i-1,j ,k+1)-pzy(i-1,j,k))) ); - px(i,j,k) = ( (vx(i,j,k) < 0) ? - px(i,j,k) - 0.5*dtdx[1] * ( 0.5*(vy(i ,j+1,k ) + vy(i ,j,k)) * (pyz(i ,j+1,k )-pyz(i ,j,k))) - - 0.5*dtdx[2] * ( 0.5*(vz(i ,j ,k+1) + vz(i ,j,k)) * (pzy(i ,j ,k+1)-pzy(i ,j,k))) : - px(i,j,k) - 0.5*dtdx[1] * ( 0.5*(vy(i-1,j+1,k ) + vy(i-1,j,k)) * (pyz(i-1,j+1,k )-pyz(i-1,j,k))) - - 0.5*dtdx[2] * ( 0.5*(vz(i-1,j ,k+1) + vz(i-1,j,k)) * (pzy(i-1,j ,k+1)-pzy(i-1,j,k))) ); - - fx(i,j,k) = vx(i,j,k)*px(i,j,k); - - } - } - } + fx(i,j,k) = vx(i,j,k)*px(i,j,k); } AMREX_GPU_DEVICE AMREX_INLINE -void combine_flux_y(Box const& bx, +void combine_flux_y(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -280,27 +185,18 @@ void combine_flux_y(Box const& bx, Array4 const& fy, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); + py(i,j,k) = ( (vy(i,j,k) < 0) ? + py(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k ) + vx(i,j ,k)) * (pxz(i+1,j ,k )-pxz(i,j ,k))) + - 0.5*dtdx[2] * ( 0.5*(vz(i, j ,k+1) + vz(i,j ,k)) * (pzx(i, j ,k+1)-pzx(i,j ,k))) : + py(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j-1,k ) + vx(i,j-1,k)) * (pxz(i+1,j-1,k )-pxz(i,j-1,k))) + - 0.5*dtdx[2] * ( 0.5*(vz(i ,j-1,k+1) + vz(i,j-1,k)) * (pzx(i ,j-1,k+1)-pzx(i,j-1,k))) ); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - py(i,j,k) = ( (vy(i,j,k) < 0) ? - py(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k ) + vx(i,j ,k)) * (pxz(i+1,j ,k )-pxz(i,j ,k))) - - 0.5*dtdx[2] * ( 0.5*(vz(i, j ,k+1) + vz(i,j ,k)) * (pzx(i, j ,k+1)-pzx(i,j ,k))) : - py(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j-1,k ) + vx(i,j-1,k)) * (pxz(i+1,j-1,k )-pxz(i,j-1,k))) - - 0.5*dtdx[2] * ( 0.5*(vz(i ,j-1,k+1) + vz(i,j-1,k)) * (pzx(i ,j-1,k+1)-pzx(i,j-1,k))) ); - - fy(i,j,k) = vy(i,j,k)*py(i,j,k); - } - } - } + fy(i,j,k) = vy(i,j,k)*py(i,j,k); } AMREX_GPU_DEVICE AMREX_INLINE -void combine_flux_z(Box const& bx, +void combine_flux_z(int i, int j, int k, AMREX_D_DECL(Array4 const& vx, Array4 const& vy, Array4 const& vz), @@ -310,22 +206,13 @@ void combine_flux_z(Box const& bx, Array4 const& fz, const GpuArray& dtdx) { - const auto lo = lbound(bx); - const auto hi = ubound(bx); - - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { - pz(i,j,k) = ( (vz(i,j,k) < 0) ? - pz(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k ) + vx(i,j,k )) * (pxy(i+1,j ,k )-pxy(i,j,k ))) - - 0.5*dtdx[1] * ( 0.5*(vy(i, j+1,k ) + vy(i,j,k )) * (pyx(i, j+1,k )-pyx(i,j,k ))) : - pz(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k-1) + vx(i,j,k-1)) * (pxy(i+1,j ,k-1)-pxy(i,j,k-1))) - - 0.5*dtdx[1] * ( 0.5*(vy(i ,j+1,k-1) + vy(i,j,k-1)) * (pyx(i ,j+1,k-1)-pyx(i,j,k-1))) ); + pz(i,j,k) = ( (vz(i,j,k) < 0) ? + pz(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k ) + vx(i,j,k )) * (pxy(i+1,j ,k )-pxy(i,j,k ))) + - 0.5*dtdx[1] * ( 0.5*(vy(i, j+1,k ) + vy(i,j,k )) * (pyx(i, j+1,k )-pyx(i,j,k ))) : + pz(i,j,k) - 0.5*dtdx[0] * ( 0.5*(vx(i+1,j ,k-1) + vx(i,j,k-1)) * (pxy(i+1,j ,k-1)-pxy(i,j,k-1))) + - 0.5*dtdx[1] * ( 0.5*(vy(i ,j+1,k-1) + vy(i,j,k-1)) * (pyx(i ,j+1,k-1)-pyx(i,j,k-1))) ); - fz(i,j,k) = vz(i,j,k)*pz(i,j,k); - } - } - } + fz(i,j,k) = vz(i,j,k)*pz(i,j,k); } #endif diff --git a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/slope_3d.H b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/slope_3d.H index 575b7ef242b..1c2f3ea953e 100644 --- a/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/slope_3d.H +++ b/Tutorials/GPU/Advection_AmrCore/Source/Src_3d/slope_3d.H @@ -18,9 +18,9 @@ void slopex2(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i-1,j,k); Real drgt = q(i+1,j,k) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); @@ -44,9 +44,9 @@ void slopex4(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i-1,j,k); Real drgt = q(i+1,j,k) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); @@ -72,9 +72,9 @@ void slopey2(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i,j-1,k); Real drgt = q(i,j+1,k) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); @@ -98,9 +98,9 @@ void slopey4(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i,j-1,k); Real drgt = q(i,j+1,k) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); @@ -126,9 +126,9 @@ void slopez2(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i,j,k-1); Real drgt = q(i,j,k+1) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); @@ -152,9 +152,9 @@ void slopez4(Box const& bx, const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); - for (int k = lo.z; k < hi.z; ++k) { - for (int j = lo.y; j < hi.y; ++j) { - for (int i = lo.x; i < hi.x; ++i) { + for (int k = lo.z; k <= hi.z; ++k) { + for (int j = lo.y; j <= hi.y; ++j) { + for (int i = lo.x; i <= hi.x; ++i) { Real dlft = q(i,j,k) - q(i,j,k-1); Real drgt = q(i,j,k+1) - q(i,j,k); Real dcen = 0.5*(dlft+drgt); diff --git a/Tutorials/GPU/CNS/Source/CNS.cpp b/Tutorials/GPU/CNS/Source/CNS.cpp index d2cb3e56f00..c06320a2d37 100644 --- a/Tutorials/GPU/CNS/Source/CNS.cpp +++ b/Tutorials/GPU/CNS/Source/CNS.cpp @@ -90,7 +90,7 @@ CNS::initData () auto sfab = S_new.array(mfi); amrex::ParallelFor(box, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_initdata(i, j, k, sfab, geomdata); }); @@ -314,7 +314,7 @@ CNS::errorEst (TagBoxArray& tags, int, int, Real time, int, int) auto tag = tags.array(mfi); amrex::ParallelFor(bx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_tag_denerror(i, j, k, tag, rhofab, dengrad_threshold, tagval); }); @@ -395,7 +395,7 @@ CNS::estTimeStep () const MultiFab& S = get_new_data(State_Type); Real estdt = amrex::ReduceMin(S, 0, - [=] AMREX_GPU_HOST_DEVICE (Box const& bx, FArrayBox const& fab) -> Real + [=] AMREX_GPU_HOST_DEVICE (Box const& bx, FArrayBox const& fab) noexcept -> Real { return cns_estdt(bx, fab, dx); }); @@ -427,7 +427,7 @@ CNS::computeTemp (MultiFab& State, int ng) auto const& sfab = State.array(mfi); amrex::ParallelFor(bx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_compute_temperature(i,j,k,sfab); }); diff --git a/Tutorials/GPU/CNS/Source/CNS_K.H b/Tutorials/GPU/CNS/Source/CNS_K.H index fbe15ffe182..2b8414cb6a0 100644 --- a/Tutorials/GPU/CNS/Source/CNS_K.H +++ b/Tutorials/GPU/CNS/Source/CNS_K.H @@ -13,7 +13,7 @@ AMREX_GPU_HOST_DEVICE inline amrex::Real cns_estdt (amrex::Box const& bx, amrex::FArrayBox const& statefab, - amrex::GpuArray const& dx) + amrex::GpuArray const& dx) noexcept { const auto lo = amrex::lbound(bx); const auto hi = amrex::ubound(bx); @@ -53,7 +53,7 @@ cns_estdt (amrex::Box const& bx, amrex::FArrayBox const& statefab, AMREX_GPU_DEVICE inline void -cns_compute_temperature (int i, int j, int k, amrex::Array4 const& u) +cns_compute_temperature (int i, int j, int k, amrex::Array4 const& u) noexcept { amrex::Real rhoinv = 1.0/u(i,j,k,URHO); amrex::Real mx = u(i,j,k,UMX); diff --git a/Tutorials/GPU/CNS/Source/CNS_advance.cpp b/Tutorials/GPU/CNS/Source/CNS_advance.cpp index 0f2ab50b1f6..9baea322b8d 100644 --- a/Tutorials/GPU/CNS/Source/CNS_advance.cpp +++ b/Tutorials/GPU/CNS/Source/CNS_advance.cpp @@ -91,7 +91,7 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, auto const& qfab = q.array(); amrex::ParallelFor(bxg2, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_ctoprim(i, j, k, sfab, qfab); }); @@ -104,13 +104,13 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, int cdir = 0; const Box& xslpbx = amrex::grow(bx, cdir, 1); amrex::ParallelFor(xslpbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_slope_x(i, j, k, slopefab, qfab); }); const Box& xflxbx = amrex::surroundingNodes(bx,cdir); amrex::ParallelFor(xflxbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_riemann_x(i, j, k, fxfab, slopefab, qfab); for (int n = neqns; n < ncons; ++n) fxfab(i,j,k,n) = 0.0; @@ -120,13 +120,13 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, cdir = 1; const Box& yslpbx = amrex::grow(bx, cdir, 1); amrex::ParallelFor(yslpbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_slope_y(i, j, k, slopefab, qfab); }); const Box& yflxbx = amrex::surroundingNodes(bx,cdir); amrex::ParallelFor(yflxbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_riemann_y(i, j, k, fyfab, slopefab, qfab); for (int n = neqns; n < ncons; ++n) fyfab(i,j,k,n) = 0.0; @@ -136,13 +136,13 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, cdir = 2; const Box& zslpbx = amrex::grow(bx, cdir, 1); amrex::ParallelFor(zslpbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_slope_z(i, j, k, slopefab, qfab); }); const Box& zflxbx = amrex::surroundingNodes(bx,cdir); amrex::ParallelFor(zflxbx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { cns_riemann_z(i, j, k, fzfab, slopefab, qfab); for (int n = neqns; n < ncons; ++n) fzfab(i,j,k,n) = 0.0; @@ -153,7 +153,7 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, slope.clear(); amrex::ParallelFor(bx, ncons, - [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) + [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept { cns_flux_to_dudt(i, j, k, n, dsdtfab, AMREX_D_DECL(fxfab,fyfab,fzfab), dxinv); }); @@ -164,7 +164,7 @@ CNS::compute_dSdt (const MultiFab& S, MultiFab& dSdt, Real dt, const int imz = Zmom; const int irhoE = Eden; amrex::ParallelFor(bx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { dsdtfab(i,j,k,imz) += g * sfab(i,j,k,irho); dsdtfab(i,j,k,irhoE) += g * sfab(i,j,k,imz); diff --git a/Tutorials/GPU/CNS/Source/CNS_derive.cpp b/Tutorials/GPU/CNS/Source/CNS_derive.cpp index 23fc22ff7f0..d4a2ba7b06e 100644 --- a/Tutorials/GPU/CNS/Source/CNS_derive.cpp +++ b/Tutorials/GPU/CNS/Source/CNS_derive.cpp @@ -10,7 +10,7 @@ void cns_derpres (const Box& bx, FArrayBox& pfab, int dcomp, int /*ncomp*/, auto const rhoe = rhoefab.array(); auto p = pfab.array(); amrex::ParallelFor(bx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { p(i,j,k,dcomp) = (Parm::eos_gamma-1.)*rhoe(i,j,k); }); @@ -23,7 +23,7 @@ void cns_dervel (const Box& bx, FArrayBox& velfab, int dcomp, int /*ncomp*/, auto const dat = datfab.array(); auto vel = velfab.array(); amrex::ParallelFor(bx, - [=] AMREX_GPU_DEVICE (int i, int j, int k) + [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { vel(i,j,k,dcomp) = vel(i,j,k,1)/vel(i,j,k,0); }); diff --git a/Tutorials/GPU/CNS/Source/CNS_tagging.H b/Tutorials/GPU/CNS/Source/CNS_tagging.H index 0befdb961c3..99373e987b7 100644 --- a/Tutorials/GPU/CNS/Source/CNS_tagging.H +++ b/Tutorials/GPU/CNS/Source/CNS_tagging.H @@ -11,7 +11,7 @@ void cns_tag_denerror (int i, int j, int k, amrex::Array4 const& tag, amrex::Array4 const& rho, - amrex::Real dengrad_threshold, char tagval) + amrex::Real dengrad_threshold, char tagval) noexcept { amrex::Real ax = std::abs(rho(i+1,j,k) - rho(i,j,k)); amrex::Real ay = std::abs(rho(i,j+1,k) - rho(i,j,k)); diff --git a/Tutorials/GPU/CNS/Source/hydro/CNS_hydro_K.H b/Tutorials/GPU/CNS/Source/hydro/CNS_hydro_K.H index eb7c9e0f1bb..117df5f0a02 100644 --- a/Tutorials/GPU/CNS/Source/hydro/CNS_hydro_K.H +++ b/Tutorials/GPU/CNS/Source/hydro/CNS_hydro_K.H @@ -11,7 +11,7 @@ inline void cns_ctoprim (int i, int j, int k, amrex::Array4 const& u, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real rho = amrex::max(u(i,j,k,URHO),Parm::smallr); amrex::Real rhoinv = 1.0/rho; @@ -42,7 +42,7 @@ cns_flux_to_dudt (int i, int j, int k, int n, amrex::Array4 const& fx, amrex::Array4 const& fy, amrex::Array4 const& fz, - amrex::GpuArray const& dxinv) + amrex::GpuArray const& dxinv) noexcept { dudt(i,j,k,n) = dxinv[0] * (fx(i,j,k,n) - fx(i+1,j,k,n)) + dxinv[1] * (fy(i,j,k,n) - fy(i,j+1,k,n)) @@ -52,7 +52,7 @@ cns_flux_to_dudt (int i, int j, int k, int n, namespace { AMREX_GPU_DEVICE AMREX_FORCE_INLINE -amrex::Real limiter (amrex::Real dlft, amrex::Real drgt) +amrex::Real limiter (amrex::Real dlft, amrex::Real drgt) noexcept { amrex::Real dcen = 0.5*(dlft+drgt); amrex::Real dsgn = std::copysign(1.0, dcen); @@ -68,7 +68,7 @@ inline void cns_slope_x (int i, int j, int k, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real dlft = 0.5*(q(i,j,k,QPRES)-q(i-1,j,k,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i,j,k,QU) - q(i-1,j,k,QU)); amrex::Real drgt = 0.5*(q(i+1,j,k,QPRES)-q(i,j,k,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i+1,j,k,QU) - q(i,j,k,QU)); @@ -103,7 +103,7 @@ inline void cns_slope_y (int i, int j, int k, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real dlft = 0.5*(q(i,j,k,QPRES)-q(i,j-1,k,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i,j,k,QV) - q(i,j-1,k,QV)); amrex::Real drgt = 0.5*(q(i,j+1,k,QPRES)-q(i,j,k,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i,j+1,k,QV) - q(i,j,k,QV)); @@ -138,7 +138,7 @@ inline void cns_slope_z (int i, int j, int k, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real dlft = 0.5*(q(i,j,k,QPRES)-q(i,j,k-1,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i,j,k,QW) - q(i,j,k-1,QW)); amrex::Real drgt = 0.5*(q(i,j,k+1,QPRES)-q(i,j,k,QPRES))/q(i,j,k,QCS) - 0.5*q(i,j,k,QRHO)*(q(i,j,k+1,QW) - q(i,j,k,QW)); @@ -178,7 +178,8 @@ riemann (const amrex::Real gamma, const amrex::Real smallp, const amrex::Real sm const amrex::Real ut1l, const amrex::Real ut2l, const amrex::Real rr, const amrex::Real ur, const amrex::Real pr, const amrex::Real ut1r, const amrex::Real ut2r, - amrex::Real& flxrho, amrex::Real& flxu, amrex::Real& flxut, amrex::Real& flxutt, amrex::Real& flxe) + amrex::Real& flxrho, amrex::Real& flxu, amrex::Real& flxut, + amrex::Real& flxutt, amrex::Real& flxe) noexcept { constexpr amrex::Real weakwv = 1.e-3; constexpr amrex::Real small = 1.e-6; @@ -306,7 +307,7 @@ void cns_riemann_x (int i, int j, int k, amrex::Array4 const& fx, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real cspeed = q(i-1,j,k,QCS); amrex::Real rl = q(i-1,j,k,QRHO) + 0.5 * ( (dq(i-1,j,k,0)+dq(i-1,j,k,2))/cspeed + dq(i-1,j,k,1)); @@ -337,7 +338,7 @@ void cns_riemann_y (int i, int j, int k, amrex::Array4 const& fy, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real cspeed = q(i,j-1,k,QCS); amrex::Real rl = q(i,j-1,k,QRHO) + 0.5 * ( (dq(i,j-1,k,0)+dq(i,j-1,k,2))/cspeed + dq(i,j-1,k,1)); @@ -368,7 +369,7 @@ void cns_riemann_z (int i, int j, int k, amrex::Array4 const& fz, amrex::Array4 const& dq, - amrex::Array4 const& q) + amrex::Array4 const& q) noexcept { amrex::Real cspeed = q(i,j,k-1,QCS); amrex::Real rl = q(i,j,k-1,QRHO) + 0.5 * ( (dq(i,j,k-1,0)+dq(i,j,k-1,2))/cspeed + dq(i,j,k-1,1)); diff --git a/paper/Makefile b/paper/Makefile new file mode 100644 index 00000000000..7028ac8d1bd --- /dev/null +++ b/paper/Makefile @@ -0,0 +1,43 @@ +all: + wget -N https://raw.githubusercontent.com/openjournals/whedon/master/resources/joss-logo.png + wget -N https://raw.githubusercontent.com/openjournals/whedon/master/resources/latex.template + pandoc \ + -V repository="https://github.com/amrex-codes/amrex" \ + -V archive_doi="http://dx.doi.org/10.5281/zenodo.2555438" \ + -V paper_url="http://joss.theoj.org/papers/10.xxxxx/joss.xxxxx" \ + -V formatted_doi="10.xxxxx/joss.xxxxx" \ + -V review_issue_url="https://github.com/openjournals/joss-reviews/issues/588" \ + -V graphics="true" \ + -V journal_name="Journal of Open Source Software" \ + -V issue="34" \ + -V volume="4" \ + -V page="1265" \ + -V logo_path="joss-logo.png" \ + -V year="2018" \ + -V submitted="15 February 2019" \ + -V published="22 March 2019" \ + -V citation_author="Zhang et al." \ + -V paper_title="AMReX: a framework for block-structured adaptive mesh refinement (AMR)" \ + paper.md --template latex.template --filter pandoc-citeproc --bibliography paper.bib -o paper.pdf -V geometry:margin=1in + +tex: + wget -N https://raw.githubusercontent.com/openjournals/whedon/master/resources/joss-logo.png + wget -N https://raw.githubusercontent.com/openjournals/whedon/master/resources/latex.template + pandoc \ + -V repository="https://github.com/amrex-codes/amrex" \ + -V archive_doi="http://dx.doi.org/10.5281/zenodo.2555438" \ + -V paper_url="http://joss.theoj.org/papers/10.xxxxx/joss.xxxxx" \ + -V formatted_doi="10.xxxxx/joss.xxxxx" \ + -V review_issue_url="https://github.com/openjournals/joss-reviews/issues/588" \ + -V graphics="true" \ + -V journal_name="Journal of Open Source Software" \ + -V issue="34" \ + -V volume="4" \ + -V page="1265" \ + -V logo_path="joss-logo.png" \ + -V year="2018" \ + -V submitted="xx March 2019" \ + -V published="xx April 2019" \ + -V citation_author="Zhang et al." \ + -V paper_title="AMReX: a framework for block-structured adaptive mesh refinement (AMR)" \ + paper.md --template latex.template --filter pandoc-citeproc --bibliography paper.bib -o paper.tex -V geometry:margin=1in diff --git a/paper/paper.bib b/paper/paper.bib new file mode 100644 index 00000000000..e19bc79a7b1 --- /dev/null +++ b/paper/paper.bib @@ -0,0 +1,34 @@ +@article{Zingale_2018, + doi = {10.1088/1742-6596/1031/1/012024}, + url = {https://doi.org/10.1088%2F1742-6596%2F1031%2F1%2F012024}, + year = 2018, + month = {may}, + publisher = {{IOP} Publishing}, + volume = {1031}, + pages = {012024}, + author = {M. Zingale and A. S. Almgren and M. G. Barrios Sazo and V. E. Beckner and J. B. Bell and B. Friesen and A. M. Jacobs and M. P. Katz and C. M. Malone and A. J. Nonaka and D. E. Willcox and W. Zhang}, + title = {Meeting the Challenges of Modeling Astrophysical Thermonuclear Explosions: Castro, Maestro, and the {AMReX} Astrophysics Suite}, + journal = {Journal of Physics: Conference Series}, + + abstract = {We describe the AMReX suite of astrophysics codes and their application to modeling problems in stellar astrophysics. Maestro is tuned to efficiently model subsonic convective flows while Castro models the highly compressible flows associated with stellar explosions. Both are built on the block-structured adaptive mesh refinement library AMReX. Together, these codes enable a thorough investigation of stellar phenomena, including Type Ia supernovae and X-ray bursts. We describe these science applications and the approach we are taking to make these codes performant on current and future many-core and GPU-based architectures.} + +} + +@ARTICLE{BoxLib, + author = {Weiqun Zhang and + Ann S. Almgren and + Marcus Day and + Tan Nguyen and + John Shalf and + Didem Unat}, + title = {BoxLib with Tiling: An {AMR} Software Framework}, + journal = {SIAM J. Sci. Comput}, + volume = {38}, + number = {5}, + pagers = {S156-S172}, + year = {2016}, + doi = {10.1137/15M102616X}, + url = {http://arxiv.org/abs/1604.03570}, + archivePrefix = {arXiv} +} + diff --git a/paper/paper.md b/paper/paper.md new file mode 100644 index 00000000000..57e454ee48a --- /dev/null +++ b/paper/paper.md @@ -0,0 +1,200 @@ +--- +title: 'AMReX: a framework for block-structured adaptive mesh refinement' + +tags: +- C++ +- adaptive mesh refinement +- block-structured +- finite volume +- partial differential equations + +authors: +- name: Weiqun Zhang + orcid: 0000-0001-8092-1974 + affiliation: 1 +- name: Ann Almgren + orcid: 0000-0003-2103-312X + affiliation: 1 +- name: Vince Beckner + affiliation: 1 +- name: John Bell + orcid: 0000-0002-5749-334X + affiliation: 1 +- name: Johannes Blaschke + orcid: 0000-0002-6024-3990 + affiliation: 1 +- name: Cy Chan + orcid: 0000-0001-6881-827X + affiliation: 2 +- name: Marcus Day + orcid: 0000-0002-1711-3963 + affiliation: 1 +- name: Brian Friesen + orcid: 0000-0002-1572-1631 + affiliation: 3 +- name: Kevin Gott + orcid: 0000-0003-3244-5525 + affiliation: 3 +- name: Daniel Graves + orcid: 0000-0001-9730-7217 + affiliation: 2 +- name: Max P. Katz + orcid: 0000-0003-0439-4556 + affiliation: 4 +- name: Andrew Myers + orcid: 0000-0001-8427-8330 + affiliation: 1 +- name: Tan Nguyen + orcid: 0000-0003-3748-403X + affiliation: 2 +- name: Andrew Nonaka + orcid: 0000-0003-1791-0265 + affiliation: 1 +- name: Michele Rosso + orcid: 0000-0001-8126-7425 + affiliation: 1 +- name: Samuel Williams + orcid: 0000-0002-8327-5717 + affiliation: 2 +- name: Michael Zingale + orcid: 0000-0001-8401-030X + affiliation: 5 + +affiliations: +- name: Center for Computational Sciences and Engineering (CCSE), Lawrence Berkeley National Laboratory + index: 1 +- name: Computational Research Division, Lawrence Berkeley National Laboratory + index: 2 +- name: National Energy Research Scientific Computing Center (NERSC) + index: 3 +- name: NVIDIA Corporation + index: 4 +- name: Department of Physics and Astronomy, Stony Brook University + index: 5 + +date: 22 March 2019 + +bibliography: paper.bib +--- + +# Summary + +AMReX is a C++ software framework that supports the development of +block-structured adaptive mesh refinement (AMR) algorithms for solving +systems of partial differential equations (PDEs) with complex boundary +conditions on current and emerging architectures. + +Block-structured AMR provides the basis for the temporal and spatial +discretization strategy for a large number of applications. +AMR reduces the computational cost +and memory footprint compared to a uniform mesh while preserving the +local descriptions of different physical processes in complex multiphysics algorithms. +Current AMReX-based application codes span a number of areas; in particular +the AMReX-Astro GitHub repository holds a number of astrophysical modeling tools based on AMReX [@Zingale_2018]. +The origins of AMReX trace back to the BoxLib [@BoxLib] software framework. + +AMReX supports a number of different time-stepping strategies +and spatial discretizations. Solution strategies supported by AMReX range +from level-by-level approaches (with or without subcycling in time) with +multilevel synchronization to full-hierarchy approaches, and any combination thereof. +User-defined kernels that operate +on patches of data can be written in C++ or Fortran; there is also a Fortran-interface functionality +which wraps the core C++ data structures and operations in Fortran wrappers so that an application +code based on AMReX can be written entirely in Fortran. + +AMReX developers believe that interoperability is an important feature of sustainable software. +AMReX has examples of interfaces to other popular software packages such as SUNDIALS, +PETSc and hypre, and is part of the 2018 xSDK software release thus installable with Spack. + +### Mesh and Particle Data + +AMReX supplies data containers and iterators for mesh-based fields and particle data. +The mesh-based data can be defined on cell centers, cell faces or cell corners (nodes). +Coordinate systems include 1D Cartesian or spherical; 2D Cartesian or cylindrical (r-z); and 3D Cartesian. + +AMReX provides data structures and iterators for performing data-parallel particle simulations. +The approach is particularly suited to particles that interact with data defined on a (possibly adaptive) +block-structured hierarchy of meshes. Example applications include those that use Particle-in-Cell (PIC) methods, +Lagrangian tracers, or solid particles that exchange momentum with the surrounding fluid through drag forces. +AMReX’s particle implementation allows users flexibility in specifying how the particle data +is laid out in memory and in choosing how to optimize parallel communication of particle data. + +### Complex Geometries + +AMReX provides support for discretizing complex geometries using the cut cell / embedded boundary +approach. This requires additional data structures for holding face apertures and normals as well +as volume fractions. Support for operations on the mesh hierarchy including cut cells is enabled +through the use of specialized discretizations at and near cut cells, and masks to ensure that only +values in the valid domain are computed. Examples are provided in the tutorials. + +### Parallelism + +AMReX’s GPU strategy focuses on providing performant GPU support with +minimal changes to AMReX-based application codes and maximum flexibility. +This allows application teams to get running on GPUs quickly while allowing +long term performance tuning and programming model selection. +AMReX currently uses CUDA for GPUs, but application teams can use CUDA, CUDA Fortran, +OpenACC or OpenMP in their individual codes. AMReX will support non-CUDA strategies +as appropriate. + +When running on CPUs, AMReX uses an MPI+X strategy where the X threads are used to perform +parallelization techniques like tiling. The most common X is OpenMP. On GPUs, AMReX requires CUDA +and can be further combined with other parallel GPU languages, including OpenACC and OpenMP, +to control the offloading of subroutines to the GPU. This MPI+CUDA+X GPU strategy has been developed +to give users the maximum flexibility to find the best combination of portability, +readability and performance for their applications. + +### Asynchronous Iterators and Fork-Join Support + +AMReX includes a runtime system that can execute asynchronous AMReX-based applications efficiently +on large-scale systems. The runtime system constructs a task dependency graph for the +whole coarse time step and executes it asynchronously to the completion of the step. There +is also support for more user-specific algorithms such as asynchronous filling of ghost cells +across multiple ranks, including interpolation of data in space and time. + +In addition, AMReX has support for fork-join functionality. During a run of an AMReX-based application, +the user can divide the MPI ranks into subgroups (i.e. fork) and assign each subgroup an independent task +to compute in parallel with each other. +After all of the forked child tasks complete, they synchronize (i.e. join), and the parent task continues execution as before. +The fork-join operation can also be invoked in a nested fashion, creating a hierarchy of fork-join operations, +where each fork further subdivides the ranks of a task into child tasks. +This approach enables heterogeneous computation and reduces the strong scaling penalty for +operations with less inherent parallelism or with large communication overheads. + +### Linear Solvers + +AMReX includes native linear solvers for parabolic and elliptic equations. Solution procedures +include geometric multigrid and BiCGStab iterative solvers; interfaces to external hypre and +PETSc solvers are also provided. The linear solvers operate on regular mesh data as well +as data with cut cells. + +### I/O and Post-processing + +AMReX has native I/O for checkpointing and for reading and writing plotfiles for post-processing +analysis or visualization. AMReX also supplies interfaces to HDF5. The AMReX plotfile format +is supported by VisIt, Paraview, and yt. AMReX also has linkages to external routines through +both Conduit and SENSEI. + +### Documentation, Tutorials and Profiling Tools + +Extensive documentation of core AMReX functionality is available online, and many of the application +codes based on AMReX are publicly available as well. Smaller examples of using AMReX for building application codes +are provided in the AMReX Tutorials section. +Examples include a Particle-in-Cell (PIC) code, a compressible Navier-Stokes solver in complex geometry, +advection-diffusion solvers, support for spectral deferred corrections time-stepping, and much more. + +AMReX-based application codes can be instrumented using AMReX-specific performance profiling tools that take +into account the hierarchical nature of the mesh in most AMReX-based applications. +These codes can be instrumented for varying levels of profiling detail. + +# Acknowledgements + +The development of AMReX was supported by the +U.S. Department of Energy, Office of Science, +Office of Advanced Scientific Computing Research, +Applied Mathematics program under contract number DE-AC02005CH11231, +and by the +Exascale Computing Project (17-SC-20-SC), a collaborative effort of the +U.S. Department of Energy Office of Science and the National Nuclear Security Administration. + +# References