root/ompi/mca/common/ompio/common_ompio_print_queue.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mca_common_ompio_initialize_print_queue
  2. mca_common_ompio_register_print_entry
  3. mca_common_ompio_unregister_print_entry
  4. mca_common_ompio_empty_print_queue
  5. mca_common_ompio_full_print_queue
  6. mca_common_ompio_print_time_info

   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-2017 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) 2018      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  *
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include "ompi_config.h"
  25 
  26 #include "ompi/communicator/communicator.h"
  27 #include "ompi/datatype/ompi_datatype.h"
  28 
  29 #include "ompi/mca/common/ompio/common_ompio.h"
  30 
  31 
  32 /* Print queue related function implementations */
  33 int mca_common_ompio_initialize_print_queue( struct mca_common_ompio_print_queue  **r){
  34 
  35     struct mca_common_ompio_print_queue *q=NULL;
  36     int ret = OMPI_SUCCESS;
  37 
  38     q = (struct mca_common_ompio_print_queue *) malloc ( sizeof(mca_common_ompio_print_queue));
  39     if ( NULL == q ) {
  40         ret = OMPI_ERR_OUT_OF_RESOURCE;
  41     }
  42     q->first = 0;
  43     q->last = MCA_COMMON_OMPIO_QUEUESIZE - 1;
  44     q->count = 0;
  45     
  46     *r = q;
  47     return ret;
  48 }
  49 
  50 int mca_common_ompio_register_print_entry ( struct mca_common_ompio_print_queue *q,
  51                                             mca_common_ompio_print_entry x)
  52 {
  53     if (q->count >= MCA_COMMON_OMPIO_QUEUESIZE){
  54         return OMPI_ERROR;
  55     }
  56     else{
  57         q->last = (q->last + 1) % MCA_COMMON_OMPIO_QUEUESIZE;
  58         q->entry[q->last] = x;
  59         q->count = q->count + 1;
  60     }
  61 
  62     return OMPI_SUCCESS;
  63 }
  64 
  65 int  mca_common_ompio_unregister_print_entry ( struct mca_common_ompio_print_queue *q,
  66                                                mca_common_ompio_print_entry *x)
  67 {
  68 
  69     if (q->count <= 0){
  70         return OMPI_ERROR;
  71     }
  72     else{
  73         *x = q->entry[q->first];
  74         q->first = (q->first+1) % MCA_COMMON_OMPIO_QUEUESIZE;
  75         q->count = q->count - 1;
  76     }
  77 
  78     return OMPI_SUCCESS;
  79 }
  80 
  81 int mca_common_ompio_empty_print_queue( struct mca_common_ompio_print_queue *q)
  82 {
  83     if (q->count == 0) {
  84         return 1;
  85     }
  86     
  87     return 0;
  88 }
  89 
  90 int mca_common_ompio_full_print_queue( struct mca_common_ompio_print_queue *q)
  91 {
  92     if (q->count < MCA_COMMON_OMPIO_QUEUESIZE) {
  93         return 0;
  94     }
  95 
  96     return 1;
  97 }
  98 
  99 
 100 int mca_common_ompio_print_time_info( struct mca_common_ompio_print_queue *q,
 101                                       char *name,
 102                                       struct ompio_file_t *fh){
 103 
 104     int i = 0, j=0, nprocs_for_coll = 0, ret = OMPI_SUCCESS, count = 0;
 105     double *time_details = NULL, *final_sum = NULL;
 106     double *final_max = NULL, *final_min = NULL;
 107     double *final_time_details=NULL;
 108 
 109     nprocs_for_coll = q->entry[0].nprocs_for_coll;
 110     time_details = (double *) calloc (4,sizeof(double));
 111     if ( NULL == time_details){
 112         ret = OMPI_ERR_OUT_OF_RESOURCE;
 113         goto exit;
 114 
 115     }
 116 
 117     if (!fh->f_rank){
 118 
 119         final_min = (double *) malloc (3*sizeof(double));
 120         if ( NULL == final_min){
 121             ret = OMPI_ERR_OUT_OF_RESOURCE;
 122             goto exit;
 123         }
 124 
 125         final_max = (double *) malloc (3*sizeof(double));
 126         if ( NULL == final_max){
 127             ret = OMPI_ERR_OUT_OF_RESOURCE;
 128             goto exit;
 129 
 130         }
 131 
 132         final_sum = (double *) malloc (3*sizeof(double));
 133         if ( NULL == final_sum){
 134             ret = OMPI_ERR_OUT_OF_RESOURCE;
 135             goto exit;
 136         }
 137 
 138         final_time_details = (double *)calloc (fh->f_size, 4 * sizeof(double));
 139         if (NULL == final_time_details){
 140             ret = OMPI_ERR_OUT_OF_RESOURCE;
 141             goto exit;
 142         }
 143 
 144         count = 4 * fh->f_size;
 145     }
 146 
 147     if (q->count > 0){
 148         for (i=0; i < q->count; i++){
 149             for (j=0;j<3;j++){
 150                 if (!fh->f_rank){
 151                     final_min[j] = 100000.0;
 152                     final_max[j] = 0.0;
 153                     final_sum[j] = 0.0;
 154                 }
 155                 time_details[j] += q->entry[i].time[j];
 156             }
 157             time_details[3]  = q->entry[i].aggregator;
 158         }
 159     }
 160 
 161     ret = fh->f_comm->c_coll->coll_gather(time_details,
 162                                          4,
 163                                          MPI_DOUBLE,
 164                                          final_time_details,
 165                                          4,
 166                                          MPI_DOUBLE,
 167                                          0,
 168                                          fh->f_comm,
 169                                          fh->f_comm->c_coll->coll_gather_module);
 170     
 171     if ( OMPI_SUCCESS != ret ) {
 172     }
 173 
 174     if (!fh->f_rank){
 175 
 176         for (i=0;i<count;i+=4){
 177             if (final_time_details[i+3] == 1){
 178                 final_sum[0] += final_time_details[i];
 179                 final_sum[1] += final_time_details[i+1];
 180                 final_sum[2] += final_time_details[i+2];
 181 
 182                 if ( final_time_details[i] < final_min[0])
 183                     final_min[0] = final_time_details[i];
 184                 if ( final_time_details[i+1] < final_min[1])
 185                     final_min[1] = final_time_details[i+1];
 186                 if ( final_time_details[i+2] < final_min[2])
 187                     final_min[2] = final_time_details[i+2];
 188 
 189 
 190 
 191                 if ( final_time_details[i] > final_max[0])
 192                     final_max[0] = final_time_details[i];
 193                 if ( final_time_details[i+1] > final_max[1])
 194                     final_max[1] = final_time_details[i+1];
 195                 if ( final_time_details[i+2] > final_max[2])
 196                     final_max[2] = final_time_details[i+2];
 197 
 198             }
 199         }
 200 
 201         printf ("\n# MAX-%s AVG-%s MIN-%s MAX-COMM AVG-COMM MIN-COMM",
 202                 name, name, name);
 203         printf (" MAX-EXCH AVG-EXCH MIN-EXCH\n");
 204         printf (" %f %f %f %f %f %f %f %f %f\n\n",
 205                 final_max[0], final_sum[0]/nprocs_for_coll, final_min[0],
 206                 final_max[1], final_sum[1]/nprocs_for_coll, final_min[1],
 207                 final_max[2], final_sum[2]/nprocs_for_coll, final_min[2]);
 208 
 209     }
 210 
 211  exit:
 212     if ( NULL != final_max){
 213         free(final_max);
 214         final_max = NULL;
 215     }
 216     if (NULL != final_min){
 217         free(final_min);
 218         final_min = NULL;
 219     }
 220     if (NULL != final_sum){
 221         free(final_sum);
 222         final_sum = NULL;
 223     }
 224     if (NULL != time_details){
 225         free(time_details);
 226         time_details = NULL;
 227     }
 228 
 229     return ret;
 230 }
 231 

/* [<][>][^][v][top][bottom][index][help] */