How to combine @generated and @inline?

314 views
Skip to first unread message

Erik Schnetter

unread,
Jan 20, 2016, 2:27:14 PM1/20/16
to julia...@googlegroups.com
I have a generated function that generates a very small function
(essentially a vector load instruction). Unfortunately, this function
is not inlined, and I thus want to mark the generated function as
@inline. How do I do so?

Writing either "@inline @generated" or "@generated @inline" both fail.

-erik

--
Erik Schnetter <schn...@gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

Matt Bauman

unread,
Jan 20, 2016, 2:35:28 PM1/20/16
to julia-users
You need to manually attach the inline annotation within the function body that gets generated.  See, e.g., https://github.com/JuliaLang/julia/blob/275c7e8929dd391960ba88e741c6f537ccca6cc9/base/multidimensional.jl#L233-L236

Stefan Karpinski

unread,
Jan 20, 2016, 2:39:23 PM1/20/16
to Julia Users
This seems like a viable feature request if you want to open an issue – i.e. @inline @generated or @generated @inline should arrange that the resulting function body be annotated appropriately.

Matt Bauman

unread,
Jan 20, 2016, 2:50:55 PM1/20/16
to julia-users
Yeah, I was thinking about that as I responded.  An easier intermediate solution (which could be implemented purely in the Julia macro) would be to support `@inline quote … end`.  Either way, the semantics are a little strange — you're not inlining the quote block, nor are you inlining the function generator itself.

Jeffrey Sarnoff

unread,
Jan 20, 2016, 9:55:16 PM1/20/16
to julia-users
I'd prefer @inline @generated
because @generated @inline seems to say "generate this function inline" (not "inline the function generated")

Erik Schnetter

unread,
Jan 21, 2016, 9:26:28 AM1/21/16
to julia...@googlegroups.com
Thanks for the pointer! `meta(:inline)` is easy enough to generate.

-erik
Reply all
Reply to author
Forward
0 new messages