==> include/mesh/args.h <==1/* @ajax/mesh-args: meshd's command line (args.rs; hand-rolled: a dozen flags
2 * do not need a parser). Errors are the Rust's, word for word; the CUDA-only
3 * flags are refused under another backend (no silent ignoring). */
4#ifndef MESH_ARGS_H
5#define MESH_ARGS_H
6
7#include "mesh/backend.h"
8#include "mesh/cluster_conf.h"
9#include "mesh/strmap.h"
10
11#include <stdbool.h>
12#include <stdint.h>
13
14#define MESH_ARGS_USAGE \
15 "usage: meshd [--backend cuda|metal|wasm (default: metal on macOS, else cuda; wasm: CPU programs only)] [--programs out/programs] " \
16 "[--autoload] [--state FILE] [--wasm-cache DIR] [--sms N] [--control 127.0.0.1:7700] [--http 0.0.0.0:8088] [--cluster FILE " \
17 "--system K | --system 0 --peer HOST:7701 | --system 1 --peer-listen ADDR:7701] [--fleet-state FILE (a fleet member's term, vote " \
18 "and desired state; required with --cluster/--peer)] [--jobs-state FILE (the job table's log; default: the fleet state's " \
19 "FILE.jobs)] [--blobs DIR (job items' payloads; default: the fleet state's FILE.blobs)] [--blobs-cap MB (default 4096)] " \
20 "[--nvjitlink /usr/local/cuda/lib64] [--cuda-lib DIR (or $MESH_CUDA_LIB)] [--isolation blink|mps [--mps-dir DIR] [--mps-pool 8]] " \
21 "[--logs DIR (native workers' output; default logs)] [--models DIR (native workers' model files: MESH_MODELS)] (--sms, " \
22 "--nvjitlink, --cuda-lib, --isolation, --mps-*: CUDA only)"
23
24/* The platform's backend when --backend is not given: Metal on macOS, CUDA elsewhere. */
25#ifdef __APPLE__
26#define MESH_DEFAULT_BACKEND MESH_BACKEND_METAL
27#else
28#define MESH_DEFAULT_BACKEND MESH_BACKEND_CUDA
29#endif
30
31typedef struct {
32 uint32_t backend;
33 char *wasm_cache; /* NULL: none */
34 bool has_sms;
35 uint32_t sms;
36 char *control, *http;
37 bool has_system;
38 uint32_t system;
39 bool cluster; /* false: a single machine */
40 mcc_topology topo;
41 char *nvjitlink, *programs, *state; /* state: NULL none */
42 bool autoload;
43 mesh_isolation_mode isolation;
44 char *mps_dir;
45 bool has_mps_pool;
46 uint32_t mps_pool;
47 char *logs, *fleet_state, *jobs_state, *blobs, *models; /* NULL: none */
48 uint64_t blobs_cap_mb;
49 bool has_keys; /* --cluster FILE: its keys (the inference services' addresses) */
50 ms_map keys;
51} mesh_args;
52
53/* --backend alone (main needs it first): 0 and *kind, or -1 and *err. */
54int mesh_args_backend_of(int argc, char **argv, uint32_t *kind, char **err);
55/* The command line (argv without the program name): 0, or -1 and *err (USAGE for --help). */
56int mesh_args_parse(int argc, char **argv, mesh_args *a, char **err);
57void mesh_args_free(mesh_args *a);
58
59#endif