Discard variable &quot;tempo&quot;, without this continue getting error.<br><br>thanks<br><br><div><span class="gmail_quote">2007/1/23, Luiz Mendes &lt;<a href="mailto:luizmendesw@gmail.com">luizmendesw@gmail.com</a>&gt;:</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;">&nbsp;&nbsp; &nbsp;int opcao, dimensao,nome_tamanho, processo, num_procs;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;int coluna, contador_bytes, contador_bytes_parcial, interacao, contador_total_bytes;
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;char&nbsp; *palavra = NULL, *arquivo_nome;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *arquivo_pv;</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;char procname[MPI_MAX_PROCESSOR_NAME];</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;double inicio, termino, tempo_parcial, soma_tempo_total, valor;</span>

<br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;long long offset;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Datatype linhaMatriz;</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_File arquivo;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Status status;</span><br style="font-style: italic;"><span style="font-style: italic;">

&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Init(&amp;argc, &amp;argv);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Comm_rank(MPI_COMM_WORLD, &amp;processo);
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Comm_size(MPI_COMM_WORLD, &amp;num_procs);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Get_processor_name(procname,&amp;nome_tamanho);
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;while ((opcao = getopt(argc, argv, &quot;A:D:P:h&quot;)) != EOF)</span>

<br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;{</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;switch(opcao) </span><br style="font-style: italic;"><span style="font-style: italic;">

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case &#39;A&#39;: </span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;arquivo_pv =optarg;
</span>
<br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sprintf(arquivo_nome,&quot;%s&quot;,arquivo_pv);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case &#39;D&#39;: </span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sscanf (optarg, &quot;%d&quot;, &amp;dimensao);
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;break;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;case &#39;P&#39;:</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sprintf(arquivo_nome,&quot;pvfs2:/mnt/pvfs2/%s&quot;,arquivo_pv);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</span>
<br style="font-style: italic;">
<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;}</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><br style="font-style: italic;"><span style="font-style: italic;">

&nbsp;&nbsp; &nbsp;MPI_Type_contiguous(dimensao,MPI_DOUBLE,&amp;linhaMatriz);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Type_commit(&amp;linhaMatriz); </span><br style="font-style: italic;"><span style="font-style: italic;">

&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_File_open(MPI_COMM_WORLD, arquivo_nome, MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &amp;arquivo);</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;for(interacao=0; interacao&lt;(dimensao/num_procs);interacao++)</span><br style="font-style: italic;"><span style="font-style: italic;">

&nbsp;&nbsp; &nbsp;{</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;double matrizlocal[dimensao];</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;valor=processo*(dimensao/num_procs)*dimensao+interacao*dimensao;
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;offset=valor*sizeof(double);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for(coluna=0; coluna&lt;dimensao; coluna++)
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;matrizlocal[coluna]=valor+coluna;</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;MPI_File_set_view(arquivo, offset, MPI_DOUBLE, linhaMatriz, &quot;native&quot;, MPI_INFO_NULL);
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;inicio=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;MPI_File_write(arquivo, matrizlocal, 1, linhaMatriz, &amp;status);
</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;termino=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;tempo_parcial=termino-inicio;</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;contador_bytes_parcial+=sizeof(matrizlocal);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;soma_tempo_total+=tempo_parcial;</span><br style="font-style: italic;">

<span style="font-style: italic;">&nbsp;&nbsp; &nbsp;}</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_File_close(&amp;arquivo);</span><br style="font-style: italic;"><span style="font-weight: bold; font-style: italic;">

&nbsp;&nbsp; &nbsp;MPI_Allreduce(&amp;soma_tempo_total, &amp;tempo, dimensao, MPI_DOUBLE, MPI_MAX,MPI_COMM_WORLD);</span><br style="font-style: italic;"><span style="font-style: italic;">&nbsp;&nbsp; &nbsp;MPI_Finalize();&nbsp;&nbsp;&nbsp; <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>