MATLAB Job Submission on MatriCS
This example shows how to submit a MATLAB job on MatriCS.
To execute each section in this script you can either click on , or click on the blue bar on the left of the section Documentation and Examples
Cluster Configuration
- Choose the partition, the number of workers (or GPUs if using GPU servers partition), and the memory. (For advanced users, nb GPUs = nb Workers)
- For example:
- Partition: normal-amd
- Number of Workers: 4
- RAM per Worker (MB): 4000
- Click on Save to save the configuration.
Job Submission
In this example, the code being executed approximates the value of Pi using a Monte Carlo method. See the Job Submission section and the call to the @computePi function. The code that approximates pi is written in the Write Your Own Function section. You can write your own MATLAB function here and then test it. If you change the function name, remember to change it in the batch function as well. c = parcluster('MatriCS');
job = batch(c,@computePI,1,{10e3,10e3},Pool=c.PreferredPoolNumWorkers,CurrentFolder='.');
Monitor your job
To monitor your job you can click on Home and then on Parallel (Icon with 4 blue bars) then choose Monitor Jobs.
You can also just display the variable job
Otherwise in a terminal, you can view your job with the command:
Get the result
If the job has completed successfully, you should see the estimated value of pi displayed, approximately 3.14.
if job.State == "finished"
results = job.fetchOutputs
elseif job.State == "running"
disp(['Job state: ', job.State]);
Compute PI with Monte Carlo Method
function PI = computePI(m,n)
PI = 4/(m*n) * gather(c);
Write Your Own Function
Now to you: write your function and modify the batch command to call your function.
function out = myFunction(in)