255 Commits

Author SHA1 Message Date
Adam Basfop Cavendish
032361a177 chore(example): add nvvm library path to LD_LIBRARY_PATH and add back the add example in CI (#190)
When linking `libnvvm.so.4` into `librustc_codegen_nvvm.so` shared
library via the `cust_raw` package, we specified the following
parameters in the `build.rs`:

- cargo::rustc-link-search=native=xxx
- cargo::rustc-link-lib=dylib=nvvm

According to the [Cargo documentation](https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-search),
the path we added to the `rustc-link-search` parameter is not further
populated to the `LD_LIBRARY_PATH` for search by the transitive
dependencies.

> These paths are also added to the dynamic library search path
> environment variable if they are within the OUT_DIR.

The behavior is intended to be limited to the OUT_DIR so the
`libnvvm.so.4`, which lives as a part of the CUDA SDK, is excluded.
Therefore, we must add it to the LD_LIBRARY_PATH manually in our
container build stage.
2025-04-05 13:26:45 -07:00
Jorge Ortega
295459dcea refactor(cust_raw): Parse macro function renames in cuda headers. (#187)
Adds a custom bindgen callback that prevents function renames due to macro defines while still linking to the intend function after macro expansion. It does this by tracking macros when generating the bindings, so that it can change the name of the function back to what it was before the macro changed and link to the macro expanded function name. Doing so helps prevents breaking changes across CUDA versions when generating the bindings, and generates function bindings that match those used in Nvidia's CUDA documentation.

misc.: optix-sys rebuilds if related optix environment variables change.
misc.: unpin cc and jobserver from add example.
2025-04-04 10:37:47 -07:00
Adam Basfop Cavendish
9856aad6d3 feat(ci): Split Linux CI workflow and add container images pipeline (#188)
Added a new workflow, container_images.yml, to automate building and
pushing CI container images to GitHub Container Registry, ensuring
consistent environments for CI runs across Linux distributions.

Added a dedicated CI workflow for Linux to streamline testing across
multiple CUDA and OS configurations. It reuses the images built from
container_images.yml workflow to avoid installing CUDA toolkits every
time to save time.

Key changes:
- Matrix configurations for Ubuntu 22/24, RockyLinux 9 with CUDA 12.8.1
- Dockerfiles updated with required dependencies (clang, CUDA
  toolchains, etc.) to support bindgen and build examples.
- Removed redundant CI steps from `rust.yml` now handled in
  `ci_linux.yml`
2025-04-03 17:30:16 -07:00
Jorge Ortega
0f9bc16102 chore(ci) Use CUDA network installer and specify sub-packages. (#189)
The network installer is a smaller initial download, which will only
download the require packages to install. This should reduce the install
times on Windows CI.
2025-04-03 16:31:41 -07:00
Adam Basfop Cavendish
b85d9ca136 refactor(cust_raw): consolidate CUDA, cuDNN, OptiX bindgen and remove find_cuda_helper (#181)
1. Consolidation of bindgen related "*-sys" packages
  - Remove the common dependency of `find_cuda_helper`. Use the cargo
    metadata mechanism instead.
  - Merged all CUDA bindgen-generated code into the cust_raw crate for
    simplicity and maintainability.
  - Add CUDA Runtime API bindgen support.
2. cuDNN and OptiX Integration
  - Split cudnn into cudnn (high-level API) and cudnn-sys (low-level
    bindgens) for better abstraction.
  - Split optix into optix (high-level API) and optix-sys (low-level
    bindgens) for better abstraction.
3. CUDA 12+ Support
  - Updated cust to support CUDA versions >= 12.
  - Added compatibility for CUDA 12.3+ graph API changes:
    - Renamed cuGraphKernelNodeGetParams →
      cuGraphKernelNodeGetParams_v2.
    - Enabled conditional node support for CUDA >= 12.3.
4. Temporarily disable cuDNN in CI
    - Windows CI pipelines have no cuDNN support yet.

Co-authored-by: Jorge Ortega <jorge-ortega@outlook.com>
2025-04-02 16:57:40 -07:00
Adam Basfop Cavendish
7eb199cb9a chore(docker): add support for multiple Linux distributions and CUDA versions
The Docker setup has been refactored to support Ubuntu 20.04, 24.04, and
Rocky Linux 9 with CUDA 11/12. The original Dockerfile (Ubuntu 18.04 +
CUDA 11.4) has been replaced with a matrix of distribution-specific
Dockerfiles. Dependencies like LLVM 7 and Rust are now configured to
work across these environments.
2025-03-24 17:41:51 -04:00
Jorge Ortega
6d79a12dad Use bindgen::CargoCallback to rerun when included header files change. 2025-03-20 21:58:18 -04:00
Jorge Ortega
ac7765da4a Remove redundant cargo instructions.
`cc` already sets rustc-link-search and rustc-link-lib after compiling. Since other rerun-if-changed instructions are emitted, specifying build.rs is redudant.
2025-03-20 21:58:18 -04:00
Jorge Ortega
ed04a9d19f Rework optix_stubs.c
The stubs were a copy of optix_stubs.h, but without `inline` so they end up in the binary when compiling them. This change instead includes optix_stubs.h and uses the preprocessor to erase `inline` in the header.
2025-03-20 21:58:18 -04:00
Christian Legnitto
a21f4da628 Turn off local CUDA install cache 2025-03-19 15:09:47 -04:00
Jorge Ortega
2b33f4e47f path_tracer builds and runs on windows
- Addresses some review comments.
- Updates `sysinfo` in `path_tracer` to latest.
- Removes the copy of optix_wrapper.rs used for debugging.
2025-03-19 13:47:19 -04:00
trigpolynom
210af5d38c fixing path_tracer and build works for linux 2025-03-19 13:47:19 -04:00
Christian Legnitto
1a663aadc3 Add CUDA 12 to CI (#168) 2025-03-17 22:19:32 -04:00
Alex Eisenschmied
792056ccc6 Mark functions in float_ext.rs as gpu_only (#169)
* Mark functions in float_ext.rs as gpu_only

Different behavior between linux and windows linkers causes windows CI to fail when compiliing crates that need cuda_std.

https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2019?view=msvc-170#you-call-intrinsic-functions-or-pass-argument-types-to-intrinsic-functions-that-arent-supported-on-your-target-architecture

This link contains the exact reason for the error message. Compiling float_ext for an architecture other than nvptx caused the linker to fail with LNK2019, for the reason linked.
2025-03-17 20:20:18 -04:00
Christian Legnitto
42afe4b62b Add experimental 12 sdk support to guide (#167) 2025-03-17 17:04:15 -04:00
Alex Eisenschmied
400f816f38 Small Compatibility Fix for CUDA 12.8. (#165)
The latest version of CUDA ships libnvvm with version 2.0, which fails the check for an appropriate version number. This commit fixes this so that 2.0 correctly passes the minimum version number check.
2025-03-17 16:45:52 -04:00
Jorge Ortega
1083480841 Fix optix examples (#160)
* Remove missing and unused symbols when compiling cuda.

See this [issue](https://github.com/ingowald/optix7course/issues/35), from what I think is the source repo for this header.
2025-03-15 21:40:24 -04:00
Christian Legnitto
9b07099e37 Output CUDA files in workflow (#161)
This will help debug.
2025-03-15 15:15:47 -04:00
Jorge Ortega
4bd1ad664c Fix: use core::arch::asm when building cuda target 2025-03-13 22:17:37 -04:00
Jorge Ortega
1697114c7e optix: Fix bitflags derive macros for optix enums/flags.
Updated `bitflags` has a few breaking changes:
- it no longer adds traits like `Clone`, `Copy`, etc.. Add those explicitly.
- An internal wrapper over the underlying flag type is used that isn't `DeviceCopy`. Define the struct wrapping the underlying type explictly, and use `bitflags!` to define the impl.
2025-03-13 22:17:37 -04:00
Jorge Ortega
8fea329604 denoiser example: Replace image::io::Reader with image::ImageReader 2025-03-13 22:17:37 -04:00
Christian Legnitto
a494bbb64f Fix formatting (#158) 2025-03-13 14:49:14 -04:00
Chris Jones
85fe41efec Remove unnecessary Default bound from DeviceSlice::as_host_vec. (#68)
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2025-03-13 14:45:41 -04:00
beepster
3d80022295 Make DeviceSlice a newtype around [()] (#44)
Co-authored-by: DrMeepster <19316085+DrMeepster@users.noreply.github.com>
Co-authored-by: Christian Legnitto <LegNeato@users.noreply.github.com>
2025-03-13 14:31:18 -04:00
Chris Jones
388031325b Remove unnecessary Default constraint on DeviceBox::as_host_value. (#67) 2025-03-13 14:23:29 -04:00
Christian Legnitto
e8ddcf592b Fix some compilation errors, warnings, and clippy issues (#156) 2025-03-13 14:17:00 -04:00
Jorge Ortega
8fc34d5a76 Fix clippy errors in cuda_std 2025-03-13 10:45:20 -04:00
Jorge Ortega
896c21d70d Fix clippy error for ignored ?Sized bound 2025-03-13 10:45:20 -04:00
Jorge Ortega
48963ad0cd Run cargo fmt 2025-03-13 10:45:20 -04:00
Jorge Ortega
e079b57224 Fix nvvm_internal attribute usage. add example now compiles and runs!
`register_attr` was removed in favor of `register_tool`. This updates how the nvvm attributes are applied in our proc_macros and how the nvvm backend parses them. Also removes redundant applications of no_std, as cuda_builder applies it to all crates built on the cuda target via rustc flags.

The add example crate now compiles and runs the geneated ptx! :D
2025-03-13 10:45:20 -04:00
Jorge Ortega
99063d34bb Fix: Move must_used attributes to trait definitions instead of implementations. 2025-03-13 10:45:20 -04:00
Jorge Ortega
179b0ffb42 Pass the acutal intrinsic llfn type when overriding libm functions.
Previous change was just to get the backend to compile. This gets libm to compile now.
2025-03-13 10:45:20 -04:00
Jorge Ortega
9eedf24728 Update rust-toolchain to nightly-2025-03-02.
Nvvm codegen compiles with latest nightly, and is able to codegen `core` and other essential crates. `libm` causes ICE and is next on the list to fix.
2025-03-13 10:45:20 -04:00
Jorge Ortega
25b3fddad7 Run cargo fmt 2025-03-13 10:45:20 -04:00
Jorge Ortega
689a7a2055 Updates rust-toolchain to nightly-02-20.
This includes several updates to the backend based on changes in
rustc_codegen_llvm, which brings some bug fixes and a refactor to debug
info. This fixes failing dependencies that resolved to newer versions
that failed to build on the previous nightly.

Removes depending on rustc_codegen_llvm as it can't be imported with the
new toolchain for some reason.

The example cuda kernals fail to build. Their dependencies
cause nvvm to abort with ICE.
2025-03-13 10:45:20 -04:00
Christian Legnitto
54f476cbc6 Fix some compilation errors and warnings (#152) 2025-03-08 14:59:24 -04:00
Christian Kuntz
34df9c74b3 Panic when nvcc can't be found by which (#151)
std::process::Command.output() doesn't return error on non-zero exit, only
when command.inner() fails.

If `which nvcc` can't find `nvcc` it returns like (ExitStatus(-1), "", "")
and causes a panic in the return of the function.

Instead, panic on non-zero return with an informational diagnostic message.
2025-03-08 13:31:14 -04:00
Christian Legnitto
63abe778b5 Fix formatting (#150) 2025-03-07 17:40:10 -04:00
Christian Legnitto
450d16c0cc Run CI on main (#148) 2025-03-07 15:21:02 -04:00
DoeringChristian
9db073bab9 Fix: cast caused double free (use mem::forget) (#105)
Co-authored-by: Döring Christian <christian.doering@ŧum.de>
2025-03-07 15:17:46 -04:00
Genius
6a6dcdadda README.md: Add the tutorial for building the proj. (#144) 2025-03-07 15:11:55 -04:00
Alex Eisenschmied
d00cf26f0e Updated crates to use new versions of Dependencies (#146)
* Dependencies updated and toolchain updated to a modern version of rust nightly. Had to update the vek, sysinfo, and rayon crates, since they wer pulling in code from dependencies that has long since been broken.

rustc codegen nvvm is still broken, seems to have a number of issues. Once I got Optix installed and setup, I started having trouble with llvm. The build file seems to need llvm-config, which does not ship with precompiled binaries for llvm. I compiled llvm from source, but am still unable to get the build file to find that correctly. There are also a number of regular errors which will need to resolved slowly.

* Dependencies for all crates should be updated to the latest available versions. Going to tackle any breaking changes next

* Two bit flag fields in cust/texture.rs did not implement traits required by the structs they were contained in. This has been resolved

* I both of these files, the field access was replaced with a getter method, which was previously throwing an error

* ArrayObjectFlags needed Debug and PartialEq traits to be derived, was throwing an error before

* updating another file

* removed once_cell as dependency from rustc_codegen_nvvm. The goal was to replace with the standardized version from the std library, but the dependency does not seem to be in use anyway
2025-03-07 15:11:30 -04:00
Jorge Ortega
be0d1fb226 FIX: Remove nvptx target architecture conditions. (#145)
32-bit support was removed in ef4fcc86d. Updates attributes to match.
Fixes numerous warnings when compiling with newer nightly.
2025-03-07 15:10:23 -04:00
Christian Legnitto
ab4af169b0 Fix cuda toolkit installation in CI (#147) 2025-03-07 15:08:37 -04:00
Juniper Tyree
5db35d2476 Allow Stream::add_callback to run on context error again (#138)
* Revert "Feat: use cuMemHostLaunch instead of cuStreamAddCallback internally"

This reverts commit 6ab550cc6a.

* Amend the changelog
2025-02-07 23:25:53 -08:00
Juniper Tyree
833485cf9f Take an &Event in Stream::wait_event (#137) 2025-02-07 23:23:52 -08:00
Christian Legnitto
1b56eb0804 Fix formatting (#134) 2025-01-27 15:03:31 -04:00
William
a3dc4101fa fixed impl_glam|mint|vek feature flags being an illusion of choice (#69) 2025-01-27 14:49:00 -04:00
Ralf Biedert
5d801f4ab9 On NixOS find cudatoolkit via which nvcc, fixes #92. (#93) 2025-01-27 14:46:49 -04:00
Jonathan
e9f625c609 Readme: Guide links to github page instead of source directory (#73) 2025-01-27 14:44:59 -04:00