aboutsummaryrefslogtreecommitdiffhomepage
path: root/zluda/src/impl/device.rs
diff options
context:
space:
mode:
Diffstat (limited to 'zluda/src/impl/device.rs')
-rw-r--r--zluda/src/impl/device.rs123
1 files changed, 120 insertions, 3 deletions
diff --git a/zluda/src/impl/device.rs b/zluda/src/impl/device.rs
index 8836c1e..13bce63 100644
--- a/zluda/src/impl/device.rs
+++ b/zluda/src/impl/device.rs
@@ -1,4 +1,4 @@
-use cuda_types::*;
+use cuda_types::cuda::*;
use hip_runtime_sys::*;
use std::{mem, ptr};
@@ -70,6 +70,16 @@ pub(crate) fn get_attribute(
attrib: CUdevice_attribute,
dev_idx: hipDevice_t,
) -> hipError_t {
+ fn get_device_prop(
+ pi: &mut i32,
+ dev_idx: hipDevice_t,
+ f: impl FnOnce(&hipDeviceProp_tR0600) -> i32,
+ ) -> hipError_t {
+ let mut props = unsafe { mem::zeroed() };
+ unsafe { hipGetDevicePropertiesR0600(&mut props, dev_idx)? };
+ *pi = f(&props);
+ Ok(())
+ }
match attrib {
CUdevice_attribute::CU_DEVICE_ATTRIBUTE_WARP_SIZE => {
*pi = 32;
@@ -79,6 +89,110 @@ pub(crate) fn get_attribute(
*pi = 0;
return Ok(());
}
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLayered[2])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture1DLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture1DLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER => {
+ return get_device_prop(pi, dev_idx, |props| {
+ (props.maxTexture2DGather[0] > 0 && props.maxTexture2DGather[1] > 0) as i32
+ })
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DGather[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DGather[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture3DAlt[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture3DAlt[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture3DAlt[2])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTextureCubemap)
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTextureCubemapLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTextureCubemapLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface1D)
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface2D[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface2D[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface3D[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface3D[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface3D[2])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface1DLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface1DLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface2DLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface2DLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurface2DLayered[2])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurfaceCubemap)
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurfaceCubemapLayered[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS => {
+ return get_device_prop(pi, dev_idx, |props| props.maxSurfaceCubemapLayered[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture1DLinear)
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLinear[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLinear[1])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DLinear[2])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DMipmap[0])
+ }
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture2DMipmap[1])
+ }
CUdevice_attribute::CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR => {
*pi = COMPUTE_CAPABILITY_MAJOR;
return Ok(());
@@ -87,6 +201,9 @@ pub(crate) fn get_attribute(
*pi = COMPUTE_CAPABILITY_MINOR;
return Ok(());
}
+ CUdevice_attribute::CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH => {
+ return get_device_prop(pi, dev_idx, |props| props.maxTexture1DMipmap)
+ }
_ => {}
}
let attrib = remap_attribute! {
@@ -260,7 +377,7 @@ pub(crate) fn get_name(
name: *mut ::core::ffi::c_char,
len: ::core::ffi::c_int,
dev: hipDevice_t,
-) -> cuda_types::CUresult {
+) -> CUresult {
unsafe { hipDeviceGetName(name, len, dev) }?;
let len = len as usize;
let buffer = unsafe { std::slice::from_raw_parts(name, len) };
@@ -287,7 +404,7 @@ pub(crate) fn total_mem_v2(bytes: *mut usize, dev: hipDevice_t) -> hipError_t {
unsafe { hipDeviceTotalMem(bytes, dev) }
}
-pub(crate) fn get_properties(prop: &mut cuda_types::CUdevprop, dev: hipDevice_t) -> hipError_t {
+pub(crate) fn get_properties(prop: &mut CUdevprop, dev: hipDevice_t) -> hipError_t {
let mut hip_props = unsafe { mem::zeroed() };
unsafe { hipGetDevicePropertiesR0600(&mut hip_props, dev) }?;
prop.maxThreadsPerBlock = hip_props.maxThreadsPerBlock;