程序代写 2022/3/22 20:55 Homework 5 – Computer Architecture I – ShanghaiTech Univers

2022/3/22 20:55 Homework 5 – Computer Architecture I – ShanghaiTech University
Homework 5 – with POSIX Threads
Computer Architecture I ShanghaiTech University HW4 HW5
Introduction

Copyright By PowCoder代写 加微信 powcoder

Ray tracing is an algorithm to generate photorealistic images or animations. In recent years, ray tracing is becoming more and more widely used. You may imagine that it is difficult to implement such an amazing algorithm, but actually, even a simple physically based rendering (PBR) tracer can be compacted to 300 lines of C code.
This homework is designed for you to enjoy the power of computer graphics while accelerating ray tracing with pthread. Don’t be afraid, you don’t have to understand the algorithm. Here is the template.
Your Mission
You only need to focus on main() in main.c. There are 5 nested loops here. You only need to make at least one of them parallel with pthread. Pay attention, some of the loops are designed as traps and will not gain much speedup if you try to parallel them. Try to figure out the traps.
Compile and Run the Template
https://robotics.shanghaitech.edu.cn/courses/ca/22s/hw/5/ 1/3

2022/3/22 20:55 Homework 5 – Computer Architecture I – ShanghaiTech University
time ./hw5 24
Run the above instructions in your terminal, and you will find an image called image.ppm appears. Double click, and you will see a noisy image. It is noisy because the quality of ray tracing depends on samples per pixel (SPP). In the above example, SPP is set to 24 in time ./hw5 24. You can try to set SPP to a larger number, such as 100, 200, 1000, …
1. You must make sure that the output image looks similar enough (do not need to be exactly the same) compared with the one generated by the template code when SPP is large.
2. You must use pthread, and OpenMP is not allowed for this homework.
3. You must make your code compilable with -Wpedantic -Wall -Wextra -Werror -std=c89.
4. You must avoid any memory leaks.
5. You must not output the image with hard code.
6. You must not use any third-party libraries.
7. You must not use any denosing techniques.
8. You must not use self-defined scene settings instead of using the settings defined in
scene.h, or use self-defined image writing functions instead of using the one given in image.h, because we may modify them.
1. You do not need to optimize the random number generator.
2. You do not need to worry about the load balancing of threads.
Submission and Grading
You only need to submit main.c to Autolab. However, it is difficult to check whether your output is OK enough on Autolab since it is an image, so the grading part is split into two stages. Autolab is used to test your speed, and later we will manually check the output image.
Case 1: If your output image is not similar enough to the one generated by the template code, you will definitely get 0.
Case 2: If your output image is similar enough to the one generated by the template code, you will be graded based on Autolab test cases as usual. There are 4 test cases and each of them is worth 10, 20, 30, 40 respectively. Thus the total score is 100.
You do not need to worry any about the similarity test if you just make it parallel with pthread.
Autolab Server Configurations
CPUs: 2 * Intel Xeon E5-2690 v4 2.6 GHz Details here Memory: 200GB 4-channel DDR4 (shared by all student tasks) 4 threads are allowed for each grading job
https://robotics.shanghaitech.edu.cn/courses/ca/22s/hw/5/ 2/3

2022/3/22 20:55 Homework 5 – Computer Architecture I – ShanghaiTech University
You can edit the scene by inserting or deleting spheres in scene.h. The variable camera_offset sometimes should be properly set to avoid the camera being blocked by big spheres.
Related Materials
1. in One Weekend
2. Global Illumination in 99 lines
3. Physically Based Rendering Tracer
Schwertfeger, Sören Chundong Wang Yi
Last modified: 2022-03-18
https://robotics.shanghaitech.edu.cn/courses/ca/22s/hw/5/ 3/3

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com