-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·78 lines (63 loc) · 1.59 KB
/
build.sh
File metadata and controls
executable file
·78 lines (63 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Build script for BlockStructuredSolvers_CPP
# Usage: ./build.sh [cpu|cuda] [debug|release]
set -e # Exit on any error
# Default values
BACKEND="cpu"
BUILD_TYPE="Release"
# Parse arguments
if [ $# -ge 1 ]; then
BACKEND=$1
fi
if [ $# -ge 2 ]; then
if [ "$2" = "debug" ]; then
BUILD_TYPE="Debug"
elif [ "$2" = "release" ]; then
BUILD_TYPE="Release"
fi
fi
echo "Building BlockStructuredSolvers_CPP..."
echo "Backend: $BACKEND"
echo "Build type: $BUILD_TYPE"
echo
# Create build directory
BUILD_DIR="build-$BACKEND-$(echo $BUILD_TYPE | tr '[:upper:]' '[:lower:]')"
mkdir -p $BUILD_DIR
cd $BUILD_DIR
# Configure CMake
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE"
if [ "$BACKEND" = "cuda" ]; then
echo "Configuring with CUDA support..."
CMAKE_ARGS="$CMAKE_ARGS -DENABLE_CUDA=ON"
# Check if CUDA is available
if ! command -v nvcc &> /dev/null; then
echo "Warning: nvcc not found. Make sure CUDA is properly installed."
fi
else
echo "Configuring CPU-only build..."
fi
cmake .. $CMAKE_ARGS
# Build
echo "Building..."
make -j$(nproc)
echo
echo "Build completed successfully!"
echo "Executables are in: $PWD"
echo
# Run tests
echo "Running tests..."
if ctest --output-on-failure; then
echo "All tests passed!"
else
echo "Some tests failed. Check the output above."
exit 1
fi
echo
echo "Build and test completed successfully!"
echo
echo "To run examples:"
echo " CPU example: ./$BUILD_DIR/example_cpu"
if [ "$BACKEND" = "cuda" ]; then
echo " CUDA example: ./$BUILD_DIR/example_cuda"
fi
echo " Benchmark: ./$BUILD_DIR/benchmark"