-
-
Notifications
You must be signed in to change notification settings - Fork 63
Description
First up, thanks for this great project, we've been using it successfully for quite a while now!
I'd like to add support for cross compilation for Jetson/aarch64 using redist.json as a source. I have hacked already a bit and have a version that can at least compile examples/basic. The libraries still need some work, but before I put that in, I'd like to hear if there are already thoughts on how to accomplish that. I guess I could finish my version and it'd be fine for my needs, but ideally I'd like to contribute a PR so that others benefit from this as well.
Here's a rough outline of what I did:
- Extend
redist_json_helperso that it does not filter forx86_64, but also includesaarch64. I then added a fieldarchto the struct that gets appended tospecsfor each component. - Then in
_redist_json_implincuda/extensions.bzl, I modify the specs list a bit so that for each component I have an entry where there are dictsurls,shas256, andstrip_prefixesthat each have two keys,x86_64andaarch64. - The result gets fed into a new repository rule
cuda_multi_platform_componentwhich iterates over the keys, effectively callingdownload_and_extracttwice. - Finally, the templates needed a bit of work to have targets for each architecture that are used by a top-level target (such as
cuda_runtime), which has a bunch of selects, very similar to what is currently present to support both Windows and Linux.
As I said, this seems to be working, however, I'm not certain which usecases I broke along the way. Also, some cleanup and refactoring would be necessary to avoid redundancy.
One thing that complicates things a bit is that for most things I need the target architecture archive, but nvcc I need for the host. Just like clang, you only need to care about the host architecture here. In the repository rule I extract archives into x86_64 and aarch64 subdirectories. For nvcc I added some special handling, there I also create some symlinks to the directories in x86_64, so that all files are available where current main expects them.
Another thing I thought about was having subdirectories only in lib, but then I'd have to modify the original archive structure, which is something I'd like to avoid.
Initially I also thought about having a repository per architecture, but then I'd need a new place for the select. Ultimately, I want to be able to depend on @cuda//:cublas in my top-level target and it picks the correct libraries automatically depending on the architecture I'm building for.
I only need support for Linux x86_64 as the host and x86_64 and aarch64 as targets. However, AFAIU, support for a Linux aarch64 host would be possible with the redist.json archives, but would complicate the work required for rules_cuda even further.
If the overall approach outlined above sounds reasonable, I would suggest to start with the Linux x86_64 -> aarch64 support without breaking existing Linux x86_64 -> Linux x86_64 and Windows -> Windows support.
Another thing; I only care about bzlmod. Not sure how much of a priority new features for workspace are here.
Anyway, let me know what you think! Thanks!