Closed gbaraldi closed 2 years ago
This looks awesome!
Ideally this would receive a module and compile the methods defined in the module, but I still have to figure out how to do that.
All methods in a module? How would you determine function-argument pairs, and name mangling if there are multiple arguments for the same function?
@chriselrod The perfect API in my mind would be something like
module SquareLib
@noinline square(n::Float64) = n*n
function squaresquare(n::Float64)
square(square(n))
end
function squaresquaresquare(n::Float64)
square(squaresquare(n))
end
end
compile_shlib(SquareLib)
So all methods have to have concrete types as arguments, have different names etc. The issue is I don't know how I would do that. Maybe instead of a module I would use a macro and a scope or something. I am taking suggestions ;)
C++ has extern "C" { }
for this.
What about just looking for all Base.@ccallable
functions?
Hmm, looks like there's maybe an issue with the name (de?)mangling in the test? You can ignore "integration nightly" though
Looking for the ccallable functions is an option, I'm not sure how I would do that since I think it only changes a bit in the MethodInstance
but I only need the MethodInstance
anyway
Tests look good now! LGTM but I'll defer to Mason
Yeah, this looks good @gbaraldi. Do you have any interest in trying to make the compile
interface also work with this? No problem if not
@MasonProtter I will take a look tomorrow, since you call into generate_obj
it's just a question of adding a function and some way to serialize multiple compiled functions.
Still thinking about the compile
interface, or want to merge this without and think about that later?
I'm about to disappear for fieldwork, so no rush on my end but I probably won't be able to be very responsive for a bit after tomorrow
Okay, let’s just merge this and deal with compile
in a later PR
Option to compile a shared lib with multiple functions. The API receives a vector of tuples that look like
Tuple{func,Tuple{args}
. Ideally this would receive a module and compile the methods defined in the module, but I still have to figure out how to do that.