Skip to content

Add MKLMemory class to expose MKL allocated memory via Python buffer protocol#182

Open
ndgrigorian wants to merge 8 commits intouse-meson-buildfrom
feature/add-mkl-memory
Open

Add MKLMemory class to expose MKL allocated memory via Python buffer protocol#182
ndgrigorian wants to merge 8 commits intouse-meson-buildfrom
feature/add-mkl-memory

Conversation

@ndgrigorian
Copy link
Copy Markdown
Collaborator

@ndgrigorian ndgrigorian commented Apr 12, 2026

This PR proposes the introduction of _mkl_memory.pyx, which implements an MKLMemory class that exposes memory allocated via mkl_malloc and mkl_calloc to Python via the buffer protocol

The class uses an atomic counter incremented as __getbuffer__ and __releasebuffer__ are called to track the views on the buffer to permit use of mkl_realloc in the object (via realloc method). This concept was adapted from the PEP which revised the buffer protocol which proposed this kind of approach to tracking views on a buffer

Closes #18

@ndgrigorian ndgrigorian force-pushed the feature/add-mkl-memory branch 2 times, most recently from 0071f09 to c88863f Compare April 12, 2026 04:49
as atomics are a c11+ feature, specific flags are needed to enable on window
@ndgrigorian ndgrigorian force-pushed the feature/add-mkl-memory branch from c88863f to d4cc27f Compare April 12, 2026 04:57
@ndgrigorian ndgrigorian force-pushed the feature/add-mkl-memory branch from 32ec03b to 5909cac Compare April 12, 2026 06:39
@ndgrigorian ndgrigorian force-pushed the feature/add-mkl-memory branch from aed1ff6 to a99e626 Compare April 12, 2026 07:19
@ndgrigorian ndgrigorian marked this pull request as ready for review April 12, 2026 09:03
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