Skip to content

Commit bd4e37c

Browse files
committed
add nogil to MKL functions for freeing buffers
1 parent a99e626 commit bd4e37c

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

mkl/_mkl_service.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ctypedef unsigned long long MKL_UINT64
2929
ctypedef int MKL_INT
3030

3131

32-
cdef extern from "mkl.h":
32+
cdef extern from "mkl.h" nogil:
3333
# MKL Function Domains Constants
3434
int MKL_DOMAIN_BLAS
3535
int MKL_DOMAIN_FFT
@@ -151,10 +151,10 @@ cdef extern from "mkl.h":
151151
MKL_INT64 mkl_mem_stat(int* buf)
152152
MKL_INT64 mkl_peak_mem_usage(int mode)
153153
int mkl_set_memory_limit(int mem_type, size_t limit)
154-
void *mkl_malloc(size_t size, int alignment) nogil
155-
void *mkl_realloc(void *ptr, size_t size) nogil
156-
void *mkl_calloc(size_t num, size_t size, int alignment) nogil
157-
void mkl_free(void *ptr) nogil
154+
void *mkl_malloc(size_t size, int alignment)
155+
void *mkl_realloc(void *ptr, size_t size)
156+
void *mkl_calloc(size_t num, size_t size, int alignment)
157+
void mkl_free(void *ptr)
158158

159159
# Conditional Numerical Reproducibility
160160
int mkl_cbwr_set(int settings)

mkl/_py_mkl_service.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ cdef inline void __free_buffers() noexcept:
601601
"""
602602
Frees unused memory allocated by the Intel(R) MKL Memory Allocator.
603603
"""
604-
mkl.mkl_free_buffers()
604+
with nogil:
605+
mkl.mkl_free_buffers()
605606
return
606607

607608

@@ -610,7 +611,8 @@ cdef inline void __thread_free_buffers() noexcept:
610611
Frees unused memory allocated by the Intel(R) MKL Memory Allocator in the current
611612
thread.
612613
"""
613-
mkl.mkl_thread_free_buffers()
614+
with nogil:
615+
mkl.mkl_thread_free_buffers()
614616
return
615617

616618

0 commit comments

Comments
 (0)