Note that there are some explanatory texts on larger screens.

plurals
  1. POMatrix Vector multiplication in MPI and C
    primarykey
    data
    text
    <p>i'm trying to multiply a square matrix by a vector using MPI and C. I must use MPI_Allgather to send all the parts of the matrix to all the processes. This is what i have so far</p> <pre><code>#include "mpi.h" #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;math.h&gt; #include &lt;string.h&gt; #include &lt;time.h&gt; #define DIM 500 int main(int argc, char *argv[]) { int i, j, n; int nlocal; /* Number of locally stored rows of A */ double *fb; double a[DIM*DIM], b[DIM], x[DIM]; /* Will point to a buffer that stores the entire vector b */ int npes, myrank; MPI_Status status; MPI_Init(&amp;argc,&amp;argv); /* Get information about the communicator */ MPI_Comm_rank(MPI_COMM_WORLD, &amp;myrank); MPI_Comm_size(MPI_COMM_WORLD, &amp;npes); /* Allocate the memory that will store the entire vector b */ fb = (double*)malloc(n*sizeof(double)); nlocal = n/npes; /* Gather the entire vector b on each processor using MPI's ALLGATHER operation */ MPI_Allgather(b, nlocal, MPI_DOUBLE, fb, nlocal, MPI_DOUBLE, MPI_COMM_WORLD); /* Perform the matrix-vector multiplication involving the locally stored submatrix */ for (i=0; i&lt;nlocal; i++) { x[i] = 0.0; for (j=0; j&lt;n; j++) x[i] += a[i*n+j]*fb[j]; } free(fb); MPI_Finalize(); }//end main </code></pre> <p>OK Now it works! It compiles but then i get an mpi allgather internal error! I got this also with other solution i tried.</p> <pre><code>Fatal error in MPI_Allgather: Internal MPI error!, error stack: MPI_Allgather(961).......: MPI_Allgather(sbuf=0xa1828, scount=407275437, MPI_DOU BLE, rbuf=0xf61d0008, rcount=407275437, MPI_DOUBLE, MPI_COMM_WORLD) failed MPIR_Allgather_impl(807).: MPIR_Allgather(766)......: MPIR_Allgather_intra(560): MPIR_Localcopy(357)......: memcpy arguments alias each other, dst=0xb8513d70 src =0xa1828 len=-1036763800 Fatal error in MPI_Allgather: Internal MPI error!, error stack: MPI_Allgather(961).......: MPI_Allgather(sbuf=0xa1828, scount=407275437, MPI_DOU BLE, rbuf=0xf61d0008, rcount=407275437, MPI_DOUBLE, MPI_COMM_WORLD) failed MPIR_Allgather_impl(807).: MPIR_Allgather(766)......: MPIR_Allgather_intra(560): MPIR_Localcopy(357)......: memcpy arguments alias each other, dst=0x3cb9b840 src =0xa1828 len=-1036763800 Fatal error in MPI_Allgather: Internal MPI error!, error stack: MPI_Allgather(961).......: MPI_Allgather(sbuf=0xa1828, scount=407275437, MPI_DOU BLE, rbuf=0xf61d0008, rcount=407275437, MPI_DOUBLE, MPI_COMM_WORLD) failed MPIR_Allgather_impl(807).: MPIR_Allgather(766)......: MPIR_Allgather_intra(560): MPIR_Localcopy(357)......: memcpy arguments alias each other, dst=0x7a857ad8 src =0xa1828 len=-1036763800 </code></pre> <p>Can anyone help me?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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