ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 25 May 2017 My Price 8.00

#define VECTOR_N 1024

please  share its answer

#define VECTOR_N 1024
2 #define ELEMENT_N 256
3 const int DATA_N ¼ VECTOR_N * ELEMENT_N;
4 const int DATA_SZ ¼ DATA_N * sizeof(float);
5 const int RESULT_SZ ¼ VECTOR_N * sizeof(float);
. . .
6 float *d_A, *d_B, *d_C;
. . .
7 cudaMalloc((void **)&d_A, DATA_SZ);
8 cudaMalloc((void **)&d_B, DATA_SZ);
9 cudaMalloc((void **)&d_C, RESULT_SZ);
. . .
10 scalarProd>(d_C, d_A, d_B, ELEMENT_N);
11
12 __global__ void
13 scalarProd(float *d_C, float *d_A, float *d_B, int ElementN)
14 {
15 __shared__ float accumResult[ELEMENT_N];
16 //Current vectors bases
17 float *A ¼ d_A þ ElementN * blockIdx.x;
18 float *B ¼ d_B þ ElementN * blockIdx.x;
19 int tx ¼ threadIdx.x;
20
21 accumResult[tx] ¼ A[tx] * B[tx];
22
23 for(int stride ¼ ElementN /2; stride > 0; stride >>¼ 1)
24 {
25 __syncthreads();
26 if(tx 27 accumResult[tx] þ¼ accumResult[stride þ tx];
28 }
30 d_C[blockIdx.x] ¼ accumResult[0];
31 }
a. How many threads are there in total?
b. How many threads are there in a warp?
c. How many threads are there in a block?
d. How many global memory loads and stores are done for each
thread?

Answers

(11)
Status NEW Posted 25 May 2017 03:05 AM My Price 8.00

-----------

Not Rated(0)