5
$\begingroup$

Why sending data from gpu to cpu is slower than cpu to gpu?

I heard the relation is similar to network situation, in detail, the upload is slower than download. However, I could not understand the meaning.

In my opinion, the sending operation should be same because the two sending buses (cpu to gpu and gpu to cpu) can be made with the same performance (I mean bendwith).

$\endgroup$
1
  • 1
    $\begingroup$ What makes you think it is necessarily slower? If you can edit your question to add that extra detail, you'll get better answers. $\endgroup$
    – Dan Hulme
    Commented Jan 23, 2018 at 9:30

1 Answer 1

7
$\begingroup$

The actual sending of data is the same. The PCIe bus is the same speed in both directions.

However when programming there is a big difference namely that when you send you can immediately start doing something else (including queuing other operations using that new data) while the actual transfer is going on. But when receiving you need to synchronize on the completion of the transfer before you can use the data that was sent.

$\endgroup$
6
  • $\begingroup$ That's not exactly accurate, though. Commands that actually send data to the API are still synchronous, e.g. you can immediately free the memory that you called glBufferData with right after calling it, since it's copied into the API then. What is possibly unsynchronized is the transfer of that data to the actual GPU memory. However, the same asynchronous transfer approaches can be applied for data download, too. It's just that in this case you usually have to wait for all previous operations to finish. $\endgroup$ Commented Jan 25, 2018 at 12:52
  • $\begingroup$ @ChristianRau but most of the time the data you send through glBufferData is first copied to another part of memory from which the actual transfer to the GPU will take place asynchronously. $\endgroup$ Commented Jan 25, 2018 at 13:02
  • $\begingroup$ Yeah, but you could as well do that with glReadPixels. $\endgroup$ Commented Jan 25, 2018 at 13:03
  • $\begingroup$ @ChristianRau no because the driver cannot know you want that data until you call glReadPixels which is the trigger to make the gpu start sending data to RAM. The glReadPixels call cannot return until the GPU is done and the data is ready to be used. $\endgroup$ Commented Jan 25, 2018 at 13:07
  • $\begingroup$ No, glReadPixels will return immediately if you tell it to copy that data into a buffer object. Then you can do other things and then you can retrieve the data from the buffer whenever you want. $\endgroup$ Commented Jan 25, 2018 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.