Skip to content

Commit aa5d7de

Browse files
Changed mkl.set_mpi function interface. Currently 'custom_library_name'
required only with 'custom' parameter.
1 parent 148e82b commit aa5d7de

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

mkl-service/_mkl_service.pyx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525

2626

27-
cimport _mkl_service as mkl
2827
import six
28+
cimport _mkl_service as mkl
2929

3030

3131
# Version Information
@@ -260,7 +260,7 @@ cpdef verbose(enable):
260260
return __verbose(enable)
261261

262262

263-
cpdef set_mpi(vendor, custom_library_name):
263+
cpdef set_mpi(vendor, custom_library_name=None):
264264
"""
265265
Sets the implementation of the message-passing interface to be used by Intel MKL.
266266
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-mpi
@@ -781,7 +781,7 @@ cdef inline __verbose(enable):
781781
return bool(mkl.mkl_verbose(enable))
782782

783783

784-
cdef inline __set_mpi(vendor, custom_library_name):
784+
cdef inline __set_mpi(vendor, custom_library_name=None):
785785
"""
786786
Sets the implementation of the message-passing interface to be used by Intel MKL.
787787
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-set-mpi
@@ -801,9 +801,14 @@ cdef inline __set_mpi(vendor, custom_library_name):
801801
},
802802
}
803803
mkl_vendor = __mkl_str_to_int(vendor, __variables['input'])
804-
805-
cdef bytes c_bytes = custom_library_name.encode()
806-
cdef char* c_string = c_bytes
804+
assert((vendor is 'custom' and custom_library_name is not None) or
805+
(vendor is not 'custom' and custom_library_name is None))
806+
807+
cdef bytes c_bytes
808+
cdef char* c_string = ''
809+
if custom_library_name is not None:
810+
c_bytes = custom_library_name.encode()
811+
c_string = c_bytes
807812
mkl_status = mkl.mkl_set_mpi(mkl_vendor, c_string)
808813

809814
status = __mkl_int_to_str(mkl_status, __variables['output'])

mkl-service/tests/test_mkl_service.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,17 @@ def test_verbose_false(self):
237237
def test_verbose_true(self):
238238
mkl.verbose(True)
239239

240-
# def test_set_mpi_custom(self):
241-
# mkl.set_mpi('custom', 'test')
240+
def test_set_mpi_custom(self):
241+
mkl.set_mpi('custom', 'custom_library_name')
242242

243243
# def test_set_mpi_msmpi(self):
244-
# mkl.set_mpi('msmpi', 'test')
244+
# mkl.set_mpi('msmpi')
245245

246-
# def test_set_mpi_intelmpi(self):
247-
# mkl.set_mpi('intelmpi', 'test')
246+
def test_set_mpi_intelmpi(self):
247+
mkl.set_mpi('intelmpi')
248248

249-
# def test_set_mpi_mpich2(self):
250-
# mkl.set_mpi('mpich2', 'test')
249+
def test_set_mpi_mpich2(self):
250+
mkl.set_mpi('mpich2')
251251

252252

253253
class test_vm_service_functions():

0 commit comments

Comments
 (0)