Skip to content

Commit d70ac4d

Browse files
Aligned code with PEP8
1 parent afd81af commit d70ac4d

File tree

3 files changed

+72
-105
lines changed

3 files changed

+72
-105
lines changed

mkl-service/_mkl_service.pxd

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ cdef extern from "mkl.h":
112112
int VML_STATUS_OVERFLOW
113113
int VML_STATUS_UNDERFLOW
114114

115-
116115
ctypedef struct MKLVersion:
117116
int MajorVersion
118117
int MinorVersion
@@ -123,8 +122,8 @@ cdef extern from "mkl.h":
123122
char* Platform
124123

125124
# MKL support functions
126-
void mkl_get_version(MKLVersion *pv)
127-
void mkl_get_version_string(char *buf, int len)
125+
void mkl_get_version(MKLVersion* pv)
126+
void mkl_get_version_string(char* buf, int len)
128127

129128
# Threading
130129
void mkl_set_num_threads(int nth)
@@ -138,7 +137,7 @@ cdef extern from "mkl.h":
138137
# Timing
139138
float second()
140139
double dsecnd()
141-
void mkl_get_cpu_clocks(MKL_UINT64 *clocks)
140+
void mkl_get_cpu_clocks(MKL_UINT64* clocks)
142141
double mkl_get_cpu_frequency()
143142
double mkl_get_max_cpu_frequency()
144143
double mkl_get_clocks_frequency()
@@ -147,7 +146,7 @@ cdef extern from "mkl.h":
147146
void mkl_free_buffers()
148147
void mkl_thread_free_buffers()
149148
int mkl_disable_fast_mm()
150-
MKL_INT64 mkl_mem_stat(int *buf)
149+
MKL_INT64 mkl_mem_stat(int* buf)
151150
MKL_INT64 mkl_peak_mem_usage(int mode)
152151
int mkl_set_memory_limit(int mem_type, size_t limit)
153152

@@ -160,12 +159,11 @@ cdef extern from "mkl.h":
160159
int mkl_enable_instructions(int isa)
161160
int mkl_set_env_mode(int mode)
162161
int mkl_verbose(int enable)
163-
int mkl_set_mpi (int vendor, const char *custom_library_name)
162+
int mkl_set_mpi(int vendor, const char* custom_library_name)
164163

165164
# VM Service Functions
166165
unsigned int vmlSetMode(unsigned int mode)
167166
unsigned int vmlGetMode()
168167
int vmlSetErrStatus(const MKL_INT status)
169168
int vmlGetErrStatus()
170169
int vmlClearErrStatus()
171-

mkl-service/_mkl_service.pyx

Lines changed: 65 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -99,66 +99,79 @@ class enums(IntEnum):
9999
VML_STATUS_OVERFLOW = mkl.VML_STATUS_OVERFLOW
100100
VML_STATUS_UNDERFLOW = mkl.VML_STATUS_UNDERFLOW
101101

102+
102103
# MKL Function Domains Constants
103-
__mkl_domain_enums = {'blas': mkl.MKL_DOMAIN_BLAS,
104-
'fft': mkl.MKL_DOMAIN_FFT,
105-
'vml': mkl.MKL_DOMAIN_VML,
106-
'pardiso': mkl.MKL_DOMAIN_PARDISO,
107-
'all': mkl.MKL_DOMAIN_ALL}
104+
__mkl_domain_enums = {
105+
'blas': mkl.MKL_DOMAIN_BLAS,
106+
'fft': mkl.MKL_DOMAIN_FFT,
107+
'vml': mkl.MKL_DOMAIN_VML,
108+
'pardiso': mkl.MKL_DOMAIN_PARDISO,
109+
'all': mkl.MKL_DOMAIN_ALL,
110+
}
108111

109112
# MKL Peak Memory Usage Constants
110-
__mkl_peak_mem_usage_enums = {'enable': mkl.MKL_PEAK_MEM_ENABLE,
111-
'disable': mkl.MKL_PEAK_MEM_DISABLE,
112-
'peak_mem': mkl.MKL_PEAK_MEM,
113-
'peak_mem_reset': mkl.MKL_PEAK_MEM_RESET}
113+
__mkl_peak_mem_usage_enums = {
114+
'enable': mkl.MKL_PEAK_MEM_ENABLE,
115+
'disable': mkl.MKL_PEAK_MEM_DISABLE,
116+
'peak_mem': mkl.MKL_PEAK_MEM,
117+
'peak_mem_reset': mkl.MKL_PEAK_MEM_RESET,
118+
}
114119

115120
# CNR Control Constants Constants
116-
__mkl_cbwr_set_in_enums = {'auto': mkl.MKL_CBWR_AUTO,
117-
'compatible': mkl.MKL_CBWR_COMPATIBLE,
118-
'sse2': mkl.MKL_CBWR_SSE2,
119-
'sse3': mkl.MKL_CBWR_SSE3,
120-
'ssse3': mkl.MKL_CBWR_SSSE3,
121-
'sse4_1': mkl.MKL_CBWR_SSE4_1,
122-
'sse4_2': mkl.MKL_CBWR_SSE4_2,
123-
'avx': mkl.MKL_CBWR_AVX,
124-
'avx2': mkl.MKL_CBWR_AVX2,
125-
'avx512_mic': mkl.MKL_CBWR_AVX512_MIC,
126-
'avx512': mkl.MKL_CBWR_AVX512}
127-
128-
__mkl_cbwr_set_out_enums = {mkl.MKL_CBWR_SUCCESS: 'success',
129-
mkl.MKL_CBWR_ERR_INVALID_INPUT: 'err_invalid_input',
130-
mkl.MKL_CBWR_ERR_UNSUPPORTED_BRANCH: 'err_unsupported_branch',
131-
mkl.MKL_CBWR_ERR_MODE_CHANGE_FAILURE: 'err_mode_change_failure'}
132-
133-
__mkl_cbwr_get_in_enums = {'branch': mkl.MKL_CBWR_BRANCH,
134-
'all': mkl.MKL_CBWR_ALL}
135-
136-
__mkl_cbwr_get_out_enums = {mkl.MKL_CBWR_SUCCESS: 'success',
137-
mkl.MKL_CBWR_ERR_INVALID_INPUT: 'err_invalid_input'}
121+
__mkl_cbwr_set_in_enums = {
122+
'auto': mkl.MKL_CBWR_AUTO,
123+
'compatible': mkl.MKL_CBWR_COMPATIBLE,
124+
'sse2': mkl.MKL_CBWR_SSE2,
125+
'sse3': mkl.MKL_CBWR_SSE3,
126+
'ssse3': mkl.MKL_CBWR_SSSE3,
127+
'sse4_1': mkl.MKL_CBWR_SSE4_1,
128+
'sse4_2': mkl.MKL_CBWR_SSE4_2,
129+
'avx': mkl.MKL_CBWR_AVX,
130+
'avx2': mkl.MKL_CBWR_AVX2,
131+
'avx512_mic': mkl.MKL_CBWR_AVX512_MIC,
132+
'avx512': mkl.MKL_CBWR_AVX512,
133+
}
134+
135+
__mkl_cbwr_set_out_enums = {
136+
mkl.MKL_CBWR_SUCCESS: 'success',
137+
mkl.MKL_CBWR_ERR_INVALID_INPUT: 'err_invalid_input',
138+
mkl.MKL_CBWR_ERR_UNSUPPORTED_BRANCH: 'err_unsupported_branch',
139+
mkl.MKL_CBWR_ERR_MODE_CHANGE_FAILURE: 'err_mode_change_failure',
140+
}
141+
142+
__mkl_cbwr_get_in_enums = {
143+
'branch': mkl.MKL_CBWR_BRANCH,
144+
'all': mkl.MKL_CBWR_ALL,
145+
}
146+
147+
__mkl_cbwr_get_out_enums = {
148+
mkl.MKL_CBWR_SUCCESS: 'success',
149+
mkl.MKL_CBWR_ERR_INVALID_INPUT: 'err_invalid_input',
150+
}
138151
__mkl_cbwr_get_out_enums.update({value: key for key, value in __mkl_cbwr_set_in_enums.items()})
139152

140153
__mkl_cbwr_get_auto_branch_out_enums = {}
141154
__mkl_cbwr_get_auto_branch_out_enums.update({value: key for key, value in __mkl_cbwr_set_in_enums.items()})
142155

143156
# ISA Constants
144-
__mkl_isa_enums = {'avx512': mkl.MKL_ENABLE_AVX512,
145-
'avx512_mic': mkl.MKL_ENABLE_AVX512_MIC,
146-
'avx2': mkl.MKL_ENABLE_AVX2,
147-
'avx': mkl.MKL_ENABLE_AVX,
148-
'sse4_2': mkl.MKL_ENABLE_SSE4_2}
157+
__mkl_isa_enums = {
158+
'avx512': mkl.MKL_ENABLE_AVX512,
159+
'avx512_mic': mkl.MKL_ENABLE_AVX512_MIC,
160+
'avx2': mkl.MKL_ENABLE_AVX2,
161+
'avx': mkl.MKL_ENABLE_AVX,
162+
'sse4_2': mkl.MKL_ENABLE_SSE4_2,
163+
}
149164

150165
# MPI Implementation Constants
151-
__mkl_blacs_enums = {'custom': mkl.MKL_BLACS_CUSTOM,
152-
'msmpi': mkl.MKL_BLACS_MSMPI,
153-
'intelmpi': mkl.MKL_BLACS_INTELMPI}
154-
#'mpich': mkl.MKL_BLACS_MPICH}
166+
__mkl_blacs_enums = {
167+
'custom': mkl.MKL_BLACS_CUSTOM,
168+
'msmpi': mkl.MKL_BLACS_MSMPI,
169+
'intelmpi': mkl.MKL_BLACS_INTELMPI,
170+
#'mpich': mkl.MKL_BLACS_MPICH,}
171+
}
155172

156173

157-
'''
158-
# MKL support functions
159-
void mkl_get_version(MKLVersion * pv)
160-
void mkl_get_version_string(char *buf, int len)
161-
'''
174+
# MKL support functions
162175
def mkl_get_version():
163176
cdef mkl.MKLVersion c_mkl_version
164177
mkl.mkl_get_version(&c_mkl_version)
@@ -172,16 +185,7 @@ def mkl_get_version_string():
172185
return c_string.decode()
173186

174187

175-
'''
176-
# Threading
177-
void mkl_set_num_threads(int nth)
178-
int mkl_domain_set_num_threads(int nt, int domain)
179-
int mkl_set_num_threads_local(int nth)
180-
void mkl_set_dynamic(int flag)
181-
int mkl_get_max_threads()
182-
int mkl_domain_get_max_threads(int domain)
183-
int mkl_get_dynamic()
184-
'''
188+
# Threading
185189
def mkl_set_num_threads(num_threads):
186190
assert(type(num_threads) is int)
187191
assert(num_threads > 0)
@@ -227,6 +231,7 @@ def mkl_set_num_threads_local(num_threads):
227231

228232
return status
229233

234+
230235
def mkl_set_dynamic(enable):
231236
assert(type(enable) is bool)
232237
if enable:
@@ -268,15 +273,7 @@ def mkl_get_dynamic():
268273
return mkl.mkl_get_dynamic()
269274

270275

271-
'''
272-
# Timing
273-
float second()
274-
double dsecnd()
275-
void mkl_get_cpu_clocks(MKL_UINT64* cl)
276-
double mkl_get_cpu_frequency()
277-
double mkl_get_cpu_max_frequency()
278-
double mkl_get_clocks_frequency()
279-
'''
276+
# Timing
280277
def second():
281278
return mkl.second()
282279

@@ -303,16 +300,7 @@ def mkl_get_clocks_frequency():
303300
return mkl.mkl_get_clocks_frequency()
304301

305302

306-
'''
307-
# Memory
308-
void mkl_free_buffers()
309-
void mkl_thread_free_buffers()
310-
int mkl_disable_fast_mm()
311-
MKL_INT64 mkl_mem_stat(int *buf)
312-
MKL_INT64 mkl_peak_mem_usage(int mode)
313-
int mkl_set_memory_limit(int mem_type, size_t limit)
314-
315-
'''
303+
# Memory
316304
def mkl_free_buffers():
317305
mkl.mkl_free_buffers()
318306

@@ -363,12 +351,7 @@ def mkl_set_memory_limit(limit):
363351
return status
364352

365353

366-
'''
367-
# Conditional Numerical Reproducibility
368-
int mkl_cbwr_set(int settings)
369-
int mkl_cbwr_get(int option)
370-
int mkl_cbwr_get_auto_branch()
371-
'''
354+
# Conditional Numerical Reproducibility
372355
def mkl_cbwr_set(branch=None):
373356
branch_type = type(branch)
374357
if branch_type is str:
@@ -407,14 +390,7 @@ def mkl_cbwr_get_auto_branch():
407390
return __mkl_cbwr_get_auto_branch_out_enums[status]
408391

409392

410-
'''
411-
#Miscellaneous
412-
int mkl_enable_instructions(int isa)
413-
int mkl_set_env_mode(int mode)
414-
int mkl_verbose(int enable)
415-
int mkl_set_mpi (int vendor, const char *custom_library_name)
416-
'''
417-
__mkl_isa_enums
393+
# Miscellaneous
418394
def mkl_enable_instructions(isa=None):
419395
isa_type = type(isa)
420396
if isa_type is str:
@@ -475,14 +451,7 @@ def mkl_set_mpi(vendor, custom_library_name):
475451
return status
476452

477453

478-
'''
479-
#VM Service Functions
480-
unsigned int vmlSetMode(unsigned int mode)
481-
unsigned int vmlGetMode()
482-
int vmlSetErrStatus(const MKL_INT status)
483-
int vmlGetErrStatus()
484-
int vmlClearErrStatus()
485-
'''
454+
# VM Service Functions
486455
def vmlSetMode(mode):
487456
return mkl.vmlSetMode(mode)
488457

mkl-service/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from os.path import join, exists, dirname
2929

3030

31-
def configuration(parent_package='',top_path=None):
31+
def configuration(parent_package='', top_path=None):
3232
from numpy.distutils.misc_util import Configuration
3333
from numpy.distutils.system_info import get_info
3434
config = Configuration('mkl_service', parent_package, top_path)
@@ -45,7 +45,7 @@ def configuration(parent_package='',top_path=None):
4545
have_cython = False
4646
sources = [join(pdir, '_mkl_service.c')]
4747
if not exists(sources[0]):
48-
raise ValueError(str(e) + '. ' +
48+
raise ValueError(str(e) + '. ' +
4949
'Cython is required to build the initial .c file.')
5050

5151
config.add_extension(

0 commit comments

Comments
 (0)