File: flops.readme

package info (click to toggle)
papi 5.7.0+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 9,856 kB
  • sloc: ansic: 93,265; fortran: 3,338; xml: 2,460; makefile: 815; sh: 290
file content (83 lines) | stat: -rw-r--r-- 3,022 bytes parent folder | download | duplicates (4)
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
Running PAPI FLOPS in the MATLAB Environment

If you want to measure the rate of floating point operations
in a MATLAB program, PAPI FLOPS is a good way to do it.
PAPI FLOPS uses the PAPI library and underlying hardware counters
to accurately compute both the total number of floating point operations
and the rate of floating point execution in a section of
MATLAB code.

For more information on the flops function, 
you can type 'help flops' inside MATLAB.

FLOPS - Has 3 execution possibilities:
  Initialize FLOP counting or reset the counters with:
    FLOPS(0)
  Record the number of floating point instructions since
  initialization:
    ops = FLOPS
  Record the number of floating point instructions and
  the incremental rate of floating point execution
  since initialization:
    [ops, mflips] = FLOPS

PAPI_flops.c, when compiled, turns into a callable function in MATLAB.
 In order to use this function, you need to know a little
about mex.  mex is simply the compiler you use to make your
code run in the MATLAB environment.  If you don't know
how to use mex, you might want to acquaint yourself a bit.

"mex -setup "might be needed if you encounter problems, but
the simplest explanation might be to substitute "mex" for 
"gcc" and you are on your way.

All the other rules for compiling PAPI are the same.  mex
compilations can de done inside or outside of the Matlab
environment, but in this case, it is recommended that you
compile outside of Matlab.  For some reason, compiling 
inside does not work on some systems.

So far, the Linux environment and the Windows environment
have been tested, but _in theory_ this code should work anywhere 
PAPI and Matlab both work.

The following instructions are for a Linux/Unix environment:

Assuming papi.h is present in /usr/local/include and libpapi.a
is present in /usr/local/lib, the below should work.  If not,
you may need to alter the compile strings and/or the #include
statement in PAPI_flops.c.  Also, the compile string will be
different for different platforms.

For instance, if I want to compile and run on a linux
machine assuming PAPI_flops.c is in your current working
directory (you'll have a different compile string on a 
different architecture):

1. Compile the wrapper:
mex -I/usr/local/include PAPI_flops.c /usr/local/lib/libpapi.a -output flops

2.  Start Matlab:
matlab

3.  Run the code:

b.  Play with FLOPS - the first initializes the counting;
    the second returns the number of floating point instructions
    since the first call, and the third line does the same as the
    first AND reports the incremental rate of floating point
    execution since the last call:
FLOPS(0)
ins = FLOPS
[ins, mflips] = FLOPS

c. Try the example m files included with the distribution:
FlopsInnerProduct.m
FlopsMatrixVector.m
FlopsMatrixMatrix.m
FlopsSampler.m

Contact jthomas@cs.utk.edu with any questions regarding
PAPI calls in Matlab - either errors or questions.
Also, this has just been implemented, so changes could
be coming..........