修复了必须使用amd显卡的问题(逃
This commit is contained in:
parent
11f0df1254
commit
ea7a1c212e
16
src/main.rs
16
src/main.rs
@ -1,6 +1,6 @@
|
||||
use opencl3::command_queue::{CommandQueue, CL_QUEUE_PROFILING_ENABLE};
|
||||
use opencl3::context::Context;
|
||||
use opencl3::device::{get_all_devices, get_device_info, Device, CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD, CL_DEVICE_TYPE_GPU};
|
||||
use opencl3::device::{get_all_devices, get_device_info, Device, CL_DEVICE_MAX_WORK_GROUP_SIZE, CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD, CL_DEVICE_TYPE_GPU};
|
||||
use opencl3::kernel::{ExecuteKernel, Kernel};
|
||||
use opencl3::memory::{Buffer, CL_MAP_WRITE, CL_MEM_READ_ONLY};
|
||||
use opencl3::program::Program;
|
||||
@ -19,14 +19,24 @@ fn main() -> anyhow::Result<()> {
|
||||
let device_id = *get_all_devices(CL_DEVICE_TYPE_GPU)?
|
||||
.first()
|
||||
.expect("no device found in platform");
|
||||
let size = match get_device_info(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD) {
|
||||
let size = {
|
||||
match get_device_info(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD) {
|
||||
Ok(size) => {
|
||||
size.to_size()
|
||||
},
|
||||
Err(err) => {
|
||||
println!("get_device_info failed: {}", err);
|
||||
println!("警告: get_device_info failed: {}\n也许是你没有一张AMD显卡,让我们试试非AMD", err);
|
||||
match get_device_info(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE) {
|
||||
Ok(size) => {
|
||||
size.to_size()
|
||||
},
|
||||
Err(err) => {
|
||||
println!("错误: get_device_info failed: {}\n", err);
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let device = Device::new(device_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user