From 37e0826d93d8ef5090c5a08941259dc44016beda Mon Sep 17 00:00:00 2001 From: AbsoluteVacuum <32832158+AbsoluteVacuum@users.noreply.github.com> Date: Wed, 29 May 2024 15:24:56 +0300 Subject: [PATCH 1/4] add bash array example --- triton/tut/array.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/triton/tut/array.rst b/triton/tut/array.rst index 1a1d97e5a..b70efdd00 100644 --- a/triton/tut/array.rst +++ b/triton/tut/array.rst @@ -203,6 +203,13 @@ of successes):: $ cat pi_22.json {"successes": 1963163, "pi_estimate": 3.1410608, "iterations": 2500000} +An alternative to using ``case`` statement would be using ``bash`` arrays, like in the following example +:download:`pi_array_hardcoded_alt.sh ` +. + +.. literalinclude:: /triton/examples/array/pi_array_hardcoded_alt.sh + :language: slurm + Reading parameters from one file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From d6e1db87edc30845fd140e0875b8c467c151b07b Mon Sep 17 00:00:00 2001 From: AbsoluteVacuum <32832158+AbsoluteVacuum@users.noreply.github.com> Date: Wed, 29 May 2024 15:28:49 +0300 Subject: [PATCH 2/4] Add files via upload --- triton/examples/array/pi_array_hardcoded_alt.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 triton/examples/array/pi_array_hardcoded_alt.sh diff --git a/triton/examples/array/pi_array_hardcoded_alt.sh b/triton/examples/array/pi_array_hardcoded_alt.sh new file mode 100644 index 000000000..377890422 --- /dev/null +++ b/triton/examples/array/pi_array_hardcoded_alt.sh @@ -0,0 +1,11 @@ +#!/bin/bash +#SBATCH --time=01:00:00 +#SBATCH --mem=500M +#SBATCH --job-name=pi-array-hardcoded +#SBATCH --output=pi-array-hardcoded_%a.out +#SBATCH --array=0-4 + +SEEDS=(123 38 22 60 432) +SEED=${SEEDS[SLURM_ARRAY_TASK_ID]} + +srun python slurm/pi.py 2500000 --seed=$SEED > pi_$SEED.json From 6431721de61026d181956f230a2d4d0f9719b841 Mon Sep 17 00:00:00 2001 From: AbsoluteVacuum <32832158+AbsoluteVacuum@users.noreply.github.com> Date: Wed, 29 May 2024 15:37:04 +0300 Subject: [PATCH 3/4] Clarification regarding bash arrays --- triton/tut/array.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/triton/tut/array.rst b/triton/tut/array.rst index b70efdd00..d33a36918 100644 --- a/triton/tut/array.rst +++ b/triton/tut/array.rst @@ -210,6 +210,10 @@ An alternative to using ``case`` statement would be using ``bash`` arrays, like .. literalinclude:: /triton/examples/array/pi_array_hardcoded_alt.sh :language: slurm +``bash`` arrays only support non-negative integers or strings, so if your parameters are e.g. real numbers, they can be put in the array as strings:: + FREQUENCIES=("2.8" "2.9" "3.0" "3.1") + FREQUENCY=${FREQUENCIES[SLURM_ARRAY_TASK_ID]} + Reading parameters from one file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 819e7dc67b77482aaeb20d66925216bdc84e185f Mon Sep 17 00:00:00 2001 From: AbsoluteVacuum <32832158+AbsoluteVacuum@users.noreply.github.com> Date: Wed, 29 May 2024 15:38:40 +0300 Subject: [PATCH 4/4] added bash variables clarification --- triton/tut/array.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triton/tut/array.rst b/triton/tut/array.rst index d33a36918..e847f504b 100644 --- a/triton/tut/array.rst +++ b/triton/tut/array.rst @@ -210,7 +210,7 @@ An alternative to using ``case`` statement would be using ``bash`` arrays, like .. literalinclude:: /triton/examples/array/pi_array_hardcoded_alt.sh :language: slurm -``bash`` arrays only support non-negative integers or strings, so if your parameters are e.g. real numbers, they can be put in the array as strings:: +``bash`` arrays and variables only support non-negative integers or strings, so if your parameters are e.g. real numbers, they can be put in the array as strings:: FREQUENCIES=("2.8" "2.9" "3.0" "3.1") FREQUENCY=${FREQUENCIES[SLURM_ARRAY_TASK_ID]}