Skip to content

Commit

Permalink
Seems to work on windows now
Browse files Browse the repository at this point in the history
not everything works yet, but I've identified the main issues. Still
TODO: handle missing OMP libraries gracefully
  • Loading branch information
nfusi committed Oct 11, 2013
1 parent de0a5d0 commit 6945ad7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion GPy/util/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def symmetrify(A, upper=False):
"""
N, M = A.shape
assert N == M

c_contig_code = """
int iN;
for (int i=1; i<N; i++){
Expand All @@ -343,6 +344,8 @@ def symmetrify(A, upper=False):
}
}
"""

N = int(N) # for safe type casting
if A.flags['C_CONTIGUOUS'] and upper:
weave.inline(f_contig_code, ['A', 'N'], extra_compile_args=['-O3'])
elif A.flags['C_CONTIGUOUS'] and not upper:
Expand Down Expand Up @@ -403,4 +406,3 @@ def backsub_both_sides(L, X, transpose='left'):
else:
tmp, _ = lapack.dtrtrs(L, np.asfortranarray(X), lower=1, trans=0)
return lapack.dtrtrs(L, np.asfortranarray(tmp.T), lower=1, trans=0)[0].T

20 changes: 11 additions & 9 deletions GPy/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def fast_array_equal(A, B):
int i, j;
return_val = 1;
#pragma omp parallel for private(i, j)
// #pragma omp parallel for private(i, j)
for(i=0;i<N;i++){
for(j=0;j<D;j++){
if(A(i, j) != B(i, j)){
Expand All @@ -76,7 +76,7 @@ def fast_array_equal(A, B):
int i, j, z;
return_val = 1;
#pragma omp parallel for private(i, j, z)
// #pragma omp parallel for private(i, j, z)
for(i=0;i<N;i++){
for(j=0;j<D;j++){
for(z=0;z<Q;z++){
Expand All @@ -90,7 +90,7 @@ def fast_array_equal(A, B):
"""

support_code = """
#include <omp.h>
// #include <omp.h>
#include <math.h>
"""

Expand All @@ -107,15 +107,17 @@ def fast_array_equal(A, B):
return False
elif A.shape == B.shape:
if A.ndim == 2:
N, D = A.shape
value = weave.inline(code2, support_code=support_code, libraries=['gomp'],
N, D = [int(i) for i in A.shape]
value = weave.inline(code2, support_code=support_code,
arg_names=['A', 'B', 'N', 'D'],
type_converters=weave.converters.blitz,**weave_options)
type_converters=weave.converters.blitz)
# libraries=['gomp'], **weave_options)
elif A.ndim == 3:
N, D, Q = A.shape
value = weave.inline(code3, support_code=support_code, libraries=['gomp'],
N, D, Q = [int(i) for i in A.shape]
value = weave.inline(code3, support_code=support_code,
arg_names=['A', 'B', 'N', 'D', 'Q'],
type_converters=weave.converters.blitz,**weave_options)
type_converters=weave.converters.blitz)
#libraries=['gomp'], **weave_options)
else:
value = np.array_equal(A,B)

Expand Down

0 comments on commit 6945ad7

Please sign in to comment.