Skip to content

Conversation

rafaqz
Copy link
Contributor

@rafaqz rafaqz commented Sep 6, 2018

Needed to work with GPUArrays. See: JuliaGPU/GPUArrays.jl#157

@rafaqz rafaqz closed this Sep 6, 2018
@rafaqz rafaqz reopened this Sep 6, 2018
src/SMatrix.jl Outdated

function getindex(v::SMatrix, i::Int)
Base.@propagate_inbounds function getindex(v::SMatrix, i::Int)
Base.@_inline_meta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@propagate_inbounds implies that the function is inlined AFAIK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah is that true? so you dont need the inline meta?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  @propagate_inbounds

  Tells the compiler to inline a function while retaining the caller's
  inbounds context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, guilty! never read the docs!

Copy link
Contributor Author

@rafaqz rafaqz Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base is full of @inline @propagate_inbounds so maybe you're not the only one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thats were i got it from ;)

@andyferris
Copy link
Member

Thanks!

Can we do this properly for all the array types?

@rafaqz
Copy link
Contributor Author

rafaqz commented Sep 7, 2018

I'm not sure the inlining comments were meant as no-go for @propagate_inbounds or not?

SMatrix is especially useful on the GPU, it's the only type of matrix you can use as a struct field. But I can update this for everything else too if that's a good idea.

@tkoolen
Copy link
Contributor

tkoolen commented Sep 7, 2018

I'm not sure the inlining comments were meant as no-go for @propagate_inbounds or not?

Nope, just wanted to point out redundant code.

@andyferris
Copy link
Member

As in: keep the propagate inbounds, ditch the inline.

@andyferris
Copy link
Member

My point was partly that SMatrix is only one type of SArray (does the same problem occur for SVector? Or 3D arrays?)

@rafaqz
Copy link
Contributor Author

rafaqz commented Sep 8, 2018

Ok duh I missed the Base.@_inline_meta

I'll test all types of SArray and FieldVector and update.

@rafaqz
Copy link
Contributor Author

rafaqz commented Sep 8, 2018

SArrays needed @propagate_inbounds to work, SVector already has it and also works. Scalars work without it because of constant propagation.

FieldVectors also have @propagate_inbounds already. But they don't work on GPUs for some other reason I don't understand, even when the underlying type is immutable.

Is there anything else relevant to the (immutable) GPU context?

@rafaqz
Copy link
Contributor Author

rafaqz commented Sep 8, 2018

Also I haven't added any tests for this because of the need for a GPU.

Is it possible to test GPUArrays integration with JLArray? @SimonDanisch ?

@SimonDanisch
Copy link
Member

I mean, all of this isn't GPU specific! You will want to have inbounds propagating in all performance sensitive code. Not sure how to test this. A hacky way would be to search for the throw in the IR :P

@rafaqz
Copy link
Contributor Author

rafaqz commented Sep 8, 2018

Not sure I can manage that kind of hack! And sure its useful for other things as well, but it doesn't break them entirely without it! I just meant having some test to ensure
these types continued to actually work on the GPU.

@andyferris andyferris merged commit ade1b55 into JuliaArrays:master Sep 12, 2018
@c42f c42f mentioned this pull request Oct 22, 2018
2 tasks
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.

5 participants