Main Content

getCurrentCluster

Get cluster object from a worker in a cluster

    Description

    example

    c = getCurrentCluster returns the parallel.Cluster object that the current worker is associated with. Use getCurrentCluster to get information from the cluster during a computation, such as the host name of the cluster's head node, credentials for the user that submitted a job, or the job storage location.

    If getCurrentCluster is evaluated on a worker, c is a parallel.Cluster object. Otherwise, c is an empty double.

    Examples

    collapse all

    Use the Host property to find the host name of the head node of the cluster which submitted the current task.

    On a worker, use getCurrentCluster to get the current cluster object c from a worker on the cluster c.

    c = getCurrentCluster;

    Then, use the Host property to get the host name of the head node of the cluster.

    host = c.Host;

    You can use the cluster object returned by getCurrentCluster to submit jobs.

    On a worker, use getCurrentCluster to get the current cluster object c from a worker on the cluster c.

    c = getCurrentCluster;

    You can use batch, createJob, or createCommunicatingJob to submit jobs to this cluster.

    Use batch to submit a job to the cluster c.

    j = batch(c,@magic,1,{3});

    Tip

    Avoid submitting jobs from a worker currently working on a job or task. When you create and submit jobs from a worker, you can recursively create and submit jobs. Recursive submission can create infinitely nested submissions which use a significant amount of the cluster's resources.

    Output Arguments

    collapse all

    Cluster object, specified as a parallel.Cluster or empty double. When you use getCurrentCluster on a worker, c is the parallel.Cluster object that the current worker is associated with. When you use getCurrentCluster on the client, c is an empty double.

    Data Types: parallel.cluster | double

    Introduced in R2012a