[BUG] createGLBuffer and copyToGLBuffer do not point to the same device
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
调研方向
从 forge/examples/opencl 和 cl_helpers.h 开始,重点查看 get_devices 和两个 createCLGLContext 重载。在具有多个显卡的系统上复现该故障,然后跟踪每个 OpenGL 缓冲区操作使用的是哪个 OpenCL 设备。完成的标准是:示例通过同一个设备创建和复制 GL 缓冲区,而不依赖于选择最后一个设备。
由索引模型根据 Issue 内容生成。
描述
If you have more than one display cards, all the examples in forge/examples/opencl will fail.
A temporary workaround is to modify createCLGLContext in cl_helpers.h so that cl::Context always use the last device instead of the first device. But it is not a solution at all.
void get_devices(const forge::Window &wnd,
std::vector<cl::Platform> &platforms_interop,
std::vector<Device> &devices_interop) {
std::vector<cl::Platform> platforms;
Platform::get(&platforms);
for (auto platform : platforms) {
std::vector<cl::Device> devices;
try {
platform.getDevices(CL_DEVICE_TYPE_GPU, &devices);
for (auto device : devices) {
if (checkGLInterop(platform, device, wnd)) {
devices_interop.push_back(device);
platforms_interop.push_back(platform);
}
}
} catch (const cl::Error &err) {
if (err.err() != CL_DEVICE_NOT_FOUND) {
std::cout << "Platform: " << platform.getInfo<CL_PLATFORM_NAME>()
<< " got error = " << err.err() << std::endl;
throw std::runtime_error("Fatal Error!");
}
}
}
if (devices_interop.size() == 0)
throw std::runtime_error("No CL-GL sharing contexts found");
}
cl::Context createCLGLContext(const forge::Window &wnd, cl::Platform platform,
cl::Device device) {
// std::cout << "Platform: " << platform.getInfo<CL_PLATFORM_NAME>()
// << std::endl;
// std::cout << "Device: " << device.getInfo<CL_DEVICE_NAME>() << std::endl;
#if defined(OS_MAC)
CGLContextObj cgl_current_ctx = CGLGetCurrentContext();
CGLShareGroupObj cgl_share_group = CGLGetShareGroup(cgl_current_ctx);
cl_context_properties cps[] = {CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
(cl_context_properties)cgl_share_group, 0};
#elif defined(OS_LNX)
cl_context_properties cps[] = {CL_GL_CONTEXT_KHR,
(cl_context_properties)wnd.context(),
CL_GLX_DISPLAY_KHR,
(cl_context_properties)wnd.display(),
CL_CONTEXT_PLATFORM,
(cl_context_properties)platform(),
0};
#else /* OS_WIN */
cl_context_properties cps[] = {CL_GL_CONTEXT_KHR,
(cl_context_properties)wnd.context(),
CL_WGL_HDC_KHR,
(cl_context_properties)wnd.display(),
CL_CONTEXT_PLATFORM,
(cl_context_properties)platform(),
0};
#endif
return cl::Context(device, cps);
}
cl::Context createCLGLContext(const forge::Window &wnd) {
std::vector<cl::Platform> platforms;
std::vector<Device> devices;
get_devices(wnd, platforms, devices);
for (size_t i = devices.size() - 1; i >= 0; i--) {
// for (size_t i = 0; i < devices.size(); i++) {
try {
return createCLGLContext(wnd, platforms[i], devices[i]);
} catch (const cl::Error &err) {
std::cout << "[createCLGLContext]Error:" << err.err() << std::endl;
}
}
return cl::Context();
}
- 主要语言
- C++
- 星标
- 238
- 派生
- 46
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
arrayfire/forge 的其他 Issue
-
难度 5/5 一周以上 新手友好度 10/100
-
难度 5/5 一周以上 新手友好度 20/100
-
question
难度 5/5 一周以上 新手友好度 25/100
-
enhancement
-
enhancement feature
相似的 Issue
-
bug build
难度 1/5 1 小时以内 新手友好度 91/100
facebookincubator/velox#19194 ·
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW 未关闭fuzz
难度 2/5 1-3 小时 新手友好度 82/100
ClickHouse/ClickHouse#122114 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
module/agent platform/macos type/bug/regression
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement PyCDE
难度 2/5 1-3 小时 新手友好度 78/100