Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] copperhead/compiler/rewrites.py seems not to handle nested argument lists #13

Open
asterbini opened this issue Nov 19, 2013 · 0 comments

Comments

@asterbini
Copy link

Hi

trying the samples/of_cg.py demo I have noticed that the rewriter is not able to correctly associate nested argument names to variables

The culprit seems to be lines 724-725 of file copperhead/compiler/rewrites.py

    for (internal, external) in zip(functionArguments, instantiatedArguments):
         env[internal.id] = external

which expect the argument list to be a flat list, while in of_gc.py there are 2 functions using nested argument lists

def of_spmv((du, dv), width, (m1, m2, m3, m4, m5, m6, m7)):
     <body>
def precondition(u, v, (p1, p2, p3)):
     <body>

By rewriting the initial part of the functions as follow all works fine

def precondition(u, v, p1_p3):
    (p1, p2, p3) = p1_p3       
    <body>

def of_spmv(du_dv, width, m1_m7):
    (du, dv) = du_dv                            
    (m1, m2, m3, m4, m5, m6, m7) = m1_m7        
    <body>

[FIX]: I think I fixed the problem by moving the name_tuples step before the inline one in copperhead/compiler/passes.py

diff --git a/copperhead/compiler/passes.py b/copperhead/compiler/passes.py
index 6d5fa29..672e5bd 100644
--- a/copperhead/compiler/passes.py
+++ b/copperhead/compiler/passes.py
@@ -243,6 +243,7 @@ frontend = Pipeline('frontend', [gather_source,
                                  procedure_flatten,
                                  expression_flatten,
                                  syntax_check,
+                                 name_tuples,  # FIX: moved here to avoid inline errors with nested argument lists
                                  inline,
                                  cast_literals,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant