File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ int main(int argc, const char *argv[])
43
43
int i ,a [100 ],b [100 ],c [100 ];
44
44
uint32_t total = 0 ;
45
45
int lcore_id ;
46
+ int numEvents = argc - 1 ;
46
47
47
48
/* Seed for predictable rand() results */
48
49
srand (0 );
@@ -80,22 +81,17 @@ int main(int argc, const char *argv[])
80
81
PCM .pcm_c_get_cycles == NULL || PCM .pcm_c_get_instr == NULL ||
81
82
PCM .pcm_c_build_core_event == NULL || PCM .pcm_c_get_core_event == NULL )
82
83
return -1 ;
83
- switch (argc - 1 )
84
- {
85
- case 4 :
86
- PCM .pcm_c_build_core_event (3 ,argv [3 ]);
87
- case 3 :
88
- PCM .pcm_c_build_core_event (2 ,argv [2 ]);
89
- case 2 :
90
- PCM .pcm_c_build_core_event (1 ,argv [2 ]);
91
- case 1 :
92
- PCM .pcm_c_build_core_event (0 ,argv [1 ]);
93
- case 0 :
94
- break ;
95
- default :
96
- printf ("Number of arguments are too many! exit...\n" );
97
- return -2 ;
98
- }
84
+
85
+ if (numEvents > 4 )
86
+ {
87
+ printf ("Number of arguments are too many! exit...\n" );
88
+ return -2 ;
89
+ }
90
+
91
+ for (int i = 0 ; i < numEvents ; ++ i )
92
+ {
93
+ PCM .pcm_c_build_core_event (i , argv [i + 1 ]);
94
+ }
99
95
100
96
printf ("[c_example] Initializing PCM measurements:\n" );
101
97
PCM .pcm_c_init ();
You can’t perform that action at this time.
0 commit comments