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

More advanced Rust binding examples #1621

Open
eliasboegel opened this issue Jun 27, 2024 · 8 comments
Open

More advanced Rust binding examples #1621

eliasboegel opened this issue Jun 27, 2024 · 8 comments
Labels

Comments

@eliasboegel
Copy link

Hi,

I'm wondering whether there are any more advanced examples or, even better, research codes using the Rust bindings outside of the libceed repository that go into more depth than just a mass or stiffness matrix. I'm especially looking for some example codes that use the libceed bindings, as well as petsc-rs (and possibly rsmpi) bindings, just showing how the different binding APIs of libceed and petsc-rs interact. Does anything like this exist?

Thanks!

@jeremylt
Copy link
Member

Such examples don't exist currently. I do want to make some but it hasn't bubbled to the top of my list yet

@eliasboegel
Copy link
Author

On a related note:
Is there an overview of the limitations of using the Rust bindings to libceed anywhere? I remember Jed mentioning that device acceleration is unavailable with the Rust binding in a Rust talk (due to lack of kernel fusion?), but I couldn't actually find anything mentioning this in the docs. Is that still a limitation, and are there any others?

@jeremylt
Copy link
Member

That's correct, at this time only QFunctions written in C can be used via the Rust interface on the device (QFunctions created from the 'gallery'). QFunction source written in Rust can only be run by the CPU backends. The Julia wrapper can compile user QFunction code for CUDA backends but we haven't figured out something similar for Rust yet.

@eliasboegel
Copy link
Author

Thanks - do I then understand correctly that it is possible to get full device acceleration with the Rust bindings if the QFunction is written in C, with everything else using the bindings? What would be the correct way to do this?

I have similar questions about the practical limitations of the PETSc bindings, but those are probably better kept in a petsc-rs issue.

@jeremylt
Copy link
Member

So currently we don't have the ability to make a new QFunction in C from the Rust interface and pass it to the GPU backends, but that should be relatively straightforward to set up if you would like that.

Only the current QFunctions available here can be used on the GPU from Rust:

https://github.com/CEED/libCEED/tree/main/gallery

https://docs.rs/libceed/latest/libceed/qfunction/struct.QFunctionByName.html

Wrapping a libCEED operator in a MatShell in Rust is probably the other missing piece you need. I don't have an example of that due to getting lost with lifelines being tangled

@eliasboegel
Copy link
Author

No worries. Thank you for all the information provided so far!

@jeremylt
Copy link
Member

It's incomplete but here's as far as I got with using the two Rust wrappers together

https://github.com/jeremylt/meles-rs

@jeremylt
Copy link
Member

jeremylt commented Jul 1, 2024

Note to me - merging MatCEED upstream will help with those timelines I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants