[mpich-discuss] send/receive a vector
Nicolas Rosner
nrosner at gmail.com
Tue Jan 7 11:46:22 CST 2014
Hi Zahra,
> but it seems each send function just sending one value, the first one
That's because your second parameter there says to only send 1:
> rc = MPI_Send(x_in, 1, MPI_DOUBLE, dest, tag, MPI_COMM_WORLD);
See the "count" parameter in
http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Send.html
http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Recv.html
Cheers
N
On Tue, Jan 7, 2014 at 2:34 PM, Z.Rahmani <za.rahmani at gmail.com> wrote:
> For more information I copied some part of my code below:
>
> double x_in[1024];/* buffer for random numbers */
> int main(int argc,char** argv)
> {
> .....
>
> MPI_Init(&argc,&argv);
> MPI_Comm_size(MPI_COMM_WORLD,&numtasks);
> MPI_Comm_rank(MPI_COMM_WORLD,&rank);
> if (rank == 0 && numtasks != 5) {
> printf("Number of tasks = %d\n",numtasks);
> printf("Only need 5 tasks - extra will be ignored...\n");
> }
>
> MPI_Barrier(MPI_COMM_WORLD);
>
> /******** Thread 0 ************************************/
> if (rank == 0) {
>
> printf("task %d has started...\n", rank);
>
> dest = 1;
>
> /* send message to worker - message tag set to 1. */
> /* If return code indicates error quit */
>
> rc = MPI_Send(x_in, 1, MPI_DOUBLE, dest, tag, MPI_COMM_WORLD);
> if (rc != MPI_SUCCESS) {
> printf("Send error in task 0!\n");
> MPI_Abort(MPI_COMM_WORLD, rc);
> exit(1);}
> }
> .
> .
> .
> .
> .
>
> I am waiting for your advice.
>
> Thanks,
> Zahra
>
>
>
>
> On Tue, Jan 7, 2014 at 12:13 PM, Wesley Bland <wbland at mcs.anl.gov> wrote:
>>
>> It’s not clear what you’re asking for here. Could you provide a very small
>> (not your complete code) code example showing what you’re talking about?
>>
>> Thanks,
>> Wesley
>>
>> On Jan 7, 2014, at 11:03 AM, Z.Rahmani <za.rahmani at gmail.com> wrote:
>>
>> > Dear all,
>> >
>> > I want to send / receive a vector of integer values via mpich in a
>> > 5-thread plan but it seems each send function just sending one value, the
>> > first one. How can I resolve this problem? can I use loop commands inside a
>> > mpi function?
>> >
>> > thanks,
>> > Zahra
>> > _______________________________________________
>> > discuss mailing list discuss at mpich.org
>> > To manage subscription options or unsubscribe:
>> > https://lists.mpich.org/mailman/listinfo/discuss
>>
>> _______________________________________________
>> discuss mailing list discuss at mpich.org
>> To manage subscription options or unsubscribe:
>> https://lists.mpich.org/mailman/listinfo/discuss
>
>
>
> _______________________________________________
> discuss mailing list discuss at mpich.org
> To manage subscription options or unsubscribe:
> https://lists.mpich.org/mailman/listinfo/discuss
More information about the discuss
mailing list