0% found this document useful (0 votes)
29 views

DAPC Assignement 4

The document describes steps to parallelize a ray tracing program using OpenMP. It involves creating a Task 4 directory, copying over a sequential ray tracing program, modifying it with OpenMP pragmas to parallelize loops, measuring performance with different thread counts and schedule clauses, and plotting the results. Key aspects are parallelizing the main pixel computation loop, measuring times, comparing performance for different numbers of threads and schedule types, and explaining any differences in performance.

Uploaded by

mine craft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

DAPC Assignement 4

The document describes steps to parallelize a ray tracing program using OpenMP. It involves creating a Task 4 directory, copying over a sequential ray tracing program, modifying it with OpenMP pragmas to parallelize loops, measuring performance with different thread counts and schedule clauses, and plotting the results. Key aspects are parallelizing the main pixel computation loop, measuring times, comparing performance for different numbers of threads and schedule types, and explaining any differences in performance.

Uploaded by

mine craft
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Note: conform to Astana IT-University DAPC 2021

Prepare your report as a google doc (make a copy of this template) and send a link to the
course email address: [email protected]

Report on task 4
Name: Sabyrbek Madiar
Group: IT-1902
E-mail: [email protected]

Main part:

Step 0:
We will be using the sequential ray tracing program from Task 2. Download and install
Mini-Rt library (https://github.com/georgy-schukin/mini-rt), if necessary.

Step 1: Prepare a directory for the Task 4


In the dapc2021-2 repository, in your personal directory:
● Create directory “Task 4”
● Copy sequential program raytracing.cpp to this new directory
● Rename the file to raytracing_openmp.cpp
You can also create Task 4 project directory in some other place and at the end copy it to
your personal folder in the repository.

Step 2: Implement parallel program with OpenMP


Use OpenMP to parallelize the sequential ray tracing program (edit
raytracing_openmp.cpp); the single image should be computed in parallel by many
threads. Use #pragma omp parallel for directive to parallelize the main computational
loop(s) (in which image is computed pixel by pixel). Compare performance with different
parameters of the schedule clause. Explain the results. Why do some parameters provide
better performance? Why are the others worse?
Step 3: Study performance of your parallel program

1. Use omp_get_wtime() to measure the execution time for the main loop:

double start = omp_get_wtime();


#pragma omp …
for(int x = …)
for(int y = …) {
const auto color = viewPlane.computePixel(
scene, x, y, numOfSamples);

}
double end = omp_get_wtime();

double execution_time = end - start;

std::cout << “Time = “ << execution_time << std::endl;

2. Select such a scene and rendering parameters (image size, number of samples,
depth of recursion, etc.), that the execution time of the program, when running on 1
thread, is more than several seconds.
3. Measure the execution time for the parallel program on 1, 2, 4, 8, 16 threads. For
accuracy you can do several runs (>5) on each number of threads and choose the
minimal time among runs for this number of threads.
4. Build plots (line plots or bar plots; see lecture slides) for:
a. the execution time (to demonstrate how it depends on the number of threads)
b. speedup
c. efficiency
You can also additionally present obtained values as tables.

Remember that you have to compare performance of the program with different parameters
of the schedule clause. So, you will have multiple lines on your plots for different versions of
parameters. For example:
Explain reasons for the (possible) difference in the performance of the program with different
schedule parameters (you may use other parameters than in the example here).

export OMP_NUM_THREADS=1
Static = 2.36839
Dynamic = 2.36717
Guided = 2.36703

export OMP_NUM_THREADS=2
Static = 1.56911
Dynamic = 1.19633
Guided = 1.56586

export OMP_NUM_THREADS=4
Static = 0.8665
Dynamic = 0.639667
Guided = 0.85846

export OMP_NUM_THREADS=8
Static = 0.571753
Dynamic = 0.382615
Guided = 0.49057

export OMP_NUM_THREADS=16
Static = 0.368069
Dynamic = 0.261348
Guided = 0.275038
Step 4: Commit and push your changes to the Gitlab server
Upload your source files (.cpp and .h) and scene files (.txt) in Task 4 directory to the Gitlab
server.
Conclusion:
During the task I worked with OPENMP for scheduling. I used static, dynamic and guided
schedules.

You might also like