From 147e3a315adade9c52c783a7ea1eed06d54859ac Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 8 Oct 2014 16:24:01 +0200 Subject: [PATCH] OpenMP flag has to be set for openmp programs --- src/command_line.py | 12 ++++++++++-- src/irpf90.py | 4 ++++ src/makefile.py | 2 +- src/module.py | 1 + src/preprocessed_text.py | 6 ------ src/variable.py | 1 + src/variables.py | 11 ----------- src/version.py | 2 +- 8 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/command_line.py b/src/command_line.py index 7c681e7..1581b8b 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -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 diff --git a/src/irpf90.py b/src/irpf90.py index eaed0e9..1b9fd65 100644 --- a/src/irpf90.py +++ b/src/irpf90.py @@ -106,6 +106,10 @@ def main(): import profile profile.run() + if command_line.do_openmp: + import locks + locks.create() + if __name__ == '__main__': main() diff --git a/src/makefile.py b/src/makefile.py index ea17300..2a7c016 100644 --- a/src/makefile.py +++ b/src/makefile.py @@ -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, "" diff --git a/src/module.py b/src/module.py index 2f38de9..3d648aa 100644 --- a/src/module.py +++ b/src/module.py @@ -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) diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index eabe855..e58a8f5 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -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) ] diff --git a/src/variable.py b/src/variable.py index d678727..19c2076 100644 --- a/src/variable.py +++ b/src/variable.py @@ -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): diff --git a/src/variables.py b/src/variables.py index c86c844..6029c84 100644 --- a/src/variables.py +++ b/src/variables.py @@ -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 ###################################################################### diff --git a/src/version.py b/src/version.py index 9c0c0ee..6abaa20 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -version = "1.3.6" +version = "1.4.1"