Commit 144ff848 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Add a stand-alone PAPI test program

parent 1d11c7f3
......@@ -55,7 +55,7 @@ ftimings_c_example_SOURCES = \
ftimings_c_example_LDADD = libftimings-@FTIMINGS_API_VERSION@-@FC@.la
ftimings_c_example_LINK = $(FCLINK) -static
noinst_PROGRAMS = do_flops do_memory_transfer test_perf
noinst_PROGRAMS = do_flops do_memory_transfer test_perf test_papi
do_flops_SOURCES = \
examples/do_flops.c
......@@ -69,6 +69,10 @@ test_perf_SOURCES = \
ftimings/perf_memory_counter.c
test_perf_CPPFLAGS = -DTEST_PERF
test_papi_SOURCES = \
ftimings/papi.c
test_papi_CPPFLAGS = -DTEST_PAPI
# other files to distribute
filesdir = $(datadir)/@PACKAGE@-@FC@/examples
files_DATA = examples/example.F90
......
......@@ -136,4 +136,33 @@ void ftimings_papi_counters(long long *flop, long long *cycles) {
*cycles = 0LL;
}
}
#endif
#ifdef TEST_PAPI
#include <assert.h>
static void print_papi_counters(int event_set) {
long long flop_count, cycle_count;
ftimings_papi_counters(&flop_count, &cycle_count);
printf("FLOP count: %lld, CPU cycles: %lld\n", flop_count, cycle_count);
printf("FLOP/cycle: %g\n\n", (double) flop_count / (double) cycle_count);
}
double w;
int main(int argc, char *argv[argc + 1]) {
int i;
assert(ftimings_flop_init());
print_papi_counters(event_set);
w = 1.5;
for (i = 0; i < 1 << 27; i++) {
w = w + 1/w;
}
print_papi_counters(event_set);
}
#endif /* TEST_PAPI */
#endif /* HAVE_LIBPAPI */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment