use super::CUstream;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u32)]
pub enum CuLaunchAttributeId {
Ignore = 0,
AccessPolicyWindow = 1,
Cooperative = 2,
SynchronizationPolicy = 3,
ClusterDimension = 4,
ClusterSchedulingPolicyPreference = 5,
ProgrammaticStreamSerialization = 6,
ProgrammaticEvent = 7,
Priority = 8,
MemSyncDomainMap = 9,
MemSyncDomain = 10,
LaunchCompletionEvent = 12,
DeviceUpdatableKernelNode = 13,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct CuLaunchAttributeClusterDim {
pub x: u32,
pub y: u32,
pub z: u32,
}
#[repr(C)]
pub union CuLaunchAttributeValue {
pub cluster_dim: CuLaunchAttributeClusterDim,
pub value_u32: u32,
pub pad: [u8; 64],
}
impl Copy for CuLaunchAttributeValue {}
impl Clone for CuLaunchAttributeValue {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CuLaunchAttribute {
pub id: CuLaunchAttributeId,
pub pad: [u8; 4],
pub value: CuLaunchAttributeValue,
}
#[repr(C)]
pub struct CuLaunchConfig {
pub grid_dim_x: u32,
pub grid_dim_y: u32,
pub grid_dim_z: u32,
pub block_dim_x: u32,
pub block_dim_y: u32,
pub block_dim_z: u32,
pub shared_mem_bytes: u32,
pub stream: CUstream,
pub attrs: *const CuLaunchAttribute,
pub num_attrs: u32,
}
unsafe impl Send for CuLaunchConfig {}
unsafe impl Sync for CuLaunchConfig {}
#[cfg(test)]
mod tests {
use super::CuLaunchAttributeId;
#[test]
fn launch_attribute_id_matches_header() {
assert_eq!(CuLaunchAttributeId::Ignore as u32, 0);
assert_eq!(CuLaunchAttributeId::AccessPolicyWindow as u32, 1);
assert_eq!(CuLaunchAttributeId::Cooperative as u32, 2);
assert_eq!(CuLaunchAttributeId::SynchronizationPolicy as u32, 3);
assert_eq!(CuLaunchAttributeId::ClusterDimension as u32, 4);
assert_eq!(
CuLaunchAttributeId::ClusterSchedulingPolicyPreference as u32,
5
);
assert_eq!(
CuLaunchAttributeId::ProgrammaticStreamSerialization as u32,
6
);
assert_eq!(CuLaunchAttributeId::ProgrammaticEvent as u32, 7);
assert_eq!(CuLaunchAttributeId::Priority as u32, 8);
assert_eq!(CuLaunchAttributeId::MemSyncDomainMap as u32, 9);
assert_eq!(CuLaunchAttributeId::MemSyncDomain as u32, 10);
assert_eq!(CuLaunchAttributeId::LaunchCompletionEvent as u32, 12);
assert_eq!(CuLaunchAttributeId::DeviceUpdatableKernelNode as u32, 13);
}
}