Launching and Connecting

The Wolfram Language can run parallel kernels in a number of different ways: locally on the same machine or remote on other machines connected in a network. Furthermore, the network might be a homogeneous grid controlled by some dedicated management application, or it might be a heterogenous grid. To use all these different configurations, the Wolfram Language needs to launch the parallel kernels and then communicate with them. When working with remote machines, it is complicated to launch the parallel kernels. However the parallel kernels were launched, communication always uses WSTP.

Typically, the Wolfram Language launches parallel kernels automatically as they are needed. This uses settings from Parallel Preferences, but you can also launch kernels manually with the command LaunchKernels. This might be useful if you were running in a batch mode.

This section will discuss issues related to launching and connecting to parallel kernels. It will cover the different connection methods that are provided, each specialized to the different types of environment in which the Wolfram Language may be running.

Launching Kernels

Wolfram Language parallel computation will, typically, automatically launch kernels when a parallel command is executed. The kernels that are launched are those that are set in Parallel Preferences. The default setting is to launch kernels that run on the same computer, using the local kernels connection method; for a two-core machine there will be two parallel kernels. You can see the kernels that will be automatically launched with $ConfiguredKernels; in the following there will be two local kernels.

If you use LaunchKernels with no arguments, this will launch the kernels that have been configured. Here, the two kernels are launched.

Note that you do not need to use LaunchKernelsif instead you had used a parallel command such as ParallelTablethe kernels would also have been launched automatically.

At any time you can see the kernels that are running with Kernels. This shows the two kernels that have been launched.

You can also use LaunchKernels to launch kernels manually, without configuring them in the preferences. The details are different for each connection method and are described in the following sections.

The rest of this section now describes configuration and launching for each of the different connection methods.

Local Kernels

The local kernels connection method is used to run parallel kernels on the same computer as the master Wolfram Language. It is suitable for a multicore environment, and is the easiest way to set up for parallel computation.

Configuration of the local kernels connection method is done through Parallel Preferences. The configuration panel looks similar to the following.

1.gif

Since the parallel kernels are all launched on the same computer as the master kernel, this is the easiest to configure. The main question is the number of kernels to be launched; the automatic setting is to use the number of processor cores and the number of parallel kernel licenses.

The number of processor cores is given by $ProcessorCount; if you wish to change its value, you can unprotect it and assign a new value. Here, its value is 2.

The number of parallel kernel licenses is given by $MaxLicenseSubprocesses, which is controlled by the Wolfram System license. Here the value is 4.

A setting of 4 means that you can launch up to four parallel kernels.

Manual Launching

If you want to launch kernels manually and avoid the configuration mechanism, you can pass arguments directly to LaunchKernels. This might be useful if you were running the Wolfram Language in a batch mode directly from a command line.

LaunchKernels[num]launch num local kernels
LaunchKernels["localhost"]launch a local kernel
LaunchKernels[LocalMachine[num]]launch num local kernels
LaunchKernels[LocalMachine[cmd]]launch a local kernel using operatingsystem command cmd

Manual launching of local kernels.

The local kernels connection method supports launching local kernels directly from LaunchKernels by passing it an integer (setting the number of kernels) or by specifying the string localhost. In addition, you can give more detailed settings inside of LocalMachine. To do so, you must first load the LocalKernels` package, which is shown below.

Now you can pass arguments to LocalMachine. The following sets the number of local kernels to launch.

It might be more useful to change the command used to launch remote kernels. The default command is set by $mathkernel, which has a typical setting as follows.

You can pass the command directly into LocalMachine. The following would be suitable for a non-standard installation of the Wolfram System.

An alternative would be to modify the value of $mathkernel before launching any kernels.

Once you have launched the parallel kernels, then all the parallel functions of the Wolfram Language can be used.

The Lightweight Grid

The Lightweight Grid connection method is used to run parallel workers on different computers from the master Wolfram Language. It uses Wolfram Lightweight Grid technology to launch the Wolfram Language on the remote machines. It is suitable for a heterogeneous network and where there is no management technology.

Configuration of the Lightweight Grid connection method is done through Parallel Preferences. The configuration panel should look similar to the following.

2.gif

In this setup, the master kernel has found three other computers running a Lightweight Grid Manager and each is configured to run two kernels.

More information can be found in the Lightweight Grid documentation.

Manual Launching

If you want to launch kernels manually and avoid the configuration mechanism, you can pass arguments directly to LaunchKernels. This might be useful if you were running the Wolfram Language in a batch mode directly from a command line.

LaunchKernels[url]launch a kernel using the Lightweight Grid on server url
LaunchKernels[LightweightGrid[url]]launch a kernel using the Lightweight Grid on server url

Manual launching of Lightweight Grid kernels.

The Lightweight Grid connection method supports launching kernels directly from LaunchKernels by passing it the name of a Lightweight Grid manager. In addition, you can give more detailed settings inside of LightweightGrid. To do so you must first load the LightweightGridClient` package, which is shown below.

Now you use arguments in LightweightGrid when you launch a kernel. An example is shown below.

Once you have launched the parallel kernels, then all the parallel functions of the Wolfram Language can be used.

More information can be found in the Lightweight Grid documentation.

Cluster Integration

The Cluster Integration connection method is used to run parallel workers on different computers from the master Wolfram Language. It integrates with a large number of third party cluster management technologies.

Configuration of the Cluster Integration connection method is done through Parallel Preferences. The configuration panel should look similar to the following.

3.gif

In this setup one cluster has been configured to use Windows Computer Cluster Server, with a head node of clusterboss. Each machine is setup to run two kernels.

The Wolfram Language supports the following cluster management technologies:

Manual Launching

If you want to launch kernels manually and avoid the configuration mechanism, you can pass arguments directly to LaunchKernels. This might be useful if you were running the Wolfram Language in a batch mode directly from a command line.

LaunchKernels[cluster[args]]launch a kernel using Cluster Integration on cluster

Manual launching of Cluster Integration kernels.

The Cluster Integration connection method supports launching kernels directly from LaunchKernels. To do so, you must first load the ClusterIntegration` package, which is shown below.

To launch on a particular cluster, you have to pass the name for that cluster into LaunchKernels. For example, to use Windows Compute Cluster Server, you would use CCS. An example is shown below that launches two kernels.

Note that for this to work, you need to have Windows Compute Cluster Server configured to work.

Once you have launched the parallel kernels, then all the parallel functions of the Wolfram Language can be used.

More information can be found in the Cluster Integration documentation.

Remote Kernels

The remote kernels connection method is used to run parallel workers on different computers from the master Wolfram Language. It relies on using remote shell invocation technology for launching and is typically harder to configure and maintain.

Configuration of the remote kernels connection method is done through Parallel Preferences. The configuration panel should look similar to the following.

4.gif

In this configuration, two remote machines are configured each to provide four parallel kernels.

On Windows, the default setting is to use rsh to launch kernels on the remote machines; other platforms use ssh. This is because ssh is typically not available for Windows. Of course, any machines will have to be configured to allow remote shell invocation from the master machine.

You can modify the launch command that is used to launch the kernel. In the command, you can use a number of parameters that are inserted before the command is actually used. For example, the parameter `1` is used to refer to the name of the remote machine that is being used.

`1`the name of the remote machine
`2`the name of the link created on the local machine (when the remote machine is connecting)
`3`the user name to execute the remote shell
`4`the link protocol to use to for the WSTP connection

Launch command parameters.

The default value for the user name is to use $Username, the user running the local copy of the Wolfram Language.

Manual Launching

If you want to launch kernels manually and avoid the configuration mechanism, you can pass arguments directly to LaunchKernels. This might be useful if you were running the Wolfram Language in a batch mode directly from a command line.

LaunchKernels[RemoteMachine[host]]launch a remote kernel on machine host
LaunchKernels[RemoteMachine[host,num]]launch num remote kernels on machine host
LaunchKernels[RemoteMachine[host,command,num]]launch num remote kernels on machine host using command as a remote command

Manual launching of remote kernels.

The remote kernels connection method supports launching remote kernels directly from LaunchKernels. To do so you must first load the RemoteKernels` package, which is shown below.

To launch, you pass arguments in RemoteMachine. The following launches one remote kernel on machine remote1.wolfram.com.

It might be more useful to change the command used to launch remote kernels. The default command is set by $RemoteCommand, which has a typical setting as follows. Note that rsh is only used on Windows; on other platforms ssh is used.

Note that the parameters for the remote command are described in the previous section. The user name argument is set by $RemoteUsername, which is set by default to $Username.

You can pass the command directly into RemoteMachine. The following would be suitable for a non-standard installation of the Wolfram System.

An alternative would be to modify the value of $RemoteKernel before launching any kernels.

Once you have launched the parallel kernels, then all the parallel functions of the Wolfram Language can be used.

WSTPServer Kernels

The remote kernels connection method is used to run parallel workers on different computers from the master Wolfram Language. It can connect to running instances of WSTPServer, and request kernels from these servers.

Enabling the WSTPServer kernel connection method is done through Parallel Preferences. The configuration panel should look similar to the following. The kernels need to be configured manually.

5.gif

Manual Launching

WSTPServer kernels can be specified conveniently via an URL of the form wstp://server:port. The port number is optional.

You can specify the wstp: URLs directly as an argument of LaunchKernels.

Here, we ask for 2 kernels from the WSTPServer listening on a machine named "raspi4b".

WSTPServer kernels can also be included in $ConfiguredKernels. They need to be added as WSTPServerKernel[] items.

Once you have launched the parallel kernels, all the parallel functions of the Wolfram Language can be used.

Raw WSTP Connections

It is also possible to attach to kernels connected via WSTP links that have been set up manually.

In the following example, the application for raw link connections is loaded. Then another copy of the Wolfram Language is launched giving both -subkernel and -mathlink as command line options. Finally, this link is passed to LaunchKernels, making the remote kernel a worker kernel.