Skip to content

Commit

Permalink
[FIX] pool cuda support for windows platform (#227)
Browse files Browse the repository at this point in the history
* [FIX] (cu29_runtime) pool for windows cuda cfg

* [FEAT] (CI) separate CUDA and non-CUDA Unit Tests

* [FIX] (CI) remove cuda feature for Unit Tests (non-cuda)

* [CHORE] (CI) add cuda-release mode in Unit-Tests for cleaning

* [FIX] (CI) FEATURES_FLAG

* [FIX] (CI) FEATURES_FLAG for windows
  • Loading branch information
makeecat authored Jan 18, 2025
1 parent 0c34cce commit 7f40f1f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
45 changes: 29 additions & 16 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
mode: [ debug, release ]
mode: [ debug, release, cuda-release]

steps:
- uses: actions/checkout@v4
Expand All @@ -37,17 +37,16 @@ jobs:
run: cargo +stable fmt --all -- --check

- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
if: runner.os == 'Linux' && matrix.mode == 'cuda-release'
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
# do not remove large-packages, as it is necessary
large-packages: false
docker-images: true
swap-storage: true
Expand All @@ -56,12 +55,6 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libudev-dev libpcap-dev

- name: Install CUDA
uses: Jimver/cuda-toolkit@master
if: runner.os != 'macOS'
with:
log-file-suffix: '${{ matrix.os }}-${{ matrix.mode }}.txt'

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
Expand All @@ -71,22 +64,42 @@ jobs:
winget install DaiyuuNobori.Win10Pcap --accept-source-agreements --accept-package-agreements
Add-Content -Path $env:GITHUB_ENV -Value "LIB=$env:USERPROFILE\npcap-sdk\Lib\x64"
- name: Install CUDA
uses: Jimver/cuda-toolkit@master
if: runner.os != 'macOS' && matrix.mode == 'cuda-release'
with:
log-file-suffix: '${{ matrix.os }}-${{ matrix.mode }}-cuda.txt'

- name: Set build mode (Linux / MacOS)
if: runner.os != 'Windows'
run: echo "RELEASE_FLAG=$([[ '${{ matrix.mode }}' == 'release' ]] && echo '--release' || echo '')" >> $GITHUB_ENV
if: runner.os != 'Windows' && ( matrix.mode == 'release' || matrix.mode == 'cuda-release' )
run: echo "RELEASE_FLAG=--release" >> $GITHUB_ENV

- name: Set build mode (Windows)
if: runner.os == 'Windows' && matrix.mode == 'release'
if: runner.os == 'Windows' && ( matrix.mode == 'release' || matrix.mode == 'cuda-release' )
run: |
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_FLAG=--release"
- name: Set features (Linux / MacOS)
if: runner.os != 'Windows'
run: echo "FEATURES_FLAG=$([[ '${{ matrix.mode }}' == 'cuda-release' ]] && echo '--all-features' || echo '--features macro_debug,mock,iyes_perf_ui,image,kornia')" >> $GITHUB_ENV

- name: Set features (Windows)
if: runner.os == 'Windows'
run: |
$features = if ($env:matrix_mode -eq 'cuda-release') {
'--all-features'
} else {
'--features macro_debug,mock,iyes_perf_ui,image,kornia'
}
Add-Content -Path $env:GITHUB_ENV -Value "FEATURES_FLAG=$features"
# Run Clippy and build
- name: Run clippy on (${{ matrix.os }} | ${{matrix.mode}})
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets -- --deny warnings
- name: Run clippy with all features on (${{ matrix.os }} | ${{matrix.mode}})
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets --all-features -- --deny warnings
run: cargo +stable clippy $RELEASE_FLAG --workspace --all-targets $FEATURES_FLAG -- --deny warnings
- name: Run build with all features on (${{ matrix.os }} | ${{matrix.mode}})
run: cargo +stable build $RELEASE_FLAG --workspace --all-targets --all-features
run: cargo +stable build $RELEASE_FLAG --workspace --all-targets $FEATURES_FLAG

- name: Run doctests on (${{ matrix.os }} | debug)
if: matrix.mode == 'debug'
Expand All @@ -96,7 +109,7 @@ jobs:
- name: Run Unit Tests on (${{ matrix.os }} | ${{matrix.mode}})
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace
- name: Run Unit Tests with all features on (${{ matrix.os }} | ${{matrix.mode}})
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace --all-features
run: cargo +stable nextest run $RELEASE_FLAG --all-targets --workspace $FEATURES_FLAG

# Run Project Generation Tests
- name: Install cargo-generate on (${{ matrix.os }} | debug)
Expand Down
2 changes: 1 addition & 1 deletion core/cu29_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ hdrhistogram = "7.5.4"
petgraph = { version = "0.7.1", features = ["serde", "serde-1", "serde_derive"] }
object-pool = "0.6.0"

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(not(target_os = "macos"))'.dependencies]
cudarc = { version = "0.13", optional = true, features = ["cuda-version-from-build-system"] }

[features]
Expand Down
8 changes: 4 additions & 4 deletions core/cu29_runtime/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<E: ElementType + 'static> ArrayLike for Vec<E> {
type Element = E;
}

#[cfg(all(feature = "cuda", target_os = "linux"))]
#[cfg(all(feature = "cuda", not(target_os = "macos")))]
mod cuda {
use super::*;
use cudarc::driver::{CudaDevice, CudaSlice, DeviceRepr, ValidAsZeroBits};
Expand Down Expand Up @@ -443,7 +443,7 @@ impl<E: ElementType> Drop for AlignedBuffer<E> {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(all(feature = "cuda", target_os = "linux"))]
#[cfg(all(feature = "cuda", not(target_os = "macos")))]
use crate::pool::cuda::CuCudaPool;
use std::cell::RefCell;

Expand Down Expand Up @@ -475,7 +475,7 @@ mod tests {
assert!(obj5.is_none());
}

#[cfg(all(feature = "cuda", target_os = "linux"))]
#[cfg(all(feature = "cuda", not(target_os = "macos")))]
#[test]
#[ignore] // Can only be executed if a real CUDA device is present
fn test_cuda_pool() {
Expand All @@ -502,7 +502,7 @@ mod tests {
assert!(obj5.is_none());
}

#[cfg(all(feature = "cuda", target_os = "linux"))]
#[cfg(all(feature = "cuda", not(target_os = "macos")))]
#[test]
#[ignore] // Can only be executed if a real CUDA device is present
fn test_copy_roundtrip() {
Expand Down

0 comments on commit 7f40f1f

Please sign in to comment.