Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Particle Send/Recv Routine #77

Merged
merged 54 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c1f5ab6
benchmark flow
haykh Dec 1, 2024
553bcae
added new particle array
Dec 2, 2024
cffc563
added new sendbuffer function
Dec 2, 2024
3c55ee7
fixed bug in CommunicateParticlesBuffer and created metadomain object…
Dec 3, 2024
5f1fe4a
Printing nparticles per domain
Dec 3, 2024
5b14e34
Printing particle count in domain
Dec 3, 2024
1b0993d
benchmark/benchmark.cpp
Dec 6, 2024
3202924
create mirror views for MPISendRecv in comm_mpi
Dec 12, 2024
831e7d9
fixed function to time old and new communication routines
Dec 12, 2024
896a957
bug fix in comm
Dec 16, 2024
9391c19
fmt
haykh Dec 16, 2024
c0d4652
tested prtlsort (WIP)
haykh Dec 16, 2024
646a208
removed tag_offset array from the particle class. The npart_per_tag()…
Dec 18, 2024
708115c
changed functions that called npart_per_tag()
Dec 18, 2024
d6a325b
changed comms to dispatch arrays of same type in one buffer
Dec 19, 2024
89a109d
test for cuda mpi
Dec 29, 2024
43924f5
fixed displacements
Dec 31, 2024
8571797
changed mpi init call
Dec 31, 2024
ea99f3b
fixed displacements
Jan 1, 2025
73377c2
fixed permute vector construction
Jan 4, 2025
0d18e5c
test of the number of particles
Jan 4, 2025
d7f92f0
added function to remove dead particles
Jan 5, 2025
510532b
Merge remote-tracking branch 'origin/dev/prtlsort' into dev/prtlsort
Jan 5, 2025
39f6c9f
testing: remove dead prtls
Jan 6, 2025
c54035f
testing removedeadparticles()
Jan 6, 2025
6ac585f
fixed dead particle removal bug
Jan 7, 2025
c719c1f
print mpi ranks during sendrecv
Jan 7, 2025
e43b716
changed communications in fields
Jan 7, 2025
42a6ea2
small change in metadomain header
Jan 7, 2025
a570474
correct communications with boundaries
Jan 9, 2025
d63595f
added dead particle function
Jan 9, 2025
8fc0cd6
added header
Jan 9, 2025
0ef2312
hdf5_root -- optionally set
haykh Jan 22, 2025
16a4086
sort_interval -> clear_interval
haykh Jan 22, 2025
e2644a6
rm old sorting + added new comm
haykh Jan 22, 2025
541633e
toml schema
haykh Jan 22, 2025
9d0c8db
nix shells
haykh Jan 22, 2025
5d1d8f7
comment
haykh Jan 22, 2025
179928f
plds are now 2d array
haykh Jan 23, 2025
ad02663
comm kernels
haykh Jan 23, 2025
ea4366b
minor fix in tags
haykh Jan 23, 2025
29ef300
proper tag_offsets access
haykh Jan 23, 2025
3c85363
minor
haykh Jan 23, 2025
d376b6e
minor bug: tag access
haykh Jan 23, 2025
f7ec06e
inline if patched
haykh Jan 24, 2025
fed4e62
bug on gpus fixed
haykh Jan 24, 2025
7388d8e
pld comm
haykh Jan 24, 2025
4357cb3
pld comm
haykh Jan 24, 2025
6aa7a80
minor bug fixed in kernel
haykh Jan 28, 2025
3071251
nix devshell
haykh Jan 29, 2025
6aa045a
pld reading in checkpoint fixed
haykh Jan 29, 2025
649e328
clean benchmark
haykh Jan 29, 2025
3f2674c
cleanup prep for release
haykh Jan 29, 2025
2b6ef3c
tested with/without mpi cpu+hip
haykh Jan 29, 2025
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 .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[formatting]
align_entries = true
indent_tables = true
indent_entries = true
trailing_newline = true
align_comments = true
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,12 @@ if(${output})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/adios2Config.cmake)
find_or_fetch_dependency(adios2 FALSE)
if(NOT DEFINED ENV{HDF5_ROOT})
set(USE_CUSTOM_HDF5 OFF)
if(DEFINED ENV{CONDA_PREFIX})
execute_process(COMMAND bash -c "conda list | grep \"hdf5\" -q"
RESULT_VARIABLE HDF5_INSTALLED)
if(HDF5_INSTALLED EQUAL 0)
set(HDF5_ROOT $ENV{CONDA_PREFIX})
else()
set(USE_CUSTOM_HDF5 ON)
endif()
else()
set(USE_CUSTOM_HDF5 ON)
endif()
if(USE_CUSTOM_HDF5)
message(
FATAL_ERROR
"HDF5_ROOT is not set. Please set it to the root of the HDF5 installation"
)
endif()
endif()
find_package(HDF5 REQUIRED)
Expand All @@ -134,6 +123,9 @@ link_libraries(${DEPENDENCIES})
if(TESTS)
# ---------------------------------- Tests --------------------------------- #
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tests.cmake)
elseif(BENCHMARK)
# ------------------------------ Benchmark --------------------------------- #
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/benchmark.cmake)
else()
# ----------------------------------- GUI ---------------------------------- #
if(${gui})
Expand Down
4 changes: 4 additions & 0 deletions TASKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
- [ ] removing temporary variables in interpolation
- [ ] passing by value vs const ref in metric
- [ ] return physical coords one-by-one instead of by passing full vector

