Skip to content

Commit

Permalink
move thread lock allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapriot committed Feb 28, 2024
1 parent d635c8a commit d45857b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pydiso/mkl_solver.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#cython: language_level=3
#cython: linetrace=True
cimport numpy as np
import cython
from cython cimport numeric
from cpython.pythread cimport (
PyThread_type_lock,
Expand Down Expand Up @@ -260,9 +261,6 @@ cdef class MKLPardisoSolver:
raise ValueError("Matrix is not square")
self.shape = n_row, n_col

# allocate the lock
#self.lock = PyThread_allocate_lock()

self._data_type = A.dtype
if matrix_type is None:
if np.issubdtype(self._data_type, np.complexfloating):
Expand Down Expand Up @@ -306,6 +304,9 @@ cdef class MKLPardisoSolver:
raise PardisoError("Unrecognized integer length")
self._initialized = True

# allocate the lock
self.lock = PyThread_allocate_lock()

if(verbose):
#for reporting factorization progress via python's `print`
mkl_set_progress(mkl_progress)
Expand Down Expand Up @@ -523,8 +524,8 @@ cdef class MKLPardisoSolver:
err = error or error64
if err!=0:
raise PardisoError("Memmory release error "+_err_messages[err])
#dealloc lock
PyThread_free_lock(self.lock)
#dealloc lock
PyThread_free_lock(self.lock)

cdef _analyze(self):
#phase = 11
Expand Down Expand Up @@ -552,7 +553,8 @@ cdef class MKLPardisoSolver:
if err!=0:
raise PardisoError("Solve step error, "+_err_messages[err])

cdef int _run_pardiso(self, int_t phase, void* b=NULL, void* x=NULL, int_t nrhs=0):
@cython.boundscheck(False)
cdef int _run_pardiso(self, int_t phase, void* b=NULL, void* x=NULL, int_t nrhs=0) nogil:
cdef int_t error=0
cdef long_t error64=0, phase64=phase, nrhs64=nrhs

Expand Down

0 comments on commit d45857b

Please sign in to comment.