mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-22 12:23:32 +01:00
Added has_openmp for variables
This commit is contained in:
parent
2b2e048f01
commit
f6ff97f5c5
@ -45,24 +45,34 @@ module irp_stack_mod
|
|||||||
double precision,allocatable :: irp_cpu(:,:)
|
double precision,allocatable :: irp_cpu(:,:)
|
||||||
integer,allocatable :: stack_index(:)
|
integer,allocatable :: stack_index(:)
|
||||||
logical :: alloc = .False.
|
logical :: alloc = .False.
|
||||||
|
integer :: nthread
|
||||||
character*(128) :: white = ''
|
character*(128) :: white = ''
|
||||||
end module
|
end module
|
||||||
|
|
||||||
subroutine irp_enter(irp_where)
|
subroutine irp_enter(irp_where)
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
integer :: ithread
|
integer :: ithread
|
||||||
integer :: nthread
|
|
||||||
character*(*) :: irp_where
|
character*(*) :: irp_where
|
||||||
$OMP_DECL
|
!$ integer, external :: omp_get_thread_num
|
||||||
!$OMP CRITICAL
|
!$ integer, external :: omp_get_num_threads
|
||||||
ithread = $OMP_GET_THREAD_NUM
|
ithread = 0
|
||||||
nthread = $OMP_GET_NUM_THREADS
|
!$ ithread = omp_get_thread_num()
|
||||||
$1
|
$1
|
||||||
!$OMP END CRITICAL
|
if (ithread /= 0) then
|
||||||
|
print *, 'Error: Provider is called by thread', ithread
|
||||||
|
call irp_trace
|
||||||
|
stop 1
|
||||||
|
endif
|
||||||
"""
|
"""
|
||||||
if command_line.do_memory:
|
if command_line.do_memory:
|
||||||
txt+="""
|
txt+="""
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
|
nthread = 1
|
||||||
|
!$OMP PARALLEL
|
||||||
|
!$OMP SINGLE
|
||||||
|
!$ nthread = omp_get_num_threads()
|
||||||
|
!$OMP END SINGLE
|
||||||
|
!$OMP END PARALLEL
|
||||||
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
|
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
|
||||||
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
|
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
|
||||||
print *, 'Allocating stack_index(',nthread,')'
|
print *, 'Allocating stack_index(',nthread,')'
|
||||||
@ -71,36 +81,55 @@ $1
|
|||||||
$2
|
$2
|
||||||
end subroutine
|
end subroutine
|
||||||
|
|
||||||
|
subroutine irp_enter_f(irp_where)
|
||||||
|
use irp_stack_mod
|
||||||
|
integer :: ithread
|
||||||
|
character*(*) :: irp_where
|
||||||
|
!$ integer, external :: omp_get_thread_num
|
||||||
|
!$ integer, external :: omp_get_num_threads
|
||||||
|
ithread = 0
|
||||||
|
!$ ithread = omp_get_thread_num()
|
||||||
|
$1
|
||||||
|
"""
|
||||||
|
if command_line.do_memory:
|
||||||
|
txt+="""
|
||||||
|
if (.not.alloc) then
|
||||||
|
!$OMP PARALLEL
|
||||||
|
!$OMP SINGLE
|
||||||
|
!$ nthread = omp_get_num_threads()
|
||||||
|
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
|
||||||
|
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
|
||||||
|
print *, 'Allocating stack_index(',nthread,')'
|
||||||
|
!$OMP END SINGLE
|
||||||
|
!$OMP END PARALLEL
|
||||||
|
endif"""
|
||||||
|
txt +="""
|
||||||
|
$2
|
||||||
|
end subroutine
|
||||||
|
|
||||||
subroutine irp_leave (irp_where)
|
subroutine irp_leave (irp_where)
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
character*(*) :: irp_where
|
character*(*) :: irp_where
|
||||||
integer :: ithread
|
integer :: ithread
|
||||||
double precision :: cpu
|
double precision :: cpu
|
||||||
$OMP_DECL
|
!$ integer, external :: omp_get_thread_num
|
||||||
!$OMP CRITICAL
|
ithread = 0
|
||||||
ithread = $OMP_GET_THREAD_NUM
|
!$ ithread = omp_get_thread_num()
|
||||||
$3
|
$3
|
||||||
$4
|
$4
|
||||||
!$OMP END CRITICAL
|
|
||||||
end subroutine
|
end subroutine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# $OMP_DECL
|
|
||||||
if do_openmp:
|
|
||||||
txt = txt.replace("$OMP_DECL","""
|
|
||||||
integer :: omp_get_num_threads
|
|
||||||
integer :: omp_get_thread_num
|
|
||||||
""")
|
|
||||||
txt = txt.replace("$OMP_GET_NUM_THREADS","omp_get_num_threads()")
|
|
||||||
txt = txt.replace("$OMP_GET_THREAD_NUM","omp_get_thread_num()")
|
|
||||||
else:
|
|
||||||
txt = txt.replace("$OMP_DECL","")
|
|
||||||
txt = txt.replace("$OMP_GET_NUM_THREADS","1")
|
|
||||||
txt = txt.replace("$OMP_GET_THREAD_NUM","0")
|
|
||||||
|
|
||||||
# $1
|
# $1
|
||||||
if do_assert or do_debug:
|
if do_assert or do_debug:
|
||||||
txt = txt.replace("$1","""
|
txt = txt.replace("$1","""
|
||||||
|
if (.not.alloc) then
|
||||||
|
!$OMP PARALLEL
|
||||||
|
!$OMP SINGLE
|
||||||
|
!$ nthread = omp_get_num_threads()
|
||||||
|
!$OMP END SINGLE
|
||||||
|
!$OMP END PARALLEL
|
||||||
|
!$OMP CRITICAL
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
allocate(irp_stack(STACKMAX,nthread+1))
|
allocate(irp_stack(STACKMAX,nthread+1))
|
||||||
allocate(irp_cpu(STACKMAX,nthread+1))
|
allocate(irp_cpu(STACKMAX,nthread+1))
|
||||||
@ -108,6 +137,8 @@ end subroutine
|
|||||||
stack_index = 0
|
stack_index = 0
|
||||||
alloc = .True.
|
alloc = .True.
|
||||||
endif
|
endif
|
||||||
|
!$OMP END CRITICAL
|
||||||
|
endif
|
||||||
stack_index(ithread+1) = stack_index(ithread+1)+1
|
stack_index(ithread+1) = stack_index(ithread+1)+1
|
||||||
irp_stack(stack_index(ithread+1),ithread+1) = irp_where""")
|
irp_stack(stack_index(ithread+1),ithread+1) = irp_where""")
|
||||||
if command_line.do_memory:
|
if command_line.do_memory:
|
||||||
@ -143,13 +174,14 @@ end subroutine
|
|||||||
else:
|
else:
|
||||||
txt = txt.replace("$4","")
|
txt = txt.replace("$4","")
|
||||||
|
|
||||||
if do_debug or do_assert:
|
|
||||||
txt += """
|
txt += """
|
||||||
subroutine irp_trace
|
subroutine irp_trace
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
integer :: ithread
|
integer :: ithread
|
||||||
integer :: i
|
integer :: i
|
||||||
|
!$ integer, external :: omp_get_thread_num
|
||||||
ithread = 0
|
ithread = 0
|
||||||
|
!$ ithread = omp_get_thread_num()
|
||||||
if (.not.alloc) return
|
if (.not.alloc) return
|
||||||
print *, 'Stack trace: ', ithread
|
print *, 'Stack trace: ', ithread
|
||||||
print *, '-------------------------'
|
print *, '-------------------------'
|
||||||
|
@ -602,7 +602,7 @@ def irp_simple_statements(text):
|
|||||||
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
|
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
|
||||||
if command_line.do_assert or command_line.do_debug:
|
if command_line.do_assert or command_line.do_debug:
|
||||||
result += [
|
result += [
|
||||||
Simple_line(i," call irp_enter(irp_here)", f),
|
Simple_line(i," call irp_enter_f(irp_here)", f),
|
||||||
]
|
]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -616,7 +616,7 @@ def irp_simple_statements(text):
|
|||||||
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
|
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
|
||||||
if command_line.do_assert or command_line.do_debug:
|
if command_line.do_assert or command_line.do_debug:
|
||||||
result += [
|
result += [
|
||||||
Simple_line(i," call irp_enter(irp_here)", f),
|
Simple_line(i," call irp_enter_f(irp_here)", f),
|
||||||
]
|
]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -55,6 +55,20 @@ class Variable(object):
|
|||||||
return self._is_touched
|
return self._is_touched
|
||||||
is_touched = property(is_touched)
|
is_touched = property(is_touched)
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
def has_openmp(self):
|
||||||
|
if '_has_openmp' not in self.__dict__:
|
||||||
|
buffer = None
|
||||||
|
text = self.text
|
||||||
|
result = False
|
||||||
|
for line in text:
|
||||||
|
if type(line) == Openmp:
|
||||||
|
result = True
|
||||||
|
break
|
||||||
|
self._has_openmp = result
|
||||||
|
return self._has_openmp
|
||||||
|
has_openmp = property(has_openmp)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
def is_written(self):
|
def is_written(self):
|
||||||
if '_is_written' not in self.__dict__:
|
if '_is_written' not in self.__dict__:
|
||||||
|
Loading…
Reference in New Issue
Block a user