Skip to content

Commit

Permalink
Added ugex.F (example for SC User's Guide)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosinski committed Apr 26, 2007
1 parent b962331 commit f68402a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ftests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FFLAGS = @PAPIPREP@ @FORTDEFS@ @FFLAGS@ @BITFLAGS@ @FTHREADFLAGS@
LDFLAGS = @BITFLAGS@ @FTHREADFLAGS@ -L.. -lgptl @LDFLAGS@ @LIBS@
CAMLDFLAGS = @BITFLAGS@ @FTHREADFLAGS@ -L.. -lcamgptl @LDFLAGS@ @LIBS@

OBJS = errtest.o papiomptest.o stride.o utrtest.o
EXES = errtest papiomptest stride utrtest
OBJS = errtest.o papiomptest.o stride.o ugex.o utrtest.o
EXES = errtest papiomptest stride ugex utrtest
CAMOBJ = camtest.o
CAMEXE = camtest

Expand All @@ -25,5 +25,8 @@ stride: stride.o
camtest: camtest.o
$(FC) $(FFLAGS) -o $@ camtest.o $(CAMLDFLAGS)

ugex: ugex.o
$(FC) $(FFLAGS) -o $@ ugex.o $(LDFLAGS)

utrtest: utrtest.o
$(FC) $(FFLAGS) -o $@ utrtest.o $(LDFLAGS)
69 changes: 69 additions & 0 deletions ftests/ugex.F
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
program ugex
implicit none

#include "gptl.inc"
#include "f90papi.h"

integer, parameter :: nompiter = 128 ! iteration count for threaded loop
integer, parameter :: ny = 9 ! iteration count for middle loop
integer, parameter :: nx = 1000000 ! iteration count for inner loop

integer :: i, j, iter ! loop indices
integer :: ret ! return code
integer*8 :: papicounters(3) ! PAPI counter values

real*8 :: sums(nompiter) ! summation array

if (gptlsetoption (gptlverbose, 0) < 0) call exit (1) ! turn off verbosity
if (gptlsetoption (gptlabort_on_error, 1) < 0) call exit(2) ! abort on error

ret = gptlsetoption (PAPI_FP_INS, 1) ! count FP instructions
ret = gptlsetoption (PAPI_TOT_CYC, 1) ! count total cycles
ret = gptlsetoption (gptloverhead, 0) ! don't print overhead stats
ret = gptlsetoption (gptlnarrowprint, 1) ! print fewer sig figs
ret = gptlinitialize () ! initialize GPTL
ret = gptlstart ('total') ! start a timer for the entire program
ret = gptlstart ('init') ! start a timer
do i=1,nompiter
sums(i) = 0.
end do
ret = gptlstop ('init') ! stop a timer
! Invoke a threaded loop, and gather timing info
!$OMP PARALLEL DO PRIVATE (i, j, iter, ret)
do iter=1,nompiter
ret = gptlstart ('Jloop')
do j=1,ny
ret = gptlstart ('Iloop1')
do i=1,nx
sums(iter) = sums(iter) + 0.0001*i
end do
ret = gptlstop ('Iloop1')
ret = gptlstart ('Iloop2')
do i=1,nx
sums(iter) = sums(iter) + i
end do
ret = gptlstop ('Iloop2')
end do
ret = gptlstop ('Jloop') ! stop timer
end do
ret = gptlstop ('total') ! stop the timer for the entire program
! Retrieve the PAPI counters for timer 'total' and print them
ret = gptlquerycounters ('total', -1, papicounters)
write(6,*)'total PAPI_FP_INS= ', papicounters(1)
write(6,*)'total PAPI_TOT_CYC= ', papicounters(2)
ret = gptlpr (0) ! print the timing results to timing.0
ret = gptlfinalize () ! clean up
stop 0
end program ugex

0 comments on commit f68402a

Please sign in to comment.