[gegl/threaded-base-classes] opt point-composer3 ops out of parallelization
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/threaded-base-classes] opt point-composer3 ops out of parallelization
- Date: Tue, 24 Jun 2014 06:15:02 +0000 (UTC)
commit 0b9ac06ff9490d69c9d52a5b55a8805287faed2d
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jun 24 07:54:12 2014 +0200
opt point-composer3 ops out of parallelization
gegl/operation/gegl-operation-composer.c | 9 +++++----
gegl/operation/gegl-operation-composer3.c | 5 ++++-
gegl/operation/gegl-operation-filter.c | 9 ++++++---
gegl/operation/gegl-operation-source.c | 8 +++++---
gegl/operation/gegl-operation.c | 3 +++
5 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-composer.c b/gegl/operation/gegl-operation-composer.c
index de6beca..6617842 100644
--- a/gegl/operation/gegl-operation-composer.c
+++ b/gegl/operation/gegl-operation-composer.c
@@ -159,13 +159,13 @@ gegl_operation_composer_process (GeglOperation *operation,
if (input != NULL ||
aux != NULL)
{
-// success = klass->process (operation, input, aux, output, result, level);
+ gint threads = gegl_config ()->threads;
- op_class->parallelize = 1;
- if (op_class->parallelize && result->width * result->height > 64*64)
+ if (threads > 1 &&
+ op_class->parallelize &&
+ result->width * result->height > 64*64)
{
GThreadPool *pool = thread_pool ();
- gint threads = gegl_config ()->threads;
ThreadData thread_data[GEGL_MAX_THREADS];
gint pending = threads;
@@ -210,6 +210,7 @@ gegl_operation_composer_process (GeglOperation *operation,
thread_process (&thread_data[0], NULL);
while (pending > 0) {g_usleep(3);};
+ success = thread_data[0].success;
}
else
{
diff --git a/gegl/operation/gegl-operation-composer3.c b/gegl/operation/gegl-operation-composer3.c
index 8cbda17..c79f803 100644
--- a/gegl/operation/gegl-operation-composer3.c
+++ b/gegl/operation/gegl-operation-composer3.c
@@ -51,6 +51,9 @@ gegl_operation_composer3_class_init (GeglOperationComposer3Class * klass)
{
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ operation_class->parallelize = FALSE; /* such composer ops do not derive benefit from
+ * parallelization
+ */
operation_class->process = gegl_operation_composer3_process;
operation_class->attach = attach;
operation_class->detect = detect;
@@ -179,7 +182,6 @@ gegl_operation_composer3_process (GeglOperation *operation,
aux2 != NULL)
{
gint threads = gegl_config ()->threads;
- op_class->parallelize = 1;
if (threads > 1 && op_class->parallelize && result->width * result->height > 64*64)
{
GThreadPool *pool = thread_pool ();
@@ -228,6 +230,7 @@ gegl_operation_composer3_process (GeglOperation *operation,
thread_process (&thread_data[0], NULL);
while (pending > 0) {g_usleep(3);};
+ success = thread_data[0].success;
}
else
{
diff --git a/gegl/operation/gegl-operation-filter.c b/gegl/operation/gegl-operation-filter.c
index ea3e9bf..680d02b 100644
--- a/gegl/operation/gegl-operation-filter.c
+++ b/gegl/operation/gegl-operation-filter.c
@@ -148,6 +148,7 @@ gegl_operation_filter_process (GeglOperation *operation,
GeglBuffer *input;
GeglBuffer *output;
gboolean success = FALSE;
+ gint threads = gegl_config ()->threads;
klass = GEGL_OPERATION_FILTER_GET_CLASS (operation);
op_class = GEGL_OPERATION_CLASS (klass);
@@ -163,11 +164,11 @@ gegl_operation_filter_process (GeglOperation *operation,
input = gegl_operation_context_get_source (context, "input");
output = gegl_operation_context_get_target (context, "output");
- op_class->parallelize = 1;
- if (op_class->parallelize && result->width * result->height > 64*64)
+ if (threads > 1 &&
+ op_class->parallelize &&
+ result->width * result->height > 64*64)
{
GThreadPool *pool = thread_pool ();
- gint threads = gegl_config ()->threads;
ThreadData thread_data[GEGL_MAX_THREADS];
gint pending = threads;
@@ -211,6 +212,8 @@ gegl_operation_filter_process (GeglOperation *operation,
thread_process (&thread_data[0], NULL);
while (pending > 0) {g_usleep(3);};
+
+ success = thread_data[0].success;
}
else
{
diff --git a/gegl/operation/gegl-operation-source.c b/gegl/operation/gegl-operation-source.c
index ad102ec..5de4623 100644
--- a/gegl/operation/gegl-operation-source.c
+++ b/gegl/operation/gegl-operation-source.c
@@ -122,6 +122,7 @@ gegl_operation_source_process (GeglOperation *operation,
GeglOperationClass *op_class;
GeglBuffer *output;
gboolean success = FALSE;
+ gint threads = gegl_config ()->threads;
op_class = GEGL_OPERATION_CLASS (klass);
@@ -134,11 +135,11 @@ gegl_operation_source_process (GeglOperation *operation,
g_assert (klass->process);
output = gegl_operation_context_get_target (context, "output");
- op_class->parallelize= 1;
- if (op_class->parallelize && result->width * result->height > 64*64)
+ if (threads > 1 &&
+ op_class->parallelize &&
+ result->width * result->height > 64*64)
{
GThreadPool *pool = thread_pool ();
- gint threads = gegl_config ()->threads;
ThreadData thread_data[GEGL_MAX_THREADS];
gint pending = threads;
@@ -181,6 +182,7 @@ gegl_operation_source_process (GeglOperation *operation,
thread_process (&thread_data[0], NULL);
while (pending > 0) {g_usleep(3);};
+ success = thread_data[0].success;
}
else
{
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index 560a80d..06c6bc7 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -86,6 +86,9 @@ gegl_operation_class_init (GeglOperationClass *klass)
klass->attach = attach;
klass->prepare = NULL;
klass->no_cache = FALSE;
+ klass->parallelize = TRUE; /* whether baseclass' auto threading
+ * should be used.
+ */
klass->get_bounding_box = get_bounding_box;
klass->get_invalidated_by_change = get_invalidated_by_change;
klass->get_required_for_output = get_required_for_output;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]