### Things to look into

1. _h fields in mpi communication
17 changes: 17 additions & 0 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "global.h"

#include <iostream>
#include <stdexcept>

auto main(int argc, char* argv[]) -> int {
ntt::GlobalInitialize(argc, argv);
try {
// ...
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
GlobalFinalize();
return 1;
}
GlobalFinalize();
return 0;
}
24 changes: 24 additions & 0 deletions cmake/benchmark.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

add_subdirectory(${SRC_DIR}/global ${CMAKE_CURRENT_BINARY_DIR}/global)
add_subdirectory(${SRC_DIR}/metrics ${CMAKE_CURRENT_BINARY_DIR}/metrics)
add_subdirectory(${SRC_DIR}/kernels ${CMAKE_CURRENT_BINARY_DIR}/kernels)
add_subdirectory(${SRC_DIR}/archetypes ${CMAKE_CURRENT_BINARY_DIR}/archetypes)
add_subdirectory(${SRC_DIR}/framework ${CMAKE_CURRENT_BINARY_DIR}/framework)

if(${output})
add_subdirectory(${SRC_DIR}/output ${CMAKE_CURRENT_BINARY_DIR}/output)
add_subdirectory(${SRC_DIR}/checkpoint ${CMAKE_CURRENT_BINARY_DIR}/checkpoint)
endif()

set(exec benchmark.xc)
set(src ${CMAKE_CURRENT_SOURCE_DIR}/benchmark/benchmark.cpp)

add_executable(${exec} ${src})

set(libs ntt_global ntt_metrics ntt_kernels ntt_archetypes ntt_framework)
if(${output})
list(APPEND libs ntt_output ntt_checkpoint)
endif()
add_dependencies(${exec} ${libs})
target_link_libraries(${exec} PRIVATE ${libs} stdc++fs)
67 changes: 67 additions & 0 deletions dev/nix/adios2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
pkgs ? import <nixpkgs> { },
hdf5 ? false,
mpi ? false,
}:

let
name = "adios2";
version = "2.10.2";
cmakeFlags = {
CMAKE_CXX_STANDARD = "17";
CMAKE_CXX_EXTENSIONS = "OFF";
CMAKE_POSITION_INDEPENDENT_CODE = "TRUE";
BUILD_SHARED_LIBS = "ON";
ADIOS2_USE_HDF5 = if hdf5 then "ON" else "OFF";
ADIOS2_USE_Python = "OFF";
ADIOS2_USE_Fortran = "OFF";
ADIOS2_USE_ZeroMQ = "OFF";
BUILD_TESTING = "OFF";
ADIOS2_BUILD_EXAMPLES = "OFF";
ADIOS2_USE_MPI = if mpi then "ON" else "OFF";
CMAKE_BUILD_TYPE = "Release";
} // (if !mpi then { ADIOS2_HAVE_HDF5_VOL = "OFF"; } else { });
in
pkgs.stdenv.mkDerivation {
pname = "${name}${if hdf5 then "-hdf5" else ""}${if mpi then "-mpi" else ""}";
version = "${version}";
src = pkgs.fetchgit {
url = "https://github.com/ornladios/ADIOS2/";
rev = "v${version}";
sha256 = "sha256-NVyw7xoPutXeUS87jjVv1YxJnwNGZAT4QfkBLzvQbwg=";
};

nativeBuildInputs = with pkgs; [
cmake
perl
];

propagatedBuildInputs =
[
pkgs.gcc13
]
++ (if hdf5 then (if mpi then [ pkgs.hdf5-mpi ] else [ pkgs.hdf5 ]) else [ ])
++ (if mpi then [ pkgs.openmpi ] else [ ]);

configurePhase = ''
cmake -B build $src ${
pkgs.lib.attrsets.foldlAttrs (
acc: key: value:
acc + " -D ${key}=${value}"
) "" cmakeFlags
}
'';

buildPhase = ''
cmake --build build -j
'';

installPhase = ''
sed -i '/if(CMAKE_INSTALL_COMPONENT/,/^[[:space:]]&endif()$/d' build/cmake/install/post/cmake_install.cmake
cmake --install build --prefix $out
chmod +x build/cmake/install/post/generate-adios2-config.sh
sh build/cmake/install/post/generate-adios2-config.sh $out
'';

enableParallelBuilding = true;
}
64 changes: 64 additions & 0 deletions dev/nix/kokkos.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
pkgs ? import <nixpkgs> { },
arch ? "native",
gpu ? "none",
}:

let
gpuUpper = pkgs.lib.toUpper gpu;
name = "kokkos";
version = "4.5.01";
compilerPkgs = {
"HIP" = with pkgs.rocmPackages; [
rocm-core
clr
rocthrust
rocprim
rocminfo
rocm-smi
];
"NONE" = [
pkgs.gcc13
];
};
cmakeFlags = {
"HIP" = [
"-D CMAKE_C_COMPILER=hipcc"
"-D CMAKE_CXX_COMPILER=hipcc"
];
"NONE" = [ ];
};
getArch =
_:
if gpu != "none" && arch == "native" then
throw "Please specify an architecture when the GPU support is enabled. Available architectures: https://kokkos.org/kokkos-core-wiki/keywords.html#architectures"
else
pkgs.lib.toUpper arch;

in
pkgs.stdenv.mkDerivation {
pname = "${name}";
version = "${version}";
src = pkgs.fetchgit {
url = "https://github.com/kokkos/kokkos/";
rev = "v${version}";
sha256 = "sha256-cI2p+6J+8BRV5fXTDxxHTfh6P5PeeLUiF73o5zVysHQ=";
};

nativeBuildInputs = with pkgs; [
cmake
];

propagatedBuildInputs = compilerPkgs.${gpuUpper};

cmakeFlags = [
"-D CMAKE_CXX_STANDARD=17"
"-D CMAKE_CXX_EXTENSIONS=OFF"
"-D CMAKE_POSITION_INDEPENDENT_CODE=TRUE"
"-D Kokkos_ARCH_${getArch { }}=ON"
(if gpu != "none" then "-D Kokkos_ENABLE_${gpuUpper}=ON" else "")
"-D CMAKE_BUILD_TYPE=Release"
] ++ cmakeFlags.${gpuUpper};

enableParallelBuilding = true;
}
48 changes: 48 additions & 0 deletions dev/nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
pkgs ? import <nixpkgs> { },
mpi ? false,
hdf5 ? false,
gpu ? "none",
arch ? "native",
}:

let
name = "entity-dev";
adios2Pkg = (pkgs.callPackage ./adios2.nix { inherit pkgs mpi hdf5; });
kokkosPkg = (pkgs.callPackage ./kokkos.nix { inherit pkgs arch gpu; });
in
pkgs.mkShell {
name = "${name}-env";
nativeBuildInputs = with pkgs; [
zlib
cmake

clang-tools

adios2Pkg
kokkosPkg

python312
python312Packages.jupyter

cmake-format
neocmakelsp
black
pyright
taplo
vscode-langservers-extracted
];

LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ([
pkgs.stdenv.cc.cc
pkgs.zlib
]);

shellHook = ''
BLUE='\033[0;34m'
NC='\033[0m'

echo ""
echo -e "${name} nix-shell activated"
'';
}
2 changes: 1 addition & 1 deletion extern/Kokkos
Submodule Kokkos updated 653 files
2 changes: 1 addition & 1 deletion extern/adios2
Submodule adios2 updated 147 files
13 changes: 6 additions & 7 deletions input.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
# @note: In spherical, bondaries in theta/phi are set automatically (only specify bc @ [rmin, rmax]) [["ATMOSPHERE", "ABSORB"]]
# @note: In GR, the horizon boundary is set automatically (only specify bc @ rmax): [["ABSORB"]]
particles = ""

[grid.boundaries.absorb]
# Size of the absorption layer in physical (code) units:
# @type: float
Expand All @@ -119,7 +119,7 @@
coeff = ""

[grid.boundaries.atmosphere]
# @required: if ATMOSPHERE is one of the boundaries
# @required: if ATMOSPHERE is one of the boundaries
# Temperature of the atmosphere in units of m0 c^2
# @type: float
temperature = ""
Expand Down Expand Up @@ -210,7 +210,7 @@
# @type: float: ~1
# @default: 1.0
correction = ""

# @inferred:
# - dt [= CFL * dx0]
# @brief: timestep duration
Expand Down Expand Up @@ -252,12 +252,11 @@
# @type: bool
# @default: false
use_weights = ""
# Timesteps between particle re-sorting:
# Timesteps between particle re-sorting (removing dead particles):
# @type: unsigned int
# @default: 100
# @note: When MPI is enable, particles are sorted every step.
# @note: When `sort_interval` == 0, the sorting is disabled.
sort_interval = ""
# @note: set to 0 to disable re-sorting
clear_interval = ""

# @inferred:
# - nspec
Expand Down
Loading