Skip to content
This repository was archived by the owner on May 27, 2021. It is now read-only.

Avoid address space casts. #642

Merged
merged 2 commits into from
May 5, 2020
Merged

Avoid address space casts. #642

merged 2 commits into from
May 5, 2020

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented May 5, 2020

This PR changes how we work with and store address-space pointers: instead of casting them to and from generic pointers, directly work with their in-address space representation. That means we don't have to addrspacecast anymore, just inttoptr ... addrspace(...)* directly.

For WMMA, this requires 1.5's Base.AddrSpacePtr, because otherwise we select intrinsics for the generic case which leads to illegal memory accesses (cc @thomasfaingnaert).

Fixes #641.

@thomasfaingnaert
Copy link
Member

Will this completely eliminate all addrspacecasts in kernels? LLVM doesn't seem to handle them too well. In particular, I've noticed issues with the LSV and SeparateConstOffsetFromGEP passes.

For vectorisation in #629, I use the CUDA C++ approach of casting to float4* before loading/storing, which I'm not a big fan of. I suspect that, with this change, I can just call unsafe_load and unsafe_store! directly, so long as I use the correct alignment. The LSV pass will then handle the rest.

(Also, since AddrSpacePtr was backported to 1.4.1, the WMMA tests should still pass for non-debug 1.4.1 I believe, so 1.5 is too strict a requirement)

@maleadt maleadt force-pushed the tb/rm_addrspacecast branch from 8a9bf2e to b2cc3e1 Compare May 5, 2020 12:40
@maleadt maleadt force-pushed the tb/rm_addrspacecast branch from b2cc3e1 to b5cce68 Compare May 5, 2020 13:07
@maleadt
Copy link
Member Author

maleadt commented May 5, 2020

Will this completely eliminate all addrspacecasts in kernels?

It should, yes.

(Also, since AddrSpacePtr was backported to 1.4.1, the WMMA tests should still pass for non-debug 1.4.1 I believe, so 1.5 is too strict a requirement)

Ah yes, good call, it's only the return value that's problematic on 1.4.

@maleadt maleadt merged commit b480342 into master May 5, 2020
@bors bors bot deleted the tb/rm_addrspacecast branch May 5, 2020 14:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Atomic operations on shared memory
2 participants