Sperli: ranks that send each other messages

Sperli (Simple Parallel Execution over Remote Links Interface) is the cluster layer of Hilde: a job of n ranks, each a process on a listed host, that send and receive messages with a tag. It has the semantics of message passing (rank, size, send and receive with a tag) and none of the interface of MPI. The bytes on the wire are in the Sperli protocol; the refusals are the codes H1601 to H1625 of the error codes. This page describes point-to-point messages, the collectives, the checkpoints and the launcher; the C library follows the checkpoints.

Security

Security is not an option and has no switch.

hilde run

hilde run -n 3 --hosts hosts.txt ./app arguments

hilde run is carried out by hilde-launcher, which make builds beside hilde. The programme is the path of an executable that is the same on every host. The options:

OptionMeaning
-n Nthe number of ranks, 1 to 4096; required
--hosts FILEthe host list; required
--deny-hosts FILEnames to refuse besides those of SPERLI_REFUSED_HOSTS and the reserved ones, one a line
--checkpoint-dir DIR, --checkpoint-every SECONDS, --restart-max K, --resume JOB--checkpoint-dir and --restart-max make the launcher start a failed job again; the other two are read and kept

A host list has one host a line and an optional port: node1, node2 47001. A line that starts with # is a comment. Rank i runs on line i; there must be at least N lines. A rank on localhost or an address of 127. is started directly, gets a free port and listens at the loopback address its line names (127.0.0.1 for localhost); any other rank is started over ssh at port 62222 (ssh -p 62222 -o BatchMode=yes host program arguments, each word quoted) and listens at the port of its line, or at 47000 and its rank. The ranks' output is shown, rank by rank, when they have ended: [rank 1] text. The exit status is 0 when every rank ended with 0.

hilde run [--modules=d:d] FILE.hiq arguments is no job: it builds the module and runs its main on this machine, modules unchanged since an earlier build taken from the cache of compiled modules. It is told by the name ending in .hiq; the words after the file are the programme's own.

A rank

A rank reads its job from the first line of its standard input and joins:

let line: String := readLine(&!input);
case readJobText(asSpan(&line)) of
    when Right(right as job: Job) do
        case init(job) of
            when Right(right as opened: Comm) do
                var comm: Comm := opened;
                let sent: Int32 := send(&!comm, 1, 7, message);
                case recv(&!comm, 1, 7) of
                    when Right(right as text: String) do
                        destroyString(text);
                    when Left(left as code: Int32) do
                        skip;
                end case;
                finish(comm);
            when Left(left as code: Int32) do
                skip;
        end case;
    when Left(left as code: Int32) do
        skip;
end case;

Collectives

let code: Int32 := barrier(&!comm);
case allreduce(&!comm, int64Type(), sumReduction(), numbers) of
    when Right(right as total: String) do
        destroyString(total);
    when Left(left as code: Int32) do
        skip;
end case;
CallResult
barrier(comm)0 when every rank has called it
bcast(comm, root, data)the data of root on every rank
reduce(comm, root, type, operation, data)the reduction over all ranks at root; the empty string elsewhere
allreduce(comm, type, operation, data)the reduction on every rank
gather(comm, root, data)the blocks of all ranks in rank order at root; the empty string elsewhere
scatter(comm, root, data)block i of the data of root on rank i

Checkpoints

useCheckpoints(&!comm, "ckpt");
let code: Int32 := checkpoint(&!comm, &state);
case resume(&!comm) of
    when Right(right as back: String) do
        destroyString(back);
    when Left(left as code: Int32) do
        skip;
end case;

The C library

libsperli is the C interface of Sperli, for a programme that is not written in Hilde, such as the Go package. It is a static library and a header per target:

sh scripts/libsperli/build.sh

writes libsperli/c/<target>/libsperli.a and libsperli/c/<target>/sperli.h, with <target> one of linux, openbsd, freebsd and darwin, the system the script runs on. A programme links the library with -lpthread -ltls -lcrypto and includes sperli.h, which has the full text of every function.

FunctionCall
sperli_initjoins the job that a description names; gives the handle
sperli_rank, sperli_sizethe own rank, the number of ranks
sperli_send, sperli_recvone message to or from a rank with a tag
sperli_barrier, sperli_bcast, sperli_reduce, sperli_allreduce, sperli_gather, sperli_scatterthe collectives
sperli_resultcopies out the data a call kept
sperli_checkpoint_directory, sperli_checkpoint, sperli_resumethe checkpoints
sperli_finishleaves the job
sperli_describea sentence for a code
CodeNameMeaning
-1SPERLI_E_NULL_POINTERa pointer is NULL where bytes or a result are needed
-2SPERLI_E_BAD_LENGTHa length is zero where data is needed, or above its limit
-3SPERLI_E_BAD_RANKa rank is not in the job, or is the own rank where a peer is needed
-4SPERLI_E_BAD_TAGa tag is above 2147483647
-5SPERLI_E_BAD_HANDLEthe handle is not the live session
-6SPERLI_E_NOT_READYthe session holds no comm
-7SPERLI_E_BAD_TYPEan element type is above 6
-8SPERLI_E_BAD_OPERATIONa reduction is 0 or above 10
-9SPERLI_E_BUFFER_TOO_SMALLthe buffer is shorter than the result; the result is kept
-10SPERLI_E_NO_RESULTthere is no result to take
-11SPERLI_E_RESULT_PENDINGan earlier result has not been taken
-12SPERLI_E_BUSYanother call is running
-13SPERLI_E_ALREADY_INITIALISEDthe process holds a session already
-14SPERLI_E_BAD_PATHa path holds a zero byte
-15SPERLI_E_BAD_COUNTthe data is no whole number of elements or blocks
-16SPERLI_E_INTERNALthe core answered with a code that is none of these

Mixed jobs, the sum example and the benchmark

A job may mix Hilde ranks and ranks of the Go package (sperli, which uses libsperli); the wire, the certificates and the tokens are the same. The programmes and the scripts are:

PathWhat it is
examples/sperli-sumthe sum of a table of 3,000,000 rows over the ranks of a job; row i holds i + 1, so the total is 4500001500000
examples/sperli-benchlatency and bandwidth between two ranks: ping, echo, stream and sink
libsperli/test/mixedthe helpers of the tests: the descriptions of a job, and a rank 0 that is wrong in one chosen way
scripts/sperli/mixed-test.shthe mixed tests
scripts/sperli/bench.shthe benchmark
PairRound trip, meanBandwidth
Hilde and Hilde68 us90.1 MB/s
Hilde (rank 0) and Go381 us4.3 MB/s
Go and Go547 us4.3 MB/s

Files

A rank writes its CA, certificate and key to a directory sperli-<job>-<rank> of the working directory, readable only by its user, and removes them when it has joined the job or failed to. It needs a working directory it may write in.