forked from icl-utk-edu/papi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux-coretemp.c
More file actions
796 lines (646 loc) · 21.1 KB
/
linux-coretemp.c
File metadata and controls
796 lines (646 loc) · 21.1 KB
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
#include <string.h>
/* Headers required by PAPI */
#include "papi.h"
#include "papi_internal.h"
#include "papi_vector.h"
#include "papi_memory.h"
#include "linux-coretemp.h"
/* this is what I found on my core2 machine
* but I have not explored this widely yet*/
#define REFRESH_LAT 4000
#define INVALID_RESULT -1000000L
papi_vector_t _coretemp_vector;
/* temporary event */
struct temp_event {
char name[PAPI_MAX_STR_LEN];
char units[PAPI_MIN_STR_LEN];
char description[PAPI_MAX_STR_LEN];
char location[PAPI_MAX_STR_LEN];
char path[PATH_MAX];
int stone;
long count;
struct temp_event *next;
};
// The following macro follows if a string function has an error. It should
// never happen; but it is necessary to prevent compiler warnings. We print
// something just in case there is programmer error in invoking the function.
#define HANDLE_STRING_ERROR {fprintf(stderr,"%s:%i unexpected string function error.\n",__FILE__,__LINE__); exit(-1);}
static CORETEMP_native_event_entry_t * _coretemp_native_events;
static int num_events = 0;
static int is_initialized = 0;
/***************************************************************************/
/****** BEGIN FUNCTIONS USED INTERNALLY SPECIFIC TO THIS COMPONENT *******/
/***************************************************************************/
static struct temp_event* root = NULL;
static struct temp_event *last = NULL;
static int
insert_in_list(char *name, char *units,
char *description, char *filename) {
struct temp_event *temp;
/* new_event path, events->d_name */
temp = (struct temp_event *) papi_calloc(1, sizeof(struct temp_event));
if (temp==NULL) {
PAPIERROR("out of memory!");
/* We should also free any previously allocated data */
return PAPI_ENOMEM;
}
temp->next = NULL;
if (root == NULL) {
root = temp;
}
else if (last) {
last->next = temp;
}
else {
/* Because this is a function, it is possible */
/* we are called with root!=NULL but no last */
/* so add this to keep coverity happy */
papi_free(temp);
PAPIERROR("This shouldn't be possible\n");
return PAPI_ECMP;
}
last = temp;
snprintf(temp->name, PAPI_MAX_STR_LEN, "%s", name);
snprintf(temp->units, PAPI_MIN_STR_LEN, "%s", units);
snprintf(temp->description, PAPI_MAX_STR_LEN, "%s", description);
snprintf(temp->path, PATH_MAX, "%s", filename);
return PAPI_OK;
}
/*
* find all coretemp information reported by the kernel
*/
static int
generateEventList(char *base_dir)
{
char path[PATH_MAX],filename[PATH_MAX];
char modulename[PAPI_MIN_STR_LEN],
location[PAPI_MIN_STR_LEN],
units[PAPI_MIN_STR_LEN],
description[PAPI_MAX_STR_LEN],
name[PAPI_MAX_STR_LEN];
DIR *dir,*d;
FILE *fff;
int count = 0;
struct dirent *hwmonx;
int i,pathnum;
int retlen;
#define NUM_PATHS 2
char paths[NUM_PATHS][PATH_MAX]={
"device","."
};
/* Open "/sys/class/hwmon" */
dir = opendir(base_dir);
if ( dir == NULL ) {
SUBDBG("Can't find %s, are you sure the coretemp module is loaded?\n",
base_dir);
return 0;
}
/* Iterate each /sys/class/hwmonX/device directory */
while( (hwmonx = readdir(dir) ) ) {
if ( !strncmp("hwmon", hwmonx->d_name, 5) ) {
/* Found a hwmon directory */
/* Sometimes the files are in ./, sometimes in device/ */
for(pathnum=0;pathnum<NUM_PATHS;pathnum++) {
retlen = snprintf(path, PATH_MAX, "%s/%s/%s",
base_dir, hwmonx->d_name,paths[pathnum]);
if (retlen <= 0 || PATH_MAX <= retlen) {
SUBDBG("Path length is too long.\n");
return PAPI_EINVAL;
}
SUBDBG("Trying to open %s\n",path);
d = opendir(path);
if (d==NULL) {
continue;
}
/* Get the name of the module */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/name",path);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Module name too long.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) {
snprintf(modulename, PAPI_MIN_STR_LEN, "Unknown");
} else {
if (fgets(modulename,PAPI_MIN_STR_LEN,fff)!=NULL) {
modulename[strlen(modulename)-1]='\0';
}
fclose(fff);
}
SUBDBG("Found module %s\n",modulename);
/******************************************************/
/* Try handling all events starting with in (voltage) */
/******************************************************/
/* arbitrary maximum */
/* the problem is the numbering can be sparse */
/* should probably go back to dirent listing */
for(i=0;i<32;i++) {
/* Try looking for a location label */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/in%d_label",
path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Failed to construct location label.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) {
strncpy(location,"?",PAPI_MIN_STR_LEN);
}
else {
if (fgets(location,PAPI_MIN_STR_LEN,fff)!=NULL) {
location[strlen(location)-1]='\0';
}
fclose(fff);
}
/* Look for input temperature */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/in%d_input",
path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Failed input temperature string.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) continue;
fclose(fff);
retlen = snprintf(name, PAPI_MAX_STR_LEN, "%s:in%i_input", hwmonx->d_name, i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Unable to generate name %s:in%i_input\n", hwmonx->d_name, i);
closedir(dir);
closedir(d);
return ( PAPI_EINVAL );
}
snprintf(units, PAPI_MIN_STR_LEN, "V");
retlen = snprintf(description, PAPI_MAX_STR_LEN, "%s, %s module, label %s",
units,modulename,
location);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("snprintf failed.\n");
return PAPI_EINVAL;
}
if (insert_in_list(name,units,description,filename)!=PAPI_OK) {
goto done_error;
}
count++;
}
/************************************************************/
/* Try handling all events starting with temp (temperature) */
/************************************************************/
for(i=0;i<32;i++) {
/* Try looking for a location label */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/temp%d_label",
path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Location label string failed.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) {
strncpy(location,"?",PAPI_MIN_STR_LEN);
}
else {
if (fgets(location,PAPI_MIN_STR_LEN,fff)!=NULL) {
location[strlen(location)-1]='\0';
}
fclose(fff);
}
/* Look for input temperature */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/temp%d_input",
path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Input temperature string failed.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) continue;
fclose(fff);
retlen = snprintf(name, PAPI_MAX_STR_LEN, "%s:temp%i_input", hwmonx->d_name, i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Unable to generate name %s:temp%i_input\n", hwmonx->d_name, i);
closedir(d);
closedir(dir);
return ( PAPI_EINVAL );
}
snprintf(units, PAPI_MIN_STR_LEN, "degrees C");
retlen = snprintf(description, PAPI_MAX_STR_LEN, "%s, %s module, label %s",
units,modulename,
location);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("snprintf failed.\n");
return PAPI_EINVAL;
}
if (insert_in_list(name,units,description,filename)!=PAPI_OK) {
goto done_error;
}
count++;
}
/************************************************************/
/* Try handling all events starting with fan (fan) */
/************************************************************/
for(i=0;i<32;i++) {
/* Try looking for a location label */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/fan%d_label",
path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Failed to write fan label string.\n");
return PAPI_EINVAL;
}
fff=fopen(filename,"r");
if (fff==NULL) {
strncpy(location,"?",PAPI_MIN_STR_LEN);
}
else {
if (fgets(location,PAPI_MIN_STR_LEN,fff)!=NULL) {
location[strlen(location)-1]='\0';
}
fclose(fff);
}
/* Look for input fan */
retlen = snprintf(filename, PAPI_MAX_STR_LEN, "%s/fan%d_input", path,i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Unable to generate filename %s/fan%d_input\n", path,i);
closedir(d);
closedir(dir);
return ( PAPI_EINVAL );
}
fff=fopen(filename,"r");
if (fff==NULL) continue;
fclose(fff);
retlen = snprintf(name, PAPI_MAX_STR_LEN, "%s:fan%i_input", hwmonx->d_name, i);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("Unable to generate name %s:fan%i_input\n", hwmonx->d_name, i);
closedir(d);
closedir(dir);
return ( PAPI_EINVAL );
}
snprintf(units, PAPI_MIN_STR_LEN, "RPM");
retlen = snprintf(description, PAPI_MAX_STR_LEN, "%s, %s module, label %s",
units,modulename,
location);
if (retlen <= 0 || PAPI_MAX_STR_LEN <= retlen) {
SUBDBG("snprintf failed.\n");
return PAPI_EINVAL;
}
if (insert_in_list(name,units,description,filename)!=PAPI_OK) {
goto done_error;
}
count++;
}
closedir(d);
}
}
}
closedir(dir);
return count;
done_error:
closedir(d);
closedir(dir);
return PAPI_ECMP;
}
static long long
getEventValue( int index )
{
char buf[PAPI_MAX_STR_LEN];
FILE* fp;
long result;
if (_coretemp_native_events[index].stone) {
return _coretemp_native_events[index].value;
}
fp = fopen(_coretemp_native_events[index].path, "r");
if (fp==NULL) {
return INVALID_RESULT;
}
if (fgets(buf, PAPI_MAX_STR_LEN, fp)==NULL) {
result=INVALID_RESULT;
}
else {
result=strtoll(buf, NULL, 10);
}
fclose(fp);
return result;
}
/*****************************************************************************
******************* BEGIN PAPI's COMPONENT REQUIRED FUNCTIONS *************
*****************************************************************************/
/*
* This is called whenever a thread is initialized
*/
static int
_coretemp_init_thread( hwd_context_t *ctx )
{
( void ) ctx;
return PAPI_OK;
}
/* Initialize hardware counters, setup the function vector table
* and get hardware information, this routine is called when the
* PAPI process is initialized (IE PAPI_library_init)
*/
static int
_coretemp_init_component( int cidx )
{
int retval = PAPI_OK;
int i = 0;
struct temp_event *t,*last;
if ( is_initialized )
goto fn_exit;
is_initialized = 1;
/* This is the prefered method, all coretemp sensors are symlinked here
* see $(kernel_src)/Documentation/hwmon/sysfs-interface */
num_events = generateEventList("/sys/class/hwmon");
if ( num_events < 0 ) {
char* strCpy;
strCpy=strncpy(_coretemp_vector.cmp_info.disabled_reason,
"Cannot open /sys/class/hwmon",PAPI_MAX_STR_LEN);
_coretemp_vector.cmp_info.disabled_reason[PAPI_MAX_STR_LEN-1]=0;
if (strCpy == NULL) HANDLE_STRING_ERROR;
retval = PAPI_ECMP;
goto fn_fail;
}
if ( num_events == 0 ) {
char* strCpy=strncpy(_coretemp_vector.cmp_info.disabled_reason,
"No coretemp events found",PAPI_MAX_STR_LEN);
_coretemp_vector.cmp_info.disabled_reason[PAPI_MAX_STR_LEN-1]=0;
if (strCpy == NULL) HANDLE_STRING_ERROR;
retval = PAPI_ECMP;
goto fn_fail;
}
t = root;
_coretemp_native_events = (CORETEMP_native_event_entry_t*)
papi_calloc(num_events, sizeof(CORETEMP_native_event_entry_t));
if (_coretemp_native_events == NULL) {
int strErr=snprintf(_coretemp_vector.cmp_info.disabled_reason, PAPI_MAX_STR_LEN, "malloc() of _coretemp_native_events failed for %lu bytes.", num_events*sizeof(CORETEMP_native_event_entry_t));
_coretemp_vector.cmp_info.disabled_reason[PAPI_MAX_STR_LEN-1]=0;
if (strErr > PAPI_MAX_STR_LEN) HANDLE_STRING_ERROR;
retval = PAPI_ENOMEM;
goto fn_fail;
}
do {
int retlen;
retlen = snprintf(_coretemp_native_events[i].name, PAPI_MAX_STR_LEN, "%s", t->name);
if (retlen <= 0 || retlen >= PAPI_MAX_STR_LEN) HANDLE_STRING_ERROR;
retlen = snprintf(_coretemp_native_events[i].path, PATH_MAX, "%s", t->path);
if (retlen <= 0 || retlen >= PATH_MAX) HANDLE_STRING_ERROR;
retlen = snprintf(_coretemp_native_events[i].units, PAPI_MIN_STR_LEN, "%s", t->units);
if (retlen <= 0 || retlen >= PAPI_MIN_STR_LEN) HANDLE_STRING_ERROR;
retlen = snprintf(_coretemp_native_events[i].description, PAPI_MAX_STR_LEN, "%s",t->description);
if (retlen <= 0 || retlen >= PAPI_MAX_STR_LEN) HANDLE_STRING_ERROR;
_coretemp_native_events[i].stone = 0;
_coretemp_native_events[i].resources.selector = i + 1;
last = t;
t = t->next;
papi_free(last);
i++;
} while (t != NULL);
root = NULL;
/* Export the total number of events available */
_coretemp_vector.cmp_info.num_native_events = num_events;
/* Export the component id */
_coretemp_vector.cmp_info.CmpIdx = cidx;
fn_exit:
_papi_hwd[cidx]->cmp_info.disabled = retval;
return retval;
fn_fail:
goto fn_exit;
}
/*
* Control of counters (Reading/Writing/Starting/Stopping/Setup)
* functions
*/
static int
_coretemp_init_control_state( hwd_control_state_t * ctl)
{
int i;
CORETEMP_control_state_t *coretemp_ctl = (CORETEMP_control_state_t *) ctl;
for ( i=0; i < num_events; i++ ) {
coretemp_ctl->counts[i] = getEventValue(i);
}
/* Set last access time for caching results */
coretemp_ctl->lastupdate = PAPI_get_real_usec();
return PAPI_OK;
}
static int
_coretemp_start( hwd_context_t *ctx, hwd_control_state_t *ctl)
{
( void ) ctx;
( void ) ctl;
return PAPI_OK;
}
static int
_coretemp_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
long long ** events, int flags)
{
(void) flags;
(void) ctx;
CORETEMP_control_state_t* control = (CORETEMP_control_state_t*) ctl;
long long now = PAPI_get_real_usec();
int i;
/* Only read the values from the kernel if enough time has passed */
/* since the last read. Otherwise return cached values. */
if ( now - control->lastupdate > REFRESH_LAT ) {
for ( i = 0; i < num_events; i++ ) {
control->counts[i] = getEventValue( i );
}
control->lastupdate = now;
}
/* Pass back a pointer to our results */
*events = control->counts;
return PAPI_OK;
}
static int
_coretemp_stop( hwd_context_t *ctx, hwd_control_state_t *ctl )
{
(void) ctx;
/* read values */
CORETEMP_control_state_t* control = (CORETEMP_control_state_t*) ctl;
int i;
for ( i = 0; i < num_events; i++ ) {
control->counts[i] = getEventValue( i );
}
return PAPI_OK;
}
/* Shutdown a thread */
static int
_coretemp_shutdown_thread( hwd_context_t * ctx )
{
( void ) ctx;
return PAPI_OK;
}
/*
* Clean up what was setup in coretemp_init_component().
*/
static int
_coretemp_shutdown_component( )
{
if ( is_initialized ) {
is_initialized = 0;
papi_free(_coretemp_native_events);
_coretemp_native_events = NULL;
}
return PAPI_OK;
}
/* This function sets various options in the component
* The valid codes being passed in are PAPI_SET_DEFDOM,
* PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL * and PAPI_SET_INHERIT
*/
static int
_coretemp_ctl( hwd_context_t *ctx, int code, _papi_int_option_t *option )
{
( void ) ctx;
( void ) code;
( void ) option;
return PAPI_OK;
}
static int
_coretemp_update_control_state( hwd_control_state_t *ptr,
NativeInfo_t * native, int count,
hwd_context_t * ctx )
{
int i, index;
( void ) ctx;
( void ) ptr;
for ( i = 0; i < count; i++ ) {
index = native[i].ni_event;
native[i].ni_position = _coretemp_native_events[index].resources.selector - 1;
}
return PAPI_OK;
}
/*
* This function has to set the bits needed to count different domains
* In particular: PAPI_DOM_USER, PAPI_DOM_KERNEL PAPI_DOM_OTHER
* By default return PAPI_EINVAL if none of those are specified
* and PAPI_OK with success
* PAPI_DOM_USER is only user context is counted
* PAPI_DOM_KERNEL is only the Kernel/OS context is counted
* PAPI_DOM_OTHER is Exception/transient mode (like user TLB misses)
* PAPI_DOM_ALL is all of the domains
*/
static int
_coretemp_set_domain( hwd_control_state_t * cntl, int domain )
{
(void) cntl;
if ( PAPI_DOM_ALL != domain )
return PAPI_EINVAL;
return PAPI_OK;
}
static int
_coretemp_reset( hwd_context_t *ctx, hwd_control_state_t *ctl )
{
( void ) ctx;
( void ) ctl;
return PAPI_OK;
}
/*
* Native Event functions
*/
static int
_coretemp_ntv_enum_events( unsigned int *EventCode, int modifier )
{
int index;
switch ( modifier ) {
case PAPI_ENUM_FIRST:
if (num_events==0) {
return PAPI_ENOEVNT;
}
*EventCode = 0;
return PAPI_OK;
case PAPI_ENUM_EVENTS:
index = *EventCode;
if ( index < num_events - 1 ) {
*EventCode = *EventCode + 1;
return PAPI_OK;
} else {
return PAPI_ENOEVNT;
}
break;
default:
return PAPI_EINVAL;
}
return PAPI_EINVAL;
}
/*
*
*/
static int
_coretemp_ntv_code_to_name( unsigned int EventCode, char *name, int len )
{
int index = EventCode;
if ( index >= 0 && index < num_events ) {
strncpy( name, _coretemp_native_events[index].name, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
/*
*
*/
static int
_coretemp_ntv_code_to_descr( unsigned int EventCode, char *name, int len )
{
int index = EventCode;
if ( index >= 0 && index < num_events ) {
strncpy( name, _coretemp_native_events[index].description, len );
return PAPI_OK;
}
return PAPI_ENOEVNT;
}
static int
_coretemp_ntv_code_to_info(unsigned int EventCode, PAPI_event_info_t *info)
{
int index = EventCode;
if ( ( index < 0) || (index >= num_events )) return PAPI_ENOEVNT;
strncpy( info->symbol, _coretemp_native_events[index].name, sizeof(info->symbol));
strncpy( info->long_descr, _coretemp_native_events[index].description, sizeof(info->long_descr));
strncpy( info->units, _coretemp_native_events[index].units, sizeof(info->units));
info->units[sizeof(info->units)-1] = '\0';
return PAPI_OK;
}
/*
*
*/
papi_vector_t _coretemp_vector = {
.cmp_info = {
/* default component information (unspecified values are initialized to 0) */
.name = "coretemp",
.short_name = "coretemp",
.description = "Linux hwmon temperature and other info",
.version = "4.2.1",
.num_mpx_cntrs = CORETEMP_MAX_COUNTERS,
.num_cntrs = CORETEMP_MAX_COUNTERS,
.default_domain = PAPI_DOM_ALL,
.available_domains = PAPI_DOM_ALL,
.default_granularity = PAPI_GRN_SYS,
.available_granularities = PAPI_GRN_SYS,
.hardware_intr_sig = PAPI_INT_SIGNAL,
/* component specific cmp_info initializations */
.fast_real_timer = 0,
.fast_virtual_timer = 0,
.attach = 0,
.attach_must_ptrace = 0,
.kernel_multiplex = 1,
}
,
/* sizes of framework-opaque component-private structures */
.size = {
.context = sizeof ( CORETEMP_context_t ),
.control_state = sizeof ( CORETEMP_control_state_t ),
.reg_value = sizeof ( CORETEMP_register_t ),
.reg_alloc = sizeof ( CORETEMP_reg_alloc_t ),
}
,
/* function pointers in this component */
.init_thread = _coretemp_init_thread,
.init_component = _coretemp_init_component,
.init_control_state = _coretemp_init_control_state,
.start = _coretemp_start,
.stop = _coretemp_stop,
.read = _coretemp_read,
.shutdown_thread = _coretemp_shutdown_thread,
.shutdown_component = _coretemp_shutdown_component,
.ctl = _coretemp_ctl,
.update_control_state = _coretemp_update_control_state,
.set_domain = _coretemp_set_domain,
.reset = _coretemp_reset,
.ntv_enum_events = _coretemp_ntv_enum_events,
.ntv_code_to_name = _coretemp_ntv_code_to_name,
.ntv_code_to_descr = _coretemp_ntv_code_to_descr,
.ntv_code_to_info = _coretemp_ntv_code_to_info,
};