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

[FIX] pool cuda support for windows platform #227

Merged
merged 6 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading