PAPI 7.1.0.0
Loading...
Searching...
No Matches
driver.h File Reference
Include dependency graph for driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define USE_ALL_EVENTS   0x0
 
#define READ_FROM_FILE   0x1
 
#define BENCH_FLOPS   0x01
 
#define BENCH_BRANCH   0x02
 
#define BENCH_DCACHE_READ   0x04
 
#define BENCH_DCACHE_WRITE   0x08
 
#define BENCH_ICACHE_READ   0x10
 
#define BENCH_VEC   0x20
 
#define BENCH_INSTR   0x40
 

Functions

int parseArgs (int argc, char **argv, cat_params_t *params)
 
int setup_evts (char *inputfile, char ***basenames, int **cards)
 
unsigned long int omp_get_thread_num_wrapper ()
 
int check_cards (cat_params_t mode, int **indexmemo, char **basenames, int *cards, int ct, int nevts, evstock *data)
 
void combine_qualifiers (int n, int pk, int ct, char **list, char *name, char **allevts, int *track, int flag, int *bitmap)
 
void trav_evts (evstock *stock, int pk, int *cards, int nevts, int selexnsize, int mode, char **allevts, int *track, int *indexmemo, char **basenames)
 
int perm (int n, int k)
 
int comb (int n, int k)
 
void testbench (char **allevts, int cmbtotal, hw_desc_t *hw_desc, cat_params_t params, int myid, int nprocs)
 
void print_usage ()
 
static int parse_line (FILE *input, char **key, long long *value)
 
static void read_conf_file (char *conf_file, hw_desc_t *hw_desc)
 
static hw_desc_tobtain_hardware_description (char *conf_file_name)
 

Macro Definition Documentation

◆ BENCH_BRANCH

#define BENCH_BRANCH   0x02

Definition at line 15 of file driver.h.

◆ BENCH_DCACHE_READ

#define BENCH_DCACHE_READ   0x04

Definition at line 16 of file driver.h.

◆ BENCH_DCACHE_WRITE

#define BENCH_DCACHE_WRITE   0x08

Definition at line 17 of file driver.h.

◆ BENCH_FLOPS

#define BENCH_FLOPS   0x01

Definition at line 14 of file driver.h.

◆ BENCH_ICACHE_READ

#define BENCH_ICACHE_READ   0x10

Definition at line 18 of file driver.h.

◆ BENCH_INSTR

#define BENCH_INSTR   0x40

Definition at line 20 of file driver.h.

◆ BENCH_VEC

#define BENCH_VEC   0x20

Definition at line 19 of file driver.h.

◆ READ_FROM_FILE

#define READ_FROM_FILE   0x1

Definition at line 12 of file driver.h.

◆ USE_ALL_EVENTS

#define USE_ALL_EVENTS   0x0

Definition at line 11 of file driver.h.

Function Documentation

◆ check_cards()

int check_cards ( cat_params_t  mode,
int **  indexmemo,
char **  basenames,
int cards,
int  ct,
int  nevts,
evstock data 
)

Definition at line 196 of file main.c.

