diff --git a/.github/workflows/actions/pre-install-py-packages/action.yml b/.github/workflows/actions/pre-install-py-packages/action.yml new file mode 100644 index 000000000..2be0d7afd --- /dev/null +++ b/.github/workflows/actions/pre-install-py-packages/action.yml @@ -0,0 +1,15 @@ +name: Install python packages + +description: "Action installing the Idefix python packages before running the tests." + +inputs: {} + +runs: + using: "composite" + steps: + - name: Create venv + shell: bash + run: | + python3 -m venv .venv + source .venv/bin/activate + python3 -m pip install -r ./test/python_requirements.txt diff --git a/.github/workflows/idefix-ci-jobs.yml b/.github/workflows/idefix-ci-jobs.yml index 847ba3cbe..05b42568e 100644 --- a/.github/workflows/idefix-ci-jobs.yml +++ b/.github/workflows/idefix-ci-jobs.yml @@ -32,6 +32,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Sod test run: scripts/ci/run-tests $IDEFIX_DIR/test/HD/sod -all $TESTME_OPTIONS - name: Isothermal Sod test @@ -49,6 +51,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Viscous flow past cylinder run: scripts/ci/run-tests $IDEFIX_DIR/test/HD/ViscousFlowPastCylinder -all $TESTME_OPTIONS - name: Viscous disk @@ -64,6 +68,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: MHD Sod test run: scripts/ci/run-tests $IDEFIX_DIR/test/MHD/sod -all $TESTME_OPTIONS - name: MHD Isothermal Sod test @@ -85,6 +91,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Ambipolar C Shock run: scripts/ci/run-tests $IDEFIX_DIR/test/MHD/AmbipolarCshock -all $TESTME_OPTIONS - name: Ambipolar C Shock 3D @@ -105,6 +113,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Fargo + planet run: scripts/ci/run-tests $IDEFIX_DIR/test/HD/FargoPlanet -all $TESTME_OPTIONS - name: Fargo MHD spherical @@ -119,6 +129,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Hydro shearing box run: scripts/ci/run-tests $IDEFIX_DIR/test/HD/ShearingBox -all $TESTME_OPTIONS - name: MHD shearing box @@ -133,6 +145,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Jeans Instability run: scripts/ci/run-tests $IDEFIX_DIR/test/SelfGravity/JeansInstability -all $TESTME_OPTIONS - name: Random sphere spherical @@ -153,6 +167,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: 3 body run: scripts/ci/run-tests $IDEFIX_DIR/test/Planet/Planet3Body -all $TESTME_OPTIONS - name: migration @@ -175,6 +191,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Energy conservation run: scripts/ci/run-tests $IDEFIX_DIR/test/Dust/DustEnergy -all $TESTME_OPTIONS - name: Dusty wave @@ -189,6 +207,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: MTI run: scripts/ci/run-tests $IDEFIX_DIR/test/MHD/MTI -all $TESTME_OPTIONS - name: Spherical anisotropic diffusion @@ -207,6 +227,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Run examples test run: cd test && ./checks_examples.sh $TEST_OPTIONS @@ -219,6 +241,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Lookup table run: scripts/ci/run-tests $IDEFIX_DIR/test/utils/lookupTable -all $TESTME_OPTIONS - name: Dump Image @@ -235,6 +259,8 @@ jobs: with: submodules: recursive persist-credentials: false + - name: Prep python + uses: ./.github/workflows/actions/pre-install-py-packages - name: Restart dumps run: scripts/ci/run-tests $IDEFIX_DIR/test/IO/dump -all $TESTME_OPTIONS - name: Pydefix diff --git a/CMakeLists.txt b/CMakeLists.txt index 6698aaec6..fad0058ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16) if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) endif() -set (CMAKE_CXX_STANDARD 17) +set (CMAKE_CXX_STANDARD 20) set(Idefix_VERSION_MAJOR 2) set(Idefix_VERSION_MINOR 3) diff --git a/doc/source/index.rst b/doc/source/index.rst index d36ab39be..2871f7953 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -20,11 +20,11 @@ algorithm is essentially the same (but with some major modification to its struc ================ Requirements ================ -*Idefix* is written is standard C++17 and does not rely on any external library in serial (non MPI). +*Idefix* is written is standard C++20 and does not rely on any external library in serial (non MPI). Compiler - *Idefix* requires a C++17 compatible compiler. It has been tested successfully with GCC (>8), Intel compiler suite (>2018) and - Clang on both Intel and AMD CPUs. *Idefix* has also been tested on NVIDIA GPUs (Pascal, Volta and Ampere architectures) using the nvcc (>10) compiler, and on AMD GPUs (Radeon Mi50, Mi210, Mi250) using the hipcc compiler. + *Idefix* requires a C++20 compatible compiler. It has been tested successfully with GCC (>11), Intel compiler suite (>2022) and + Clang on both Intel and AMD CPUs. *Idefix* has also been tested on NVIDIA GPUs (Pascal, Volta and Ampere architectures) using the nvcc (>12) compiler, and on AMD GPUs (Radeon Mi50, Mi210, Mi250, Mi300) using the hipcc compiler. Kokkos library *Idefix* relies internally on the `Kokkos `_ library, which is bundled with *Idefix* as a git submodule and compiled on the fly, hence no external installation is required. @@ -90,6 +90,9 @@ Jean Kempf, Victor Reville, François Rincon Marc Coiffier Continuous integration, automatic benchmarking +Sébastien Valat + Continuous integration + ======================== About this documentation ======================== diff --git a/doc/source/programmingguide.rst b/doc/source/programmingguide.rst index 4bd7c69f7..6f65742bc 100644 --- a/doc/source/programmingguide.rst +++ b/doc/source/programmingguide.rst @@ -355,13 +355,13 @@ fills the following arrays (essentially grid information) with data from its par .. code-block:: c++ - IdefixArray1D::HostMirror x[3]; // geometrical central points - IdefixArray1D::HostMirror xr[3]; // cell right interface - IdefixArray1D::HostMirror xl[3]; // cell left interface - IdefixArray1D::HostMirror dx[3]; // cell width + IdefixArray1D::host_mirror_type x[3]; // geometrical central points + IdefixArray1D::host_mirror_type xr[3]; // cell right interface + IdefixArray1D::host_mirror_type xl[3]; // cell left interface + IdefixArray1D::host_mirror_type dx[3]; // cell width - IdefixArray3D::HostMirror dV; // cell volume - IdefixArray3D::HostMirror A[3]; // cell right interface area + IdefixArray3D::host_mirror_type dV; // cell volume + IdefixArray3D::host_mirror_type A[3]; // cell right interface area Note however that the physics arrays are not automatically synchronized when ``DataBlockHost`` is @@ -369,17 +369,17 @@ created, that is: .. code-block:: c++ - IdefixArray4D::HostMirror Vc; // Main cell-centered primitive variables index - IdefixArray4D::HostMirror Vs; // Main face-centered primitive variables index - IdefixArray4D::HostMirror J; // Current (only when haveCurrent is enabled) - IdefixArray4D::HostMirror Uc; // Main cell-centered conservative variables - IdefixArray3D::HostMirror InvDt; + IdefixArray4D::host_mirror_type Vc; // Main cell-centered primitive variables index + IdefixArray4D::host_mirror_type Vs; // Main face-centered primitive variables index + IdefixArray4D::host_mirror_type J; // Current (only when haveCurrent is enabled) + IdefixArray4D::host_mirror_type Uc; // Main cell-centered conservative variables + IdefixArray3D::host_mirror_type InvDt; - IdefixArray3D::HostMirror Ex1; // x1 electric field - IdefixArray3D::HostMirror Ex2; // x2 electric field - IdefixArray3D::HostMirror Ex3; // x3 electric field + IdefixArray3D::host_mirror_type Ex1; // x1 electric field + IdefixArray3D::host_mirror_type Ex2; // x2 electric field + IdefixArray3D::host_mirror_type Ex3; // x3 electric field -need to be synchronized *manually*. These IdefixArrays are all defined as ``HostMirror``, implying that they are accessible +need to be synchronized *manually*. These IdefixArrays are all defined as ``host_mirror_type``, implying that they are accessible from the host only. If modifications are performed on the arrays of the parent ``DataBlock``, one can call ``DataBlockHost::SyncFromDevice()`` to refresh the host arrays, and inversely one can call ``DataBlockHost::SyncToDevice()`` to send data from ``DataBlockHost`` diff --git a/scripts/ci/run-tests b/scripts/ci/run-tests index 329831029..359e1eb14 100755 --- a/scripts/ci/run-tests +++ b/scripts/ci/run-tests @@ -1,7 +1,20 @@ #!/usr/bin/env bash + +# load ICC compiler env if [ "$IDEFIX_COMPILER" == icc ]; then source /opt/intel/oneapi/setvars.sh fi + +# enable bash features set -ue + +# load python venv if present +if [ -d .venv ]; then + source .venv/bin/activate +fi + +# jump in test directory cd "$1" + +# run the test ./testme.py "${@:2}" diff --git a/src/dataBlock/dumpToFile.cpp b/src/dataBlock/dumpToFile.cpp index 51347e6ed..f20dde838 100644 --- a/src/dataBlock/dumpToFile.cpp +++ b/src/dataBlock/dumpToFile.cpp @@ -45,13 +45,13 @@ void DataBlock::DumpToFile(std::string filebase) { // TODO(lesurg) Make datablock a friend of hydro to get the Riemann flux? - //IdefixArray4D::HostMirror locFlux = Kokkos::create_mirror_view(Kokkos::HostSpace(), + //IdefixArray4D::host_mirror_type locFlux = Kokkos::create_mirror_view(Kokkos::HostSpace(), // this->hydro->FluxRiemann); //Kokkos::deep_copy(locFlux, this->FluxRiemann); #if MHD == YES - IdefixArray4D::HostMirror locJ; + IdefixArray4D::host_mirror_type locJ; if(hydro->haveCurrent) { locJ = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->hydro->J); Kokkos::deep_copy(locJ, this->hydro->J); @@ -82,7 +82,7 @@ void DataBlock::DumpToFile(std::string filebase) { fwrite (header, sizeof(char), HEADERSIZE, fileHdl); // Write Vc - IdefixArray4D::HostMirror locVc = Kokkos::create_mirror_view(this->hydro->Vc); + IdefixArray4D::host_mirror_type locVc = Kokkos::create_mirror_view(this->hydro->Vc); Kokkos::deep_copy(locVc,this->hydro->Vc); dims[0] = this->np_tot[IDIR]; dims[1] = this->np_tot[JDIR]; @@ -94,7 +94,7 @@ void DataBlock::DumpToFile(std::string filebase) { WriteVariable(fileHdl, 4, dims, fieldName, locVc.data()); if (this->gravity->haveSelfGravityPotential) { - IdefixArray3D::HostMirror locPot = Kokkos::create_mirror_view(this->gravity->phiP); + IdefixArray3D::host_mirror_type locPot = Kokkos::create_mirror_view(this->gravity->phiP); Kokkos::deep_copy(locPot, this->gravity->phiP); dims[3] = 1; @@ -121,7 +121,7 @@ void DataBlock::DumpToFile(std::string filebase) { // Write Vs #if MHD == YES // Write Vs - IdefixArray4D::HostMirror locVs = Kokkos::create_mirror_view(Kokkos::HostSpace(), + IdefixArray4D::host_mirror_type locVs = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->hydro->Vs); Kokkos::deep_copy(locVs,this->hydro->Vs); dims[0] = this->np_tot[IDIR]+IOFFSET; @@ -139,7 +139,7 @@ void DataBlock::DumpToFile(std::string filebase) { dims[2] = this->np_tot[KDIR]; std::snprintf(fieldName,NAMESIZE,"Ex3"); - IdefixArray3D::HostMirror locE = Kokkos::create_mirror_view(Kokkos::HostSpace(), + IdefixArray3D::host_mirror_type locE = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->hydro->emf->ez); Kokkos::deep_copy(locE,this->hydro->emf->ez); WriteVariable(fileHdl, 3, dims, fieldName, locE.data()); @@ -155,7 +155,7 @@ void DataBlock::DumpToFile(std::string filebase) { if(hydro->haveCurrent) { - IdefixArray4D::HostMirror locJ = Kokkos::create_mirror_view(Kokkos::HostSpace(), + IdefixArray4D::host_mirror_type locJ = Kokkos::create_mirror_view(Kokkos::HostSpace(), this->hydro->J); Kokkos::deep_copy(locJ,this->hydro->J); dims[0] = this->np_tot[IDIR]; diff --git a/src/dataBlock/planetarySystem/planetStructs.hpp b/src/dataBlock/planetarySystem/planetStructs.hpp index 3749a34d2..6440daf8f 100644 --- a/src/dataBlock/planetarySystem/planetStructs.hpp +++ b/src/dataBlock/planetarySystem/planetStructs.hpp @@ -19,7 +19,7 @@ struct Force { real f_ex_inner[3]; real f_outer[3]; real f_ex_outer[3]; - KOKKOS_FUNCTION void operator+=(Force const volatile& f) volatile { + KOKKOS_FUNCTION void operator+=(const Force & f) { for (int i = 0; i < 3; ++i) { f_inner[i] += f.f_inner[i]; f_ex_inner[i] += f.f_ex_inner[i]; diff --git a/src/fluid/boundary/axis.hpp b/src/fluid/boundary/axis.hpp index 1a1227b61..229c772f6 100644 --- a/src/fluid/boundary/axis.hpp +++ b/src/fluid/boundary/axis.hpp @@ -126,7 +126,7 @@ Axis::Axis(Boundary *boundary) { // Init the symmetry array (used to flip the signs of arrays accross the axis) symmetryVc = IdefixArray1D("Axis:SymmetryVc",nVar); - IdefixArray1D::HostMirror symmetryVcHost = Kokkos::create_mirror_view(symmetryVc); + IdefixArray1D::host_mirror_type symmetryVcHost = Kokkos::create_mirror_view(symmetryVc); // Init the array for (int nv = 0; nv < nVar; nv++) { symmetryVcHost(nv) = 1; @@ -143,7 +143,7 @@ Axis::Axis(Boundary *boundary) { if constexpr(Phys::mhd) { symmetryVs = IdefixArray1D("Axis:SymmetryVs",DIMENSIONS); - IdefixArray1D::HostMirror symmetryVsHost = Kokkos::create_mirror_view(symmetryVs); + IdefixArray1D::host_mirror_type symmetryVsHost = Kokkos::create_mirror_view(symmetryVs); // Init the array for(int nv = 0; nv < DIMENSIONS; nv++) { symmetryVsHost(nv) = 1; diff --git a/src/gravity/laplacian.cpp b/src/gravity/laplacian.cpp index 7ac329ea3..127299548 100644 --- a/src/gravity/laplacian.cpp +++ b/src/gravity/laplacian.cpp @@ -170,7 +170,7 @@ void Laplacian::InitInternalGrid() { }); // Check that all is well - IdefixArray1D::HostMirror xH = Kokkos::create_mirror_view(x1l); + IdefixArray1D::host_mirror_type xH = Kokkos::create_mirror_view(x1l); Kokkos::deep_copy(xH, x1l); if(xH(0)<0.0) { diff --git a/src/kokkos b/src/kokkos index 09e775bfc..3ec81abe1 160000 --- a/src/kokkos +++ b/src/kokkos @@ -1 +1 @@ -Subproject commit 09e775bfc585840bb9ab1156cbd8d7d1c9e0cc6d +Subproject commit 3ec81abe1816109f6f62ac48cef41921f91a4d00 diff --git a/src/mpi/mpi.cpp b/src/mpi/mpi.cpp index 36b4eb9a3..d0759199a 100644 --- a/src/mpi/mpi.cpp +++ b/src/mpi/mpi.cpp @@ -131,7 +131,7 @@ void Mpi::CheckConfig() { // Run-time check that we can do a reduce on device arrays IdefixArray1D src("MPIChecksrc",1); - IdefixArray1D::HostMirror srcHost = Kokkos::create_mirror_view(src); + IdefixArray1D::host_mirror_type srcHost = Kokkos::create_mirror_view(src); if(idfx::prank == 0) { srcHost(0) = 0; diff --git a/test/MHD/AmbipolarWind/setup.cpp b/test/MHD/AmbipolarWind/setup.cpp index 78620f6e2..892eeea27 100644 --- a/test/MHD/AmbipolarWind/setup.cpp +++ b/test/MHD/AmbipolarWind/setup.cpp @@ -373,7 +373,7 @@ void ComputeUserVars(DataBlock & data, UserDefVariablesContainer &variables) { IdefixHostArray1D x1=d.x[IDIR]; IdefixHostArray1D x2=d.x[JDIR]; IdefixHostArray4D Vc=d.Vc; - IdefixArray3D::HostMirror scrhHost = Kokkos::create_mirror_view(scrh); + IdefixArray3D::host_mirror_type scrhHost = Kokkos::create_mirror_view(scrh); Kokkos::deep_copy(scrhHost,scrh); for(int k = d.beg[KDIR]; k < d.end[KDIR] ; k++) { diff --git a/test/python_requirements.txt b/test/python_requirements.txt index 9cf2383a2..6419c74af 100644 --- a/test/python_requirements.txt +++ b/test/python_requirements.txt @@ -8,7 +8,7 @@ scipy>=1.2.3 # note that no version of inifix supports Python older than 3.6 inifix>=0.11.2 - +pybind11 >= 3.0.4 # To run the test suite, we can use pytest, mostly any version # 6.0 is the one available on system available on debian-11 pytest >= 6.0 diff --git a/test/skeleton/main.cpp b/test/skeleton/main.cpp index 4930ecb15..aecadc962 100644 --- a/test/skeleton/main.cpp +++ b/test/skeleton/main.cpp @@ -37,7 +37,7 @@ void testReduction() { // Init an array on device, and image on host IdefixArray3D rho = IdefixArray3D("rho",nx3,nx2,nx1); - IdefixArray3D::HostMirror rhoHost = Kokkos::create_mirror_view(rho); + IdefixArray3D::host_mirror_type rhoHost = Kokkos::create_mirror_view(rho); // Fill the host array, and compute the theoretical results real theoreticalResult = 0; diff --git a/test/utils/columnDensity/setup.cpp b/test/utils/columnDensity/setup.cpp index fe7c57e69..090024abc 100644 --- a/test/utils/columnDensity/setup.cpp +++ b/test/utils/columnDensity/setup.cpp @@ -33,7 +33,7 @@ void Analysis(DataBlock & data) { columnX3Right->ComputeColumn(rho); IdefixArray3D columnDensityLeft, columnDensityRight; - IdefixArray3D::HostMirror columnDensityLeftHost, columnDensityRightHost; + IdefixArray3D::host_mirror_type columnDensityLeftHost, columnDensityRightHost; // IDIR columnDensityLeft = columnX1Left->GetColumn(); columnDensityRight = columnX1Right->GetColumn(); diff --git a/test/utils/lookupTable/main.cpp b/test/utils/lookupTable/main.cpp index 619cae6d2..1fc660cd6 100644 --- a/test/utils/lookupTable/main.cpp +++ b/test/utils/lookupTable/main.cpp @@ -38,7 +38,7 @@ int main( int argc, char* argv[] ) idfx::cout << "--------------------------------------" << std::endl; idfx::cout << "Testing 2D CSV file on device." << std::endl; IdefixArray1D arr = IdefixArray1D("Test",1); - IdefixArray1D::HostMirror arrHost = Kokkos::create_mirror_view(arr); + IdefixArray1D::host_mirror_type arrHost = Kokkos::create_mirror_view(arr); LookupTable<2> csv("toto.csv",',');