-
Notifications
You must be signed in to change notification settings - Fork 158
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
chore(gpu): pass over all cuda bind #1514
Conversation
f46be60
to
48cd4a7
Compare
48cd4a7
to
5a7e8ab
Compare
@@ -3,104 +3,58 @@ use std::ffi::c_void; | |||
#[link(name = "tfhe_cuda_backend", kind = "static")] | |||
extern "C" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"stupid" question are we sure the C ABI is respected when the CUDA backend is compiled ? in the sense that C++ does not exactly have the C ABI and I don't know how both relate 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(related to the potential launch failure stuff)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm not totally sure no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way you make sure in the C++ code base that you expose the C function as extern "C"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be alright, as all the entry points in the binding are actually "C compatible". Nothing C++-like is passed through the interface, only raw pointer types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while I agree, I would not be against the "ceinture et bretelles" approach here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we define all functions that go through the interface with "extern C" in the header files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so then we are good on the ABI declaration, nothing else to do on the C++ side, just need to make sure definitions agree, do you want someone to double check function by function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be very troublesome and not so efficient: I already went through it thoroughly yesterday. But really at some point we should spend some time to figure out how to generate this API automatically, at least part of it.
@@ -8,7 +8,7 @@ extern std::mutex m; | |||
extern bool p2p_enabled; | |||
|
|||
extern "C" { | |||
int cuda_setup_multi_gpu(); | |||
int32_t cuda_setup_multi_gpu(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For curiosity, why do we want to have int32_t
instead of int
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure with the types on any architecture, I prefer to always specify the size of the integer (as we do on the Rust side as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just moving functions and removing unnecessary comments in the binding file helps a lot.
closes:
PR content/description
I rewrote all the binding to be sure it's consistent with the c++ headers.
Check-list: