如何解决OpenCL 程序在 clBuildProgram 挂起
我的内核正在按预期编译和工作,但现在它挂在 clBuildProgram 上。我的源代码上的内核代码或 OpenCL 代码在两次尝试之间没有改变。我也尝试构建一个空内核,但它仍然挂在 clBuildProgram 上。 这是我的 C++ 代码:
/*
struct FileData {
char* Buffer;
unsigned int Length; }
*/
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 200
#include <CL/opencl.hpp>
...
std::vector< cl::Platform > Platforms;
cl::Platform::get(&Platforms);
cl::Platform Platform = Platforms[0];
if (!Platform())
throw std::runtime_error("No OpenCL platform found.");
std::vector<cl::Device> Devices;
Platform.getDevices(CL_DEVICE_TYPE_GPU,&Devices);
cl::Device Device = Devices[0];
if (!Device())
throw std::runtime_error("No compatible devices found.");
cl::Context Context({ Device });
cl::Program::Sources Source;
FileData KernelCode = OpenFile("Source/TestKernel.cl");
Source.push_back({ KernelCode.Buffer,KernelCode.Length });
cl::Program Program(Context,Source);
try
{
Program.build({ Device }); // Doesn't return
}
catch (cl::Error error)
{
std::cerr << Program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(Device) << std::endl;
throw std::runtime_error("Failed to build the kernel.");
}
...
还有我的内核代码 (TestKernel.cl):
__kernel void TestKernel() { }
我错过了什么? 我没有提供其余的代码,因为它永远不会执行,OpenFile(...) 成功读取了内核源代码并且没有抛出异常。
我的环境:
Visual Studio 2019 社区 16.8.4, GPUOpen OCL_SDK_Light SDK, AMD Radeon RX5700XT(OpenCL 报告的“gfx1010”), Windows 10 版本 2004
谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。