[gegl] increase maximum number of threads to 16
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] increase maximum number of threads to 16
- Date: Sun, 19 Dec 2010 01:01:27 +0000 (UTC)
commit e821991df17b4fa2f68aed15497b14c76081fb27
Author: �yvind Kolås <pippin gimp org>
Date: Sun Dec 19 00:16:58 2010 +0000
increase maximum number of threads to 16
gegl/gegl-init.c | 11 +++-
gegl/graph/gegl-node.c | 7 +-
gegl/graph/gegl-node.h | 1 +
perf/Makefile | 79 ++++++++++++----------
perf/README | 28 ++++++--
perf/create-report.rb | 163 +++++++++++++++++++++------------------------
perf/tests/Makefile | 2 +
perf/tests/test-common.h | 10 ++-
perf/tests/unsharpmask.c | 28 ++++++++
9 files changed, 190 insertions(+), 139 deletions(-)
---
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index be718b4..8c61137 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -93,6 +93,7 @@ guint gegl_debug_flags = 0;
#include "operation/gegl-extension-handler.h"
#include "buffer/gegl-buffer-private.h"
#include "gegl-config.h"
+#include "graph/gegl-node.h"
/* if this function is made to return NULL swapping is disabled */
@@ -291,7 +292,15 @@ GeglConfig *gegl_config (void)
config->tile_height = atoi(str+1);
}
if (g_getenv ("GEGL_THREADS"))
- config->threads = atoi(g_getenv("GEGL_THREADS"));
+ {
+ config->threads = atoi(g_getenv("GEGL_THREADS"));
+ if (config->threads > GEGL_MAX_THREADS)
+ {
+ g_warning ("Tried to use %i threads max is %i",
+ config->threads, GEGL_MAX_THREADS);
+ config->threads = GEGL_MAX_THREADS;
+ }
+ }
if (gegl_swap_dir())
config->swap = g_strdup(gegl_swap_dir ());
}
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 1447e32..7620279 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -61,7 +61,6 @@ enum
LAST_SIGNAL
};
-#define MAX_THREADS 8
struct _GeglNodePrivate
{
@@ -72,7 +71,7 @@ struct _GeglNodePrivate
gchar *name;
GeglProcessor *processor;
GHashTable *contexts;
- GeglEvalMgr *eval_mgr[MAX_THREADS];
+ GeglEvalMgr *eval_mgr[GEGL_MAX_THREADS];
};
@@ -927,7 +926,7 @@ gegl_node_blit (GeglNode *self,
#if 1
threads = gegl_config ()->threads;
- if (threads > MAX_THREADS)
+ if (threads > GEGL_MAX_THREADS)
threads = 0;
if (pool == NULL)
@@ -948,7 +947,7 @@ gegl_node_blit (GeglNode *self,
*/
if (flags == GEGL_BLIT_DEFAULT)
{
- ThreadData data[MAX_THREADS];
+ ThreadData data[GEGL_MAX_THREADS];
gint i;
/* Subdivide along the largest of width/height, this should be further
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index ec037c2..36d969b 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -229,6 +229,7 @@ void gegl_node_set_name (GeglNode *self,
#define gegl_object_get_has_forked(object) \
(g_object_get_data(G_OBJECT(object), "gegl has-forked")!=NULL)
+#define GEGL_MAX_THREADS 16
G_END_DECLS
diff --git a/perf/Makefile b/perf/Makefile
index 5de9867..87f0610 100644
--- a/perf/Makefile
+++ b/perf/Makefile
@@ -1,51 +1,58 @@
-PROJECT_PATH = ../
+# revision to start at
+START_REV = master
# number of revisions to create
-START_REV = master
-REVISIONS = 40
+REVISIONS = 40
-#comment the following line out to see what the makefile is doing
-.SILENT:
+MAKE_FLAGS = -j3 -k
+CC = ccache gcc # if you do not have ccache replace with just gcc
+
+PROJECT_PATH = ../
-REFS = $(wildcard jobs/*)
-REPORTS = $(subst jobs/,reports/,$(REFS))
+# mute makes echoing of commands
+.SILENT:
-# use random mode for a bit first to get better ranges for plots and less noise
-all: sequential reset
-#all: $(REPORTS) reset
+all: reset sequential
+retry:
+ rm -rf reports/`cat jobs | tail -n1`*
+ make
-sequential:
- for a in `cat joblist`;do echo $$a;make reports/$$a;done
+prepare:
+ # uncomment these to make sure cpu is in high performance mode
+ #sudo sh -c 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor || true'
+ #sudo sh -c 'echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor || true'
reset:
- test -d jobs || ( make jobs ; make )
+ rm -rf jobs jobs
+ # remove build dir for each iteration
rm -rf build
- #echo "Have 0 jobs, edit Makefile to inspect run options, then type make jobs" && false )
-reports/%:
- if [ ! -d build ]; then git clone -s $(PROJECT_PATH) build ; fi
- ( cd build; git checkout `echo $@|sed s:reports/::` )
+ # create clone
+ git clone -s $(PROJECT_PATH) build
+ mkdir reports > /dev/null 2>&1 || true
+ make jobs
+ make prepare
+
+jobs:
+ ( cd build; git checkout $(START_REV) )
+ ( cd build; git log |grep -r "^commit " | head -n $(REVISIONS) | tac | sed "s/commit //" > ../jobs )
+
+sequential:
+ for a in `cat jobs`;do make reports/$$a;done
+
+reports/%:
+ # check out revision
+ (cd build; git checkout `echo $@|sed s:reports/::`)
+ # write header for report
git log -1 > $@ || true
- (cd build; if [ ! -f Makefile ]; then ./autogen.sh ; fi ; \
- CC="ccache gcc" make -j3 && sudo make -j3 install ) > $ log 2>&1 && \
- ( echo -n 'built and installed, testing...' ; \
- make -C tests clean ; make -C tests ; \
- make -C tests check >> $@ )\
- || true
- echo
+ # build revision
+ (cd build; if [ ! -f Makefile ]; then CC=$(CC) ./autogen.sh ; fi ; \
+ make $(MAKE_FLAGS) ; sudo make -k install ) > $ log 2>&1 || true
+ # testing
+ make -C tests clean; make -C tests; make -C tests check >> $@ || true
+ # update report.pdf / report.png
./create-report.rb
echo
-jobs:
- if [ ! -d build ]; then git clone -s $(PROJECT_PATH) build ; fi
- ( cd build; git checkout $(START_REV) )
- mkdir reports > /dev/null 2>&1 || true
- mkdir jobs > /dev/null 2>&1 || true
- rm -f jobs/*
- ( cd build; git log |grep -r "^commit " | head -n $(REVISIONS) | tac | sed "s/commit //" > ../joblist )
- for a in `cat joblist`;do touch jobs/$$a;done
- echo Made `ls -1 jobs|wc -w` jobs
clean:
- rm -rf reports
- rm -rf jobs
- rm -f joblist
+ rm -rf reports jobs report.pdf report.png build
diff --git a/perf/README b/perf/README
index f1c15b4..7f0af87 100644
--- a/perf/README
+++ b/perf/README
@@ -1,9 +1,23 @@
-Performance tracking framework
-------------------------------
+GEGL Performance tracking framework
+===================================
-This directory contains a simple framework to track performance development of
-a set of GEGL tests over time. It requires ruby and ruby cairo bindings to
-work.
+This directory contains a framework to track performance development of a set
+of tests over time. It requires make, ruby and ruby cairo bindings to work. The
+framework is designed to be possible to drop in to existing software projects
+and operate outside the projects own build system, it creates an internal clone
+of the git repo - CAVEAT: it installs the tested project system wide.
+
+Take a look at the top of Makefile for configuration of number of revisions to
+test. And just type make to build, later invokations of make when the
+repository has changed will generate tests for the new revisions. To re-run the
+last revision type 'make retry'.
+
+tests/ contains the tests being run for every revision and a makefile for
+building the tests against an installed GEGL and testing all of them. Rename a
+test to not end in .c to temporarily not test it.
+
+make # build tests
+make clean # remove all temporary files
+make check # run all tests with output values in std-out of the
+ # form "\n@ test-name: 244.4".
-Hopefully just typing make would trigger generation of a graph for the last
-20 commits, edit the Makefile to change this behavior.
diff --git a/perf/create-report.rb b/perf/create-report.rb
index 95f677e..9949372 100755
--- a/perf/create-report.rb
+++ b/perf/create-report.rb
@@ -21,7 +21,7 @@ class Database
[1,0,1, 0.8],
[1,1,0, 0.8],
#[0.5,0.5,0.5,0.8],
- # gray has too little contrast against the background
+ # gray doesnt have sufficient contrast against background
[0.5,0.5,1, 0.8],
[0.5,1,0.5, 0.8],
[0.5,1,1, 0.8],
@@ -51,12 +51,10 @@ class Database
min=9999990
@runs.each { |run|
val = @vals[key][run]
- if val and val < min
- min = val
- end
+ min = val if val and val < min
}
min
- 0
+ 0 # this shows the relative noise in measurements better
end
def add_run(run)
@runs = @runs + [run]
@@ -72,100 +70,91 @@ class Database
end
def drawbg cr
-
- cr.set_source_rgba(0.2, 0.2, 0.2, 1)
- cr.paint
-
- i=0
- @runs.each { |run|
-
- if i % 2 == 1
- cr.move_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx,
- 0 * (@height - @marginy*2) + @marginy
- cr.line_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx,
- 1.0 * (@height - @marginy*2) + @marginy
- cr.rel_line_to(1.0 / @runs.length * (@width - @marginlx- marginrx), 0)
- cr.rel_line_to(0, -(@height - @marginy*2))
-
- cr.set_source_rgba([0.25,0.25,0.25,1])
- cr.fill
- end
-
- i+=1
- }
- end
+ cr.set_source_rgba(0.2, 0.2, 0.2, 1)
+ cr.paint
+
+ i=0
+ @runs.each { |run|
+ if i % 2 == 1
+ cr.move_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx, 0 * (@height - @marginy*2) + @marginy
+ cr.line_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx, 1.0 * (@height - @marginy*2) + @marginy
+ cr.rel_line_to(1.0 / @runs.length * (@width - @marginlx- marginrx), 0)
+ cr.rel_line_to(0, -(@height - @marginy*2))
+
+ cr.set_source_rgba([0.25,0.25,0.25,1])
+ cr.fill
+ end
+ i+=1
+ }
+ end
def drawtext cr
+ i = 0
+ @runs.each { |run|
+ y = i * 10 + 20
+ while y > @height - @marginy
+ y = y - @height + @marginy + 10
+ end
+ cr.move_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx, y
- i = 0
- @runs.each { |run|
- y = i * 10 + 20
- while y > @height - @marginy
- y = y - @height + @marginy + 10
- end
- cr.move_to 1.0 * i / @runs.length * (@width - @marginlx- marginrx) + @marginlx, y
-
- cr.set_source_rgba(0.6,0.6,0.6,1)
- cr.show_text(run[0..7])
- i+=1
- }
+ cr.set_source_rgba(0.6,0.6,0.6,1)
+ cr.show_text(run[0..7])
+ i+=1
+ }
end
def draw_limits cr, key
- cr.move_to @width - @marginrx, 20
- cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
- cr.show_text(" #{val_max(key)} mb/s")
- cr.move_to @width - @marginrx, @height - @marginy
- cr.show_text(" #{val_min(key)} mb/s")
+ cr.move_to @width - @marginrx, 20
+ cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
+ cr.show_text(" #{val_max(key)} mb/s")
+ cr.move_to @width - @marginrx, @height - @marginy
+ cr.show_text(" #{val_min(key)} mb/s")
end
def draw_val cr, key, valno
- min = val_min(key)
- max = val_max(key)
-
- cr.set_source_rgba(@colors[valno])
- cr.move_to(@width - 137, valno * 14 + @marginy + 20)
- cr.show_text(key)
-
- cr.line_width = 2
- cr.new_path
-
- i = 0
- @runs.each { |run|
- val = @vals[key][run]
- if val
- cr.line_to 1.0 * (i+0.5) / @runs.length * (@width - @marginlx- marginrx) + @marginlx,
- (1.0 - ((val-min) * 1.0 / (max - min))) * (@height - @marginy*2) + @marginy
- end
- i = i + 1
- }
- cr.stroke
+ min = val_min(key)
+ max = val_max(key)
+
+ cr.set_source_rgba(@colors[valno])
+ cr.move_to(@width - 137, valno * 14 + @marginy + 20)
+ cr.show_text(key)
+
+ cr.line_width = 2
+ cr.new_path
+
+ i = 0
+ @runs.each { |run|
+ val = @vals[key][run]
+ if val
+ cr.line_to 1.0 * (i+0.5) / @runs.length * (@width - @marginlx- marginrx) + @marginlx,
+ (1.0 - ((val-min) * 1.0 / (max - min))) * (@height - @marginy*2) + @marginy
+ end
+ i = i + 1
+ }
+ cr.stroke
end
- def create_report
-
-
- cairo_surface(@width, @height) { |cr|
-
- drawbg cr
- valno = 0
- @vals.each { |key, value|
- draw_val cr, key, valno
- valno += 1
- }
- drawtext cr
- cr.target.write_to_png("report.png")
-
- valno = 0
- @vals.each { |key, value|
- cr.show_page
- drawbg cr
- draw_val cr, key, valno
- drawtext cr
- draw_limits cr, key
- valno += 1
- }
+ def create_report
+ cairo_surface(@width, @height) { |cr|
+ drawbg cr
+ valno = 0
+ @vals.each { |key, value|
+ draw_val cr, key, valno
+ valno += 1
+ }
+ drawtext cr
+ cr.target.write_to_png("report.png")
+
+ valno = 0
+ @vals.each { |key, value|
+ cr.show_page
+ drawbg cr
+ draw_val cr, key, valno
+ drawtext cr
+ draw_limits cr, key
+ valno += 1
}
+ }
end
end
diff --git a/perf/tests/Makefile b/perf/tests/Makefile
index 01555d0..e402de1 100644
--- a/perf/tests/Makefile
+++ b/perf/tests/Makefile
@@ -1,4 +1,6 @@
CFILES = $(wildcard *.c)
+#CFILES = comp.c # to just run individual test..
+
bins = $(subst ,,$(CFILES:.c=))
all: $(bins)
diff --git a/perf/tests/test-common.h b/perf/tests/test-common.h
index 4a91265..6d515a5 100644
--- a/perf/tests/test-common.h
+++ b/perf/tests/test-common.h
@@ -4,21 +4,24 @@
static long ticks_start;
-glong gegl_ticks (void);
+long babl_ticks (void); /* using babl_ticks instead of gegl_ticks
+ to be able to go further back in time */
void test_start (void)
{
- ticks_start = gegl_ticks ();
+ ticks_start = babl_ticks ();
}
void test_end (const gchar *id,
glong bytes)
{
- long ticks = gegl_ticks ()-ticks_start;
+ long ticks = babl_ticks ()-ticks_start;
g_print ("@ %s: %.2f megabytes/second\n",
id, (bytes / 1024.0 / 1024.0) / (ticks / 1000000.0));
}
+/* create a test buffer of random data in -0.5 to 2.0 range
+ */
GeglBuffer *test_buffer (gint width,
gint height,
Babl *format)
@@ -34,4 +37,3 @@ GeglBuffer *test_buffer (gint width,
g_free (buf);
return buffer;
}
-
diff --git a/perf/tests/unsharpmask.c b/perf/tests/unsharpmask.c
new file mode 100644
index 0000000..ea0d768
--- /dev/null
+++ b/perf/tests/unsharpmask.c
@@ -0,0 +1,28 @@
+#include "test-common.h"
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ GeglBuffer *buffer, *buffer2;
+ GeglNode *gegl, *sink;
+
+ g_thread_init (NULL);
+ gegl_init (&argc, &argv);
+
+ buffer = test_buffer (2048, 2048, babl_format ("RGBA float"));
+
+ gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL,
+ gegl_node ("gegl:unsharp-mask",
+ "std-dev", 2.1,
+ "scale", 1.2,
+ NULL,
+ gegl_node ("gegl:buffer-source", "buffer", buffer, NULL))));
+
+ test_start ();
+ gegl_node_process (sink);
+ test_end ("unsharp-mask", gegl_buffer_get_pixel_count (buffer) * 16);
+ g_object_unref (gegl);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]