@@ -59,8 +59,11 @@ cdef extern from 'mkl.h':
59
59
60
60
61
61
# call pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, perm, nrhs, iparm, msglvl, b, x, error)
62
- cdef int mkl_progress(int * thread, int * step, char * stage, int stage_len):
63
- print (thread[0 ], step[0 ], stage, stage_len)
62
+ cdef int mkl_progress(int * thread, int * step, char * stage, int stage_len) nogil:
63
+ # must be a nogil process to pass to mkl pardiso progress reporting
64
+ with gil:
65
+ # must reacquire the gil to print out back to python.
66
+ print (thread[0 ], step[0 ], stage, stage_len)
64
67
return 0
65
68
66
69
cdef int mkl_no_progress(int * thread, int * step, char * stage, int stage_len) nogil:
@@ -515,20 +518,21 @@ cdef class MKLPardisoSolver:
515
518
cdef long_t phase64= - 1 , nrhs64= 0 , error64= 0
516
519
517
520
if self ._initialized():
518
- PyThread_acquire_lock(self .lock, 1 )
519
- if self ._is_32:
520
- pardiso(
521
- self .handle, & self ._par.maxfct, & self ._par.mnum, & self ._par.mtype,
522
- & phase, & self ._par.n, NULL , NULL , NULL , NULL , & nrhs, self ._par.iparm,
523
- & self ._par.msglvl, NULL , NULL , & error
524
- )
525
- else :
526
- pardiso_64(
527
- self .handle, & self ._par64.maxfct, & self ._par64.mnum, & self ._par64.mtype,
528
- & phase64, & self ._par64.n, NULL , NULL , NULL , NULL , & nrhs64,
529
- self ._par64.iparm, & self ._par64.msglvl, NULL , NULL , & error64
530
- )
531
- PyThread_release_lock(self .lock)
521
+ with nogil:
522
+ PyThread_acquire_lock(self .lock, 1 )
523
+ if self ._is_32:
524
+ pardiso(
525
+ self .handle, & self ._par.maxfct, & self ._par.mnum, & self ._par.mtype,
526
+ & phase, & self ._par.n, NULL , NULL , NULL , NULL , & nrhs, self ._par.iparm,
527
+ & self ._par.msglvl, NULL , NULL , & error
528
+ )
529
+ else :
530
+ pardiso_64(
531
+ self .handle, & self ._par64.maxfct, & self ._par64.mnum, & self ._par64.mtype,
532
+ & phase64, & self ._par64.n, NULL , NULL , NULL , NULL , & nrhs64,
533
+ self ._par64.iparm, & self ._par64.msglvl, NULL , NULL , & error64
534
+ )
535
+ PyThread_release_lock(self .lock)
532
536
err = error or error64
533
537
if err!= 0 :
534
538
raise PardisoError(" Memory release error " + _err_messages[err])
@@ -541,15 +545,17 @@ cdef class MKLPardisoSolver:
541
545
542
546
cdef _analyze(self ):
543
547
# phase = 11
544
- err = self ._run_pardiso(11 )
548
+ with nogil:
549
+ err = self ._run_pardiso(11 )
545
550
if err!= 0 :
546
551
raise PardisoError(" Analysis step error, " + _err_messages[err])
547
552
548
553
cdef _factor(self ):
549
554
# phase = 22
550
555
self ._factored = False
551
556
552
- err = self ._run_pardiso(22 )
557
+ with nogil:
558
+ err = self ._run_pardiso(22 )
553
559
554
560
if err!= 0 :
555
561
raise PardisoError(" Factor step error, " + _err_messages[err])
@@ -561,12 +567,14 @@ cdef class MKLPardisoSolver:
561
567
if (not self ._factored):
562
568
raise PardisoError(" Cannot solve without a previous factorization." )
563
569
564
- err = self ._run_pardiso(33 , b, x, nrhs_in)
570
+ with nogil:
571
+ err = self ._run_pardiso(33 , b, x, nrhs_in)
572
+
565
573
if err!= 0 :
566
574
raise PardisoError(" Solve step error, " + _err_messages[err])
567
575
568
576
@ cython.boundscheck (False )
569
- cdef int _run_pardiso(self , int_t phase, void * b = NULL , void * x = NULL , int_t nrhs = 0 ) nogil:
577
+ cdef int _run_pardiso(self , int_t phase, void * b = NULL , void * x = NULL , int_t nrhs = 0 ) noexcept nogil:
570
578
cdef int_t error= 0
571
579
cdef long_t error64= 0 , phase64= phase, nrhs64= nrhs
572
580
0 commit comments