Skip to content

Commit f0d923f

Browse files
Merge pull request #9 from IntelPython/vml_get-set_mode-roundtrip
Vml get set mode roundtrip
2 parents 1e1357b + 44921a6 commit f0d923f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

mkl/_mkl_service.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ cdef extern from "mkl.h":
5656
int MKL_CBWR_AVX2
5757
int MKL_CBWR_AVX512_MIC
5858
int MKL_CBWR_AVX512
59+
int MKL_CBWR_STRICT
60+
int MKL_CBWR_AVX512_E1
61+
int MKL_CBWR_AVX512_MIC_E1
5962
int MKL_CBWR_BRANCH
6063
int MKL_CBWR_ALL
6164
int MKL_CBWR_SUCCESS

mkl/_mkl_service.pyx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ cpdef cbwr_set(branch=None):
275275
return __cbwr_set(branch)
276276

277277

278-
cpdef cbwr_get(cnr_const=None):
278+
cpdef cbwr_get(cnr_const='all'):
279279
"""
280280
Returns the current CNR settings.
281281
https://software.intel.com/en-us/mkl-developer-reference-c-mkl-cbwr-get
@@ -390,12 +390,14 @@ cdef int __python_obj_to_int(obj, func_name):
390390

391391
cdef void __check_positive_num_threads(int p, func_name):
392392
if p <= 0:
393-
warnings.warn("Non-positive argument of " + func_name + " is being ignored, number of threads will not be changed")
393+
warnings.warn("Non-positive argument of " + func_name +
394+
" is being ignored, number of threads will not be changed")
394395

395396

396397
cdef void __check_non_negative_num_threads(int p, func_name):
397398
if p < 0:
398-
warnings.warn("Non-positive argument of " + func_name + " is being ignored, number of threads will not be changed")
399+
warnings.warn("Non-positive argument of " + func_name +
400+
" is being ignored, number of threads will not be changed")
399401

400402

401403
cdef inline int __mkl_str_to_int(variable, possible_variables_dict):
@@ -404,7 +406,8 @@ cdef inline int __mkl_str_to_int(variable, possible_variables_dict):
404406
if possible_variables_dict is None:
405407
raise RuntimeError("Dictionary mapping possible variable value to internal code is missing")
406408
if variable not in possible_variables_dict:
407-
raise ValueError('Variable: <' + str(variable) + '> not in ' + str(possible_variables_dict))
409+
raise ValueError('Variable: <' + str(variable) + '> not in ' +
410+
str(possible_variables_dict.keys()))
408411

409412
return possible_variables_dict[variable]
410413

@@ -414,7 +417,8 @@ cdef __mkl_int_to_str(int mkl_int_variable, possible_variables_dict):
414417
raise RuntimeError("Dictionary mapping possible internal code to output string is missing")
415418

416419
if mkl_int_variable not in possible_variables_dict:
417-
raise ValueError('Variable: <' + str(mkl_int_variable) + '> not in ' + str(possible_variables_dict))
420+
raise ValueError('Variable: <' + str(mkl_int_variable) + '> not in ' +
421+
str(possible_variables_dict.keys()))
418422

419423
return possible_variables_dict[mkl_int_variable]
420424

@@ -653,6 +657,12 @@ cdef object __cbwr_set(branch=None):
653657
'avx2': mkl.MKL_CBWR_AVX2,
654658
'avx512_mic': mkl.MKL_CBWR_AVX512_MIC,
655659
'avx512': mkl.MKL_CBWR_AVX512,
660+
'avx512_e1': mkl.MKL_CBWR_AVX512_E1,
661+
'avx512_mic_e1': mkl.MKL_CBWR_AVX512_MIC_E1,
662+
'avx2,strict': mkl.MKL_CBWR_AVX2 | mkl.MKL_CBWR_STRICT,
663+
'avx512_mic,strict': mkl.MKL_CBWR_AVX512_MIC | mkl.MKL_CBWR_STRICT,
664+
'avx512,strict': mkl.MKL_CBWR_AVX512 | mkl.MKL_CBWR_STRICT,
665+
'avx512_e1,strict': mkl.MKL_CBWR_AVX512_E1 | mkl.MKL_CBWR_STRICT,
656666
},
657667
'output': {
658668
mkl.MKL_CBWR_SUCCESS: 'success',
@@ -850,6 +860,7 @@ cdef object __vml_set_mode(accuracy, ftzdaz, errmode):
850860
'ftzdaz': {
851861
'on': mkl.VML_FTZDAZ_ON,
852862
'off': mkl.VML_FTZDAZ_OFF,
863+
'default': 0,
853864
},
854865
'errmode': {
855866
'ignore': mkl.VML_ERRMODE_IGNORE,

tests/test_mkl_service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ def test_set_mpi_msmpi(self):
287287

288288
class test_vm_service_functions():
289289
# https://software.intel.com/en-us/mkl-developer-reference-c-vm-service-functions
290+
def test_vml_set_get_mode_roundtrip(self):
291+
saved = mkl.vml_get_mode()
292+
mkl.vml_set_mode(*saved) # should not raise errors
293+
290294
def test_vml_set_mode_ha_on_ignore(self):
291295
mkl.vml_set_mode('ha', 'on', 'ignore')
292296

0 commit comments

Comments
 (0)