Skip to content
Closed
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
47 changes: 47 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
TARGET="$1"
BUILD_MODE="$2"
if [[ -z "$TARGET" ]]; then
echo "Usage: ./build.sh [cpu|gpu]"
exit 1
fi

# PATHS
HOME_PATH="$(dirname "$PWD")"
SPACK_PATH=$HOME_PATH/spack
. $SPACK_PATH/share/spack/setup-env.sh
PROJECT_DIR=$HOME_PATH/x3d2
BUILD_DIR="$PROJECT_DIR/build_$TARGET"

# Set flags depending on the mode
if [[ "$TARGET" == "gpu" ]]; then
echo "Building with GPU flags..."
# CMAKE_FLAGS="-DUSE_GPU=ON -DUSE_CPU=OFF"
spack env activate -p $PROJECT_DIR/scripts/spack-env-gpu
spack install
spack load nvhpc
spack load cmake
# Fatal Error: Cannot open module file 'mpi.mod' for reading at (1): No such file or directory
# spack location -i nvhpc
elif [[ "$TARGET" == "cpu" ]]; then
echo "Building with CPU flags..."
spack env activate -p $PROJECT_DIR/scripts/spack-env-cpu
spack install
spack load openmpi
spack load cmake
else
echo "Invalid option: $TARGET"
echo "Use: cpu or gpu"
exit 1
fi

export FC=mpif90
rm -rf $BUILD_DIR
if [[ "$BUILD_MODE" == "debug" ]]; then
cmake -S "$PROJECT_DIR" -B $BUILD_DIR -DCMAKE_BUILD_TYPE=Debug
else
cmake -S "$PROJECT_DIR" -B $BUILD_DIR -DCMAKE_BUILD_TYPE=Release
fi
cd $BUILD_DIR
make
echo "Running Tests..."
make test
12 changes: 12 additions & 0 deletions scripts/spack-env-cpu/spack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
# add package specs to the `specs` list
specs:
- cmake
- openmpi@5.0.5
view: true
concretizer:
unify: true
12 changes: 12 additions & 0 deletions scripts/spack-env-gpu/spack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
# add package specs to the `specs` list
specs:
- nvhpc+mpi
- cmake
view: true
concretizer:
unify: true