Last active
July 25, 2019 03:32
-
-
Save msarahan/84403b0e9214aec994326bda2574fc94 to your computer and use it in GitHub Desktop.
validation of MKL 2018.0.3 openmp initialization fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cimport numpy as np | |
import numpy as np | |
import cython | |
from cython.parallel import prange | |
@cython.boundscheck(False) | |
@cython.wraparound(False) | |
@cython.cdivision(True) | |
def p_arange(int n): | |
''' | |
A useless function only for demonstration purposes | |
''' | |
cdef np.ndarray[np.int_t, ndim=1] ret = np.zeros(n) | |
for i in range(n, schedule='guided', nogil=True): | |
ret[i] = i | |
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package: | |
name: mkl_blas_test | |
version: 1.0 | |
source: | |
path: . | |
build: | |
script: | |
- python setup.py install | |
requirements: | |
# build: | |
# - {{ compiler('c') }} | |
host: | |
- gcc | |
- python | |
- cython | |
- numpy-devel | |
run: | |
- python | |
- scipy | |
- blas=*=mkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import numpy as np | |
import scipy.linalg | |
n = 50 | |
eye = np.eye(n+1, n+1) | |
### do something with scipy; comment to make go BOOM! | |
# scipy.linalg.svd(eye) | |
# now import the extension | |
import ext | |
u, s, vh = scipy.linalg.svd(eye) | |
eye2 = u @ np.diag(s) @ vh | |
all_close = np.allclose(eye, eye2) | |
if all_close: | |
print("Whew") | |
else: | |
print("BOOM!") | |
sys.exit(1) | |
print("All close?", all_close) | |
print("Min(eye2):", np.min(eye2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distutils.core import setup | |
from distutils.extension import Extension | |
from Cython.Build import cythonize | |
from numpy.distutils.core import setup | |
extensions = [ | |
Extension("ext", ["ext.pyx"], | |
include_dirs = ['/opt/MacOSX10.9.sdk/usr/include'])] | |
setup( | |
name = "My hello app", | |
ext_modules = cythonize(extensions), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment