|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
| 4 | + * University Research and Technology |
| 5 | + * Corporation. All rights reserved. |
| 6 | + * Copyright (c) 2004-2013 The University of Tennessee and The University |
| 7 | + * of Tennessee Research Foundation. All rights |
| 8 | + * reserved. |
| 9 | + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 10 | + * University of Stuttgart. All rights reserved. |
| 11 | + * Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | + * All rights reserved. |
| 13 | + * Copyright (c) 2008-2016 University of Houston. All rights reserved. |
| 14 | + * Copyright (c) 2011-2015 Cisco Systems, Inc. All rights reserved. |
| 15 | + * Copyright (c) 2012-2013 Inria. All rights reserved. |
| 16 | + * Copyright (c) 2015 Research Organization for Information Science |
| 17 | + * and Technology (RIST). All rights reserved. |
| 18 | + * $COPYRIGHT$ |
| 19 | + * |
| 20 | + * Additional copyrights may follow |
| 21 | + * |
| 22 | + * $HEADER$ |
| 23 | + */ |
| 24 | + |
| 25 | +#include "ompi_config.h" |
| 26 | + |
| 27 | +#include "ompi/communicator/communicator.h" |
| 28 | +#include "ompi/datatype/ompi_datatype.h" |
| 29 | + |
| 30 | +#include "common_ompio_print_queue.h" |
| 31 | + |
| 32 | +mca_common_ompio_print_queue *coll_write_time=NULL; |
| 33 | +mca_common_ompio_print_queue *coll_read_time=NULL; |
| 34 | + |
| 35 | +/* Print queue related function implementations */ |
| 36 | +int common_ompio_set_print_queue (mca_common_ompio_print_queue **q, |
| 37 | + int queue_type){ |
| 38 | + |
| 39 | + int ret = OMPI_SUCCESS; |
| 40 | + |
| 41 | + switch(queue_type) { |
| 42 | + |
| 43 | + case WRITE_PRINT_QUEUE: |
| 44 | + *q = coll_write_time; |
| 45 | + break; |
| 46 | + case READ_PRINT_QUEUE: |
| 47 | + *q = coll_read_time; |
| 48 | + break; |
| 49 | + } |
| 50 | + |
| 51 | + if (NULL == q){ |
| 52 | + ret = OMPI_ERROR; |
| 53 | + } |
| 54 | + return ret; |
| 55 | + |
| 56 | +} |
| 57 | + |
| 58 | + |
| 59 | +int common_ompio_initialize_print_queue(void *r){ |
| 60 | + |
| 61 | + mca_common_ompio_print_queue *q; |
| 62 | + int ret = OMPI_SUCCESS; |
| 63 | + |
| 64 | + q = (mca_common_ompio_print_queue *) malloc ( sizeof(mca_common_ompio_print_queue)); |
| 65 | + if ( NULL == q ) { |
| 66 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 67 | + } |
| 68 | + q->first = 0; |
| 69 | + q->last = COMMON_OMPIO_QUEUESIZE - 1; |
| 70 | + q->count = 0; |
| 71 | + |
| 72 | + *r = ( void *) *q; |
| 73 | + return ret; |
| 74 | +} |
| 75 | +int common_ompio_register_print_entry (int queue_type, |
| 76 | + mca_common_ompio_print_entry x){ |
| 77 | + |
| 78 | + int ret = OMPI_SUCCESS; |
| 79 | + mca_common_ompio_print_queue *q=NULL; |
| 80 | + |
| 81 | + ret = common_ompio_set_print_queue(&q, queue_type); |
| 82 | + |
| 83 | + if (ret != OMPI_ERROR){ |
| 84 | + if (q->count >= COMMON_OMPIO_QUEUESIZE){ |
| 85 | + return OMPI_ERROR; |
| 86 | + } |
| 87 | + else{ |
| 88 | + q->last = (q->last + 1) % COMMON_OMPIO_QUEUESIZE; |
| 89 | + q->entry[q->last] = x; |
| 90 | + q->count = q->count + 1; |
| 91 | + } |
| 92 | + } |
| 93 | + return ret; |
| 94 | +} |
| 95 | + |
| 96 | +int common_ompio_unregister_print_entry (int queue_type, |
| 97 | + mca_common_ompio_print_entry *x){ |
| 98 | + |
| 99 | + int ret = OMPI_SUCCESS; |
| 100 | + mca_common_ompio_print_queue *q=NULL; |
| 101 | + ret = common_ompio_set_print_queue(&q, queue_type); |
| 102 | + if (ret != OMPI_ERROR){ |
| 103 | + if (q->count <= 0){ |
| 104 | + return OMPI_ERROR; |
| 105 | + } |
| 106 | + else{ |
| 107 | + *x = q->entry[q->first]; |
| 108 | + q->first = (q->first+1) % COMMON_OMPIO_QUEUESIZE; |
| 109 | + q->count = q->count - 1; |
| 110 | + } |
| 111 | + } |
| 112 | + return OMPI_SUCCESS; |
| 113 | +} |
| 114 | + |
| 115 | +int common_ompio_empty_print_queue(int queue_type){ |
| 116 | + |
| 117 | + int ret = OMPI_SUCCESS; |
| 118 | + mca_common_ompio_print_queue *q=NULL; |
| 119 | + ret = common_ompio_set_print_queue(&q, queue_type); |
| 120 | + |
| 121 | + assert (ret != OMPI_ERROR); |
| 122 | + (void)ret; // silence compiler warning |
| 123 | + if (q->count == 0) |
| 124 | + return 1; |
| 125 | + else |
| 126 | + return 0; |
| 127 | + |
| 128 | + |
| 129 | +} |
| 130 | + |
| 131 | +int common_ompio_full_print_queue(int queue_type){ |
| 132 | + |
| 133 | + |
| 134 | + int ret = OMPI_SUCCESS; |
| 135 | + mca_common_ompio_print_queue *q=NULL; |
| 136 | + ret = common_ompio_set_print_queue(&q, queue_type); |
| 137 | + |
| 138 | + assert ( ret != OMPI_ERROR); |
| 139 | + (void)ret; // silence compiler warning |
| 140 | + if (q->count < COMMON_OMPIO_QUEUESIZE) |
| 141 | + return 0; |
| 142 | + else |
| 143 | + return 1; |
| 144 | + |
| 145 | +} |
| 146 | + |
| 147 | + |
| 148 | +int common_ompio_print_time_info(int queue_type, |
| 149 | + char *name, |
| 150 | + mca_io_ompio_file_t *fh){ |
| 151 | + |
| 152 | + int i = 0, j=0, nprocs_for_coll = 0, ret = OMPI_SUCCESS, count = 0; |
| 153 | + double *time_details = NULL, *final_sum = NULL; |
| 154 | + double *final_max = NULL, *final_min = NULL; |
| 155 | + double *final_time_details=NULL; |
| 156 | + mca_common_ompio_print_queue *q=NULL; |
| 157 | + |
| 158 | + ret = common_ompio_set_print_queue(&q, queue_type); |
| 159 | + |
| 160 | + assert (ret != OMPI_ERROR); |
| 161 | + nprocs_for_coll = q->entry[0].nprocs_for_coll; |
| 162 | + time_details = (double *) malloc (4*sizeof(double)); |
| 163 | + if ( NULL == time_details){ |
| 164 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 165 | + goto exit; |
| 166 | + |
| 167 | + } |
| 168 | + |
| 169 | + if (!fh->f_rank){ |
| 170 | + |
| 171 | + final_min = (double *) malloc (3*sizeof(double)); |
| 172 | + if ( NULL == final_min){ |
| 173 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 174 | + goto exit; |
| 175 | + } |
| 176 | + |
| 177 | + final_max = (double *) malloc (3*sizeof(double)); |
| 178 | + if ( NULL == final_max){ |
| 179 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 180 | + goto exit; |
| 181 | + |
| 182 | + } |
| 183 | + |
| 184 | + final_sum = (double *) malloc (3*sizeof(double)); |
| 185 | + if ( NULL == final_sum){ |
| 186 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 187 | + goto exit; |
| 188 | + } |
| 189 | + |
| 190 | + final_time_details = |
| 191 | + (double *)malloc |
| 192 | + (fh->f_size * 4 * sizeof(double)); |
| 193 | + if (NULL == final_time_details){ |
| 194 | + ret = OMPI_ERR_OUT_OF_RESOURCE; |
| 195 | + goto exit; |
| 196 | + } |
| 197 | + |
| 198 | + count = 4 * fh->f_size; |
| 199 | + for(i=0;i<count;i++){ |
| 200 | + final_time_details[i] = 0.0; |
| 201 | + } |
| 202 | + |
| 203 | + |
| 204 | + } |
| 205 | + |
| 206 | + for (i = 0; i < 4; i++){ |
| 207 | + time_details[i] = 0.0; |
| 208 | + } |
| 209 | + |
| 210 | + if (q->count > 0){ |
| 211 | + for (i=0; i < q->count; i++){ |
| 212 | + for (j=0;j<3;j++){ |
| 213 | + if (!fh->f_rank){ |
| 214 | + final_min[j] = 100000.0; |
| 215 | + final_max[j] = 0.0; |
| 216 | + final_sum[j] = 0.0; |
| 217 | + } |
| 218 | + time_details[j] += q->entry[i].time[j]; |
| 219 | + } |
| 220 | + time_details[3] = q->entry[i].aggregator; |
| 221 | + } |
| 222 | + } |
| 223 | + |
| 224 | + fh->f_comm->c_coll.coll_gather(time_details, |
| 225 | + 4, |
| 226 | + MPI_DOUBLE, |
| 227 | + final_time_details, |
| 228 | + 4, |
| 229 | + MPI_DOUBLE, |
| 230 | + 0, |
| 231 | + fh->f_comm, |
| 232 | + fh->f_comm->c_coll.coll_gather_module); |
| 233 | + |
| 234 | + |
| 235 | + |
| 236 | + if (!fh->f_rank){ |
| 237 | + |
| 238 | + for (i=0;i<count;i+=4){ |
| 239 | + if (final_time_details[i+3] == 1){ |
| 240 | + final_sum[0] += final_time_details[i]; |
| 241 | + final_sum[1] += final_time_details[i+1]; |
| 242 | + final_sum[2] += final_time_details[i+2]; |
| 243 | + |
| 244 | + if ( final_time_details[i] < final_min[0]) |
| 245 | + final_min[0] = final_time_details[i]; |
| 246 | + if ( final_time_details[i+1] < final_min[1]) |
| 247 | + final_min[1] = final_time_details[i+1]; |
| 248 | + if ( final_time_details[i+2] < final_min[2]) |
| 249 | + final_min[2] = final_time_details[i+2]; |
| 250 | + |
| 251 | + |
| 252 | + |
| 253 | + if ( final_time_details[i] > final_max[0]) |
| 254 | + final_max[0] = final_time_details[i]; |
| 255 | + if ( final_time_details[i+1] > final_max[1]) |
| 256 | + final_max[1] = final_time_details[i+1]; |
| 257 | + if ( final_time_details[i+2] > final_max[2]) |
| 258 | + final_max[2] = final_time_details[i+2]; |
| 259 | + |
| 260 | + } |
| 261 | + } |
| 262 | + |
| 263 | + printf ("\n# MAX-%s AVG-%s MIN-%s MAX-COMM AVG-COMM MIN-COMM", |
| 264 | + name, name, name); |
| 265 | + printf (" MAX-EXCH AVG-EXCH MIN-EXCH\n"); |
| 266 | + printf (" %f %f %f %f %f %f %f %f %f\n\n", |
| 267 | + final_max[0], final_sum[0]/nprocs_for_coll, final_min[0], |
| 268 | + final_max[1], final_sum[1]/nprocs_for_coll, final_min[1], |
| 269 | + final_max[2], final_sum[2]/nprocs_for_coll, final_min[2]); |
| 270 | + |
| 271 | + } |
| 272 | + |
| 273 | + exit: |
| 274 | + if ( NULL != final_max){ |
| 275 | + free(final_max); |
| 276 | + final_max = NULL; |
| 277 | + } |
| 278 | + if (NULL != final_min){ |
| 279 | + free(final_min); |
| 280 | + final_min = NULL; |
| 281 | + } |
| 282 | + if (NULL != final_sum){ |
| 283 | + free(final_sum); |
| 284 | + final_sum = NULL; |
| 285 | + } |
| 286 | + if (NULL != time_details){ |
| 287 | + free(time_details); |
| 288 | + time_details = NULL; |
| 289 | + } |
| 290 | + |
| 291 | + return ret; |
| 292 | +} |
| 293 | + |
0 commit comments