Matlab Runtime Libraries

CTC clusters V2, V3, Development, and serial have just the MATLAB runtime libraries installed (rather than the full package). This enables the execution of both serial jobs and parallel batch jobs that have been compiled with the multitask toolbox. It precludes starting matlab from the start menu or the command line. Thus, it is expected that parallel program development will be performed in interactive mode on machines where a full copy of MATLAB, including the multitask toolbox and MPI/Pro, have been installed, such as the CTC login machines and Collaboratory. Then, when a properly running program has been produced, minor modifications to it can be made and it can be compiled there. Finally, production runs of the code can be done in batch mode on the clusters.
 
Compilation and Setup
 
To compile a matlab code first call setup_matlab.bat.  Then, presuming that the code you want to compile is mypi.m, issue the command
mcc -m mypi
This will produce at least two files, mypi.exe and mypi.ctf.  Next, you will submit a batch job to a machine where the matlab runtime libraries are installed.  Both mypi.exe and mypi.ctf must be in the same directory when you run the code.
 
Note: The version of matlab used to compile must match that of the runtime libraries. In the .bat file, call the appropriate setup file.
  • R2007a: call setup_matlabruntime2007a.bat
  • R2006a: call setup_matlabruntime2006a.bat

    Sample Batch Command File

    • Here is a sample batch file that you can copy and modify. You may also view an in-depth explanation of the sample batch file.
    • In addition to modifying the xml elements in the sample batch file, users will need to set some variables.

    Variable List:

    Variable
     Description
    Example
    ROOTDIR
    the H: directory containing the compiled matlab .exe and .ctf files
    set ROOTDIR = \\tc.cornell.edu\tc\users\%USERNAME%\matlab_runtime
    OUTDIR 
    the directory to which the output will be written
    set OUTDIR=%ROOTDIR%\output
    CODE
    the root of the .exe and .ctf files
    set CODE=mypi
    Toolboxes
     
    All toolboxes available under the Cornell site license can be used with the matlab runtime libraries.  There is a smaller set of matlab toolboxes available on CTC machines with matlab installed.  If you compile matlab on a non-CTC machine, the executable should run using the runtime libraries on the CTC machines.  Note: The version of matlab used to compile must match that of the runtime libraries.
     
     
    Toolbox
    Version
    MATLAB
    7.4
    Simulink
    6.6
    Bioinformatics Toolbox
    2.5
    Cornell Multitask Toolbox
    0.954
    Curve Fitting Toolbox
    1.1.7
    Database Toolbox
    3.3
    Datafeed Toolbox
    2.0
    Excel Link
    2.5
    Financial Derivatives Toolbox
    5.0
    Financial Toolbox
    3.2
    Fixed-Income Toolbox
    1.3
    GARCH Toolbox
    2.3.1
    Genetic Algorithm and Direct Search Toolbox
    2.1
    MATLAB Builder for .NET
    2.2
    MATLAB Builder for Excel
    1.2.8
    MATLAB Compiler
    4.6
    MATLAB Report Generator
    3.2
    Neural Network Toolbox
    5.0.2
    Optimization Toolbox
    3.1.1
    Partial Differential Equation Toolbox
    1.0.10
    Spline Toolbox
    3.3.2
    Statistics Toolbox
    6.0
    Virtual Reality Toolbox
    4.5

     
    Interactive CMTM
     
    To get started then, one should use a workstation running Windows 2000 or XP, MATLAB 6.5 or later, the multitask toolbox, and MPI/Pro. Write the initial version of your program for executation in interactive mode.
    Here is a "Hello, World" example for two copies of MATLABŪ using the multitask toolbox: MM_Eval(1,'message=''Hello, World'';'); MM_Eval(1,'MMPI_Send(message,0,1);'); message=MMPI_Recv(1,1)
     
    This program could be entered at the command prompt in the window for the master task after initializing the multitask toolbox with MM_Init(2) , or it could be placed in a file named MM_run.m and it would be executed automatically when the multitask toolbox is initialized.
     
    In general, to run a parallel program interactively, start with MM_Init() to start up the appropriate number of tasks, use one or more MM_Eval calls to run code on them (either using actual command strings or by referencing m-files) and call MM_Finalize to shut down the extra tasks and leave only the master MATLAB running. If your goal is ultimately to create a compiled code to run in batch mode, avoid any calls to other first class (MM_) functions because they will have to be removed before compilation.
     
    Compiled CMTM
     
    If you have a parallel code that runs interactively, you will have to make a few changes to make it compilable. Whatever commands you issued at the console of the master MATLAB must now be coded into a main m-function that will be executed on all nodes. This main function (or a child) will also need to call MMPI_Init and MMPI_Finalize where MM_Init and MM_Finalize were before. To eliminate MM_Eval calls, put in if..end blocks based on the task's rank to cause functions to be evaluated on different tasks. See the Applications section for examples.
     
    Before compiling the code, make sure that the multitask toolbox library, cmtmlib.lib, is in the path and that your path also includes mpipro.lib. Then issue the command:
    mcc -Glm mymain cmtmlib.lib mpipro.lib
    This will produce an executable named mymain.exe in the current directory. It should be runnable on any parallel cluster using a batch script of the kind described below.
     
    Note to CTC users: If you compile in the Collaboratory, you must start Matlab from a command window, not from the Start menu or a desktop shortcut. Open a command window and type:

    C:\Matlab6p5p1\bin\win32\matlab

    to start MATLAB. The reason for this is that MATLAB opens a command shell to carry out its compilation and if a command shell is opened in a context that doesn't derive from a command shell, login.bat will be run, wiping out your path.
     
    If you will not be running the code at CTC, you need to follow whatever procedures for running parallel jobs with MPI/Pro that your site has established.
     
    CMTM Guidelines for use with CTC clusters
     
    The only way to run code that uses the multitask toolbox on the batch nodes at CTC is to compile it into a MPI/Pro application first. Once you have a compiled application, running it is not much different from running any other mpi applicatoin with one exception. Before calling mpirun for the compiled application, insert the following line in your batch script: set path=%PATH%;C:\MATLAB6p5\bin\win32 this adds the directory containing the MATLAB runtime libraries to your path so your executable will be able to find them.