




Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Os melhores documentos à venda: Trabalhos de alunos formados
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Comunidade
Peça ajuda à comunidade e tire suas dúvidas relacionadas ao estudo
Descubra as melhores universidades em seu país de acordo com os usuários da Docsity
Guias grátis
Baixe gratuitamente nossos guias de estudo, métodos para diminuir a ansiedade, dicas de TCC preparadas pelos professores da Docsity
Assume a hypothetical GPU with the following characteristics
Tipologia: Exercícios
1 / 8
Esta página não é visível na pré-visualização
Não perca as partes importantes!
a. Every single-precision number takes 4 bytes. In each iteration, the code reads 4 × 4 = 16 bytes from the main memory (the second access of a[i], b[i], c[i] and d[i] is from the cache) and writes 2 × 4 = 8 bytes to the main memory, in total 24 bytes. In each iteration, six floating point operations are executed. Therefore, the arithmetic intensity is 6 / 24 = 1/4 = 0.25. b. li $VL,16 # perform the first 16 ops li $r1,0 # initialize index loop: lv $v1,a+$r1 # load a lv $v3,b+$r1 # load b mulvv.s $v5,$v1,$v3 # ab lv $v2,c+$r1 # load c lv $v4,d+$r1 # load d mulvv.s $v6,$v2,$v4 # cd subvv.s $v5,$v5,$v6 # ab - cd sv $v5,u+$r1 # store u mulvv.s $v5,$v1,$v4 # ad mulvv.s $v6,$v2,$v3 # cb addvv.s $v5,$v5,$v6 # ad + cb sv $v5,v+$r1 # store v bnez $r1,else # check if first iteration li $VL, 64 # perform 64 ops for every iteration addi $r1,$r1,# 64 # first iteration, increment by 16 *4= j loop # guaranteed next iteration else: addi $r1,$r1,#256 # not first iteration,
skip: blt $r1,1600,loop # next iteration? c.
The total number of cycles taken is 54 + 39 + 39 + 48 + 87 * 6 + (87 + 72 + 87 + 144) * 6 + 87 = 3129 cycles. The number of cycles per result = 3129 / 400 = 7.8225 cycles.
int i = blockIdx.x*blockDim.x + threadIdx.x; if (i < n) { u[i] = a[i] * b[i] – c[i] * d[i]; v[i] = a[i] * d[i] + c[i] * b[i]; } }
Anti-dependencies S1 and S2 through B[i] S2 and S3 through A[i] S3 and S4 through C[i] Re-written code: /* Assume A1,B1,C1 are copies of A,B,C / for (i=0;i<100;i++) { X[i] = A 1 [i] * B 1 [i]; / S1 / B[i] = X[i] + c; / S2 / A[i] = C 1 [i] * c; / S3 / C[i] = D[i] * A[i]; / S4 */ } c. There is an anti-dependence between iteration i and i+1 for array B Re-written code: A[0] = A[0] + B[0]; for (i=0; i<99; i=i+1) { B[i+1] = C[i] + D[i]; A[i+1] = A[i+1] + B[i+1]; } B[100] = C[99] + D[99];