Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from GaryMcD/set_func_attribute
Browse files Browse the repository at this point in the history
Added functionality for cuFuncSetAttribute.
GaryMcD authored Jan 14, 2024

Verified

This commit was signed with the committer’s verified signature.
falkTX Filipe Coelho
2 parents 1619f6b + 63c942c commit bc1e46f
Showing 2 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/driver/result.rs
Original file line number Diff line number Diff line change
@@ -139,6 +139,28 @@ pub mod device {
}
}

pub mod function {
use super::sys::{self, CUfunction_attribute_enum};

/// Sets the specific attribute of a cuda function.
///
/// See [cuda docs](https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EXECUTION.html#group__CUDART__EXECUTION_1g317e77d2657abf915fd9ed03e75f3eb0)
///
/// # Safety
/// Function must exist.
pub unsafe fn set_function_attribute(
f: sys::CUfunction,
attribute: CUfunction_attribute_enum,
value: i32,
) -> Result<(), super::DriverError> {
unsafe {
sys::cuFuncSetAttribute(f, attribute, value).result()?;
}

Ok(())
}
}

pub mod occupancy {

use core::{
18 changes: 17 additions & 1 deletion src/driver/safe/core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::driver::{result, sys};
use crate::driver::{
result,
sys::{self, CUfunction_attribute_enum},
};

use super::{alloc::DeviceRepr, device_ptr::DeviceSlice};

@@ -387,6 +390,19 @@ impl CudaFunction {

Ok(cluster_size as u32)
}

/// Set the value of a specific attribute of this [CudaFunction].
pub fn set_attribute(
&self,
attribute: CUfunction_attribute_enum,
value: i32,
) -> Result<(), result::DriverError> {
unsafe {
result::function::set_function_attribute(self.cu_function, attribute, value)?;
}

Ok(())
}
}

unsafe impl Send for CudaFunction {}

0 comments on commit bc1e46f

Please sign in to comment.