Skip to content

Commit bfc332a

Browse files
committed
Update to experimental cust fork
1 parent b506127 commit bfc332a

File tree

16 files changed

+69
-81
lines changed

16 files changed

+69
-81
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ kernel = ["dep:rust-cuda-kernel"]
9898
[dependencies]
9999
const-type-layout = { version = "0.3.2", default-features = false, features = ["derive"] }
100100
# FIXME: cust fails to compile without the `bytemuck` feature
101-
cust = { version = "0.3.2", default-features = false, features = ["bytemuck"], optional = true }
102-
cust_core = { version = "0.1", default-features = false }
103-
cust_derive = { version = "0.2", default-features = false, optional = true }
101+
cust = { git = "https://github.com/juntyr/Rust-GPU-CUDA.git", rev = "5365c14", version = "0.3.2", default-features = false, features = ["bytemuck"], optional = true }
102+
cust_core = { git = "https://github.com/juntyr/Rust-GPU-CUDA.git", rev = "5365c14", version = "0.1", default-features = false }
103+
cust_derive = { git = "https://github.com/juntyr/Rust-GPU-CUDA.git", rev = "5365c14", version = "0.2", default-features = false, optional = true }
104104
final = { version = "0.1.1", default-features = false, optional = true }
105105
oneshot = { version = "0.1", default-features = false, features = ["std", "async"], optional = true }
106106
regex = { version = "1.10", default-features = false, optional = true }

examples/print/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ fn main() -> rust_cuda::deps::cust::error::CudaResult<()> {
1515

1616
// Create a CUDA context associated to this device
1717
let _context = rust_cuda::host::CudaDropWrapper::from(
18-
rust_cuda::deps::cust::context::Context::create_and_push(
19-
rust_cuda::deps::cust::context::ContextFlags::MAP_HOST
20-
| rust_cuda::deps::cust::context::ContextFlags::SCHED_AUTO,
18+
rust_cuda::deps::cust::context::legacy::Context::create_and_push(
19+
rust_cuda::deps::cust::context::legacy::ContextFlags::MAP_HOST
20+
| rust_cuda::deps::cust::context::legacy::ContextFlags::SCHED_AUTO,
2121
device,
2222
)?,
2323
);

rust-cuda-kernel/src/kernel/link/mod.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ fn extract_ptx_kernel_layout(kernel_ptx: &mut String) -> proc_macro2::TokenStrea
189189
);
190190
}
191191

