From 0e9a6b769e672dec9c9822039fb07b9b4aade431 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 16 Oct 2024 21:39:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E9=98=9F=E5=88=97=E5=A4=AA=E5=A4=A7=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9ba6c19..4c59118 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ fn main() -> anyhow::Result<()> { println!("警告: get_device_info failed: {}\n也许是你没有一张AMD显卡,让我们试试非AMD", err); match get_device_info(device_id, CL_DEVICE_MAX_WORK_GROUP_SIZE) { Ok(size) => { + println!("非 amd size 获取成功"); size.to_size() }, Err(err) => { @@ -46,12 +47,17 @@ fn main() -> anyhow::Result<()> { // Create a Context on an OpenCL device let context = Context::from_device(&device).expect("Context::from_device failed"); - let queue = CommandQueue::create_default_with_properties( + let queue = match CommandQueue::create_default_with_properties( &context, CL_QUEUE_PROFILING_ENABLE, - worker_count as u32, - ) - .expect("create_command_queue_with_properties failed"); + 10, // 写死试试, 看起来没问题 + ) { + Ok(q) => q, + Err(err) => { + println!("创建命令队列失败: {}", err); + panic!(); + } + }; // Build the OpenCL program source and create the kernel. let program = match Program::create_and_build_from_source(&context, PROGRAM_SOURCE, "") {