Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++
JAVA
PHP
SQL
Alice

ReadingQuestions


OpenMP.html

Reading Questions from other places

  • Open MP Videos 1-7 question
    Notes:
    • Video 4:
      • Near the end where he has you make a Hello World program (which you should do), replace the line
        int ID = 0;
        with
        int ID = omp_get_thread_num();
        He has this fix in video #5, but doesn't mention the error.
      • Also, add #include<stdio.h> at the beginning of the file.
      • Do not forget that to compile you need to use gcc -fopenmp helloWorld.c (or whatever you named your file) and run it by typing a.out.
    • Video 6
      • Download the code from the videos from Mattson_OMP_exercises.zip.
      • Unzip the file and it should have a folder called OMP_exercises.
      • Copy the folder to LOKI. (If you are using MobaXTerm, you can just drag the folder to the left side of the screen where the files are listed).
      • Navigate to the foloder and edit make.def as follows: Replace icl with gcc,   /Qopenmp with -fopenmp   and   obj with o.
      • To compile the pi.c program, type make pi. If you get errors, make sure you made the appropriate changes from the last step.
      • To run the pi program, type ./pi (don't as me why the "./" is necessary before the "pi". It has to do with paths and stuff.).
      • Now parallelize it as suggested in the video.
      • Note that the code related to omp_get_wtime has already been added, so you don't have to worry about that.
      • If you get stuck on parallelizing the code, move on to video 7 and fix your code using his solution.
      • FYI, as we move forward, you can compile and run the other programs the same way. Just replace pi with whatever the other program is called. (The makefile has rules for compiling all of the programs.)
    Questions
    1. Submit your pi.c program using Webhandin 385-SRQ
  • Open MP Videos 8-15 question
    1. Do the exercise at the end of video 8.
    2. If you have trouble, fix your solution according to his solution in video 9.
    3. What is a loop carry dependency?
    4. What is a reduction?
    5. Do the exercise from video 11. First, make a copy of your program and call the new copy pi2.c. Submit pi2.c using Webhandin 385-SRQ
  • Open MP Video 16-18 question
    1. In Video 17, make sure you spend some time trying to fix the mandel.c code. before moving on to video 18.
    2. In video 18, I think there is a very slight error in the code presented near the end of the video (just after 7:00). What is it?
  • Open MP Video 19-22 question
    1. At the end of video 19 he gives an exercise. Make sure you spend some time trying to figure it out before moving on to the next video.
    2. Turn in your finished linked.c from video 19 using Webhandin 385-SRQ
    3. Turn in your finished linked2.c (rename it before submitting it) from video 21 using Webhandin 385-SRQ. This one should attempt to use tasks.