[SOLVED] GPGPU-Assignment 2

30.00 $

Programming resource
Digital learning resource
Category:
βœ“ Practical programming resource
βœ“ Suitable for guided study and reference
βœ“ Tutor guidance available when needed

Description

5/5 - (1 vote)

Assignment #2: The Big Dot II

The dot product of two vectors π‘Ž = (π‘Ž$, Β  Β  Β  Β  Β  Β  π‘Žβ€™, Β  Β  Β  Β  Β  Β  Β  Β  Β  Β  …, π‘Ž()’ ) and 𝑏 = (𝑏$, Β  Β  Β  Β  Β  Β  Β  𝑏’, Β  Β  Β  Β   …, 𝑏()’ ), written π‘Ž βˆ™ 𝑏, is simply the sum of the component-by-component products:

π‘Ž βˆ™ 𝑏 = βˆ‘(-/)$’ π‘Ž- Γ— 𝑏-

Dot products are used extensively in computing and have a wide range of applications. For instance, in 3D graphics (n = 3), we often make use of the fact that π‘Ž βˆ™ 𝑏 = |π‘Ž||𝑏|π‘π‘œπ‘ πœƒ, where | | denotes vector length and πœƒ is the angle between the two vectors. Β In this assignment, you are expected to:

1. Β  Β  Write a CUDA code to compute in parallel the dot product of two random single precision floating-point vectors with size N = 1<<24;

2. Β  Β  Write two kernel functions for the dot product computation on GPU:

β€’ Β  Β  Β I) kernel1: use shared memory and parallel reduction to calculate partial sum on each thread block. (Add up all the partial sums on CPU after transferring all the partial sums back to host from device)

β€’ Β  Β  Β 2) kernel2: use shared memory, parallel reduction, and atomic function or atomic lock to perform the entire computation on GPU. (Transfer the final dot product result back to host from device)

3. Β  Β  Compare the time it takes for kernel1 and kernel 2. (Use cudaEventRecord() for the timing.)

4. Β  Β  Turn in your source code on Canvas with a readme.txt to explain whatever I need to know to run your code successfully.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.