Discard variable "tempo", without this continue getting error.<br><br>thanks<br><br><div><span class="gmail_quote">2007/1/23, Luiz Mendes <<a href="mailto:luizmendesw@gmail.com">luizmendesw@gmail.com</a>>:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi all, i am with a problem in operation MPI_Allreduce. <br><br>The code is the following below:
<br><br><span style="font-style: italic;">int main(int argc, char *argv[])</span><br style="font-style: italic;"><span style="font-style: italic;">
{</span><br style="font-style: italic;"><span style="font-style: italic;"> int opcao, dimensao,nome_tamanho, processo, num_procs;</span><br style="font-style: italic;"><span style="font-style: italic;"> int coluna, contador_bytes, contador_bytes_parcial, interacao, contador_total_bytes;
</span><br style="font-style: italic;"><span style="font-style: italic;"> char *palavra = NULL, *arquivo_nome;</span><br style="font-style: italic;"><span style="font-style: italic;"> char *arquivo_pv;</span><br style="font-style: italic;">
<span style="font-style: italic;"> char procname[MPI_MAX_PROCESSOR_NAME];</span><br style="font-style: italic;"><span style="font-style: italic;"> double inicio, termino, tempo_parcial, soma_tempo_total, valor;</span>
<br style="font-style: italic;"><span style="font-style: italic;"> long long offset;</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Datatype linhaMatriz;</span><br style="font-style: italic;">
<span style="font-style: italic;"> MPI_File arquivo;</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Status status;</span><br style="font-style: italic;"><span style="font-style: italic;">
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Init(&argc, &argv);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Comm_rank(MPI_COMM_WORLD, &processo);
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Comm_size(MPI_COMM_WORLD, &num_procs);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Get_processor_name(procname,&nome_tamanho);
</span><br style="font-style: italic;"><span style="font-style: italic;"> </span><br style="font-style: italic;"><span style="font-style: italic;"> while ((opcao = getopt(argc, argv, "A:D:P:h")) != EOF)</span>
<br style="font-style: italic;"><span style="font-style: italic;"> {</span><br style="font-style: italic;"><span style="font-style: italic;"> switch(opcao) </span><br style="font-style: italic;"><span style="font-style: italic;">
{</span><br style="font-style: italic;"><span style="font-style: italic;"> case 'A': </span><br style="font-style: italic;"><span style="font-style: italic;"> arquivo_pv =optarg;
</span>
<br style="font-style: italic;"><span style="font-style: italic;"> sprintf(arquivo_nome,"%s",arquivo_pv);</span><br style="font-style: italic;"><span style="font-style: italic;"> break;
</span><br style="font-style: italic;"><span style="font-style: italic;"> case 'D': </span><br style="font-style: italic;"><span style="font-style: italic;"> sscanf (optarg, "%d", &dimensao);
</span><br style="font-style: italic;"><span style="font-style: italic;"> break;</span><br style="font-style: italic;"><span style="font-style: italic;"> case 'P':</span><br style="font-style: italic;">
<span style="font-style: italic;"> sprintf(arquivo_nome,"pvfs2:/mnt/pvfs2/%s",arquivo_pv);</span><br style="font-style: italic;"><span style="font-style: italic;"> } </span>
<br style="font-style: italic;">
<span style="font-style: italic;"> }</span><br style="font-style: italic;"><span style="font-style: italic;"> </span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">
MPI_Type_contiguous(dimensao,MPI_DOUBLE,&linhaMatriz);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Type_commit(&linhaMatriz); </span><br style="font-style: italic;"><span style="font-style: italic;">
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_open(MPI_COMM_WORLD, arquivo_nome, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &arquivo);</span><br style="font-style: italic;">
<span style="font-style: italic;"> </span><br style="font-style: italic;"><span style="font-style: italic;"> for(interacao=0; interacao<(dimensao/num_procs);interacao++)</span><br style="font-style: italic;"><span style="font-style: italic;">
{</span><br style="font-style: italic;"><span style="font-style: italic;"> double matrizlocal[dimensao];</span><br style="font-style: italic;"><span style="font-style: italic;"> valor=processo*(dimensao/num_procs)*dimensao+interacao*dimensao;
</span><br style="font-style: italic;"><span style="font-style: italic;"> offset=valor*sizeof(double);</span><br style="font-style: italic;"><span style="font-style: italic;"> for(coluna=0; coluna<dimensao; coluna++)
</span><br style="font-style: italic;"><span style="font-style: italic;"> {</span><br style="font-style: italic;"><span style="font-style: italic;"> matrizlocal[coluna]=valor+coluna;</span><br style="font-style: italic;">
<span style="font-style: italic;"> }</span><br style="font-style: italic;"><span style="font-style: italic;"> </span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_set_view(arquivo, offset, MPI_DOUBLE, linhaMatriz, "native", MPI_INFO_NULL);
</span><br style="font-style: italic;"><span style="font-style: italic;"> inicio=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_write(arquivo, matrizlocal, 1, linhaMatriz, &status);
</span><br style="font-style: italic;"><span style="font-style: italic;"> termino=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;"> tempo_parcial=termino-inicio;</span><br style="font-style: italic;">
<span style="font-style: italic;"> contador_bytes_parcial+=sizeof(matrizlocal);</span><br style="font-style: italic;"><span style="font-style: italic;"> soma_tempo_total+=tempo_parcial;</span><br style="font-style: italic;">
<span style="font-style: italic;"> }</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_close(&arquivo);</span><br style="font-style: italic;"><span style="font-weight: bold; font-style: italic;">
MPI_Allreduce(&soma_tempo_total, &tempo, dimensao, MPI_DOUBLE, MPI_MAX,MPI_COMM_WORLD);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Finalize(); <br>.......<br><br></span>
<br>Do you know what could be happening?<br><br>Thanks<br><span class="sg"><br>Luiz Mendes<br>
</span></blockquote></div><br>