192+
#[allow(clippy::literal_string_with_formatting_args)] // false positive
192193
if type_layout_metas
193194
.insert(String::from(param), bytes)
194195
.is_some()
@@ -320,8 +321,7 @@ fn check_kernel_ptx_and_report(
320321
Ok(None) => (),
321322
Ok(Some(binary)) => {
322323
if ptx_lint_levels
323-
.get(&PtxLint::DumpAssembly)
324-
.map_or(false, |level| *level > LintLevel::Allow)
324+
.get(&PtxLint::DumpAssembly).is_some_and(|level| *level > LintLevel::Allow)
325325
{
326326
const HEX: [char; 16] = [
327327
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
@@ -335,8 +335,7 @@ fn check_kernel_ptx_and_report(
335335
}
336336

337337
if ptx_lint_levels
338-
.get(&PtxLint::DumpAssembly)
339-
.map_or(false, |level| *level > LintLevel::Warn)
338+
.get(&PtxLint::DumpAssembly).is_some_and(|level| *level > LintLevel::Warn)
340339
{
341340
emit_call_site_error!(
342341
"{} compiled binary:\n{}\n\n{}",
@@ -458,27 +457,22 @@ fn check_kernel_ptx(
458457
let mut options = options.clone();
459458

460459
if ptx_lint_levels
461-
.get(&PtxLint::Verbose)
462-
.map_or(false, |level| *level > LintLevel::Warn)
460+
.get(&PtxLint::Verbose).is_some_and(|level| *level > LintLevel::Warn)
463461
{
464462
options.push(c"--verbose");
465463
}
466464
if ptx_lint_levels
467-
.get(&PtxLint::DoublePrecisionUse)
468-
.map_or(false, |level| *level > LintLevel::Warn)
465+
.get(&PtxLint::DoublePrecisionUse).is_some_and(|level| *level > LintLevel::Warn)
469466
{
470467
options.push(c"--warn-on-double-precision-use");
471468
}
472469
if ptx_lint_levels
473-
.get(&PtxLint::LocalMemoryUse)
474-
.map_or(false, |level| *level > LintLevel::Warn)
470+
.get(&PtxLint::LocalMemoryUse).is_some_and(|level| *level > LintLevel::Warn)
475471
{
476472
options.push(c"--warn-on-local-memory-usage");
477473
}
478474
if ptx_lint_levels
479-
.get(&PtxLint::RegisterSpills)
480-
.map_or(false, |level| *level > LintLevel::Warn)
481-
{
475+
.get(&PtxLint::RegisterSpills).is_some_and(|level| *level > LintLevel::Warn) {
482476
options.push(c"--warn-on-spills");
483477
}
484478
if ptx_lint_levels
@@ -504,26 +498,21 @@ fn check_kernel_ptx(
504498
};
505499

506500
if ptx_lint_levels
507-
.get(&PtxLint::Verbose)
508-
.map_or(false, |level| *level > LintLevel::Allow)
501+
.get(&PtxLint::Verbose).is_some_and(|level| *level > LintLevel::Allow)
509502
{
510503
options.push(c"--verbose");
511504
}
512505
if ptx_lint_levels
513-
.get(&PtxLint::DoublePrecisionUse)
514-
.map_or(false, |level| *level > LintLevel::Allow)
515-
{
506+
.get(&PtxLint::DoublePrecisionUse).is_some_and(|level| *level > LintLevel::Allow) {
516507
options.push(c"--warn-on-double-precision-use");
517508
}
518509
if ptx_lint_levels
519-
.get(&PtxLint::LocalMemoryUse)
520-
.map_or(false, |level| *level > LintLevel::Allow)
510+
.get(&PtxLint::LocalMemoryUse).is_some_and(|level| *level > LintLevel::Allow)
521511
{
522512
options.push(c"--warn-on-local-memory-usage");
523513
}
524514
if ptx_lint_levels
525-
.get(&PtxLint::RegisterSpills)
526-
.map_or(false, |level| *level > LintLevel::Allow)
515+
.get(&PtxLint::RegisterSpills).is_some_and(|level| *level > LintLevel::Allow)
527516
{
528517
options.push(c"--warn-on-spills");
529518
}

rust-cuda-kernel/src/kernel/lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub trait NestedMetaParser {
180180
) -> syn::Result<()>;
181181
}
182182

183-
impl<'a> NestedMetaParser for syn::meta::ParseNestedMeta<'a> {
183+
impl NestedMetaParser for syn::meta::ParseNestedMeta<'_> {
184184
fn path(&self) -> &syn::Path {
185185
&self.path
186186
}

rust-toolchain

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[toolchain]
2-
# Pin to final 1.81.0 nightly
3-
channel = "nightly-2024-07-21"
2+
# Pin to final 1.85.0 nightly
3+
channel = "nightly-2025-01-03"
44
components = [ "cargo", "rustfmt", "clippy", "llvm-bitcode-linker", "llvm-tools" ]
5-
targets = [ "x86_64-unknown-linux-gnu", "nvptx64-nvidia-cuda" ]
5+
targets = [ "nvptx64-nvidia-cuda" ]

src/host/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub struct Stream<'stream> {
3535
_brand: InvariantLifetime<'stream>,
3636
}
3737

38-
impl<'stream> Deref for Stream<'stream> {
38+
impl Deref for Stream<'_> {
3939
type Target = cust::stream::Stream;
4040

4141
fn deref(&self) -> &Self::Target {
4242
self.stream
4343
}
4444
}
4545

46-
impl<'stream> Stream<'stream> {
46+
impl Stream<'_> {
4747
/// Create a new uniquely branded [`Stream`], which can bind async
4848
/// operations to the [`Stream`] that they are computed on.
4949
///
@@ -152,6 +152,7 @@ macro_rules! impl_sealed_drop_value {
152152
impl_sealed_drop_value!(Module);
153153
impl_sealed_drop_value!(cust::stream::Stream);
154154
impl_sealed_drop_value!(Context);
155+
impl_sealed_drop_value!(cust::context::legacy::Context);
155156
impl_sealed_drop_value!(Event);
156157

157158
#[expect(clippy::module_name_repetitions)]
@@ -271,13 +272,13 @@ pub struct HostAndDeviceConstRef<'a, T: PortableBitSemantics + TypeGraphLayout>
271272
host_ref: &'a T,
272273
}
273274

274-
impl<'a, T: PortableBitSemantics + TypeGraphLayout> Clone for HostAndDeviceConstRef<'a, T> {
275+
impl<T: PortableBitSemantics + TypeGraphLayout> Clone for HostAndDeviceConstRef<'_, T> {
275276
fn clone(&self) -> Self {
276277
*self
277278
}
278279
}
279280

280-
impl<'a, T: PortableBitSemantics + TypeGraphLayout> Copy for HostAndDeviceConstRef<'a, T> {}
281+
impl<T: PortableBitSemantics + TypeGraphLayout> Copy for HostAndDeviceConstRef<'_, T> {}
281282

282283
impl<'a, T: PortableBitSemantics + TypeGraphLayout> HostAndDeviceConstRef<'a, T> {
283284
/// # Errors

src/kernel/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ use std::{
77
ptr::NonNull,
88
};
99

10-
use cust::module::{ModuleJitOption, OptLevel};
1110
#[cfg(feature = "host")]
1211
use cust::{
1312
error::{CudaError, CudaResult},
1413
function::Function,
15-
module::Module,
14+
module::{Module, ModuleJitOption, OptLevel},
1615
};
1716

1817
#[cfg(feature = "kernel")]
@@ -226,7 +225,7 @@ macro_rules! impl_launcher_launch {
226225
}
227226

228227
#[cfg(feature = "host")]
229-
impl<'stream, 'kernel, Kernel> Launcher<'stream, 'kernel, Kernel> {
228+
impl<'stream, Kernel> Launcher<'stream, '_, Kernel> {
230229
impl_launcher_launch! { launch0() => with0_async => launch0_async }
231230

232231
impl_launcher_launch! { launch1(

src/kernel/param.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl<
157157
{
158158
}
159159

160+
#[cfg_attr(feature = "device", expect(clippy::needless_lifetimes))]
160161
impl<
161162
'a,
162163
T: Sync + crate::safety::StackOnly + crate::safety::PortableBitSemantics + TypeGraphLayout,
@@ -244,9 +245,8 @@ impl<
244245
}
245246
}
246247
impl<
247-
'a,
248248
T: Sync + crate::safety::StackOnly + crate::safety::PortableBitSemantics + TypeGraphLayout,
249-
> sealed::Sealed for &'a PerThreadShallowCopy<T>
249+
> sealed::Sealed for &PerThreadShallowCopy<T>
250250
{
251251
}
252252

@@ -342,9 +342,8 @@ impl<
342342
}
343343
}
344344
impl<
345-
'a,
346345
T: Sync + crate::safety::StackOnly + crate::safety::PortableBitSemantics + TypeGraphLayout,
347-
> sealed::Sealed for &'a PtxJit<PerThreadShallowCopy<T>>
346+
> sealed::Sealed for &PtxJit<PerThreadShallowCopy<T>>
348347
{
349348
}
350349

@@ -374,6 +373,7 @@ impl<
374373
}
375374
}
376375

376+
#[cfg_attr(feature = "device", expect(clippy::needless_lifetimes))]
377377
impl<
378378
'a,
379379
T: Sync
@@ -467,13 +467,12 @@ impl<
467467
}
468468
}
469469
impl<
470-
'a,
471470
T: crate::safety::StackOnly
472471
+ Sync
473472
+ crate::safety::PortableBitSemantics
474473
+ TypeGraphLayout
475474
+ InteriorMutableSync,
476-
> sealed::Sealed for &'a ShallowInteriorMutable<T>
475+
> sealed::Sealed for &ShallowInteriorMutable<T>
477476
{
478477
}
479478

@@ -618,6 +617,7 @@ impl<
618617
{
619618
}
620619

620+
#[cfg_attr(feature = "device", expect(clippy::needless_lifetimes))]
621621
impl<'a, T: Sync + RustToCuda> CudaKernelParameter for &'a DeepPerThreadBorrow<T> {
622622
#[cfg(feature = "host")]
623623
type AsyncHostType<'stream, 'b>
@@ -707,8 +707,9 @@ impl<'a, T: Sync + RustToCuda> CudaKernelParameter for &'a DeepPerThreadBorrow<T
707707
}
708708
}
709709
}
710-
impl<'a, T: Sync + RustToCuda> sealed::Sealed for &'a DeepPerThreadBorrow<T> {}
710+
impl<T: Sync + RustToCuda> sealed::Sealed for &DeepPerThreadBorrow<T> {}
711711

712+
#[cfg_attr(feature = "device", expect(clippy::needless_lifetimes))]
712713
impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> CudaKernelParameter
713714
for &'a mut DeepPerThreadBorrow<T>
714715
{
@@ -806,8 +807,8 @@ impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> CudaKernelParameter
806807
}
807808
}
808809
}
809-
impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> sealed::Sealed
810-
for &'a mut DeepPerThreadBorrow<T>
810+
impl<T: Sync + RustToCuda + SafeMutableAliasing> sealed::Sealed
811+
for &mut DeepPerThreadBorrow<T>
811812
{
812813
}
813814

@@ -994,7 +995,7 @@ impl<'a, T: Sync + RustToCuda> CudaKernelParameter for &'a PtxJit<DeepPerThreadB
994995
}
995996
}
996997
}
997-
impl<'a, T: Sync + RustToCuda> sealed::Sealed for &'a PtxJit<DeepPerThreadBorrow<T>> {}
998+
impl<T: Sync + RustToCuda> sealed::Sealed for &PtxJit<DeepPerThreadBorrow<T>> {}
998999

9991000
impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> CudaKernelParameter
10001001
for &'a mut PtxJit<DeepPerThreadBorrow<T>>
@@ -1090,8 +1091,8 @@ impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> CudaKernelParameter
10901091
}
10911092
}
10921093
}
1093-
impl<'a, T: Sync + RustToCuda + SafeMutableAliasing> sealed::Sealed
1094-
for &'a mut PtxJit<DeepPerThreadBorrow<T>>
1094+
impl<T: Sync + RustToCuda + SafeMutableAliasing> sealed::Sealed
1095+
for &mut PtxJit<DeepPerThreadBorrow<T>>
10951096
{
10961097
}
10971098

@@ -1135,7 +1136,7 @@ mod private_shared {
11351136
}
11361137
}
11371138

1138-
impl<'a, T: 'static> CudaKernelParameter for &'a mut crate::utils::shared::ThreadBlockShared<T> {
1139+
impl<T: 'static> CudaKernelParameter for &mut crate::utils::shared::ThreadBlockShared<T> {
11391140
#[cfg(feature = "host")]
11401141
type AsyncHostType<'stream, 'b>
11411142
= &'b mut crate::utils::shared::ThreadBlockShared<T>
@@ -1218,10 +1219,10 @@ impl<'a, T: 'static> CudaKernelParameter for &'a mut crate::utils::shared::Threa
12181219
inner.with(&mut param)
12191220
}
12201221
}
1221-
impl<'a, T: 'static> sealed::Sealed for &'a mut crate::utils::shared::ThreadBlockShared<T> {}
1222+
impl<T: 'static> sealed::Sealed for &mut crate::utils::shared::ThreadBlockShared<T> {}
12221223

