omp_get_max_threads still occasionally causes crashes even in binaries compiled with icl.. committing a workaround
parent
f589e35b1d
commit
b7d6fc7dba
|
@ -174,6 +174,9 @@ private:
|
||||||
boost::scoped_ptr<ThreadPrivate> d;
|
boost::scoped_ptr<ThreadPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Variant of \c omp_get_max_threads that works on all platforms
|
||||||
|
extern MTS_EXPORT_CORE int mts_omp_get_max_threads();
|
||||||
|
|
||||||
MTS_NAMESPACE_END
|
MTS_NAMESPACE_END
|
||||||
|
|
||||||
#endif /* __MITSUBA_CORE_THREAD_H_ */
|
#endif /* __MITSUBA_CORE_THREAD_H_ */
|
||||||
|
|
|
@ -43,7 +43,7 @@ BeamRadianceEstimator::BeamRadianceEstimator(const PhotonMap *pmap, size_t looku
|
||||||
|
|
||||||
Log(EInfo, "Computing photon radii ..");
|
Log(EInfo, "Computing photon radii ..");
|
||||||
#if defined(MTS_OPENMP)
|
#if defined(MTS_OPENMP)
|
||||||
int tcount = omp_get_max_threads();
|
int tcount = mts_omp_get_max_threads();
|
||||||
#else
|
#else
|
||||||
int tcount = 1;
|
int tcount = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -390,9 +390,26 @@ std::string Thread::toString() const {
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MTS_OPENMP)
|
||||||
|
static int __omp_threadCount = 0;
|
||||||
|
#endif
|
||||||
|
static std::vector<Thread *> __unmanagedThreads;
|
||||||
|
static boost::mutex __unmanagedMutex;
|
||||||
|
|
||||||
|
#if defined(MTS_OPENMP)
|
||||||
|
int mts_omp_get_max_threads() {
|
||||||
|
/* This function exists to sidestep an annoying
|
||||||
|
implementation bug that causes crashes on OSX */
|
||||||
|
return __omp_threadCount;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Thread::staticInitialization() {
|
void Thread::staticInitialization() {
|
||||||
#if defined(__OSX__)
|
#if defined(__OSX__)
|
||||||
__mts_autorelease_init();
|
__mts_autorelease_init();
|
||||||
|
#endif
|
||||||
|
#if defined(MTS_OPENMP)
|
||||||
|
__omp_threadCount = omp_get_max_threads();
|
||||||
#endif
|
#endif
|
||||||
detail::initializeGlobalTLS();
|
detail::initializeGlobalTLS();
|
||||||
detail::initializeLocalTLS();
|
detail::initializeLocalTLS();
|
||||||
|
@ -405,9 +422,6 @@ void Thread::staticInitialization() {
|
||||||
ThreadPrivate::self->set(mainThread);
|
ThreadPrivate::self->set(mainThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<Thread *> __unmanagedThreads;
|
|
||||||
static boost::mutex __unmanagedMutex;
|
|
||||||
|
|
||||||
Thread *Thread::registerUnmanagedThread(const std::string &name) {
|
Thread *Thread::registerUnmanagedThread(const std::string &name) {
|
||||||
Thread *thread = getThread();
|
Thread *thread = getThread();
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
|
@ -443,6 +457,7 @@ void Thread::initializeOpenMP(size_t threadCount) {
|
||||||
ref<Logger> logger = Thread::getThread()->getLogger();
|
ref<Logger> logger = Thread::getThread()->getLogger();
|
||||||
ref<FileResolver> fResolver = Thread::getThread()->getFileResolver();
|
ref<FileResolver> fResolver = Thread::getThread()->getFileResolver();
|
||||||
|
|
||||||
|
__omp_threadCount = threadCount;
|
||||||
omp_set_num_threads((int) threadCount);
|
omp_set_num_threads((int) threadCount);
|
||||||
omp_set_dynamic(false);
|
omp_set_dynamic(false);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ void blueNoisePointSet(const Scene *scene, const std::vector<Shape *> &shapes,
|
||||||
int kmax = 8; /* Perform 8 trial runs */
|
int kmax = 8; /* Perform 8 trial runs */
|
||||||
|
|
||||||
#if defined(MTS_OPENMP)
|
#if defined(MTS_OPENMP)
|
||||||
int nproc = omp_get_max_threads();
|
int nproc = mts_omp_get_max_threads();
|
||||||
#else
|
#else
|
||||||
int nproc = 1;
|
int nproc = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue