mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-22 04:13:33 +01:00
Improved profiled
Version:1.2.4
This commit is contained in:
parent
caba30c9de
commit
a37456429c
@ -46,6 +46,7 @@ options['z'] = [ 'openmp' , 'Automatic openMP tasks (may not work)', 0 ]
|
|||||||
options['l'] = [ 'align' , 'Align arrays using compiler directives', 1 ]
|
options['l'] = [ 'align' , 'Align arrays using compiler directives', 1 ]
|
||||||
options['s'] = [ 'substitute' , 'Substitute values for loop max values', 1 ]
|
options['s'] = [ 'substitute' , 'Substitute values for loop max values', 1 ]
|
||||||
options['r'] = [ 'no_directives', 'Ignore compiler directives !DEC$ and !DIR$', 0 ]
|
options['r'] = [ 'no_directives', 'Ignore compiler directives !DEC$ and !DIR$', 0 ]
|
||||||
|
options['n'] = [ 'inline' , 'all|providers|builders : Force inlining of providers or builders', 1 ]
|
||||||
|
|
||||||
class CommandLine(object):
|
class CommandLine(object):
|
||||||
|
|
||||||
@ -64,6 +65,16 @@ class CommandLine(object):
|
|||||||
return self._defined
|
return self._defined
|
||||||
defined = property(fget=defined)
|
defined = property(fget=defined)
|
||||||
|
|
||||||
|
def inline(self):
|
||||||
|
if '_inline' not in self.__dict__:
|
||||||
|
self._inline = ""
|
||||||
|
for o,a in self.opts:
|
||||||
|
if o in [ "-n", '--'+options['n'][0] ]:
|
||||||
|
self._inline = a
|
||||||
|
break
|
||||||
|
return self._inline
|
||||||
|
inline = property(fget=inline)
|
||||||
|
|
||||||
def substituted(self):
|
def substituted(self):
|
||||||
if '_substituted' not in self.__dict__:
|
if '_substituted' not in self.__dict__:
|
||||||
self._substituted = {}
|
self._substituted = {}
|
||||||
|
@ -89,7 +89,7 @@ def run():
|
|||||||
|
|
||||||
print >>file, "OBJ1 = $(patsubst %%, %s%%,$(notdir $(OBJ))) %sirp_touches.irp.o"%(irpdir,irpdir),
|
print >>file, "OBJ1 = $(patsubst %%, %s%%,$(notdir $(OBJ))) %sirp_touches.irp.o"%(irpdir,irpdir),
|
||||||
if command_line.do_profile:
|
if command_line.do_profile:
|
||||||
print >>file, " %sirp_profile.irp.o"%(irpdir), " %sirp_rdtsc.o"%(irpdir),
|
print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o",
|
||||||
if command_line.do_openmp:
|
if command_line.do_openmp:
|
||||||
print >>file, " %sirp_locks.irp.o"%(irpdir),
|
print >>file, " %sirp_locks.irp.o"%(irpdir),
|
||||||
else:
|
else:
|
||||||
|
@ -34,6 +34,8 @@ from util import *
|
|||||||
re_endif = re.compile("end\s+if")
|
re_endif = re.compile("end\s+if")
|
||||||
re_elseif = re.compile("else\s+if")
|
re_elseif = re.compile("else\s+if")
|
||||||
re_enddo = re.compile("end\s+do")
|
re_enddo = re.compile("end\s+do")
|
||||||
|
re_endtype= re.compile("end\s+type")
|
||||||
|
re_endmodule = re.compile("end\s+module")
|
||||||
re_endselect = re.compile("end\s+select")
|
re_endselect = re.compile("end\s+select")
|
||||||
|
|
||||||
# Local variables
|
# Local variables
|
||||||
@ -100,6 +102,8 @@ def get_type (i, filename, line, is_doc):
|
|||||||
# Replacements
|
# Replacements
|
||||||
lower_line = re_elseif.sub("elseif",lower_line)
|
lower_line = re_elseif.sub("elseif",lower_line)
|
||||||
lower_line = re_enddo.sub("enddo",lower_line)
|
lower_line = re_enddo.sub("enddo",lower_line)
|
||||||
|
lower_line = re_endtype.sub("endtype",lower_line)
|
||||||
|
lower_line = re_endmodule.sub("endmodule",lower_line)
|
||||||
lower_line = re_endif.sub("endif",lower_line)
|
lower_line = re_endif.sub("endif",lower_line)
|
||||||
lower_line = re_endselect.sub("endselect",lower_line)
|
lower_line = re_endselect.sub("endselect",lower_line)
|
||||||
for c in """()'"[]""":
|
for c in """()'"[]""":
|
||||||
|
@ -29,8 +29,7 @@ def build_rdtsc():
|
|||||||
file.write(rdtsc)
|
file.write(rdtsc)
|
||||||
file.close()
|
file.close()
|
||||||
def t():
|
def t():
|
||||||
p = subprocess.Popen(["gcc","-O2",filename,"-c","-o","IRPF90_temp/irp_rdtsc.o"])
|
p = subprocess.Popen(["gcc","-O2",filename,"-c","-o","irp_rdtsc.o"])
|
||||||
|
|
||||||
p.communicate()
|
p.communicate()
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
@ -39,14 +38,52 @@ def build_rdtsc():
|
|||||||
def build_module():
|
def build_module():
|
||||||
data = """
|
data = """
|
||||||
module irp_timer
|
module irp_timer
|
||||||
double precision :: irp_profile(2,%(n)d)
|
double precision :: irp_profile(3,%(n)d)
|
||||||
|
integer :: irp_order(%(n)d)
|
||||||
character*(64) :: irp_profile_label(%(n)d)
|
character*(64) :: irp_profile_label(%(n)d)
|
||||||
|
double precision :: irp_rdtsc_shift
|
||||||
|
|
||||||
|
contains
|
||||||
|
|
||||||
|
subroutine profile_sort ()
|
||||||
|
implicit none
|
||||||
|
character*(64) :: xtmp
|
||||||
|
integer :: i, i0, j, jmax
|
||||||
|
|
||||||
|
do i=1,size(irp_profile_label)
|
||||||
|
irp_order(i)=i
|
||||||
|
enddo
|
||||||
|
do i=1,size(irp_profile_label)
|
||||||
|
xtmp = irp_profile_label(i)
|
||||||
|
i0 = irp_order(i)
|
||||||
|
j = i-1
|
||||||
|
do j=i-1,1,-1
|
||||||
|
if ( irp_profile_label(j) > xtmp ) then
|
||||||
|
irp_profile_label(j+1) = irp_profile_label(j)
|
||||||
|
irp_order(j+1) = irp_order(j)
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
irp_profile_label(j+1) = xtmp
|
||||||
|
irp_order(j+1) = i0
|
||||||
|
enddo
|
||||||
|
end subroutine profile_sort
|
||||||
|
|
||||||
end module
|
end module
|
||||||
|
|
||||||
subroutine irp_init_timer
|
subroutine irp_init_timer
|
||||||
use irp_timer
|
use irp_timer
|
||||||
implicit none
|
implicit none
|
||||||
irp_profile = 0.
|
integer :: i
|
||||||
|
double precision :: irp_rdtsc, t0
|
||||||
|
irp_profile = 0.d0
|
||||||
|
irp_rdtsc_shift = 0.d0
|
||||||
|
do i=1,1000
|
||||||
|
t0 = irp_rdtsc()
|
||||||
|
irp_rdtsc_shift = irp_rdtsc_shift + (irp_rdtsc()-t0)
|
||||||
|
enddo
|
||||||
|
irp_rdtsc_shift = 1.d-3*irp_rdtsc_shift
|
||||||
%(text)s
|
%(text)s
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,33 +91,55 @@ subroutine irp_set_timer(i,value)
|
|||||||
use irp_timer
|
use irp_timer
|
||||||
implicit none
|
implicit none
|
||||||
integer, intent(in) :: i
|
integer, intent(in) :: i
|
||||||
double precision, intent(in) :: value
|
double precision, intent(inout) :: value
|
||||||
|
value = value - irp_rdtsc_shift
|
||||||
irp_profile(1,i) = irp_profile(1,i) + value
|
irp_profile(1,i) = irp_profile(1,i) + value
|
||||||
irp_profile(2,i) = irp_profile(2,i) + 1.d0
|
irp_profile(2,i) = irp_profile(2,i) + value*value
|
||||||
|
irp_profile(3,i) = irp_profile(3,i) + 1.d0
|
||||||
end
|
end
|
||||||
|
|
||||||
subroutine irp_print_timer()
|
subroutine irp_print_timer()
|
||||||
use irp_timer
|
use irp_timer
|
||||||
implicit none
|
implicit none
|
||||||
integer :: i
|
integer :: i, ii
|
||||||
print '(A24,A8,4(X,A14))', 'Calls', 'Tot Cycles', 'Avge Cycles', &
|
double precision :: error, sigma2, average, average2, frequency, t0
|
||||||
'Tot Secs(1GHz)', 'Avge Secs(1GHz)'
|
double precision :: irp_rdtsc
|
||||||
|
t0 = irp_rdtsc()
|
||||||
|
call sleep(1)
|
||||||
|
frequency = (irp_rdtsc()-t0-irp_rdtsc_shift)
|
||||||
|
|
||||||
|
call profile_sort()
|
||||||
|
print '(A24,A8,A17,A20,A13,A20)', '', 'N.Calls', 'Tot Cycles', 'Avg Cycles', &
|
||||||
|
'Tot Secs', 'Avg Secs'
|
||||||
print '(A)', '----------------------------------------------'// &
|
print '(A)', '----------------------------------------------'// &
|
||||||
'----------------------------------------------'
|
'----------------------------------------------'
|
||||||
do i=1,%(n)d
|
do ii=1,%(n)d
|
||||||
if (irp_profile(2,i) > 0.) then
|
i = irp_order(ii)
|
||||||
print '(A24,F8.0,2(X,F14.0),2(X,F14.8))', &
|
if (irp_profile(3,i) > 0.) then
|
||||||
irp_profile_label(i), irp_profile(2,i), &
|
error = 0.d0
|
||||||
irp_profile(1,i), irp_profile(1,i)/irp_profile(2,i), &
|
average = irp_profile(1,i)/irp_profile(3,i)
|
||||||
irp_profile(1,i)*1.d-9, 1.d-9*irp_profile(1,i)/irp_profile(2,i)
|
if (irp_profile(3,i) > 1.d0) then
|
||||||
|
average2 = irp_profile(2,i)/irp_profile(3,i)
|
||||||
|
sigma2 = (average2 - average*average)
|
||||||
|
error = sqrt(sigma2/(irp_profile(3,i)+1.d0))
|
||||||
|
endif
|
||||||
|
print '(A24 , F8.0 , X,F12.0 , X,F12.0,A3,F8.0, X,F12.8, X,F8.5,A3,F8.5 )', &
|
||||||
|
irp_profile_label(ii), &
|
||||||
|
irp_profile(3,i), &
|
||||||
|
irp_profile(1,i), &
|
||||||
|
average, '+/-', error, &
|
||||||
|
irp_profile(1,i)/frequency, &
|
||||||
|
average/frequency, '+/-', error/frequency
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
|
print *, 'Frequency :', frequency*1.d-9, ' GHz'
|
||||||
|
print *, 'rdtsc latency :', irp_rdtsc_shift, ' cycles'
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
label = {}
|
label = {}
|
||||||
for i in variables:
|
for i in variables:
|
||||||
vi = variables[i]
|
vi = variables[i]
|
||||||
label[vi.label] = vi.name
|
label[vi.label] = vi.same_as
|
||||||
text = []
|
text = []
|
||||||
lmax = 0
|
lmax = 0
|
||||||
for l in label:
|
for l in label:
|
||||||
|
@ -46,6 +46,7 @@ re_decl = re.compile( "".join( [ r"^\ *",
|
|||||||
r"|intrinsic *(::)?",
|
r"|intrinsic *(::)?",
|
||||||
r"|external *(::)?",
|
r"|external *(::)?",
|
||||||
r"|equivalence *(::)?",
|
r"|equivalence *(::)?",
|
||||||
|
r"|type",
|
||||||
r")[^=(]"
|
r")[^=(]"
|
||||||
] ) )
|
] ) )
|
||||||
|
|
||||||
|
@ -507,7 +507,10 @@ class Variable(object):
|
|||||||
" endif" ]
|
" endif" ]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = [ "subroutine provide_%s"%(name) ]
|
result = []
|
||||||
|
if command_line.directives and command_line.inline in ["all","providers"]:
|
||||||
|
result += [ "!DEC$ ATTRIBUTES FORCEINLINE :: provide_%s"%(name) ]
|
||||||
|
result += [ "subroutine provide_%s"%(name) ]
|
||||||
result += build_use( [same_as]+self.to_provide )
|
result += build_use( [same_as]+self.to_provide )
|
||||||
result.append(" implicit none")
|
result.append(" implicit none")
|
||||||
length = len("provide_%s"%(name))
|
length = len("provide_%s"%(name))
|
||||||
@ -570,7 +573,10 @@ class Variable(object):
|
|||||||
text = map(lambda x: x[1], text)
|
text = map(lambda x: x[1], text)
|
||||||
for line in filter(lambda x: type(x) not in [ Begin_doc, End_doc, Doc], text):
|
for line in filter(lambda x: type(x) not in [ Begin_doc, End_doc, Doc], text):
|
||||||
if type(line) == Begin_provider:
|
if type(line) == Begin_provider:
|
||||||
result = [ "subroutine bld_%s"%(name) ]
|
result = []
|
||||||
|
if command_line.directives and command_line.inline in ["all","builders"]:
|
||||||
|
result += [ "!DEC$ ATTRIBUTES FORCEINLINE :: bld_%s"%(same_as) ]
|
||||||
|
result += [ "subroutine bld_%s"%(name) ]
|
||||||
result += build_use([name]+self.needs)
|
result += build_use([name]+self.needs)
|
||||||
elif type(line) == Cont_provider:
|
elif type(line) == Cont_provider:
|
||||||
pass
|
pass
|
||||||
|
@ -1 +1 @@
|
|||||||
version = "1.2.3"
|
version = "1.2.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user