Cycles: Move non-vectorized bitscan() to util

This way we can use bitscan() from both vectorized and non-vectorized
code, which applies to both kernel and host code.
This commit is contained in:
Sergey Sharybin 2016-02-21 15:13:09 +01:00
parent 0b6b094a8c
commit 65b375e798
2 changed files with 17 additions and 15 deletions

View File

@ -34,21 +34,6 @@
CCL_NAMESPACE_BEGIN
#if !defined(__KERNEL_SSE2__)
/* TODO(sergey): Move to some generic header so all code
* can use bitscan on non-SSE processors.
*/
ccl_device_inline int bitscan(int value)
{
assert(value != 0);
int bit = 0;
while(value >>= 1) {
++bit;
}
return bit;
}
#endif
/* BVH Build Task */
class BVHBuildTask : public Task {

View File

@ -430,6 +430,23 @@ __forceinline __int64 _mm_extract_epi64( __m128i input, const int index ) {
#endif
#else /* __KERNEL_SSE2__ */
/* This section is for utility functions which operates on non-register data
* which might be used from a non-vectorized code.
*/
ccl_device_inline int bitscan(int value)
{
assert(value != 0);
int bit = 0;
while(value >>= 1) {
++bit;
}
return bit;
}
#endif /* __KERNEL_SSE2__ */
CCL_NAMESPACE_END