void IMB_i_alloc(int** B, size_t Len, char* where ) /* Allocates int memory Input variables: -Len (type int) #int's to allocate -where (type char*) Comment (marker for calling place) In/out variables: -B (type int**) *B contains allocated memory */ { Len=max(1,Len); *B = (int*) IMB_v_alloc(sizeof(int)*Len, where); }
void IMB_alloc_aux(size_t L, char* where) /* Allocates global auxiliary memory AUX Input variables: -L (type int) #Bytes to allocate -where (type char*) Comment (marker for calling place) */ { L += asize; if( AUX_LEN < L) { if( AUX_LEN>0 ) IMB_v_free((void**)&AUX); AUX = IMB_v_alloc(L, where); AUX_LEN = AUX ? L : 0; } }
void IMB_print_info() /* Prints MPI_Info selections (MPI-2 only) */ { int nkeys,ikey,vlen,exists; MPI_Info tmp_info; char key[MPI_MAX_INFO_KEY], *value; IMB_user_set_info(&tmp_info); /* July 2002 fix V2.2.1: handle NULL case */ if( tmp_info!=MPI_INFO_NULL ) { /* end change */ MPI_Info_get_nkeys(tmp_info, &nkeys); if( nkeys > 0) fprintf(unit,"# Got %d Info-keys:\n\n",nkeys); for( ikey=0; ikey<nkeys; ikey++ ) { MPI_Info_get_nthkey(tmp_info, ikey, key); MPI_Info_get_valuelen(tmp_info, key, &vlen, &exists); value = (char*)IMB_v_alloc((vlen+1)* sizeof(char), "Print_Info"); MPI_Info_get(tmp_info, key, vlen, value, &exists); printf("# %s = \"%s\"\n",key,value); IMB_v_free ((void**)&value); } MPI_Info_free(&tmp_info); /* July 2002 fix V2.2.1: end if */ } /* end change */ }
void IMB_alloc_buf(struct comm_info* c_info, char* where, size_t s_len, size_t r_len) /* Allocates send/recv buffers for message passing Input variables: -where (type char*) Comment (marker for calling place) -s_len (type int) Send buffer length (bytes) -r_len (type int) Recv buffer length (bytes) In/out variables: -c_info (type struct comm_info*) Collection of all base data for MPI; see [1] for more information Send/Recv buffer components get allocated */ { /* July 2002 V2.2.1 change: use MPI_Alloc_mem */ #if ( defined EXT || defined MPIIO || RMA ) MPI_Aint slen = (MPI_Aint)(max(1,s_len)); MPI_Aint rlen = (MPI_Aint)(max(1,r_len)); int ierr; #else s_len=max(1,s_len); r_len=max(1,r_len); #endif if( c_info->s_alloc < s_len ) { /* July 2002 V2.2.1 change: use MPI_Alloc_mem */ #if ( defined EXT || defined MPIIO || RMA) if (c_info->s_buffer) MPI_Free_mem(c_info->s_buffer); ierr=MPI_Alloc_mem(slen, MPI_INFO_NULL, &c_info->s_buffer); MPI_ERRHAND(ierr); c_info->s_alloc = slen; #else IMB_v_free((void**)&c_info->s_buffer); c_info->s_buffer = IMB_v_alloc(s_len,where); c_info->s_alloc = s_len; #endif c_info->s_data = (assign_type*)c_info->s_buffer; } if( c_info->r_alloc < r_len ) { /* July 2002 V2.2.1 change: use MPI_Alloc_mem */ #if ( defined EXT || defined MPIIO || RMA) if (c_info->r_buffer) MPI_Free_mem(c_info->r_buffer); ierr=MPI_Alloc_mem(rlen, MPI_INFO_NULL, &c_info->r_buffer); MPI_ERRHAND(ierr); c_info->r_alloc = rlen; #else IMB_v_free((void**)&c_info->r_buffer); c_info->r_buffer = IMB_v_alloc(r_len,where); c_info->r_alloc = r_len; #endif c_info->r_data = (assign_type*)c_info->r_buffer; } }
void IMB_print_array(int* Array, int N, int disp_N, int M, char* txt, FILE* unit) /* Formattedly prints to stdout a M by N int array Input variables: -Array (type int*) Array to be printed -N (type int) Number of rows to be printed -disp_N (type int) Displacement in Array where frist row begins -M (type int) Number of columns -txt (type char*) Accompanying text -unit (type FILE*) Output unit */ { #define MAX_SHOW 1024 int i,j; char* outtxt; int do_out; do_out=0; if( txt ) if( strcmp(txt,"") ) { outtxt = (char*)IMB_v_alloc((strlen(txt)+6)*sizeof(char)," IMB_print_array "); do_out=1; } if( N<=1 ) { if( M>MAX_SHOW ) { fprintf(unit,"# "); IMB_print_int_row(unit, Array, MAX_SHOW/2); fprintf(unit," ... "); IMB_print_int_row(unit, &Array[M-MAX_SHOW/2], MAX_SHOW/2); } else { if( do_out ) fprintf(unit,"# %s",txt); else fprintf(unit,"# "); IMB_print_int_row(unit, Array, M); } } else if ( N<=MAX_SHOW ) { int zero=0, one=1; for( i=0; i<N; i++) { if( do_out ) sprintf(outtxt,"%s %d: ",txt,disp_N+i); else outtxt=(char*)NULL; IMB_print_array(&Array[i*M], one, zero, M, outtxt, unit); fprintf(unit,"\n");} } /*for( i=0...*/ else { int disp; disp=0; IMB_print_array(Array, MAX_SHOW/2, disp, M, txt, unit); fprintf(unit,"# . \n"); fprintf(unit,"# . \n"); disp=N-MAX_SHOW/2; IMB_print_array(&Array[(N-MAX_SHOW/2)*M], MAX_SHOW/2, disp, M, txt, unit); } if( do_out ) { IMB_v_free((void**)&outtxt); } }
/* Introduce new ITERATIONS object */ void IMB_output(struct comm_info* c_info, struct Bench* Bmark, MODES BMODE, int header, int size, struct iter_schedule* ITERATIONS, double *time) /* >> IMB 3.1 */ /* Input variables: -c_info (type struct comm_info*) Collection of all base data for MPI; see [1] for more information -Bmark (type struct Bench*) (For explanation of struct Bench type: describes all aspects of modes of a benchmark; see [1] for more information) The actual benchmark -BMODE (type MODES) The actual benchmark mode (if relevant; only MPI-2 case, see [1]) -header (type int) 1/0 for do/don't print table headers -size (type int) Benchmark message size -ITERATIONS (type struct iter_schedule) Benchmark repetition descr. object -time (type double *) Benchmark timing outcome 3 numbers (min/max/average) */ { double scaled_time[MAX_TIME_ID]; int i,i_gr; int li_len; int out_format; const int DO_OUT = (c_info->w_rank == 0) ? 1 : 0; const int GROUP_OUT = (c_info->group_mode > 0) ? 1 : 0; ierr = 0; if (DO_OUT) { /* Fix IMB_1.0.1: NULL all_times before allocation */ IMB_v_free((void**)&all_times); all_times = (double*)IMB_v_alloc(c_info->w_num_procs * Bmark->Ntimes * sizeof(double), "Output 1"); #ifdef CHECK if(!all_defect) { all_defect = (double*)IMB_v_alloc(c_info->w_num_procs * sizeof(double), "Output 1"); for(i=0; i<c_info->w_num_procs; i++) all_defect[i]=0.; } #endif } /*if (DO_OUT)*/ /* Scale the timings */ for(i=0; i < Bmark->Ntimes; i++) { scaled_time[i] = time[i] * SCALE * Bmark->scale_time; } /* collect all times */ ierr=MPI_Gather(scaled_time,Bmark->Ntimes,MPI_DOUBLE,all_times,Bmark->Ntimes,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_ERRHAND(ierr); #ifdef CHECK /* collect all defects */ ierr=MPI_Gather(&defect,1,MPI_DOUBLE,all_defect,1,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_ERRHAND(ierr); #endif if( DO_OUT ) { BTYPES type= Bmark->RUN_MODES[0].type; const int n_groups = GROUP_OUT ? c_info->n_groups : 1; if ( Bmark->RUN_MODES[0].NONBLOCKING && type != Sync) { out_format = OUT_OVERLAP; } else if ( (type == SingleTransfer && c_info->group_mode != 0) || type == MultPassiveTransfer || type == SingleElementTransfer ) { out_format = OUT_TIME_AND_BW; } else if ( type == ParallelTransfer || type == SingleTransfer ) { out_format = OUT_TIME_RANGE_AND_BW; } else if ( type == ParallelTransferMsgRate ) { out_format = OUT_BW_AND_MSG_RATE; } else if (type == Collective ) { #ifdef MPIIO out_format = OUT_TIME_RANGE_AND_BW; #else out_format = OUT_TIME_RANGE; #endif } else { out_format = OUT_SYNC; } if (header) { IMB_print_header (out_format, Bmark, c_info, BMODE); } if( GROUP_OUT ) { fprintf(unit,"\n"); } for(i_gr = 0; i_gr < n_groups; i_gr++) { IMB_display_times(Bmark, all_times, c_info, i_gr, ITERATIONS->n_sample, size, out_format); } } /*if( DO_OUT )*/ }
/* Introduce new ITERATIONS object */ void IMB_output(struct comm_info* c_info, struct Bench* Bmark, MODES BMODE, int header, int size, struct iter_schedule* ITERATIONS, double *time) /* >> IMB 3.1 */ /* Input variables: -c_info (type struct comm_info*) Collection of all base data for MPI; see [1] for more information -Bmark (type struct Bench*) (For explanation of struct Bench type: describes all aspects of modes of a benchmark; see [1] for more information) The actual benchmark -BMODE (type MODES) The actual benchmark mode (if relevant; only MPI-2 case, see [1]) -header (type int) 1/0 for do/don't print table headers -size (type int) Benchmark message size -ITERATIONS (type struct iter_schedule) Benchmark repetition descr. object -time (type double *) Benchmark timing outcome 3 numbers (min/max/average) */ { double scaled_time[MAX_TIMINGS]; int DO_OUT; int GROUP_OUT; int i,i_gr; int li_len; int edit_type; ierr = 0; DO_OUT = (c_info->w_rank == 0 ); GROUP_OUT = (c_info->group_mode > 0 ); if (DO_OUT) { /* Fix IMB_1.0.1: NULL all_times before allocation */ IMB_v_free((void**)&all_times); all_times = (double*)IMB_v_alloc(c_info->w_num_procs * Bmark->Ntimes * sizeof(double), "Output 1"); #ifdef CHECK if(!all_defect) { all_defect = (double*)IMB_v_alloc(c_info->w_num_procs * sizeof(double), "Output 1"); for(i=0; i<c_info->w_num_procs; i++) all_defect[i]=0.; } #endif } /*if (DO_OUT)*/ /* Scale the timings */ for(i=0; i<Bmark->Ntimes; i++) scaled_time[i] = time[i] * SCALE * Bmark->scale_time; /* collect all times */ ierr=MPI_Gather(scaled_time,Bmark->Ntimes,MPI_DOUBLE,all_times,Bmark->Ntimes,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_ERRHAND(ierr); #ifdef CHECK /* collect all defects */ ierr=MPI_Gather(&defect,1,MPI_DOUBLE,all_defect,1,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_ERRHAND(ierr); #endif if( DO_OUT ) { BTYPES type= Bmark->RUN_MODES[0].type; if ( Bmark->RUN_MODES[0].NONBLOCKING ) edit_type = 4; else if ( type == SingleTransfer && c_info->group_mode != 0 ) edit_type=0; else if ( type == ParallelTransfer || type == SingleTransfer ) edit_type=1; else if (type == Collective ) #ifdef MPIIO edit_type=1; #else edit_type=2; #endif else edit_type=3; if( header ) { fprintf(unit,"\n"); /* FOR GNUPLOT: CURVE SEPERATOR */ if( GROUP_OUT ) {strcpy(aux_string,"&Group") ; li_len=1;} else {strcpy(aux_string,""); li_len=0;} if ( edit_type == 0 ) { li_len+=4; strcat(aux_string,"&#bytes&#repetitions&t[usec]&Mbytes/sec&"); } else if ( edit_type == 1 ) { li_len+=6; strcat(aux_string, "&#bytes&#repetitions&t_min[usec]&t_max[usec]&t_avg[usec]&Mbytes/sec&"); } else if ( edit_type == 2 ) { li_len+=5; strcat(aux_string, "&#bytes&#repetitions&t_min[usec]&t_max[usec]&t_avg[usec]&"); } else if ( edit_type == 3 ) { li_len+=4; strcat(aux_string, "&#repetitions&t_min[usec]&t_max[usec]&t_avg[usec]&"); } else { li_len+=6; strcat(aux_string, "&#bytes&#repetitions&t_ovrl[usec]&t_pure[usec]&t_CPU[usec]& overlap[%]&"); } #ifdef CHECK if( Bmark->RUN_MODES[0].type != Sync && strcmp(Bmark->name,"Window") ) { li_len+=1; strcat(aux_string,"&defects&"); } #endif IMB_make_line(li_len); if( c_info->n_groups > 1) fprintf(unit,"# Benchmarking Multi-%s ",Bmark->name); else fprintf(unit,"# Benchmarking %s ",Bmark->name); IMB_show_procids(c_info); IMB_make_line(li_len); switch(BMODE->AGGREGATE) { case 1: fprintf(unit,"#\n# MODE: AGGREGATE \n#\n"); break; case 0: fprintf(unit,"#\n# MODE: NON-AGGREGATE \n#\n"); break; } IMB_print_headlines(aux_string); } /*if( header )*/ if( GROUP_OUT ) { /* IMB 3.1 << use ITERATIONS object */ for( i_gr=0; i_gr<c_info->n_groups; i_gr++ ) { if(i_gr == 0) fprintf(unit,"\n"); IMB_display_times(Bmark, all_times, c_info, i_gr, ITERATIONS->n_sample, size, edit_type); } /*for( i_gr=0; */ } else IMB_display_times(Bmark, all_times, c_info, 0, ITERATIONS->n_sample, size, edit_type); } /*if( DO_OUT )*/