HPC/Applications/matlab/Compiler: Difference between revisions
m (→Introduction) |
m (→Quickstart) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
mkdir ''deploydir'' | mkdir ''deploydir'' | ||
== Basic compiler options == | === Basic compiler options === | ||
mcc -v \ | mcc -v \ | ||
-o ''myname'' \ | -o ''myname'' \ | ||
Line 29: | Line 29: | ||
* 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". | * 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. | * -v is optional but useful to get progress info during the lengthy compile process. | ||
* You only need to give the toplevel file ''myfunc''.m - mcc will locate and compile dependencies in the MATLAB search path. | |||
== Additional options == | === Additional options === | ||
You can include the following lines, ''before'' naming your own .m file: | You can include the following lines, ''before'' naming your own .m file: | ||
* To always write a log file upon execution: | * To always write a log file upon execution: | ||
Line 37: | Line 38: | ||
-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 | $ ls $MATLAB_HOME/toolbox/ | ||
compiler '''curvefit distcomp images''' local matlab '''optim''' shared '''stats''' | compiler '''curvefit distcomp images''' local matlab '''optim''' shared '''stats''' | ||
=== Cleanup === | |||
* The compiler places the binary as ''deploydir/myname'', and a couple of other files that you can remove or ignore: | |||
cd ''deploydir'' | |||
rm mccExcludedFiles.log readme.txt | |||
== Running the executable == | == Running the executable == |
Latest revision as of 21:44, 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:
- http://www.mathworks.com/help/compiler/
- or http://www.mathworks.com/help/releases/R2013a/compiler/
- http://www.mathworks.com/help/compiler/standalone-applications.html
- http://www.mathworks.com/help/compiler/compile-a-standalone-application-from-the-command-line.html
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.
- You only need to give the toplevel file myfunc.m - mcc will locate and compile dependencies in the MATLAB search path.
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:
- The toolboxes that can be given for the
$ ls $MATLAB_HOME/toolbox/ compiler curvefit distcomp images local matlab optim shared stats
Cleanup
- The compiler places the binary as deploydir/myname, and a couple of other files that you can remove or ignore:
cd deploydir rm mccExcludedFiles.log readme.txt
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.