$34.99
CS Program
1 Introduction
There are two questions in this assignment. Each question carries 50 marks. Details are as under.
2 Question 1
The first task asks you to write CUDA code to initialize a random array of 1000000 elements. Provide the following:
1. Share the amount of time it takes to populate data in the array on the CPU. Use any timing function like clock() or hiresolution counters to note the amount of time it takes to generate data on the CPU. (+20)
2. Find a way to do the random data initialization of the array on the GPU. Do not just copy data from CPU array to GPU. Instead, you should use any library like cuRand but you should provide relevant references. Note the time it takes to run the kernel using the CUDA event API to calculate the amount of time needed by the GPU. (+20)
3. Copy the random array data generated on the GPU from the GPU to the CPU using cudaMemcpy. Note the amount of time it takes to move the data from GPU to the CPU. (+10)
3 Question 2
Write CUDA code to calculate the sum of 1000 elements array and output the sum. Calculate the total time for doing the calculation on the CPU as well as on the GPU. Use an appropriate execution configuration when you launch your kernel. Share the following information from your solution.
1. Code compiles and outputs as expected both on CPU and GPU. (+10)
2. Plot your results in a graph and show both your results (CPU/GPU) against different dataset sizes (1000,10000,100000) and different execution configurations (+30)
3. Do proper error handling in your code so any CUDA error should be reported to the user. (+10)
1
4 Deliverables
Submit a colab notebook (.ipynb) file with your regn. no. as the filename i.e. [ABxxxx Assgn1].ipynb. It should contain your solutions for Questions 1, 2 and the required work like graphs presented in a report form. Use the jupyter notebook text and code cells and write a consolidated report. No other file name or file type will be accepted.
5 Deductions Note
Failing to comply to the instructions will result in a deduction of 20 percent score.
2