在单个上下文中读取/写入多个GPU上的OpenCL内存缓冲区 [英] Read/Write OpenCL memory buffers on multiple GPU in a single context

查看:155
本文介绍了在单个上下文中读取/写入多个GPU上的OpenCL内存缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设系统具有两个不同的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