HPC/Applications/matlab/Compiler

From CNM Wiki
< HPC‎ | Applications‎ | matlab
Revision as of 18:14, February 18, 2014 by Stern (talk | contribs) (Created page with "== Introduction == As of 2013, we have available a MATLAB compiler on Carbon. This compiler allows you to create standalone Linux binaries that ''do not need a MATLAB license ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

As of 2013, 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 /opt/soft/matlab-R2013a-8/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.