subject
Computers and Technology, 25.02.2020 21:45 wreckem

The following scalar product code tests your understanding of the basic CUDA model. The code computes 1024 dot products, each of which is calculated from a pair of 256-element vectors. Assume that the code is executed on G80. Use the code to answer the following questions.1 #define VECTOR_N 10242 #define ELEMENT_N 2563 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);1112 __global__ void13 scalarProd(float *d_C, float *d_A, float *d_B, int ElementN)14 {15 __shared__ float accumResult[ELEMENT_N];16 //Current vectors bases17 float *A ¼ d_A þ ElementN * blockIdx. x;18 float *B ¼ d_B þ ElementN * blockIdx. x;19 int tx ¼ threadIdx. x;2021 accumResult[tx] ¼ A[tx] * B[tx];2223 for(int stride ¼ ElementN /2; stride > 0; stride >>¼ 1)24 {25 __syncthreads();26 if(tx < stride)27 accumResult[tx] þ¼ accumResult[stride þ tx];28 }30 d_C[blockIdx. x] ¼ accumResult[0];31 }The following scalar product code tests your understanding of the basic CUDA model. The following code computes 1024 dot products, each of which is calculated from a pair of 256-element vectors. Assume that the code is executed on the G80. Use the code to answer the questions that follow. How many threads are there in total?How many threads are there in a warp?How many threads are there in a block?How many global memory loads and stores are done for each thread?How many accesses to shared memory are done for each block? (4pts.)List the source code lines, if any, that cause shared memory bank conflicts. (2 pts.)How many iterations of the for loop (Line 23) will have branch divergence? Show your derivation. Identify an opportunity to significantly reduce the bandwidth requirement on the global memory. How would you achieve this?How many accesses can you eliminate?

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:00, jairus34
We as humans write math expression in infix notation, e. g. 5 + 2 (the operators are written in-between the operands). in a computer’s language, however, it is preferred to have the operators on the right side of the operands, i. e. 5 2 +. for more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix. write a program that takes an “infix” expression as input, uses stacks to convert it into postfix expression, and finally evaluates it. it must support the following operations: + - / * ^ % (example infix expression: (7 - 3) / (2 + 2)postfix expression: 7 3 - 2 2 + /result: 1guidelines: 1. you will need to use stacks in three placesa. one for the parenthesis check [char stack]b. one during infix to postfix [char stack]c. one during evaluation [int stack]for a and b above, you can use same array and same push, pop method as both ofthem are char. but for evaluation you have int stack and you might consider to createanother push pop method to handle it. maybe push_int, pop_int, etc. or find otherstrategy to utilize existing push pop method2. you can create a function for obtaining operator priority. that function should take anoperator as input and return its priority as an integer. this function will you a lot andreduce repeated code3. during evaluation you will need to convert char into integer. example for single digit: char c = '5'; int x = c - '0';
Answers: 2
image
Computers and Technology, 22.06.2019 14:30, qxchung7310
The “rule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
image
Computers and Technology, 22.06.2019 19:30, andyromero
Once the data center routes to the destination server that hosts the website, what's the next step in the internet process? user’s browser renders html code from destination server into web page request goes through router/model and isp request routed to nameserver and datacenter
Answers: 2
image
Computers and Technology, 23.06.2019 23:30, cam961
What are "open-loop" and "closed-loop" systems
Answers: 1
You know the right answer?
The following scalar product code tests your understanding of the basic CUDA model. The code compute...

Questions in other subjects:

Konu
Mathematics, 08.07.2019 12:00
Konu
Mathematics, 08.07.2019 12:00