Instructions
User Manual:
Open the PDF directly: View PDF .
Page Count: 1
EE 382C/EE 361C Multicore Computing Fall 2018
Assignment 4
Due: November 1
Instructor: Professor Vijay K. Garg (email: garg@ece.utexas.edu)
The goal of this assignment is to learn CUDA programming. For each of the problems in this assignment
use an efficient parallel algorithm.
1. (20 points) Write a parallel program in cuda that reads a text file “inp.txt” and performs various com-
putations on the data in the file. The file contains a list of integers in the range [0-999] separated by
commas. Your program should read this file in an array Aof integers.
(a, 10 points) Compute minA, the minimum value in the array.
(b, 10 points) Compute an array Bsuch that B[i] is the last digit of A[i] for all i.
2. (40 points) Read an array Aas in the first question.
(a, 10 points) Create an array Bof size 10 that keeps a count of the entries in each of the ranges:[0,99],[100,199],[200,299],...,[900,999].
For this part of the problem, maintain array Bin global memory of GPU.
(b, 10 points) Repeat part (a) but first use the shared memory in a block for updating the local copy of
Bin each block. Once every block is done, add all local copies to get the global copy of B.
(c, 20 points) Create an array of size 10 that uses Bto compute Cwhich keeps count of the entries
in each of the ranges:[0,99], [0,199], [0,299],. . . , [0, 999]. For this part of the problem, you must not use
array A.
3. (40 points) Read an array Aas in the first question. Compute an array Dsuch that Dconsists only of
odd numbers in A. You would need to determine the total number of odd numbers in A, and then copy
all the odd numbers from Ato Dpreserving their order in A.
1