Job arrays: Difference between revisions

(Adding a Python example where we iterate a parameter though a list or NumPy array.)
Line 88: Line 88:
== Example: Data-parallel Python script ==
== Example: Data-parallel Python script ==


Suppose you have a Python script doing a certain calculations with some parameters defined in a Python list or a NumPy array such as
Suppose you have a Python script doing certain calculations with some parameters defined in a Python list or a NumPy array such as
{{File
{{File
|name=my_script.py
|name=my_script.py
Line 112: Line 112:
The above task can be processed in a job array so that each value of the beta parameter can be treated in parallel.
The above task can be processed in a job array so that each value of the beta parameter can be treated in parallel.
The idea is to pass the <code>$SLURM_ARRAY_TASK_ID</code> to the Python script and get the beta parameter based on its value.
The idea is to pass the <code>$SLURM_ARRAY_TASK_ID</code> to the Python script and get the beta parameter based on its value.
The Python script become
The Python script becomes
{{File
{{File
|name=my_script_parallel.py
|name=my_script_parallel.py
cc_staff
4

edits