GithubHelp home page GithubHelp logo

matlab-batch's Introduction

BATCH

Distributed Matlab job execution library.

  • High-level Matlab wrapper over computing grid infrastracture.
  • Matlab parallel processing toolbox not required.

Currently following job schedulers are supported.

  • Sun Grid Engine (qsub)
  • Platform LSF (bsub)
  • Matlab Parallel Computing Toolbox supporting parpool
  • Fake scheduler for debugging

Example

The following code shows an example of distributing 100 data points to 5 distributed jobs. Note the function handle @(x)x+1 takes a vector with 100 / 5 = 20 elements at each distributed job.

addpath('/path/to/matlab-batch');
scheduler = createJobScheduler('ShardSize', 5);
input_data = 1:100;
output_data = scheduler.execute(@(x)x+1, input_data);
disp(output_data);

The function can be a char or a function handle. The function must take a single input argument of split data and return a corresponding output for the input data. You may pass any array to the scheduler, as long as the input and the output contains the same number of elements. To process a complex input, use a struct array instead of a numeric array.

function exampleBatchUsage()
%EXAMPLEBATCHUSAGE Another usage example.
  scheduler = SGEJobScheduler('ShardSize', 5, ...
                              'ExtraOptions', '-l hostname=host1');
  input_data = struct('index', num2cell(1:100));
  additional_input = 'some flag';
  output_data = scheduler.execute(@processBatch, ...
                                  input_data, ...
                                  additional_input);
end

function data = processBatch(data, varargin)
%PROCESSBATCH This function takes a split batch of input data.
  [data.result] = deal([]);
  for i = 1:numel(data)
    data(i).result = complicatedFunction(data(i), varargin{:});
  end
end

Tips

  • Be careful about the data size. If you assign large data to each element of the output, you will run out of memory. To generate large data in the output, save them in an external file and return an array of file names.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.