Implementation:Ggml org Ggml Blas backend api
Appearance
Metadata
| Field | Value |
|---|---|
| Page Type | Implementation (API Header) |
| Knowledge Sources | GGML |
| Domains | ML_Infrastructure, Tensor_Computing, Linear_Algebra |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
Public header declaring the BLAS backend interface for accelerating matrix operations via libraries like OpenBLAS, MKL, Accelerate, BLIS, or NVPL.
Description
ggml-blas.h (25 lines) provides the minimal public API for the BLAS backend. It exposes four functions:
ggml_backend_blas_init()-- creates and returns a new BLAS backend instanceggml_backend_is_blas()-- checks whether a given backend is a BLAS backendggml_backend_blas_set_n_threads()-- configures thread count for float conversion and BLAS operations (for OpenBLAS and BLIS, this also sets the internal BLAS thread count)ggml_backend_blas_reg()-- returns the backend registration handle for dynamic discovery
All functions are marked with GGML_BACKEND_API for proper DLL export/import on Windows.
Usage
Include this header in application code to initialize and configure the BLAS backend for CPU-side matrix multiplication acceleration.
Code Reference
Source Location
GGML repo, file: include/ggml-blas.h, 25 lines.
Signature
GGML_BACKEND_API ggml_backend_t ggml_backend_blas_init(void);
GGML_BACKEND_API bool ggml_backend_is_blas(ggml_backend_t backend);
GGML_BACKEND_API void ggml_backend_blas_set_n_threads(ggml_backend_t backend_blas,
int n_threads);
GGML_BACKEND_API ggml_backend_reg_t ggml_backend_blas_reg(void);
Import
#include "ggml-blas.h"
Dependencies
ggml.h-- core GGML typesggml-backend.h-- backend abstraction types (ggml_backend_t,ggml_backend_reg_t)
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
backend |
ggml_backend_t |
Yes (for is_blas) | Backend instance to check. |
backend_blas |
ggml_backend_t |
Yes (for set_n_threads) | BLAS backend instance to configure. |
n_threads |
int |
Yes (for set_n_threads) | Number of threads for conversion and BLAS operations. |
Outputs
| Output | Type | Description |
|---|---|---|
| Backend handle | ggml_backend_t |
From ggml_backend_blas_init(): initialized BLAS backend.
|
| Is BLAS | bool |
From ggml_backend_is_blas(): true if the backend is BLAS-based.
|
| Registration | ggml_backend_reg_t |
From ggml_backend_blas_reg(): registration handle for backend discovery.
|
Usage Examples
Basic BLAS Backend Setup
#include "ggml-blas.h"
ggml_backend_t blas = ggml_backend_blas_init();
ggml_backend_blas_set_n_threads(blas, 8);
// ... use blas backend with scheduler ...
ggml_backend_free(blas);
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment