Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
Browse files Browse the repository at this point in the history
…to fix-AB-alpha-beta-to-documentation
  • Loading branch information
eebasso committed Nov 16, 2023
2 parents e9d8f90 + a9da2a5 commit 041f061
Show file tree
Hide file tree
Showing 47 changed files with 1,589 additions and 950 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
export PATH=/tmp/my-amrex/bin:$PATH
which fcompare
which amrex_fcompare
ctest --output-on-failure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
export PATH=/tmp/my-amrex/bin:$PATH
which fcompare
which amrex_fcompare
ctest --output-on-failure
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,9 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DAMReX_EB=ON \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_FORTRAN=ON \
-DAMReX_FORTRAN=OFF \
-DCMAKE_C_COMPILER=$(which icc) \
-DCMAKE_CXX_COMPILER=$(which icpc) \
-DCMAKE_Fortran_COMPILER=$(which ifort) \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build build --parallel 2
cmake --build build --target install
Expand Down
49 changes: 49 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# 23.11

-- Give FlashFluxRegisters ways to accumulate data in registers (#3597)

-- `AMReXBuildInfo.cmake`: AMReX_DIR (#3609)

-- update doc for amrex::Abort on GPU (#3605)

-- Add runtime particle components to HDF5 wrapper (#3596)

-- Windows: Fix Installed AMReXBuildInfo.cmake (#3606)

-- Print AMReX version at the beginning of Initialize (#3604)

-- Install Move Tools to `shared/amrex` (#3599)

-- Revert "Add ability for GCC 8 in CMake to build fgradient which uses std::filesystem" (#3601)

-- Avoid std::filesystem (#3602)

-- Fix Assertion in MLEBNodeFDLaplacian (#3594)

-- Fix a memory "leak" in VisMF's persistent streams (#3592)

-- RealVect Static: Export (#3589)

-- change MaxCnt from 4 to max(4,max_level+1) for how many iterations we… (#3588)
… allow in creation of the initial grid hierarchy

-- Add Bittree CI (#3577)

-- BCType::ext_dir_cc (#3581)

-- Disable CCache in Windows CIs (#3566)

-- Fix ICC CI by Freeing up Disk Space (#3583)

-- Docs: Link pyAMReX (#3582)

-- NodeABecLaplacian: Reuse (#3579)

-- simplify how 2d surface integrals are computed (#3571)

-- Adding bittree interface to improve regridding performance in octree mode (#3555)

-- MLNodeABecLaplacian (#3559)

-- Fix Boundary Centroid in a Corner Case in 2D (#3568)

# 23.10

-- Bugfix typo in AMReX_SundialsIntegrator.H Nvar vs NVar, the
Expand Down
9 changes: 4 additions & 5 deletions Docs/sphinx_documentation/source/GPU.rst
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,10 @@ GPU support.
When AMReX is compiled with ``USE_OMP_OFFLOAD=TRUE``,
``AMREX_USE_OMP_OFFLOAD`` is defined.

In addition to AMReX's preprocessor macros, CUDA provides the
``__CUDA_ARCH__`` macro which is only defined when in device code.
HIP and Sycl provide similar macros.
``AMREX_DEVICE_COMPILE`` should be used when a ``__host__ __device__``
function requires separate code for the CPU and GPU implementations.
The macros ``AMREX_IF_ON_DEVICE((code_for_device))`` and
``AMREX_IF_ON_HOST((code_for_host))`` should be used when a
``__host__ __device__`` function requires separate code for the
CPU and GPU implementations.

.. ===================================================================
Expand Down
21 changes: 21 additions & 0 deletions Docs/sphinx_documentation/source/InputsComputeBackends.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _Chap:InputsComputeBackends:

Compute Backends
================

The following inputs must be preceded by ``amrex.`` and determine runtime options of CPU or GPU compute implementations.

+------------------------+-----------------------------------------------------------------------+-------------+------------+
| Parameter | Description | Type | Default |
+========================+=======================================================================+=============+============+
| ``omp_threads`` | If OpenMP is enabled, this can be used to set the default number of | String | ``system`` |
| | threads. The special value ``nosmt`` can be used to avoid using | or Int | |
| | threads for virtual cores (aka Hyperthreading or SMT), as is default | | |
| | in OpenMP, and instead only spawns threads equal to the number of | | |
| | physical cores in the system. | | |
| | For the values ``system`` and ``nosmt``, the environment variable | | |
| | ``OMP_NUM_THREADS`` takes precedence. For Integer values, | | |
| | ``OMP_NUM_THREADS`` is ignored. | | |
+------------------------+-----------------------------------------------------------------------+-------------+------------+

For GPU-specific parameters, see also the :ref:`GPU chapter <sec:gpu:parameters>`.
1 change: 1 addition & 0 deletions Docs/sphinx_documentation/source/Inputs_Chapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Run-time Inputs
InputsProblemDefinition
InputsTimeStepping
InputsLoadBalancing
InputsComputeBackends
InputsPlotFiles
InputsCheckpoint

60 changes: 27 additions & 33 deletions Src/Base/AMReX.H
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,15 @@ namespace amrex

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void Error (const char* msg = nullptr) {
#if AMREX_DEVICE_COMPILE
#if defined(NDEBUG)
amrex::ignore_unused(msg);
AMREX_IF_ON_DEVICE((amrex::ignore_unused(msg);))
#else
if (msg) { AMREX_DEVICE_PRINTF("Error %s\n", msg); }
AMREX_DEVICE_ASSERT(0);
#endif
#else
Error_host("Error", msg);
AMREX_IF_ON_DEVICE((
if (msg) { AMREX_DEVICE_PRINTF("Error %s\n", msg); }
AMREX_DEVICE_ASSERT(0);
))
#endif
AMREX_IF_ON_HOST((Error_host("Error", msg);))
}

//! Print out warning message to cerr.
Expand All @@ -132,32 +131,28 @@ namespace amrex

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void Warning (const char * msg) {
#if AMREX_DEVICE_COMPILE
#if defined(NDEBUG)
amrex::ignore_unused(msg);
#else
if (msg) { AMREX_DEVICE_PRINTF("Warning %s\n", msg); }
#endif
AMREX_IF_ON_DEVICE((amrex::ignore_unused(msg);))
#else
Warning_host(msg);
AMREX_IF_ON_DEVICE((if (msg) { AMREX_DEVICE_PRINTF("Warning %s\n", msg); }))
#endif
AMREX_IF_ON_HOST((Warning_host(msg);))
}

//! Print out message to cerr and exit via abort().
void Abort (const std::string& msg);

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void Abort (const char * msg = nullptr) {
#if AMREX_DEVICE_COMPILE
#if defined(NDEBUG)
amrex::ignore_unused(msg);
AMREX_IF_ON_DEVICE((amrex::ignore_unused(msg);))
#else
if (msg) { AMREX_DEVICE_PRINTF("Abort %s\n", msg); }
AMREX_DEVICE_ASSERT(0);
#endif
#else
Error_host("Abort", msg);
AMREX_IF_ON_DEVICE((
if (msg) { AMREX_DEVICE_PRINTF("Abort %s\n", msg); }
AMREX_DEVICE_ASSERT(0);
))
#endif
AMREX_IF_ON_HOST((Error_host("Abort", msg);))
}

/**
Expand All @@ -170,22 +165,21 @@ namespace amrex

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void Assert (const char* EX, const char* file, int line, const char* msg = nullptr) {
#if AMREX_DEVICE_COMPILE
#if defined(NDEBUG)
amrex::ignore_unused(EX,file,line,msg);
#else
if (msg) {
AMREX_DEVICE_PRINTF("Assertion `%s' failed, file \"%s\", line %d, Msg: %s",
EX, file, line, msg);
} else {
AMREX_DEVICE_PRINTF("Assertion `%s' failed, file \"%s\", line %d",
EX, file, line);
}
AMREX_DEVICE_ASSERT(0);
#endif
AMREX_IF_ON_DEVICE((amrex::ignore_unused(EX,file,line,msg);))
#else
Assert_host(EX,file,line,msg);
AMREX_IF_ON_DEVICE((
if (msg) {
AMREX_DEVICE_PRINTF("Assertion `%s' failed, file \"%s\", line %d, Msg: %s",
EX, file, line, msg);
} else {
AMREX_DEVICE_PRINTF("Assertion `%s' failed, file \"%s\", line %d",
EX, file, line);
}
AMREX_DEVICE_ASSERT(0);
))
#endif
AMREX_IF_ON_HOST((Assert_host(EX,file,line,msg);))
}

/**
Expand Down
15 changes: 11 additions & 4 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#endif

#ifdef AMREX_USE_OMP
#include <AMReX_OpenMP.H>
#include <omp.h>
#endif

Expand All @@ -72,7 +73,9 @@
#include <iostream>
#include <iomanip>
#include <new>
#include <optional>
#include <stack>
#include <string>
#include <thread>
#include <limits>
#include <vector>
Expand Down Expand Up @@ -459,15 +462,17 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
#endif

#ifdef AMREX_USE_OMP
amrex::OpenMP::init_threads();

// status output
if (system::verbose > 0) {
// static_assert(_OPENMP >= 201107, "OpenMP >= 3.1 is required.");
amrex::Print() << "OMP initialized with "
<< omp_get_max_threads()
<< " OMP threads\n";
}
#endif

#if defined(AMREX_USE_MPI) && defined(AMREX_USE_OMP)
// warn if over-subscription is detected
if (system::verbose > 0) {
auto ncores = int(std::thread::hardware_concurrency());
if (ncores != 0 && // It might be zero according to the C++ standard.
Expand All @@ -476,8 +481,10 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
amrex::Print(amrex::ErrorStream())
<< "AMReX Warning: You might be oversubscribing CPU cores with OMP threads.\n"
<< " There are " << ncores << " cores per node.\n"
<< " There are " << ParallelDescriptor::NProcsPerNode() << " MPI ranks per node.\n"
<< " But OMP is initialized with " << omp_get_max_threads() << " threads per rank.\n"
#if defined(AMREX_USE_MPI)
<< " There are " << ParallelDescriptor::NProcsPerNode() << " MPI ranks (processes) per node.\n"
#endif
<< " But OMP is initialized with " << omp_get_max_threads() << " threads per process.\n"
<< " You should consider setting OMP_NUM_THREADS="
<< ncores/ParallelDescriptor::NProcsPerNode() << " or less in the environment.\n";
}
Expand Down
Loading

0 comments on commit 041f061

Please sign in to comment.