197{
198 int i, j, minim, n, cmbtotal = 0;
199 char *name;
200 int mode = params.mode;
201 int pk = params.subsetsize;
202
203 // User provided a file of events.
204 if(READ_FROM_FILE == mode)
205 {
206 // Compute the total number of qualifier combinations and allocate memory to store them.
207 if (NULL == ((*indexmemo) = (int*)malloc(ct*sizeof(int)))) {
208 fprintf(stderr, "Failed to allocate memory.\n");
209 return 0;
210 }
211
212 // Find the index in the main stock whose event corresponds to that in the file provided.
213 // This simplifies looking up event qualifiers later.
214 for(i = 0; i < ct; ++i)
215 {
216 if(NULL == basenames[i])
217 {
218 (*indexmemo)[i] = -1;
219 cmbtotal -= 1;
220 continue;
221 }
222
223 // j is the index of the event name provided by the user.
224 for(j = 0; j < nevts; ++j)
225 {
226 name = evt_name(data, j);
227 if(strcmp(basenames[i], name) == 0)
228 {
229 break;
230 }
231 }
232
233 // If the event name provided by the user does not match any of the main event
234 // names in the architecture, then it either contains qualifiers or it does not
235 // exist.
236 if(cards[i] != 0 && j == nevts)
237 {
238 fprintf(stderr, "The provided event '%s' is either not in the architecture or contains qualifiers.\n" \
239 "If the latter, use '0' in place of the provided '%d'.\n", basenames[i], cards[i]);
240 cards[i] = 0;
241 }
242
243 // If an invalid (negative) qualifier count was given, use zero qualifiers.
244 if(cards[i] < 0)
245 {
246 fprintf(stderr, "The qualifier count (provided for event '%s') cannot be negative.\n", basenames[i]);
247 cards[i] = 0;
248 }
249
250 (*indexmemo)[i] = j;
251 }
252
253 // Count the total number of events to test.
254 for(i = 0; i < ct; ++i)
255 {
256 // If no qualifiers are used, then just count the event itself.
257 if(cards[i] <= 0)
258 {
259 cmbtotal += 1;
260 continue;
261 }
262
263 // Get the number of qualifiers which belong to the main event.
264 if((*indexmemo)[i] != -1)
265 {
266 n = num_quals(data, (*indexmemo)[i]);
267 }
268 else
269 {
270 n = 0;
271 }
272
273 // If the user specifies to use more qualifiers than are available
274 // for the main event, do not use any qualifiers. Otherwise, count
275 // the number of combinations of qualifiers for the main event.
276 minim = cards[i];
277 if(cards[i] > n || cards[i] < 0)
278 {
279 minim = 0;
280 }
281 cmbtotal += comb(n, minim);
282 }
283 }
284 // User wants to inspect all events in the architecture.
285 else
286 {
287 for(i = 0; i < nevts; ++i)
288 {
289 // Get the number of qualifiers which belong to the main event.
290 n = num_quals(data, i);
291
292 // If the user specifies to use more qualifiers than are available
293 // for the main event, do not use any qualifiers. Otherwise, count
294 // the number of combinations of qualifiers for the main event.
295 minim = pk;
296 if(pk > n || pk < 0)
297 {
298 minim = 0;
299 }
300 cmbtotal += comb(n, minim);
301 }
302 }
303
304 return cmbtotal;
305}
int i
#define READ_FROM_FILE
Definition: driver.h:12
int num_quals(evstock *stock, int base_evt)
Definition: eventstock.c:178
char * evt_name(evstock *stock, int index)
Definition: eventstock.c:193
int comb(int n, int k)
Definition: main.c:804
FILE * stderr
const char * name
Definition: rocs.c:225
int mode
Definition: params.h:6
Here is the call graph for this function:
Here is the caller graph for this function:

◆ comb()

int comb ( int  n,
int  k 
)

Definition at line 804 of file main.c.

805{
806 return perm(n, k)/perm(k, k);
807}
int perm(int n, int k)
Definition: main.c:789
Here is the call graph for this function:
Here is the caller graph for this function:

◆ combine_qualifiers()

void combine_qualifiers ( int  n,
int  pk,
int  ct,
char **  list,
char *  name,
char **  allevts,
int track,
int  flag,
int bitmap 
)

Definition at line 585 of file main.c.

586{
587 int original;
588 int counter;
589 int i;
590
591 // Set flag in the array.
592 original = bitmap[ct];
593 bitmap[ct] = flag;
594
595 // Only make recursive calls if there are more items.
596 // Ensure proper cardinality.
597 counter = 0;
598 for(i = 0; i < n; ++i)
599 {
600 counter += bitmap[i];
601 }
602
603 // Cannot use more qualifiers than are available.
604 if(ct+1 < n)
605 {
606 // Make recursive calls both with and without a given qualifier.
607 // Recursion cannot exceed the number of qualifiers specified by
608 // the user.
609 if(counter < pk)
610 {
611 combine_qualifiers(n, pk, ct+1, list, name, allevts, track, 1, bitmap);
612 }
613 combine_qualifiers(n, pk, ct+1, list, name, allevts, track, 0, bitmap);
614 }
615 // Qualifier count matches that specified by the user.
616 else
617 {
618 if(counter == pk)
619 {
620 // Construct the qualifier combination string.
621 char* chunk;
622 size_t evtsize = strlen(name)+1;
623 for(i = 0; i < n; ++i)
624 {
625 if(bitmap[i] == 1)
626 {
627 // Add one to account for the colon in front of the qualifier.
628 evtsize += strlen(list[i])+1;
629 }
630 }
631
632 if (NULL == (chunk = (char*)malloc((evtsize+1)*sizeof(char)))) {
633 fprintf(stderr, "Failed to allocate memory.\n");
634 return;
635 }
636
637 strcpy(chunk,name);
638 for(i = 0; i < n; ++i)
639 {
640 if(bitmap[i] == 1)
641 {
642 strcat(chunk,":");
643 strcat(chunk,list[i]);
644 }
645 }
646
647 // Add qualifier combination string to the list.
648 allevts[*track] = strdup(chunk);
649 *track += 1;
650
651 free(chunk);
652 }
653 }
654
655 // Undo effect of recursive call to combine other qualifiers.
656 bitmap[ct] = original;
657
658 return;
659}
void combine_qualifiers(int n, int pk, int ct, char **list, char *name, char **allevts, int *track, int flag, int *bitmap)
Definition: main.c:585
Here is the call graph for this function:
Here is the caller graph for this function:

◆ obtain_hardware_description()

static hw_desc_t * obtain_hardware_description ( char *  conf_file_name)
static

◆ omp_get_thread_num_wrapper()

unsigned long int omp_get_thread_num_wrapper ( )

Definition at line 191 of file main.c.

191 {
192 return omp_get_thread_num();
193}
Here is the caller graph for this function:

◆ parse_line()

static int parse_line ( FILE *  input,
char **  key,
long long value 
)
static

◆ parseArgs()

int parseArgs ( int  argc,
char **  argv,
cat_params_t params 
)

Definition at line 988 of file main.c.

988 {
989 char *name = argv[0];
990 char *tmp = NULL;
991 int dirlen = 0;
992 int kflag = 0;
993 int inflag = 0;
994 FILE *test = NULL;
995 int len, status = 0;
996
997 params->subsetsize = -1;
998
999 // Parse the command line arguments
1000 while(--argc){
1001 ++argv;
1002 if( !strcmp(argv[0],"-h") ){
1004 return -1;
1005 }
1006 if( argc > 1 && !strcmp(argv[0],"-k") ){
1007 params->subsetsize = atoi(argv[1]);
1008 if( params->subsetsize < 0 )
1009 {
1010 params->subsetsize = 0;
1011 fprintf(stderr, "Warning: Cannot pass a negative value to -k.\n");
1012 }
1013 params->mode = USE_ALL_EVENTS;
1014 kflag = 1;
1015 --argc;
1016 ++argv;
1017 continue;
1018 }
1019 if( argc > 1 && !strcmp(argv[0],"-n") ){
1020 params->max_iter = atoi(argv[1]);
1021 --argc;
1022 ++argv;
1023 continue;
1024 }
1025 if( argc > 1 && !strcmp(argv[0],"-conf") ){
1026 params->conf_file = argv[1];
1027 --argc;
1028 ++argv;
1029 continue;
1030 }
1031 if( argc > 1 && !strcmp(argv[0],"-in") ){
1032 params->inputfile = argv[1];
1033 params->mode = READ_FROM_FILE;
1034 inflag = 1;
1035 --argc;
1036 ++argv;
1037 continue;
1038 }
1039 if( argc > 1 && !strcmp(argv[0],"-out") ){
1040 tmp = argv[1];
1041 --argc;
1042 ++argv;
1043 continue;
1044 }
1045 if( !strcmp(argv[0],"-verbose") ){
1046 params->show_progress = 1;
1047 continue;
1048 }
1049 if( !strcmp(argv[0],"-quick") ){
1050 params->quick = 1;
1051 continue;
1052 }
1053 if( !strcmp(argv[0],"-branch") ){
1054 params->bench_type |= BENCH_BRANCH;
1055 continue;
1056 }
1057 if( !strcmp(argv[0],"-dcr") ){
1058 params->bench_type |= BENCH_DCACHE_READ;
1059 continue;
1060 }
1061 if( !strcmp(argv[0],"-dcw") ){
1062 params->bench_type |= BENCH_DCACHE_WRITE;
1063 continue;
1064 }
1065 if( !strcmp(argv[0],"-flops") ){
1066 params->bench_type |= BENCH_FLOPS;
1067 continue;
1068 }
1069 if( !strcmp(argv[0],"-ic") ){
1070 params->bench_type |= BENCH_ICACHE_READ;
1071 continue;
1072 }
1073 if( !strcmp(argv[0],"-vec") ){
1074 params->bench_type |= BENCH_VEC;
1075 continue;
1076 }
1077 if( !strcmp(argv[0],"-instr") ){
1078 params->bench_type |= BENCH_INSTR;
1079 continue;
1080 }
1081
1083 return -1;
1084 }
1085
1086 // MODE INFO: mode 1 uses file; mode 2 uses all native events.
1087 if(READ_FROM_FILE == params->mode)
1088 {
1089 test = fopen(params->inputfile, "r");
1090 if(test == NULL)
1091 {
1092 fprintf(stderr, "Could not open %s. Exiting...\n", params->inputfile);
1093 return -1;
1094 }
1095 fclose(test);
1096 }
1097
1098 // Make sure user does not specify both modes simultaneously.
1099 if(kflag == 1 && inflag == 1)
1100 {
1101 fprintf(stderr, "Cannot use -k flag with -in flag. Exiting...\n");
1102 return -1;
1103 }
1104
1105 // Make sure user specifies mode explicitly.
1106 if(kflag == 0 && inflag == 0)
1107 {
1109 return -1;
1110 }
1111
1112 // Make sure output path was provided.
1113 if(tmp == NULL)
1114 {
1115 fprintf(stderr, "Output path not provided. Exiting...\n");
1116 return -1;
1117 }
1118
1119 // Write output files in the user-specified directory.
1120 dirlen = strlen(tmp);
1121 params->outputdir = (char*)malloc((2+dirlen)*sizeof(char));
1122
1123 if (NULL == params->outputdir) {
1124 fprintf(stderr, "Failed to allocate memory.\n");
1125 return -1;
1126 }
1127
1128 len = snprintf( params->outputdir, 2+dirlen, "%s/", tmp);
1129 if( len < 1+dirlen )
1130 {
1131 fprintf(stderr, "Problem with output directory name.\n");
1132 return -1;
1133 }
1134
1135 // Make sure files can be written to the provided path.
1136 status = access(params->outputdir, W_OK);
1137 if(status != 0)
1138 {
1139 fprintf(stderr, "Permission to write files to \"%s\" denied. Make sure the path exists and is writable.\n", tmp);
1140 return -1;
1141 }
1142
1143 return 0;
1144}
double tmp
#define BENCH_DCACHE_WRITE
Definition: driver.h:17
#define BENCH_FLOPS
Definition: driver.h:14
#define BENCH_VEC
Definition: driver.h:19
#define BENCH_DCACHE_READ
Definition: driver.h:16
#define USE_ALL_EVENTS
Definition: driver.h:11
#define BENCH_BRANCH
Definition: driver.h:15
void print_usage()
#define BENCH_INSTR
Definition: driver.h:20
#define BENCH_ICACHE_READ
Definition: driver.h:18
int fclose(FILE *__stream)
int quick
Definition: params.h:10
char * conf_file
Definition: params.h:11
char * inputfile
Definition: params.h:12
int show_progress
Definition: params.h:9
int subsetsize
Definition: params.h:5
int bench_type
Definition: params.h:8
int max_iter
Definition: params.h:7
char * outputdir
Definition: params.h:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perm()

