Note that there are some explanatory texts on larger screens.

plurals
  1. POMPI Barrier and Printing
    primarykey
    data
    text
    <p>I am working on a simple MPI assignment that does row wise Matrix Multiplication.</p> <p>I am trying to output the matrix and for some reason the order of the prints is out of order. Only one process is designated to print at a time, the output if flushed, and a MPI_Barrier is used. So I am confused how the prints are being reordered.</p> <pre><code>void print_matrix(int id, int p, int pn, int n, double **row, double *shared_col_data, double *resdata){ int i,j, k; for(i=0; i&lt;p; i++){ for(k=0; k &lt; pn; k++){ int row_pos=((i*pn)+k); if(id==i){ if( row_pos &lt;n){ printf("[ROW: %10d][ID: %3d]\t",row_pos,id); printf("|"); for(j=0; j&lt;n; j++){ printf("%.4f ",row[k][j]); } if(row_pos == (n/2)){ printf("| X |"); } else{ printf("| |"); } printf("%.4f ",shared_col_data[row_pos]); fflush(stdout); } }//End its ur turn to print MPI_Barrier (MPI_COMM_WORLD); if(id==0){ if(row_pos == (n/2)){ printf("| = |"); } else{ printf("| |"); } printf("%.4f|\n",resdata[row_pos]); fflush(stdout); } MPI_Barrier (MPI_COMM_WORLD); } }//End Processor Loop } </code></pre> <p>Here is a sample output:</p> <pre><code>Input Size(N): 12 Processors(P): 12 N per Processors(P): 1 ID: 3 SN: 3 EN: 3 ID: 0 SN: 0 EN: 0 ID: 2 SN: 2 EN: 2 ID: 4 SN: 4 EN: 4 ID: 11 SN: 11 EN: 11 ID: 7 SN: 7 EN: 7 ID: 8 SN: 8 EN: 8 ID: 6 SN: 6 EN: 6 ID: 10 SN: 10 EN: 10 ID: 1 SN: 1 EN: 1 ID: 9 SN: 9 EN: 9 ID: 5 SN: 5 EN: 5 All Data Generated Column Data Shared Multiplication Done All res Gather [ROW: 0][ID: 0] |0.5974 0.7066 0.9131 0.1548 0.4382 0.5132 0.3729 0.5554 0.7832 0.7953 0.5202 0.6986 | |0.8076 | |2.4959| [ROW: 1][ID: 1] |0.4320 0.9492 0.2266 0.1211 0.3904 0.9614 0.2000 0.7380 0.4471 0.3622 0.9844 0.1921 | |0.0051 | |2.3152| [ROW: 2][ID: 2] |0.2821 0.6740 0.9673 0.6623 0.6922 0.9760 0.8697 0.0096 0.6827 0.9590 0.2399 0.1100 | |0.2254 | |2.8286| [ROW: 3][ID: 3] |0.5915 0.1042 0.7262 0.8395 0.9665 0.9716 0.2252 0.7184 0.6054 0.8336 0.5033 0.2620 | |0.3670 | |2.8024| | |2.1632| [ROW: 4][ID: 4] |0.0821 0.3956 0.0252 0.9953 0.3822 0.4278 0.8978 0.7726 0.5235 0.2972 0.3229 0.4520 | |0.1409 [ROW: 5][ID: 5] |0.5684 0.0840 0.5961 0.7087 0.1331 0.1426 0.1554 0.3976 0.2051 0.1481 0.9468 0.7025 | |0.5302 | |2.1380| | = |2.7801| [ROW: 6][ID: 6] |0.7347 0.9194 0.3374 0.9823 0.1040 0.3878 0.7086 0.3132 0.4359 0.8223 0.2545 0.8752 | X |0.9129 [ROW: 7][ID: 7] |0.0464 0.6857 0.7146 0.6858 0.3210 0.2477 0.5767 0.2342 0.1406 0.5467 0.4063 0.0733 | |0.1262 | |1.8125| [ROW: 8][ID: 8] |0.6413 0.1076 0.2843 0.3515 0.9252 0.0349 0.0830 0.5063 0.9232 0.9900 0.5849 0.5612 | |0.0204 | |2.1263| [ROW: 9][ID: 9] |0.5292 0.3410 0.8543 0.5942 0.5822 0.3245 0.1719 0.9346 0.7611 0.3722 0.9653 0.4368 | |0.5167 | |2.4469| | |2.6545| [ROW: 10][ID: 10] |0.7641 0.6008 0.9687 0.9276 0.2462 0.2832 0.0131 0.0390 0.4860 0.6569 0.9390 0.7620 | |0.7972 | |2.0755| [ROW: 11][ID: 11] |0.7291 0.5953 0.6171 0.0396 0.5790 0.5262 0.5881 0.2631 0.9517 0.5118 0.0835 0.2115 | |0.2310 </code></pre> <p>You can see some of the lines begin with the ends of the other lines, but the code that prints those is surround by a barrier.</p> <p>I feel like it is a simple issue and I am to tired to see it</p> <p>Thanks for any help.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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