As a continuation of this question and the subsequent answer, does anyone know how 开发者_开发技巧to have a job created using the Parallel Computing Toolbox (using createJob
and createTask
) access external toolboxes? Is there a configuration parameter I can specify when creating the function to specify toolboxes that should be loaded?
According to this section of the documentation, one way you can do this is to specify either the 'PathDependencies'
property or the 'FileDependencies'
property of the job object so that it points to the functions you need the job's workers to be able to use.
You should be able to point the way to the KbCheck
function in PsychToolbox, along with any other functions or directories needed for KbCheck
to work properly. It would look something like this:
obj = createJob('PathDependencies',{'path_to_KbCheck',...
'path_to_other_PTB_functions'});
A few comments, based on my work troubleshooting this:
It appears that there are inconsistencies with how well nested functions and anonymous functions work with the Parallel Computation toolkit. I was unable to get them to work, while others have been able to. (Also see here.) As such, I would recommend having each function stored in it's own file, and including those files using the
PathDependencies
orFileDependencies
properties, as described by gnovice above.It is very hard to troubleshoot the Parallel Computation toolkit, as everything happens outside your view. Use breakpoints liberally in your code, and the
inspect
command is your friend. Also note that if there is an error, task objects will contain an error parameter, which in turn will containErrorMessage
string, and possibly theError.causes
MException object. Both of these were immensely useful in debugging.When including Psychtoolbox, you need to do it as follows. First, create a
jobStartup.m
file with the following lines:PTB_path = '/Users/eliezerk/Documents/MATLAB/Psychtoolbox3/'; addpath( PTB_path ); cd( PTB_path ); SetupPsychtoolbox;
However, since the Parallel Computation toolkit can't handle any graphics functionality, running
SetupPsychtoolbox
as-is will actually cause your thread to crash. To avoid this, you need to edit thePsychtoolboxPostInstallRoutine
function, which is called at the very end ofSetupPsychtoolbox
. Specifically, you want to comment out the lineAssertOpenGL
(line 496, as of the time of this answer; this may change in future releases).
精彩评论