| 213 | |
| 214 | == Compiled Matlab == |
| 215 | === Compiling Matlab Scripts using mcc === |
| 216 | Start an interactive session with idev, load the intel-psxe module (if you want to use mkl and multithreading), load the matlab module |
| 217 | |
| 218 | {{{ |
| 219 | [tulaneID@cypress1 ~]$ idev |
| 220 | Requesting 1 node(s) task(s) to normal queue of defq partition |
| 221 | 1 task(s)/node, 20 cpu(s)/task, 2 MIC device(s)/node |
| 222 | Time: 0 (hr) 60 (min). |
| 223 | Submitted batch job 80102 |
| 224 | JOBID=80102 begin on cypress01-036 |
| 225 | --> Creating interactive terminal session (login) on node cypress01-036. |
| 226 | --> You have 0 (hr) 60 (min). |
| 227 | --> Assigned Host List : /tmp/idev_nodes_file_tulaneID |
| 228 | Last login: Tue Sep 22 16:27:39 2015 from cypress1.cm.cluster |
| 229 | [tulaneID@cypress01-036 ~]$ module load intel-psxe |
| 230 | [tulaneID@cypress01-036 ~]$ module load matlab |
| 231 | [tulaneID@cypress01-036 ~]$ |
| 232 | }}} |
| 233 | |
| 234 | cd to the directory containing your matlab file and compile using matlabs C compiler {{{mcc -m <your matlab .m file>}}}. If your script is spread over many files you need to specify the directories containing those files {{{mcc -m -I <source directory> <your matlab .m file>}}}. For example, to compile my_script.m which depends on other .m files located in /home/tulaneID/myMatlab I would run |
| 235 | {{{ |
| 236 | mcc -m -I /home/tulaneID/myMatlab my_script.m |
| 237 | }}} |
| 238 | This will compile files that my_script.m depends upon provided they are in /home/tulaneID/myMatlab |
| 239 | |
| 240 | === Executing Compiled scripts === |
| 241 | The above will create a binary executable named my_script. To run the executable as a SLRUM Job, just include the matlab module in your SLURM script. This will provide all the necessary libraries. For example, |
| 242 | {{{#!bash |
| 243 | #!/bin/bash |
| 244 | #SBATCH --qos=normal # Quality of Service |
| 245 | #SBATCH --job-name=my_script # Job Name |
| 246 | #SBATCH --time=1-0:00:00 # WallTime |
| 247 | #SBATCH --nodes=1 # Number of Nodes |
| 248 | #SBATCH --ntasks-per-node=1 # Number of tasks (MPI processes) |
| 249 | #SBATCH --cpus-per-task=1 # Number of threads per task (OMP threads) |
| 250 | |
| 251 | module load matlab |
| 252 | |
| 253 | ./my_script |
| 254 | }}} |