Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize data transfer between OpenCL devices. #5

Open
marty1885 opened this issue May 20, 2019 · 2 comments
Open

Optimize data transfer between OpenCL devices. #5

marty1885 opened this issue May 20, 2019 · 2 comments
Labels
OpenCL About the OpenCL backend optimization make stuff faster!

Comments

@marty1885
Copy link
Member

Currently copying data between 2 OpenCL backends are done by

  1. Allocating a temporary buffer
  2. Copy data from GPU1 to buffer
  3. Copy data from buffer to GPU2
  4. release the buffer

Which is slow. There are other more optimized routes. But the mechanism to trigger it is yet to determined.

Sol 1: Using clEnqueueMapBuffer

  1. Map the memory from GPU1 to CPU (a pre-pinned DMA transfer)
  2. Copy data from buffer to GPU2
  3. unmap buffer

Sol 2: With OpenCL 2.0's Shared Virtual Memory. Host memory is not touched, super fast.

  1. Allocate Tensors as SVM buffers
  2. Ask GPU2 to copy data from GPU1

They should make multi-gpu faster.

@marty1885 marty1885 added enhancement New feature or request OpenCL About the OpenCL backend optimization make stuff faster! and removed enhancement New feature or request labels May 20, 2019
@marty1885
Copy link
Member Author

Sol 3:

  1. Make a copy of tensor on GPU1 (clCreateBuffer && clEnqueueCopyBuffer)
  2. Migrate the buffer (clEnqueueMigrateMemObject) from GPU1 to GPU2

But it is still not optimal that we need to copy a buffer on GPU1

@marty1885
Copy link
Member Author

Apparently Nvidia does have some OpenCL 2.0 support.
https://streamhpc.com/blog/2017-02-22/nvidia-enables-opencl-2-0-beta-support/

Seems I can build OpenCL 2.0 code before grabbing myself a Navi card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenCL About the OpenCL backend optimization make stuff faster!
Projects
None yet
Development

No branches or pull requests

1 participant