OpenMP flag has to be set for openmp programs

This commit is contained in:
Anthony Scemama 2014-10-08 16:24:01 +02:00
parent 673220f1a9
commit 147e3a315a
8 changed files with 18 additions and 21 deletions

View File

@ -50,11 +50,10 @@ options['s'] = [ 'substitute' , 'Substitute values in do loops for generating
options['t'] = [ 'touch' , 'Display which entities are touched when touching the variable given as an argument.', 1 ]
options['u'] = [ 'unused' , 'Print unused providers', 0 ]
options['v'] = [ 'version' , 'Prints version of irpf90', 0 ]
#options['z'] = [ 'openmp' , 'Automatic openMP tasks (may not work)', 0 ]
options['z'] = [ 'openmp' , 'Activate for OpenMP code', 0 ]
class CommandLine(object):
do_openmp = False
def __init__(self):
global options
self._opts = None
@ -162,6 +161,15 @@ or
return self._coarray
coarray = property(fget=coarray)
def openmp(self):
if '_openmp' not in self.__dict__:
self._openmp = False
for o,a in self.opts:
if o in [ "-z", '--'+options['z'][0] ]:
self._openmp = True
return self._openmp
do_openmp = property(fget=openmp)
def directives(self):
if '_directives' not in self.__dict__:
self._directives = True

View File

@ -106,6 +106,10 @@ def main():
import profile
profile.run()
if command_line.do_openmp:
import locks
locks.create()
if __name__ == '__main__':
main()

View File

@ -113,7 +113,7 @@ def run():
if command_line.do_codelet:
print >>file, " irp_rdtsc.o",
if command_line.do_openmp:
print >>file, " %sirp_locks.irp.o"%(irpdir),
print >>file, " %sirp_locks.irp.o"%(irpdir)
else:
print >>file, ""

View File

@ -177,6 +177,7 @@ class Fmodule(object):
use,dec,result = extract_use_dec_text(result)
self._use = make_single(map(lambda x: " "+x[1].text, use))
self._dec = map(lambda x: " "+x[1].text, dec)
# self._dec = make_single(map(lambda x: " "+x[1].text, dec))
result = provide_variables(result)
result = move_to_top(result,Declaration)
result = move_to_top(result,Implicit)

View File

@ -627,13 +627,7 @@ def irp_simple_statements(text):
temp = [ Program(0,"program irp_program",program_name) ]
if command_line.do_profile:
temp += [ Simple_line(0,"call irp_init_timer()",line.filename) ]
if command_line.do_openmp:
temp += [ Openmp(0,"!$OMP PARALLEL",line.filename) ]
temp += [ Openmp(0,"!$OMP MASTER",line.filename) ]
temp += [ Call(0," call %s"%(program_name),line.filename) ]
if command_line.do_openmp:
temp += [ Openmp(0,"!$OMP END MASTER",line.filename) ]
temp += [ Openmp(0,"!$OMP END PARALLEL",line.filename) ]
if command_line.do_profile:
temp += [ Simple_line(0,"call irp_print_timer()",line.filename) ]
temp += [ Simple_line(0," call irp_finalize_%s()"%(irp_id),line.filename) ]

View File

@ -470,6 +470,7 @@ class Variable(object):
"!$ print *, irp_here//': Error: Provider in an openMP section'" ,
"!$ stop 1",
"!$ endif" ]
result = []
return result
def build_alloc(name):

View File

@ -69,26 +69,15 @@ def call_provides(vars,opt=False):
vars = filter(lambda x: x not in all_children,vars)
def fun(x):
result = []
if command_line.do_openmp:
result += [ "!$OMP TASK" ]
result += [ \
" if (.not.%s_is_built) then"%(x) ]
result += [ \
" call provide_%s"%(x) ]
result += [ \
" endif" ]
if command_line.do_openmp:
result += [ "!$OMP END TASK" ]
return result
result = flatten ( map (fun, vars) )
if command_line.do_openmp and result != []:
result.reverse()
result.remove("!$OMP TASK")
result.remove("!$OMP END TASK")
result.reverse()
if "!$OMP TASK" in result:
result += [ "!$OMP TASKWAIT" ]
return result
######################################################################

View File

@ -1 +1 @@
version = "1.3.6"
version = "1.4.1"