concurrency - MPI Barrier and Printing -
this question has answer here:
- ordering output in mpi 4 answers
i working on simple mpi assignment row wise matrix multiplication.
i trying output matrix , reason order of prints out of order. 1 process designated print @ time, output if flushed, , mpi_barrier used. confused how prints being reordered.
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<p; i++){ for(k=0; k < pn; k++){ int row_pos=((i*pn)+k); if(id==i){ if( row_pos <n){ printf("[row: %10d][id: %3d]\t",row_pos,id); printf("|"); for(j=0; j<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 ur turn 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 }
here sample output:
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 data generated column data shared multiplication done 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
you can see of lines begin ends of other lines, code prints surround barrier.
i feel simple issue , tired see it
thanks help.
mpi specification not cover parallel i/o. purely implementation dependant.
Comments
Post a Comment