1223-
impl<'a, T: 'static + PortableBitSemantics + TypeGraphLayout> CudaKernelParameter
1224-
for &'a mut crate::utils::shared::ThreadBlockSharedSlice<T>
1224+
impl<T: 'static + PortableBitSemantics + TypeGraphLayout> CudaKernelParameter
1225+
for &mut crate::utils::shared::ThreadBlockSharedSlice<T>
12251226
{
12261227
#[cfg(feature = "host")]
12271228
type AsyncHostType<'stream, 'b>
@@ -1307,7 +1308,7 @@ impl<'a, T: 'static + PortableBitSemantics + TypeGraphLayout> CudaKernelParamete
13071308
}
13081309
}
13091310
}
1310-
impl<'a, T: 'static + PortableBitSemantics + TypeGraphLayout> sealed::Sealed
1311-
for &'a mut crate::utils::shared::ThreadBlockSharedSlice<T>
1311+
impl<T: 'static + PortableBitSemantics + TypeGraphLayout> sealed::Sealed
1312+
for &mut crate::utils::shared::ThreadBlockSharedSlice<T>
13121313
{
13131314
}

src/lend/impls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod arc;
2-
mod arced_slice;
2+
// mod arced_slice;
33
mod r#box;
44
mod boxed_slice;
55
#[cfg(feature = "final")]

