use std::fmt::{self, Display, Formatter};
use bitflags::parser;
use num_enum::{IntoPrimitive, TryFromPrimitive};
use singe_core::impl_enum_display;
use singe_cuda_sys::library_types;
singe_core::native_enum! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
#[repr(u32)]
#[non_exhaustive]
pub enum EmulationStrategy: library_types::cudaEmulationStrategy {
Default = CUDA_EMULATION_STRATEGY_DEFAULT,
Performant = CUDA_EMULATION_STRATEGY_PERFORMANT,
Eager = CUDA_EMULATION_STRATEGY_EAGER,
}
}
impl_enum_display!(EmulationStrategy, {
Self::Default => "CUDA_EMULATION_STRATEGY_DEFAULT",
Self::Performant => "CUDA_EMULATION_STRATEGY_PERFORMANT",
Self::Eager => "CUDA_EMULATION_STRATEGY_EAGER",
});
singe_core::native_enum! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, TryFromPrimitive, IntoPrimitive)]
#[repr(u32)]
#[non_exhaustive]
pub enum EmulationMantissaControl: library_types::cudaEmulationMantissaControl {
Dynamic = CUDA_EMULATION_MANTISSA_CONTROL_DYNAMIC,
Fixed = CUDA_EMULATION_MANTISSA_CONTROL_FIXED,
}
}
impl_enum_display!(EmulationMantissaControl, {
Self::Dynamic => "CUDA_EMULATION_MANTISSA_CONTROL_DYNAMIC",
Self::Fixed => "CUDA_EMULATION_MANTISSA_CONTROL_FIXED",
});
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EmulationSpecialValuesSupport: u32 {
const NONE = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NONE.0;
const INFINITY = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_INFINITY.0;
const NAN = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_NAN.0;
const DEFAULT = library_types::cudaEmulationSpecialValuesSupport::CUDA_EMULATION_SPECIAL_VALUES_SUPPORT_DEFAULT.0;
}
}
impl Display for EmulationSpecialValuesSupport {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
parser::to_writer(self, f)
}
}
impl From<library_types::cudaEmulationSpecialValuesSupport> for EmulationSpecialValuesSupport {
fn from(value: library_types::cudaEmulationSpecialValuesSupport) -> Self {
Self::from_bits_retain(value.0)
}
}
impl From<EmulationSpecialValuesSupport> for library_types::cudaEmulationSpecialValuesSupport {
fn from(value: EmulationSpecialValuesSupport) -> Self {
Self(value.bits())
}
}