Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cpuarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CPU Compilation/Unit Tests

on:
push:
pull_request:
types: [ready_for_review]

jobs:
check-commit:
Expand All @@ -14,6 +16,10 @@ jobs:
- name: Check commit message
id: check_message
run: |
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.action }}" == "ready_for_review" ]]; then
echo "run_tests=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git log -1 --pretty=%B | grep -q "CPUTEST"; then
echo "run_tests=true" >> "$GITHUB_OUTPUT"
else
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(PROJECT_NAME entity)

project(
${PROJECT_NAME}
VERSION 1.3.0
VERSION 1.4.0
LANGUAGES CXX C)
add_compile_options("-D ENTITY_VERSION=\"${PROJECT_VERSION}\"")
set(hash_cmd "git diff --quiet src/ && echo $(git rev-parse HEAD) ")
Expand Down Expand Up @@ -62,7 +62,7 @@ set(gpu_aware_mpi
CACHE BOOL "Enable GPU-aware MPI")

# -------------------------- Compilation settings -------------------------- #
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -162,9 +162,9 @@ if(${output})
find_or_fetch_dependency(adios2 FALSE QUIET)
add_compile_options("-D OUTPUT_ENABLED")
if(${mpi})
set(DEPENDENCIES ${DEPENDENCIES} adios2::cxx11_mpi)
set(DEPENDENCIES ${DEPENDENCIES} adios2::cxx_mpi)
else()
set(DEPENDENCIES ${DEPENDENCIES} adios2::cxx11)
set(DEPENDENCIES ${DEPENDENCIES} adios2::cxx)
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ function(find_or_fetch_dependency package_name header_only mode)
FetchContent_Declare(
${package_name}
GIT_REPOSITORY ${${package_name}_REPOSITORY}
GIT_TAG 4.7.01)
GIT_TAG 5.0.0)
elseif(${package_name} STREQUAL "adios2")
FetchContent_Declare(
${package_name}
GIT_REPOSITORY ${${package_name}_REPOSITORY}
GIT_TAG v2.10.2)
GIT_TAG v2.11.0)
else()
FetchContent_Declare(${package_name}
GIT_REPOSITORY ${${package_name}_REPOSITORY})
Expand Down
6 changes: 3 additions & 3 deletions dev/nix/adios2.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

