-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding bash script for running test suite
- Loading branch information
Showing
1 changed file
with
76 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,76 @@ | ||
#!/bin/bash | ||
|
||
# Set default parameters | ||
default_grid_size_lat=1 | ||
default_grid_size_lon=1 | ||
default_run_distributed=false | ||
|
||
# Parse command line arguments | ||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-h|--help) | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
echo "Runs the torch-harmonics test suite." | ||
echo "${bold}Arguments:${normal}" | ||
echo " ${bold}-h | --help:${normal} Prints this text." | ||
echo " ${bold}-d | --run_distributed:${normal} Run the distributed test suite." | ||
echo " ${bold}-lat | --grid_size_lat:${normal} Number of ranks in latitudinal direction for distributed case." | ||
echo " ${bold}-lon | --grid_size_lon:${normal} Number of ranks in longitudinal direction for distributed case." | ||
|
||
shift | ||
exit 0 | ||
;; | ||
-lat|--grid_size_lat) | ||
grid_size_lat="$2" | ||
shift 2 | ||
;; | ||
-lon|--grid_size_lon) | ||
grid_size_lon="$2" | ||
shift 2 | ||
;; | ||
-d|--run_distributed) | ||
run_distributed=true | ||
shift | ||
;; | ||
*) | ||
echo "Unknown argument: $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Use default values if arguments were not provided | ||
grid_size_lat=${grid_size_lat:-$default_grid_size_lat} | ||
grid_size_lon=${grid_size_lon:-$default_grid_size_lon} | ||
run_distributed=${run_distributed:-$default_run_distributed} | ||
|
||
echo "Running sequential tests:" | ||
python3 -m pytest tests/test_convolution.py tests/test_sht.py | ||
|
||
# Run distributed tests if requested | ||
if [ "$run_distributed" = "true" ]; then | ||
|
||
echo "Running distributed tests with the following parameters:" | ||
echo "Grid size latitude: $grid_size_lat" | ||
echo "Grid size longitude: $grid_size_lon" | ||
|
||
ngpu=$(( ${grid_size_lat} * ${grid_size_lon} )) | ||
|
||
mpirun --allow-run-as-root -np ${ngpu} bash -c " | ||
export CUDA_LAUNCH_BLOCKING=1; | ||
export WORLD_RANK=\${OMPI_COMM_WORLD_RANK}; | ||
export WORLD_SIZE=\${OMPI_COMM_WORLD_SIZE}; | ||
export RANK=\${OMPI_COMM_WORLD_RANK}; | ||
export MASTER_ADDR=localhost; | ||
export MASTER_PORT=29501; | ||
export GRID_H=${grid_size_lat}; | ||
export GRID_W=${grid_size_lon}; | ||
python3 -m pytest tests/test_distributed_sht.py | ||
python3 -m pytest tests/test_distributed_convolution.py | ||
" | ||
else | ||
echo "Skipping distributed tests." | ||
fi |