SIGN-IN

Webinar "Profiling function vectorization in Matlab/Octave" - 12:00pm

Date Wednesday September 30 2015
Time 12:00 - 13:00
Location Online
Contact syam@sharcnet.ca
URL http://vidyo.computecanada.ca/flex.html?roomdirect.html&key=Pr1GiEI51kFi
You are NOT registered for this event. Register.

Topic: “Profiling function vectorization in Matlab/Octave”

Speaker: James Desjardins, SHARCNET


Matlab is a productive tool for interacting with and performing calculations on multi-dimensional numeric arrays. When performing calculations on multi-dimensional arrays some forms of the procedures do not scale well and result in a poor performance for large arrays. In this seminar we will explore profiling tools for monitoring the performance of operations in Matlab and compare different forms of simple operations on three dimensional numeric arrays. The example data are taken from an electroencephalograophic (EEG) recording and the operations performed are relevant to typical procedures found in EEG processing pipelines. Although the specific examples come from EEG research, the procedures explored here are widely generalizable.

Example: given a three dimensional “data” array, subtracting the row means from the original array.

The temptation is to try:

outdata=data-mean(data,2);

…generating the error “Matrix dimensions must agree.”

The explicit nested for loop form is:

for rind=1:size(data,1); for pind=1:size(data,3); outdata(rind,:,pind)=data(rind,:,pind)-mean(data(rind,:,pind),2); end; end;

Using repmat expansion of an intermediate array:

outdata=data-repmat(mean(data,2),1,size(data,2));

Using bsxfun singlton dimension expansion:

outdata=bsxfun(@minus,data,mean(data,2));

From profiling these procedures the benefits of using bsxfun become clear in terms of performance. Specifically, a single call to minus without the need to generate an intermediate array. During this seminar the example of using bsxfun for the mean subtraction will then be expanded to a more complex procedure of correlating rows of the data array. Other topics covered in this seminar will include options for parallel processing and performance comparisons using Octave on SHARCNET.


Need help attending a webinar? See the SHARCNET Help Wiki.