Hi all, Rajeev<br><br>Well it is still early in Argonne now, here is 10pm lol<br><br>I was testing some reads, and i see that Collective read_all perform slower times to complete than read only operation. Is this correct? or it would be notable only in great files?
<br><br><div id="result_box" dir="ltr">Below, it follows the code:</div><br><span style="font-style: italic;">#include <stdio.h></span><br style="font-style: italic;"><span style="font-style: italic;">#include <stdlib.h
></span><br style="font-style: italic;"><span style="font-style: italic;">#include <unistd.h></span><br style="font-style: italic;"><span style="font-style: italic;">#include <string.h></span><br style="font-style: italic;">
<span style="font-style: italic;">#include <mpi.h></span><br style="font-style: italic;"><span style="font-style: italic;">#include <string.h></span><br style="font-style: italic;"><span style="font-style: italic;">
#define FILESIZE 1048576</span><br style="font-style: italic;"><span style="font-style: italic;">#define INTS_PER_BLK 16</span><br style="font-style: italic;"><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 *buf, rank, nprocs, nints, bufsize;</span><br style="font-style: italic;">
<span style="font-style: italic;"> double tempo_total, tempo1, tempo2, tempo;</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File fh;</span><br style="font-style: italic;"><span style="font-style: italic;">
MPI_Datatype filetype;</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, &rank);
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Comm_size(MPI_COMM_WORLD, &nprocs);</span><br style="font-style: italic;"><span style="font-style: italic;"> bufsize = FILESIZE/nprocs;
</span><br style="font-style: italic;"><span style="font-style: italic;"> buf = (int *) malloc(bufsize);</span><br style="font-style: italic;"><span style="font-style: italic;"> nints = bufsize/sizeof(int);</span><br style="font-style: italic;">
<span style="font-style: italic;"> MPI_File_open(MPI_COMM_WORLD, "datafile", MPI_MODE_RDONLY,</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_INFO_NULL, &fh);</span><br style="font-style: italic;">
<span style="font-style: italic;"> MPI_Type_vector(nints/INTS_PER_BLK, INTS_PER_BLK,INTS_PER_BLK*nprocs, MPI_INT, &filetype);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Type_commit(&filetype);
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_set_view(fh, INTS_PER_BLK*sizeof(int)*rank, MPI_INT,</span><br style="font-style: italic;"><span style="font-style: italic;"> filetype, "native", MPI_INFO_NULL);
</span><br style="font-style: italic;"><span style="font-style: italic;"> tempo1=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_File_read_all(fh, buf, nints, MPI_INT, MPI_STATUS_IGNORE);
</span><br style="font-style: italic;"><span style="font-style: italic;"> tempo2=MPI_Wtime();</span><br style="font-style: italic;"><span style="font-style: italic;"> tempo=tempo2-tempo1;</span><br style="font-style: italic;">
<span style="font-style: italic;"> printf("\nPrinting Time of current process--> foi %.10f",tempo);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Allreduce(&tempo, &tempo_total, 1, MPI_DOUBLE, MPI_MAX,MPI_COMM_WORLD);
</span><br style="font-style: italic;"><span style="font-style: italic;"> if(rank==0)</span><br style="font-style: italic;"><span style="font-style: italic;"> {</span><br style="font-style: italic;"><span style="font-style: italic;">
printf("\nThe longest time is %.10f\n",tempo_total);</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(&fh);</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Type_free(&filetype);</span><br style="font-style: italic;"><span style="font-style: italic;"> free(buf);
</span><br style="font-style: italic;"><span style="font-style: italic;"> MPI_Finalize();</span><br style="font-style: italic;"><span style="font-style: italic;"> return 0;</span><br style="font-style: italic;"><span style="font-style: italic;">
}</span><br><br><br>Thanks.<br>Luiz.<br><br><br><br><br><br><br><div><span class="gmail_quote">2007/1/23, Rajeev Thakur <<a href="mailto:thakur@mcs.anl.gov">thakur@mcs.anl.gov</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Unless dimensao is 1, the Allreduce won't work because the
input and output buffers are single element doubles (not
arrays).</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Rajeev</font></span></div><br>
<blockquote style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> Luiz Mendes
[mailto:<a href="mailto:luizmendesw@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">luizmendesw@gmail.com</a>] <br><b>Sent:</b> Tuesday, January 23, 2007 6:10
PM<br><b>To:</b> mpich-discuss<br><b>Cc:</b> Rajeev Thakur<br><b>Subject:</b>
Re: [MPICH] Re: Problems with allreduce<br></font><br></div><div><span class="e" id="q_110517b06b2c2833_1">
<div></div>Hi all, Rajeev<br><br>I correct this, and i made some
simplifications, and the problems appears to be caused by the fact of i add
double variable declarations.<br><br>It is very strange. Some light to
this?<br><br>Thanks<br>Luiz<br><br>
<div><span class="gmail_quote">2007/1/23, Rajeev Thakur <<a href="mailto:thakur@mcs.anl.gov" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">thakur@mcs.anl.gov</a>>:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Where
have you allocated space for arquivo_nome?</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Rajeev</font></span></div><br>
<blockquote style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a href="mailto:owner-mpich-discuss@mcs.anl.gov" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">owner-mpich-discuss@mcs.anl.gov</a> [mailto:<a href="mailto:owner-mpich-discuss@mcs.anl.gov" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
owner-mpich-discuss@mcs.anl.gov</a>] <b>On Behalf Of
</b>Luiz Mendes<br><b>Sent:</b> Tuesday, January 23, 2007 5:05
PM<br><b>To:</b> mpich-discuss<br><b>Subject:</b> [MPICH] Re: Problems
with allreduce<br></font><br></div>
<div><span>
<div></div>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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">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><br>Luiz
Mendes<br></span></blockquote></div><br></span></div></blockquote></div></blockquote></div><br></span></div></blockquote></div>
</blockquote></div><br>