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

[RFC] Address space preserving bitcasts #9423

Closed

Conversation

vchuravy
Copy link
Sponsor Member

@maleadt worked towards supporting the CUDA/PTX backend in llvm in Julia. He presented his work in https://groups.google.com/forum/#!topic/julia-dev/doQUqQabC8A, because he will not be able to spend much time on it in the coming months.

I personally would like to see support for this in Julia and planned to work on something similar for the OpenCL/SPIR backend in llvm.

In order to integrate @maleadt work with upstream Julia I plan to submit PRs for separated concerns so that they can be properly discussed.

First up is address space preserving bitcasts.

@maleadt do you have time to explain shortly the rational behind this?

Cherry-picked from:
6c4fbcc and 855bb43

@maleadt
Copy link
Member

maleadt commented Dec 20, 2014

In PTX land pointers live in different address spaces, depending on the type of memory you want to address. This is quote important, because the behaviour of each address space is vastly different (for example, thread-shared memory).

Julia does not care about address spaces, and makes everything live in the default one (0). Worse, the global pointer type objects (jl_pvalue_llvmt etc) are defined as living in addrspace 0. These objects are used when bitcasting jl_value_ts, regardless of the address space of those values. In older LLVM versions (pre 3.5, IIRC) this was silently ignored. Recent versions however croak when the address spaces within a bitcast don't match.

The preserving_bitcast function makes sure that, when casting pointer values, the address space is preserved by first casting the type object to the address space of the value, and then bitcasting the value with the proper type.

Note that this still lacks support for setting the address space of pointers from within Julia, which is a requirement to make this functionality useful. I was thinking of parameterizing the Ptr type to include the address space, but didn't get too far.

@Keno
Copy link
Member

Keno commented Jun 1, 2015

LGTM after rebase.

@vchuravy vchuravy force-pushed the maleadt_preserving_bitcast branch from 9c10f3a to bd6717f Compare June 1, 2015 02:34
@vchuravy
Copy link
Sponsor Member Author

vchuravy commented Jun 1, 2015

rebased

@vchuravy
Copy link
Sponsor Member Author

Superseded by #17193

@vchuravy vchuravy closed this Jun 29, 2016
@vchuravy vchuravy deleted the maleadt_preserving_bitcast branch June 29, 2016 15:30
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

Successfully merging this pull request may close these issues.

None yet

3 participants