HPC/Applications/matlab/Compiler: Difference between revisions

From CNM Wiki
< HPC‎ | Applications‎ | matlab
Jump to navigation Jump to search
Line 37: Line 37:
   -N -p distcomp -p images \
   -N -p distcomp -p images \
** The toolboxes that can be given for the <code>-p</code> option are:
** The toolboxes that can be given for the <code>-p</code> option are:
  $ ls /opt/soft/matlab-R2013a-8/toolbox/
  $ ls $MATLAB_HOME/toolbox/
  compiler  '''curvefit  distcomp  images'''  local  matlab  '''optim'''  shared  '''stats'''
  compiler  '''curvefit  distcomp  images'''  local  matlab  '''optim'''  shared  '''stats'''



Revision as of 20:11, February 18, 2014

Introduction

As of R2013a, we have available a MATLAB compiler on Carbon. This compiler allows you to create standalone Linux binaries that do not need a MATLAB license token in order to run. It is therefore highly recommended to use this tool to enable your MATLAB scripts to run when you need them, regardless of other users' demands on our MATLAB license.

Note that the compiler is, unfortunatley, rather slow and unwieldy to use and leaves much to be desired. Compilation of a simple "hello world" script takes several minutes.

Documentation

Consult the vendor site for full documentation. Useful starting points:

Quickstart

  • Connect to clogin5 .
  • Locate your toplevel file and function, say file myfunc.m.
  • Create a target directory, deploydir.
mkdir deploydir

Basic compiler options

mcc -v \
	-o myname \
	-W main \
	-T link:exe \
	-d deploydir \
	myfunc.m
  • You must use a separate deploydir, and it must be a directory other than $PWD or "." Attempting to deploy into the current directory leads to an obscure runtime error "Compiled parallel application fails: distcompdeserialize".
  • -v is optional but useful to get progress info during the lengthy compile process.

Additional options

You can include the following lines, before naming your own .m file:

  • To always write a log file upon execution:
	-R '-logfile,myfile.log' \
  • The compilation is very slow, but may be sped up by removing toolboxes that are not used, and only adding those that are:
 	-N -p distcomp -p images \
    • The toolboxes that can be given for the -p option are:
$ ls $MATLAB_HOME/toolbox/
compiler  curvefit  distcomp  images  local  matlab  optim  shared  stats

Running the executable

cd deploydir
./run_myname.sh $MATLAB_HOME args-for-your-program

The run_myname.sh script will be generated by the compiler. It expects as its first argument a path to a MATLAB runtime. On Carbon, the main MATLAB installation directory can be used, whose path is provided by the matlab module file in the environment variable shown, following local conventions.