Fix potential bug in binsearch

This commit is contained in:
Steven Robertson 2011-12-09 14:14:00 -05:00
parent d3ee6f36c2
commit b592cda3db

View File

@ -296,9 +296,10 @@ __device__
int bitwise_binsearch(const float *hay, float needle) { int bitwise_binsearch(const float *hay, float needle) {
int lo = 0; int lo = 0;
// TODO: improve efficiency on 64-bit arches
{{for i in range(search_rounds-1, -1, -1)}} {{for i in range(search_rounds-1, -1, -1)}}
if (needle > hay[lo | {{1 << i}}]) if (needle > hay[lo + {{1 << i}}])
lo |= {{1 << i}}; lo += {{1 << i}};
{{endfor}} {{endfor}}
return lo; return lo;
} }