Program that computes square matrix multiplication, C/C++ Programming

Assignment Help:

Goal:

Design a program that computes square matrix multiplication on GPU using CUDA. Write the code in C. In particular, your implementation should obey the following requirements:

1. The program must be general enough to handle matrix sizes beyond the GPU capacity.

2. The GPU capacity should not be hardcoded, but should be queried during execution.

3. The kernel implementation should be such that the execution configuration (number of blocks and threads/block) affects the performance but not the results of the kernel invocation.

Methodology

NOTE: In this lab, you will not use SHARED MEMORY!

The program will be tested on the workstations and the CUDA server using the following matrix sizes:

1. Use C++ compiler (g++) to compile your code, and use new operator instead of malloc() to dynamically allocate memory (malloc may fail on very large memory allocations).

2. Try to design the data structures so to minimize the number of memory transactions between host and device (CPU and GPU).

3. DO NOT START TO CODE IMMEDIATELY. Spend some time designing your solution.

i. How do you handle matrix sizes exceeding the GPU capacity?

ii. How do you represent the matrices?

iii. Which memory transfers are involved with matrices within and beyond the GPU capacity?

iv. When designing the kernel, which work is performed by each thread? How do you correlate each thread with the data it processes?

4. Kernel calls use shared memory and registers. Your kernel should not use shared memory. To see how many registers are used by each thread, you can have a look at the GPU assembly file.The assembly file (called PTX file) can be generated by calling:

nvcc -ptx myfile.cu

This will generate myfile.ptx.

The PTX file will show you the assembly representation of your kernel. In particular, it will show you the code execute by each thread (as you know, all threads execute the same code!). The PTX file will include an area where the registers are declared. For example:

.reg .u16 %rh<4>;//16 bit registers

.reg .u32 %r<9>; //32 bit registers

.reg .u64 %rd<10>;//64 bit registers

.reg .pred %p<3>; // registers used for predication

If you know: how many registers are used by each thread and how many registers are available on the GPU, you can easily determine what is the maximum number of threads that you can run (for your particular kernel).

5. Use the occupancy calculator to calculate the optimal point for configuring the kernel.

Questions:

1. Run your kernel with different number of blocks and of threads/block and see how this affects the performance. Report GPU occupancy and execution time, and discuss the results. Consider execution configurations that are trivially bad, and compare them with good execution configurations. How do you know in advance that some configurations are "bad"? And what is a "good" execution configuration?

2. What is the largest execution configuration that you can use without exceeding the resources available on the GPU in use?


Related Discussions:- Program that computes square matrix multiplication

Link list, For this program you will add and test 2 new member functions to...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

Required, requiredrequiredrequiredrequiredrequiredrequiredrequiredrequired

requiredrequiredrequiredrequiredrequiredrequiredrequiredrequired

Stack, write a simple c++ program to implement a stack: 1. push 2. pop

write a simple c++ program to implement a stack: 1. push 2. pop

In p = new fred(), Q: In p = new Fred(), does the Fred memory "leak" if  Fr...

Q: In p = new Fred(), does the Fred memory "leak" if  Fred constructor throws an exception? A: No.         If an exception take place during the Fred constructor of p = new F

Sort wars, Explain each of the algorithms in a way that would be understand...

Explain each of the algorithms in a way that would be understandable to an intelligent person who is not familiar with programming. You should not use any code (or even pseudo code

String, Byteland county is very famous for luminous jewels. Luminous jewels...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Program, c | c-c-c-c-c | c-c-C-c-c | ...

c | c-c-c-c-c | c-c-C-c-c | c find distance between difftent carbon atom by programing

What is object variable, The definition of an object(variable ): We can...

The definition of an object(variable ): We can explain a variable(set memory to the variable) in the following ways. e.g. double salary; int month; When more than o

Pointers with an array, // Basic pointer code #include "stdafx.h" #in...

// Basic pointer code #include "stdafx.h" #include iostream using namespace std; int _tmain(int argc, _TCHAR* argv[]) {             int FirstNumber, SecondNumber;

, Question 1 / 1 You have an N x N chessboard and you wish to place N king...

Question 1 / 1 You have an N x N chessboard and you wish to place N kings on it. Each row and column should contain exactly one king, and no two kings should attack each other (two

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd