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

PIConGPU unit tests #4723

Merged
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
14 changes: 14 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ pmacc-compile-reduced-matrix:
job: pmacc-generate-reduced-matrix
strategy: depend

picongpu-unittest-generate-reduced-matrix:
variables:
PIC_INPUTS: "unit"
TEST_TUPLE_NUM_ELEM: 1
extends: ".base_generate-reduced-matrix"

picongpu-unittest-compile-reduced-matrix:
stage: test
trigger:
include:
- artifact: compile.yml
job: picongpu-unittest-generate-reduced-matrix
strategy: depend

pypicongpu-generate-full-matrix:
stage: generate
image: ubuntu:22.04
Expand Down
1 change: 1 addition & 0 deletions include/picongpu/param/precision.param
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#pragma once

#include <picongpu/simulation_types.hpp>

namespace picongpu
{
Expand Down
8 changes: 0 additions & 8 deletions include/picongpu/particles/Particles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@ namespace picongpu
}
};

namespace traits
PrometheusPi marked this conversation as resolved.
Show resolved Hide resolved
{
template<typename T_Name, typename T_Attributes, typename T_Flags>
struct GetDataBoxType<picongpu::Particles<T_Name, T_Attributes, T_Flags>>
{
using type = typename picongpu::Particles<T_Name, T_Attributes, T_Flags>::ParticlesBoxType;
};
} // namespace traits
} // namespace picongpu

namespace pmacc
Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/CIC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/Counter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/NGP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/PCS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/PQS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
3 changes: 2 additions & 1 deletion include/picongpu/particles/shapes/TSC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

#pragma once

#include "picongpu/simulation_defines.hpp"
#include <pmacc/attribute/FunctionSpecifier.hpp>
#include <pmacc/memory/Array.hpp>

#include <cstdint>

Expand Down
2 changes: 2 additions & 0 deletions include/picongpu/simulation_defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
#include <pmacc/types.hpp>
#include <picongpu/simulation_types.hpp>
#include "pmacc_renamings.hpp"
#include "picongpu/traits/GetMargin.hpp"


namespace picongpu
{
using namespace pmacc;
using namespace picongpu::traits;
}

