BSP/CGM Algorithms - USP
BSP/CGM Algorithms - USP
BSP/CGM Algorithms - USP
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Prefix Sum - <strong>BSP</strong><br />
21/24<br />
// Passo 7. Envie os valores para a raiz<br />
bsp_push_reg(&bsp, SomaPre, numelem*sizeof(int));<br />
bsp_put(&bsp, 0, SPre, SomaPre, tam*rank*sizeof(int), tam*sizeof(int));<br />
bsp_sync(&bsp);<br />
bsp_pop_reg(&bsp, SomaPre);<br />
// Passo 8. Armazene a soma de prefixos na tarefa 0<br />
if (rank == root) {<br />
// Passo 8.1. Abre o arquivo<br />
ArqS = fopen("ArquivoS.txt", "a");<br />
// Passo 8.2. Escreve no arquivo<br />
fprintf(ArqS, "%i %i\n", numelem, size);<br />
fclose(ArqS);<br />
for (i = 0; i < numelem; i++) {<br />
fprintf(ArqS, "%d ", SomaPre[i]);<br />
}<br />
}