mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-09 15:37:58 -05:00
66 lines
1.8 KiB
Bash
Executable File
66 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Exit immediately if a command exits with a non-zero status
|
|
set -e
|
|
|
|
# Function to display usage information
|
|
show_help() {
|
|
echo "Usage: $0 [-d DEVICE_TYPE] [-b BACKEND_INSTALL_DIR]"
|
|
echo
|
|
echo "Options:"
|
|
echo " -d DEVICE_TYPE Specify the device type (default: CPU)"
|
|
echo " -b BACKEND_INSTALL_DIR Specify the backend installation directory (default: empty)"
|
|
echo " -h Show this help message"
|
|
exit 0
|
|
}
|
|
|
|
# Parse command line options
|
|
while getopts ":d:b:h" opt; do
|
|
case ${opt} in
|
|
d )
|
|
DEVICE_TYPE=$OPTARG
|
|
;;
|
|
b )
|
|
BACKEND_INSTALL_DIR="$(realpath ${OPTARG})"
|
|
;;
|
|
h )
|
|
show_help
|
|
;;
|
|
\? )
|
|
echo "Invalid option: -$OPTARG" 1>&2
|
|
show_help
|
|
;;
|
|
: )
|
|
echo "Invalid option: -$OPTARG requires an argument" 1>&2
|
|
show_help
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Set default values if not provided
|
|
: "${DEVICE_TYPE:=CPU}"
|
|
: "${BACKEND_INSTALL_DIR:=}"
|
|
|
|
# Create necessary directories
|
|
mkdir -p build/example
|
|
mkdir -p build/icicle
|
|
|
|
ICILE_DIR=$(realpath "../../../icicle_v3/")
|
|
ICICLE_CUDA_BACKEND_DIR="${ICILE_DIR}/backend/cuda"
|
|
|
|
# Build Icicle and the example app that links to it
|
|
if [ "$DEVICE_TYPE" == "CUDA" ] && [ ! -d "${BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_CUDA_BACKEND_DIR}" ]; then
|
|
echo "Building icicle with CUDA backend"
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DCUDA_BACKEND=local -S "${ICILE_DIR}" -B build/icicle
|
|
BACKEND_INSTALL_DIR=$(realpath "build/icicle/backend")
|
|
else
|
|
echo "Building icicle without CUDA backend, BACKEND_INSTALL_DIR=${BACKEND_INSTALL_DIR}"
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -S "${ICILE_DIR}" -B build/icicle
|
|
fi
|
|
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/example
|
|
|
|
cmake --build build/icicle -j
|
|
cmake --build build/example -j
|
|
|
|
./build/example/example "$DEVICE_TYPE" "$BACKEND_INSTALL_DIR"
|