-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added run.sh for cli run for poseidon2 example
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/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 ) | ||
ICICLE_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}" | ||
: "${ICICLE_BACKEND_INSTALL_DIR:=}" | ||
|
||
DEVICE_TYPE_LOWERCASE=$(echo "$DEVICE_TYPE" | tr '[:upper:]' '[:lower:]') | ||
|
||
ICILE_DIR=$(realpath "../../../icicle/") | ||
ICICLE_BACKEND_SOURCE_DIR="${ICILE_DIR}/backend/${DEVICE_TYPE_LOWERCASE}" | ||
|
||
# Build Icicle and the example app that links to it | ||
if [ "$DEVICE_TYPE" != "CPU" ] && [ ! -d "${ICICLE_BACKEND_INSTALL_DIR}" ] && [ -d "${ICICLE_BACKEND_SOURCE_DIR}" ]; then | ||
echo "Building icicle and ${DEVICE_TYPE} backend" | ||
cargo build --release --features="${DEVICE_TYPE_LOWERCASE}" | ||
export ICICLE_BACKEND_INSTALL_DIR=$(realpath "../target/release/deps/icicle/lib/backend") | ||
cargo run --release --features="${DEVICE_TYPE_LOWERCASE}" -- --device-type "${DEVICE_TYPE}" | ||
else | ||
echo "Building icicle without backend, ICICLE_BACKEND_INSTALL_DIR=${ICICLE_BACKEND_INSTALL_DIR}" | ||
export ICICLE_BACKEND_INSTALL_DIR="${ICICLE_BACKEND_INSTALL_DIR}" | ||
cargo run --release -- --device-type "${DEVICE_TYPE}" | ||
fi |