Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6a7cce2d authored by Nicolas Bellot's avatar Nicolas Bellot Committed by hhakim
Browse files

test speed up matlab

parent 89ff8cd2
No related branches found
No related tags found
No related merge requests found
...@@ -217,7 +217,7 @@ end ...@@ -217,7 +217,7 @@ end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isa(A,'float') P =@(z) A*z; Pt =@(z) A'*z; if isa(A,'float') P =@(z) A*z; Pt =@(z) A'*z;
elseif isobject(A) P =@(z) A*z; trans_A=A'; Pt =@(z) trans_A*z;%% modification nicolas bellot elseif isobject(A) P =@(z) A*z; Pt =@(z) A'*z;%% modification nicolas bellot
elseif isa(A,'function_handle') elseif isa(A,'function_handle')
try try
if isa(Pt,'function_handle'); P=A; if isa(Pt,'function_handle'); P=A;
...@@ -437,4 +437,4 @@ end ...@@ -437,4 +437,4 @@ end
% Change history % Change history
% %
% 8 of Februray: Algo does no longer stop if dictionary is not normaliesd. % 8 of Februray: Algo does no longer stop if dictionary is not normaliesd.
\ No newline at end of file
...@@ -33,7 +33,8 @@ if(BUILD_MATLAB_MEX_FILES) ...@@ -33,7 +33,8 @@ if(BUILD_MATLAB_MEX_FILES)
add_test(NAME FAUST_MEG_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;hier_fact_test('config_MEG',22450,100);catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)") add_test(NAME FAUST_MEG_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;hier_fact_test('config_MEG',22450,100);catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)")
add_test(NAME FAUST_HADAMARD_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;hier_fact_test('config_HADAMARD',5941,1);catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)") add_test(NAME FAUST_HADAMARD_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;hier_fact_test('config_HADAMARD',5941,1);catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)")
add_test(NAME DEMO_MATLAB COMMAND matlab -nodesktop -r "try;testpass=0;addpath('${FAUST_MATLAB_INSTALL_DIR}');setup_FAUST;run_all_demo;catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)") add_test(NAME DEMO_MATLAB COMMAND matlab -nodesktop -r "try;testpass=0;addpath('${FAUST_MATLAB_INSTALL_DIR}');setup_FAUST;run_all_demo;catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)")
add_test(NAME MATLAB_FAUST COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;test_matlab_faust;catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)") add_test(NAME FAUST_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;test_matlab_faust;catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)")
add_test(NAME SPEED_FAUST_MEX COMMAND matlab -nojvm -r "try;testpass=0;addpath('${FAUST_BIN_TEST_BIN_DIR}','${FAUST_BIN_TEST_TOOLS_DIR}');set_path;test_matlab_faust_time;catch ME ;testpass=-1;disp(getReport(ME)); end ; exit(testpass)")
...@@ -43,7 +44,7 @@ if(BUILD_MATLAB_MEX_FILES) ...@@ -43,7 +44,7 @@ if(BUILD_MATLAB_MEX_FILES)
set_tests_properties(FAUST_HIER_MEX FAUST_HADAMARD_MEX PROPERTIES TIMEOUT 100) set_tests_properties(FAUST_HIER_MEX FAUST_HADAMARD_MEX PROPERTIES TIMEOUT 100)
set_tests_properties(DEMO_MATLAB PROPERTIES TIMEOUT 6000) set_tests_properties(DEMO_MATLAB PROPERTIES TIMEOUT 6000)
set_tests_properties(MATLAB_FAUST PROPERTIES TIMEOUT 15) set_tests_properties(FAUST_MEX PROPERTIES TIMEOUT 30)
set_tests_properties(FAUST_MEG_MEX PROPERTIES TIMEOUT ${TIMEOUT_MEG}) set_tests_properties(FAUST_MEG_MEX PROPERTIES TIMEOUT ${TIMEOUT_MEG})
endif() endif()
...@@ -102,7 +103,7 @@ if (BUILD_MATLAB_MEX_FILES) ...@@ -102,7 +103,7 @@ if (BUILD_MATLAB_MEX_FILES)
configure_file(${FAUST_SRC_TEST_TOOL_DIR}/set_path.m.in ${FAUST_BIN_TEST_TOOLS_DIR}/set_path.m @ONLY) configure_file(${FAUST_SRC_TEST_TOOL_DIR}/set_path.m.in ${FAUST_BIN_TEST_TOOLS_DIR}/set_path.m @ONLY)
foreach(matlabtest hier_fact_test.m test_matlab_faust.m) foreach(matlabtest hier_fact_test.m test_matlab_faust.m test_matlab_faust_time.m)
configure_file(${FAUST_SRC_TEST_SRC_DIR}/${matlabtest} ${FAUST_BIN_TEST_BIN_DIR}/${matlabtest} @ONLY) configure_file(${FAUST_SRC_TEST_SRC_DIR}/${matlabtest} ${FAUST_BIN_TEST_BIN_DIR}/${matlabtest} @ONLY)
endforeach() endforeach()
endif(BUILD_MATLAB_MEX_FILES) endif(BUILD_MATLAB_MEX_FILES)
......
%% Description test_faust_transform
% This script tests the malab_faust class, i.e the different method
% overloaded for a faust (constructor, size, mtimes, mtimes_trans ...)
nb_fact = 3;
dim1 = 8000;
dim2 = 200;
dim3 = 10;
int_max= 100;
nb_transposition = 100;
nb_multiplication_vector = 100;
disp('****** TEST MATLAB_FAUST ******* ');
%% creation du faust
disp(' TEST CONSTRUCTOR : ');
factors=cell(1,nb_fact);
factors{1}=double(randi(int_max,dim1,dim2));
for i=2:nb_fact
factors{i}=double(randi(int_max,dim2,dim2));
end
F = matlab_faust(factors);
disp('Ok');
%
%%% transpose test
disp('TEST TRANSPOSE : ');
disp('operation F_trans = F'' ');
t_trans=zeros(nb_transposition,1);
for i=1:nb_transposition
disp([int2str(i) '/' int2str(nb_transposition)]);
tic
F_trans=F';
t_trans(i)=toc;
end
disp(['time trans ' num2str(mean(t_trans)) ]);
disp('Ok');
%% test faust multiplication with vector
disp('TEST MULTIPLICATION BY A VECTOR : ');
x=zeros(dim2,1);
x(:)=1:dim2;
x_trans=zeros(dim1,1);
x_trans(:)=1:dim1;
F_dense=get_product(F);
y_expected = F_dense*x;
y_expected_trans = F_dense'*x_trans;
t_times=zeros(nb_multiplication_vector,1);
t_trans_times=zeros(nb_multiplication_vector,1);
t_mult_fun=zeros(nb_multiplication_vector,1);
t_trans_mult_fun=zeros(nb_multiplication_vector,1);
for i=1:nb_multiplication_vector
disp([int2str(i) '/' int2str(nb_multiplication_vector)]);
%% F*x
tic
y_star = F*x;
t_times(i)=toc;
if (y_expected ~= y_star)
error(['multiplication faust-vector : invalid result within the precision ' num2str(threshold)]);
end
%% F'*x
tic
y_star_trans = F'*x_trans;
t_trans_times(i) = toc;
if (y_expected_trans~= y_star_trans)
error(['multiplication faust-vector with transposition : invalid result within the precision ' num2str(threshold)]);
end
%% mtimes_trans(F,x_trans,'T');
tic
y_mtimes_trans = mtimes_trans(F,x_trans,'T');
t_mtimes_trans(i) = toc;
if (y_expected_trans ~= y_mtimes_trans)
error(['multiplication faust-vector with transposition : invalid result within the precision ' num2str(threshold)]);
end
%% mtimes_trans(F,x,'N');
tic
y_mtimes = mtimes_trans(F,x,'N');
t_mtimes(i) = toc;
if (y_expected ~= y_mtimes)
error(['multiplication faust-vector : invalid result within the precision ' num2str(threshold)]);
end
end
disp(['tps A=A'' ' num2str(mean(t_trans))]);
disp(['tps A*x : ' num2str(mean(t_times))]);
disp(['tps A''*x : ' num2str(mean(t_trans_times))]);
disp(['tps mtimes_trans(F,x,''N'') : ' num2str(mean(t_mtimes))]);
disp(['tps mtimes_trans(F,x_trans,''T'') : ' num2str(mean(t_mtimes_trans))]);
disp('Ok');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment