-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsPAPI_tic.c
More file actions
33 lines (32 loc) · 943 Bytes
/
sPAPI_tic.c
File metadata and controls
33 lines (32 loc) · 943 Bytes
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
#include <stdio.h>
#include "mex.h"
#include "papi.h"
/*
* sPAPI_tic -- start hardware performance monitoring counters.
*/
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
/* Get number of running counters */
int num_counters = 0;
mxArray *sPAPI_status = mexGetVariable("global", "sPAPI_status");
if (sPAPI_status)
{
num_counters = *((int *)mxGetData(sPAPI_status));
}
if (num_counters > 0)
{
int result;
long long counter_values[num_counters];
if ((result = PAPI_read_counters(counter_values, num_counters)) != PAPI_OK)
{
char error[256];
sprintf(error, "Failed to clear counters. "
"Error message: %s.",
PAPI_strerror(result));
}
}
else
{
mexPrintf("Counters are unregistered and not running. Execute sPAPI_register first.\n");
}
}