42 printf(
"\n%s:\n%8s %12s %12s %8s %8s\n", title,
"i",
"papi",
"theory",
44 printf(
"-------------------------------------------------------------------------\n" );
55 #elif (defined(sparc) && defined(sun)) 66 long long papi, theory;
80 diff = ( int ) ( papi - theory );
82 ferror = ( ( float ) abs( diff ) ) / ( (
float ) theory ) * 100;
85 printf(
"%8d %12lld %12lld %8d %10.4f\n",
i, papi, theory, diff, ferror );
89 sprintf( err_str,
"Calibrate: difference exceeds %d percent",
MAX_WARN );
90 test_warn( __FILE__, __LINE__, err_str, 0 );
94 sprintf( err_str,
"Calibrate: error exceeds %d percent",
MAX_ERROR );
104 printf(
"Usage: %s [-ivmdh] [-e event]\n", argv[0] );
105 printf(
"Options:\n\n" );
106 printf(
"\t-i Inner Product test.\n" );
107 printf(
"\t-v Matrix-Vector multiply test.\n" );
108 printf(
"\t-m Matrix-Matrix multiply test.\n" );
109 printf(
"\t-d Double precision data. Default is float.\n" );
110 printf(
"\t-e event Use <event> as PAPI event instead of PAPI_FP_OPS\n" );
111 printf(
"\t-f Suppress failures\n" );
112 printf(
"\t-h Print this help message\n" );
114 printf(
"This test measures floating point operations for the specified test.\n" );
115 printf(
"Operations can be performed in single or double precision.\n" );
116 printf(
"Default operation is all three tests in single precision.\n" );
125 for (
i = 0;
i <= n;
i++ )
136 for (
i = 0;
i <= n;
i++ )
146 for (
i = 0;
i <= n;
i++ )
147 for ( j = 0; j <= n; j++ )
156 for (
i = 0;
i <= n;
i++ )
157 for ( j = 0; j <= n; j++ )
166 for (
i = 0;
i <= n;
i++ )
167 for ( j = 0; j <= n; j++ )
168 for ( k = 0; k <= n; k++ )
169 c[
i * n + j] =
c[
i * n + j] +
a[
i * n + k] *
b[k * n + j];
177 for (
i = 0;
i <= n;
i++ )
178 for ( j = 0; j <= n; j++ )
179 for ( k = 0; k <= n; k++ )
180 c[
i * n + j] =
c[
i * n + j] +
a[
i * n + k] *
b[k * n + j];
191 sprintf( err_str,
"%s: PAPI_start", title );
199 extern void dummy(
void * );
201 float aa, *
a=NULL, *
b=NULL, *
c=NULL, *
x=NULL, *
y=NULL;
202 double aad, *ad=NULL, *bd=NULL, *cd=NULL, *xd=NULL, *yd=NULL;
207 int double_precision = 0;
216 for (
i = 0;
i < argc;
i++ ) {
217 if ( strstr( argv[
i],
"-i" ) )
219 else if ( strstr( argv[
i],
"-f" ) )
221 else if ( strstr( argv[
i],
"-v" ) )
223 else if ( strstr( argv[
i],
"-m" ) )
225 else if ( strstr( argv[
i],
"-e" ) ) {
226 if ( ( argv[
i + 1] == NULL ) || ( strlen( argv[
i + 1] ) == 0 ) ) {
230 strncpy( papi_event_str, argv[
i + 1],
sizeof ( papi_event_str ) - 1);
231 papi_event_str[
sizeof ( papi_event_str )-1] =
'\0';
233 }
else if ( strstr( argv[
i],
"-d" ) )
234 double_precision = 1;
235 else if ( strstr( argv[
i],
"-h" ) ) {
242 if ( inner + vector + matrix == 0 )
243 inner = vector = matrix = 1;
250 printf(
"Initializing..." );
277 if (!
quiet) printf(
"\n" );
284 if (double_precision) {
285 xd = malloc(
INDEX5 *
sizeof(
double) );
286 yd = malloc(
INDEX5 *
sizeof(
double) );
291 x = malloc(
INDEX5 *
sizeof(
float) );
292 y = malloc(
INDEX5 *
sizeof(
float) );
301 for ( n = 0; n <
INDEX5; n++ ) {
302 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
305 if ( double_precision ) {
306 for (
i = 0;
i <= n;
i++ ) {
307 xd[
i] = ( double )
rand( ) * ( double ) 1.1;
308 yd[
i] = ( double )
rand( ) * ( double ) 1.1;
311 for (
i = 0;
i <= n;
i++ ) {
312 x[
i] = ( float )
rand( ) * ( float ) 1.1;
313 y[
i] = ( float )
rand( ) * ( float ) 1.1;
321 if ( double_precision ) {
323 dummy( (
void * ) &aad );
332 if (double_precision) {
344 if (double_precision) {
346 xd = malloc(
INDEX5 *
sizeof(
double) );
347 yd = malloc(
INDEX5 *
sizeof(
double) );
348 if ( !( ad && xd && yd ) )
352 x = malloc(
INDEX5 *
sizeof(
float) );
353 y = malloc(
INDEX5 *
sizeof(
float) );
354 if ( !(
a &&
x &&
y ) )
362 for ( n = 0; n <
INDEX5; n++ ) {
363 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
366 if ( double_precision ) {
367 for (
i = 0;
i <= n;
i++ ) {
369 xd[
i] = ( double )
rand( ) * ( double ) 1.1;
370 for ( j = 0; j <= n; j++ )
372 (
double )
rand( ) * ( double ) 1.1;
375 for (
i = 0;
i <= n;
i++ ) {
377 x[
i] = ( float )
rand( ) * ( float ) 1.1;
378 for ( j = 0; j <= n; j++ )
380 (
float )
rand( ) * ( float ) 1.1;
388 if ( double_precision ) {
390 dummy( (
void * ) yd );
399 if (double_precision) {
413 if (double_precision) {
417 if ( !( ad && bd && cd ) )
423 if ( !(
a &&
b &&
c ) )
432 for ( n = 0; n <
INDEX5; n++ ) {
433 if ( n <
INDEX1 || ( ( n + 1 ) % 50 ) == 0 ) {
436 if ( double_precision ) {
437 for (
i = 0;
i <= n * n + n;
i++ ) {
439 ad[
i] = ( double )
rand( ) * ( double ) 1.1;
440 bd[
i] = ( double )
rand( ) * ( double ) 1.1;
443 for (
i = 0;
i <= n * n + n;
i++ ) {
445 a[
i] = ( float )
rand( ) * ( float ) 1.1;
446 b[
i] = ( float )
rand( ) * ( float ) 1.1;
454 if ( double_precision ) {
465 if (double_precision) {
int PAPI_stop(int EventSet, long long *values)
void test_pass(const char *filename)
int PAPI_add_event(int EventSet, int EventCode)
static void vector_double(int n, double *a, double *x, double *y)
static float inner_single(int n, float *x, float *y)
static void vector_single(int n, float *a, float *x, float *y)
int PAPI_event_name_to_code(const char *in, int *out)
static void matrix_single(int n, float *c, float *a, float *b)
void test_warn(const char *file, int line, const char *call, int retval)
Return codes and api definitions.
static void matrix_double(int n, double *c, double *a, double *b)
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_library_init(int version)
static void resultline(int i, int j, int EventSet, int fail, int quiet)
static void print_help(char **argv)
static void headerlines(const char *title, int quiet)
int PAPI_create_eventset(int *EventSet)
int PAPI_query_event(int EventCode)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
static double inner_double(int n, double *x, double *y)
int PAPI_start(int EventSet)
static void reset_flops(const char *title, int EventSet)
static double b[MATRIX_SIZE][MATRIX_SIZE]
static double a[MATRIX_SIZE][MATRIX_SIZE]
int main(int argc, char *argv[])