-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmultithread.m
More file actions
executable file
·52 lines (47 loc) · 2.29 KB
/
Copy pathmultithread.m
File metadata and controls
executable file
·52 lines (47 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
% This is a quick test for multi-threading capabilities in matlab7.4+
% Paul J. Durack 19 Sep 2007
numThreads=2; % Number of threads to test
dataSize=5000; % Data size to test
A=rand(dataSize,dataSize); % Random square matrix
B=rand(dataSize,dataSize); % Random square matrix
setNumberOfComputationalThreads(1);
tic;
C = A*B;
time1=toc;
disp('Time for 1 thread = 0.058 sec - BLAS_VERSION unset; datasize=500');
disp('Time for 1 thread = 0.081 sec - BLAS_VERSION unset; datasize=500');
disp('Time for 1 thread = 76.920 sec - BLAS_VERSION unset; datasize=5000');
disp('Time for 1 thread = 77.734 sec - BLAS_VERSION unset; datasize=5000');
disp('Time for 1 thread = 78.342 sec - BLAS_VERSION unset; datasize=5000');
fprintf('Time for 1 thread = %3.3f sec - BLAS_VERSION unset; datasize=5000\n', time1);
setNumberOfComputationalThreads(numThreads);
tic;
C = A*B;
timeN=toc;
disp('Time for 2 threads = 0.059 sec - BLAS_VERSION set; datasize=500');
disp('Time for 2 threads = 0.043 sec - BLAS_VERSION set; datasize=500');
disp('Time for 2 threads = 39.382 sec - BLAS_VERSION set; datasize=5000');
disp('Time for 2 threads = 39.286 sec - BLAS_VERSION set; datasize=5000');
disp('Time for 2 threads = 39.371 sec - BLAS_VERSION set; datasize=5000');
fprintf('Time for %d threads = %3.3f sec - BLAS_VERSION set; datasize=5000\n', numThreads, timeN);
numThreads=4; % Number of threads to test
dataSize=5000; % Data size to test
A=rand(dataSize,dataSize); % Random square matrix
B=rand(dataSize,dataSize); % Random square matrix
setNumberOfComputationalThreads(numThreads);
tic;
C = A*B;
timeN=toc;
disp('Time for 4 threads = 19.925 sec - BLAS_VERSION set; datasize=5000');
disp('Time for 4 threads = 19.876 sec - BLAS_VERSION set; datasize=5000');
fprintf('Time for %d threads = %3.3f sec - BLAS_VERSION set; datasize=5000\n', numThreads, timeN);
numThreads=8; % Number of threads to test
dataSize=5000; % Data size to test
A=rand(dataSize,dataSize); % Random square matrix
B=rand(dataSize,dataSize); % Random square matrix
setNumberOfComputationalThreads(numThreads);
tic;
C = A*B;
timeN=toc;
disp('Time for 8 threads = 12.966 sec - BLAS_VERSION set; datasize=5000');
fprintf('Time for %d threads = %3.3f sec - BLAS_VERSION set; datasize=5000\n', numThreads, timeN);