I have decent/ok machine with core i7 (8 cores), 32G of RAM and Nvidia geForce GTX 1080i and running Matlab 2018b. At the moment I am a bit confuse about how to use these resources in best way to run my Monte-Carlo simulation code. The two questions I have now:

1- How can I make all the heavy computaion to be run on the GPU alonside parallel compution capability of Matlab rather than the CPU and hence I can decide what is best to use? I have read different help topics and the conclusion I think I have got is, the data I have to work with should be in the form of gpuArray Am I right? or do I miss something here?. let us assume that I have the foollowing simple code to be run on GPU :

First_Vector=zeros(2,3);

[N,M]=size(First_Vector);

Second_Matrix=ones(N,M,2);

Tset1= [20 20 20:30 30 30];

Test2= [50 50 50;60 60 60];

K=100;

for i=1:3

for j=1:3

[element]=Function1(test(i,j),K)

Test1(i,j)=element;

end

end

Second_Matrix(:,:,1)=Test1;

[Test1]=Function2(Test1,Test2);

function[outcome]=Function1(A,K)

outcome=A+K;

end

function[T1]=Function2(T1,T2)

T1=T1+T2;

end

does the commented lines (1-5) are enough to run the 'main code' on the GPU?

2- I have tested the following simple code on GPU and CPU, CPU performance was by far better than GPU. is that supposed to be normal ?

thanks in advanced.

G = ones(10,10,'gpuArray');

tic

for k=1:100

for i=1: 1000

for j=1:10

G(j,:)=G(j,:)+2;

end

end

end

toc

G = ones(10,10);

tic

for k=1:100

for i=1: 1000

for j=1:10

G(j,:)=G(j,:)+2;

end

end

end

toc

## 0 Comments

Sign in to comment.