Dynamically Allocated arrays and MPI

This is a discussion on Dynamically Allocated arrays and MPI within the C Programming forums, part of the General Programming Boards category; Hi all, I am looking to find some resources online that show how you might send/recv portions of a 3D ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    24

    Dynamically Allocated arrays and MPI

    Hi all,

    I am looking to find some resources online that show how you might send/recv portions of a 3D array in MPI using C.

    Basically, I want to be able to send each 2D layer of the 3D matrix to other processors, do some computes, get that 2D matrix back, and re-assemble it into the whole. I can't seem to find any resources that show how best to send the contiguous block of memory in MPI. In psuedo code, i imagine it being something like this

    Code:
    Declare, allocate, initialize 3DGrid[NX][NY][NZ]
    Loop over Z dimension
       
       Send all elements 3DGrid[*][*][NZ] to other processor from main processor
       Recieve elements 3DGrid[*][*][NZ] on the compute processor
       Do some computes on 3DGrid[*][*][NZ] on the compute processor
       Send modified elements 3DGrid[*][*][NZ] back to main processor from Compute processor
       Receieve 3DGrid[*][*][NZ] on main processor
       Reassemble 3DGrid[*][*][NZ] back into the main array on main processor
    
    end Z loop
    Has anyone ever done this before?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,058
    All there is to it is using the APIs provided by the MPI software, for ex. MPI_Send() and MPI_Recv().

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    Please refer this site , you may get a clear picture
    http://www.ats.ucla.edu/clusters/com...xamples/send.c

  4. #4
    Registered User
    Join Date
    Nov 2009
    Posts
    24
    I discovered that my problem was that I did not have my arrays defined contiguously. That being said, if I want to loop in this order:
    for z =...
    for x =...
    for y =...

    and access everything in the typical way 3darray[x][y][z] it will still be contiguous in memory. How do you do this? every definition I find about allocating the entire space, then space for the pointers doesnt seem to work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sorting whit MPI
    By isato in forum C Programming
    Replies: 0
    Last Post: 03-03-2009, 10:38 AM
  2. MPI help
    By cromologic in forum C Programming
    Replies: 3
    Last Post: 05-02-2008, 10:08 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21