Csnb594 - parallel computing - design parallel code to


Topics: Compiling C program with CUDA enabled on Windows using MS Visual Studio. In this session, we are going to learn to write parallel program using C language.

Outcome

CO 1 Design parallel code to solve a given problem, determine computational bottlenecks and optimize the performance of the code.
CO 2 Describe different parallel architectures, programming models, and algorithms for parallel programming.
CO 3 Analyze the time complexity of parallel algorithms as a function of the problem size and number of processors.
CO 4 Implement parallel solutions using Pthreads, OpenMP, MPI, Hybrid or GPU.

Activity 1, Question 1
How many block will be created in this program?

Activity 1, Question 2
How many thread will be created in each block?

ACTIVITY2 : EXTEND PROBLEM
Modify the source code in Activity 1 to meet the following criteria:

1.Create a new array.

2.The value of each element in this array (1) should be the current array index + 10.

3.The array created in (1) should be passed during the kernellauncher too.

4.The addKernel function should receive one (1)more value,which is the array created in (1).

5.Perform addition between each element of the both arrays.

ACTIVITY3: MULTIPLE BLOCKS

Modify the source code in Activity 2 to meet the following criteria:

1. Increase the elements of array to 1000.

2. Assume that we are using the old version of GPU.

3.Based on our data size, determine:
a.How many block should be created?
b.How many threads should be created in each block?

4.To access data in each index for multiple blocks and threads, you need to use this formula:

int i = threadIdx.x + blockIdx.x * blockDim.x;

5. Modify your source code to meet the new array size and its elements, the number of block, and thread.

ACTIVITY4: INCREASE DATA

Modify the source code in Activity 2 to meet the following criteria:

1. Increase the elements of array to 30000.

2. Assume that we are using the new version of GPU.

3. Based on our data size, determine:
a. How many block should be created?
b. How many threads should be created in each block?

4. Modify your source code to meet the new array size and its elements, the number of block, and thread.

Attachment:- Lab.pdf

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Csnb594 - parallel computing - design parallel code to
Reference No:- TGS02561114

Now Priced at $25 (50% Discount)

Recommended (92%)

Rated (4.4/5)