From 11df03bea816f02916b04ffe37ad80ea4dcade2a Mon Sep 17 00:00:00 2001 From: Cory Mikida Date: Tue, 9 May 2017 11:45:37 -0500 Subject: [PATCH 1/4] Pull bounds out of encompassing structures before entering loop --- dagrt/codegen/fortran.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 7a7875a..176c628 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -47,7 +47,6 @@ def pad_fortran(line, width): line += '&' return line - wrap_line = partial(wrap_line_base, pad_func=pad_fortran) @@ -511,15 +510,20 @@ class _ArrayLoopManager(object): code_generator.name_manager.make_unique_fortran_name(iname) for iname in array_type.index_vars] + self.f_dim_names = [ + code_generator.name_manager.make_unique_fortran_name(iname[-6:]) + for iname in array_type.dimension] + def enter(self, index_expr_map, allow_parallel_do): atype = self.array_type cg = self.code_generator self.emitters = [] - for iloop, (dim, index_name) in enumerate( - reversed(list(zip(atype.dimension, self.f_index_names)))): + for iloop, (dim, index_name, dim_name) in enumerate( + reversed(list(zip(atype.dimension, self.f_index_names, self.f_dim_names)))): cg.declaration_emitter('integer %s' % index_name) + cg.declaration_emitter('integer %s' % dim_name) pdp = None if allow_parallel_do and iloop + 1 == len(atype.dimension): @@ -527,11 +531,17 @@ class _ArrayLoopManager(object): start, stop = atype.parse_dimension(dim) + self.code_generator.emit( + "{name} = {expr}" + .format( + name=dim_name, + expr=_replace_indices(index_expr_map, stop))) + em = FortranDoEmitter( cg.emitter, index_name, "%s, %s" % ( _replace_indices(index_expr_map, start), - _replace_indices(index_expr_map, stop)), + _replace_indices(index_expr_map, dim_name)), cg, parallel_do_preamble=pdp) self.emitters.append(em) -- GitLab From 6226abaa93c753cea189ef02552916201180187b Mon Sep 17 00:00:00 2001 From: Cory Mikida Date: Tue, 9 May 2017 11:50:06 -0500 Subject: [PATCH 2/4] Fixes Flake8 issue (whoops) --- dagrt/codegen/fortran.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 176c628..5a953de 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -47,6 +47,7 @@ def pad_fortran(line, width): line += '&' return line + wrap_line = partial(wrap_line_base, pad_func=pad_fortran) -- GitLab From d8ba13a3d707641d0cb7cb69a30c3d58017df4ce Mon Sep 17 00:00:00 2001 From: Cory Mikida Date: Tue, 9 May 2017 11:55:19 -0500 Subject: [PATCH 3/4] (Hopefully) fixes the last Flake8 issue --- dagrt/codegen/fortran.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 5a953de..743d38c 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -522,7 +522,8 @@ class _ArrayLoopManager(object): self.emitters = [] for iloop, (dim, index_name, dim_name) in enumerate( - reversed(list(zip(atype.dimension, self.f_index_names, self.f_dim_names)))): + reversed(list(zip(atype.dimension, self.f_index_names, + self.f_dim_names)))): cg.declaration_emitter('integer %s' % index_name) cg.declaration_emitter('integer %s' % dim_name) -- GitLab From 1df8ef9209548f541250ec3f9c22a35902197028 Mon Sep 17 00:00:00 2001 From: Cory Mikida Date: Tue, 9 May 2017 17:27:13 -0500 Subject: [PATCH 4/4] One more commit to pass flake8 tests --- dagrt/codegen/fortran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 743d38c..9c2397f 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -522,7 +522,7 @@ class _ArrayLoopManager(object): self.emitters = [] for iloop, (dim, index_name, dim_name) in enumerate( - reversed(list(zip(atype.dimension, self.f_index_names, + reversed(list(zip(atype.dimension, self.f_index_names, self.f_dim_names)))): cg.declaration_emitter('integer %s' % index_name) cg.declaration_emitter('integer %s' % dim_name) -- GitLab