Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:matlab_tips [2016/04/04 14:50]
fangfufu old revision restored (2016/04/02 07:41)
public:matlab_tips [2018/03/31 00:38] (current)
Line 12: Line 12:
 </​code>​ </​code>​
  
-===== Highly unscientific benchmark of prod() ​===== +===== GPU / Host Performance ​===== 
-==== Sparse vs Dense ==== +These results were obtained using [[https://uk.mathworks.com/​matlabcentral/​fileexchange/​34080-gpubench|GPUBench]]
-<code matlab>​ +^ ^Results ​for data-type '​double' ​(In GFLOPS^^^Results ​for data-type '​single'​(In GFLOPS)^^^ 
->> a = rand(1000);​ +^Device ​                      ​^MTimes ^Backslash^FFT ​         ^MTimes ​ ^Backslash ^FFT   | 
->> b = eye(1000);​ +^TITAN Xp                         |422.47 |371.37   |207.24 |11607.69|1426.76   |763.56|      ​ 
->> c = sparse(a);​ +^GeForce GTX 1080                 |280.84 |223.05  ​ |137.66 |7707.01 |399.37    |424.60|      ​ 
->> d = sparse(b);​ +^Core i7-4900MQ ​(Single Thread)         |123.00 |86.57   |8.47         |272.00 |180.32 ​   |14.31 | 
->> tic; for i = 1:10000; prod(a); end; toc +^GeForce GT 730M                 |27.43 |25.43   |10.54 |346.57 |214.98 ​   |27.09 |
-Elapsed time is 7.212577 seconds+
->> tic; for i = 1:10000; prod(b); end; toc +
-Elapsed time is 3.566560 seconds. +
->> tic; for i = 1:10000; prod(c); end; toc +
-Elapsed time is 27.455137 seconds. +
->> tic; for i = 1:10000; prod(d); end; toc +
-Elapsed time is 0.030041 seconds+
->> tic; for i = 1:10000; prod(a); end; toc +
-Elapsed time is 7.250969 seconds+
->> tic; for i = 1:10000; prod(b); end; toc +
-Elapsed time is 3.645549 seconds+
->> tic; for i = 1:10000; prod(c); end; toc +
-Elapsed time is 27.538796 seconds. +
->> tic; for i = 1:10000; prod(d); end; toc +
-Elapsed time is 0.029214 seconds. +
->>+
  
->> n = 100000; 
->> a = rand(n,1); 
->> b = 1; 
->> tic; for i = 1:n; prod(a); end; toc; 
-Elapsed time is 4.849304 seconds. 
->> tic; for i = 1:n; b = b * prod(a(i)); end; toc 
-Elapsed time is 0.004573 seconds. 
->> ​ 
-</​code>​ 
- 
-==== Prod vs repeated multiplication ==== 
-=== Script === 
-<code matlab> 
-clear; 
-n = 10000; 
-a = rand(n,1) * exp(1); 
-b = 1; 
- 
-tic;  
-for i = 1:n;  
-    c = prod(a); ​ 
-end;  
-toc; 
- 
-tic;  
-for j = 1:n 
-    for i = 1:n;  
-        b = b * a(i);  
-    end;  
-end 
-toc; 
-</​code>​ 
-=== Results === 
-<code matlab> 
->> test 
-Elapsed time is 0.168450 seconds. 
-Elapsed time is 1.003991 seconds. 
-</​code>​ 
-Note that with repeated multiplication your numerical accuracy will suffer too! 
  • public/matlab_tips.txt
  • Last modified: 2018/03/31 00:38
  • (external edit)