src/lend/impls/ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ unsafe impl<'a, T: PortableBitSemantics + TypeGraphLayout> RustToCuda for &'a T
7171
}
7272
}
7373

74-
unsafe impl<'a, T: PortableBitSemantics + TypeGraphLayout> RustToCudaAsync for &'a T {
74+
unsafe impl<T: PortableBitSemantics + TypeGraphLayout> RustToCudaAsync for &T {
7575
#[cfg(all(feature = "host", not(doc)))]
7676
type CudaAllocationAsync = CombinedCudaAlloc<
7777
CudaDropWrapper<LockedBox<DeviceCopyWithPortableBitSemantics<ManuallyDrop<T>>>>,

src/lend/impls/slice_ref.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ unsafe impl<'a, T: PortableBitSemantics + TypeGraphLayout> RustToCuda for &'a [T
7474
}
7575
}
7676

77+
#[cfg_attr(feature = "device", expect(clippy::needless_lifetimes))]
7778
unsafe impl<'a, T: PortableBitSemantics + TypeGraphLayout> RustToCudaAsync for &'a [T] {
7879
#[cfg(all(feature = "host", not(doc)))]
7980
type CudaAllocationAsync = CombinedCudaAlloc<

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#![feature(generic_const_exprs)]
4949
#![expect(internal_features)]
5050
#![feature(core_intrinsics)]
51-
#![feature(const_intrinsic_compare_bytes)]
51+
// #![feature(const_intrinsic_compare_bytes)]
5252
#![doc(html_root_url = "https://juntyr.github.io/rust-cuda/")]
5353

5454
#[cfg(all(feature = "host", feature = "device", not(doc)))]

src/safety/aliasing.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,21 @@
3838
pub unsafe trait SafeMutableAliasing {}
3939

4040
unsafe impl<
41-
'a,
4241
T: crate::safety::StackOnly
4342
+ crate::safety::PortableBitSemantics
4443
+ const_type_layout::TypeGraphLayout,
4544
const STRIDE: usize,
4645
> SafeMutableAliasing
47-
for crate::utils::aliasing::SplitSliceOverCudaThreadsConstStride<&'a mut [T], STRIDE>
46+
for crate::utils::aliasing::SplitSliceOverCudaThreadsConstStride<&mut [T], STRIDE>
4847
{
4948
}
5049

5150
unsafe impl<
52-
'a,
5351
T: crate::safety::StackOnly
5452
+ crate::safety::PortableBitSemantics
5553
+ const_type_layout::TypeGraphLayout,
5654
> SafeMutableAliasing
57-
for crate::utils::aliasing::SplitSliceOverCudaThreadsDynamicStride<&'a mut [T]>
55+
for crate::utils::aliasing::SplitSliceOverCudaThreadsDynamicStride<&mut [T]>
5856
{
5957
}
6058

0 commit comments

Comments
 (0)