Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In addition to what has been said about allocation of the arrays, you are sending/receiving wrong number of bytes. Count should be 1, not baris:</p> <pre><code>MPI_Send(&amp;(hasil[0][0]),1,rowtype,master,99,MPI_COMM_WORLD); </code></pre> <p>This is because at the given address &amp;(hasil[0][0]) (which is the same as hasil[0] by the way) you have allocated an array of size kolom:</p> <pre><code>hasil[t]=(int*)malloc(kolom*sizeof(int)); </code></pre> <p>Hence, you can not send more than kolom bytes from hasil[0]. Either you send kolom ints, or 1 rowtype.</p> <p>Also, I do not really understand what you want to send from each process and where you want to save it? You save all the data in one place in your MPI_Recv - in terima[0]. You can send/receive 1 rowtype of data from different processes to different places in terima, one after another. So you could write this on the master:</p> <pre><code>for(x=1;x&lt;numOfProc;x++){ MPI_Recv(terima[x],1,rowtype,x,99,MPI_COMM_WORLD,&amp;status); } </code></pre> <p>If on the other hand you want to transfer the entire hasil array from all the threads to the master (remember that this will overwrite the data if you only receive into terima) in your implementation you need to do it in a loop, because this is how you allocated your two-dimensional arrays:</p> <pre><code>for(i=1;i&lt;baris;i++){ MPI_Send(hasil[i],1,rowtype,master,99,MPI_COMM_WORLD,&amp;status); } </code></pre> <p><strong>Edit</strong> Sending an entire matrix of values will require changing the way you allocate your data. Instead of a two dimensional array with pointers, you allocate a contiguous piece of memory that can hold the entire matrix:</p> <pre><code>int *terima; terima=(int*)malloc(baris*kolom*sizeof(int)); </code></pre> <p>Then, instead of writing terima[t][m] you address the array using a linear index: terima[t*kolom + m]. Now you can send and receive the entire matrix using</p> <pre><code>MPI_Recv(terima,baris,rowtype,x,99,MPI_COMM_WORLD,&amp;status); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload