Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Plisson <damien.plisson@yahoo.fr>2009-12-17 20:05:28 +0300
committerDamien Plisson <damien.plisson@yahoo.fr>2009-12-17 20:05:28 +0300
commit1975ee5eecc17514b441fb9ac921063c38fcabc4 (patch)
treeb17498faf199f276e843c30767d6b06577e3c9a1 /source/blender/editors/physics/physics_fluid.c
parent4271a40ee7a53029f04389234278b7f64d834a11 (diff)
OSX vs OpenMP : implement workaround to fix crashes when using mop from a background thread
Fix# 20043 & 20392 The issue is that OSX lib does not implement TLS (Thread Local Storage), so libgomp uses pthread functions to read/write thread specific vars. But this implementation is currently (gcc 4.2) buggy : the write function is called only at lib start (in main thread), and the var is undefined for background thread. The workaround is to perform this gomp_tls_key var write at beginning of background threads that use openMP. (Currently: render & fluidsim)
Diffstat (limited to 'source/blender/editors/physics/physics_fluid.c')
-rw-r--r--source/blender/editors/physics/physics_fluid.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 7893b314e3e..eec971e777e 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -98,6 +98,14 @@
/* enable/disable overall compilation */
#ifndef DISABLE_ELBEEM
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
+#include <pthread.h>
+extern pthread_key_t gomp_tls_key;
+static void *thread_tls_data;
+#endif
+
+
/* XXX */
/* from header info.c */
static int start_progress_bar(void) {return 0;};
@@ -320,6 +328,11 @@ static void *fluidsimSimulateThread(void *unused) { // *ptr) {
//char* fnameCfgPath = (char*)(ptr);
int ret=0;
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+ pthread_setspecific (gomp_tls_key, thread_tls_data);
+#endif
+
ret = elbeemSimulate();
BLI_lock_thread(LOCK_CUSTOM1);
if(globalBakeState==0) {
@@ -1036,6 +1049,11 @@ int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
// set to neutral, -1 means user abort, -2 means init error
globalBakeState = 0;
globalBakeFrame = 0;
+
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ // Workaround for Apple gcc 4.2.1 omp vs background thread bug
+ thread_tls_data = pthread_getspecific(gomp_tls_key);
+#endif
BLI_init_threads(&threads, fluidsimSimulateThread, 1);
BLI_insert_thread(&threads, targetFile);