SIONlib  1.7.7
Scalable I/O library for parallel access to task-local files
sion_internal_collstat.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
14 #define _XOPEN_SOURCE 700
15 
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <stdarg.h>
19 #include <string.h>
20 #include <time.h>
21 
22 #include "sion_const.h"
23 #include "sion_internal.h"
24 #include "sion_error_handler.h"
25 #include "sion_debug.h"
26 
27 #include "sion_internal_collstat.h"
28 
29 #define DFUNCTION "_sion_create_and_init_collstat"
30 _sion_collstat * _sion_create_and_init_collstat( _sion_filedesc *sion_filedesc ) {
31  _sion_collstat *collstat;
32  int t;
33 
34  collstat = (_sion_collstat *) malloc(sizeof(_sion_collstat));
35  if (collstat == NULL) {
36  _sion_errorprint(SION_NOT_SUCCESS,_SION_ERROR_RETURN,"cannot allocate collstat structure of size %lu (sion_collstat), aborting ...\n",
37  (unsigned long) sizeof(_sion_collstat));
38  return(NULL);
39  }
40 
41  collstat->req_collsize=sion_filedesc->collsize;
42  collstat->firstsize=0;
43  collstat->gsize=0;
44  collstat->avg_size_per_sender=0;
45  collstat->max_size_per_sender=0;
46  collstat->min_size_per_sender=1e10;
47 
48  collstat->num_collectors=0;
49  collstat->avg_sender_per_collector=0;
50  collstat->max_sender_per_collector=0;
51  collstat->min_sender_per_collector=10000000;
52  collstat->avg_size_per_collector=0;
53  collstat->max_size_per_collector=0;
54  collstat->min_size_per_collector=1e10;
55 
56 
57  /* calculate overall data size */
58  collstat->gsize=0;
59  for (t = 0; t < sion_filedesc->ntasks; t++) {
60  collstat->gsize+=sion_filedesc->all_chunksizes[t];
61  if(sion_filedesc->all_chunksizes[t]>collstat->max_size_per_sender) collstat->max_size_per_sender=sion_filedesc->all_chunksizes[t];
62  if(sion_filedesc->all_chunksizes[t]<collstat->min_size_per_sender) collstat->min_size_per_sender=sion_filedesc->all_chunksizes[t];
63  }
64  if(sion_filedesc->ntasks>0) collstat->avg_size_per_sender = (double) collstat->gsize / (double) sion_filedesc->ntasks;
65 
66  DPRINTFP((2, DFUNCTION, _SION_DEFAULT_RANK, "gsize=%ld\n", (long) collstat->gsize));
67 
68  return(collstat);
69 }
70 #undef DFUNCTION
71 
72 
73 #define DFUNCTION "_sion_update_collstat"
74 int _sion_update_collstat( _sion_collstat *collstat, _sion_filedesc *sion_filedesc ) {
75  int rc = SION_SUCCESS;
76  int t, s;
77  sion_int64 currentsize;
78 
79  /* calculate overall data size */
80 
81  for (t = 0; t < sion_filedesc->ntasks; t++) {
82 
83  if(t == sion_filedesc->all_coll_collector[t]) {
84  /* its a collector */
85 
86  /* accumulate data for collector */
87  currentsize=0;
88  for (s = t; s < t+sion_filedesc->all_coll_collsize[t]; s++) {
89  currentsize += sion_filedesc->all_chunksizes[s];
90  }
91 
92  /* statistics */
93  collstat->num_collectors++;
94  collstat->avg_size_per_collector+=currentsize;
95  if(currentsize>collstat->max_size_per_collector) collstat->max_size_per_collector=currentsize;
96  if(currentsize<collstat->min_size_per_collector) collstat->min_size_per_collector=currentsize;
97  if(sion_filedesc->all_coll_collsize[t]<collstat->min_sender_per_collector) collstat->min_sender_per_collector=sion_filedesc->all_coll_collsize[t];
98  if(sion_filedesc->all_coll_collsize[t]>collstat->max_sender_per_collector) collstat->max_sender_per_collector=sion_filedesc->all_coll_collsize[t];
99 
100  }
101  }
102  if(collstat->num_collectors>0) collstat->avg_size_per_collector/=collstat->num_collectors;
103 
104  return(rc);
105 }
106 #undef DFUNCTION
107 
108 
109 #define DFUNCTION "_sion_print_collstat"
110 int _sion_print_collstat( _sion_collstat *collstat, _sion_filedesc *sion_filedesc ) {
111  int rc = SION_SUCCESS;
112  int t,s;
113 
114  fprintf(stderr, "collective statistics: req_collsize=%11d\n", collstat->req_collsize);
115  fprintf(stderr, "collective statistics: req_num_collectors=%11d\n", collstat->req_num_collectors);
116  fprintf(stderr, "collective statistics: num_collectors=%11d\n", collstat->num_collectors);
117  fprintf(stderr, "collective statistics: avg_sender_per_collector=%14.2f\n", collstat->avg_sender_per_collector);
118  fprintf(stderr, "collective statistics: min_sender_per_collector=%11d\n", collstat->min_sender_per_collector);
119  fprintf(stderr, "collective statistics: max_sender_per_collector=%11d\n", collstat->max_sender_per_collector);
120 
121  fprintf(stderr, "collective statistics: avg_size_per_collector=%14.2f bytes\n", collstat->avg_size_per_collector);
122  fprintf(stderr, "collective statistics: min_size_per_collector=%11lld bytes\n", collstat->min_size_per_collector);
123  fprintf(stderr, "collective statistics: max_size_per_collector=%11lld bytes\n", collstat->max_size_per_collector);
124 
125  fprintf(stderr, "collective statistics: avg_size_per_sender=%14.2f bytes\n", collstat->avg_size_per_sender);
126  fprintf(stderr, "collective statistics: min_size_per_sender=%11lld bytes\n", collstat->min_size_per_sender);
127  fprintf(stderr, "collective statistics: max_size_per_sender=%11lld bytes\n", collstat->max_size_per_sender);
128 
129  if(sion_filedesc->colldebug>=3) {
130  for (t = 0; t < sion_filedesc->ntasks; t++) {
131 
132  if(t == sion_filedesc->all_coll_collector[t]) {
133  /* its a collector */
134  fprintf(stderr,"collective statistics: startpointers[%2d]=%10lld (%10.4fMB) chunksizes[%2d]=%8lld COLLECTOR collsize=%3d\n",
135  t, sion_filedesc->all_startpointers[t], sion_filedesc->all_startpointers[t] / 1024.0 / 1024.0,
136  t, sion_filedesc->all_chunksizes[t],
137  sion_filedesc->all_coll_collsize[t] );
138 
139  for (s = t+1; s < t+sion_filedesc->all_coll_collsize[t]; s++) {
140  fprintf(stderr,"collective statistics: startpointers[%2d]=%10lld (%10.4fMB) chunksizes[%2d]=%8lld SENDER to %3d\n",
141  s, sion_filedesc->all_startpointers[s], sion_filedesc->all_startpointers[s] / 1024.0 / 1024.0,
142  s, sion_filedesc->all_chunksizes[s], t );
143  }
144  }
145  }
146  }
147 
148  return(rc);
149 }
150 #undef DFUNCTION
151 
152 #define DFUNCTION "_sion_debugprint_collstat"
153 int _sion_debugprint_collstat( _sion_collstat *sion_collstat, _sion_filedesc *sion_filedesc ) {
154  int rc = SION_SUCCESS;
155  int t, s;
156 
157 
158  DPRINTFP((2, DFUNCTION, _SION_DEFAULT_RANK, " enter\n"));
159 
160  for (t = 0; t < sion_filedesc->ntasks; t++) {
161  if(t == sion_filedesc->all_coll_collector[t]) {
162  /* its a collector */
163  DPRINTFP((2048, DFUNCTION, _SION_DEFAULT_RANK, " startpointers[%2d]=%10lld (%10.4fMB) chunksizes[%2d]=%8lld COLLECTOR collsize=%3d\n",
164  t, sion_filedesc->all_startpointers[t], sion_filedesc->all_startpointers[t] / 1024.0 / 1024.0,
165  t, sion_filedesc->all_chunksizes[t],
166  sion_filedesc->all_coll_collsize[t] ));
167 
168  for (s = t+1; s < t+sion_filedesc->all_coll_collsize[t]; s++) {
169  DPRINTFP((2048, DFUNCTION, _SION_DEFAULT_RANK, " startpointers[%2d]=%10lld (%10.4fMB) chunksizes[%2d]=%8lld SENDER to %3d\n",
170  s, sion_filedesc->all_startpointers[s], sion_filedesc->all_startpointers[s] / 1024.0 / 1024.0,
171  s, sion_filedesc->all_chunksizes[s], t ));
172  }
173  }
174  }
175 
176  DPRINTFP((2, DFUNCTION, _SION_DEFAULT_RANK, " leave\n",t));
177  return(rc);
178 }
179 #undef DFUNCTION
180 
181 #define DFUNCTION "_sion_dprint_collstat"
182 int _sion_destroy_collstat( _sion_collstat *sion_collstat ) {
183  int rc = SION_SUCCESS;
184 
185  if(sion_collstat) {
186  free(sion_collstat);
187  }
188 
189  return(rc);
190 }
191 #undef DFUNCTION
Sion File Descriptor Structure.
Definition: sion_filedesc.h:79
sion_int32 * all_coll_collsize
sion_int32 * all_coll_collector
sion_int64 * all_chunksizes
sion_int64 * all_startpointers