Skip to content

Commit

Permalink
Return uints and ulongs for cl_intel_device_attribute_query for issue #…
Browse files Browse the repository at this point in the history
…10

Tested with an Intel GPU. Values are correct size, but may not all be the correct type...
  • Loading branch information
kenba committed Sep 19, 2021
1 parent a83239c commit d048733
Showing 1 changed file with 64 additions and 8 deletions.
72 changes: 64 additions & 8 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,6 @@ pub fn get_device_info(device: cl_device_id, param_name: DeviceInfo) -> Result<I
| DeviceInfo::CL_DEVICE_TOPOLOGY_AMD // cl_amd_device_attribute_query
| DeviceInfo::CL_DEVICE_BOARD_NAME_AMD // cl_amd_device_attribute_query
| DeviceInfo::CL_DEVICE_PCI_BUS_INFO_KHR // cl_khr_pci_bus_info
| DeviceInfo::CL_DEVICE_IP_VERSION_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_ID_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_SLICES_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_THREADS_PER_EU_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_FEATURE_CAPABILITIES_INTEL // cl_intel_device_attribute_query
=> {
Ok(InfoType::VecUchar(get_device_data(device, param_id)?))
}
Expand Down Expand Up @@ -546,6 +539,12 @@ pub fn get_device_info(device: cl_device_id, param_name: DeviceInfo) -> Result<I
| DeviceInfo::CL_DEVICE_GFXIP_MINOR_AMD // cl_amd_device_attribute_query
| DeviceInfo::CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD // cl_amd_device_attribute_query
| DeviceInfo::CL_DEVICE_PCIE_ID_AMD // cl_amd_device_attribute_query
| DeviceInfo::CL_DEVICE_IP_VERSION_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_ID_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_SLICES_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL // cl_intel_device_attribute_query
| DeviceInfo::CL_DEVICE_NUM_THREADS_PER_EU_INTEL // cl_intel_device_attribute_query
=> {
api_info_value!(get_value, cl_uint, clGetDeviceInfo);
Ok(InfoType::Uint(get_value(device, param_id)?))
Expand All @@ -567,7 +566,8 @@ pub fn get_device_info(device: cl_device_id, param_name: DeviceInfo) -> Result<I
| DeviceInfo::CL_DEVICE_ATOMIC_FENCE_CAPABILITIES // CL_VERSION_3_0
| DeviceInfo::CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES // CL_VERSION_3_0
| DeviceInfo::CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR
=> {
| DeviceInfo::CL_DEVICE_FEATURE_CAPABILITIES_INTEL // cl_intel_device_attribute_query
=> {
api_info_value!(get_value, cl_ulong, clGetDeviceInfo);
Ok(InfoType::Ulong(get_value(device, param_id)?))
}
Expand Down Expand Up @@ -1574,6 +1574,62 @@ mod tests {
Err(e) => println!("OpenCL error, CL_DEVICE_PCI_BUS_INFO_KHR: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_IP_VERSION_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_IP_VERSION_INTEL: {:?}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_IP_VERSION_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_ID_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_ID_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_ID_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_NUM_SLICES_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_NUM_SLICES_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_NUM_SLICES_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_NUM_THREADS_PER_EU_INTEL) {
Ok(value) => {
let value = value.to_uint();
println!("CL_DEVICE_NUM_THREADS_PER_EU_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_NUM_THREADS_PER_EU_INTEL: {}", ClError(e))
};

match get_device_info(device_id, DeviceInfo::CL_DEVICE_FEATURE_CAPABILITIES_INTEL) {
Ok(value) => {
let value = value.to_ulong();
println!("CL_DEVICE_FEATURE_CAPABILITIES_INTEL: {}", value)
}
Err(e) => println!("OpenCL error, CL_DEVICE_FEATURE_CAPABILITIES_INTEL: {}", ClError(e))
};

// CL_VERSION_2_0
if is_opencl_2 {
let value = get_device_info(device_id, DeviceInfo::CL_DEVICE_IMAGE_PITCH_ALIGNMENT).unwrap();
Expand Down

0 comments on commit d048733

Please sign in to comment.