Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| habrok:additional_information:course_material:advanced_exercises_solutions [2023/09/26 11:33] – [Exercise 1.4: Work on image from different folder] revision pedro | habrok:additional_information:course_material:advanced_exercises_solutions [2024/10/28 14:40] (current) – [Exercise 0] Changed to GitLab link aurel | ||
|---|---|---|---|
| Line 20: | Line 20: | ||
| ===== Exercise 0 ===== | ===== Exercise 0 ===== | ||
| - | The files needed to complete these exercises are on [[https://github.com/rug-cit-hpc/ | + | The files needed to complete these exercises are on [[https://gitrepo.service.rug.nl/cit-hpc/habrok/ |
| < | < | ||
| - | git clone https://github.com/rug-cit-hpc/ | + | git clone https://gitrepo.service.rug.nl/cit-hpc/habrok/ |
| </ | </ | ||
| Line 331: | Line 331: | ||
| **Run these commands on the imagefile to see what they do.** | **Run these commands on the imagefile to see what they do.** | ||
| - | As you have seen these commands result in numbers that we could use in our script. In order to store a number | + | As you have seen these commands result in numbers that we could use in our script. In order to store the output |
| < | < | ||
| myvar=$( command ) | myvar=$( command ) | ||
| Line 520: | Line 520: | ||
| #SBATCH --mem=4GB | #SBATCH --mem=4GB | ||
| #SBATCH --time=00: | #SBATCH --time=00: | ||
| - | #SBATCH --partition=short | + | #SBATCH --partition=regular |
| #SBATCH --job-name=Sharpening | #SBATCH --job-name=Sharpening | ||
| Line 534: | Line 534: | ||
| then | then | ||
| echo " | echo " | ||
| + | |||
| + | # Clean up the module environment | ||
| + | module purge | ||
| + | # Load the conversion and identification tools | ||
| + | module load ImageMagick/ | ||
| + | # Load the compilers | ||
| + | module load foss/2022b | ||
| # Get the directory in which the file is stored | # Get the directory in which the file is stored | ||
| dirname=$(dirname " | dirname=$(dirname " | ||
| filename=$(basename " | filename=$(basename " | ||
| + | | ||
| # Determine width and height of the image | # Determine width and height of the image | ||
| width=$(identify -format " | width=$(identify -format " | ||
| Line 544: | Line 551: | ||
| echo " | echo " | ||
| echo " | echo " | ||
| - | + | | |
| - | # Clean up the module environment | + | |
| - | module purge | + | |
| - | # Load the compilers | + | |
| - | module load foss/2020a | + | |
| # Compile the program | # Compile the program | ||
| make | make | ||
| Line 558: | Line 561: | ||
| # Convert the resulting file back to jpg format | # Convert the resulting file back to jpg format | ||
| convert -size ${width}x${height} | convert -size ${width}x${height} | ||
| + | | ||
| # Remove the intermediate files | # Remove the intermediate files | ||
| rm " | rm " | ||
| Line 583: | Line 586: | ||
| module purge | module purge | ||
| # Load the compilers | # Load the compilers | ||
| - | module load foss/2020a | + | module load foss/2022b |
| # Compile the program | # Compile the program | ||
| make | make | ||
| Line 622: | Line 625: | ||
| module purge | module purge | ||
| # Load the compilers | # Load the compilers | ||
| - | module load foss/2020a | + | module load foss/2022b |
| # Compile the program | # Compile the program | ||
| make | make | ||
| Line 646: | Line 649: | ||
| ** Since we are going to submit all work from a single job script, we need to make sure that the executable is in place, before we can run the script. ** This can be achieved by running the following commands: | ** Since we are going to submit all work from a single job script, we need to make sure that the executable is in place, before we can run the script. ** This can be achieved by running the following commands: | ||
| < | < | ||
| - | module load foss/2020a | + | module load foss/2022b |
| make | make | ||
| </ | </ | ||
| Line 652: | Line 655: | ||
| First we need a list of all images to be processed, and this time we are going to store this list in a text file instead of in a variable. | First we need a list of all images to be processed, and this time we are going to store this list in a text file instead of in a variable. | ||
| - | **Run a command (you can use '' | + | **Run a command (you can use '' |
| Now open the script '' | Now open the script '' | ||
| Line 665: | Line 668: | ||
| echo " | echo " | ||
| </ | </ | ||
| - | **Insert the right command between the parentheses: | + | **Insert the right command between the parentheses: |
| Finally, to make this a job array, we have to set a range that defines how many times this job is going to be run. Since we use '' | Finally, to make this a job array, we have to set a range that defines how many times this job is going to be run. Since we use '' | ||
| Line 689: | Line 692: | ||
| #SBATCH --mem=4GB | #SBATCH --mem=4GB | ||
| #SBATCH --time=00: | #SBATCH --time=00: | ||
| - | #SBATCH --partition=short | + | #SBATCH --partition=regular |
| #SBATCH --job-name=Edge_Detection | #SBATCH --job-name=Edge_Detection | ||
| #SBATCH --array=1-31 | #SBATCH --array=1-31 | ||
| Line 706: | Line 709: | ||
| image=$(cat " | image=$(cat " | ||
| echo " | echo " | ||
| + | |||
| + | # Clean up the module environment | ||
| + | module purge | ||
| + | # Load the conversion and identification tools | ||
| + | module load ImageMagick/ | ||
| # Get the directory in which the file is stored | # Get the directory in which the file is stored | ||
| Line 717: | Line 725: | ||
| echo " | echo " | ||
| | | ||
| - | # Clean up the module environment | ||
| - | module purge | ||
| - | # Load the compilers | ||
| - | module load foss/2020a | ||
| - | |||
| # Convert the jpg file to the rgb format for easy processing | # Convert the jpg file to the rgb format for easy processing | ||
| convert " | convert " | ||
| Line 755: | Line 758: | ||
| You can study the resulting image using the command: | You can study the resulting image using the command: | ||
| < | < | ||
| + | module load ImageMagick/ | ||
| display -resize 30% conv_Microcrystals.jpg | display -resize 30% conv_Microcrystals.jpg | ||
| </ | </ | ||
| Line 767: | Line 771: | ||
| #SBATCH --mem=4GB | #SBATCH --mem=4GB | ||
| #SBATCH --time=00: | #SBATCH --time=00: | ||
| - | #SBATCH --partition=short | + | #SBATCH --partition=regular |
| #SBATCH --job-name=Blurring | #SBATCH --job-name=Blurring | ||
| #SBATCH --output=singlecpu.out | #SBATCH --output=singlecpu.out | ||
| Line 774: | Line 778: | ||
| module purge | module purge | ||
| # Load the compilers | # Load the compilers | ||
| - | module load foss/2020a | + | module load foss/2022b |
| + | # Load the conversion tool | ||
| + | module load ImageMagick/ | ||
| # Compile the program | # Compile the program | ||
| make | make | ||
| Line 801: | Line 807: | ||
| After performing this exercise, you should obtain something like the following: | After performing this exercise, you should obtain something like the following: | ||
| - | {{:peregrine: | + | {{:habrok: |
| The '' | The '' | ||
| Line 836: | Line 842: | ||
| **Run the blurring app with 2, 4, 8, and 16 MPI tasks, each using one core and running on a separate node.** Make note of the runtimes, as well as the overall wallclock time. How does this differ from the previous exercise? | **Run the blurring app with 2, 4, 8, and 16 MPI tasks, each using one core and running on a separate node.** Make note of the runtimes, as well as the overall wallclock time. How does this differ from the previous exercise? | ||
| + | |||
| + | You can try to resubmit the job with 4 nodes to a '' | ||
| + | |||
| + | The " | ||
| + | |||
| <hidden Solution> | <hidden Solution> | ||
| Line 844: | Line 855: | ||
| After performing this exercise, you should get something like this: | After performing this exercise, you should get something like this: | ||
| - | {{:peregrine: | + | {{:habrok: |
| It is interesting to compare this graph with the one from exercise 2.2. The main difference is in '' | It is interesting to compare this graph with the one from exercise 2.2. The main difference is in '' | ||
| Line 866: | Line 877: | ||
| So far, you've been using either multiple CPUs on a single machine (OpenMP), or on multiple machines (MPI), to parallelize and speed up the image processing. In this exercise, you will have a look at how to use GPUs to achieve parallelization. In the folder named '' | So far, you've been using either multiple CPUs on a single machine (OpenMP), or on multiple machines (MPI), to parallelize and speed up the image processing. In this exercise, you will have a look at how to use GPUs to achieve parallelization. In the folder named '' | ||
| - | We've reserved one GPU node with 2 k40 GPUs for this course. The reservation is called '' | + | We've reserved one GPU node with 2 V100 GPUs for this course. The reservation is called '' |
| < | < | ||
| #SBATCH --reservation=advanced_course | #SBATCH --reservation=advanced_course | ||
| </ | </ | ||
| - | **Request 1 (one) GPU of type k40 on the '' | + | **Request 1 (one) GPU of type V100 on the '' |
| **Compare the times from exercise 2.2 with what you obtain now**. You might want to make the problem a bit harder by processing all the files from the '' | **Compare the times from exercise 2.2 with what you obtain now**. You might want to make the problem a bit harder by processing all the files from the '' | ||
| Line 876: | Line 887: | ||
| Programming the GPU is not for the faint of heart, though OpenACC makes it relatively easy. If you read C code, **study the code and try to figure out where is the GPU used**. If you plan to use an existing application with the GPU, you needn' | Programming the GPU is not for the faint of heart, though OpenACC makes it relatively easy. If you read C code, **study the code and try to figure out where is the GPU used**. If you plan to use an existing application with the GPU, you needn' | ||
| - | <hidden Solution> | + | <hidden Solution> |
| - | + | < | |
| - | ''# | + | #SBATCH --gpus-per-node=v100:1 |
| - | + | #SBATCH --reservation=advanced_course | |
| - | '' | + | </ |
| </ | </ | ||