Skip to content

Instantly share code, notes, and snippets.

@msarahan msarahan/ext.pyx
Last active Jul 25, 2019

Embed
What would you like to do?
validation of MKL 2018.0.3 openmp initialization fixes
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
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
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))
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
You can’t perform that action at this time.