86
86
__minfo.exponent = 0;
87
87
#endif
88
88
89
- #define PLUGIN_PREFIX "METRIC_X86_ENERGY_PLUGIN_"
89
+ #define PLUGIN_NAME "X86_ENERGY_PLUGIN"
90
+
91
+ #define PLUGIN_PREFIX "METRIC_" PLUGIN_NAME "_"
90
92
91
93
#ifdef BACKEND_SCOREP
92
94
#include <scorep/SCOREP_MetricPlugins.h>
@@ -172,7 +174,7 @@ static size_t parse_buffer_size(const char *s)
172
174
size = strtoll (s , & tmp , 10 );
173
175
174
176
if (size == 0 ) {
175
- fprintf (stderr , "X86_ENERGY_PLUGIN : Failed to parse buffer size ('%s'), " \
177
+ fprintf (stderr , PLUGIN_NAME " : Failed to parse buffer size ('%s'), " \
176
178
"using default %zu\n" , s , DEFAULT_BUF_SIZE );
177
179
return DEFAULT_BUF_SIZE ;
178
180
}
@@ -204,7 +206,7 @@ static int init_devices(void)
204
206
/* init x86_energy */
205
207
source = get_available_sources ();
206
208
if (source == NULL ) {
207
- fprintf (stderr ,"X86_ENERGY_PLUGIN : Could not detect a suitable cpu " \
209
+ fprintf (stderr , PLUGIN_NAME " : Could not detect a suitable cpu " \
208
210
"(errno = %i: %s)\n" , errno , strerror (errno ));
209
211
return -1 ;
210
212
}
@@ -215,7 +217,7 @@ static int init_devices(void)
215
217
int ret ;
216
218
if ((ret = source -> init_device (i )) != 0 )
217
219
{
218
- fprintf (stderr , "X86_ENERGY_PLUGIN : Failed to initialize device " \
220
+ fprintf (stderr , PLUGIN_NAME " : Failed to initialize device " \
219
221
"%i of %i: %i (%s)!\n" , i , nr_packages , ret , strerror (errno ));
220
222
return -1 ;
221
223
}
@@ -248,7 +250,7 @@ void strupr(char * name, char * buffer)
248
250
int i ;
249
251
250
252
if (strlen (name ) >= BUFFERSIZE )
251
- fprintf (stderr , "X86_ENERGY_PLUGIN : %s is too long for the buffer. " \
253
+ fprintf (stderr , PLUGIN_NAME " : %s is too long for the buffer. " \
252
254
"Please increase char buffer size to get correct sensor names.\n" );
253
255
254
256
for (i = 0 ; i <= strlen (name ) && i < BUFFERSIZE - 1 ; i ++ )
@@ -265,15 +267,15 @@ static int32_t init(void) {
265
267
266
268
printf ("init()\n" );
267
269
268
- env = getenv (ENV_PREFIX PLUGIN_PREFIX "INTERVAL_US " );
270
+ env = getenv (ENV_PREFIX PLUGIN_PREFIX "READING_TIME " );
269
271
if (env == NULL ) {
270
272
interval_us = 100000 ;
271
273
}
272
274
else {
273
275
interval_us = atoi (env );
274
276
if (interval_us == 0 ) {
275
- fprintf (stderr , "X86_ENERGY_PLUGIN : Could not parse " \
276
- "%sINTERVAL_US , using 100 ms\n" , ENV_PREFIX PLUGIN_PREFIX );
277
+ fprintf (stderr , PLUGIN_NAME " : Could not parse " \
278
+ "%sREADING_TIME , using 100 ms\n" , ENV_PREFIX PLUGIN_PREFIX );
277
279
interval_us = 100000 ;
278
280
}
279
281
}
@@ -288,7 +290,7 @@ static int32_t init(void) {
288
290
buf_size = parse_buffer_size (env );
289
291
if (buf_size < 1024 )
290
292
{
291
- fprintf (stderr , "X86_ENERGY_PLUGIN : Given buffer size (%zu) " \
293
+ fprintf (stderr , PLUGIN_NAME " : Given buffer size (%zu) " \
292
294
"too small, falling back to default (%zu)\n" , buf_size , \
293
295
DEFAULT_BUF_SIZE );
294
296
buf_size = DEFAULT_BUF_SIZE ;
@@ -308,7 +310,7 @@ static int32_t init(void) {
308
310
offset = atof (env );
309
311
if (offset < 0 )
310
312
{
311
- fprintf (stderr , "X86_ENERGY_PLUGIN : Power offset can't be negative " \
313
+ fprintf (stderr , PLUGIN_NAME " : Power offset can't be negative " \
312
314
"setting value to zero\n" );
313
315
offset = 0 ;
314
316
}
@@ -338,7 +340,7 @@ static metric_properties_t * get_event_info(char * event_name) {
338
340
metric_properties_t * return_values ;
339
341
return_values = malloc (numberOfMetrics * sizeof (metric_properties_t ));
340
342
if (return_values == NULL ) {
341
- fprintf (stderr , "X86_ENERGY_PLUGIN : Unable to allocate space for " \
343
+ fprintf (stderr , PLUGIN_NAME " : Unable to allocate space for " \
342
344
"counter information\n" );
343
345
return NULL ;
344
346
}
@@ -388,7 +390,7 @@ static metric_properties_t * get_event_info(char * event_name) {
388
390
metric_properties_t * return_values ;
389
391
return_values = malloc (numberOfMetrics * sizeof (metric_properties_t ));
390
392
if (return_values == NULL ) {
391
- fprintf (stderr , "X86_ENERGY_PLUGIN : Unable to allocate space for " \
393
+ fprintf (stderr , PLUGIN_NAME " : Unable to allocate space for " \
392
394
"counter information\n" );
393
395
return NULL ;
394
396
}
@@ -445,7 +447,7 @@ static metric_properties_t * get_event_info(char * event_name) {
445
447
metric_properties_t * return_values ;
446
448
return_values = malloc ((nr_packages + 2 ) * sizeof (metric_properties_t ));
447
449
if (return_values == NULL ) {
448
- fprintf (stderr , "X86_ENERGY_PLUGIN : Unable to allocate space " \
450
+ fprintf (stderr , PLUGIN_NAME " : Unable to allocate space " \
449
451
"for counter information\n" );
450
452
return NULL ;
451
453
}
@@ -509,7 +511,7 @@ static metric_properties_t * get_event_info(char * event_name) {
509
511
}
510
512
}
511
513
512
- fprintf (stderr , "X86_ENERGY_PLUGIN : Unknown Event %s\n" , event_name );
514
+ fprintf (stderr , PLUGIN_NAME " : Unknown Event %s\n" , event_name );
513
515
return NULL ;
514
516
}
515
517
@@ -532,11 +534,11 @@ static void * thread_report(void * ignore) {
532
534
if (wtime == NULL )
533
535
return NULL ;
534
536
if (sample_count >= num_entries ) {
535
- fprintf (stderr , "X86_ENERGY_PLUGIN : buffer size of %zu is to small.\n" ,
537
+ fprintf (stderr , PLUGIN_NAME " : buffer size of %zu is to small.\n" ,
536
538
buf_size );
537
- fprintf (stderr , "X86_ENERGY_PLUGIN : Increase the buffer size with the " \
539
+ fprintf (stderr , PLUGIN_NAME " : Increase the buffer size with the " \
538
540
"environment variable %sSIZE\n" ,ENV_PREFIX PLUGIN_PREFIX );
539
- fprintf (stderr , "X86_ENERGY_PLUGIN : Stopping sample thread\n" );
541
+ fprintf (stderr , PLUGIN_NAME " : Stopping sample thread\n" );
540
542
return NULL ;
541
543
}
542
544
@@ -605,20 +607,20 @@ static int32_t add_counter(char * event_name) {
605
607
}
606
608
607
609
if (!is_thread_created && !synchronous ) {
608
- fprintf (stderr , "X86_ENERGY_PLUGIN : using buffer with %zu entries per " \
610
+ fprintf (stderr , PLUGIN_NAME " : using buffer with %zu entries per " \
609
611
"feature\n" , num_entries );
610
612
/* allocate space for time values */
611
613
timestamps = malloc (num_entries * sizeof (struct timestamp_scorep_gettime ));
612
614
if (timestamps == NULL )
613
615
{
614
- fprintf (stderr , "X86_ENERGY_PLUGIN : Failed to allocate memory for " \
616
+ fprintf (stderr , PLUGIN_NAME " : Failed to allocate memory for " \
615
617
"timestamps (%zu B)\n" , num_entries *
616
618
sizeof (struct timestamp_scorep_gettime ));
617
619
return -1 ;
618
620
}
619
621
if (pthread_create (& thread , NULL , & thread_report , NULL ) != 0 )
620
622
{
621
- fprintf (stderr , "X86_ENERGY_PLUGIN : Failed to create measurement " \
623
+ fprintf (stderr , PLUGIN_NAME " : Failed to create measurement " \
622
624
"thread!\n" );
623
625
return -1 ;
624
626
}
@@ -637,7 +639,7 @@ static int32_t add_counter(char * event_name) {
637
639
event_list [i ].reg_values = malloc (num_entries * sizeof (union value ));
638
640
if (event_list [i ].reg_values == NULL )
639
641
{
640
- fprintf (stderr , "X86_ENERGY_PLUGIN : Failed to allocate " \
642
+ fprintf (stderr , PLUGIN_NAME " : Failed to allocate " \
641
643
"memory for reg_values (%zu B)\n" ,
642
644
num_entries * sizeof (union value ));
643
645
return -1 ;
@@ -769,7 +771,7 @@ static uint64_t get_all_values(int32_t id, timevalue_t **result)
769
771
/* add the offset for the BLADE */
770
772
if (blade == 1 && sumtype == ENERGY )
771
773
{
772
- /* convertation to J is needed for rapl */
774
+ /* converting to J is needed for rapl */
773
775
sum .dbl += offset /1000.0 * (timestamps [i ].millisecs - \
774
776
timestamps [0 ].millisecs )/1000.0 ;
775
777
}
@@ -804,8 +806,9 @@ static uint64_t get_all_values(int32_t id, timevalue_t **result)
804
806
return sample_count ;
805
807
}
806
808
809
+ // Plugin name
807
810
#ifdef BACKEND_SCOREP
808
- SCOREP_METRIC_PLUGIN_ENTRY ( x86energy_plugin )
811
+ SCOREP_METRIC_PLUGIN_ENTRY ( x86_energy_plugin )
809
812
#endif
810
813
#ifdef BACKEND_VTRACE
811
814
vt_plugin_cntr_info get_info ()
0 commit comments