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

Fix error message for missing allocation for base_storage #858

Closed
kaushikcfd opened this issue Jul 22, 2024 · 3 comments
Closed

Fix error message for missing allocation for base_storage #858

kaushikcfd opened this issue Jul 22, 2024 · 3 comments

Comments

@kaushikcfd
Copy link
Collaborator

Hi!

I have the following code snippet which would generate sound code in earlier versions, but does not anymore:

import loopy as lp
import numpy as np


t_unit = lp.make_kernel(
    "{[i, j1,j2]: 0<=i<n and 0<=j1,j2<5}",
    """
    for i
        for j1
            <> tmp1[j1] = x1[i, j1]
            out1[i, j1] = tmp1[j1]
        end
        ... lbarrier
        for j2
            <> tmp2[j2] = x2[i, j2]
            out2[i, j2] = tmp2[j2]
        end
    end
    """,
    [lp.GlobalArg("x1,x2,out1,out2",
                  shape=lp.auto,
                  dtype=np.float64),
     ...],
    seq_dependencies=True,
)

knl = t_unit.default_entrypoint
new_tvs = {name: tv.copy(base_storage="my_base",
                         address_space=lp.AddressSpace.LOCAL)
           for name, tv in knl.temporary_variables.items()}
knl = knl.copy(temporary_variables=new_tvs)
t_unit = t_unit.with_kernel(knl)
print(lp.generate_code_v2(t_unit).device_code())

This raises with the following exception:

  File "/home/kgk2/projects/firedrake_gpu/src/loopy/loopy/check.py", line 1315, in check_for_nested_base_storage
    raise ValueError("nothing known about storage array "
ValueError: nothing known about storage array 'my_base' serving as base_storage of 'tmp1'
@inducer
Copy link
Owner

inducer commented Jul 22, 2024

You need to call allocate_temporaries_for_base_storage (or allocate it yourself). Implicit allocation had been deprecated a while.

@inducer
Copy link
Owner

inducer commented Jul 22, 2024

But the error message is definitely unhelpful, we should fix that. I'll leave this issue open as a reminder to do that.

@inducer inducer changed the title Using base_storage for temporary_variables no longer works? Fix error message for missing allocation for base_storage Jul 22, 2024
@kaushikcfd
Copy link
Collaborator Author

call allocate_temporaries_for_base_storage

Thanks, that was it!

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

2 participants