Changes between Version 17 and Version 18 of cypress/Matlab


Ignore:
Timestamp:
10/21/25 12:25:33 (3 days ago)
Author:
fuji
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • cypress/Matlab

    v17 v18  
    88
    99See [https://wiki.hpc.tulane.edu/trac/wiki/cypress/Matlab#CompiledMatlab]
     10== MATLAB Modules ==
     11{{{
     12[fuji@cypress1 ~]$ module av matlab
     13
     14----------------------------------------------- /share/apps/modulefiles ------------------------------------------------
     15matlab/r2013b matlab/r2015a matlab/r2015b matlab/r2016a matlab/r2017b matlab/r2020a
     16
     17------------------------------------------- /share/apps/centos7/modulefiles --------------------------------------------
     18matlab/r2022b matlab/r2023a
     19}}}
    1020
    1121== Running MATLAB interactively ==
     22Download example:
     23{{{
     24git clone https://hidekiCCS:@bitbucket.org/hidekiCCS/hpc-workshop.git
     25}}}
     26
    1227Start an interactive session,
    1328{{{#!bash
    14 [fuji@cypress2 ~]$ idev
    15 Requesting 1 node(s)  task(s) to normal queue of defq partition
    16 1 task(s)/node, 20 cpu(s)/task, 2 MIC device(s)/node
     29[fuji@cypress1 ~]$ idev --partition=centos7
     30Requesting 1 node(s)  task(s) to normal queue of centos7 partition
     311 task(s)/node, 20 cpu(s)/task, 0 MIC device(s)/node
    1732Time: 0 (hr) 60 (min).
    18 Submitted batch job 47343
    19 JOBID=47343 begin on cypress01-063
    20 --> Creating interactive terminal session (login) on node cypress01-063.
     330d 0h 60m
     34Submitted batch job 3262352
     35JOBID=3262352 begin on cypress01-066
     36--> Creating interactive terminal session (login) on node cypress01-066.
    2137--> You have 0 (hr) 60 (min).
    22 Last login: Mon Jun  8 20:18:50 2015 from cypress1.cm.cluster
     38--> Assigned Host List : /tmp/idev_nodes_file_fuji
     39Last login: Tue Oct 21 12:13:06 2025 from cypress1.cm.cluster
    2340}}}
    2441Load the module
    2542{{{#!bash
    26 [fuji@cypress01-063 ~]$ module load matlab
     43[fuji@cypress01-066 ~]$ module load matlab/r2023a
    2744}}}
    2845Run MATLAB on the command-line window,
    2946{{{#!bash
    30 [fuji@cypress01-063 ~]$ matlab -nodisplay -nosplash
    31 MATLAB is selecting SOFTWARE OPENGL rendering.
    32 
    33                                                                                          < M A T L A B (R) >
    34                                                                                Copyright 1984-2015 The MathWorks, Inc.
    35                                                                                R2015a (8.5.0.197613) 64-bit (glnxa64)
    36                                                                                           February 12, 2015
    37 
    38 
    39 To get started, type one of these: helpwin, helpdesk, or demo.
     47[fuji@cypress01-066 ~]$ matlab -nodisplay -nosplash
     48
     49                                                < M A T L A B (R) >
     50                                      Copyright 1984-2023 The MathWorks, Inc.
     51                                 R2023a Update 5 (9.14.0.2337262) 64-bit (glnxa64)
     52                                                   July 24, 2023
     53
     54
     55To get started, type doc.
    4056For product information, visit www.mathworks.com.
    4157
    42 
    43         Academic License
    44 
    4558>>
    4659}}}
    47 You will get to the MATLAB command-line and can run MATLAB code here but no graphics.
     60You will get to the MATLAB command-line and can run MATLAB code here, but '''no graphics'''.
    4861
    4962=== Running MATLAB interactively with GUI ===
     
    6881}}}
    6982
    70 Note that your Matlab session will be killed when the session time exceeds the walltime limit.
     83Note that your MATLAB session will be killed when the session time exceeds the walltime limit.
    7184
    7285== Running MATLAB in a batch mode ==
     
    7588{{{#!bash
    7689#!/bin/bash
    77 #SBATCH --qos=normal            # Quality of Service
     90#SBATCH --partition=centos7     # Partition
     91#SBATCH --qos=normal            # Quality of Service
    7892#SBATCH --job-name=matlab     # Job Name
    7993#SBATCH --time=24:00:00         # WallTime
     
    8296#SBATCH --cpus-per-task=1       # Number of threads per task (OMP threads)
    8397
    84 module load matlab
     98module load matlab/r2023a
    8599matlab -nodesktop -nodisplay -nosplash < mymatlabprog.m
    86100}}}
     
    111125}}}
    112126
    113 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
     127cd to the directory containing your MATLAB file and compile using MATLAB's 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
    114128{{{
    115129mcc -m -I /home/tulaneID/myMatlab my_script.m
     
    142156=== Running MATLAB in Parallel with Multithreads ===
    143157MATLAB supports multithreaded computation for a number of functions and expressions that are combinations of element-wise functions.
    144 These functions automatically execute on multiple threads if data size is large enough.
    145 Note that on Cypress, by default, ~~~MATLAB runs with a single threads~~~, '''MATLAB utilizes the maximum number of cores, regardless of the number requested''', and therefore, you have to explicitly specify the number of threads in your code.
     158These functions automatically execute on multiple threads if the data size is large enough.
     159Note that on Cypress, by default, ~~MATLAB runs with a single threads~~, '''MATLAB utilizes the maximum number of cores, regardless of the number requested''', and therefore, you have to explicitly specify the number of threads in your code.
    146160For example,
    147161{{{#!matlab
     
    164178}}}
    165179
    166 In above code, the line,
     180In the above code, the line,
    167181{{{#!matlab
    168182LASTN = maxNumCompThreads(str2num(getenv('SLURM_JOB_CPUS_PER_NODE')));
     
    224238}}}
    225239
    226 ''!CreateWorker.m'' is a Matlab code to create workers.
     240''!CreateWorker.m'' is a MATLAB code to create workers.
    227241{{{#!matlab
    228242% Parallel Tool Box Test "CreateWorker.m"
     
    281295
    282296=== Running MATLAB with Automatic Offload ===
    283 Internally MATLAB uses Intel MKL Basic Linear Algebra Subroutines (BLAS) and Linear Algebra package (LAPACK) routines to perform the underlying computations when running on Intel processors.
     297Internally, MATLAB uses Intel MKL Basic Linear Algebra Subroutines (BLAS) and Linear Algebra package (LAPACK) routines to perform the underlying computations when running on Intel processors.
    284298
    285299Intel MKL includes Automatic Offload (AO) feature that enables computationally intensive Intel MKL functions to offload partial workload to attached '''Intel Xeon Phi''' coprocessors automatically and transparently.
     
    312326enables Intel MKL Automatic Offload (AO).
    313327
    314 The sample cose is below:
     328The sample code is below:
    315329{{{#!matlab
    316330%
     
    357371 * Effective Work Division
    358372 * Time spent on Host during call
    359  * Time spent on each available Phi coprocessor during call
     373 * Time spent on each available Phi coprocessor during the call
    360374
    361375* Setting OFFLOAD_REPORT to 2 results in a report including everything from 1, and in addition: