Skip to content

Commit

Permalink
Update MKL path in site.cfg.example; apply code review for MAX_THREADS
Browse files Browse the repository at this point in the history
  • Loading branch information
robbmcleod committed Apr 30, 2018
1 parent 14fd5d1 commit 09959bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
19 changes: 4 additions & 15 deletions numexpr/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int numexpr_set_nthreads(int nthreads_new)
// }
if (nthreads_new > global_max_threads) {
fprintf(stderr,
"Error. nthreads cannot be larger than environment variable \"NUMEXPR_MAX_THREADS\" (%d)",
"Error. nthreads cannot be larger than environment variable \"NUMEXPR_MAX_THREADS\" (%ld)",
global_max_threads);
return -1;
}
Expand Down Expand Up @@ -390,25 +390,14 @@ initinterpreter()
#endif
{
PyObject *m, *d;
// TODO: try and load `global_max_threads` from environment variable 'NUMEXPR_MAX_THREADS'
#if defined(_WIN32)
// Example of using GetEnvironmentVariable() on Windows:
// https://msdn.microsoft.com/en-us/library/ms682009(v=vs.85).aspx
int dwRet;
char max_thread_buffer[128];
char *end;
dwRet = GetEnvironmentVariable("NUMEXPR_MAX_THREADS", max_thread_buffer, 128);
if (dwRet > 0) {
global_max_threads = strtol(max_thread_buffer, &end, 10);
}
#else // Linux/OSX


char *max_thread_str = getenv("NUMEXPR_MAX_THREADS");
char *end;
if (max_thread_str != NULL) {
global_max_threads = strtol(max_thread_str, &end, 10);
}
#endif
printf("DEBUG: global_max_threads = %d\n", global_max_threads);


th_params.memsteps = (npy_intp**)calloc(sizeof(npy_intp*), global_max_threads);
th_params.iter = (NpyIter**)calloc(sizeof(NpyIter*), global_max_threads);
Expand Down
6 changes: 3 additions & 3 deletions site.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[DEFAULT]
#libraries = gfortran

[mkl]
#[mkl]
# Example for the MKL included in Intel C 11.0 compiler
# (you may need a recent NumPy version for being able to search libraries
# in different directories at a time)
Expand Down Expand Up @@ -46,6 +46,6 @@
# Please note that the valid os.pathsep is ';' on Windows and ':' on Linux
# and that numpy.distutils.system_info only accepts the first instance of library_dirs
[mkl]
library_dirs=/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64;/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/compiler/lib/intel64_win
include_dirs=/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/include
library_dirs=/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.156/windows/mkl/lib/intel64;/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.156/windows/compiler/lib/intel64_win
include_dirs=/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.156/windows/mkl/include
mkl_libs = mkl_intel_lp64, mkl_intel_thread, mkl_core, libiomp5md

0 comments on commit 09959bb

Please sign in to comment.