【发布时间】:2018-10-22 10:46:19
【问题描述】:
我注意到将数据传输到最近的高端 GPU 比将数据收集回 CPU 更快。以下是使用 mathworks 技术支持提供给我的基准测试函数在较旧的 Nvidia K20 和最近的带有 PCIE 的 Nvidia P100 上运行的结果:
Using a Tesla P100-PCIE-12GB GPU.
Achieved peak send speed of 11.042 GB/s
Achieved peak gather speed of 4.20609 GB/s
Using a Tesla K20m GPU.
Achieved peak send speed of 2.5269 GB/s
Achieved peak gather speed of 2.52399 GB/s
我在下面附上了基准函数以供参考。 P100不对称的原因是什么?这个系统是依赖于它还是最近高端 GPU 的标准?采集速度可以提高吗?
gpu = gpuDevice();
fprintf('Using a %s GPU.\n', gpu.Name)
sizeOfDouble = 8; % Each double-precision number needs 8 bytes of storage
sizes = power(2, 14:28);
sendTimes = inf(size(sizes));
gatherTimes = inf(size(sizes));
for ii=1:numel(sizes)
numElements = sizes(ii)/sizeOfDouble;
hostData = randi([0 9], numElements, 1);
gpuData = randi([0 9], numElements, 1, 'gpuArray');
% Time sending to GPU
sendFcn = @() gpuArray(hostData);
sendTimes(ii) = gputimeit(sendFcn);
% Time gathering back from GPU
gatherFcn = @() gather(gpuData);
gatherTimes(ii) = gputimeit(gatherFcn);
end
sendBandwidth = (sizes./sendTimes)/1e9;
[maxSendBandwidth,maxSendIdx] = max(sendBandwidth);
fprintf('Achieved peak send speed of %g GB/s\n',maxSendBandwidth)
gatherBandwidth = (sizes./gatherTimes)/1e9;
[maxGatherBandwidth,maxGatherIdx] = max(gatherBandwidth);
fprintf('Achieved peak gather speed of %g GB/s\n',max(gatherBandwidth))
编辑:我们现在知道它不依赖于系统(参见 cmets)。我仍然想知道不对称的原因,或者它是否可以改变。
【问题讨论】:
-
要回答你的第二个问题,我可以在 Quadro M5000 GPU 上重现结果,这里我的峰值发送速度为 10.0442 GB/s,峰值收集速度为 3.66208 GB/s。所以它似乎并不依赖于系统。
-
谢谢!我也在其他系统上尝试过,结果相似。所以现在我们可以确认它不依赖于系统。
-
考虑到 GPU 主要用于在屏幕上生成图形,因此将上传速度优先于下载速度是有意义的。
-
我认为为了完整起见,这个基准测试也应该在不同的环境/语言中完成,以排除与 MATLAB 相关的怪癖。
-
峰值代表速度吗?我肯定会更相信平均值。