int perm ( int  n,
int  k 
)

Definition at line 789 of file main.c.

790{
791 int i;
792 int prod = 1;
793 int diff = n-k;
794
795 for(i = n; i > diff; --i)
796 {
797 prod *= i;
798 }
799
800 return prod;
801}
Here is the caller graph for this function:

◆ print_usage()

void print_usage ( )
Here is the caller graph for this function:

◆ read_conf_file()

static void read_conf_file ( char *  conf_file,
hw_desc_t hw_desc 
)
static

◆ setup_evts()

int setup_evts ( char *  inputfile,
char ***  basenames,
int **  cards 
)

Definition at line 500 of file main.c.

501{
502 size_t linelen = 0;
503 int cnt = 0, status = 0;
504 char *line = NULL, *place;
505 FILE *input;
506 int evnt_count = 256;
507
508 char **names = (char **)calloc(evnt_count, sizeof(char *));
509 int *cards = (int *)calloc(evnt_count, sizeof(int));
510
511 if (NULL == names || NULL == cards) {
512 fprintf(stderr, "Failed to allocate memory.\n");
513 return 0;
514 }
515
516 // Read the base event name and cardinality columns.
517 input = fopen(inputfile, "r");
518 for(cnt=0; 1; cnt++)
519 {
520 ssize_t ret_val = getline(&line, &linelen, input);
521 if( ret_val < 0 )
522 break;
523 if( cnt >= evnt_count )
524 {
525 evnt_count *= 2;
526 names = realloc(names, evnt_count*sizeof(char *));
527 cards = realloc(cards, evnt_count*sizeof(int));
528
529 if (NULL == names || NULL == cards) {
530 fprintf(stderr, "Failed to allocate memory.\n");
531 return 0;
532 }
533 }
534
535 place = strstr(line, " ");
536
537 // If this line was commented, silently ignore it.
538 if(strlen(line) > 0 && line[0] == '#') {
539 names[cnt] = NULL;
540 cards[cnt] = -1;
541 cnt--;
542
543 free(line);
544 line = NULL;
545 linelen = 0;
546 continue;
547 } else if( NULL == place ) {
548 fprintf(stderr,"problem with line: '%s'\n",line);
549 names[cnt] = NULL;
550 cards[cnt] = -1;
551 cnt--;
552
553 free(line);
554 line = NULL;
555 linelen = 0;
556 continue;
557 }
558
559 names[cnt] = NULL;
560 status = sscanf(line, "%ms %d", &(names[cnt]), &(cards[cnt]) );
561
562 // If this line was malformed, ignore it.
563 if(2 != status)
564 {
565 fprintf(stderr,"problem with line: '%s'\n",line);
566 names[cnt] = NULL;
567 cards[cnt] = -1;
568 cnt--;
569 }
570
571 free(line);
572 line = NULL;
573 linelen = 0;
574 }
575 free(line);
576 fclose(input);
577
578 *basenames = names;
579 *evnt_cards = cards;
580
581 return cnt;
582}
const char * names[NUM_EVENTS]
__ssize_t ssize_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testbench()

void testbench ( char **  allevts,
int  cmbtotal,
hw_desc_t hw_desc,
cat_params_t  params,
int  myid,
int  nprocs 
)

Definition at line 829 of file main.c.

830{
831 int i;
832 int junk=((int)getpid()+123)/456;
833 int low = myid*(cmbtotal/nprocs);
834 int cap = (myid+1)*(cmbtotal/nprocs);
835 int offset = nprocs*(1+cmbtotal/nprocs)-cmbtotal;
836
837 // Divide the work as evenly as possible.
838 if(myid >= offset) {
839 cap += myid-offset+1;
840 low += myid-offset;
841 }
842
843 // Make sure the user provided events and iterate through all events.
844 if( 0 == cmbtotal )
845 {
846 fprintf(stderr, "No events to measure.\n");
847 return;
848 }
849
850 // Run the branch benchmark by default if none are specified.
851 if( 0 == params.bench_type )
852 {
853 params.bench_type |= BENCH_BRANCH;
854 fprintf(stderr, "Warning: No benchmark specified. Running 'branch' by default.\n");
855 }
856
857 /* Benchmark I - Branch*/
858 if( params.bench_type & BENCH_BRANCH )
859 {
860 if(params.show_progress) printf("Branch Benchmarks: ");
861
862 for(i = low; i < cap; ++i)
863 {
864 if(params.show_progress) print_progress((100*i)/cmbtotal);
865
866 if( allevts[i] != NULL )
867 branch_driver(allevts[i], junk, hw_desc, params.outputdir);
868 }
869 if(params.show_progress) print_progress(100);
870 }
871
872 /* Benchmark II - Data Cache Reads*/
873 if( params.bench_type & BENCH_DCACHE_READ )
874 {
875 if ( !params.quick && 0 == myid )
876 {
877 if(params.show_progress)
878 {
879 printf("D-Cache Latencies: 0%%\b\b\b\b");
880 fflush(stdout);
881 }
882 d_cache_driver("cat::latencies", params, hw_desc, 1, 0);
883 if(params.show_progress) printf("100%%\n");
884 }
885
886 if(params.show_progress) printf("D-Cache Read Benchmarks: ");
887 for(i = low; i < cap; ++i)
888 {
889 if(params.show_progress) print_progress2((100*i)/cmbtotal);
890
891 if( allevts[i] != NULL ) {
892 d_cache_driver(allevts[i], params, hw_desc, 0, 0);
893 }
894 }
895 if(params.show_progress) print_progress2(100);
896 }
897
898 /* Benchmark III - Data Cache Writes*/
899 if( params.bench_type & BENCH_DCACHE_WRITE )
900 {
901 // If the READ benchmark was run, do not recompute the latencies.
902 if ( !(params.bench_type & BENCH_DCACHE_READ) && !params.quick)
903 {
904 if(params.show_progress)
905 {
906 printf("D-Cache Latencies: 0%%\b\b\b\b");
907 fflush(stdout);
908 }
909 d_cache_driver("cat::latencies", params, hw_desc, 1, 0);
910 if(params.show_progress) printf("100%%\n");
911 }
912
913 if(params.show_progress) printf("D-Cache Write Benchmarks: ");
914 for(i = low; i < cap; ++i)
915 {
916 if(params.show_progress) print_progress2((100*i)/cmbtotal);
917
918 if( allevts[i] != NULL ) {
919 d_cache_driver(allevts[i], params, hw_desc, 0, 1);
920 }
921 }
922 if(params.show_progress) print_progress2(100);
923 }
924
925 /* Benchmark IV - FLOPS*/
926 if( params.bench_type & BENCH_FLOPS )
927 {
928 if(params.show_progress) printf("FLOP Benchmarks: ");
929
930 for(i = low; i < cap; ++i)
931 {
932 if(params.show_progress) print_progress((100*i)/cmbtotal);
933
934 if( allevts[i] != NULL )
935 flops_driver(allevts[i], hw_desc, params.outputdir);
936 }
937 if(params.show_progress) print_progress(100);
938 }
939
940 /* Benchmark V - Instruction Cache*/
941 if( params.bench_type & BENCH_ICACHE_READ )
942 {
943 if(params.show_progress) printf("I-Cache Benchmarks: ");
944
945 for(i = low; i < cap; ++i)
946 {
947 if(params.show_progress) print_progress2((100*i)/cmbtotal);
948
949 if( allevts[i] != NULL )
950 i_cache_driver(allevts[i], junk, hw_desc, params.outputdir, params.show_progress);
951 }
952 if(params.show_progress) print_progress2(100);
953 }
954
955 /* Benchmark VI - Vector FLOPS*/
956 if( params.bench_type & BENCH_VEC )
957 {
958 if(params.show_progress) printf("Vector FLOP Benchmarks: ");
959
960 for(i = low; i < cap; ++i)
961 {
962 if(params.show_progress) print_progress((100*i)/cmbtotal);
963
964 if( allevts[i] != NULL )
965 vec_driver(allevts[i], hw_desc, params.outputdir);
966 }
967 if(params.show_progress) print_progress(100);
968 }
969
970 /* Benchmark VII - Instructions*/
971 if( params.bench_type & BENCH_INSTR )
972 {
973 if(params.show_progress) printf("Instruction Benchmarks: ");
974
975 for(i = low; i < cap; ++i)
976 {
977 if(params.show_progress) print_progress((100*i)/cmbtotal);
978
979 if( allevts[i] != NULL )
980 instr_driver(allevts[i], hw_desc, params.outputdir);
981 }
982 if(params.show_progress) print_progress(100);
983 }
984
985 return;
986}
void branch_driver(char *papi_event_name, int junk, hw_desc_t *hw_desc, char *outdir)
Definition: branch.c:15
static pthread_t myid[NUM_THREADS]
void d_cache_driver(char *papi_event_name, cat_params_t params, hw_desc_t *hw_desc, int latency_only, int mode)
Definition: dcache.c:17
void flops_driver(char *papi_event_name, hw_desc_t *hw_desc, char *outdir)
Definition: flops.c:841
void i_cache_driver(char *papi_event_name, int junk, hw_desc_t *hw_desc, char *outdir, int show_progress)
Definition: icache.c:13
void instr_driver(char *papi_event_name, hw_desc_t *hw_desc, char *outdir)
static void print_progress2(int prg)
Definition: main.c:819
static void print_progress(int prg)
Definition: main.c:809
FILE * stdout
int
Definition: sde_internal.h:89
void vec_driver(char *papi_event_name, hw_desc_t *hw_desc, char *outdir)
Definition: vec.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trav_evts()

