Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement :func ABI for calling GPUCompiler emitted code #71

Closed
wants to merge 1 commit into from

Conversation

topolarity
Copy link
Member

This ABI is always ccallable, unlike the :specfunc ABI which frequently is not.

However, this ABI comes with a trade-off of introducing allocations (almost) always for function entry/exit. For that reason, we should re-enable the :specfunc ABI as soon as we can on as many types as possible.

Resolves #70

This ABI is always ccallable, unlike the `:specfunc` ABI which
frequently is not. In the future, it would be good to selectively
re-enable the `:specfunc` ABI for types that are safely ccallable.

The `:specfunc` ABI is interesting to us not just because it's fast.
It allows us to frequently avoid allocations for passing arguments /
return values, unlike the `:func` ABI which (almost) always allocates.
else
argsv = Any[args...]
GC.@preserve argsv begin
return ccall(f.f_ptr, Any, (Any, Ptr{Any}, UInt32), f.func, pointer(argsv), length(args))
Copy link
Member Author

Choose a reason for hiding this comment

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

@gbaraldi please double-check my ccall/ABI-foo here

# compile the function
cache = compiler_cache
source = GPUCompiler.methodinstance(F, tt)
rt = Core.Compiler.return_type(f, tt)

specsig = false # TODO: selectively re-enable after reviewing `uses_specsig` in codegen.cpp
Copy link
Member Author

Choose a reason for hiding this comment

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

Here is where we should scan the types and see if there is anything that we cannot correctly translate for specsig.

That might be just checking for Union/UnionAll? I need to stare at codegen for a while before I'm convinced, though.

@topolarity topolarity force-pushed the ct/invoke-api branch 2 times, most recently from 1a4a72e to 7ed4ef8 Compare February 1, 2024 02:30
@topolarity topolarity mentioned this pull request Feb 1, 2024
@gbaraldi
Copy link
Member

gbaraldi commented Feb 7, 2024

LGTM

@topolarity
Copy link
Member Author

Superseded by #82 and #85

@topolarity topolarity closed this Oct 8, 2024
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.

Bug: ccall method definition: return type doesn't correspond to a C type
2 participants