Project Description CS 4370/6370 Fall 2022 Project # 1 – Matrix Addition and Matrix Multiplication Task 1: Basic Matrix Addition For this task, you will develop a complete CUDA program for integer...

Programing


Project Description CS 4370/6370 Fall 2022 Project # 1 – Matrix Addition and Matrix Multiplication Task 1: Basic Matrix Addition For this task, you will develop a complete CUDA program for integer matrix addition. You will add two two-dimensional matrices A, B on the device GPU in parallel. After the device matrix addition kernel function is invoked, and the addition result will be transferred back to the CPU. Your program will also compute the sum matrix of matrices A and B using the CPU. Your program should compare the device-computed result with the CPU-computed result. If it matches, then it will print out "Test PASSED" to the screen before exiting. The pseudo code for matrix addition on the CPU is as follows: void add_matrix_cpu(int *a, int *b, int *c, int N) { int i, j, index; for (i=0;i>>(a,b,c,N); } Use the following pseudo code for matrix initialization. int *a, *b, *c; A=malloc(sizeof(int)*N*N; //N is the size //then malloc for b and c Int init =1325; For (i=0;i< width;="" ++i)‏="" for="" (int="" j="0;" j="">< width;="" ++j)="" {="" int="" sum="0;" for="" (int="" k="0;" k="">< width;="" ++k)="" {="" int="" a="M[i" *="" width="" +="" k];="" int="" b="N[k" *="" width="" +="" j];="" sum="" +="a" *="" b;="" }="" p[i="" *="" width="" +="" j]="sum;" }="" }="" void="" main()="" {="" .....="" add_matrix(a,b,c,n);="" }="" the="" pseudo="" code="" for="" matrix="" addition="" on="" the="" gpu="" device="" is="" as="" follows:="" cuda="" c="" program="" __global__="" void="" matrixmulkernel(int*="" m,="" int*="" n,="" int="" *="" p,="" int="" width)="" {="" int="" row="blockIdx.y*blockDim.y+threadIdx.y;" int="" col="blockIdx.x*blockDim.x+threadIdx.x;" if="" ((row="">< width)="" &&="" (col="">< width))="" {="" int="" pvalue="0;" for="" (int="" k="0;" k="">< width;="" ++k)="" pvalue="" +="M[Row*Width+k]" *="" n[k*width+col];="" d_p[row*width+col]="Pvalue;" }="" }="" void="" main()="" {="" dim3="" dimblock(blocksize,blocksize,1);="" dim3="" dimgrid(="" ceiling="" (double="" (n)="" dimblock.x),="" ceiling="" (double="" (n)="" dimblock.y),="" 1="" );="">>>(a,b,c,N); } Use the following pseudo code for matrix initialization. int *a, *b, *c; A=malloc(sizeof(int)*N*N; //N is the size //then malloc for b and c Int init =1325; For (i=0;i
Sep 21, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here