Multinode Computation Example

Multinode computation refers to the possibility of distributing a every party across several nodes. MP-SPDZ uses the client interface for communication between nodes. This means that you have to run Scripts/ and distribute the certificates to run it across several machines.

In the following, we will explain the example in ../Programs/Source/ and ../Programs/Source/

First, the one main node per party, listens and accepts connections from the worker nodes in the same logical party:


ready = regint.Array(n_nodes_per_party)

def _(i):
  ready[accept_client_connection(15000)] = 1

runtime_error_if(sum(ready) != n_nodes_party, 'connection problems')

Maintaining ready helps spot errors but isn’t strictly necessary. Meanwhile, the workers connect to main node:

main = init_client_connection(host, 15000, worker_id)

Once the connection is established, the main node distributes the data among the workers:

def _(i):
  data.get_vector(base=i * n_ops_per_node,

This sends a different chunk data to every node. The workers then receive it and execute the computation (squaring every number in the example), and send the result back:

@for_range_opt_multithread(n_threads, n_ops)
def _(i):
  data[i] = data[i] ** 2


Finally, the main node receives the result:

def _(i):
  data.assign_vector(sint.read_from_socket(i, size=n_ops_per_node),
    base=i * n_ops_per_node)

You can execute example with three parties, four worker nodes per party, five threads per worker node, and 1000 operations per thread as follows:

for i in $(seq 0 3); do
  Scripts/ ring multinode_example_worker 5 1000 $i localhost & true

Scripts/ ring multinode_example_main 4 5 1000