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

Handle exceptions from throw_... #241

Merged
merged 26 commits into from
Aug 30, 2018
Merged

Handle exceptions from throw_... #241

merged 26 commits into from
Aug 30, 2018

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Aug 29, 2018

Apparently LLVM managed to optimize many throws away, which breaks now that we don't inline everything anymore. Let's try to work around some.

@maleadt
Copy link
Member Author

maleadt commented Aug 30, 2018

So this has been pretty painful. ptxas is really buggy, as it turns out.

@maleadt
Copy link
Member Author

maleadt commented Aug 30, 2018

This passes CuArrays tests again. Summarized:we now have a couple of LLVM passes that rewrite IR to make it GPU compatible:

  • replace throw_XXX functions (relies on the name, to be replaced with overdubbing of Core.throw)
julia> kernel(x) = x[2] = 1
kernel (generic function with 1 method)

julia> @cuda kernel(CuArray{Int}(1)); CUDAdrv.synchronize()
ERROR: a boundserror exception occurred

@maleadt maleadt changed the title Handle throw Handle exceptions from throw_... Aug 30, 2018
@vchuravy
Copy link
Member

This reminds me of twice_return in Julia codegen which needs special handling as well (I recall there being at least two instances).

c.f. JuliaLang/julia@6a1cc96

@maleadt
Copy link
Member Author

maleadt commented Aug 30, 2018

Similar indeed. A proper fix seems tricky though, because then you'd need LLVM to reason about the thread mask and only return when all threads are active (assuming this issue is related due to exiting from a function during divergence... but shmem seems related too). It looks like CuArrays mapreduce triggers this quite easily though, so let's hope that helps us spot any changes in upstream irgen (ie. patterns in Julia-generated IR that generate a CFG ptxas doesn't like) before running into this again.

@maleadt maleadt merged commit b477dfc into master Aug 30, 2018
@maleadt maleadt deleted the tb/boundscheck branch August 30, 2018 17:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants