compiled_matlab_on_igrida
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
compiled_matlab_on_igrida [2013/07/20 11:26] – created samer | compiled_matlab_on_igrida [2014/03/02 17:44] (current) – [Preparing the Scripts] samer | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===test=== | + | ======Compile your MATLAB scripts and submit as a batch job======= |
+ | This tutorial details the procedure to compile your MATLAB script and launch it as an OAR batch job on IGRIDA. | ||
+ | |||
+ | =====Logging In===== | ||
+ | Start by connecting the IGRIDA frontend using SSH: | ||
+ | <code bash> | ||
+ | mymachine%ssh mylogin@igrida-oar-frontend | ||
+ | </ | ||
+ | |||
+ | When at the IGRIDA front-end, start an interactive job: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%oarsub -I | ||
+ | </ | ||
+ | |||
+ | =====Preparing the Scripts===== | ||
+ | |||
+ | Let us assume that your main MATLAB function is called '' | ||
+ | |||
+ | <file bash main_foo.m> | ||
+ | function main_foo(x, | ||
+ | a=x+y; | ||
+ | c=sec_foo(a, | ||
+ | matFilename = sprintf('/ | ||
+ | save(matFilename,' | ||
+ | </ | ||
+ | |||
+ | <file bash sec_foo.m> | ||
+ | function c = sec_foo(a, | ||
+ | c=a*x; | ||
+ | </ | ||
+ | |||
+ | In order to compile your scripts, you can use the '' | ||
+ | |||
+ | <code bash> | ||
+ | igrida01-01%module load matlab | ||
+ | igrida01-01%/ | ||
+ | </ | ||
+ | |||
+ | Now, you have got an executable called main_foo that you test on the command line by typing: | ||
+ | <code bash> | ||
+ | igrida01-01%./ | ||
+ | </ | ||
+ | You can now exit the interactive OAR session and get back to the frontend. | ||
+ | =====Preparing the OAR jobs===== | ||
+ | Let us suppose that you need to run hundreds of simulations of your MATLAB compiled script. You can choose to modify your MATLAB scripts and add iterating loops (then recompile). Then, you can follow this [[matlab_script_on_igrida|tutorial]] to run your job. However, with this method, you launch a single OAR job and do not take full advantage of the computing facilities on IGRIDA. | ||
+ | In order to run multiple jobs, you can write a launcher script as in '' | ||
+ | |||
+ | <file bash oar_launcher.sh> | ||
+ | # | ||
+ | for i in {1..10}; | ||
+ | do | ||
+ | for j in {1..10}; | ||
+ | do | ||
+ | echo "# | ||
+ | echo " | ||
+ | echo " | ||
+ | echo "#OAR -l core=10, | ||
+ | echo "#OAR -O / | ||
+ | echo "#OAR -E / | ||
+ | echo 'echo "My job was ran on these nodes:"' | ||
+ | echo 'cat $OAR_NODEFILE' | ||
+ | echo "# | ||
+ | echo ' | ||
+ | echo 'mkdir -p $MCR_CACHE_ROOT' | ||
+ | echo "#cd to your execution directory first" >> job$i$j.sh | ||
+ | echo "cd / | ||
+ | echo " | ||
+ | echo "# | ||
+ | echo '/ | ||
+ | | ||
+ | done; | ||
+ | |||
+ | for k in job*; | ||
+ | do | ||
+ | chmod +x $k; | ||
+ | oarsub -S $k; | ||
+ | done; | ||
+ | </ | ||
+ | |||
+ | Do not forget to create your log directory: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%mkdir -p / | ||
+ | </ | ||
+ | |||
+ | Prepare you OAR launch script to be executed: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%chmod +x oar-launcher.sh | ||
+ | </ | ||
+ | |||
+ | =====Launching the Job===== | ||
+ | You can now launch your jobs by simply calling your launcher script as in the following: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%./ | ||
+ | [ADMISSION RULE] Modify resource description with type constraints | ||
+ | [ADMISSION RULE] Job walltime greater than 4 hours, adding property duration_weight > 2 (large job). | ||
+ | Generate a job key... | ||
+ | OAR_JOB_ID=666666 | ||
+ | [ADMISSION RULE] Modify resource description with type constraints | ||
+ | [ADMISSION RULE] Job walltime greater than 4 hours, adding property duration_weight > 2 (large job). | ||
+ | Generate a job key... | ||
+ | OAR_JOB_ID=777777 | ||
+ | </ | ||
+ | |||
+ | Step back and watch your jobs being successively created then executed. | ||
+ | |||
+ | =====Verifying the Output===== | ||
+ | If you need to follow the execution of your job, you can check the status of all your jobs: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%oarstat -f | grep mylogin | ||
+ | </ | ||
+ | |||
+ | and verify the output or the errors generated using a specific job ID: | ||
+ | <code bash> | ||
+ | igrida-oar-frontend%more / | ||
+ | igrida-oar-frontend%more / | ||
+ | </ |
compiled_matlab_on_igrida.1374312392.txt.gz · Last modified: 2014/01/11 05:24 (external edit)