diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-11-03 20:24:08 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-11-03 20:44:29 +0300 |
commit | e43b74d87a43ab919b86434db9881608c5b9f762 (patch) | |
tree | 3e885e7530db301a26d68a632147b36925855bc4 /source/blender/modifiers | |
parent | 4b3f1b7540c43999b94c5147eabd6b0b7a6693f8 (diff) |
Optimization of parallel range
It now supports different scheduling schemas: dynamic and static.
Static one is the default and it splits work into equal number of
range iterations.
Dynamic one allocates chunks of 32 iterations which then being
dynamically send to a thread which is currently idling.
This gives slightly better performance. Still some tricks are
possible to have. For example we can use some smarter static scheduling
when one thread might steal tasks from another threads when it runs
out of work to be done.
Also removed unneeded spin lock in the mesh deform evaluation,
on the first glance it seemed to be a reduction involved here but
int fact threads are just adding value to the original vertex
coordinates. No write access to the same element of vertexCos
happens from separate threads.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 472f35f3d18..c253c0314ad 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -213,10 +213,9 @@ typedef struct MeshdeformUserdata { float (*vertexCos)[3]; float (*cagemat)[4]; float (*icagemat)[3]; - SpinLock lock; } MeshdeformUserdata; -static void meshdeform_vert_task(void *userdata, int iter) +static void meshdeform_vert_task(void * userdata, int iter) { MeshdeformUserdata *data = userdata; /*const*/ MeshDeformModifierData *mmd = data->mmd; @@ -265,12 +264,10 @@ static void meshdeform_vert_task(void *userdata, int iter) if (totweight > 0.0f) { mul_v3_fl(co, fac / totweight); mul_m3_v3(data->icagemat, co); - BLI_spin_lock(&data->lock); if (G.debug_value != 527) add_v3_v3(vertexCos[iter], co); else copy_v3_v3(vertexCos[iter], co); - BLI_spin_unlock(&data->lock); } } @@ -395,14 +392,10 @@ static void meshdeformModifier_do( data.vertexCos = vertexCos; data.cagemat = cagemat; data.icagemat = icagemat; - BLI_spin_init(&data.lock); /* Do deformation. */ BLI_task_parallel_range(0, totvert, &data, meshdeform_vert_task); - /* Uninitialize user dtaa used by the task system. */ - BLI_spin_end(&data.lock); - /* release cage derivedmesh */ MEM_freeN(dco); MEM_freeN(cagecos); |