let
name = "adios2";
version = "2.10.2";
version = "2.11.0";
cmakeFlags = {
CMAKE_CXX_STANDARD = "17";
CMAKE_CXX_STANDARD = "20";
CMAKE_CXX_EXTENSIONS = "OFF";
CMAKE_POSITION_INDEPENDENT_CODE = "TRUE";
BUILD_SHARED_LIBS = "ON";
Expand All @@ -30,7 +30,7 @@ stdenv.mkDerivation {
src = pkgs.fetchgit {
url = "https://github.com/ornladios/ADIOS2/";
rev = "v${version}";
sha256 = "sha256-NVyw7xoPutXeUS87jjVv1YxJnwNGZAT4QfkBLzvQbwg=";
sha256 = "sha256-yHPI///17poiCEb7Luu5qfqxTWm9Nh+o9r57mZT26U0=";
};

nativeBuildInputs = with pkgs; [
Expand Down
10 changes: 5 additions & 5 deletions dev/nix/kokkos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

let
name = "kokkos";
pversion = "4.7.01";
pversion = "5.0.0";
compilerPkgs = {
"HIP" = with pkgs.rocmPackages; [
llvm.rocm-merged-llvm
llvm.llvm
rocm-core
clr
rocthrust
Expand Down Expand Up @@ -39,7 +39,7 @@ let
"HIP" = [
"-D Kokkos_ENABLE_HIP=ON"
"-D Kokkos_ARCH_${getArch { }}=ON"
"-D AMDGPU_TARGETS=${builtins.replaceStrings [ "amd_" ] [ "" ] (pkgs.lib.toLower (getArch { }))}"
"-D GPU_TARGETS=${builtins.replaceStrings [ "amd_" ] [ "" ] (pkgs.lib.toLower (getArch { }))}"
"-D CMAKE_CXX_COMPILER=hipcc"
];
"CUDA" = [
Expand All @@ -56,7 +56,7 @@ pkgs.stdenv.mkDerivation rec {
src = pkgs.fetchgit {
url = "https://github.com/kokkos/kokkos/";
rev = "${pversion}";
sha256 = "sha256-MgphOsKE8umgYxVQZzex+elgvDDC09JaMCoU5YXaLco=";
sha256 = "sha256-C4DarqnEcdF3+19TPqcM0A9bcQSkKTJkB8b7OkzC7T8=";
};

nativeBuildInputs = with pkgs; [
Expand All @@ -78,7 +78,7 @@ pkgs.stdenv.mkDerivation rec {

configurePhase = ''
cmake -B build -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_STANDARD=17 \
-D CMAKE_CXX_STANDARD=20 \
-D CMAKE_CXX_EXTENSIONS=OFF \
-D CMAKE_POSITION_INDEPENDENT_CODE=TRUE \
${pkgs.lib.concatStringsSep " " cmakeExtraFlags.${gpu}} \
Expand Down
3 changes: 1 addition & 2 deletions dev/nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pkgs.mkShell {
adios2Pkg
kokkosPkg

python312
python312Packages.jupyter
python314

cmake-format
cmake-lint
Expand Down
2 changes: 1 addition & 1 deletion extern/Kokkos
Submodule Kokkos updated 1467 files
2 changes: 1 addition & 1 deletion extern/adios2
Submodule adios2 updated 1117 files
4 changes: 2 additions & 2 deletions minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if("ADIOS2_NOMPI" IN_LIST MODES)

find_kokkos()
find_adios2()
list(APPEND libs Kokkos::kokkos adios2::cxx11)
list(APPEND libs Kokkos::kokkos adios2::cxx)

add_executable(${exec} ${src})

Expand All @@ -104,7 +104,7 @@ if("ADIOS2_MPI" IN_LIST MODES)
find_package(MPI REQUIRED)
find_kokkos()
find_adios2()
list(APPEND libs MPI::MPI_CXX Kokkos::kokkos adios2::cxx11_mpi)
list(APPEND libs MPI::MPI_CXX Kokkos::kokkos adios2::cxx_mpi)

add_executable(${exec} ${src})

Expand Down
2 changes: 1 addition & 1 deletion minimal/adios2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Kokkos_Core.hpp>
#include <adios2.h>
#include <adios2/cxx11/KokkosView.h>
#include <adios2/cxx/KokkosView.h>

#if defined(MPI_ENABLED)
#include <mpi.h>
Expand Down
8 changes: 4 additions & 4 deletions pgens/magnetosphere/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ namespace user {

template <Dimension D>
struct DriveFields : public InitFields<D> {
DriveFields(real_t time,
DriveFields(simtime_t time,
real_t bsurf,
real_t rstar,
real_t omega,
const std::string& field_geometry)
: InitFields<D> { bsurf, rstar, field_geometry }
, time { time }
, time { (real_t)time }
, Omega { omega } {}

using InitFields<D>::bx1;
Expand Down Expand Up @@ -113,11 +113,11 @@ namespace user {

inline PGen() {}

auto AtmFields(real_t time) const -> DriveFields<D> {
auto AtmFields(simtime_t time) const -> DriveFields<D> {
return DriveFields<D> { time, Bsurf, Rstar, Omega, field_geom };
}

auto MatchFields(real_t) const -> InitFields<D> {
auto MatchFields(simtime_t) const -> InitFields<D> {
return InitFields<D> { Bsurf, Rstar, field_geom };
}
};
Expand Down
2 changes: 1 addition & 1 deletion pgens/shock/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace user {

inline PGen() {}

auto MatchFields(real_t time) const -> InitFields<D> {
auto MatchFields(simtime_t) const -> InitFields<D> {
return init_flds;
}

Expand Down
4 changes: 2 additions & 2 deletions src/archetypes/energy_dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "global.h"

#include "arch/kokkos_aliases.h"
#include "arch/traits.h"
#include "utils/comparators.h"
#include "utils/error.h"
#include "utils/numeric.h"
Expand All @@ -33,10 +34,9 @@ namespace arch {
using namespace ntt;

template <SimEngine::type S, class M>
requires traits::metric::HasD<M>
struct EnergyDistribution {
static constexpr auto D = M::Dim;
static constexpr bool is_energy_dist { true };
static_assert(M::is_metric, "M must be a metric class");

EnergyDistribution(const M& metric) : metric { metric } {}

Expand Down
62 changes: 10 additions & 52 deletions src/archetypes/field_setter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ namespace arch {
using namespace ntt;

template <class I, SimEngine::type S, class M>
requires traits::metric::HasD<M> &&
((S == SimEngine::SRPIC && traits::metric::HasConvert<M> &&
traits::metric::HasTransform_i<M>) ||
(S == SimEngine::GRPIC && traits::metric::HasConvert_i<M>))
class SetEMFields_kernel {
static constexpr Dimension D = M::Dim;
static constexpr bool defines_ex1 = traits::has_method<traits::ex1_t, I>::value;
Expand All @@ -53,7 +57,6 @@ namespace arch {
(defines_dx1 == defines_dx2 && defines_dx2 == defines_dx3 &&
defines_bx1 == defines_bx2 && defines_bx2 == defines_bx3),
"In GR mode, all components must be defined or none");
static_assert(M::is_metric, "M must be a metric class");

ndfield_t<M::Dim, 6> EM;
const I finit;
Expand Down Expand Up @@ -271,69 +274,24 @@ namespace arch {

if constexpr (defines_dx1 && defines_dx2 && defines_dx3) {
{ // dx1
vec_t<Dim::_3D> d_PU { finit.dx1({ x1_H, x2_0, x3_0 }),
finit.dx2({ x1_H, x2_0, x3_0 }),
finit.dx3({ x1_H, x2_0, x3_0 }) };
vec_t<Dim::_3D> d_U { ZERO };
metric.template transform<Idx::PU, Idx::U>({ i1_ + HALF, i2_, i3_ },
d_PU,
d_U);
EM(i1, i2, i3, em::dx1) = d_U[0];
EM(i1, i2, i3, em::dx1) = finit.dx1({ x1_H, x2_0, x3_0 });
}
{ // dx2
vec_t<Dim::_3D> d_PU { finit.dx1({ x1_0, x2_H, x3_0 }),
finit.dx2({ x1_0, x2_H, x3_0 }),
finit.dx3({ x1_0, x2_H, x3_0 }) };
vec_t<Dim::_3D> d_U { ZERO };
metric.template transform<Idx::PU, Idx::U>({ i1_, i2_ + HALF, i3_ },
d_PU,
d_U);
EM(i1, i2, i3, em::dx2) = d_U[1];
EM(i1, i2, i3, em::dx2) = finit.dx2({ x1_0, x2_H, x3_0 });
}
{ // dx3
vec_t<Dim::_3D> d_PU { finit.dx1({ x1_0, x2_0, x3_H }),
finit.dx2({ x1_0, x2_0, x3_H }),
finit.dx3({ x1_0, x2_0, x3_H }) };
vec_t<Dim::_3D> d_U { ZERO };
metric.template transform<Idx::PU, Idx::U>({ i1_, i2_, i3_ + HALF },
d_PU,
d_U);
EM(i1, i2, i3, em::dx3) = d_U[2];
EM(i1, i2, i3, em::dx3) = finit.dx3({ x1_0, x2_0, x3_H });
}
}
if constexpr (defines_bx1 && defines_bx2 && defines_bx3) {
{ // bx1
vec_t<Dim::_3D> b_PU { finit.bx1({ x1_0, x2_H, x3_H }),
finit.bx2({ x1_0, x2_H, x3_H }),
finit.bx3({ x1_0, x2_H, x3_H }) };
vec_t<Dim::_3D> b_U { ZERO };
metric.template transform<Idx::PU, Idx::U>(
{ i1_, i2_ + HALF, i3_ + HALF },
b_PU,
b_U);
EM(i1, i2, i3, em::bx1) = b_U[0];
EM(i1, i2, i3, em::bx1) = finit.bx1({ x1_0, x2_H, x3_H });
}
{ // bx2
vec_t<Dim::_3D> b_PU { finit.bx1({ x1_H, x2_0, x3_H }),
finit.bx2({ x1_H, x2_0, x3_H }),
finit.bx3({ x1_H, x2_0, x3_H }) };
vec_t<Dim::_3D> b_U { ZERO };
metric.template transform<Idx::PU, Idx::U>(
{ i1_ + HALF, i2_, i3_ + HALF },
b_PU,
b_U);
EM(i1, i2, i3, em::bx2) = b_U[1];
EM(i1, i2, i3, em::bx2) = finit.bx2({ x1_H, x2_0, x3_H });
}
{ // bx3
vec_t<Dim::_3D> b_PU { finit.bx1({ x1_H, x2_H, x3_0 }),
finit.bx2({ x1_H, x2_H, x3_0 }),
finit.bx3({ x1_H, x2_H, x3_0 }) };
vec_t<Dim::_3D> b_U { ZERO };
metric.template transform<Idx::PU, Idx::U>(
{ i1_ + HALF, i2_ + HALF, i3_ },
b_PU,
b_U);
EM(i1, i2, i3, em::bx3) = b_U[2];
EM(i1, i2, i3, em::bx3) = finit.bx3({ x1_H, x2_H, x3_0 });
}
}
} else {
Expand Down
14 changes: 6 additions & 8 deletions src/archetypes/particle_injector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace arch {
* - array_t<real_t*>: maximum coordinates of the region in computational coords
*/
template <SimEngine::type S, class M>
requires traits::metric::HasD<M> && traits::metric::HasConvert<M>
auto DeduceRegion(const Domain<S, M>& domain, const boundaries_t<real_t>& box)
-> std::tuple<bool, array_t<real_t*>, array_t<real_t*>> {
if (not domain.mesh.Intersects(box)) {
Expand Down Expand Up @@ -107,6 +108,7 @@ namespace arch {
* - array_t<real_t*>: maximum coordinates of the region in computational coords
*/
template <SimEngine::type S, class M>
requires traits::metric::HasD<M>
auto ComputeNumInject(const SimulationParams& params,
const Domain<S, M>& domain,
real_t number_density,
Expand Down Expand Up @@ -198,16 +200,15 @@ namespace arch {
* @tparam ED2 Energy distribution type for species 2
*/
template <SimEngine::type S, class M, class ED1, class ED2>
requires traits::metric::HasD<M> && traits::energydist::IsValid<ED1> &&
traits::energydist::IsValid<ED2>
inline void InjectUniform(const SimulationParams& params,
Domain<S, M>& domain,
const std::pair<spidx_t, spidx_t>& species,
const std::pair<ED1, ED2>& energy_dists,
real_t number_density,
bool use_weights = false,
const boundaries_t<real_t>& box = {}) {
static_assert(M::is_metric, "M must be a metric class");
static_assert(ED1::is_energy_dist, "ED1 must be an energy distribution class");
static_assert(ED2::is_energy_dist, "ED2 must be an energy distribution class");
raise::ErrorIf((M::CoordType != Coord::Cart) && (not use_weights),
"Weights must be used for non-Cartesian coordinates",
HERE);
Expand Down Expand Up @@ -278,7 +279,6 @@ namespace arch {
spidx_t spidx,
const std::map<std::string, std::vector<real_t>>& data,
bool use_weights = false) {
static_assert(M::is_metric, "M must be a metric class");
const auto n_inject = data.at("ux1").size();
auto injector_kernel = kernel::GlobalInjector_kernel<S, M>(
local_domain.species[spidx - 1],
Expand Down Expand Up @@ -309,6 +309,8 @@ namespace arch {
* @tparam SD Spatial distribution type
*/
template <SimEngine::type S, class M, class ED1, class ED2, class SD>
requires traits::metric::HasD<M> && traits::energydist::IsValid<ED1> &&
traits::energydist::IsValid<ED2> && traits::spatialdist::IsValid<SD>
inline void InjectNonUniform(const SimulationParams& params,
Domain<S, M>& domain,
const std::pair<spidx_t, spidx_t>& species,
Expand All @@ -317,10 +319,6 @@ namespace arch {
real_t number_density,
bool use_weights = false,
const boundaries_t<real_t>& box = {}) {
static_assert(M::is_metric, "M must be a metric class");
static_assert(ED1::is_energy_dist, "ED1 must be an energy distribution class");
static_assert(ED2::is_energy_dist, "ED2 must be an energy distribution class");
static_assert(SD::is_spatial_dist, "SD must be a spatial distribution class");
raise::ErrorIf((M::CoordType != Coord::Cart) && (not use_weights),
"Weights must be used for non-Cartesian coordinates",
HERE);
Expand Down
Loading