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

Kernel-local regions #63

Open
eholk opened this issue Nov 6, 2012 · 2 comments
Open

Kernel-local regions #63

eholk opened this issue Nov 6, 2012 · 2 comments

Comments

@eholk
Copy link
Owner

eholk commented Nov 6, 2012

We should add a special region inside of kernels that lives in local (or shared) memory. Kernels could use this to allocate data that isn't actually returned from the kernel.

@eholk
Copy link
Owner Author

eholk commented Jan 13, 2015

8694bc2 adds a hack that lets this work as long as you don't touch the region.

We'll want a proper fix soon, since function calls from kernels makes it a lot easier to get into this situation.

Fixing this is related to fixing #114 as well.

@eholk
Copy link
Owner Author

eholk commented Jan 13, 2015

Here are some comments from that most recent commit about how I fixed it and what better solutions are.

+/*
+  FIXME: The next next bit is an awful hack for when kernel-local
+  regions leak into the compiled program. This tends to happen when
+  making lots of function calls from the kernel. Here we just use a
+  NULL pointer as the region, which works as long as we never touch
+  the region (for example, lambdas always have a region but it's often
+  not used).
+
+  Commented out below is an attempt I had to declare a tiny region on
+  the stack. Unfortunately, OpenCL makes a distinction between local
+  and global pointers, so we'd need versions of the function that work
+  on different pointer types. This will take some pretty invasive
+  changes to the type inferencer and the rest of the compiler, since
+  we'll have a notion of local and global regions.
+
+  Another option is to early on identify which functions are called by
+  kernels and generate two versions. The kernel version would not
+  allocate any regions, and instead rely on the callers to supply
+  them. This again complicates the type system and will require help
+  from the type inferencer.
+
+  Finally, we could modify the compiler (such as in
+  fix-kernel-local-regions) to just find a nearby region and use that
+  instead. It's a hack, but it is a fairly local change and I don't
+  think it introduces any unsoundness, unlike the way things are
+  currently.
+
+  I'll open an issue to keep track of this.
+
+*/

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