Due: Tue, 2023/05/16 23:59
Please refer to the homework slides for problem description.
You should implement the parallel code with brute force algorithm. No need to implement Barnes-Hut Algorithm.
\[f_{ij} = \frac{Gm_im_j}{||q_j - q_i||^2} \cdot \frac{q_j - q_i}{||q_j - q_i||} = \frac{Gm_im_j(q_j - q_i)}{||q_j - q_i||^3}\]
\[F_i = \sum_{j \neq i} f_{ij} = \sum_{j \neq i} \frac{Gm_im_j(q_j - q_i)}{||q_j - q_i||^3}\]
\[F_i \approx \sum_{j \neq i} f_{ij} = \sum_{j \neq i} \frac{Gm_im_j(q_j - q_i)}{(||q_j - q_i||^2 + \varepsilon^2)^{ \frac{3}{2}}}\]
\[v_i(t) = v_i(t-\Delta t) + a_i(t) \cdot \Delta t\]
\[q_i(t) = q_i(t - \Delta t) + v_i(t) \cdot \Delta t\]
All the units given above are SI units, so you don’t need to do conversion. (If you find otherwise, it’s a bug! Please let the TAs know)
We use NCHC container for this homework.
We will compile your program with a command equivalent to:
Your program will be tested with a command equivalent to:
The input is a text file looking like this:
The first line of the input file contains three integers, which are:
Then there are N lines following, each contains 8 values:
double
.double
.double
.string
.The output is a text file looking like this:
gravity-device-id
is the ID of the gravity device that we want to destroy, missile-cost
is the cost of the missile. If there is no need to destroy the gravity devices, output -1 0. If destroying one gravity device couldn’t prevent the asteroid hitting the planet, output -1 0 as well. missile-cost is considered correct if the absolute error is within \(6*10^{4}\).Answer the following questions, in either English or Traditional Chinese.
Upload these files to eeclass:
hw5.cu
– the source code of your implementation.Makefile
– optional. Submit this file if you want to change the build command. If you didn’t submit this file, /tmp/dataset-nthu-ipc23/share/hw5/samples/Makefile
will be used.report.pdf
– your report.Please follow the naming listed above carefully. Failing to adhere to the names above will result to points deduction.
Refer to /tmp/dataset-nthu-ipc23/share/hw5
for sample test cases, source codes and tools.
The hw5-judge
command can be used to automatically judge your code against all sample test cases, it also submits your execution time to the scoreboard so you can compare your performance with others.
Scoreboard: https://apollo.cs.nthu.edu.tw/ipc23/scoreboard/hw5/).
To use it, run hw5-judge
in the directory that contains your code hw5.cu
. It will automatically search for Makefile
and use it to compile your code, or fallback to the TA provided /tmp/dataset-nthu-ipc23/share/hw5/samples/Makefile
otherwise. If code compiliation is successful, it will then run all the sample test cases, show you the results as well as update the scoreboard.
Verdict | Explaination |
---|---|
internal error | there is a bug in your code |
time limited exceeded+ | execution time > time limit + 10 seconds |
time limited exceeded | execution time > time limit |
runtime error | your program didn’t return 0 or is terminated by a signal |
no output | your program did not produce an output |
wrong answer | your output is incorrect |
accepted | you passed the test case |
spec