Skip to content

Commit

Permalink
Merge branch 'development' into add_feature_projection_div_cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkse authored Aug 15, 2024
2 parents 232d3a3 + 48b6168 commit e50b870
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
cmake -S . -B build_sp \
-DCMAKE_CXX_FLAGS_RELEASE="-O1 -DNDEBUG" \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DWarpX_EB=ON \
-DWarpX_EB=OFF \
-DWarpX_PYTHON=ON \
-DWarpX_MPI=OFF \
-DWarpX_OPENPMD=ON \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ jobs:
cmake -S . -B build_dp \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DWarpX_EB=ON \
-DWarpX_EB=OFF \
-DWarpX_OPENPMD=ON \
-DWarpX_openpmd_internal=OFF
cmake --build build_dp -j 3
cmake -S . -B build_sp \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DPython_EXECUTABLE=$(which python3) \
-DWarpX_EB=ON \
-DWarpX_EB=OFF \
-DWarpX_PYTHON=ON \
-DWarpX_OPENPMD=ON \
-DWarpX_openpmd_internal=OFF \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_VERBOSE_MAKEFILE=ON ^
-DWarpX_COMPUTE=OMP ^
-DWarpX_EB=ON ^
-DWarpX_EB=OFF ^
-DWarpX_PYTHON=ON ^
-DWarpX_MPI=OFF ^
-DWarpX_OPENPMD=ON
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ The `Advanced Package Tool (APT) <https://en.wikipedia.org/wiki/APT_(software)>`
.. code-block:: bash
sudo apt update
sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-matplotlib python3-mpi4py python3-numpy python3-pandas python3-pip python3-scipy python3-venv
sudo apt install build-essential ccache cmake g++ git libfftw3-mpi-dev libfftw3-dev libhdf5-openmpi-dev libopenmpi-dev pkg-config python3 python3-dev python3-matplotlib python3-mpi4py python3-numpy python3-pandas python3-pip python3-scipy python3-venv
# optional:
# for CUDA, either install
Expand All @@ -244,7 +244,7 @@ The `Advanced Package Tool (APT) <https://en.wikipedia.org/wiki/APT_(software)>`
.. code-block:: bash
sudo apt update
sudo apt install build-essential ccache cmake g++ git libfftw3-dev libfftw3-dev libhdf5-dev pkg-config python3 python3-matplotlib python3-numpy python3-pandas python3-pip python3-scipy python3-venv
sudo apt install build-essential ccache cmake g++ git libfftw3-dev libfftw3-dev libhdf5-dev pkg-config python3 python3-dev python3-matplotlib python3-numpy python3-pandas python3-pip python3-scipy python3-venv
# optional:
# for CUDA, either install
Expand Down
2 changes: 1 addition & 1 deletion Examples/Tests/collision/analysis_collision_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@
dim, species_name)

test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, fn)
checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-1)
2 changes: 1 addition & 1 deletion Examples/Tests/collision/analysis_collision_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@
dim, species_name)

test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, fn)
checksumAPI.evaluate_checksum(test_name, fn, rtol=1e-1)
15 changes: 0 additions & 15 deletions Regression/WarpX-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2436,21 +2436,6 @@ useOMP = 1
numthreads = 1
analysisRoutine = Examples/Tests/pml/analysis_pml_yee.py

[pml_x_yee_eb]
buildDir = .
inputFile = Examples/Tests/pml/inputs_2d
runtime_params = algo.maxwell_solver=yee chk.file_prefix=pml_x_yee_eb_chk chk.file_min_digits=5
dim = 2
addToCompileString = USE_EB=TRUE
cmakeSetupOpts = -DWarpX_DIMS=2 -DWarpX_EB=ON
restartTest = 1
restartFileNum = 150
useMPI = 1
numprocs = 2
useOMP = 1
numthreads = 1
analysisRoutine = Examples/Tests/pml/analysis_pml_yee.py

[projection_divb_cleaner_rz]
buildDir = .
inputFile = Examples/Tests/projection_divb_cleaner/inputs_rz
Expand Down
1 change: 1 addition & 0 deletions Source/EmbeddedBoundary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ foreach(D IN LISTS WarpX_DIMS)
WarpXInitEB.cpp
WarpXFaceExtensions.cpp
WarpXFaceInfoBox.H
Enabled.cpp
)
endforeach()
18 changes: 18 additions & 0 deletions Source/EmbeddedBoundary/Enabled.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright 2024 Axel Huebl
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/
#ifndef WARPX_EB_ENABLED_H_
#define WARPX_EB_ENABLED_H_

#include <AMReX_ParmParse.H>

namespace EB
{
/** Are embedded boundaries enabled? */
bool enabled ();

} // namespace EB
#endif // WARPX_EB_ENABLED_H_
39 changes: 39 additions & 0 deletions Source/EmbeddedBoundary/Enabled.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* Copyright 2024 Axel Huebl
*
* This file is part of WarpX.
*
* License: BSD-3-Clause-LBNL
*/
#include "Enabled.H"

