Skip to content

Commit

Permalink
BUG: fix prefetch statement for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
sturlamolden committed May 10, 2015
1 parent 09f4785 commit 0bbaa32
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions scipy/spatial/ckdtree/src/ckdtree_cpp_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern int number_of_processors;

#include <cmath>

#ifndef WIN32
#if defined(__GNUC__)
inline void
prefetch_datapoint(const npy_float64 *x, const npy_intp m)
{
Expand All @@ -31,10 +31,23 @@ prefetch_datapoint(const npy_float64 *x, const npy_intp m)
}
}
#else
// On Windows, except when using MinGW
#if defined(_WIN32)
#include <xmmininrin.h>
inline void
prefetch_datapoint(const npy_float64 *x, const npy_intp m)
{
const int cache_line = 64; // x86, amd64
char *cur = (char*)x;
char *end = (char*)(x+m);
while (cur < end) {
_mm_prefetch((const char*)cur,_MM_HINT_T0);
cur += cache_line;
}
}
#else
#define prefetch_datapoint(x,y)
#endif

#endif

/*
* Utility functions
Expand Down

0 comments on commit 0bbaa32

Please sign in to comment.