/* IMPORTANT we need to use #include <...> for local files
Expand Down
3 changes: 0 additions & 3 deletions include/picongpu/simulation_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#pragma once

#include "picongpu/traits/GetDataBoxType.hpp"
#include "picongpu/traits/GetMargin.hpp"
#include "version.hpp"

#include <pmacc/algorithms/PromoteType.hpp>
Expand Down Expand Up @@ -56,6 +54,5 @@ namespace picongpu

using namespace pmacc::algorithms::promoteType;
using namespace pmacc::traits;
using namespace picongpu::traits;

} // namespace picongpu
36 changes: 0 additions & 36 deletions include/picongpu/traits/GetDataBoxType.hpp

This file was deleted.

3 changes: 2 additions & 1 deletion include/picongpu/unitless/precision.unitless
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

#pragma once

#include <pmacc/math/Vector.hpp>
#include "picongpu/param/dimension.param"

#include <pmacc/math/Vector.hpp>

namespace picongpu
{
Expand Down
57 changes: 57 additions & 0 deletions share/ci/backendFlags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

###################################################
# translate PIConGPU backend names into CMake Flags
###################################################

get_backend_flags()
{
backend_cfg=(${1//:/ })
num_options="${#backend_cfg[@]}"
PrometheusPi marked this conversation as resolved.
Show resolved Hide resolved
if [ $num_options -gt 2 ] ; then
echo "-b|--backend must be contain 'backend:arch' or 'backend'" >&2
exit 1
fi
if [ "${backend_cfg[0]}" == "cuda" ] ; then
result+=" -Dalpaka_ACC_GPU_CUDA_ENABLE=ON -Dalpaka_ACC_GPU_CUDA_ONLY_MODE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DCMAKE_CUDA_ARCHITECTURES=\"${backend_cfg[1]}\""
else
result+=" -DCMAKE_CUDA_ARCHITECTURES=52"
fi
elif [ "${backend_cfg[0]}" == "omp2b" ] ; then
result+=" -Dalpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DPMACC_CPU_ARCH=\"${backend_cfg[1]}\""
fi
elif [ "${backend_cfg[0]}" == "serial" ] ; then
result+=" -Dalpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DPMACC_CPU_ARCH=\"${backend_cfg[1]}\""
fi
elif [ "${backend_cfg[0]}" == "tbb" ] ; then
result+=" -Dalpaka_ACC_CPU_B_TBB_T_SEQ_ENABLE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DPMACC_CPU_ARCH=\"${backend_cfg[1]}\""
fi
elif [ "${backend_cfg[0]}" == "threads" ] ; then
result+=" -Dalpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DPMACC_CPU_ARCH=\"${backend_cfg[1]}\""
fi
elif [ "${backend_cfg[0]}" == "hip" ] ; then
result+=" -Dalpaka_ACC_GPU_HIP_ENABLE=ON -Dalpaka_ACC_GPU_HIP_ONLY_MODE=ON"
if [ $num_options -eq 2 ] ; then
result+=" -DGPU_TARGETS=\"${backend_cfg[1]}\""
else
# If no architecture is given build for Radeon VII or MI50/60.
result+=" -DGPU_TARGETS=gfx906"
fi
else
echo "unsupported backend given '$1'" >&2
exit 1
fi

echo "$result"
exit 0
}
3 changes: 3 additions & 0 deletions share/ci/generate_reduced_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ folders=()
if [ "$PIC_INPUTS" == "pmacc" ] ; then
# create test cases for PMacc
echo "pmacc" | tr " " "\n" | n_wise_generator.py $@ --limit_boost_version
elif [ "$PIC_INPUTS" == "unit" ] ; then
# create test cases for PMacc
echo "unit" | tr " " "\n" | n_wise_generator.py $@ --limit_boost_version
else
# create test cases for PIConGPU
for CASE in ${PIC_INPUTS}; do
Expand Down
3 changes: 2 additions & 1 deletion share/ci/n_wise_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ def is_valid_combination(row):
v_cuda_hip_str = "" if v_cuda_hip == 0 else str(v_cuda_hip)
os_name = pairs[2][0]
os_version = get_version(pairs[2])
image_prefix = "_run" if folder == "pmacc" else "_compile"
image_prefix = "_run" if folder == "pmacc" or folder == "unit"\
else "_compile"
job_name = compiler + "_" + backend + v_cuda_hip_str + \
"_boost" + boost_version + "_" + folder.replace("/", ".")
print(job_name + ":")
Expand Down
1 change: 0 additions & 1 deletion share/ci/run_picongpu_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -e
set -o pipefail

# the default build type is Release
# if neccesary, you can rerun the pipeline with another build type-> https://docs.gitlab.com/ee/ci/pipelines.html#manually-executing-pipelines
# to change the build type, you must set the environment variable PIC_BUILD_TYPE
if [[ ! -v PIC_BUILD_TYPE ]] ; then
PIC_BUILD_TYPE=Release ;
Expand Down
98 changes: 98 additions & 0 deletions share/ci/run_picongpu_unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash
# Execute PIConGPU's unit tests

set -e
set -o pipefail

export code_DIR=$CI_PROJECT_DIR
source $code_DIR/share/ci/backendFlags.sh

# the default build type is Release
# to change the build type, you must set the environment variable PIC_BUILD_TYPE
if [[ ! -v PIC_BUILD_TYPE ]] ; then
PIC_BUILD_TYPE=Release ;
fi

if [[ "$CI_RUNNER_TAGS" =~ .*cpuonly.* ]] ; then
# In cases where the compile-only job is executed on a GPU runner but with different kinds of accelerators
# we need to reset the variables to avoid compiling for the wrong architecture and accelerator.
unset CI_GPUS
unset CI_GPU_ARCH
fi

if [ -n "$CI_GPUS" ] ; then
# select randomly a device if multiple exists
# CI_GPUS is provided by the gitlab CI runner
SELECTED_DEVICE_ID=$((RANDOM%CI_GPUS))
export HIP_VISIBLE_DEVICES=$SELECTED_DEVICE_ID
export CUDA_VISIBLE_DEVICES=$SELECTED_DEVICE_ID
echo "selected device '$SELECTED_DEVICE_ID' of '$CI_GPUS'"
else
echo "No GPU device selected because environment variable CI_GPUS is not set."
fi

if [[ "$PIC_BACKEND" =~ hip.* ]] || [[ "$PIC_BACKEND" =~ cuda.* ]] ; then
if [ -n "$CI_GPU_ARCH" ] ; then
export PIC_BACKEND="${PIC_BACKEND}:${CI_GPU_ARCH}"
fi
fi

###################################################
# cmake config builder
###################################################

PIC_CONST_ARGS=""
PIC_CONST_ARGS="${PIC_CONST_ARGS} -DCMAKE_BUILD_TYPE=${PIC_BUILD_TYPE}"
CMAKE_ARGS="${PIC_CONST_ARGS} ${PIC_CMAKE_ARGS} -DCMAKE_CXX_COMPILER=${CXX_VERSION} -DBOOST_ROOT=/opt/boost/${BOOST_VERSION}"
CMAKE_ARGS="$CMAKE_ARGS -DUSE_MPI_AS_ROOT_USER=ON"

# check and activate if clang should be used as CUDA device compiler
if [ -n "$CI_CLANG_AS_CUDA_COMPILER" ] ; then
export PATH="$(agc-manager -b cuda)/bin:$PATH"
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CUDA_COMPILER=${CXX_VERSION}"
fi

alpaka_backend=$(get_backend_flags ${PIC_BACKEND})
CMAKE_ARGS="$CMAKE_ARGS $alpaka_backend"

###################################################
# build and run unit tests
###################################################

# adjust number of parallel builds to avoid out of memory errors
# PIC_BUILD_REQUIRED_MEM_BYTES is a configured variable in the CI web interface
PIC_PARALLEL_BUILDS=$(($CI_RAM_BYTES_TOTAL/$PIC_BUILD_REQUIRED_MEM_BYTES))

# limit to number of available cores
if [ $PIC_PARALLEL_BUILDS -gt $CI_CPUS ] ; then
PIC_PARALLEL_BUILDS=$CI_CPUS
fi

# CI_MAX_PARALLELISM is a configured variable in the CI web interface
if [ $PIC_PARALLEL_BUILDS -gt $CI_MAX_PARALLELISM ] ; then
PIC_PARALLEL_BUILDS=$CI_MAX_PARALLELISM
fi

## run unit tests
export unitTest_folder=$HOME/buildPICUnitTest
mkdir -p $unitTest_folder
cd $unitTest_folder

echo -e "\033[0;32m///////////////////////////////////////////////////"
echo "PIC_BUILD_REQUIRED_MEM_BYTES-> ${PIC_BUILD_REQUIRED_MEM_BYTES}"
echo "CI_RAM_BYTES_TOTAL -> ${CI_RAM_BYTES_TOTAL}"
echo "CI_CPUS -> ${CI_CPUS}"
echo "CI_MAX_PARALLELISM -> ${CI_MAX_PARALLELISM}"
echo "number of processor threads -> $(nproc)"
echo "number of parallel builds -> $PIC_PARALLEL_BUILDS"
echo "cmake version -> $(cmake --version | head -n 1)"
echo "build directory -> $(pwd)"
echo "CMAKE_ARGS -> ${CMAKE_ARGS}"
echo "accelerator -> ${PIC_BACKEND}"
echo "input set -> ${PIC_TEST_CASE_FOLDER}"
echo -e "/////////////////////////////////////////////////// \033[0m \n\n"

cmake $CMAKE_ARGS $code_DIR/share/picongpu/unit
make -j $PIC_PARALLEL_BUILDS
# execute on one device
ctest -V
Loading