#ifdef AMREX_USE_EB
#include <AMReX_ParmParse.H>
#endif
#if defined(AMREX_USE_EB) && defined(WARPX_DIM_RZ)
#include <stdexcept>
#endif


namespace EB
{
bool enabled ()
{
#ifndef AMREX_USE_EB
return false;
#else
amrex::ParmParse const pp_warpx("warpx");
amrex::ParmParse const pp_eb2("eb2");

// test various runtime options to enable EBs
std::string eb_implicit_function;
bool eb_enabled = pp_warpx.query("eb_implicit_function", eb_implicit_function);

// https://amrex-codes.github.io/amrex/docs_html/EB.html
std::string eb_stl;
eb_enabled |= pp_eb2.query("geom_type", eb_stl);

return eb_enabled;
#endif
}

} // namespace EB
2 changes: 2 additions & 0 deletions Source/EmbeddedBoundary/Make.package
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
CEXE_headers += Enabled.H
CEXE_headers += ParticleScraper.H
CEXE_headers += ParticleBoundaryProcess.H
CEXE_headers += DistanceToEB.H
CEXE_headers += WarpXFaceInfoBox.H

CEXE_sources += Enabled.cpp
CEXE_sources += WarpXInitEB.cpp
CEXE_sources += WarpXFaceExtensions.cpp

Expand Down
2 changes: 2 additions & 0 deletions Source/Make.WarpX
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ ifeq ($(USE_FFT),TRUE)
INCLUDE_LOCATIONS += $(ROC_PATH)/rocfft/include
LIBRARY_LOCATIONS += $(ROC_PATH)/rocfft/lib
libraries += -lrocfft
else ifeq ($(USE_SYCL),TRUE)
# nothing
else # Running on CPU
# Use FFTW
ifeq ($(PRECISION),FLOAT)
Expand Down
8 changes: 8 additions & 0 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "BoundaryConditions/PML.H"
#include "Diagnostics/MultiDiagnostics.H"
#include "Diagnostics/ReducedDiags/MultiReducedDiags.H"
#include "EmbeddedBoundary/Enabled.H"
#include "EmbeddedBoundary/WarpXFaceInfoBox.H"
#include "FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H"
#include "FieldSolver/FiniteDifferenceSolver/MacroscopicProperties/MacroscopicProperties.H"
Expand Down Expand Up @@ -789,6 +790,13 @@ WarpX::ReadParameters ()
potential_specified |= pp_boundary.query("potential_hi_z", m_poisson_boundary_handler.potential_zhi_str);
#if defined(AMREX_USE_EB)
potential_specified |= pp_warpx.query("eb_potential(x,y,z,t)", m_poisson_boundary_handler.potential_eb_str);

if (!EB::enabled()) {
throw std::runtime_error(
"Currently, users MUST use EB if it was compiled in. "
"This will change with https://github.com/ECP-WarpX/WarpX/pull/4865 ."
);
}
#endif
m_boundary_potential_specified = potential_specified;
if (potential_specified & (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC)) {
Expand Down
17 changes: 17 additions & 0 deletions Source/ablastr/math/fft/AnyFFT.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#ifdef ABLASTR_USE_FFT
# include <AMReX_Config.H>
# include <AMReX_GpuComplex.H>
# include <AMReX_LayoutData.H>

# if defined(AMREX_USE_CUDA)
Expand All @@ -20,6 +21,8 @@
# else
# include <rocfft.h>
# endif
# elif defined(AMREX_USE_SYCL)
# include <oneapi/mkl/dfti.hpp>
# else
# include <fftw3.h>
# endif
Expand Down Expand Up @@ -62,6 +65,8 @@ namespace ablastr::math::anyfft
# else
using Complex = double2;
# endif
# elif defined(AMREX_USE_SYCL)
using Complex = amrex::GpuComplex<amrex::Real>;
# else
# ifdef AMREX_USE_FLOAT
using Complex = fftwf_complex;
Expand All @@ -77,6 +82,15 @@ namespace ablastr::math::anyfft
using VendorFFTPlan = cufftHandle;
# elif defined(AMREX_USE_HIP)
using VendorFFTPlan = rocfft_plan;
# elif defined(AMREX_USE_SYCL)
using VendorFFTPlan = oneapi::mkl::dft::descriptor<
# ifdef AMREX_USE_FLOAT
oneapi::mkl::dft::precision::SINGLE,
# else
oneapi::mkl::dft::precision::DOUBLE,
# endif
oneapi::mkl::dft::domain::REAL> *;
// dft::descriptor has no default ctor, so we have to use ptr.
# else
# ifdef AMREX_USE_FLOAT
using VendorFFTPlan = fftwf_plan;
Expand All @@ -99,6 +113,9 @@ namespace ablastr::math::anyfft
VendorFFTPlan m_plan; /**< Vendor FFT plan */
direction m_dir; /**< direction (C2R or R2C) */
int m_dim; /**< Dimensionality of the FFT plan */
#ifdef AMREX_USE_SYCL
amrex::gpuStream_t m_stream;
#endif
};

