gpt4 book ai didi

concurrency - cudaDeviceScheduleBlockingSync 和 cudaDeviceScheduleYield 有什么区别?

转载 作者:行者123 更新时间:2023-12-04 03:17:58 25 4
gpt4 key购买 nike

如这里所述:How to reduce CUDA synchronize latency / delay

有两种等待设备结果的方法:

  • “轮询”- 在旋转中消耗 CPU - 以减少我们等待结果时的延迟
  • “阻塞”——线程在中断发生前一直处于休眠状态——以提高整体性能

对于“轮询”需要使用CudaDeviceScheduleSpin

但对于“阻塞”,我需要使用CudaDeviceScheduleYieldcudaDeviceScheduleBlockingSync 什么?

cudaDeviceScheduleBlockingSynccudaDeviceScheduleYield 有什么区别?

cudaDeviceScheduleYield 写成:http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group__CUDART__DEVICE_g18074e885b4d89f5a0fe1beab589e0c8.html“在等待设备结果时指示 CUDA 放弃其线程。这会在等待设备时增加延迟,但可以提高性能 CPU 线程与设备并行执行工作。” - 即等待结果而不在自旋中烧毁 CPU - 即“阻塞”。还有 cudaDeviceScheduleBlockingSync - 等待结果不会在旋转中烧毁 CPU。但是有什么区别呢?

最佳答案

据我了解,这两种方法都使用轮询来同步。在 CudaDeviceScheduleSpin 的伪代码中:

while (!IsCudaJobDone())
{
}

CudaDeviceScheduleYield:

while (!IsCudaJobDone())
{
Thread.Yield();
}

CudaDeviceScheduleYield 告诉操作系统它可以中断轮询线程并激活另一个线程做其他工作。这提高了 CPU 上其他线程的性能,但也增加了延迟,以防 CUDA 作业完成而此时另一个线程而不是轮询线程处于事件状态。

关于concurrency - cudaDeviceScheduleBlockingSync 和 cudaDeviceScheduleYield 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22424090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com