<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-7"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 02/11/2010 01:42 PM, kostas pinokio wrote:
<blockquote cite="mid:232215.77230.qm@web28102.mail.ukl.yahoo.com"
type="cite">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;"
valign="top">HALLO,<br>
<br>
I would like to send a whole column of a dynamicly allocated array (in
C language).<br>
When i use derived datatypes(for example MPI_Type_vector) i can send a
column ONLY if i have static array but when i use dynamic allocation i
have problem!<br>
Please tell me one way to send a column of a dynamc allocated array.<br>
<br>
For example :<br>
MPI_Datatype columntype;<br>
MPI_Type_vector(10, 1, 10, MPI_INT, &columntype);<br>
MPI_Type_commit(&columntype);<br>
if(rank==0){<br>
dyn_array=(int **) calloc(10,sizeof(int *));<br>
for(i = 0; i < 10; i++){<br>
dyn_array[i] =(int *)
calloc(10,sizeof(int));<br>
}<br>
for(i=0;i<10;i++){ for(j=0;j<10;j++)
dyn_array[i][j]=9;}<br>
MPI_Send(&dyn_array[0][0], 1, columntype, dest,
tag,MPI_COMM_WORLD);<br>
}<br>
if(rank==1){<br>
MPI_Recv(&other_dyn_array[0][0], 1, columntype, 0, tag,
MPI_COMM_WORLD, &Stat);<br>
}<br>
<br>
the values of the receive are not correct!!<br>
</td>
</tr>
</tbody>
</table>
</blockquote>
<br>
The MPI_Type_vector assumes your data is contiguous in memory and this
is not the case in your code. <br>
As each raw is allocated using a different calloc. You need to arrange
the 2D array in memory in a more clever way:<br>
<br>
if(rank==0){<br>
dyn_array=(int **) calloc(10,sizeof(int *));<br>
dyn_array[0] = (int*) calloc(10*10, sizeof(int));<br>
for(i = 1; i < 10; i++)<br>
dyn_array[i] = dyn_array[0] + i*10;<br>
/*same code*/<br>
}<br>
<br>
this should work!<br>
<br>
cheers, Simone<br>
<blockquote cite="mid:232215.77230.qm@web28102.mail.ukl.yahoo.com"
type="cite">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;"
valign="top"><br>
Thank You!<br>
</td>
</tr>
</tbody>
</table>
<br>
__________________________________________________<br>
Χρησιμοποιείτε Yahoo!;<br>
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την
καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων <br>
<a class="moz-txt-link-freetext" href="http://mail.yahoo.gr">http://mail.yahoo.gr</a>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
mpi-forum mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mpi-forum@lists.mpi-forum.org">mpi-forum@lists.mpi-forum.org</a>
<a class="moz-txt-link-freetext" href="http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum">http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi-forum</a>
</pre>
</blockquote>
<br>
</body>
</html>