/** Collection of FFT plans, one FFTplan per box */
Expand Down
2 changes: 2 additions & 0 deletions Source/ablastr/math/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ foreach(D IN LISTS WarpX_DIMS)
target_sources(ablastr_${SD} PRIVATE WrapCuFFT.cpp)
elseif(WarpX_COMPUTE STREQUAL HIP)
target_sources(ablastr_${SD} PRIVATE WrapRocFFT.cpp)
elseif(WarpX_COMPUTE STREQUAL SYCL)
target_sources(ablastr_${SD} PRIVATE WrapMklFFT.cpp)
else()
target_sources(ablastr_${SD} PRIVATE WrapFFTW.cpp)
endif()
Expand Down
2 changes: 2 additions & 0 deletions Source/ablastr/math/fft/Make.package
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ifeq ($(USE_FFT),TRUE)
CEXE_sources += WrapCuFFT.cpp
else ifeq ($(USE_HIP),TRUE)
CEXE_sources += WrapRocFFT.cpp
else ifeq ($(USE_SYCL),TRUE)
CEXE_sources += WrapMklFFT.cpp
else
CEXE_sources += WrapFFTW.cpp
endif
Expand Down
96 changes: 96 additions & 0 deletions Source/ablastr/math/fft/WrapMklFFT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright 2019-2023
*
* This file is part of ABLASTR.
*
* License: BSD-3-Clause-LBNL
*/

#include "AnyFFT.H"

#include "ablastr/utils/TextMsg.H"
#include "ablastr/profiler/ProfilerWrapper.H"

#include <cstdint>

namespace ablastr::math::anyfft
{

void setup () {/*nothing to do*/}

void cleanup () {/*nothing to do*/}

FFTplan CreatePlan (const amrex::IntVect& real_size, amrex::Real * const real_array,
Complex * const complex_array, const direction dir, const int dim)
{
FFTplan fft_plan;
ABLASTR_PROFILE("ablastr::math::anyfft::CreatePlan");

// Initialize fft_plan.m_plan with the vendor fft plan.
std::vector<std::int64_t> strides(dim+1);
if (dim == 3) {
fft_plan.m_plan = new std::remove_pointer_t<VendorFFTPlan>(
{std::int64_t(real_size[2]),
std::int64_t(real_size[1]),
std::int64_t(real_size[0])});
strides[0] = 0;
strides[1] = real_size[0] * real_size[1];
strides[2] = real_size[0];
strides[3] = 1;
} else if (dim == 2) {
fft_plan.m_plan = new std::remove_pointer_t<VendorFFTPlan>(
{std::int64_t(real_size[1]),
std::int64_t(real_size[0])});
strides[0] = 0;
strides[1] = real_size[0];
strides[2] = 1;
} else if (dim == 1) {
strides[0] = 0;
strides[1] = 1;
fft_plan.m_plan = new std::remove_pointer_t<VendorFFTPlan>(
std::int64_t(real_size[0]));
} else {
ABLASTR_ABORT_WITH_MESSAGE("only dim2 =1, dim=2 and dim=3 have been implemented");
}

fft_plan.m_plan->set_value(oneapi::mkl::dft::config_param::PLACEMENT,
DFTI_NOT_INPLACE);
fft_plan.m_plan->set_value(oneapi::mkl::dft::config_param::FWD_STRIDES,
strides.data());
fft_plan.m_plan->commit(amrex::Gpu::Device::streamQueue());

// Store meta-data in fft_plan
fft_plan.m_real_array = real_array;
fft_plan.m_complex_array = complex_array;
fft_plan.m_dir = dir;
fft_plan.m_dim = dim;
fft_plan.m_stream = amrex::Gpu::gpuStream();

return fft_plan;
}

void DestroyPlan (FFTplan& fft_plan)
{
delete fft_plan.m_plan;
}

void Execute (FFTplan& fft_plan)
{
if (!(fft_plan.m_stream == amrex::Gpu::gpuStream())) {
amrex::Gpu::streamSynchronize();
}

sycl::event r;
if (fft_plan.m_dir == direction::R2C) {
r = oneapi::mkl::dft::compute_forward(
*fft_plan.m_plan,
fft_plan.m_real_array,
reinterpret_cast<std::complex<amrex::Real>*>(fft_plan.m_complex_array));
} else {
r = oneapi::mkl::dft::compute_backward(
*fft_plan.m_plan,
reinterpret_cast<std::complex<amrex::Real>*>(fft_plan.m_complex_array),
fft_plan.m_real_array);
}
r.wait();
}
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initialize_options(self):
# clashes with directories many developers have in their source trees;
# this can create confusing results with "pip install .", which clones
# the whole source tree by default
self.build_base = '_tmppythonbuild'
self.build_base = os.path.join("_tmppythonbuild", "warpx")

def run(self):
# remove existing build directory
Expand Down

0 comments on commit e50b870

Please sign in to comment.