v1 version and measurements
This commit is contained in:
@@ -12,7 +12,10 @@ function [D2] = dist2(X, Y)
|
||||
if d1 ~= d2
|
||||
error('X,Y column dimensions must match');
|
||||
end
|
||||
%D2 = sqrt((X.^2)*ones(d,m) -2*X*Y' + ones(n,d)*(Y.^2)');
|
||||
% debug
|
||||
%X_norm = sum(X.^2, 2);
|
||||
%Y_norm = sum(Y.^2, 2)';
|
||||
%XY = 2 * X*Y';
|
||||
D2 = max(sum(X.^2, 2) - 2 * X*Y' + sum(Y.^2, 2)', 0);
|
||||
D2 = sqrt(D2);
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
% Plot measurements
|
||||
|
||||
accuracy = [100 80 60 40 20 10];
|
||||
ser_sift_acc = [ 4395 4365 4384 4315 4295 4246 ];
|
||||
ser_mnist_ser_acc = [ 7936 7924 7886 7903 7844 7801 ];
|
||||
|
||||
omp_sift_acc = [
|
||||
4093 4098 4040 4001 3980 3937
|
||||
];
|
||||
omp_mnist_acc = [
|
||||
7575 7463 7389 7416 7321 7303
|
||||
];
|
||||
|
||||
cilk_sift_acc = [
|
||||
3718 3739 3673 3668 3608 3557
|
||||
];
|
||||
cilk_mnist_acc = [
|
||||
7064 7071 7035 6948 6962 6913
|
||||
];
|
||||
|
||||
pth_sift_acc = [
|
||||
1157 1159 1121 1100 1084 1075
|
||||
];
|
||||
pth_mnist_acc = [
|
||||
2050 2086 2040 2020 2004 1979
|
||||
];
|
||||
|
||||
% 1ο Διάγραμμα: OMP
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(accuracy, ser_sift_acc, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(accuracy, ser_mnist_ser_acc, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(accuracy, omp_sift_acc, '-^', 'DisplayName', 'OMP SIFT');
|
||||
plot(accuracy, omp_mnist_acc, '-d', 'DisplayName', 'OMP MNIST');
|
||||
hold off;
|
||||
title('OMP');
|
||||
xlabel('Accuracy (%)');
|
||||
ylabel('Execution Time [msec]');
|
||||
set(gca, 'XDir', 'reverse'); % reverse x
|
||||
legend('Location', 'northwest');
|
||||
grid on;
|
||||
print(gcf, 'OMP_over_accuracy.png', '-dpng', '-r300');
|
||||
|
||||
% 2ο Διάγραμμα: CILK
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(accuracy, ser_sift_acc, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(accuracy, ser_mnist_ser_acc, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(accuracy, cilk_sift_acc, '-^', 'DisplayName', 'CILK SIFT');
|
||||
plot(accuracy, cilk_mnist_acc, '-d', 'DisplayName', 'CILK MNIST');
|
||||
hold off;
|
||||
title('CILK');
|
||||
xlabel('Accuracy (%)');
|
||||
ylabel('Execution Time [msec]');
|
||||
set(gca, 'XDir', 'reverse'); % reverse x
|
||||
legend('Location', 'northwest');
|
||||
grid on;
|
||||
print(gcf, 'CILK_over_accuracy.png', '-dpng', '-r300');
|
||||
|
||||
% 3ο Διάγραμμα: Pthreads
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(accuracy, ser_sift_acc, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(accuracy, ser_mnist_ser_acc, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(accuracy, pth_sift_acc, '-^', 'DisplayName', 'Pthreads SIFT');
|
||||
plot(accuracy, pth_mnist_acc, '-d', 'DisplayName', 'Pthreads MNIST');
|
||||
hold off;
|
||||
title('Pthreads');
|
||||
xlabel('Accuracy (%)');
|
||||
ylabel('Execution Time [msec]');
|
||||
set(gca, 'XDir', 'reverse'); % reverse x
|
||||
legend('Location', 'northwest');
|
||||
grid on;
|
||||
print(gcf, 'Pthreads_over_accuracy.png', '-dpng', '-r300');
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
% Plot measurements
|
||||
|
||||
threads = [1 2 4 6 8 10 12];
|
||||
ser_sift_threads = [ 4418 4418 4418 4418 4418 4418 4418 ];
|
||||
ser_mnist_ser_threads = [ 7924 7924 7924 7924 7924 7924 7924 ];
|
||||
|
||||
omp_sift_th = [
|
||||
4469 4283 4096 3822 4060 4241 5193
|
||||
];
|
||||
omp_mnist_th = [
|
||||
8053 7806 7465 6828 7662 8013 8123
|
||||
];
|
||||
|
||||
cilk_sift_th = [
|
||||
4225 4090 3696 3122 3860 4141 5103
|
||||
];
|
||||
cilk_mnist_th = [
|
||||
7744 7206 6965 6628 7362 7813 8123
|
||||
];
|
||||
|
||||
pth_sift_th = [
|
||||
4254 2155 1133 877 724 640 682
|
||||
];
|
||||
pth_mnist_th = [
|
||||
7889 3963 2058 1445 1496 1379 1352
|
||||
];
|
||||
|
||||
% 1ο Διάγραμμα: OMP
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(threads, ser_sift_threads, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(threads, ser_mnist_ser_threads, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(threads, omp_sift_th, '-^', 'DisplayName', 'OMP SIFT');
|
||||
plot(threads, omp_mnist_th, '-d', 'DisplayName', 'OMP MNIST');
|
||||
hold off;
|
||||
title('OMP');
|
||||
xlabel('Threads');
|
||||
ylabel('Execution Time [msec]');
|
||||
legend('Location', 'northeast');
|
||||
grid on;
|
||||
print(gcf, 'OMP_over_threads.png', '-dpng', '-r300');
|
||||
|
||||
% 2ο Διάγραμμα: CILK
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(threads, ser_sift_threads, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(threads, ser_mnist_ser_threads, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(threads, cilk_sift_th, '-^', 'DisplayName', 'CILK SIFT');
|
||||
plot(threads, cilk_mnist_th, '-d', 'DisplayName', 'CILK MNIST');
|
||||
hold off;
|
||||
title('CILK');
|
||||
xlabel('Threads');
|
||||
ylabel('Execution Time [msec]');
|
||||
legend('Location', 'northeast');
|
||||
grid on;
|
||||
print(gcf, 'CILK_over_threads.png', '-dpng', '-r300');
|
||||
|
||||
% 3ο Διάγραμμα: Pthreads
|
||||
figure;
|
||||
set(gcf, 'Position', [100, 100, 1280, 720]); % Set the figure size to HD
|
||||
plot(threads, ser_sift_threads, '-o', 'DisplayName', 'Serial SIFT');
|
||||
hold on;
|
||||
plot(threads, ser_mnist_ser_threads, '-s', 'DisplayName', 'Serial MNIST');
|
||||
plot(threads, pth_sift_th, '-^', 'DisplayName', 'Pthreads SIFT');
|
||||
plot(threads, pth_mnist_th, '-d', 'DisplayName', 'Pthreads MNIST');
|
||||
hold off;
|
||||
title('Pthreads');
|
||||
xlabel('Threads');
|
||||
ylabel('Execution Time [msec]');
|
||||
legend('Location', 'northeast');
|
||||
grid on;
|
||||
print(gcf, 'Pthreads_over_threads.png', '-dpng', '-r300');
|
||||
|
||||
@@ -2,6 +2,106 @@
|
||||
%
|
||||
%
|
||||
|
||||
|
||||
%
|
||||
%
|
||||
%
|
||||
C1 = [
|
||||
0.8147 0.1576;
|
||||
0.9058 0.9706;
|
||||
0.1270 0.9572;
|
||||
0.9134 0.4854;
|
||||
0.6324 0.8003;
|
||||
0.0975 0.1419;
|
||||
0.2785 0.4218;
|
||||
0.5469 0.9157;
|
||||
0.9575 0.7922;
|
||||
0.9649 0.9595 ];
|
||||
|
||||
Q1 = [
|
||||
0.6557 0.7577;
|
||||
0.0357 0.7431;
|
||||
0.8491 0.3922;
|
||||
0.9340 0.6555;
|
||||
0.6787 0.1712 ];
|
||||
|
||||
C2 = [
|
||||
0.7060 0.4456 0.5060 0.6160;
|
||||
0.0318 0.6463 0.6991 0.4733;
|
||||
0.2769 0.7094 0.8909 0.3517;
|
||||
0.0462 0.7547 0.9593 0.8308;
|
||||
0.0971 0.2760 0.5472 0.5853;
|
||||
0.8235 0.6797 0.1386 0.5497;
|
||||
0.6948 0.6551 0.1493 0.9172;
|
||||
0.3171 0.1626 0.2575 0.2858;
|
||||
0.9502 0.1190 0.8407 0.7572;
|
||||
0.0344 0.4984 0.2543 0.7537;
|
||||
0.4387 0.9597 0.8143 0.3804;
|
||||
0.3816 0.3404 0.2435 0.5678;
|
||||
0.7655 0.5853 0.9293 0.0759;
|
||||
0.7952 0.2238 0.3500 0.0540;
|
||||
0.1869 0.7513 0.1966 0.5308;
|
||||
0.4898 0.2551 0.2511 0.7792 ];
|
||||
|
||||
Q2 = [
|
||||
0.9340 0.3112 0.4505 0.0782;
|
||||
0.1299 0.5285 0.0838 0.4427;
|
||||
0.5688 0.1656 0.2290 0.1067;
|
||||
0.4694 0.6020 0.9133 0.9619;
|
||||
0.0119 0.2630 0.1524 0.0046;
|
||||
0.3371 0.6541 0.8258 0.7749;
|
||||
0.1622 0.6892 0.5383 0.8173;
|
||||
0.7943 0.7482 0.9961 0.8687 ];
|
||||
|
||||
D1_exp = [
|
||||
0.6208 0.9745 0.2371 0.5120 0.1367;
|
||||
0.3284 0.8993 0.5811 0.3164 0.8310;
|
||||
0.5651 0.2327 0.9169 0.8616 0.9603;
|
||||
0.3749 0.9147 0.1132 0.1713 0.3921;
|
||||
0.0485 0.5994 0.4621 0.3346 0.6308;
|
||||
0.8312 0.6044 0.7922 0.9815 0.5819;
|
||||
0.5052 0.4028 0.5714 0.6959 0.4722;
|
||||
0.1919 0.5395 0.6045 0.4665 0.7561;
|
||||
0.3037 0.9231 0.4144 0.1387 0.6807;
|
||||
0.3692 0.9540 0.5790 0.3056 0.8386 ];
|
||||
|
||||
|
||||
D2_exp = [
|
||||
0.6020 0.7396 0.6583 0.6050 1.0070 0.5542 0.6298 0.6352;
|
||||
1.0696 0.6348 0.9353 0.6914 0.8160 0.4475 0.4037 0.9145;
|
||||
0.9268 0.8450 0.9376 0.6492 0.9671 0.4360 0.5956 0.7400;
|
||||
1.3455 0.9876 1.2953 0.4709 1.2557 0.3402 0.4417 0.7500;
|
||||
0.9839 0.5476 0.7517 0.7216 0.7074 0.5605 0.4784 0.9954;
|
||||
0.6839 0.7200 0.7305 0.9495 1.0628 0.8718 0.8178 0.9179;
|
||||
0.9850 0.7514 0.9585 0.7996 1.2054 0.7784 0.6680 0.8591;
|
||||
0.6950 0.4730 0.3103 1.0504 0.4397 0.8967 0.8140 1.2066;
|
||||
0.8065 1.2298 0.9722 0.7153 1.3933 0.8141 1.0204 0.6758;
|
||||
1.1572 0.3686 0.9031 0.8232 0.7921 0.6656 0.3708 1.0970;
|
||||
0.9432 0.9049 1.0320 0.6905 1.1167 0.5094 0.6455 0.6653;
|
||||
0.7672 0.3740 0.5277 0.8247 0.6842 0.6945 0.5648 0.9968;
|
||||
0.5768 1.1210 0.8403 0.9345 1.1316 0.8292 1.0380 0.8127;
|
||||
0.1939 0.8703 0.2684 1.1794 0.8103 1.0683 1.1115 1.1646;
|
||||
1.0106 0.2708 0.8184 0.8954 0.7402 0.6982 0.4509 1.0594;
|
||||
0.8554 0.5878 0.6834 0.7699 0.9155 0.7161 0.6162 0.9481 ];
|
||||
|
||||
% tests
|
||||
D1 = dist2(C1, Q1);
|
||||
if norm (D1-pdist2(C1, Q1), 'fro') > 0.01
|
||||
disp('Error in dist2(C1, Q1)');
|
||||
end
|
||||
|
||||
D2 = dist2(C2, Q2);
|
||||
if norm (D2-pdist2(C2, Q2), 'fro') > 0.01
|
||||
disp('Error in dist2(C2, Q2)');
|
||||
end
|
||||
|
||||
D2 = dist2(C2, C2);
|
||||
if norm (D2-pdist2(C2, C2), 'fro') > 0.01
|
||||
disp('Error in dist2(C2, C2)');
|
||||
end
|
||||
|
||||
|
||||
|
||||
%C = rand(10000, 2); % Corpus
|
||||
%Q = rand(10000, 2); % Queries
|
||||
C = rand(20000, 2); % Δύο clusters
|
||||
|
||||
Reference in New Issue
Block a user