Skip to content

Add optional huge-page-backed memory pool#940

Draft
jeffhammond wants to merge 1 commit into
flame:masterfrom
jeffhammond:feature/hugepage-pool
Draft

Add optional huge-page-backed memory pool#940
jeffhammond wants to merge 1 commit into
flame:masterfrom
jeffhammond:feature/hugepage-pool

Conversation

@jeffhammond

Copy link
Copy Markdown
Member

Back BLIS's internal memory pools (the packed A/B/C buffers streamed by level-3 ops) with explicit huge pages when the OS provides them, reducing dTLB pressure and page walks for large operands.

New allocator bli_hugepage_malloc / bli_hugepage_free (malloc/free- compatible) plug into BLIS_MALLOC_POOL / BLIS_FREE_POOL exactly like the existing libmemkind hbw_malloc hook. Per block, largest page first: 1 GiB hugetlb (MAP_HUGE_1GB) for >=1 GiB requests, then 2 MiB hugetlb (MAP_HUGE_2MB) for >=2 MiB, else ordinary malloc(). hugetlb blocks are mmap/munmap'd, malloc blocks free()'d; a small header before the returned pointer records which. The malloc fallback makes this a no-op when no hugetlb pool is reserved (and on a THP=always host the kernel promotes the malloc'd mmaps anyway), so there is no regression.

Opt-in via -DBLIS_ENABLE_HUGEPAGE_POOL (off by default, like memkind).

Back BLIS's internal memory pools (the packed A/B/C buffers streamed by
level-3 ops) with explicit huge pages when the OS provides them, reducing
dTLB pressure and page walks for large operands.

New allocator bli_hugepage_malloc / bli_hugepage_free (malloc/free-
compatible) plug into BLIS_MALLOC_POOL / BLIS_FREE_POOL exactly like the
existing libmemkind hbw_malloc hook. Per block, largest page first:
1 GiB hugetlb (MAP_HUGE_1GB) for >=1 GiB requests, then 2 MiB hugetlb
(MAP_HUGE_2MB) for >=2 MiB, else ordinary malloc(). hugetlb blocks are
mmap/munmap'd, malloc blocks free()'d; a small header before the returned
pointer records which. The malloc fallback makes this a no-op when no
hugetlb pool is reserved (and on a THP=always host the kernel promotes the
malloc'd mmaps anyway), so there is no regression.

Opt-in via -DBLIS_ENABLE_HUGEPAGE_POOL (off by default, like memkind).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeffhammond
jeffhammond marked this pull request as draft July 16, 2026 15:23
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