Several fixes for the parallel raycasts

- Limits the maximum number of threads to 64, since btThreadSupportPosix
and btThreadsupportWin32 don't support more than 64 bits at this moment,
due to the use of UINT64 bitmasks. This could be fixed by using
std::bitset or some other alternative.
- Introduces a threadpool class, b3ThreadPool, which is a simple wrapper
around btThreadSupportInterface and uses this instead of the global task
scheduler for parallel raycasting. This is actually quite a bit faster
than the task scheduler (~10-15% in my tests for parallel raycasts),
since the advanced features (parallelFor) are not necessary for the
parallel raycasts.
- Puts 16*1024 of MAX_RAY_INTERSECTION_MAX_SIZE_STREAMING in
parentheses, since it otherwise causes problems with other operators
of equal precedence and introduces a smaller constant for Apple targets.
- Refactors the parallel raycasts code and adds some more profiling.
This commit is contained in:
Tigran Gasparian
2018-06-19 18:28:48 +02:00
parent 8c851a70c7
commit b84eb8af74
5 changed files with 112 additions and 48 deletions

View File

@@ -48,14 +48,14 @@ subject to the following restrictions:
int btGetNumHardwareThreads()
{
return std::thread::hardware_concurrency();
return btMin<int>(BT_MAX_THREAD_COUNT, std::thread::hardware_concurrency());
}
#else
int btGetNumHardwareThreads()
{
return sysconf( _SC_NPROCESSORS_ONLN );
return btMin<int>(BT_MAX_THREAD_COUNT, sysconf( _SC_NPROCESSORS_ONLN ));
}
#endif
@@ -202,6 +202,7 @@ static void *threadFunction( void *argument )
}
printf( "Thread TERMINATED\n" );
return 0;
}
///send messages to SPUs

View File

@@ -28,6 +28,8 @@ subject to the following restrictions:
#define BT_OVERRIDE
#endif
// Don't set this to larger than 64, without modifying btThreadSupportPosix
// and btThreadSupportWin32. They use UINT64 bit-masks.
const unsigned int BT_MAX_THREAD_COUNT = 64; // only if BT_THREADSAFE is 1
// for internal use only