-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyze.py
executable file
·1803 lines (1656 loc) · 62.7 KB
/
analyze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
## written by Atsushi Hori ([email protected]) at
## Riken Center for Computational Science
## 2019 April
## George Bosilca 2019
# Preparation
# python3
# and Python modules listed below
import copy
import os
import sys
import datetime
import math
import copy
import pandas as pd
from cycler import cycler
import unicodedata
import numpy as np
import matplotlib
from matplotlib import pylab as plt
from matplotlib import dates as mdates
from matplotlib.dates import date2num
import seaborn as sns
import argparse
pd.set_option('display.max_rows', 500)
DATE_FORMAT_MS = '%m/%d/%y' # mmddyy
DATE_FORMAT_JP = '%Y/%m/%d' # YYmmdd
DATE_FORMAT_US = '%m/%d/%Y' # mmddYY
DATE_FORMATS = [ DATE_FORMAT_JP, DATE_FORMAT_US, DATE_FORMAT_MS ]
MULTIANS_NCOLS = 3
MULTIANS_CLEGEND = MULTIANS_NCOLS
CROSSTAB_THRESHOLD = 0.04 # crosstab rows and columns less than this are not shown
CROSSTAB_NCOLS = 3
CROSSTAB_CLEGEND = CROSSTAB_NCOLS
CROSSTAB_COLOR = 'YlOrRd'
# possible color map names
## Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu,
## BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens,
## Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn,
## PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r,
## PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd,
## PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r,
## RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2,
## Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn,
## YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot,
## afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg,
## brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm,
## coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r,
## gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat,
## gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r,
## gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2,
## gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, icefire,
## icefire_r, inferno, inferno_r, jet, jet_r, magma, magma_r, mako,
## mako_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r,
## plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, rocket,
## rocket_r, seismic, seismic_r, spring, spring_r, summer, summer_r,
## tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r,
## terrain, terrain_r, twilight, twilight_r, twilight_shifted,
## twilight_shifted_r, viridis, viridis_r, vlag, vlag_r, winter, winter_r
event_list = [ # [ year, month, day, event-name, text-height ]
[ 2019, 2, 18, 'hpc-announce[1]', 120 ],
[ 2019, 2, 21, 'Atsushi@Riken[1]', 140 ],
[ 2019, 2, 26, 'Sanjay@UIUC', 160 ],
[ 2019, 2, 26, 'Emmanuel@Inria', 180 ],
[ 2019, 2, 22, 'Artem@Mellanox', 200 ],
[ 2019, 2, 27, 'Atsushi@Riken[2]', 220 ],
[ 2019, 3, 1, 'hpc-announce[2]', 110 ],
[ 2019, 3, 19, 'hpc-announce[3]', 130 ],
[ 2019, 4, 1, 'Rolf@HLRS', 150 ]
]
region_tab = { 'Argentina' : 'Central and South America',
'Australia' : 'Australia',
'Austria' : 'Europe',
'belgium' : 'Europe',
'Belgium' : 'Europe',
'Brazil' : 'Central and South America',
'Canada' : 'North America',
'China' : 'China',
'Croatia' : 'Europe',
'Czech Republic' : 'Europe',
'Denmark' : 'Europe',
'Denmark, Austria' : 'Europe',
'Egypt' : 'Africa',
'Estonia' : 'Europe',
'Finland' : 'Europe',
'France' : 'Europe',
'Germany' : 'Europe',
'Greece' : 'Europe',
'India' : 'India',
'Italy' : 'Europe',
'Japan' : 'Japan',
'Korea, South' : 'South Korea',
'Luxembourg' : 'Europe',
'Mexico' : 'Central and South America',
'Netherlands' : 'Europe',
'Norway' : 'Europe',
'Pakistan' : 'Asia',
'Peru' : 'Central and South America',
'Poland' : 'Europe',
'Portugal' : 'Europe',
'Russia' : 'Russia',
'Saudi Arabia' : 'Asia',
'Serbia' : 'Europe',
'Singapore' : 'Asia',
'Spain' : 'Europe',
'Sweden' : 'Europe',
'Switzerland' : 'Europe',
'Taiwan' : 'China',
'Tunisia' : 'Africa',
'Ukraine' : 'Europe',
'UAE' : 'Asia',
'UK' : 'Europe',
'USA' : 'USA'
}
question_tab = { 'Q1' : 'Occupation',
'Q2' : 'Programming Skill',
'Q3' : 'MPI Skill',
'Q4' : 'Programming Language',
'Q5' : 'Programming Experience',
'Q6' : 'MPI Experience',
'Q7' : 'Working Fields',
'Q8' : 'Role',
'Q9' : 'MPI Standard',
'Q10' : 'Learning MPI',
'Q11' : 'MPI Book',
'Q12' : 'MPI Implementation',
'Q13' : 'Choosing MPI',
'Q14' : 'Checking MPI Spec.',
'Q15' : 'MPI Difficulty',
'Q16' : 'Unknown MPI Features',
'Q17' : 'MPI Aspects',
'Q18' : 'MPI thread level',
'Q19' : 'MPI Obstacles',
'Q20' : 'Error Checking',
'Q21' : 'Packing MPI calls',
'Q22' : 'MPI+X',
'Q23' : 'Room for tuning',
'Q24' : 'Alternatives',
'Q25' : 'Missing Features',
'Q26' : 'Missing Semantics',
'Q27' : 'Useless Features',
'Q28' : 'Backward Compatibility',
'Q29' : 'Performance and Portability'
}
graph_scale = {
'Q1' : 0.75,
'Q2' : 0.83,
'Q3' : 0.83,
'Q4' : 0.81,
'Q5' : 0.83,
'Q6' : 0.83,
'Q7' : 0.7,
'Q8' : 0.7,
'Q9' : 0.83,
'Q10' : 0.68,
'Q11' : 0.6,
'Q12' : 0.74,
'Q13' : 0.74,
'Q14' : 0.7,
'Q15' : 0.67,
'Q16' : 0.7,
'Q17' : 0.7,
'Q18' : 0.7,
'Q19' : 0.64,
'Q20' : 0.78,
'Q21' : 0.7,
'Q22' : 0.8,
'Q23' : 0.58,
'Q24' : 0.65,
'Q25' : 0.64,
'Q26' : 0.65,
'Q27' : 0.62,
'Q28' : 0.62,
'Q29' : 0.75
}
qval_tab = \
{ 'Q1' :
{ 'College/University' : 'Univ',
'Governmental institute' : 'Gov',
'Hardware vendor' : 'HW',
'Software vendor' : 'SW',
'Private research institute' : 'Priv',
'Other' : 'other' },
'Q2' :
{ '1' : 'Low',
'2' : '2',
'3' : '3',
'4' : '4',
'5' : '5',
'6' : 'High' },
'Q3' :
{ '1' : 'Low',
'2' : '2',
'3' : '3',
'4' : '4',
'5' : '5',
'6' : 'High' },
'Q4' :
{ 'C/C++' : 'C(++)',
'Fortran 90 or newer' : '>=F90',
'Python' : 'Py',
'Fortran (older one than Fortran 90)' : '<F90',
'Java' : 'Java',
'Other' : 'other' } ,
'Q5' :
{ 'more than 10 years' : '>10',
'between 5 and 10 years' : '5-10',
'between 2 and 5 years' : '2-5',
'less than 2 years' : '<2' },
'Q6' :
{ 'more than 10 years' : '>10',
'between 5 and 10 years' : '5-10',
'between 2 and 5 years' : '2-5',
'less than 2 years' : '<2' },
'Q7' :
{ 'System software development (OS, runtime library, communication library, etc.)' : 'OS/R',
'Parallel language (incl. domain specific language)' : 'Lang',
'Numerical application and/or library' : 'Num-App/Lib',
'AI (Deep Learning)' : 'AI',
'Image processing' : 'Image Proc',
'Big data' : 'Big data',
'Workflow and/or In-situ' : 'Worlflow',
'Visualization' : 'Visulization',
'Tool development (performance tuning, debugging, etc.)' : 'Tool',
'Other' : 'other' },
'Q8' :
{ 'Research and development of application(s)' : 'Apps',
'Research and development software tool(s)' : 'Tools',
'Parallelization of sequential program(s)' : 'Paralelize',
'Performance tuning of MPI program(s)' : 'Tuning',
'Debugging MPI programs' : 'Debug',
'Research and development on system software (OS and/or runtime library)' : 'OS/R',
'Other' : 'other'
},
'Q9' :
{ 'I read all.' : 'All',
'I read most of it.' : 'Mostly',
'I read only the chapters of interest for my work.' : 'Partly',
'I have not read it, but I plan to.' : 'Wish',
'No, and I will not read it.' : 'No' },
'Q10' :
{ 'I read the MPI standard document.' : 'Standard',
'I had lecture(s) at school.' : 'School',
'I read articles found on Internet.' : 'Internet',
'I read book(s).' : 'Books',
'Other lectures or tutorials (workplace, conference).' : 'Other lec.',
'I have not learned MPI.' : 'Never learned',
'Other' : 'other' },
'Q11' :
{ 'Beginning MPI (An Introduction in C)' : 'Beginning MPI',
'Parallel Programming with MPI' : 'Parallel Programming',
'Using MPI' : 'Using MPI',
'Parallel Programming in C with MPI and OpenMP' : 'Parallel Programming in C',
'MPI: The Complete Reference' : 'MPI: complete Ref',
'I have never read any MPI books' : '(no book)',
'Other' : 'other' },
'Q12' :
{ 'MPICH' : 'MPICH',
'Open MPI' : 'OMPI',
'Intel MPI' : 'Intel',
'MVAPICH' : 'MVA',
'Cray MPI' : 'Cray',
'IBM MPI (BG/Q, PE, Spectrum)' : 'IBM',
'HPE MPI' : 'HPE',
'Tianhe MPI' : 'Tianhe',
'Sunway MPI' : 'Sunway',
'Fujistu MPI' : 'Fujitsu',
'NEC MPI' : 'NEC',
'MS MPI' : 'MS',
'MPC MPI' : 'MPC',
'I do not know' : 'No idea',
'Other' : 'other' },
'Q13' :
{ 'I like to use it.' : 'I like',
'I was said to use it.' : 'Said to use',
'I could not have any choice (the one provided by a vendor).': 'No choice',
'I am familiar with it.' : 'Familiar',
'I have no special reason.' : 'No reason' },
'Q14' :
{ 'I read the MPI Standard document (web/book).' : 'MPI standard',
'I read online documents (such as man pages).' : 'Online docs',
'I search the Internet (Google / Stack Overflow).' : 'Internet',
'I ask colleagues.' : 'Colleagues',
'I read book(s) (except the MPI standard).' : 'Books',
'I know almost all MPI routines.' : 'I know all',
'Other' : 'other' },
'Q15' :
{ 'Algorithm design' : 'Algorithm',
'Debugging' : 'Debugging',
'Domain decomposition' : 'Decomposition',
'Finding appropriate MPI routines' : 'Finding MPI routines',
'Implementation issue workaround' : 'Workaround',
'Performance tuning' : 'Tuning',
'Other' : 'other' },
'Q16' :
{ 'Point-to-point communications' : 'Point-to-point',
'Collective communications' : 'Collectives',
'Communicator operations (split, duplicate, and so on)' : 'Communicator',
'MPI datatypes' : 'Datatypes',
'One-sided communications' : 'One-sided',
'Dynamic process creation' : 'Dyn. process',
'Persistent communication' : 'Persistent',
'PMPI interface' : 'PMPI',
'MPI with OpenMP (or multithread)' : 'with OpenMP',
'Other' : 'other'
},
'Q17' :
{ 'Point-to-point communications' : 'Point-to-pint',
'Collective communications' : 'Collectives',
'Communicator operations (split, duplicate, and so on)' : 'Communicator',
'MPI datatypes' : 'Datatypes',
'One-sided communications' : 'One-sided',
'Dynamic process creation' : 'Dyn. process',
'Persistent communications' : 'Persistent',
'MPI with OpenMP (or multithread)' : 'with OpenMP',
'PMPI interface' : 'PMPI',
'Other' : 'other' },
'Q18' :
{ 'MPI_THREAD_SINGLE' : 'SINGLE',
'MPI_THREAD_FUNNELED' : 'FUNNELED',
'MPI_THREAD_SERIALIZED' : 'SERIALIZED',
'MPI_THREAD_MULTIPLE' : 'MULTIPLE',
'I have never called MPI_INIT_THREAD' : 'never used',
'I do not know or I do not care.' : 'No idea',
'Other' : 'other' },
'Q19' :
{ 'I have no obstacles.' : 'No obstacles',
'Too many routines.' : 'Too many routines',
'No appropriate lecture / book / info.' : 'No appropriate one',
'Too complicated and hard to understand.' : 'Complicated',
'I have nobody to ask.' : 'Nobody to ask',
'I do not like the API.' : 'Dislike API',
'Other' : 'other' },
'Q20' :
{ 'I rely on the default ‘Errors abort’ error handling' : 'Default',
'Always' : 'Always',
'Mostly' : 'Mostly',
'Sometimes' : 'Sometimes',
'Never' : 'Never',
'Other' : 'other' },
'Q21' :
{ 'Yes, to minimize the changes of communication API.' : 'Yes',
'Yes, but I have no special reason for doing that.' : 'Yes, but no reason',
'No, my program is too small to do that.' : 'No, too small',
'No, MPI calls are scattered in my programs.' : 'No, scattered',
'Other' : 'other' },
'Q22' :
{ 'OpenMP' : 'OMP',
'Pthread' : 'Pthread',
'OpenACC' : 'OACC',
'OpenCL' : 'OCL',
'CUDA' : 'CUDA',
'No' : 'No',
'Other' : 'other' },
'Q23' :
{ 'No, my MPI programs are well-tuned.' :
'Well-tuned',
'Yes, I know there is room for tuning but I should re-write large part of my program to do that.' :
'Hard to rewrite',
'Yes, I know there is room for tuning but I do not have enough resources to do that.' :
'No resource',
'I think there is room but I do not know how to tune it.' :
'No idea to tune',
'I do not have (know) tools to find performance bottlenecks.' :
'Not having the tools',
'I have no chance to investigate.' :
'No chance to investigate',
'I do not know how to find bottlenecks.' :
'No idea to find bottlenecks',
'I do not know if there is room for performance tuning.' :
'No idea to improve',
'Other' : 'other' },
'Q24' :
{ 'A framework or library using MPI.' : 'Framework',
'A PGAS language (UPC, Coarray Fortran, OpenSHMEM, XcalableMP, ...).' : 'PGAS',
'A Domain Specific Language (DSL).' : 'DSL',
'Low-level communication layer provided by vendor (Verbs, DCMF, ...).' : 'LL comm',
'I am not investigating any alternatives.' : 'No investigation',
'Other' : 'other' },
'Q25' :
{ 'Latency' : 'Latency',
'Message injection rate' : 'Injection rate',
'Bandwidth' : 'Bandwidth',
'Additional optimization opportunities in terms of communication (network topology awareness, etc.)' : 'Additional comm. opt.',
'Optimization opportunities except communication (architecture awareness, dynamic processing, accelerator support, etc.)' : 'Other opt',
'Multi-threading support' : 'Multi-thread',
'Asynchronous progress' : 'Asynch progress',
'MPI provides all semantics I need' : 'Satisfied',
'Other' : 'other' },
'Q26' :
{ 'Latency hiding (including asynchronous completion)' : 'Latency hiding',
'Endpoints (multi-thread, sessions)' : 'End-points',
'Resilience (fault tolerance)' : 'Resilience',
'Additional optimization opportunities in terms of communication (topology awareness, locality, etc.)' : 'Additional opt',
'Another API which is easier and/or simpler to use' : 'Another API',
'MPI is providing all the communication semantics required by my application' : 'MPI provides all',
'Other' : 'other' },
'Q27' :
{ 'One-sided communication' : 'One-sided',
'Datatypes' : 'Datatypes',
'Communicator and group management' : 'Communicator',
'Collective operations' : 'Collectives',
'Process topologies' : 'Topologies',
'Dynamic process creation' : 'Dyn. process',
'Error handlers' : 'Error',
'There are no unnecessary features' : 'No',
'Other' : 'other' },
'Q28' :
{ 'Yes, compatibility is very important for me.' : 'Very important',
'API should be clearly versioned.' : 'Versioned API',
'I prefer to have new API for better performance.' : 'New API for performance',
'I prefer to have new API which is simpler and/or easier-to-use.' : 'New API for easier-to-use',
'I do not know or I do not care.' : 'No idea',
'Other' : 'other'
},
'Q29' :
{ '1' : 'Portability',
'2' : '2',
'3' : '3',
'4' : '4',
'5' : 'Performance' },
}
multi_answer = [ 'Q4', 'Q7', 'Q8', 'Q10', 'Q11', 'Q12', 'Q14',
'Q16', 'Q17', 'Q18', 'Q19', 'Q22', 'Q24',
'Q26', 'Q27' ]
sort_answer = [ 'Q1', 'Q4', 'Q7', 'Q8', 'Q10', 'Q11', 'Q12', 'Q13', 'Q14',
'Q15', 'Q16', 'Q17', 'Q19', 'Q22', 'Q23', 'Q24', 'Q25',
'Q26', 'Q27', 'Q28' ]
print_other = [ 'Q4', 'Q7', 'Q8', 'Q10', 'Q11', 'Q12', 'Q14', 'Q17', 'Q19',
'Q21', 'Q22', 'Q23', 'Q24', 'Q25', 'Q26', 'Q27', 'Q28' ]
#color_list = [ 'r', 'b', 'g', 'c', 'm', 'y', 'k' ]
color_list = [ '#7e1e9c', '#15b01a', '#0343df', '#ff81c0', '#677a04',
'#d1b26f', '#00ffff', '#06470c', '#13eac9', '#ae7181',
'#ffff14', '#75bbfd', '#929591', '#c7fdb5', '#bf77f6',
'#9a0eea', '#033500', '#06c2ac', '#c79fef', '#00035b',
'#35063e', '#01ff07', '#650021', '#6e750e', '#ff796c' ]
country_abbrv = { 'Multi-Answer' : 'mans',
'overall' : 'overall',
'Europe:France' : 'FR',
'Europe:Germany' : 'GR',
'Europe:Italy' : 'IT',
'Europe:UK' : 'UK',
'Europe:others' : 'eu',
'Japan' : 'JP',
'Russia' : 'RU',
'USA' : 'US'
}
mpi_cat = { 'MPICH' : 'OSS',
'Open MPI' : 'OSS',
'MVAPICH' : 'OSS',
'MPC MPI' : 'OSS',
'Intel MPI' : 'Vendor',
'Cray MPI' : 'Vendor',
'IBM MPI (BG/Q, PE, Spectrum)' : 'Vendor',
'HPE MPI' : 'Vendor',
'Tianhe MPI' : 'OSS',
'Sunway MPI' : 'Vendor',
'Fujistu MPI' : 'Vendor',
'NEC MPI' : 'Vendor',
'MS MPI' : 'Vendor',
'I do not know' : 'No idea',
'Other' : 'other' },
first_question = 'What is your main occupation?'
country_question = 'Select main country or region of your workplace in past 5 years. [among the countries in Top500 list as of Nov. 2018. If you cannot find your country or region, please specify.]'
def strip_accents(text):
"""
Strip accents from input String.
:param text: The input string.
:type text: String.
:returns: The processed String.
:rtype: String.
"""
try:
text = unicode(text, 'utf-8')
except (TypeError, NameError): # unicode is a default on python 3
pass
text = unicodedata.normalize('NFD', text)
text = text.encode('ascii', 'ignore')
text = text.decode('utf-8')
return str(text)
def conv_date ( dt ) :
#print( "conv_date:'", dt, "'" )
for ds in dt.split() :
for format in DATE_FORMATS :
try :
return datetime.datetime.strptime( ds, format ).date()
except :
continue
print( 'Unknown date format:', ds )
exit( 1 )
def unique ( list ) :
"""
Return a list of unique elements of the original list in the order in which they first
appear in the original list.
:param list: The input list
:return: the list of unique elements maintaining the original order
"""
unique_list = []
for elm in list :
if elm not in unique_list :
unique_list.append( elm )
return unique_list
def tex_conv( str ) :
s = copy.copy( str )
s = s.replace( '#', '\\#' )
s = s.replace( '_', '\\_' )
s = s.replace( '&', '\\&' )
s = s.replace( '^', '\\^' )
s = s.replace( '<', '\\verb!<!' )
s = s.replace( '>', '\\verb!>!' )
return( s )
def get_long_ans_tex( qno, sans ) :
for key, value in qval_tab[qno].items():
if value == sans :
if len( key ) > 45 :
key = '{\small ' + key[:40] + '$\\cdots$}'
elif len( key ) > 40 :
key = '{\small ' + key + '}'
return( key )
return( '' )
qlist = [ 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9',
'Q10', 'Q11', 'Q12', 'Q13', 'Q14', 'Q15', 'Q16', 'Q17', 'Q18', 'Q19',
'Q20', 'Q21', 'Q22', 'Q23', 'Q24', 'Q25', 'Q26', 'Q27', 'Q28', 'Q29'
]
qlist_all = qlist + [ 'all' ]
file_formats = [ 'eps', 'pdf', 'png' ]
parser = argparse.ArgumentParser( description="Survey Analysis" )
parser.add_argument( '-t', '--timeseries',
action='store_true',
help='Draw time series graph' )
parser.add_argument( '-e', '--event',
action='store_true',
help='Show events in the time series graph' )
parser.add_argument( '-s', '--simple',
nargs='?',
action='append',
choices=qlist_all,
help="Question (Qn) to output graph(s) for particular questions. " \
"Or, 'all' graphs of all questions" )
parser.add_argument( '-c', '--cross',
nargs='?',
action='append',
help="A pair of questions (Qn,Qm) " \
"to output cross-tab graph(s). " \
"Or, 'all' to draw graphs of all possible" \
"combinations." )
parser.add_argument( '-m', '--major_region', type=int, default=50,
help="Threshold to be a major region (50)" )
parser.add_argument( '-f', '--format', type=str, default='',
choices=file_formats,
help="File format. Default is 'pdf'" )
parser.add_argument( '-o', '--outdir', type=str, default='',
help="Prepend to all generated graph files" )
#parser.add_argument( '--dry-run', action='store_true', default=False,
# AH: I have no idea what to do with dry-run
# help="Don't execute any outside visible " \
# "actions (such as generating pdfs)." )
#parser.add_argument( '-D', '--log', dest='DEBUG', action='store_true',
# default=False,
# help="Log all steps of the operations (verbose)." )
# We automatically open the files in read mode,
# so if they dont exists an exception
# will be raised by the parsec. Protect if necessary.
parser.add_argument( '-x', '--tex', action='store_true', help='Output TeX' )
parser.add_argument( '-O', '--tex-outdir', type=str, default='',
help="Prepend to all generated TeX files" )
parser.add_argument( '-V', '--csvout', type=str, default='',
help="Output CSV files used to draw all graphs" )
parser.add_argument( '-D', '--DEBUG', action='store_true', help='for debug' )
parser.add_argument( 'csv_in',
nargs=argparse.REMAINDER,
type=argparse.FileType('r'),
help='CSV file name containing the survey data ' +
"(Google Form or Microsoft Forms). " +
"Multiple files can be provided." )
def normalize_df( df ) :
if 'ID' in df.columns :
del df['ID']
if 'Start time' in df.columns :
del df['Start time']
if 'Completion time' in df.columns :
df = df.rename(columns={'Completion time':'Timestamp'})
if 'Email' in df.columns :
del df['Email']
if 'Name' in df.columns :
del df['Name']
return df
args = parser.parse_args()
flag_timeseries = False
flag_show_event = False
if args.timeseries :
flag_timeseries = True
if args.event :
flag_show_event = True
list_simple = []
if args.simple is not None :
if 'all' in args.simple :
list_simple = qlist
else :
list_simple = args.simple
list_cross = []
if args.cross is not None :
if 'all' in args.cross :
i = 0
for q0 in qlist :
i += 1
for q1 in qlist[i:] :
if q0 in multi_answer and q1 in multi_answer :
# we cannot cross-tab on multi-answer questions
continue
list_cross.append( [q0,q1] )
else :
for item in args.cross :
pair = item.split( ',' )
if len( pair ) != 2 :
# print( 'ERR0' )
parser.print_help()
exit( 1 )
elif pair[0] == pair[1] :
# print( 'ERR1' )
parser.print_help()
exit( 1 )
elif pair[0] == 'all' and pair[1] in qlist :
q1 = pair[1]
for q0 in qlist :
if q0 == q1 :
continue;
if q0 in multi_answer and q1 in multi_answer :
# we cannot cross-tab on multi-answer questions
continue
list_cross.append( [q0,q1] )
elif pair[1] == 'all' and pair[0] in qlist :
q0 = pair[0]
for q1 in qlist :
if q0 == q1 :
continue;
if q0 in multi_answer and q1 in multi_answer :
# we cannot cross-tab on multi-answer questions
continue
list_cross.append( [q0,q1] )
elif pair[0] not in qlist and pair[1] not in qlist :
# print( 'ERR2' )
parser.print_help()
exit( 1 )
else :
list_cross.append( pair )
major_region = args.major_region
if args.csv_in is None :
print( 'At least one input CSV file must be specified' )
exit( 1 )
csv_in = args.csv_in
DEBUG = False
if args.DEBUG :
DEBUG = True
FILE_TYPE = ''
flag_timeseries = True
flag_show_event = True
list_simple = [ 'Q1', 'Q2', 'Q11' ]
list_cross = [ ['Q2','Q3'], ['Q3','Q4'], ['Q27','Q29'] ]
flag_tex = args.tex
tex_outdir = args.tex_outdir + '/'
csv_outdir = args.csvout + '/'
if not flag_timeseries and not flag_tex and \
list_simple == [] and list_cross == [] :
flag_timeseries = True
list_simple = qlist
i = 0
j = 0
flag_break = False
for q0 in qlist :
if flag_break :
break
i += 1
for q1 in qlist[i:] :
if q0 in multi_answer and q1 in multi_answer :
break;
j += 1
if DEBUG and j > 4 :
flag_break = True
break
if args.csv_in is [] :
print( "ERROR: CSV filename(s) must be given" )
exit( 1 )
csv_in = args.csv_in.pop(0)
df = pd.read_csv( csv_in, sep=',', dtype=str, keep_default_na=False )
df = normalize_df( df )
dirname = ''
format = args.format
if args.outdir != '' :
dirname = args.outdir + '/'
if args.csv_in is not [] :
for csv_in in args.csv_in :
dfn = pd.read_csv( csv_in, sep=',', dtype=str, keep_default_na=False )
dfn = normalize_df( dfn )
df = pd.concat( [df, dfn], sort=False )
df = df.reset_index(drop=True)
# strip blank(s) of user input value (not choices)
for clm in df.columns :
for idx in df.index :
val = df.at[idx,clm]
if isinstance(val,str) or isinstance(val,int) :
sv = ''
val = val.strip( ';' )
for v in val.split( ';' ) :
v = v.strip()
if sv == '' :
sv = v
else :
sv = sv + ';' + v
df.at[idx,clm] = sv
# shorten long (and wrong?) country names
df.replace( [ 'United Kingdom',
'United States',
'belgium',
'United arab Emirates' ],
[ 'UK',
'USA',
'Belgium',
'UAE' ],
inplace=True )
dict_orgq = {}
for i in range(1,10) :
# print( df.columns[i] )
if df.columns[i] == first_question :
break;
#print( df.columns[i:] )
j = 1;
for column_name in df.columns[i:] :
q = 'Q' + str(j)
if( column_name == country_question ) :
df.rename( columns={column_name: 'country'}, inplace=True )
else :
dict_orgq.setdefault( q, column_name )
df.rename( columns={column_name: q}, inplace=True )
j += 1
for column_name in df :
# print( column_name )
countries = df[ 'country' ]
err = False
# checking for unknown countries and remove accents from all countries name
for country in countries :
stripped = strip_accents(country)
if stripped != country :
print( "Convert %s to %s" % (country, stripped) )
df.replace( country, stripped, inplace=True )
country = stripped
region = region_tab[ stripped ]
if None == region :
print( '????? Unknown Country: ' + stripped )
exit( 1 )
# As we modified tha panda table to remove accents
# we need to update the list of countries
countries = df[ 'country' ]
# adding another Region column
region_list = []
rename_list = []
if major_region <= 1 :
for country in countries :
region = region_tab[ country ]
region_list.append( region )
else :
for country in countries :
region = region_tab[ country ]
if len( df[df['country'] == country] ) >= major_region and \
region != country :
region_list.append( region + ':' + country )
rename_list.append( region )
else :
region_list.append( region )
# adding Region column
df_whole = df.assign( Region = region_list )
if rename_list != [] :
for rename in unique( rename_list ) :
df_whole.replace( rename, rename+':others', inplace=True )
regions = df_whole['Region']
region_list = regions.values.tolist()
#print( 'Region_list:', region_list[:3] )
unique_regions = unique(region_list)
#print( 'Unique_regions:', unique_regions )
# creating region list having more than 'major_region' threshold
regions_major = []
for reg in unique_regions :
df_reg = df_whole.query( 'Region=='+'"'+reg+'"' )
if len( df_reg ) >= major_region :
regions_major.append( reg )
regions_major.sort()
#print( regions_major )
regions_minor = []
for reg in unique_regions :
if reg not in regions_major :
regions_minor.append( reg )
whole = 'overall'
dict_qno = {}
dict_others = {}
for qno in qval_tab.keys() :
list_sum = []
dict_tmp = {}
legend = qval_tab[qno]
# decompose answers if this is a multiple-answer question and
# convert to percent numbers on whole data
dict_ans = { 'other' : 0 }
for ans in legend.values() :
dict_ans.setdefault( str(ans), 0 )
tmp = df_whole[qno]
# print( 'tmp\n', tmp )
nn = 0
if qno in multi_answer :
for mans in tmp :
n = 0
list_ans = mans.split( ';' )
for ans in list_ans :
if ans in legend.keys() :
dict_ans[legend[ans]] += 1
n = 1
elif len( ans ) > 0 :
dict_ans['other'] += 1
n = 1
nn += n
else :
for ans in tmp :
if isinstance( ans, str ) :
if ans in legend.keys() :
nn += 1
dict_ans[legend[ans]] += 1
elif len( ans ) > 0 :
nn += 1
dict_ans['other'] += 1
# print( 'dict_ans\n', dict_ans )
ser = pd.Series( data=dict_ans, dtype=float )
# sum = ser.sum()
# sum = len( tmp.index )
sum = nn
list_sum.append( sum )
for i in range( ser.size ) :
ser.iat[i] = ser.iat[i] / float(sum) * 100.0
dfq = pd.DataFrame( { whole : ser } )
if flag_tex :
tex_list = []
tex_list.append( '\\begin{table}[htb]%\n' )
tex_list.append( '\\begin{center}%\n' )
tex_list.append( '\\caption{' + qno + ': ' + dict_orgq[qno] + '}%\n' )
tex_list.append( '\\label{tab:' + qno + '-ans}%\n' )
tex_list.append( '\\begin{tabular}{l|l|r}%\n' )
tex_list.append( '\\hline%\n' )
tex_list.append( 'Choice & Abbrv. & \# Answers \\\\%\n' )
tex_list.append( '\\hline%\n' )
sum = 0
for k, v in dict_ans.items() :
sum = sum + v
flag_other = False
if qno in sort_answer :
for k, v in sorted( dict_ans.items(), key=lambda x: -x[1] ) :
if k == 'other' :
flag_other = True
continue
valstr = str( v )
skeystr = tex_conv( k )
lkeystr = tex_conv( get_long_ans_tex( qno, k ) )
# percent = str( round( ((v*100*100)/sum)/100, 1 ) )
percent = str( round( ((v*100*100)/nn)/100, 1 ) )
tex_list.append( lkeystr + ' & ' + skeystr + ' & ' + \
valstr + ' (' + percent + '\%)' + \
' \\\\%\n')
else :
for k, v in dict_ans.items() :
if k == 'other' :
flag_other = True
continue
valstr = str( v )
skeystr = tex_conv( k )
lkeystr = tex_conv( get_long_ans_tex( qno, k ) )
# percent = str( round( ((v*100*100)/sum)/100, 1 ) )
percent = str( round( ((v*100*100)/nn)/100, 1 ) )
tex_list.append( lkeystr + ' & ' + skeystr + ' & ' + \
valstr + ' (' + percent + '\%)' + \
' \\\\%\n')
if flag_other :
key = 'other'
if dict_ans[key] > 0 :
v = dict_ans[key]
valstr = str( v )
# percent = str( round( ((v*100*100)/sum)/100, 1 ) )
percent = str( round( ((v*100*100)/nn)/100, 1 ) )
tex_list.append( key + ' & - & ' + valstr + \
' (' + percent + '\%)' + \
' \\\\%\n')
tex_list.append( '\\hline%\n' )
if qno in multi_answer :
tex_list.append( '\multicolumn{2}{c}{total} & ' + str( sum ) + \
' (' + str( nn ) + ')\\\\%\n' )
else :
tex_list.append( '\multicolumn{2}{c}{total} & ' + str( sum ) + \
' \\\\%\n' )
tex_list.append( '\\hline%\n' )
tex_list.append( '\\end{tabular}%\n' )
tex_list.append( '\\end{center}%\n' )
tex_list.append( '\\end{table}%\n' )
with open( tex_outdir + qno + '-ans.tex', mode='w' ) as f :
f.writelines( tex_list )
# convert to percent numbers for each region
list_others = []
for reg in regions_major :
dict_ans = { 'other' : 0 }
for ans in legend.values() :
dict_ans.setdefault( str(ans), 0 )
tmp = df_whole[df_whole['Region']==reg][qno]
#print( 'TMP\n', tmp )
sum = 0
if qno in multi_answer :
for mans in tmp :
a = 0
list_ans = mans.split( ';' )
for ans in list_ans :
if ans in legend.keys() :
dict_ans[legend[ans]] += 1
a = 1
elif len( ans ) > 0 :
dict_ans['other'] += 1
list_others.append( reg + ': ' + ans )
a = 1
sum += a
else :
for ans in tmp :
if ans in legend.keys() :
dict_ans[legend[ans]] += 1
sum += 1
elif len( ans ) > 0 :
dict_ans['other'] += 1
list_others.append( reg + ': ' + ans )
sum += 1
ser = pd.Series( data=dict_ans, dtype=float )
list_sum.append( sum )
for i in range( ser.size ) :
ser.iat[i] = ser.iat[i] / float(sum) * 100.0
dfq[reg] = ser