开发者

How can I make an external toolbox available to a MATLAB Parallel Computing Toolbox job?

开发者 https://www.devze.com 2023-01-30 18:35 出处:网络
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 ext

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 or FileDependencies 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 contain ErrorMessage string, and possibly the Error.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 the PsychtoolboxPostInstallRoutine function, which is called at the very end of SetupPsychtoolbox. Specifically, you want to comment out the line AssertOpenGL (line 496, as of the time of this answer; this may change in future releases).

0

精彩评论

暂无评论...
验证码 换一张
取 消