juntyr / rust-cuda

https://juntyr.github.io/rust-cuda/
Apache License 2.0
5 stars 1 forks source link

Add usage for single-source example #21

Open JordanLloydHall opened 4 days ago

JordanLloydHall commented 4 days ago

I really love the work you're doing here, and want to use it in my own personal project! However I'm currently getting to grips with the usage of this crate, and I'm struggling to get single-source to do anything once it's built. Would it be possible to have more examples to work off of, or have this example come with a bin target?

Many thanks for your work! And I would be happy to take a look at creating more examples once I've wrapped my head around it!

juntyr commented 4 days ago

Thank you for your interest in my crate!

The print example is currently the only one that is fully executable.

I initially developed rust-cuda for necsim-rust, a neutral ecology model. It shows the full in-action usage of this crate:

If your kernel linking is ever so slightly complex, I'd recommend to also make the three-crate split (single-source kernel, linking, host) to improve compile times (since otherwise any change in the host code recompiles all kernel variants as well).

The important things to make sure everything runs, is to have the required CUDA libraries and the "llvm-bitcode-linker" and "llvm-tools" rust components installed, and to put the https://github.com/juntyr/rust-cuda/blob/main/examples/print/.cargo/config.toml file in the crate that contains your kernel.

I hope this helps a bit :) I could also have a look at your code to help you integrate rust-cuda if you'd like.