| 409 |   | See [https://wiki.hpc.tulane.edu/trac/wiki/Workshops/cypress/JobDependency here] for more about job-dependency. | 
          
          
            |   | 409 | See [https://wiki.hpc.tulane.edu/trac/wiki/Workshops/cypress/JobDependency here] for more about job dependency. | 
          
          
            |   | 410 |  | 
          
          
            |   | 411 | === Many-task computing === | 
          
          
            |   | 412 | If you have many tasks and each task needs a few cores, it may be beneficial to pack several tasks into one job. | 
          
          
            |   | 413 | For example, | 
          
          
            |   | 414 |  | 
          
          
            |   | 415 | {{{ | 
          
          
            |   | 416 | #!/bin/bash | 
          
          
            |   | 417 | #SBATCH --qos=normal            # Quality of Service | 
          
          
            |   | 418 | #SBATCH --job-name=many-task    # Job Name | 
          
          
            |   | 419 | #SBATCH --time=24:00:00         # WallTime | 
          
          
            |   | 420 | #SBATCH --nodes=1               # Number of Nodes | 
          
          
            |   | 421 | #SBATCH --ntasks-per-node=1     # Number of tasks (MPI presseces) | 
          
          
            |   | 422 | #SBATCH --cpus-per-task=20      # Number of processors per task OpenMP threads() | 
          
          
            |   | 423 |  | 
          
          
            |   | 424 | # Our custom function | 
          
          
            |   | 425 | cust_func(){ | 
          
          
            |   | 426 |   echo "Do something $1 task" | 
          
          
            |   | 427 |   sleep 1 | 
          
          
            |   | 428 | } | 
          
          
            |   | 429 | # For loop 20 times | 
          
          
            |   | 430 | date | 
          
          
            |   | 431 | for i in {1..20} | 
          
          
            |   | 432 | do | 
          
          
            |   | 433 |         cust_func $i & # Put a function in the background | 
          
          
            |   | 434 | done | 
          
          
            |   | 435 |  | 
          
          
            |   | 436 | ## Put all cust_func in the background and bash | 
          
          
            |   | 437 | ## would wait until those are completed | 
          
          
            |   | 438 | ## before displaying all done message | 
          
          
            |   | 439 | wait | 
          
          
            |   | 440 | echo "All done" | 
          
          
            |   | 441 | date | 
          
          
            |   | 442 | }}} | 
          
          
            |   | 443 |  | 
          
          
            |   | 444 | See [https://wiki.hpc.tulane.edu/trac/wiki/Workshops/cypress/ManyTaskComputing here] for more about Many Task Computing. | 
          
          
            |   | 445 |  |