Skip to content

Split gotoblas dispatch table by group / operation (1/2) - #6087

Open
topolarity wants to merge 4 commits into
OpenMathLib:developfrom
topolarity:ct/dispatch-split-prep
Open

topolarity wants to merge 4 commits into
OpenMathLib:developfrom
topolarity:ct/dispatch-split-prep

Conversation

@topolarity

@topolarity topolarity commented Oct 2, 2026 •

Copy link
Copy Markdown

This is a preliminary PR to prepare for splitting the monolithic gotoblas dispatch table, to allow functions to be GC'd by the linker when linking statically with -Wl,--gc-sections. See #6088 for the motivation (smaller binaries).

Changes (by commit) are:

  1. Add *_KERNEL_BASE #define, to allow for per-kernel dispatch tables.
  2. Add build system-generated dyn_cores.h to define OPENBLAS_CORE_LIST macro to enumerate the enabled cores for the build.
  3. Add per-group dispatch tables / dispatch.c and an enum to identify selected cores in each dispatch table.
  4. Add -ffunction-sections -fdata-sections to the build flags, so that -Wl,--gc-sections is effective once the dispatch table is split.

This PR does not yet use the split dispatch table. It is populated and initialized in PR 2 of this stack, which is separated since the changes were largely generated by script.

Claude Opus 5.5 was used to prepare these changes. I have reviewed all code by hand.

@topolarity topolarity changed the title Prepare for splitting dispatch cores by operation (1/2) Split gotoblas dispatch table by group / operation (1/2) Oct 2, 2026
topolarity and others added 2 commits October 2, 2026 00:52
No functional change.  With DYNAMIC_ARCH the small-matrix kernel tables in
interface/gemm*.c hold FUNC_OFFSET()s, which are offsets into gotoblas_t,
and add them to gotoblas.  Spell that base FUNC_BASE(func), next to
FUNC_OFFSET(func), and reach it through GEMM_SMALL_KERNEL_BASE in the same
way as the offsets themselves.

This lets the kernels move out of gotoblas_t without interface/gemm*.c
knowing where they went.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preparation for numbering the DYNAMIC_ARCH cores; nothing includes the
header yet.  dyn_cores.h holds one X-macro, OPENBLAS_CORE_LIST(X, arg),
which expands to X(CORE, arg) for each core of the build, in sorted order
and without duplicates.  Makefile.system and cmake/arch.cmake each write it
where they finish computing DYNAMIC_CORE.

dyn_cores.h is written by the top-level make only - sub-makes inherit
OPENBLAS_DYN_CORES - so that parallel sub-makes never rewrite it under a
compile.  It is emitted through $(HASH) because GNU Make 3.81 reads a
literal '#' inside $(shell ...) as a comment.  cmake rewrites it only when
the list changes, and puts it in the build directory, which the kernel
targets now have on their include path.  A stale copy left in the source
tree by make would shadow cmake's, so cmake refuses to configure with one
there, as it already does for config_kernel.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@topolarity
topolarity force-pushed the ct/dispatch-split-prep branch from 02bef9d to 61d7286 Compare October 2, 2026 00:55
topolarity and others added 2 commits October 2, 2026 01:35
Preparation for splitting the kernels out of gotoblas_t; nothing uses the
new macros yet.

  * common_param.h numbers the cores of the build, OPENBLAS_CORE_<CORE>,
    from OPENBLAS_CORE_LIST() in dyn_cores.h, and every core's gotoblas_t
    records its number in the new "core" field.

  * OPENBLAS_DISPATCH(group) is the running core's table for a group of
    kernels, from the array openblas_<group>_dispatch[], indexed by
    gotoblas->core.  driver/others/dispatch.c will define those arrays,
    with DEFINE_DISPATCH_TABLE(group).  OPENBLAS_DISPATCH_OFFSET/_BASE do
    for the offset tables of interface/gemm*.c what FUNC_OFFSET/FUNC_BASE
    do today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preparation for splitting the kernels out of gotoblas_t, later in this
series.  After that split, each core's kernel tables are defined together in
setparam_<CORE>.o, and all the per-group arrays together in dispatch.o; a
static link would keep all of them as soon as it kept any, and with them
every kernel.  Separate sections let --gc-sections keep only the groups a
program calls.

On its own this changes no static link size: every kernel is still
reachable from gotoblas_t.

Only for compilers known to accept the flags, and not for MSVC-style
frontends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant