17run_output_t probeBufferSize(
long long active_buf_len,
long long line_size,
float pageCountPerBlock,
int pattern, uintptr_t **v, uintptr_t *rslt,
int latency_only,
int mode,
int ONT){
19 int retval, buffer = 0, status = 0;
20 int error_line = -1, error_type =
PAPI_OK;
21 register uintptr_t *p = NULL;
22 register uintptr_t p_prime;
23 long long count, pageSize, blockSize;
24 long long int counter[ONT];
28 assert(
sizeof(
int) >= 4 );
31 x = floor(1.3*
x/(1.4*
x+1.8));
34 printf(
"WARNING: x=%lf y=%lf\n",
x,
y);
39 if( active_buf_len*
sizeof(uintptr_t) >
threshold )
40 countMax = 64LL*((
long long)(active_buf_len/line_size));
45 pageSize = sysconf(_SC_PAGESIZE)/
sizeof(uintptr_t);
47 fprintf(
stderr,
"Cannot determine pagesize, sysconf() returned an error code.\n");
53 blockSize = (
long long)(pageCountPerBlock*(
float)pageSize);
54 #pragma omp parallel reduction(+:status) default(shared)
56 int idx = omp_get_thread_num();
58 status +=
prepareArray(v[idx], active_buf_len, line_size, blockSize, pattern);
62 #pragma omp parallel private(p,count,retval) reduction(+:buffer) reduction(+:status) firstprivate(_papi_eventset) default(shared)
64 int idx = omp_get_thread_num();
67 double time1=0, time2=0, dt, factor;
71 if ( !latency_only ) {
80 if ( !latency_only && (
is_core || 0 == idx) ) {
84 error_line = __LINE__;
93 error_line = __LINE__;
103 error_line = __LINE__;
115 if( latency_only ) time1 =
getticks();
120 if( latency_only ) time2 =
getticks();
131 if ( !latency_only && (
is_core || 0 == idx) ) {
136 error_line = __LINE__;
143 divisor = 1.0*countMax;
147 out.
counter[idx] = (1.0*counter[idx])/divisor;
153 error_line = __LINE__;
160 error_line = __LINE__;
172 factor /= (1.0*countMax);
175 out.
dt[idx] = dt*factor;
179 buffer += (uintptr_t)p+(uintptr_t)(
x+
y);
197 const char *errors[26] = {
200 "Insufficient memory",
201 "A System/C library call failed",
202 "Not supported by component",
203 "Access to the counters was lost or interrupted",
204 "Internal error, please send mail to the developers",
205 "Event does not exist",
206 "Event exists, but cannot be counted due to counter resource limitations",
207 "EventSet is currently not running",
208 "EventSet is currently counting",
209 "No such EventSet Available",
210 "Event in argument is not a valid preset",
211 "Hardware does not support performance counters",
212 "Unknown error code",
213 "Permission level does not permit operation",
214 "PAPI hasn't been initialized yet",
215 "Component Index isn't set",
218 "Buffer size exceeded",
219 "EventSet domain is not supported for the operation",
220 "Invalid or missing event attributes",
221 "Too many events or attributes",
222 "Bad combination of features",
223 "Component containing event is disabled"
227 if(idx >= 26 || idx < 0 )
231 fprintf(
stderr,
"\nError \"%s\" occured at line %d when processing event %s.\n", errors[idx], line,
eventname);
233 fprintf(
stderr,
"\nError \"%s\" occured at line %d.\n", errors[idx], line);
static double elapsed(double t1, double t0)
static double getticks(void)
add PAPI preset or native hardware event by name to an EventSet
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Return codes and api definitions.
int prepareArray(uintptr_t *array, long long len, long long stride, long long secSize, int pattern)
double counter[MAXTHREADS]
run_output_t probeBufferSize(long long active_buf_len, long long line_size, float pageCountPerBlock, int pattern, uintptr_t **v, uintptr_t *rslt, int latency_only, int mode, int ONT)
void error_handler(int e, int line)