本文介绍了Matlab GPU计算中G2 = G.* G和G2 = G * G之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

以下代码中的G2 = G .* GG2 = G * G有什么区别?又为什么我在gpu-z上的第一个代码获得100%的GPU负载,而第二个代码获得100%的GPU负载和内存控制器负载传感器?

What's the difference between G2 = G .* G and G2 = G * G in the following codes? And why I get with first code GPU Load 100% and with the second I get GPU Load and Memory Controller Load sensors both at 100% on gpu-z ?

X = rand(5000, 'double');
G = gpuArray(X);
classUnderlying(G)          % Returns 'single'

for m = 1:5000
G2 = G .* G .* G .* G;         % Performed on GPU
end

whos G2                     % Result on GPU


X = rand(5000, 'double');
G = gpuArray(X);
classUnderlying(G)          % Returns 'single'

for m = 1:5000
G2 = G * G * G * G;         % Performed on GPU
end

whos G2                     % Result on GPU

推荐答案

有矩阵乘法(mtimes)和逐元素乘法(times)

There is matrix multiplication (mtimes) and elementwise multiplication (times)

http://www.mathworks.de/de/help/matlab/ref/mtimes.html

http://www.mathworks.de/de/help/matlab/ref/times.html

这篇关于Matlab GPU计算中G2 = G.* G和G2 = G * G之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:40