[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27365] trunk/blender/source/blender: Mac + OpenMP + pthreads workaround: recent commit broke compile, just
Brecht Van Lommel
brecht at blender.org
Tue Mar 9 17:54:25 CET 2010
Revision: 27365
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27365
Author: blendix
Date: 2010-03-09 17:54:25 +0100 (Tue, 09 Mar 2010)
Log Message:
-----------
Mac + OpenMP + pthreads workaround: recent commit broke compile, just
moved it into threads.c now instead of having it duplicated in various
places.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/pointcache.c
trunk/blender/source/blender/blenlib/CMakeLists.txt
trunk/blender/source/blender/blenlib/intern/threads.c
trunk/blender/source/blender/editors/physics/physics_fluid.c
trunk/blender/source/blender/editors/render/render_internal.c
trunk/blender/source/blender/editors/render/render_preview.c
trunk/blender/source/blender/editors/screen/screen_ops.c
Modified: trunk/blender/source/blender/blenkernel/intern/pointcache.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/pointcache.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/blenkernel/intern/pointcache.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -88,13 +88,6 @@
#include "BLI_winstuff.h"
#endif
-#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
-
#define PTCACHE_DATA_FROM(data, type, from) if(data[type]) { memcpy(data[type], from, ptcache_data_size[type]); }
#define PTCACHE_DATA_TO(data, type, index, to) if(data[type]) { memcpy(to, (char*)data[type] + (index ? index * ptcache_data_size[type] : 0), ptcache_data_size[type]); }
@@ -2375,11 +2368,6 @@
static void *ptcache_make_cache_thread(void *ptr) {
ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr;
-#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
-
for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step)
scene_update_for_newframe(data->scene, data->scene->lay);
@@ -2497,10 +2485,6 @@
thread_data.thread_ended = FALSE;
old_progress = -1;
-#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, ptcache_make_cache_thread, 1);
BLI_insert_thread(&threads, (void*)&thread_data);
Modified: trunk/blender/source/blender/blenlib/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenlib/CMakeLists.txt 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/blenlib/CMakeLists.txt 2010-03-09 16:54:25 UTC (rev 27365)
@@ -44,6 +44,10 @@
SET(INC ${INC} ${PTHREADS_INC})
ENDIF(WIN32)
+IF(WITH_OPENMP)
+ ADD_DEFINITIONS(-DPARALLEL=1)
+ENDIF(WITH_OPENMP)
+
BLENDERLIB(bf_blenlib "${SRC}" "${INC}")
#if env['OURPLATFORM'] == 'linux2':
# cflags='-pthread'
Modified: trunk/blender/source/blender/blenlib/intern/threads.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/threads.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/blenlib/intern/threads.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -56,6 +56,12 @@
#include <sys/time.h>
#endif
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
+extern pthread_key_t gomp_tls_key;
+static void *thread_tls_data;
+#endif
+
/* ********** basic thread control API ************
Many thread cases have an X amount of jobs, and only an Y amount of
@@ -148,9 +154,17 @@
tslot->avail= 1;
}
- if(thread_levels == 0)
+ if(thread_levels == 0) {
MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ /* workaround for Apple gcc 4.2.1 omp vs background thread bug,
+ we copy gomp thread local storage pointer to setting it again
+ inside the thread that we start */
+ thread_tls_data = pthread_getspecific(gomp_tls_key);
+#endif
+ }
+
thread_levels++;
}
}
@@ -181,7 +195,19 @@
return 0;
}
+static void *tslot_thread_start(void *tslot_p)
+{
+ ThreadSlot *tslot= (ThreadSlot*)tslot_p;
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ /* workaround for Apple gcc 4.2.1 omp vs background thread bug,
+ set gomp thread local storage pointer which was copied beforehand */
+ pthread_setspecific (gomp_tls_key, thread_tls_data);
+#endif
+
+ return tslot->do_thread(tslot->callerdata);
+}
+
void BLI_insert_thread(ListBase *threadbase, void *callerdata)
{
ThreadSlot *tslot;
@@ -190,7 +216,7 @@
if(tslot->avail) {
tslot->avail= 0;
tslot->callerdata= callerdata;
- pthread_create(&tslot->pthread, NULL, tslot->do_thread, tslot->callerdata);
+ pthread_create(&tslot->pthread, NULL, tslot_thread_start, tslot);
return;
}
}
Modified: trunk/blender/source/blender/editors/physics/physics_fluid.c
===================================================================
--- trunk/blender/source/blender/editors/physics/physics_fluid.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/editors/physics/physics_fluid.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -98,14 +98,6 @@
/* 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;};
@@ -328,11 +320,6 @@
//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) {
@@ -1050,10 +1037,6 @@
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);
Modified: trunk/blender/source/blender/editors/render/render_internal.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_internal.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/editors/render/render_internal.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -530,11 +530,6 @@
rj->stop= stop;
rj->do_update= do_update;
-#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
-
if(rj->anim)
RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
else
@@ -640,11 +635,6 @@
WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
-#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
-
/* get a render result image, and make sure it is empty */
ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
Modified: trunk/blender/source/blender/editors/render/render_preview.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_preview.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/editors/render/render_preview.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -100,13 +100,6 @@
#define PR_XMAX 200
#define PR_YMAX 195
-#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 */
static int qtest() {return 0;}
/* XXX */
@@ -1105,11 +1098,6 @@
{
ShaderPreview *sp= customdata;
-#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
-
if(sp->pr_method == PR_ICON_RENDER)
icon_preview_startjob(customdata, stop, do_update);
else
@@ -1140,11 +1128,6 @@
WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL);
-#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
-
WM_jobs_start(CTX_wm_manager(C), steve);
}
@@ -1171,11 +1154,6 @@
WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob);
-#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
-
WM_jobs_start(CTX_wm_manager(C), steve);
}
Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c 2010-03-09 16:34:28 UTC (rev 27364)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c 2010-03-09 16:54:25 UTC (rev 27365)
@@ -83,12 +83,6 @@
#define KM_MODAL_STEP10 3
#define KM_MODAL_STEP10_OFF 4
-#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
/* ************** Exported Poll tests ********************** */
int ED_operator_regionactive(bContext *C)
More information about the Bf-blender-cvs
mailing list