Skip to content

Commit de5ced2

Browse files
committed
Merge branch 'build_script_docs' into 'main'
Documentation improvements to libra_build.sh See merge request ardg/libra!151
2 parents 5a610f8 + 27627dd commit de5ced2

File tree

1 file changed

+74
-15
lines changed

1 file changed

+74
-15
lines changed

scripts/libra_build.sh

100644100755
Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright (C) 2025
2+
# Copyright (C) 2024
33
# Associated Universities, Inc. Washington DC, USA.
44
#
55
# This library is free software; you can redistribute it and/or modify it
@@ -45,18 +45,81 @@
4545
# Additional commands required on stampede3 before running this script:
4646
# . <PATH_TO_SPACK_PACKAGE>/share/spack/setup-env.sh
4747
# spacktivate -p <LIBRA_ENV_NAME>
48-
# module unload python/3.9.18 intel/24.0
48+
# module unload python/3.9.18 intel/24.0
4949

50-
function in_spack_env() {
51-
if [[ -v SPACK_ROOT ]]; then
52-
return 0; # True is bash!
53-
else
54-
return 1; # False in bash!
55-
fi
50+
# Display help message
51+
function show_help() {
52+
cat << EOF
53+
LibRA Build Script
54+
55+
DESCRIPTION:
56+
This script sets up and builds LibRA using an out-of-tree build
57+
configuration. It configures the build environment, and runs CMake to
58+
configure and build the project. It optionally checks for required SPACK
59+
dependencies, if SPACK is being used.
60+
61+
SPACK PREREQUISITES:
62+
1. SPACK must be set up and activated:
63+
. <PATH_TO_SPACK_PACKAGE>/share/spack/setup-env.sh
64+
spacktivate -p <LIBRA_ENV_NAME>
65+
2. On stampede3, unload conflicting modules:
66+
module unload python/3.9.18 intel/24.0
67+
3. Enable SPACK buil of this script by passing in -DLIBRA_USE_SPACK=ON
68+
to the command line.
69+
70+
REQUIRED SPACK PACKAGES:
71+
- cfitsio
72+
- wcslib
73+
- gsl
74+
- ncurses
75+
- readline
76+
- cmake
77+
78+
OPTIONAL SPACK PACKAGES:
79+
- openblas
80+
- python
81+
82+
USAGE:
83+
$0 (-DLIBRA_ENABLE_CUDA_BACKEND=OFF | -DKokkos_CUDA_ARCH_NAME=<GPU_ARCH>) [CMAKE_OPTIONS...]
84+
85+
CMAKE OPTIONS:
86+
-DLIBRA_ENABLE_CUDA_BACKEND=OFF
87+
Build for CPU-only (default: ON for GPU build)
88+
89+
-DKokkos_CUDA_ARCH_NAME=<GPU_ARCH>
90+
Specify GPU architecture for GPU+CPU build
91+
Example: -DKokkos_CUDA_ARCH_NAME=AMPERE80
92+
93+
Any other CMake options can be passed and will be forwarded to cmake
94+
95+
EXAMPLES:
96+
# CPU-only build
97+
$0 -DLIBRA_ENABLE_CUDA_BACKEND=OFF
98+
99+
# GPU build for Ampere architecture
100+
$0 -DKokkos_CUDA_ARCH_NAME=AMPERE80
101+
102+
# GPU build with additional CMake options
103+
$0 -DKokkos_CUDA_ARCH_NAME=AMPERE80 -DCMAKE_BUILD_TYPE=Debug
104+
105+
NOTES:
106+
- HPG does not build with GCC 11.4 and CUDA 12.x combo
107+
- GCC 11.4 with CUDA 11.x works
108+
- The script assumes CMakeLists.txt is in the parent directory (..)
109+
- Build output will be in ../build directory
110+
111+
EOF
56112
}
113+
114+
# Check for help flag or no arguments
115+
if [[ $# -eq 0 ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
116+
show_help
117+
exit 0
118+
fi
119+
57120
# This function checks if a given package is installed in the spack env.
58121
function is_installed_in_spack() {
59-
if in_spack_env; then
122+
if [[ -v SPACK_ROOT ]]; then
60123
if spack find --format "{name}" "$1" > /dev/null 2>&1; then
61124
return 1;
62125
else
@@ -69,10 +132,7 @@ fi
69132

70133
export CMAKE=`which cmake`
71134

72-
#
73-
# Setup and checks for build in an SPACK env
74-
#
75-
if in_spack_env; then
135+
if [[ -v SPACK_ROOT ]]; then
76136
# $SPACK_ENV gets defined in an activated env.
77137
SPACK_ENV_ROOT=$SPACK_ENV/.spack-env/view/
78138

@@ -99,7 +159,7 @@ if in_spack_env; then
99159
# Maybe required
100160
#
101161
tt=$(is_installed_in_spack "openblas")
102-
tt+=$(is_installed_in_spack "python")
162+
tt+=" "$(is_installed_in_spack "python")
103163

104164
if [[ -z "$tt" ]]; then
105165
echo -n "";
@@ -113,7 +173,6 @@ if in_spack_env; then
113173
#
114174
export GSL_ROOT=$(spack location -i gsl)
115175
export WCSLIB_ROOT=$(spack location -i wcslib)
116-
117176
export LD_LIBRARY_PATH=/lib64:/lib:$SPACK_ENV_ROOT/lib64:$SPACK_ENV_ROOT/lib:$LD_LIBRARY_PATH
118177

119178
export CMAKE=$(spack location -i cmake)/bin/cmake

0 commit comments

Comments
 (0)