Q1 [Understanding 2-D blocks]
Modify the βpargpu.cuβ code (from the class examples) where number of threads are specified as a two dimensional variable. In CUDA, βdim3β data type can be used to specify two or three dimensional elements. Specifically, number of threads in each dimension of a 2-D block should be parameters to the program. Your program should be executed as follows,
$ ./q1 {number of elements} {rows} {cols}
Where rows * colsΒ <= 1024 (max threads per block}
Β
Q2 [XOR based Checksum]
Given randomly generated N numbers {Xβ1, Xββ2, β¦..Xβ βN}β as input, find out the XOR sum as follows,
SUM = Xβ1 XOR Xβ β2 XOR Xβ β3 β¦.. XOR Xβ βN
You can use maximum O(1) extra space to perform the operations on GPU. Further, the input copied to the device memory is not required to maintain the old values after completion of the program.
Your program should take two arguments, i.e., βnumber of elementsβ and a βrandom seedβ as command line parameter. In your program (main function) should execute βsrand (seed)β and generate random inputs before invoking the GPU kernel (refer class examples). Your program should print the final output in the console.





