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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
|
/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/
/*
* File: papi_fwrappers.c
* CVS: $Id$
* Author: Philip Mucci
* mucci@cs.utk.edu
* Mods: Nils Smeds
* smeds@pdc.kth.se
* Anders Nilsson
* anni@pdc.kth.se
* Kevin London
* london@cs.utk.edu
* dan terpstra
* terpstra@cs.utk.edu
* Min Zhou
* min@cs.utk.edu
*/
#pragma GCC visibility push(default)
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "papi.h"
/* Lets use defines to rename all the files */
#ifdef FORTRANUNDERSCORE
#define PAPI_FCALL(function,caps,args) void function##_ args
#elif FORTRANDOUBLEUNDERSCORE
#define PAPI_FCALL(function,caps,args) void function##__ args
#elif FORTRANCAPS
#define PAPI_FCALL(function,caps,args) void caps args
#else
#define PAPI_FCALL(function,caps,args) void function args
#endif
/* Many Unix systems passes Fortran string lengths as extra arguments */
#if defined(_AIX) || defined(sun) || defined(linux)
#define _FORTRAN_STRLEN_AT_END
#endif
/* The Low Level Wrappers */
/** \internal @defgroup PAPIF PAPI Fortran API */
/* helper routine to convert Fortran strings to C strings */
#if defined(_FORTRAN_STRLEN_AT_END)
static void Fortran2cstring( char *cstring, char *Fstring, int clen , int Flen )
{
int slen, i;
/* What is the maximum number of chars to copy ? */
slen = Flen < clen ? Flen : clen;
strncpy( cstring, Fstring, ( size_t ) slen );
/* Remove trailing blanks from initial Fortran string */
for ( i = slen - 1; i > -1 && cstring[i] == ' '; cstring[i--] = '\0' );
/* Make sure string is NULL terminated */
cstring[clen - 1] = '\0';
if ( slen < clen )
cstring[slen] = '\0';
}
#endif
/** @class PAPIF_accum
* @ingroup PAPIF
* @brief accumulate and reset counters in an event set
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_accum( C_INT EventSet, C_LONG_LONG(*) values, C_INT check )
*
* @see PAPI_accum
*/
PAPI_FCALL( papif_accum, PAPIF_ACCUM,
( int *EventSet, long long *values, int *check ) )
{
*check = PAPI_accum( *EventSet, values );
}
/** @class PAPIF_add_event
* @ingroup PAPIF
* @brief add PAPI preset or native hardware event to an event set
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_add_event( C_INT EventSet, C_INT EventCode, C_INT check )
*
* @see PAPI_add_event
*/
PAPI_FCALL( papif_add_event, PAPIF_ADD_EVENT,
( int *EventSet, int *Event, int *check ) )
{
*check = PAPI_add_event( *EventSet, *Event );
}
/** @class PAPIF_add_named_event
* @ingroup PAPIF
* @brief add PAPI preset or native hardware event to an event set by name
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_add_named_event( C_INT EventSet, C_STRING EventName, C_INT check )
*
* @see PAPI_add_named_event
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
( int *EventSet, char *EventName, int *check, int Event_len ) )
{
char tmp[PAPI_MAX_STR_LEN];
Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
*check = PAPI_add_named_event( *EventSet, tmp );
}
#else
PAPI_FCALL( papif_add_named_event, PAPIF_ADD_NAMED_EVENT,
( int *EventSet, char *EventName, int *check ) )
{
*check = PAPI_add_named_event( *EventSet, EventName );
}
#endif
/** @class PAPIF_add_events
* @ingroup PAPIF
* @brief add multiple PAPI presets or native hardware events to an event set
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_add_events( C_INT EventSet, C_INT(*) EventCodes, C_INT number, C_INT check )
*
* @see PAPI_add_events
*/
PAPI_FCALL( papif_add_events, PAPIF_ADD_EVENTS,
( int *EventSet, int *Events, int *number, int *check ) )
{
*check = PAPI_add_events( *EventSet, Events, *number );
}
/** @class PAPIF_cleanup_eventset
* @ingroup PAPIF
* @brief empty and destroy an EventSet
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_cleanup_eventset( C_INT EventSet, C_INT check )
*
* @see PAPI_cleanup_eventset
*/
PAPI_FCALL( papif_cleanup_eventset, PAPIF_CLEANUP_EVENTSET,
( int *EventSet, int *check ) )
{
*check = PAPI_cleanup_eventset( *EventSet );
}
/** @class PAPIF_create_eventset
* @ingroup PAPIF
* @brief create a new empty PAPI EventSet
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_create_eventset( C_INT EventSet, C_INT check )
*
* @see PAPI_create_eventset
*/
PAPI_FCALL( papif_create_eventset, PAPIF_CREATE_EVENTSET,
( int *EventSet, int *check ) )
{
*check = PAPI_create_eventset( EventSet );
}
/** @class PAPIF_assign_eventset_component
* @ingroup PAPIF
* @brief assign a component index to an existing but empty EventSet
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_assign_eventset_component( C_INT EventSet, C_INT EventSet, C_INT check )
*
* @see PAPI_assign_eventset_component
*/
PAPI_FCALL( papif_assign_eventset_component, PAPIF_ASSIGN_EVENTSET_COMPONENT,
( int *EventSet, int *cidx, int *check ) )
{
*check = PAPI_assign_eventset_component( *EventSet, *cidx );
}
/** @class PAPIF_destroy_eventset
* @ingroup PAPIF
* @brief empty and destroy an EventSet
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_destroy_eventset( C_INT EventSet, C_INT check )
*
* @see PAPI_destroy_eventset
*/
PAPI_FCALL( papif_destroy_eventset, PAPIF_DESTROY_EVENTSET,
( int *EventSet, int *check ) )
{
*check = PAPI_destroy_eventset( EventSet );
}
/** @class PAPIF_get_dmem_info
* @ingroup PAPIF
* @brief get information about the dynamic memory usage of the current program
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_dmem_info( C_INT EventSet, C_INT check )
*
* @see PAPI_get_dmem_info
*/
/* XXX This looks totally broken. Should be passed all the members of the dmem_info struct. */
PAPI_FCALL( papif_get_dmem_info, PAPIF_GET_DMEM_INFO,
( long long *dest, int *check ) )
{
*check = PAPI_get_dmem_info( ( PAPI_dmem_info_t * ) dest );
}
/** @class PAPIF_get_exe_info
* @ingroup PAPIF
* @brief get information about the dynamic memory usage of the current program
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_exe_info( C_STRING fullname, C_STRING name, @n
* C_LONG_LONG text_start, C_LONG_LONG text_end, @n
* C_LONG_LONG data_start, C_LONG_LONG data_end, @n
* C_LONG_LONG bss_start, C_LONG_LONG bss_end, C_INT check )
*
* @see PAPI_get_executable_info
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
( char *fullname, char *name, long long *text_start,
long long *text_end, long long *data_start, long long *data_end,
long long *bss_start, long long *bss_end,
int *check, int fullname_len, int name_len ) )
#else
PAPI_FCALL( papif_get_exe_info, PAPIF_GET_EXE_INFO,
( char *fullname, char *name, long long *text_start,
long long *text_end, long long *data_start, long long *data_end,
long long *bss_start, long long *bss_end, int *check ) )
#endif
{
PAPI_option_t e;
/* WARNING: The casts from caddr_t to long below WILL BREAK on systems with
64-bit addresses. I did it here because I was lazy. And because I wanted
to get rid of those pesky gcc warnings. If you find a 64-bit system,
conditionalize the cast with (yet another) #ifdef...
*/
if ( ( *check = PAPI_get_opt( PAPI_EXEINFO, &e ) ) == PAPI_OK ) {
#if defined(_FORTRAN_STRLEN_AT_END)
int i;
strncpy( fullname, e.exe_info->fullname, ( size_t ) fullname_len );
for ( i = ( int ) strlen( e.exe_info->fullname ); i < fullname_len;
fullname[i++] = ' ' );
strncpy( name, e.exe_info->address_info.name, ( size_t ) name_len );
for ( i = ( int ) strlen( e.exe_info->address_info.name ); i < name_len;
name[i++] = ' ' );
#else
strncpy( fullname, e.exe_info->fullname, PAPI_MAX_STR_LEN );
strncpy( name, e.exe_info->address_info.name, PAPI_MAX_STR_LEN );
#endif
*text_start = ( long ) e.exe_info->address_info.text_start;
*text_end = ( long ) e.exe_info->address_info.text_end;
*data_start = ( long ) e.exe_info->address_info.data_start;
*data_end = ( long ) e.exe_info->address_info.data_end;
*bss_start = ( long ) e.exe_info->address_info.bss_start;
*bss_end = ( long ) e.exe_info->address_info.bss_end;
}
}
/** @class PAPIF_get_hardware_info
* @ingroup PAPIF
* @brief get information about the system hardware
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_hardware_info( C_INT ncpu, C_INT nnodes, C_INT totalcpus,@n
* C_INT vendor, C_STRING vendor_str, C_INT model, C_STRING model_str, @n
* C_FLOAT revision, C_FLOAT mhz )
*
* @see PAPI_get_hardware_info
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
int *nnodes,
int *totalcpus,
int *vendor,
char
*vendor_str,
int *model,
char *model_str,
float *revision,
float *mhz,
int vendor_len,
int
model_len ) )
#else
PAPI_FCALL( papif_get_hardware_info, PAPIF_GET_HARDWARE_INFO, ( int *ncpu,
int *nnodes,
int *totalcpus,
int *vendor,
char
*vendor_string,
int *model,
char
*model_string,
float *revision,
float *mhz ) )
#endif
{
const PAPI_hw_info_t *hwinfo;
int i;
hwinfo = PAPI_get_hardware_info( );
if ( hwinfo == NULL ) {
*ncpu = 0;
*nnodes = 0;
*totalcpus = 0;
*vendor = 0;
*model = 0;
*revision = 0;
*mhz = 0;
} else {
*ncpu = hwinfo->ncpu;
*nnodes = hwinfo->nnodes;
*totalcpus = hwinfo->totalcpus;
*vendor = hwinfo->vendor;
*model = hwinfo->model;
*revision = hwinfo->revision;
*mhz = hwinfo->cpu_max_mhz;
#if defined(_FORTRAN_STRLEN_AT_END)
strncpy( vendor_str, hwinfo->vendor_string, ( size_t ) vendor_len );
for ( i = ( int ) strlen( hwinfo->vendor_string ); i < vendor_len;
vendor_str[i++] = ' ' );
strncpy( model_str, hwinfo->model_string, ( size_t ) model_len );
for ( i = ( int ) strlen( hwinfo->model_string ); i < model_len;
model_str[i++] = ' ' );
#else
(void)i; /* unused... */
/* This case needs the passed strings to be of sufficient size *
* and will include the NULL character in the target string */
strcpy( vendor_string, hwinfo->vendor_string );
strcpy( model_string, hwinfo->model_string );
#endif
}
return;
}
/** @class PAPIF_num_hwctrs
* @ingroup PAPIF
* @brief Return the number of hardware counters on the cpu.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_num_hwctrs( C_INT num )
*
* @see PAPI_num_hwctrs
* @see PAPI_num_cmp_hwctrs
*/
PAPI_FCALL( papif_num_hwctrs, PAPIF_num_hwctrs, ( int *num ) )
{
*num = PAPI_num_hwctrs( );
}
/** @class PAPIF_num_cmp_hwctrs
* @ingroup PAPIF
* @brief Return the number of hardware counters on the specified component.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_num_cmp_hwctrs( C_INT cidx, C_INT num )
*
* @see PAPI_num_hwctrs
* @see PAPI_num_cmp_hwctrs
*/
PAPI_FCALL( papif_num_cmp_hwctrs, PAPIF_num_cmp_hwctrs,
( int *cidx, int *num ) )
{
*num = PAPI_num_cmp_hwctrs( *cidx );
}
/** @class PAPIF_get_real_cyc
* @ingroup PAPIF
* @brief Get real time counter value in clock cycles.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_real_cyc( C_LONG_LONG real_cyc )
*
* @see PAPI_get_real_cyc
*/
PAPI_FCALL( papif_get_real_cyc, PAPIF_GET_REAL_CYC, ( long long *real_cyc ) )
{
*real_cyc = PAPI_get_real_cyc( );
}
/** @class PAPIF_get_real_usec
* @ingroup PAPIF
* @brief Get real time counter value in microseconds.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_real_usec( C_LONG_LONG time )
*
* @see PAPI_get_real_usec
*/
PAPI_FCALL( papif_get_real_usec, PAPIF_GET_REAL_USEC, ( long long *time ) )
{
*time = PAPI_get_real_usec( );
}
/** @class PAPIF_get_real_nsec
* @ingroup PAPIF
* @brief Get real time counter value in nanoseconds.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_real_nsec( C_LONG_LONG time )
*
* @see PAPI_get_real_nsec
*/
PAPI_FCALL( papif_get_real_nsec, PAPIF_GET_REAL_NSEC, ( long long *time ) )
{
*time = PAPI_get_real_nsec( );
}
/** @class PAPIF_get_virt_cyc
* @ingroup PAPIF
* @brief Get virtual time counter value in clock cycles.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_virt_cyc( C_LONG_LONG virt_cyc )
*
* @see PAPI_get_virt_cyc
*/
PAPI_FCALL( papif_get_virt_cyc, PAPIF_GET_VIRT_CYC, ( long long *virt_cyc ) )
{
*virt_cyc = PAPI_get_virt_cyc( );
}
/** @class PAPIF_get_virt_usec
* @ingroup PAPIF
* @brief Get virtual time counter value in microseconds.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_virt_usec( C_LONG_LONG time )
*
* @see PAPI_get_virt_usec
*/
PAPI_FCALL( papif_get_virt_usec, PAPIF_GET_VIRT_USEC, ( long long *time ) )
{
*time = PAPI_get_virt_usec( );
}
/** @class PAPIF_is_initialized
* @ingroup PAPIF
* @brief Check for initialization.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_is_initialized( C_INT level )
*
* @see PAPI_is_initialized
*/
PAPI_FCALL( papif_is_initialized, PAPIF_IS_INITIALIZED, ( int *level ) )
{
*level = PAPI_is_initialized( );
}
/** @class PAPIF_library_init
* @ingroup PAPIF
* @brief Initialize the PAPI library.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_library_init( C_INT check )
*
* @see PAPI_library_init
*/
PAPI_FCALL( papif_library_init, PAPIF_LIBRARY_INIT, ( int *check ) )
{
*check = PAPI_library_init( *check );
}
/** @class PAPIF_thread_id
* @ingroup PAPIF
* @brief Get the thread identifier of the current thread.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_thread_id( C_INT id )
*
* @see PAPI_thread_id
*/
PAPI_FCALL( papif_thread_id, PAPIF_THREAD_ID, ( unsigned long *id ) )
{
*id = PAPI_thread_id( );
}
/** @class PAPIF_register_thread
* @ingroup PAPIF
* @brief Notify PAPI that a thread has 'appeared'.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_register_thread( C_INT check )
*
* @see PAPI_register_thread
*/
PAPI_FCALL( papif_register_thread, PAPIF_REGISTER_THREAD, ( int *check ) )
{
*check = PAPI_register_thread( );
}
/** @class PAPIF_unregister_thread
* @ingroup PAPIF
* @brief Notify PAPI that a thread has 'disappeared'.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_unregister_thread( C_INT check )
*
* @see PAPI_unregister_thread
*/
PAPI_FCALL( papif_unregster_thread, PAPIF_UNREGSTER_THREAD, ( int *check ) )
{
*check = PAPI_unregister_thread( );
}
/** @class PAPIF_thread_init
* @ingroup PAPIF
* @brief Initialize thread support in the PAPI library.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_thread_init( C_INT FUNCTION handle, C_INT check )
*
* @see PAPI_thread_init
*/
/* This must be passed an EXTERNAL or INTRINISIC FUNCTION not a SUBROUTINE */
PAPI_FCALL( papif_thread_init, PAPIF_THREAD_INIT,
( unsigned long int ( *handle ) ( void ), int *check ) )
{
*check = PAPI_thread_init( handle );
}
/** @class PAPI_list_events
* @ingroup PAPIF
* @brief List the events in an event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPI_list_events( C_INT EventSet, C_INT(*) Events, C_INT number, C_INT check )
*
* @see PAPI_list_events
*/
PAPI_FCALL( papif_list_events, PAPIF_LIST_EVENTS,
( int *EventSet, int *Events, int *number, int *check ) )
{
*check = PAPI_list_events( *EventSet, Events, number );
}
/** @class PAPIF_multiplex_init
* @ingroup PAPIF
* @brief Initialize multiplex support in the PAPI library.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_multiplex_init( C_INT check )
*
* @see PAPI_multiplex_init
*/
PAPI_FCALL( papif_multiplex_init, PAPIF_MULTIPLEX_INIT, ( int *check ) )
{
*check = PAPI_multiplex_init( );
}
/** @class PAPIF_get_multiplex
* @ingroup PAPIF
* @brief Get the multiplexing status of specified event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_multiplex( C_INT EventSet, C_INT check )
*
* @see PAPI_get_multiplex
*/
PAPI_FCALL( papif_get_multiplex, PAPIF_GET_MULTIPLEX,
( int *EventSet, int *check ) )
{
*check = PAPI_get_multiplex( *EventSet );
}
/** @class PAPIF_set_multiplex
* @ingroup PAPIF
* @brief Convert a standard event set to a multiplexed event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_set_multiplex( C_INT EventSet, C_INT check )
*
* @see PAPI_set_multiplex
*/
PAPI_FCALL( papif_set_multiplex, PAPIF_SET_MULTIPLEX,
( int *EventSet, int *check ) )
{
*check = PAPI_set_multiplex( *EventSet );
}
/** @class PAPIF_perror
* @ingroup PAPIF
* @brief Convert PAPI error codes to strings, and print error message to stderr.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_perror( C_STRING message )
*
* @see PAPI_perror
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_perror, PAPIF_PERROR,
( char *message,
int message_len ) )
#else
PAPI_FCALL( papif_perror, PAPIF_PERROR,
( char *message ) )
#endif
{
#if defined(_FORTRAN_STRLEN_AT_END)
char tmp[PAPI_MAX_STR_LEN];
Fortran2cstring( tmp, message, PAPI_MAX_STR_LEN, message_len );
PAPI_perror( tmp );
#else
PAPI_perror( message );
#endif
}
/* This will not work until Fortran2000 :)
* PAPI_FCALL(papif_profil, PAPIF_PROFIL, (unsigned short *buf, unsigned *bufsiz, unsigned long *offset, unsigned *scale, unsigned *eventset,
* unsigned *eventcode, unsigned *threshold, unsigned *flags, unsigned *check))
* {
* *check = PAPI_profil(buf, *bufsiz, *offset, *scale, *eventset, *eventcode, *threshold, *flags);
* }
*/
/** @class PAPIF_query_event
* @ingroup PAPIF
* @brief Query if PAPI event exists.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_query_event(C_INT EventCode, C_INT check )
*
* @see PAPI_query_event
*/
PAPI_FCALL( papif_query_event, PAPIF_QUERY_EVENT,
( int *EventCode, int *check ) )
{
*check = PAPI_query_event( *EventCode );
}
/** @class PAPIF_query_named_event
* @ingroup PAPIF
* @brief Query if named PAPI event exists.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_query_named_event(C_STRING EventName, C_INT check )
*
* @see PAPI_query_named_event
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
( char *EventName, int *check, int Event_len ) )
{
char tmp[PAPI_MAX_STR_LEN];
Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
*check = PAPI_query_named_event( tmp );
}
#else
PAPI_FCALL( papif_query_named_event, PAPIF_QUERY_NAMED_EVENT,
( char *EventName, int *check ) )
{
*check = PAPI_query_named_event( EventName );
}
#endif
/** @class PAPIF_get_event_info
* @ingroup PAPIF
* @brief Get the event's name and description info.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_get_event_info(C_INT EventCode, C_STRING symbol, C_STRING long_descr,
C_STRING short_descr, C_INT count, C_STRING event_note,
C_INT flags, C_INT check )
*
* @see PAPI_get_event_info
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
( int *EventCode, char *symbol, char *long_descr, char *short_descr,
int *count, char *event_note, int *flags, int *check,
int symbol_len, int long_descr_len, int short_descr_len,
int event_note_len ) )
#else
PAPI_FCALL( papif_get_event_info, PAPIF_GET_EVENT_INFO,
( int *EventCode, char *symbol, char *long_descr, char *short_descr,
int *count, char *event_note, int *flags, int *check ) )
#endif
{
PAPI_event_info_t info;
( void ) flags; /*Unused */
#if defined(_FORTRAN_STRLEN_AT_END)
int i;
if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
strncpy( symbol, info.symbol, ( size_t ) symbol_len );
for ( i = ( int ) strlen( info.symbol ); i < symbol_len;
symbol[i++] = ' ' );
strncpy( long_descr, info.long_descr, ( size_t ) long_descr_len );
for ( i = ( int ) strlen( info.long_descr ); i < long_descr_len;
long_descr[i++] = ' ' );
strncpy( short_descr, info.short_descr, ( size_t ) short_descr_len );
for ( i = ( int ) strlen( info.short_descr ); i < short_descr_len;
short_descr[i++] = ' ' );
*count = ( int ) info.count;
int note_len=0;
strncpy( event_note, info.note, ( size_t ) event_note_len );
note_len=strlen(info.note);
for ( i = note_len; i < event_note_len;
event_note[i++] = ' ' );
}
#else
/* printf("EventCode: %d\n", *EventCode ); -KSL */
if ( ( *check = PAPI_get_event_info( *EventCode, &info ) ) == PAPI_OK ) {
strncpy( symbol, info.symbol, PAPI_MAX_STR_LEN );
strncpy( long_descr, info.long_descr, PAPI_MAX_STR_LEN );
strncpy( short_descr, info.short_descr, PAPI_MAX_STR_LEN );
*count = info.count;
if (info.note)
strncpy( event_note, info.note,
PAPI_MAX_STR_LEN );
}
/* printf("Check: %d\n", *check); -KSL */
#endif
}
/** @class PAPIF_event_code_to_name
* @ingroup PAPIF
* @brief Convert a numeric hardware event code to a name.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_event_code_to_name( C_INT EventCode, C_STRING EventName, C_INT check )
*
* @see PAPI_event_code_to_name
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
( int *EventCode, char *out_str, int *check, int out_len ) )
#else
PAPI_FCALL( papif_event_code_to_name, PAPIF_EVENT_CODE_TO_NAME,
( int *EventCode, char *out, int *check ) )
#endif
{
#if defined(_FORTRAN_STRLEN_AT_END)
char tmp[PAPI_MAX_STR_LEN];
int i;
*check = PAPI_event_code_to_name( *EventCode, tmp );
/* tmp has \0 within PAPI_MAX_STR_LEN chars so strncpy is safe */
strncpy( out_str, tmp, ( size_t ) out_len );
/* overwrite any NULLs and trailing garbage in out_str */
for ( i = ( int ) strlen( tmp ); i < out_len; out_str[i++] = ' ' );
#else
/* The array "out" passed by the user must be sufficiently long */
*check = PAPI_event_code_to_name( *EventCode, out );
#endif
}
/** @class PAPIF_event_name_to_code
* @ingroup PAPIF
* @brief Convert a name to a numeric hardware event code.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_event_name_to_code( C_STRING EventName, C_INT EventCode, C_INT check )
*
* @see PAPI_event_name_to_code
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
( char *in_str, int *out, int *check, int in_len ) )
#else
PAPI_FCALL( papif_event_name_to_code, PAPIF_EVENT_NAME_TO_CODE,
( char *in, int *out, int *check ) )
#endif
{
#if defined(_FORTRAN_STRLEN_AT_END)
int slen, i;
char tmpin[PAPI_MAX_STR_LEN];
/* What is the maximum number of chars to copy ? */
slen = in_len < PAPI_MAX_STR_LEN ? in_len : PAPI_MAX_STR_LEN;
strncpy( tmpin, in_str, ( size_t ) slen );
/* Remove trailing blanks from initial Fortran string */
for ( i = slen - 1; i > -1 && tmpin[i] == ' '; tmpin[i--] = '\0' );
/* Make sure string is NULL terminated before call */
tmpin[PAPI_MAX_STR_LEN - 1] = '\0';
if ( slen < PAPI_MAX_STR_LEN )
tmpin[slen] = '\0';
*check = PAPI_event_name_to_code( tmpin, out );
#else
/* This will have trouble if argument in is not null terminated */
*check = PAPI_event_name_to_code( in, out );
#endif
}
/** @class PAPIF_num_events
* @ingroup PAPIF
* @brief Enumerate PAPI preset or native events.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_num_events(C_INT EventSet, C_INT count)
*
* @see PAPI_num_events
*/
PAPI_FCALL( papif_num_events, PAPIF_NUM_EVENTS, ( int *EventCode, int *count ) )
{
*count = PAPI_num_events( *EventCode );
}
/** @class PAPIF_enum_event
* @ingroup PAPIF
* @brief Return the number of events in an event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_enum_event( C_INT EventCode, C_INT modifier, C_INT check )
*
* @see PAPI_enum_event
*/
PAPI_FCALL( papif_enum_event, PAPIF_ENUM_EVENT,
( int *EventCode, int *modifier, int *check ) )
{
*check = PAPI_enum_event( EventCode, *modifier );
}
/** @class PAPIF_read
* @ingroup PAPIF
* @brief Read hardware counters from an event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_read(C_INT EventSet, C_LONG_LONG(*) values, C_INT check )
*
* @see PAPI_read
*/
PAPI_FCALL( papif_read, PAPIF_READ,
( int *EventSet, long long *values, int *check ) )
{
*check = PAPI_read( *EventSet, values );
}
/** @class PAPIF_read_ts
* @ingroup PAPIF
* @brief Read hardware counters with a timestamp.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_read_ts(C_INT EventSet, C_LONG_LONG(*) values, C_LONG_LONG(*) cycles, C_INT check)
*
* @see PAPI_read_ts
*/
PAPI_FCALL( papif_read_ts, PAPIF_READ_TS,
( int *EventSet, long long *values, long long *cycles, int *check ) )
{
*check = PAPI_read_ts( *EventSet, values, cycles );
}
/** @class PAPIF_remove_event
* @ingroup PAPIF
* @brief Remove a hardware event from a PAPI event set.
*
* @par Fortran interface:
* \#include "fpapi.h" @n
* PAPIF_remove_event( C_INT EventSet, C_INT EventCode, C_INT check )
*
* @see PAPI_remove_event
*/
PAPI_FCALL( papif_remove_event, PAPIF_REMOVE_EVENT,
( int *EventSet, int *Event, int *check ) )
{
*check = PAPI_remove_event( *EventSet, *Event );
}
/** @class PAPIF_remove_named_event
* @ingroup PAPIF
* @brief Remove a named hardware event from a PAPI event set.
*
* @par Fortran interface:
* \#include "fpapi.h" @n
* PAPIF_remove_named_event( C_INT EventSet, C_STRING EventName, C_INT check )
*
* @see PAPI_remove_named_event
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
( int *EventSet, char *EventName, int *check, int Event_len ) )
{
char tmp[PAPI_MAX_STR_LEN];
Fortran2cstring( tmp, EventName, PAPI_MAX_STR_LEN, Event_len );
*check = PAPI_remove_named_event( *EventSet, tmp );
}
#else
PAPI_FCALL( papif_remove_named_event, PAPIF_REMOVE_NAMED_EVENT,
( int *EventSet, char *EventName, int *check ) )
{
*check = PAPI_remove_named_event( *EventSet, EventName );
}
#endif
/** @class PAPIF_remove_events
* @ingroup PAPIF
* @brief Remove an array of hardware event codes from a PAPI event set.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_remove_events( C_INT EventSet, C_INT(*) EventCode, C_INT number, C_INT check )
*
* @see PAPI_remove_events
*/
PAPI_FCALL( papif_remove_events, PAPIF_REMOVE_EVENTS,
( int *EventSet, int *Events, int *number, int *check ) )
{
*check = PAPI_remove_events( *EventSet, Events, *number );
}
/** @class PAPIF_reset
* @ingroup PAPIF
* @brief Reset the hardware event counts in an event set.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_reset( C_INT EventSet, C_INT check )
*
* @see PAPI_reset
*/
PAPI_FCALL( papif_reset, PAPIF_RESET, ( int *EventSet, int *check ) )
{
*check = PAPI_reset( *EventSet );
}
/** @class PAPIF_set_debug
* @ingroup PAPIF
* @brief Set the current debug level for error output from PAPI.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_debug( C_INT level, C_INT check )
*
* @see PAPI_set_debug
*/
PAPI_FCALL( papif_set_debug, PAPIF_SET_DEBUG, ( int *debug, int *check ) )
{
*check = PAPI_set_debug( *debug );
}
/** @class PAPIF_set_domain
* @ingroup PAPIF
* @brief Set the default counting domain for new event sets bound to the cpu component.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_domain( C_INT domain, C_INT check )
*
* @see PAPI_set_domain
*/
PAPI_FCALL( papif_set_domain, PAPIF_SET_DOMAIN, ( int *domain, int *check ) )
{
*check = PAPI_set_domain( *domain );
}
/** @class PAPIF_set_cmp_domain
* @ingroup PAPIF
* @brief Set the default counting domain for new event sets bound to the specified component.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_cmp_domain( C_INT domain, C_INT cidx, C_INT check )
*
* @see PAPI_set_cmp_domain
*/
PAPI_FCALL( papif_set_cmp_domain, PAPIF_SET_CMP_DOMAIN,
( int *domain, int *cidx, int *check ) )
{
*check = PAPI_set_cmp_domain( *domain, *cidx );
}
/** @class PAPIF_set_granularity
* @ingroup PAPIF
* @brief Set the default counting granularity for eventsets bound to the cpu component.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_granularity( C_INT granularity, C_INT check )
*
* @see PAPI_set_granularity
*/
PAPI_FCALL( papif_set_granularity, PAPIF_SET_GRANULARITY,
( int *granularity, int *check ) )
{
*check = PAPI_set_granularity( *granularity );
}
/** @class PAPIF_set_cmp_granularity
* @ingroup PAPIF
* @brief Set the default counting granularity for eventsets bound to the specified component.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_cmp_granularity( C_INT granularity, C_INT cidx, C_INT check )
*
* @see PAPI_set_cmp_granularity
*/
PAPI_FCALL( papif_set_cmp_granularity, PAPIF_SET_CMP_GRANULARITY,
( int *granularity, int *cidx, int *check ) )
{
*check = PAPI_set_cmp_granularity( *granularity, *cidx );
}
/** @class PAPIF_shutdown
* @ingroup PAPIF
* @brief finish using PAPI and free all related resources.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_shutdown( )
*
* @see PAPI_shutdown
*/
PAPI_FCALL( papif_shutdown, PAPIF_SHUTDOWN, ( void ) )
{
PAPI_shutdown( );
}
/** @class PAPIF_start
* @ingroup PAPIF
* @brief Start counting hardware events in an event set.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_start( C_INT EventSet, C_INT check )
*
* @see PAPI_start
*/
PAPI_FCALL( papif_start, PAPIF_START, ( int *EventSet, int *check ) )
{
*check = PAPI_start( *EventSet );
}
/** @class PAPIF_state
* @ingroup PAPIF
* @brief Return the counting state of an EventSet.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_state(C_INT EventSet, C_INT status, C_INT check )
*
* @see PAPI_state
*/
PAPI_FCALL( papif_state, PAPIF_STATE,
( int *EventSet, int *status, int *check ) )
{
*check = PAPI_state( *EventSet, status );
}
/** @class PAPIF_stop
* @ingroup PAPIF
* @brief Stop counting hardware events in an EventSet.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_stop( C_INT EventSet, C_LONG_LONG(*) values, C_INT check )
*
* @see PAPI_stop
*/
PAPI_FCALL( papif_stop, PAPIF_STOP,
( int *EventSet, long long *values, int *check ) )
{
*check = PAPI_stop( *EventSet, values );
}
/** @class PAPIF_write
* @ingroup PAPIF
* @brief Write counter values into counters.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_write( C_INT EventSet, C_LONG_LONG(*) values, C_INT check )
*
* @see PAPI_write
*/
PAPI_FCALL( papif_write, PAPIF_WRITE,
( int *EventSet, long long *values, int *check ) )
{
*check = PAPI_write( *EventSet, values );
}
/** @class PAPIF_lock
* @ingroup PAPIF
* @brief Lock one of two mutex variables defined in papi.h.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_lock( C_INT lock )
*
* @see PAPI_lock
*/
PAPI_FCALL( papif_lock, PAPIF_LOCK,
( int *lock, int *check ) )
{
*check = PAPI_lock( *lock );
}
/** @class PAPIF_unlock
* @ingroup PAPIF
* @brief Unlock one of the mutex variables defined in papi.h.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_unlock( C_INT lock )
*
* @see PAPI_unlock
*/
PAPI_FCALL( papif_unlock, PAPIF_unlock,
( int *lock, int *check ) )
{
*check = PAPI_unlock( *lock );
}
/* The High Level API Wrappers */
/** @class PAPIF_start_counters
* @ingroup PAPIF
* @brief Start counting hardware events.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_start_counters( C_INT(*) events, C_INT array_len, C_INT check )
*
* @see PAPI_start_counters
*/
PAPI_FCALL( papif_start_counters, PAPIF_START_COUNTERS,
( int *events, int *array_len, int *check ) )
{
*check = PAPI_start_counters( events, *array_len );
}
/** @class PAPI_read_counters
* @ingroup PAPIF
* @brief Read and reset counters.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_read_counters( C_LONG_LONG(*) values, C_INT array_len, C_INT check )
*
* @see PAPI_read_counters
*/
PAPI_FCALL( papif_read_counters, PAPIF_READ_COUNTERS,
( long long *values, int *array_len, int *check ) )
{
*check = PAPI_read_counters( values, *array_len );
}
/** @class PAPIF_stop_counters
* @ingroup PAPIF
* @brief Stop counting hardware events and reset values to zero.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_stop_counters( C_LONG_LONG(*) values, C_INT array_len, C_INT check )
*
* @see PAPI_stop_counters
*/
PAPI_FCALL( papif_stop_counters, PAPIF_STOP_COUNTERS,
( long long *values, int *array_len, int *check ) )
{
*check = PAPI_stop_counters( values, *array_len );
}
/** @class PAPIF_accum_counters
* @ingroup PAPIF
* @brief Accumulate and reset counters.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_accum_counters( C_LONG_LONG(*) values, C_INT array_len, C_INT check )
*
* @see PAPI_accum_counters
*/
PAPI_FCALL( papif_accum_counters, PAPIF_ACCUM_COUNTERS,
( long long *values, int *array_len, int *check ) )
{
*check = PAPI_accum_counters( values, *array_len );
}
/** @class PAPIF_num_counters
* @ingroup PAPIF
* @brief Get the number of hardware counters available on the system.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_num_counters( C_INT numevents )
*
* @see PAPI_num_counters
*/
PAPI_FCALL( papif_num_counters, PAPIF_NUM_COUNTERS, ( int *numevents ) )
{
*numevents = PAPI_num_counters( );
}
/** @class PAPIF_ipc
* @ingroup PAPIF
* @brief Get instructions per cycle, real and processor time.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_ipc( C_FLOAT real_time, C_FLOAT proc_time, C_LONG_LONG ins, C_FLOAT ipc, C_INT check )
*
* @see PAPI_ipc
*/
PAPI_FCALL( papif_ipc, PAPIF_IPC,
( float *rtime, float *ptime, long long *ins, float *ipc,
int *check ) )
{
*check = PAPI_ipc( rtime, ptime, ins, ipc );
}
/** @class PAPIF_epc
* @ingroup PAPIF
* @brief Get named events per cycle, real and processor time, reference and core cycles.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_epc( C_STRING EventName, C_FLOAT real_time, C_FLOAT proc_time, C_LONG_LONG ref, C_LONG_LONG core, C_LONG_LONG evt, C_FLOAT epc, C_INT check )
*
* @see PAPI_epc
*/
PAPI_FCALL( papif_epc, PAPIF_EPC,
( int event, float *rtime, float *ptime,
long long *ref, long long *core, long long *evt, float *epc,
int *check) )
{
*check = PAPI_epc( event, rtime, ptime, ref, core, evt, epc );
}
/** @class PAPIF_flips
* @ingroup PAPIF
* @brief Simplified call to get Mflips/s (floating point instruction rate), real and processor time.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_flips( C_FLOAT real_time, C_FLOAT proc_time, C_LONG_LONG flpins, C_FLOAT mflips, C_INT check )
*
* @see PAPI_flips
*/
PAPI_FCALL( papif_flips, PAPIF_FLIPS,
( float *real_time, float *proc_time, long long *flpins,
float *mflips, int *check ) )
{
*check = PAPI_flips( real_time, proc_time, flpins, mflips );
}
/** @class PAPIF_flops
* @ingroup PAPIF
* @brief Simplified call to get Mflops/s (floating point instruction rate), real and processor time.
*
* @par Fortran Interface:
* \#include "fpapi.h" @n
* PAPIF_flops( C_FLOAT real_time, C_FLOAT proc_time, C_LONG_LONG flpops, C_FLOAT mflops, C_INT check )
*
* @see PAPI_flops
*/
PAPI_FCALL( papif_flops, PAPIF_FLOPS,
( float *real_time, float *proc_time, long long *flpops,
float *mflops, int *check ) )
{
*check = PAPI_flops( real_time, proc_time, flpops, mflops );
}
/* Fortran only APIs for get_opt and set_opt functionality */
/** @class PAPIF_get_clockrate
* @ingroup PAPIF
* @brief Get the clockrate in MHz for the current cpu.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_domain( C_INT cr )
*
* @note This is a Fortran only interface that returns a value from the PAPI_get_opt call.
*
* @see PAPI_get_opt
*/
PAPI_FCALL( papif_get_clockrate, PAPIF_GET_CLOCKRATE, ( int *cr ) )
{
*cr = PAPI_get_opt( PAPI_CLOCKRATE, NULL );
}
/** @class PAPIF_get_preload
* @ingroup PAPIF
* @brief Get the LD_PRELOAD environment variable.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_get_preload( C_STRING lib_preload_env, C_INT check )
*
* @note This is a Fortran only interface that returns a value from the PAPI_get_opt call.
*
* @see PAPI_get_opt
*/
#if defined(_FORTRAN_STRLEN_AT_END)
PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
( char *lib_preload_env, int *check, int lib_preload_env_len ) )
#else
PAPI_FCALL( papif_get_preload, PAPIF_GET_PRELOAD,
( char *lib_preload_env, int *check ) )
#endif
{
PAPI_option_t p;
#if defined(_FORTRAN_STRLEN_AT_END)
int i;
if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
strncpy( lib_preload_env, p.preload.lib_preload_env,
( size_t ) lib_preload_env_len );
for ( i = ( int ) strlen( p.preload.lib_preload_env );
i < lib_preload_env_len; lib_preload_env[i++] = ' ' );
}
#else
if ( ( *check = PAPI_get_opt( PAPI_PRELOAD, &p ) ) == PAPI_OK ) {
strncpy( lib_preload_env, p.preload.lib_preload_env, PAPI_MAX_STR_LEN );
}
#endif
}
/** @class PAPIF_get_granularity
* @ingroup PAPIF
* @brief Get the granularity setting for the specified EventSet.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_get_granularity( C_INT eventset, C_INT granularity, C_INT mode, C_INT check )
*
* @see PAPI_get_opt
*/
PAPI_FCALL( papif_get_granularity, PAPIF_GET_GRANULARITY,
( int *eventset, int *granularity, int *mode, int *check ) )
{
PAPI_option_t g;
if ( *mode == PAPI_DEFGRN ) {
*granularity = PAPI_get_opt( *mode, &g );
*check = PAPI_OK;
} else if ( *mode == PAPI_GRANUL ) {
g.granularity.eventset = *eventset;
if ( ( *check = PAPI_get_opt( *mode, &g ) ) == PAPI_OK ) {
*granularity = g.granularity.granularity;
}
} else {
*check = PAPI_EINVAL;
}
}
/** @class PAPIF_get_domain
* @ingroup PAPIF
* @brief Get the domain setting for the specified EventSet.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_get_domain( C_INT eventset, C_INT domain, C_INT mode, C_INT check )
*
* @see PAPI_get_opt
*/
PAPI_FCALL( papif_get_domain, PAPIF_GET_DOMAIN,
( int *eventset, int *domain, int *mode, int *check ) )
{
PAPI_option_t d;
if ( *mode == PAPI_DEFDOM ) {
*domain = PAPI_get_opt( *mode, NULL );
*check = PAPI_OK;
} else if ( *mode == PAPI_DOMAIN ) {
d.domain.eventset = *eventset;
if ( ( *check = PAPI_get_opt( *mode, &d ) ) == PAPI_OK ) {
*domain = d.domain.domain;
}
} else {
*check = PAPI_EINVAL;
}
}
#if 0
PAPI_FCALL( papif_get_inherit, PAPIF_GET_INHERIT, ( int *inherit, int *check ) )
{
PAPI_option_t i;
if ( ( *check = PAPI_get_opt( PAPI_INHERIT, &i ) ) == PAPI_OK ) {
*inherit = i.inherit.inherit;
}
}
#endif
/** @class PAPIF_set_event_domain
* @ingroup PAPIF
* @brief Set the default counting domain for specified EventSet.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_event_domain( C_INT EventSet, C_INT domain, C_INT check )
*
* @see PAPI_set_domain
* @see PAPI_set_opt
*/
PAPI_FCALL( papif_set_event_domain, PAPIF_SET_EVENT_DOMAIN,
( int *es, int *domain, int *check ) )
{
PAPI_option_t d;
d.domain.domain = *domain;
d.domain.eventset = *es;
*check = PAPI_set_opt( PAPI_DOMAIN, &d );
}
/** @class PAPIF_set_inherit
* @ingroup PAPIF
* @brief Turn on inheriting of counts from daughter to parent process.
*
* @par Fortran Prototype:
* \#include "fpapi.h" @n
* PAPIF_set_inherit( C_INT inherit, C_INT check )
*
* @see PAPI_set_opt
*/
PAPI_FCALL( papif_set_inherit, PAPIF_SET_INHERIT, ( int *inherit, int *check ) )
{
PAPI_option_t i;
i.inherit.inherit = *inherit;
*check = PAPI_set_opt( PAPI_INHERIT, &i );
}
#pragma GCC visibility pop
|