diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 17:56:18 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-25 17:56:18 +0200 |
| commit | 417f861f3661c2253258b5683a627d961e81fc68 (patch) | |
| tree | 54b3a7019dc05dcb2db610005920ac95b406a92f | |
| parent | 22626c7f1bd540e6f90b524be38320a546b4d025 (diff) | |
| download | ffwd-417f861f3661c2253258b5683a627d961e81fc68.tar.gz ffwd-417f861f3661c2253258b5683a627d961e81fc68.zip | |
build: update build info and accelerator labels
| -rw-r--r-- | libffwd/build.h | 14 | ||||
| -rw-r--r-- | libffwd/ffwd.h | 30 | ||||
| -rw-r--r-- | libffwd/platform.h | 8 | ||||
| -rw-r--r-- | tools/cli/main.c | 6 | ||||
| -rw-r--r-- | tools/server/main.c | 6 |
5 files changed, 30 insertions, 34 deletions
diff --git a/libffwd/build.h b/libffwd/build.h index 01073d5..a133163 100644 --- a/libffwd/build.h +++ b/libffwd/build.h @@ -37,13 +37,13 @@ static inline void ffwd_print_version(const char *prog) { printf("%s %s (%s/%s)\n", prog, FFWD_VERSION, FFWD_BUILD_OS, FFWD_BUILD_ARCH); } -static inline void ffwd_print_build_info(const char *prog) { - ffwd_print_version(prog); - printf("backend: %s\n" - "compiler: %s\n" - "built: %s\n" - "commit: %s\n", - ffwd_capability(), __VERSION__, FFWD_BUILD_DATE, FFWD_BUILD_COMMIT); +static inline void ffwd_print_build_info() { + const char *backend = ffwd_capability(); /* empty on a CPU build */ + printf("Built: %s (commit %s)\n" + "Compiler: %s\n", + FFWD_BUILD_DATE, FFWD_BUILD_COMMIT, __VERSION__); + if (backend[0]) + printf("Accelerator: %s\n", backend); } #endif /* FFWD_BUILD_H */ diff --git a/libffwd/ffwd.h b/libffwd/ffwd.h index 6f947b6..03a8e26 100644 --- a/libffwd/ffwd.h +++ b/libffwd/ffwd.h @@ -115,8 +115,8 @@ typedef struct { * Engine API — the backend-selected inference handle * * This is the library's primary public interface and the entire supported - * surface of the shared library. Exactly one backend (CPU, Apple Silicon GPU, - * or NVIDIA GPU) is linked at build time and implements these functions; + * surface of the shared library. Exactly one backend (CPU, Apple Metal, or + * NVIDIA CUDA) is linked at build time and implements these functions; * callers never branch on the backend. The CLI, the server, and any language * binding use only these functions plus the math helpers below. * @@ -165,8 +165,8 @@ FFWD_API int ffwd_init(const ffwd_options_t *opts, char *err, size_t errlen); /* First load phase, on the caller's thread: load a CPU model now, or record what * a GPU build will load in ffwd_activate. is_late selects a late-interaction * model. NULL on failure with a reason in err. */ -FFWD_API ffwd_t *ffwd_open( - const char *model_dir, int is_late, const ffwd_options_t *opts, char *err, size_t errlen); +FFWD_API ffwd_t * +ffwd_open(const char *model_dir, int is_late, const ffwd_options_t *opts, char *err, size_t errlen); /* Second load phase, on the inference thread: create the GPU context. CPU * no-op. Returns -1 with a reason in err on failure. */ FFWD_API int ffwd_activate(ffwd_t *e, char *err, size_t errlen); @@ -184,21 +184,19 @@ FFWD_API int ffwd_token_dim(const ffwd_t *e); FFWD_API int ffwd_uses_dense_batches(const ffwd_t *e); /* Encode a packed batch into out[batch, hidden_size]. Returns 0 on success. */ -FFWD_API int -ffwd_encode_batch(ffwd_t *e, const ffwd_input_t *inputs, int batch, float *out); +FFWD_API int ffwd_encode_batch(ffwd_t *e, const ffwd_input_t *inputs, int batch, float *out); /* Encode a contextual document batch, pooling each selected span in order. */ -FFWD_API int ffwd_encode_spans_batch(ffwd_t *e, - const ffwd_context_input_t *inputs, - int batch, - float *out); +FFWD_API int +ffwd_encode_spans_batch(ffwd_t *e, const ffwd_context_input_t *inputs, int batch, float *out); /* Score one query against its candidate documents into scores[n_docs]. */ FFWD_API int ffwd_rerank(ffwd_t *e, const ffwd_rerank_input_t *in, float *scores); /* Scratch memory the model currently holds, for diagnostics; 0 on GPU. */ FFWD_API size_t ffwd_scratch_nbytes(const ffwd_t *e); -/* Capability label for --build-info and the startup banner: "CPU", "Apple - * Silicon GPU", or "NVIDIA GPU". A function, not a macro, so a shared object - * does not bake in one backend's label and stays correct across a rebuild. */ +/* Accelerator label for --build-info and the startup banner: "Apple Metal", + * "NVIDIA CUDA", or "" on a CPU build. A function, not a macro, so a shared + * object does not bake in one backend's label and stays correct across a + * rebuild. */ FFWD_API const char *ffwd_capability(void); /* First-arrival micro-batch wait the backend prefers, in microseconds. */ @@ -248,15 +246,13 @@ typedef struct { /* Load the tokenizer for the model in model_dir and resolve its special-token * ids. is_late additionally resolves the late-interaction [Q]/[D]/[MASK] ids. * NULL on failure with a reason in err. */ -FFWD_API ffwd_tok_t * -ffwd_tok_open(const char *model_dir, int is_late, char *err, size_t errlen); +FFWD_API ffwd_tok_t *ffwd_tok_open(const char *model_dir, int is_late, char *err, size_t errlen); FFWD_API void ffwd_tok_free(ffwd_tok_t *t); /* Tokenize text for this model: applies the model's special-token layout and * optionally prepends a query instruction. Returns a malloc'd id array (caller * frees) and sets *n_out. NULL on error. */ -FFWD_API int * -ffwd_tokenize(ffwd_tok_t *t, const char *text, const char *query_instruct, int *n_out); +FFWD_API int *ffwd_tokenize(ffwd_tok_t *t, const char *text, const char *query_instruct, int *n_out); /* Late-interaction tokenization: [Q]/[D] prefix, [MASK]-pad queries to a fixed * length, and mark the document positions to score. Returns 0 on success. */ diff --git a/libffwd/platform.h b/libffwd/platform.h index 3c92c98..0575a43 100644 --- a/libffwd/platform.h +++ b/libffwd/platform.h @@ -15,13 +15,13 @@ # endif #endif -/* Hardware-class label for --build-info and the startup banner. */ +/* Accelerator label for --build-info and the startup banner; empty on CPU. */ #if defined(USE_MLX) -# define FFWD_BACKEND_LABEL "Apple Silicon GPU" +# define FFWD_BACKEND_LABEL "Apple Metal" #elif defined(USE_CUDA) -# define FFWD_BACKEND_LABEL "NVIDIA GPU" +# define FFWD_BACKEND_LABEL "NVIDIA CUDA" #else -# define FFWD_BACKEND_LABEL "CPU" +# define FFWD_BACKEND_LABEL "" #endif #endif /* FFWD_PLATFORM_H */ diff --git a/tools/cli/main.c b/tools/cli/main.c index d9516b8..bb6f2f8 100644 --- a/tools/cli/main.c +++ b/tools/cli/main.c @@ -310,7 +310,7 @@ static void print_matrix(const float *embs, int n, int dim, int json, int print_ if (j) putchar(','); printf("%.6f", (double)ffwd_cosine_similarity(embs + (size_t)i * dim, - embs + (size_t)j * dim, dim)); + embs + (size_t)j * dim, dim)); } putchar(']'); } @@ -323,7 +323,7 @@ static void print_matrix(const float *embs, int n, int dim, int json, int print_ if (j) putchar(' '); printf("%.6f", (double)ffwd_cosine_similarity(embs + (size_t)i * dim, - embs + (size_t)j * dim, dim)); + embs + (size_t)j * dim, dim)); } putchar('\n'); } @@ -459,7 +459,7 @@ int main(int argc, char *argv[]) { ffwd_print_version(prog); return 0; } else if (!strcmp(f, "--build-info")) { - ffwd_print_build_info(prog); + ffwd_print_build_info(); return 0; } else if (!strcmp(f, "-t") || !strcmp(f, "--threads")) { opts.n_threads = atoi(argv[++arg_start]); diff --git a/tools/server/main.c b/tools/server/main.c index 1cbdc3b..b94d438 100644 --- a/tools/server/main.c +++ b/tools/server/main.c @@ -225,7 +225,7 @@ int main(int argc, char *argv[]) { free_model_specs(&model_specs); return 0; } else if (!strcmp(f, "--build-info")) { - ffwd_print_build_info(prog); + ffwd_print_build_info(); free_model_specs(&model_specs); return 0; } else if (!strcmp(f, "--model")) { @@ -235,8 +235,8 @@ int main(int argc, char *argv[]) { return 1; } } else if (!strcmp(f, "--contextual-model")) { - if (arg + 1 >= argc || append_model_spec(&model_specs, argv[++arg], - FFWD_SERVER_MODEL_CONTEXTUAL, f) != 0) { + if (arg + 1 >= argc || + append_model_spec(&model_specs, argv[++arg], FFWD_SERVER_MODEL_CONTEXTUAL, f) != 0) { free_model_specs(&model_specs); return 1; } |
