在单个上下文中读取/写入多个GPU上的OpenCL内存缓冲区 [英] Read/Write OpenCL memory buffers on multiple GPU in a single context
问题描述
假设系统具有两个不同的GPU,但来自同一供应商,因此可以从单个OpenCL平台进行访问.给出以下简化的 OpenCL代码:
Assume a system with two distinct GPUs, but from the same vendor so they can be accessed from a single OpenCL Platform. Given the following simplified OpenCL code:
float* someRawData;
cl_device_id gpu1 = clGetDeviceIDs(0,...);
cl_device_id gpu2 = clGetDeviceIDs(1,...);
cl_context ctx = clCreateContext(gpu1,gpu2,...);
cl_command_queue queue1 = clCreateCommandQueue(ctx,gpu1,...);
cl_command_queue queue2 = clCreateCommandQueue(ctx,gpu2,...);
cl_mem gpuMem = clCreateBuffer(ctx, CL_MEM_READ_WRITE, ...);
clEnqueueWriteBuffer(queue1,gpuMem,...,someRawData,...);
clFinish(queue1);
执行结束时,someRawData
是在两个GPU内存中还是仅在gpu1
内存中?
At the end of the execution, will someRawData
be on both GPU in-memory or will it be only on gpu1
in-memory?
推荐答案
这取决于实现,数据将在调用clFinish()
之后出现,但最有可能在队列引用的GPU上.同样,这种抽象使得从queue2
上启动的内核访问gpuMem
成为可能,而无需进行明确的数据传输.
It is up to the implementation, where the data will be after calling clFinish()
but most likely it will be on the GPU referenced by the queue. Also, this kind of abstraction makes it possible to access gpuMem
from a kernel launched on queue2
without an explicit data transfer.
这篇关于在单个上下文中读取/写入多个GPU上的OpenCL内存缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!