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 10:44] – Revise exercise 1.2 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 286: | Line 286: | ||
if [ -e $1 ] | if [ -e $1 ] | ||
then | then | ||
- | # Clean up the module environment | + | |
- | module purge | + | module purge |
- | # Load the compilers | + | # Load the compilers |
- | module load foss/ | + | module load foss/ |
- | # Load the conversion tool | + | # Load the conversion tool |
- | module load ImageMagick/ | + | module load ImageMagick/ |
- | # Compile the program | + | # Compile the program |
- | make | + | make |
- | echo " | + | |
- | # Convert the jpg file to the rgb format for easy processing | + | |
- | convert $1 $1.rgb | + | convert $1 $1.rgb |
- | # Run the convolution filter program on the image | + | # Run the convolution filter program on the image |
- | ./ | + | ./ |
- | # Convert the resulting file back to jpg format | + | # Convert the resulting file back to jpg format |
- | convert -size 5184x3456 | + | convert -size 5184x3456 |
- | # Remove the intermediate files | + | |
- | rm $1.rgb conv_$1.rgb | + | rm $1.rgb conv_$1.rgb |
else | else | ||
echo " | echo " | ||
Line 318: | Line 318: | ||
As you probably have seen, when studying the jobscript, the image size needs to be specified to the convolution program and the convert program. So for now our script only works for images with a predefined size. | As you probably have seen, when studying the jobscript, the image size needs to be specified to the convolution program and the convert program. So for now our script only works for images with a predefined size. | ||
- | In order to fix this we need to be able to extract the image size from an image file. The program '' | + | In order to fix this we need to be able to extract the image size from an image file. The program '' |
**Run the program identify on the image file.** As you can see from the result the size of the image is returned by '' | **Run the program identify on the image file.** As you can see from the result the size of the image is returned by '' | ||
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 350: | Line 350: | ||
#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 | ||
Line 363: | Line 363: | ||
if [ -e $1 ] | if [ -e $1 ] | ||
then | then | ||
+ | # Clean up the module environment | ||
+ | module purge | ||
+ | # Load the conversion and identification tool | ||
+ | module load ImageMagick/ | ||
# Determine width and height of the image | # Determine width and height of the image | ||
width=$(identify -format " | width=$(identify -format " | ||
Line 369: | Line 373: | ||
echo " | echo " | ||
| | ||
- | # Clean up the module environment | ||
- | 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 418: | Line 420: | ||
#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 436: | Line 438: | ||
dirname=$(dirname $1) | dirname=$(dirname $1) | ||
filename=$(basename $1) | filename=$(basename $1) | ||
+ | | ||
+ | # Clean up the module environment | ||
+ | module purge | ||
+ | # Load the conversion and identification tools | ||
+ | module load ImageMagick/ | ||
+ | # Load the compilers | ||
+ | module load foss/2022b | ||
| | ||
# Determine width and height of the image | # Determine width and height of the image | ||
Line 443: | Line 452: | ||
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 515: | 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 529: | 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 539: | 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 553: | 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 578: | 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 617: | 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 641: | 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 647: | 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 660: | 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 684: | 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 701: | 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 712: | 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 750: | 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 762: | 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 769: | 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 796: | 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 831: | 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 839: | 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 861: | 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 871: | 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 | |
- | '' | + | </ |
</ | </ | ||