void trav_evts ( evstock stock,
int  pk,
int cards,
int  nevts,
int  selexnsize,
int  mode,
char **  allevts,
int track,
int indexmemo,
char **  basenames 
)

Definition at line 662 of file main.c.

663{
664 int i, j, k, n = 0;
665 char** chosen = NULL;
666 char* name = NULL;
667 int* bitmap = NULL;
668
669 // User provided a file of events.
670 if(READ_FROM_FILE == mode)
671 {
672 for(i = 0; i < selexnsize; ++i)
673 {
674 // Iterate through whole stock. If there are matches, proceed normally using the given cardinalities.
675 j = indexmemo[i];
676 if( -1 == j )
677 {
678 allevts[i] = NULL;
679 continue;
680 }
681
682 // Get event's name and qualifier count.
683 if(j == nevts)
684 {
685 // User a provided specific qualifier combination.
686 name = basenames[i];
687 }
688 else
689 {
690 name = evt_name(stock, j);
691 n = num_quals(stock, j);
692 }
693
694 // Create a list to contain the qualifiers.
695 if(cards[i] > 0)
696 {
697 chosen = (char**)malloc(n*sizeof(char*));
698 bitmap = (int*)calloc(n, sizeof(int));
699
700 if (NULL == chosen || NULL == bitmap) {
701 fprintf(stderr, "Failed to allocate memory.\n");
702 return;
703 }
704
705 // Store the qualifiers for the current event.
706 for(k = 0; k < n; ++k)
707 {
708 chosen[k] = strdup(stock->evts[j][k]);
709 }
710 }
711
712 // Get combinations of all current event's qualifiers.
713 if (n!=0 && cards[i]>0)
714 {
715 combine_qualifiers(n, cards[i], 0, chosen, name, allevts, track, 0, bitmap);
716 combine_qualifiers(n, cards[i], 0, chosen, name, allevts, track, 1, bitmap);
717 }
718 else
719 {
720 allevts[*track] = strdup(name);
721 *track += 1;
722 }
723
724 // Free the space back up.
725 if(cards[i] > 0)
726 {
727 for(k = 0; k < n; ++k)
728 {
729 free(chosen[k]);
730 }
731 free(chosen);
732 free(bitmap);
733 }
734 }
735 }
736 // User wants to inspect all events in the architecture.
737 else
738 {
739 for(i = 0; i < nevts; ++i)
740 {
741 // Get event's name and qualifier count.
742 n = num_quals(stock, i);
743 name = evt_name(stock, i);
744
745 // Show progress to the user.
746 //fprintf(stderr, "CURRENT EVENT: %s (%d/%d)\n", name, (i+1), nevts);
747
748 // Create a list to contain the qualifiers.
749 chosen = (char**)malloc(n*sizeof(char*));
750 bitmap = (int*)calloc(n, sizeof(int));
751
752 if (NULL == chosen || NULL == bitmap) {
753 fprintf(stderr, "Failed to allocate memory.\n");
754 return;
755 }
756
757 // Store the qualifiers for the current event.
758 for(j = 0; j < n; ++j)
759 {
760 chosen[j] = strdup(stock->evts[i][j]);
761 }
762
763 // Get combinations of all current event's qualifiers.
764 if (n!=0)
765 {
766 combine_qualifiers(n, pk, 0, chosen, name, allevts, track, 0, bitmap);
767 combine_qualifiers(n, pk, 0, chosen, name, allevts, track, 1, bitmap);
768 }
769 else
770 {
771 allevts[*track] = strdup(name);
772 *track += 1;
773 }
774
775 // Free the space back up.
776 for(j = 0; j < n; ++j)
777 {
778 free(chosen[j]);
779 }
780 free(chosen);
781 free(bitmap);
782 }
783 }
784
785 return;
786}
char *** evts
Definition: eventstock.h:10
Here is the call graph for this function:
Here is the caller graph for this function: