Starting from:
$35

$29

Assignment 4 Solution

In this assignment you will sort trajectories of Whales based on the lengths of the trajectories, using GPU.

The Whale trajectories will be provided using a text file. The format of the file is following. The file line will have two numbers N and M. N represents the number of trajectories, and M represents the number of stops each trajectory has. For simplicity, you can consider all Whales will take the same number of stops.

Then, there will be N lines in the file, each line will contain M Cartesian coordinates (M pair of numbers in each line) where each pair indicates a stop. All Whale starts from the location (0,0).

When completed, you GPU based program will read two file names from command line argument list. The first file will be the whale trajectory file. The program, then read the trajectory file, upload the data to GPU, and perform calculation as follows. For each data, your GPU will calculate the length of the data. The length will be calculated by summing the Euclidian distances between consecutive stops, starting from (0,0). Then the GPU will sort the trajectory based on the length of the trajectories. Once the sort complete, the host program will download the sorted the data from GPU, and save it to file, as name given in the second argument.

You need to develop the program using computing programming model either CUDA or OpenCL.

Sample input file (input.dat)

4 2

051010

2246

102034

104 410
Sample output file (output.dat)

2246

051010

104 410

102034
Explanation

0 5 10 10 (distance 16.18)

2 2 4 6 (distance 7.30)

10 20 3 4 (distance 39.83)

10 4 4 10 (distance 19.26)

Individual Distance Calculation:

051010

(0,0) -> (0,5) => 5

(0,5) -> (10,10) => 11.18034

Total Trajectory (5+11.18034) = 16.18
Page 2 of 2






Grading:

You need to submit the code that you will create for solving the given problem. Your program will be tested and graded under the programming environment you picked. You need to provide a setup instruction (as a setup.txt file with code). The grade will be based on the functionality (whether or not it works for the given settings) as well as the efficiency as guided in the following:


#
Description
Marks
1
Providing setup.txt
1
2
Program read files names from command line argument and generate output file
4
3
Program able to sort the data correctly*
10

Program works for sample input (2)


Program works for additional input file with lower dimensional data (4)


Program works for additional output file with higher dimensional data (4)

4
Program use GPU efficiently
5

    • Operations related to sort needs to be done on DEVICE, not on HOST. Host will only responsible a) reading the fille from the storage, upload the data on the device, download the result from the device, and save it too the storage. Any other operations on HOST will caused deduction of marks.

More products