diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-08 09:46:07 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-08 09:46:07 +0200 |
commit | 9b2f641ca8ff64bea569e596d8568d9ec757c172 (patch) | |
tree | d04b18ba995d501a28ffc949a59446b19669e53f | |
parent | b97b89b55d4b0ab30719f49a9df305516d72cbf4 (diff) | |
parent | 1e89faf524dfa137abcadec3958142efaed9c700 (diff) |
Merge tag 'v0.14.0'
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | AUTHORS | 0 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Makefile.am | 21 | ||||
-rw-r--r-- | NEWS | 31 | ||||
-rwxr-xr-x | autogen.sh | 5 | ||||
-rw-r--r-- | bin/Makefile.am | 30 | ||||
-rwxr-xr-x | bin/deploy.sh | 53 | ||||
-rw-r--r-- | bin/meson.build | 35 | ||||
-rw-r--r-- | bin/ufo-launch.c | 74 | ||||
-rw-r--r-- | bin/ufo-runjson.c | 113 | ||||
-rw-r--r-- | common/Makefile.am | 1 | ||||
-rw-r--r-- | common/autotools/Makefile.am | 4 | ||||
-rw-r--r-- | common/autotools/ufo.pc.in | 11 | ||||
-rw-r--r-- | config.h.meson.in | 7 | ||||
-rw-r--r-- | configure.ac | 123 | ||||
-rw-r--r-- | docs/Makefile.am | 105 | ||||
-rw-r--r-- | docs/manual/Makefile.am | 19 | ||||
-rw-r--r-- | docs/manual/install/linux.rst | 4 | ||||
-rw-r--r-- | meson.build | 62 | ||||
-rw-r--r-- | sphinx.make | 130 | ||||
-rw-r--r-- | tests/Makefile.am | 29 | ||||
-rw-r--r-- | ufo/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ufo/Makefile.am | 169 | ||||
-rw-r--r-- | ufo/meson.build | 138 | ||||
-rw-r--r-- | ufo/ufo-base-scheduler.c | 18 | ||||
-rw-r--r-- | ufo/ufo-enums.c.template | 2 | ||||
-rw-r--r-- | ufo/ufo-resources.c | 132 | ||||
-rw-r--r-- | ufo/ufo-scheduler.c | 27 | ||||
-rw-r--r-- | ufo/ufo-task-graph.c | 52 |
30 files changed, 533 insertions, 869 deletions
diff --git a/.travis.yml b/.travis.yml index 3126209..8d85e27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ env: - BUILD_TYPE=Release before_install: - # Hijacking the crystfel repos for OpenCL headers and ICD - - sudo add-apt-repository ppa:valmar-lp/crystfel-releases -y - - sudo apt-get update -qq -y --force-yes - sudo apt-get install -y --force-yes gobject-introspection gir1.2-glib-2.0 gir1.2-json-1.0 opencl-headers ocl-icd-opencl-dev libjson-glib-dev libzmq3-dev autoconf-archive gtk-doc-tools before_script: diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index e69de29..0000000 --- a/AUTHORS +++ /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index 5037f81..76a33e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(UFO_DESCRIPTION_SUMMARY "UFO high-speed image processing core library") #{{{ Library version set(UFO_VERSION_MAJOR "0") -set(UFO_VERSION_MINOR "13") +set(UFO_VERSION_MINOR "14") set(UFO_VERSION_PATCH "0") set(UFO_VERSION "${UFO_VERSION_MAJOR}.${UFO_VERSION_MINOR}.${UFO_VERSION_PATCH}") set(UFO_GIR_VERSION "${UFO_VERSION_MAJOR}.0") diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 40ce29d..0000000 --- a/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -AM_DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection - -SUBDIRS=common ufo bin tests docs - -dist-hook: -## Generate the Changelog file for the distribution. - @if test -d "$(srcdir)/.git"; \ - then \ - echo Creating ChangeLog && \ - ( cd "$(top_srcdir)" && \ - echo '# Generated by Makefile. Do not edit.'; echo; \ - $(top_srcdir)/config/missing --run git log --stat ) > ChangeLog.tmp \ - && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ - || ( rm -f ChangeLog.tmp ; \ - echo Failed to generate ChangeLog >&2 ); \ - else \ - echo A git clone is required to generate a ChangeLog >&2; \ - fi - -EXTRA_DIST = README.md sphinx.make @@ -5,6 +5,37 @@ Changelog Here you can see the full list of changes between each ufo-core release. +Version 0.14.0 +============== + +Release on September 5th 2017. + +Enhancements: + +- meson build system support has been added +- Improve documentation +- Improve expansion for multi-input node graphs +- Output warning in case expansion is not possible +- Use g_printerr to print errors on stderr instead of stdout +- ufo-launch returns exit code 1 on execution error +- Make device usage debug output unambiguous +- #123: allow vector properties via ufo-launch +- #120: generate buffer timestamps with the --timestamps option + +Fixes: + +- Fix a minor memory leak in ufo-launch +- Fix problem with CMake install dir +- Fix #119: compile OpenCL programs for each device with device-specific flags + to allow kernel developers optimizations for each device +- Fix #121: use the same command-line interface for both runjson and launch + +Breaks: + +- We dropped support for Autotools, CMake and meson are the only options to + build at the moment. + + Version 0.13.0 ============== diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index a0e42c6..0000000 --- a/autogen.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -test -d m4 || mkdir m4 -gtkdocize || exit 1 -autoreconf -ivf diff --git a/bin/Makefile.am b/bin/Makefile.am deleted file mode 100644 index aa8fa4c..0000000 --- a/bin/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -AM_CFLAGS = -I$(top_builddir)/common/autotools -I$(top_srcdir)\ - $(GLIB_CFLAGS) $(JSON_GLIB_CFLAGS) $(OPENCL_CFLAGS) -LDADD = $(top_builddir)/ufo/libufo.la \ - $(GLIB_LIBS) $(JSON_GLIB_LIBS) $(ZMQ3_LIBS) $(OPENCL_LIBS) - -bin_PROGRAMS=ufo-launch ufo-runjson ufod - -ufo_launch_SOURCES = ufo-launch.c - -ufo_runjson_SOURCES = ufo-runjson.c - -ufotemplatesdir=$(pkgdatadir)/templates - -dist_ufotemplates_DATA=\ - templates/ufo-task.c.in \ - templates/ufo-task.h.in - -nodist_bin_SCRIPTS = ufo-mkfilter -ufo-mkfilter: ufo-mkfilter.in - sed -e 's![@]UFO_FILTER_TEMPLATE_DIR[@]!$(ufotemplatesdir)!g' $(srcdir)/ufo-mkfilter.in > $@ - -EXTRA_DIST = ufo-mkfilter.in - -CLEANFILES = ufo-mkfilter - -# Support for GNU Flymake, in Emacs. - -check-syntax: AM_CFLAGS += -fsyntax-only -pipe -check-syntax: - test -z "$(CHK_SOURCES)" || $(COMPILE) $(CHK_SOURCES) diff --git a/bin/deploy.sh b/bin/deploy.sh deleted file mode 100755 index a5ff687..0000000 --- a/bin/deploy.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# Usage: deploy.sh PREFIX [LIBDIR] - -UFO_URL=http://github.com/ufo-kit - -ROOT=$(pwd) -PREFIX=$1 -LIBDIR=$2 - -if [[ -z "$PREFIX" ]]; then - PREFIX=$ROOT/usr -fi - -if [[ -z "$LIBDIR" ]]; then - LIBDIR=$PREFIX/lib -fi - -export LD_LIBRARY_PATH=$LIBDIR -export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig -export GI_TYPELIB_PATH=$LD_LIBRARY_PATH/girepository-1.0 - -function build_package() { - printf "\n** Fetching $1\n" - cd $ROOT - - if [ -d "$ROOT/$1" ]; then - cd $ROOT/$1 - git pull - else - git clone $2 - cd $ROOT/$1 - printf "\n** Configuring $1\n" - cmake . -DPREFIX=$PREFIX -DLIBDIR=$LIBDIR || exit 1 - fi - - printf "\n** Building $1\n" - cd $ROOT/$1 - make || exit 1 - make install -} - -build_package "ufo-core" http://github.com/ufo-kit/ufo-core -build_package "ufo-filters" http://github.com/ufo-kit/ufo-filters - -# Link the typelib because the girepository framework is not searching -# /usr/local on openSUSE systems. -if [[ $EUID -eq 0 ]]; then - TYPELIB_PATH=$(ls $GI_TYPELIB_PATH/Ufo-*.typelib) - TYPELIB=$(basename $TYPELIB_PATH) - ln -s $TYPELIB_PATH $LIBDIR/girepository-1.0/$TYPELIB - ldconfig -fi diff --git a/bin/meson.build b/bin/meson.build new file mode 100644 index 0000000..ff708d3 --- /dev/null +++ b/bin/meson.build @@ -0,0 +1,35 @@ +progs = ['ufo-launch', + 'ufo-query', + 'ufo-runjson', + 'ufod'] + +foreach prog: progs + sources = [ + '@0@.c'.format(prog), + enums_h + ] + + executable(prog, + sources: sources, + include_directories: include_dir, + dependencies: deps, + link_with: lib, + install: true + ) +endforeach + +template_dir = join_paths(get_option('prefix'), get_option('datadir'), 'ufo', 'templates') +mkfilter = configuration_data() +mkfilter.set('CMAKE_INSTALL_TEMPLATEDIR', template_dir) + +configure_file( + input: 'ufo-mkfilter.in', + output: 'ufo-mkfilter', + configuration: mkfilter, + install_dir: get_option('bindir'), +) + +install_data( + ['templates/ufo-task.c.in', 'templates/ufo-task.h.in'], + install_dir: template_dir, +) diff --git a/bin/ufo-launch.c b/bin/ufo-launch.c index bf86217..90fe968 100644 --- a/bin/ufo-launch.c +++ b/bin/ufo-launch.c @@ -164,6 +164,15 @@ tokenize_args (const gchar *pipeline) } static void +free_tokens (Token *token) +{ + if (token->str != NULL) + g_string_free (token->str, TRUE); + + g_free (token); +} + +static void set_property (UfoTaskNode *task, const gchar *key, const gchar *pvalue) { GParamSpec *pspec; @@ -242,6 +251,7 @@ static UfoTaskNode * read_connection (Environment *env, UfoTaskNode *previous); static gboolean try_consume_assignment (Environment *env, UfoTaskNode *task) { + GParamSpec *pspec; Token *key; Token *equal; Token *value; @@ -259,12 +269,47 @@ try_consume_assignment (Environment *env, UfoTaskNode *task) if (equal == NULL || equal->type != ASSIGNMENT) return FALSE; - value = consume (env); + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (task), key->str->str); - if (value == NULL || key->type != STRING) - return FALSE; + if (pspec->value_type == G_TYPE_VALUE_ARRAY) { + GParamSpecValueArray *vapspec; + GValueArray *array; + GValue array_value = { 0, }; + Token *next; + + vapspec = (GParamSpecValueArray *) pspec; + array = g_value_array_new (8); + + do { + GValue from_value = { 0, }; + GValue to_value = { 0, }; + + value = consume (env); - set_property (task, key->str->str, value->str->str); + if (value == NULL || value->type != STRING) + return FALSE; + + next = consume (env); + + g_value_init (&from_value, G_TYPE_STRING); + g_value_init (&to_value, vapspec->element_spec->value_type); + g_value_set_string (&from_value, value->str->str); + g_value_transform (&from_value, &to_value); + g_value_array_append (array, &to_value); + } while (next->type == COMMA); + + g_value_init (&array_value, G_TYPE_VALUE_ARRAY); + g_value_set_boxed (&array_value, array); + g_object_set_property (G_OBJECT (task), key->str->str, &array_value); + } + else { + value = consume (env); + + if (value == NULL || key->type != STRING) + return FALSE; + + set_property (task, key->str->str, value->str->str); + } return TRUE; } @@ -482,6 +527,7 @@ main(int argc, char* argv[]) static gboolean quieter = FALSE; static gboolean trace = FALSE; static gboolean version = FALSE; + static gboolean timestamps = FALSE; static gchar **addresses = NULL; static gchar *dump = NULL; @@ -489,6 +535,7 @@ main(int argc, char* argv[]) { "trace", 't', 0, G_OPTION_ARG_NONE, &trace, "enable tracing", NULL }, { "address", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &addresses, "Address of remote server running `ufod'", NULL }, { "dump", 'd', 0, G_OPTION_ARG_STRING, &dump, "Dump to JSON file", NULL }, + { "timestamps",0, 0, G_OPTION_ARG_NONE, ×tamps, "generate timestamps", NULL }, { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, "be quiet", NULL }, { "quieter", 0, 0, G_OPTION_ARG_NONE, &quieter, "be quieter", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL }, @@ -503,7 +550,7 @@ main(int argc, char* argv[]) g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_print ("Error parsing options: %s\n", error->message); + g_printerr ("Error parsing options: %s\n", error->message); return 1; } @@ -518,11 +565,12 @@ main(int argc, char* argv[]) pipeline = g_strjoinv (" ", &argv[1]); tokens = tokenize_args (pipeline); graph = parse (pipeline, tokens, pm, &error); - g_list_free_full (tokens, g_free); + g_free (pipeline); + g_list_free_full (tokens, (GDestroyNotify) free_tokens); if (graph == NULL) { if (error != NULL) - g_print ("Error parsing pipeline: %s\n", error->message); + g_printerr ("Error parsing pipeline: %s\n", error->message); return 1; } @@ -546,9 +594,10 @@ main(int argc, char* argv[]) sched = ufo_scheduler_new (); - if (trace) { - g_object_set (sched, "enable-tracing", TRUE, NULL); - } + g_object_set (sched, + "enable-tracing", trace, + "timestamps", timestamps, + NULL); address_list = string_array_to_value_array (addresses); @@ -563,7 +612,8 @@ main(int argc, char* argv[]) ufo_base_scheduler_run (sched, graph, &error); if (error != NULL) { - g_print ("Error executing pipeline: %s\n", error->message); + g_printerr ("Error executing pipeline: %s\n", error->message); + return 1; } if (!quieter) { @@ -584,7 +634,7 @@ main(int argc, char* argv[]) ufo_task_graph_save_to_json (graph, dump, &error); if (error != NULL) - g_print ("Error dumping task graph: %s\n", error->message); + g_printerr ("Error dumping task graph: %s\n", error->message); } g_list_for (nodes, it) diff --git a/bin/ufo-runjson.c b/bin/ufo-runjson.c index c04ec9c..663c9da 100644 --- a/bin/ufo-runjson.c +++ b/bin/ufo-runjson.c @@ -30,11 +30,21 @@ #include <ufo/ufo-mpi-messenger.h> #endif +typedef struct { + gchar **addresses; + gchar *scheduler; + gboolean trace; + gboolean timestamps; + gboolean version; + gboolean quiet; + gboolean quieter; +} Options; + static void handle_error (const gchar *prefix, GError *error, UfoGraph *graph) { if (error) { - g_warning ("%s: %s", prefix, error->message); + g_printerr ("%s: %s", prefix, error->message); g_error_free (error); exit (EXIT_FAILURE); } @@ -69,9 +79,7 @@ progress_update (gpointer user) static void execute_json (const gchar *filename, - gboolean trace, - const gchar *sched_name, - gchar **addresses) + const Options *options) { UfoTaskGraph *task_graph; UfoBaseScheduler *scheduler = NULL; @@ -80,7 +88,7 @@ execute_json (const gchar *filename, UfoResources *resources = NULL; GValueArray *address_list = NULL; GError *error = NULL; - gboolean has_tty; + gboolean have_tty; manager = ufo_plugin_manager_new (); @@ -88,43 +96,49 @@ execute_json (const gchar *filename, ufo_task_graph_read_from_file (task_graph, manager, filename, &error); handle_error ("Reading JSON", error, UFO_GRAPH (task_graph)); - has_tty = isatty (fileno (stdin)); + have_tty = isatty (fileno (stdin)); leaves = ufo_graph_get_leaves (UFO_GRAPH (task_graph)); - if (has_tty) { + if (!options->quiet && have_tty) { UfoTaskNode *leaf; leaf = UFO_TASK_NODE (leaves->data); g_signal_connect (leaf, "processed", G_CALLBACK (progress_update), NULL); } - if ( (NULL != sched_name) && (0 == g_ascii_strcasecmp(sched_name, "fixed")) ) { - fprintf(stdout, "using a fixed-scheduler to run the workflow.\n"); - scheduler = ufo_fixed_scheduler_new (); + if ((NULL != options->scheduler) && (0 == g_ascii_strcasecmp (options->scheduler, "fixed"))) { + g_debug ("INFO: run-json: using fixed-scheduler"); + scheduler = ufo_fixed_scheduler_new (); } + /* - if ( (NULL != sched_name) && (0 == g_ascii_strcasecmp(sched_name, "local")) ) { - fprintf(stdout, "using a local-scheduler to run the workflow.\n"); - scheduler = ufo_local_scheduler_new (); + if ((NULL != options->scheduler) && (0 == g_ascii_strcasecmp (options->scheduler, "local"))) { + g_debug ("INFO: run-json: using local-scheduler"); + scheduler = ufo_local_scheduler_new (); } - if ( (NULL != sched_name) && (0 == g_ascii_strcasecmp(sched_name, "group")) ) { - fprintf(stdout, "using a group-scheduler to run the workflow.\n"); - scheduler = ufo_group_scheduler_new (); + + if ((NULL != options->scheduler) && (0 == g_ascii_strcasecmp (options->scheduler, "group"))) { + g_debug ("INFO: run-json: using group-scheduler"); + scheduler = ufo_group_scheduler_new (); } */ - if ( (NULL != sched_name) && (0 == g_ascii_strcasecmp(sched_name, "dynamic")) ) { - fprintf(stdout, "using a (default) dynamic scheduler to run the workflow.\n"); - scheduler = ufo_scheduler_new (); + + if ((NULL != options->scheduler) && (0 == g_ascii_strcasecmp (options->scheduler, "dynamic"))) { + g_debug ("INFO: run-json: using dynamic scheduler"); + scheduler = ufo_scheduler_new (); } - if ( ! scheduler ) { - fprintf(stdout, "scheduler defaulting to (dynamic)-scheduler since no option given or unrecognised scheduler request.\n"); - scheduler = ufo_scheduler_new (); + + if (!scheduler) { + g_debug ("INFO: run-json: using dynamic scheduler by default"); + scheduler = ufo_scheduler_new (); } - if (trace) - g_object_set (scheduler, "enable-tracing", TRUE, NULL); + g_object_set (scheduler, + "enable-tracing", options->trace, + "timestamps", options->timestamps, + NULL); - address_list = string_array_to_value_array (addresses); + address_list = string_array_to_value_array (options->addresses); if (address_list) { resources = UFO_RESOURCES (ufo_resources_new (NULL)); @@ -136,8 +150,15 @@ execute_json (const gchar *filename, ufo_base_scheduler_run (scheduler, task_graph, &error); handle_error ("Executing", error, UFO_GRAPH (task_graph)); - if (has_tty) - g_print ("\n"); + if (!options->quieter) { + gdouble run_time; + + if (!options->quiet && have_tty) + g_print ("\n"); + + g_object_get (scheduler, "time", &run_time, NULL); + g_print ("Finished in %3.5fs\n", run_time); + } g_list_free (leaves); @@ -201,7 +222,6 @@ mpi_init (int *argc, char *argv[], gint *rank, gint *global_size) sleep (3); #endif - } #endif @@ -210,21 +230,26 @@ int main(int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; - gchar **addresses = NULL; - gboolean trace = FALSE; - gchar *sched_name = NULL; - gboolean show_version = FALSE; + + static Options options = { + .addresses = NULL, + .scheduler = NULL, + .trace = FALSE, + .timestamps = FALSE, + .version = FALSE, + .quiet = FALSE, + .quieter = FALSE, + }; GOptionEntry entries[] = { - { "trace", 't', 0, G_OPTION_ARG_NONE, &trace, "enable tracing", NULL }, - { "scheduler", 's', 0, G_OPTION_ARG_STRING, &sched_name, "selecting a scheduler", + { "trace", 't', 0, G_OPTION_ARG_NONE, &options.trace, "enable tracing", NULL }, + { "scheduler", 's', 0, G_OPTION_ARG_STRING, &options.scheduler, "selecting a scheduler", "dynamic|fixed"}, -#ifndef WITH_MPI - { "address", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &addresses, - "Address of remote server running `ufod'", NULL }, -#endif - { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, - "Show version information", NULL }, + { "address", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &options.addresses, "Address of remote server running `ufod'", NULL }, + { "timestamps", 0, 0, G_OPTION_ARG_NONE, &options.timestamps, "enable timestamps", NULL }, + { "quiet", 'q', 0, G_OPTION_ARG_NONE, &options.quiet, "be quiet", NULL }, + { "quieter", 0, 0, G_OPTION_ARG_NONE, &options.quieter, "be quieter", NULL }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &options.version, "Show version information", NULL }, { NULL } }; @@ -236,11 +261,11 @@ int main(int argc, char *argv[]) g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_print ("Option parsing failed: %s\n", error->message); + g_printerr ("Option parsing failed: %s\n", error->message); return 1; } - if (show_version) { + if (options.version) { g_print ("runjson %s\n", UFO_VERSION); exit (EXIT_SUCCESS); } @@ -271,7 +296,7 @@ int main(int argc, char *argv[]) } #endif - execute_json (argv[argc-1], trace, sched_name, addresses); + execute_json (argv[argc-1], &options); #ifdef WITH_MPI if (rank == 0) { @@ -280,7 +305,7 @@ int main(int argc, char *argv[]) } #endif - g_strfreev (addresses); + g_strfreev (options.addresses); g_option_context_free (context); return 0; diff --git a/common/Makefile.am b/common/Makefile.am deleted file mode 100644 index 8c90237..0000000 --- a/common/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = autotools diff --git a/common/autotools/Makefile.am b/common/autotools/Makefile.am deleted file mode 100644 index 0d0fae5..0000000 --- a/common/autotools/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = ufo.pc - -EXTRA_DIST = ufo.pc.in diff --git a/common/autotools/ufo.pc.in b/common/autotools/ufo.pc.in deleted file mode 100644 index e9b8f0f..0000000 --- a/common/autotools/ufo.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: Ufo -Description: "high-speed image processing core library" -Version: @VERSION@ -Requires: glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0 json-glib-1.0 libzmq OpenCL -Libs: -L${libdir} -lufo -Cflags: -I${includedir}/ufo-@VMAJ@ diff --git a/config.h.meson.in b/config.h.meson.in new file mode 100644 index 0000000..8370320 --- /dev/null +++ b/config.h.meson.in @@ -0,0 +1,7 @@ +#mesondefine WITH_PYTHON +#mesondefine WITH_ZMQ +#mesondefine WITH_MPI +#mesondefine HAVE_VIENNACL +#mesondefine UFO_PLUGIN_DIR +#mesondefine UFO_KERNEL_DIR +#mesondefine UFO_VERSION diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 654a530..0000000 --- a/configure.ac +++ /dev/null @@ -1,123 +0,0 @@ -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_define([v_maj], m4_esyscmd([(grep "set(UFO_VERSION_MAJOR" CMakeLists.txt | sed 's,[^[:digit:]],,g' || echo 0) | tr -d '\n'])) -m4_define([v_min], m4_esyscmd([(grep "set(UFO_VERSION_MINOR" CMakeLists.txt | sed 's,[^[:digit:]],,g' || echo 0) | tr -d '\n'])) -m4_define([v_mic], m4_esyscmd([(grep "set(UFO_VERSION_PATCH" CMakeLists.txt | sed 's,[^[:digit:]],,g' || echo 0) | tr -d '\n'])) -m4_define([v_rev], m4_esyscmd([(git rev-list --count HEAD 2>/dev/null || echo 0) | tr -d '\n']))dnl -##-- When released, remove the dnl on the below line -dnl m4_undefine([v_rev]) -##-- When doing snapshots - change soname. remove dnl on below line -dnl m4_define([relname], [ver-pre-svn-07]) -dnl m4_define([v_rel], [-release relname]) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_ifdef([v_rev], [m4_define([v_ver], [v_maj.v_min.v_mic.v_rev])], [m4_define([v_ver], [v_maj.v_min.v_mic])]) -m4_define([lt_cur], m4_eval(v_maj + v_min)) -m4_define([lt_rev], v_mic) -m4_define([lt_age], v_min) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## - -AC_PREREQ([2.68]) -AC_INIT([ufo], [v_ver], [http://ufo.kit.edu/ufo/newticket]) -AC_CONFIG_SRCDIR([ufo/ufo-task-node.h]) -AC_CONFIG_HEADERS([common/autotools/config.h]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_AUX_DIR(config) -AM_INIT_AUTOMAKE([foreign]) -AM_SILENT_RULES([yes]) - -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -m4_ifdef([v_rev], , [m4_define([v_rev], [0])]) -m4_ifdef([v_rel], , [m4_define([v_rel], [])]) -AC_DEFINE_UNQUOTED(VMAJ, [v_maj], [Major version]) -AC_DEFINE_UNQUOTED(VMIN, [v_min], [Minor version]) -AC_DEFINE_UNQUOTED(VMIC, [v_mic], [Micro version]) -AC_DEFINE_UNQUOTED(VREV, [v_rev], [Revison]) -version_info="lt_cur:lt_rev:lt_age" -release_info="v_rel" -AC_SUBST(version_info) -AC_SUBST(release_info) -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -VMAJ=v_maj -AC_SUBST(VMAJ) - -dnl *********** -dnl *** MPI *** -dnl *********** - -# If --with-mpi=auto is used, try to find MPI, but use standard C compiler if it is not found. -# If --with-mpi=yes is used, try to find MPI and fail if it isn't found. -# If --with-mpi=no is used, use a standard C compiler instead. -AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi], - [compile with MPI (parallelization) support. If none is found, - MPI is not used. Default: no]) -],,[with_mpi=no]) -# -AX_PROG_CC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[ - use_mpi=no - if test x"$with_mpi" = xyes; then - AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.]) - else - AC_MSG_WARN([No MPI compiler found, won't use MPI.]) - fi -]) -AM_CONDITIONAL([WITH_MPI], [test x"$with_mpi" = xyes]) - -# Checks for programs. -AC_PROG_CC_C99 -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_MAKE_SET -LT_INIT - -# Checks for libraries. -AM_PATH_GLIB_2_0(0.22.0,,,gmodule gobject gthread gio) -PKG_CHECK_MODULES([JSON_GLIB], [json-glib-1.0 >= 0.7.6]) -PKG_CHECK_MODULES([ZMQ3], [libzmq >= 2.1]) -PKG_CHECK_MODULES([OPENCL], [OpenCL >= 1.2]) - -# Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_SIZE_T - -# Checks for library functions. - -dnl ********************************** -dnl *** add a few config variables *** -dnl ********************************** - -AC_DEFINE_UNQUOTED([UFO_VERSION], [VERSION], [the UFO version]) - -dnl ********************* -dnl *** introspection *** -dnl ********************* - -GOBJECT_INTROSPECTION_CHECK([0.6.7]) - -dnl *************** -dnl *** gtk-doc *** -dnl *************** - -GTK_DOC_CHECK([1.9],[--flavour no-tmpl]) - -dnl ************** -dnl *** python *** -dnl ************** - -AM_PATH_PYTHON(,[PKG_CHECK_MODULES([PYTHON], [python])], [:]) -AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :]) - -AC_CONFIG_FILES([Makefile - common/Makefile - common/autotools/Makefile - common/autotools/ufo.pc - docs/Makefile - docs/manual/Makefile - tests/Makefile - bin/Makefile - ufo/Makefile]) -AC_OUTPUT diff --git a/docs/Makefile.am b/docs/Makefile.am deleted file mode 100644 index f50639e..0000000 --- a/docs/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ -## Process this file with automake to produce Makefile.in -SUBDIRS = manual - -# We require automake 1.6 at least. -AUTOMAKE_OPTIONS = 1.6 - -# This is a blank Makefile.am for using gtk-doc. -# Copy this to your project's API docs directory and modify the variables to -# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples -# of using the various options. - -# The name of the module, e.g. 'glib'. -DOC_MODULE=Ufo - -# Uncomment for versioned docs and specify the version of the module, e.g. '2'. -DOC_MODULE_VERSION=@VMAJ@ - -# The top-level XML file (SGML in the past). You can change this if you want to. -DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml - -# Directories containing the source code. -# gtk-doc will search all .c and .h files beneath these paths -# for inline comments documenting functions and macros. -# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk -DOC_SOURCE_DIR=$(top_srcdir)/ufo - -# Extra options to pass to gtkdoc-scangobj. Not normally needed. -SCANGOBJ_OPTIONS= - -# Extra options to supply to gtkdoc-scan. -# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" -SCAN_OPTIONS=--rebuild-types --rebuild-sections - -# Extra options to supply to gtkdoc-mkdb. -# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml -MKDB_OPTIONS=--xml-mode --output-format=xml - -# Extra options to supply to gtkdoc-mktmpl -# e.g. MKTMPL_OPTIONS=--only-section-tmpl -MKTMPL_OPTIONS= - -# Extra options to supply to gtkdoc-mkhtml -MKHTML_OPTIONS= - -# Extra options to supply to gtkdoc-fixref. Not normally needed. -# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html -FIXXREF_OPTIONS= - -# Used for dependencies. The docs will be rebuilt if any of these change. -# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h -# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c -HFILE_GLOB=$(top_srcdir)/ufo/*.h -CFILE_GLOB=$(top_srcdir)/ufo/*.c - -# Extra header to include when scanning, which are not under DOC_SOURCE_DIR -# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h -EXTRA_HFILES= - -# Header files or dirs to ignore when scanning. Use base file/dir names -# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code -IGNORE_HFILES=ufo-mpi-messenger.h ufo-mpi-messenger.c - -# Images to copy into HTML directory. -# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png -HTML_IMAGES= - -# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). -# e.g. content_files=running.sgml building.sgml changes-2.0.sgml -content_files= - -# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded -# These files must be listed here *and* in content_files -# e.g. expand_content_files=running.sgml -expand_content_files= - -# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. -# Only needed if you are using gtkdoc-scangobj to dynamically query widget -# signals and properties. -# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) -# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) -GTKDOC_CFLAGS= -GTKDOC_LIBS=$(top_builddir)/ufo/libufo.la - -# This includes the standard gtk-doc make rules, copied by gtkdocize. -include $(top_srcdir)/gtk-doc.make - -# Other files to distribute -# e.g. EXTRA_DIST += version.xml.in -EXTRA_DIST += - -# Files not to distribute -# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types -# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt -DISTCLEANFILES = $(DOC_MODULE).types $(DOC_MODULE)-sections.txt - -# Comment this out if you want 'make check' to test you doc status -# and run some sanity checks -if ENABLE_GTK_DOC -TESTS_ENVIRONMENT = cd $(srcdir) && \ - DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ - SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) -#TESTS = $(GTKDOC_CHECK) -endif - --include $(top_srcdir)/git.mk diff --git a/docs/manual/Makefile.am b/docs/manual/Makefile.am deleted file mode 100644 index f6d68f5..0000000 --- a/docs/manual/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -EXTRA_DIST = \ - bugs.rst \ - changelog.rst \ - conf.py \ - copyright.rst \ - faq.rst \ - index.rst \ - json.rst \ - install/index.rst \ - install/linux.rst \ - install/mac.rst \ - _static/ufo-logo.png \ - using/background.rst \ - using/cluster.rst \ - using/filters.rst \ - using/index.rst \ - using/quickstart.rst - --include $(top_srcdir)/sphinx.make diff --git a/docs/manual/install/linux.rst b/docs/manual/install/linux.rst index 14721ba..f176f09 100644 --- a/docs/manual/install/linux.rst +++ b/docs/manual/install/linux.rst @@ -122,7 +122,7 @@ CMake will notify you, if some of the dependencies are not met. In case you want to install the library system-wide on a 64-bit machine you should generate the Makefiles with :: - $ cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib64 <path-to-ufo> + $ cmake -DCMAKE_INSTALL_LIBDIR=lib64 <path-to-ufo> For earlier versions of PyGObject, it is necessary that the introspection files are located under ``/usr`` not ``/usr/local``. You can force the prefix by @@ -154,7 +154,7 @@ way :: $ mkdir -p build/ufo-filters $ cd build/ufo-filters - $ cmake <path-to-ufo-filters> -DLIBDIR=/usr/lib64 -DPREFIX=/usr + $ cmake <path-to-ufo-filters> -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib64 $ make $ make install diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..d66577f --- /dev/null +++ b/meson.build @@ -0,0 +1,62 @@ +project('ufo', 'c', + version: '0.14.0' +) + +version = meson.project_version() +components = version.split('.') +version_major = components[0] +version_minor = components[1] +version_patch = components[2] + +cc = meson.get_compiler('c') + +gnome = import('gnome') + +glib_dep = dependency('glib-2.0', version: '>= 2.28') +gio_dep = dependency('gio-2.0', version: '>= 2.28') +gobject_dep = dependency('gobject-2.0', version: '>= 2.28') +gmodule_dep = dependency('gmodule-2.0', version: '>= 2.28') +json_dep = dependency('json-glib-1.0', version: '>= 0.10.0') +python_dep = dependency('python', required: false) +zmq_dep = dependency('libzmq', required: false) + +opencl_dep = declare_dependency(dependencies: cc.find_library('OpenCL')) + +deps = [ + glib_dep, + gio_dep, + gobject_dep, + gmodule_dep, + json_dep, + opencl_dep, + python_dep, + zmq_dep, +] + +include_dir = include_directories('.') + +plugindir = '@0@/@1@/ufo'.format(get_option('prefix'), get_option('libdir')) +kerneldir = '@0@/@1@/ufo'.format(get_option('prefix'), get_option('datadir')) +header_dir = 'ufo-@0@'.format(version_major) +header_subdir = '@0@/ufo'.format(header_dir) + +conf = configuration_data() +conf.set_quoted('UFO_PLUGIN_DIR', plugindir) +conf.set_quoted('UFO_KERNEL_DIR', kerneldir) +conf.set_quoted('UFO_VERSION', version) +conf.set('WITH_PYTHON', python_dep.found()) +conf.set('WITH_ZMQ', zmq_dep.found()) + +configure_file( + input: 'config.h.meson.in', + output: 'config.h', + configuration: conf +) + +add_global_arguments('-DUFO_COMPILATION', language: 'c') +add_global_arguments('-DCL_USE_DEPRECATED_OPENCL_1_1_APIS', language: 'c') +add_global_arguments('-DCL_USE_DEPRECATED_OPENCL_1_2_APIS', language: 'c') +add_global_arguments('-DGLIB_DISABLE_DEPRECATION_WARNINGS', language: 'c') + +subdir('ufo') +subdir('bin') diff --git a/sphinx.make b/sphinx.make deleted file mode 100644 index 2d6b981..0000000 --- a/sphinx.make +++ /dev/null @@ -1,130 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -E -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest - -help: - @echo "Please use \`make <target>' where <target> is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/hkl.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/hkl.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/hkl" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/hkl" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - make -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 70d7208..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -AM_CFLAGS = -I$(top_builddir)/common/autotools -I$(top_srcdir) \ - $(GLIB_CFLAGS) $(JSON_GLIB_CFLAGS) $(ZMQ3_CFLAGS) $(OPENCL_CFLAGS) -AM_CPPFLAGS = -DUFO_COMPILATION -DUFO_PLUGIN_DIR=\"$(pkglibdir)\" -LDADD = $(top_builddir)/ufo/libufo.la \ - $(GLIB_LIBS) $(JSON_GLIB_LIBS) $(ZMQ3_LIBS) $(OPENCL_LIBS) - -check_PROGRAMS = test-suite -test_suite_SOURCES = \ - test-suite.c \ - test-suite.h \ - test-buffer.c \ - test-config.c \ - test-graph.c \ - test-node.c \ - test-profiler.c \ - test-remote-node.c \ - test-mpi-remote-node.c \ - test-zmq-messenger.c - -check-local: $(check_PROGRAMS) - ./test-suite -p /no-opencl - -# Support for GNU Flymake, in Emacs. - -check-syntax: AM_CFLAGS += -fsyntax-only -pipe -check-syntax: - test -z "$(CHK_SOURCES)" || $(COMPILE) $(CHK_SOURCES) - -.PHONY: check-syntax diff --git a/ufo/CMakeLists.txt b/ufo/CMakeLists.txt index 4ee9fa4..42034f6 100644 --- a/ufo/CMakeLists.txt +++ b/ufo/CMakeLists.txt @@ -85,6 +85,8 @@ if (WITH_ZMQ) list(APPEND ufocore_HDRS ufo-zmq-messenger.h) endif () +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + add_library(ufo SHARED ${ufocore_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/ufo-enums.c) set_target_properties(ufo PROPERTIES diff --git a/ufo/Makefile.am b/ufo/Makefile.am deleted file mode 100644 index dac8683..0000000 --- a/ufo/Makefile.am +++ /dev/null @@ -1,169 +0,0 @@ -AM_CFLAGS = -I$(top_builddir)/common/autotools -I$(top_srcdir) \ - $(GLIB_CFLAGS) $(JSON_GLIB_CFLAGS) $(ZMQ3_CFLAGS) $(OPENCL_CFLAGS) -AM_CPPFLAGS = \ - -DUFO_COMPILATION \ - -DUFO_PLUGIN_DIR=\"$(pkglibdir)\" \ - -DUFO_KERNEL_DIR=\"$(pkgdatadir)\" - -# ufo library - -ufo_sources = \ - compat.h \ - compat.c \ - ufo-priv.c \ - ufo-base-scheduler.c \ - ufo-buffer.c \ - ufo-copyable-iface.c \ - ufo-copy-task.c \ - ufo-cpu-node.c \ - ufo-daemon.c \ - ufo-dummy-task.c \ - ufo-fixed-scheduler.c \ - ufo-gpu-node.c \ - ufo-graph.c \ - ufo-group.c \ - ufo-input-task.c \ - ufo-local-scheduler.c \ - ufo-messenger-iface.c \ - ufo-method-iface.c \ - ufo-node.c \ - ufo-output-task.c \ - ufo-plugin-manager.c \ - ufo-profiler.c \ - ufo-processor.c \ - ufo-remote-node.c \ - ufo-remote-task.c \ - ufo-resources.c \ - ufo-scheduler.c \ - ufo-task-iface.c \ - ufo-task-graph.c \ - ufo-task-node.c \ - ufo-transform-iface.c \ - ufo-two-way-queue.c \ - ufo-basic-ops.c \ - ufo-zmq-messenger.c - -ufo_headers = \ - ufo-base-scheduler.h \ - ufo-buffer.h \ - ufo-copyable-iface.h \ - ufo-copy-task.h \ - ufo-cpu-node.h \ - ufo-daemon.h \ - ufo-dummy-task.h \ - ufo-fixed-scheduler.h \ - ufo-gpu-node.h \ - ufo-graph.h \ - ufo-group.h \ - ufo-input-task.h \ - ufo-local-scheduler.h \ - ufo-messenger-iface.h \ - ufo-method-iface.h \ - ufo-node.h \ - ufo-output-task.h \ - ufo-plugin-manager.h \ - ufo-profiler.h \ - ufo-processor.h \ - ufo-remote-node.h \ - ufo-remote-task.h \ - ufo-resources.h \ - ufo-scheduler.h \ - ufo-task-iface.h \ - ufo-task-graph.h \ - ufo-task-node.h \ - ufo-transform-iface.h \ - ufo-two-way-queue.h \ - ufo-basic-ops.h \ - ufo-zmq-messenger.h - -if WITH_MPI -ufo_sources += ufo-mpi-messenger.c -ufo_headers += ufo-mpi-messenger.h -endif - -lib_LTLIBRARIES = libufo.la -libufo_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@ -libufo_la_LIBADD = $(GLIB_LIBS) $(JSON_GLIB_LIBS) $(ZMQ3_LIBS) $(OPENCL_LIBS) -libufo_la_SOURCES = ufo-enums.h ufo-enums.c zmq-shim.h $(ufo_sources) - -if HAVE_PYTHON -AM_CPPFLAGS += -DHAVE_PYTHON $(PYTHON_CFLAGS) -libufo_la_LIBADD += $(PYTHON_LIBS) -endif - - -ufoincludedir = ${includedir}/ufo-@VMAJ@/ufo -ufoinclude_HEADERS = $(ufo_headers) ufo.h ufo-enums.h - -dist_pkgdata_DATA = ufo-basic-ops.cl - -ufo-enums.h: stamp-ufo-enums.h - @true -stamp-ufo-enums.h: $(ufo_headers) $(srcdir)/ufo-enums.h.template - ( cd $(srcdir) && $(GLIB_MKENUMS) --template ufo-enums.h.template \ - $(ufo_headers) ) >> xgen-gtbh \ - && (cmp -s xgen-gtbh ufo-enums.h || cp xgen-gtbh ufo-enums.h ) \ - && rm -f xgen-gtbh \ - && echo timestamp > $(@F) -ufo-enums.c: $(ufo_headers) $(srcdir)/ufo-enums.c.template ufo-enums.h - ( cd $(srcdir) && $(GLIB_MKENUMS) --template ufo-enums.c.template \ - $(ufo_headers) ) > xgen-gtbc \ - && cp xgen-gtbc ufo-enums.c \ - && rm -f xgen-gtbc - -EXTRA_DIST = ufo-enums.c.template ufo-enums.h.template - -CLEANFILES = ufo-enums.c ufo-enums.h stamp-ufo-enums.h - -# introspection - --include $(INTROSPECTION_MAKEFILE) -INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = \ - --add-include-path=$(srcdir) \ - --add-include-path=$(srcdir) \ - --add-include-path=$(JSON_GLIB_CFLAGS) \ - --include=Json-1.0 \ - --warn-all -INTROSPECTION_COMPILER_ARGS = \ - --includedir=$(srcdir) \ - --includedir=. - -if HAVE_INTROSPECTION -Ufo-@VMAJ@.0.gir: $(INTROSPECTION_SCANNER) libufo.la Makefile - -Ufo_@VMAJ@_0_gir_NAMESPACE = Ufo -Ufo_@VMAJ@_0_gir_VERSION = @VMAJ@.0 -Ufo_@VMAJ@_0_gir_LIBS = libufo.la -Ufo_@VMAJ@_0_gir_FILES = $(ufo_sources) $(ufo_headers) -Ufo_@VMAJ@_0_gir_INCLUDES = GLib-2.0 GModule-2.0 GObject-2.0 -Ufo_@VMAJ@_0_gir_CFLAGS = $(INCLUDES) $(AM_CPPFLAGS) $(AM_CFLAGS) -Ufo_@VMAJ@_0_gir_EXPORT_PACKAGES = Ufo-@VMAJ@.0 -Ufo_@VMAJ@_0_gir_SCANNERFLAGS = --warn-all --c-include='ufo.h' - -INTROSPECTION_GIRS += Ufo-@VMAJ@.0.gir - -girdir = $(datadir)/gir-1.0 -gir_DATA = $(INTROSPECTION_GIRS) - -typelibsdir = $(libdir)/girepository-1.0 -typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) - -CLEANFILES += $(gir_DATA) $(typelibs_DATA) - -endif - -# Support for GNU Flymake, in Emacs. - -check-syntax: AM_CFLAGS += -fsyntax-only -pipe -check-syntax: - test -z "$(CHK_SOURCES)" || $(COMPILE) $(CHK_SOURCES) - -# check for includes with iwyu -iwyu: - @list='$(libufo_la_SOURCES)';\ - for p in $$list; do\ - iwyu $(AM_CFLAGS) $(AM_CPPFLAGS) $$p; \ - done; - -.PHONY: check-syntax iwyu diff --git a/ufo/meson.build b/ufo/meson.build new file mode 100644 index 0000000..cb4966a --- /dev/null +++ b/ufo/meson.build @@ -0,0 +1,138 @@ +sources = [ + 'compat.c', + 'ufo-base-scheduler.c', + 'ufo-basic-ops.c', + 'ufo-buffer.c', + 'ufo-copy-task.c', + 'ufo-copyable-iface.c', + 'ufo-cpu-node.c', + 'ufo-daemon.c', + 'ufo-dummy-task.c', + 'ufo-fixed-scheduler.c', + 'ufo-gpu-node.c', + 'ufo-graph.c', + 'ufo-group.c', + 'ufo-group-scheduler.c', + 'ufo-input-task.c', + 'ufo-local-scheduler.c', + 'ufo-messenger-iface.c', + 'ufo-method-iface.c', + 'ufo-node.c', + 'ufo-output-task.c', + 'ufo-plugin-manager.c', + 'ufo-priv.c', + 'ufo-profiler.c', + 'ufo-processor.c', + 'ufo-remote-node.c', + 'ufo-remote-task.c', + 'ufo-resources.c', + 'ufo-scheduler.c', + 'ufo-task-iface.c', + 'ufo-task-graph.c', + 'ufo-task-node.c', + 'ufo-transform-iface.c', + 'ufo-two-way-queue.c', +] + +headers = [ + 'ufo.h', + 'ufo-base-scheduler.h', + 'ufo-basic-ops.h', + 'ufo-buffer.h', + 'ufo-copy-task.h', + 'ufo-copyable-iface.h', + 'ufo-cpu-node.h', + 'ufo-daemon.h', + 'ufo-dummy-task.h', + 'ufo-fixed-scheduler.h', + 'ufo-gpu-node.h', + 'ufo-graph.h', + 'ufo-group.h', + 'ufo-group-scheduler.h', + 'ufo-input-task.h', + 'ufo-local-scheduler.h', + 'ufo-messenger-iface.h', + 'ufo-method-iface.h', + 'ufo-node.h', + 'ufo-output-task.h', + 'ufo-plugin-manager.h', + 'ufo-profiler.h', + 'ufo-processor.h', + 'ufo-remote-node.h', + 'ufo-remote-task.h', + 'ufo-resources.h', + 'ufo-scheduler.h', + 'ufo-task-iface.h', + 'ufo-task-graph.h', + 'ufo-task-node.h', + 'ufo-transform-iface.h', + 'ufo-two-way-queue.h', +] + +enums = gnome.mkenums('ufo-enums', + sources: headers, + h_template: 'ufo-enums.h.template', + c_template: 'ufo-enums.c.template', + install_header: true, + install_dir: '@0@/@1@'.format(get_option('includedir'), header_subdir), +) + +enums_c = enums[0] +enums_h = enums[1] + +sources += [enums_c, enums_h] + +if zmq_dep.found() + sources += ['ufo-zmq-messenger.c'] +endif + +m_dep = declare_dependency( + dependencies: cc.find_library('m') +) + +lib = shared_library('ufo', + sources: sources, + dependencies: deps + [m_dep], + version: version, + soversion: version_major, + include_directories: include_dir, + install: true, +) + +gnome.generate_gir(lib, + namespace: 'Ufo', + nsversion: '@0@.0'.format(version_major), + sources: sources + headers, + install: true, + includes: [ + 'GLib-2.0', + 'GObject-2.0', + 'GModule-2.0', + 'Json-1.0', + ], +) + +pkg = import('pkgconfig') + +pkg.generate( + libraries: [lib], + version: version, + name: 'ufo', + description: 'Library for unified scientific camera access', + requires: [ + 'glib-2.0', + 'gobject-2.0', + 'gmodule-2.0', + 'gio-2.0', + 'json-glib-1.0', + ], + variables: [ + 'plugindir=${libdir}/ufo', + 'kerneldir=${prefix}/@0@/ufo'.format(get_option('datadir')), + ], + subdirs: [ + header_dir + ], +) + +install_headers(headers, subdir: header_subdir) diff --git a/ufo/ufo-base-scheduler.c b/ufo/ufo-base-scheduler.c index 8dd37dc..786f883 100644 --- a/ufo/ufo-base-scheduler.c +++ b/ufo/ufo-base-scheduler.c @@ -62,6 +62,7 @@ struct _UfoBaseSchedulerPrivate { gboolean expand; gboolean trace; gboolean ran; + gboolean timestamps; gdouble time; }; @@ -69,6 +70,7 @@ enum { PROP_0, PROP_EXPAND, PROP_ENABLE_TRACING, + PROP_TIMESTAMPS, PROP_TIME, N_PROPERTIES, }; @@ -243,6 +245,10 @@ ufo_base_scheduler_set_property (GObject *object, priv->trace = g_value_get_boolean (value); break; + case PROP_TIMESTAMPS: + priv->timestamps = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); break; @@ -266,6 +272,10 @@ ufo_base_scheduler_get_property (GObject *object, g_value_set_boolean (value, priv->trace); break; + case PROP_TIMESTAMPS: + g_value_set_boolean (value, priv->timestamps); + break; + case PROP_TIME: g_value_set_double (value, priv->time); break; @@ -363,6 +373,13 @@ ufo_base_scheduler_class_init (UfoBaseSchedulerClass *klass) FALSE, G_PARAM_READWRITE); + properties[PROP_TIMESTAMPS] = + g_param_spec_boolean ("timestamps", + "Enable generating timestamp metadata", + "Enable generating timestamp metadata", + FALSE, + G_PARAM_READWRITE); + properties[PROP_TIME] = g_param_spec_double ("time", "Finished execution time", @@ -384,6 +401,7 @@ ufo_base_scheduler_init (UfoBaseScheduler *scheduler) scheduler->priv = priv = UFO_BASE_SCHEDULER_GET_PRIVATE (scheduler); priv->expand = TRUE; priv->trace = FALSE; + priv->timestamps = FALSE; priv->ran = FALSE; priv->time = 0.0; priv->gpu_nodes = NULL; diff --git a/ufo/ufo-enums.c.template b/ufo/ufo-enums.c.template index 7d8c9f3..ef171ce 100644 --- a/ufo/ufo-enums.c.template +++ b/ufo/ufo-enums.c.template @@ -26,7 +26,7 @@ /*** BEGIN file-production ***/ /* enumerations from "@filename@" */ -#include "ufo/@filename@" +#include "@filename@" /*** END file-production ***/ diff --git a/ufo/ufo-resources.c b/ufo/ufo-resources.c index 3548ef6..7ca56cb 100644 --- a/ufo/ufo-resources.c +++ b/ufo/ufo-resources.c @@ -81,6 +81,7 @@ struct _UfoResourcesPrivate { cl_context context; cl_uint n_devices; /* Number of OpenCL devices per platform id */ cl_device_id *devices; /* Array of OpenCL devices per platform id */ + gchar **device_names; /* Array of names for each device */ GList *gpu_nodes; @@ -327,17 +328,6 @@ platform_vendor_has_prefix (cl_platform_id platform, } static void -add_vendor_to_build_opts (GString *opts, - cl_platform_id platform) -{ - if (platform_vendor_has_prefix (platform, "NVIDIA")) - g_string_append (opts, "-cl-nv-verbose -DVENDOR_NVIDIA"); - - if (platform_vendor_has_prefix (platform, "Advanced Micro Devices")) - g_string_append (opts, "-DVENDOR_AMD"); -} - -static void restrict_to_gpu_subset (UfoResourcesPrivate *priv) { const gchar* var; @@ -427,17 +417,22 @@ initialize_opencl (UfoResourcesPrivate *priv) cl_int errcode = CL_SUCCESS; priv->platform = get_preferably_gpu_based_platform (priv); - add_vendor_to_build_opts (priv->build_opts, priv->platform); + + if (platform_vendor_has_prefix (priv->platform, "NVIDIA")) + g_string_append (priv->build_opts, "-cl-nv-verbose -DVENDOR_NVIDIA"); + + if (platform_vendor_has_prefix (priv->platform, "Advanced Micro Devices")) + g_string_append (priv->build_opts, "-DVENDOR_AMD"); device_type = get_device_type_from_env (); device_type |= priv->device_type & UFO_DEVICE_CPU ? CL_DEVICE_TYPE_CPU : 0; device_type |= priv->device_type & UFO_DEVICE_GPU ? CL_DEVICE_TYPE_GPU : 0; device_type |= priv->device_type & UFO_DEVICE_ACC ? CL_DEVICE_TYPE_ACCELERATOR : 0; - g_debug ("INFO Using CPUs=%i GPUs=%i Accelerators=%i", - (device_type & CL_DEVICE_TYPE_CPU) != 0, - (device_type & CL_DEVICE_TYPE_GPU) != 0, - (device_type & CL_DEVICE_TYPE_ACCELERATOR) != 0); + g_debug ("INFO Using CPUs=%c GPUs=%c Accelerators=%c", + (device_type & CL_DEVICE_TYPE_CPU) != 0 ? 'y' : 'n', + (device_type & CL_DEVICE_TYPE_GPU) != 0 ? 'y' : 'n', + (device_type & CL_DEVICE_TYPE_ACCELERATOR) != 0 ? 'y' : 'n'); errcode = clGetDeviceIDs (priv->platform, device_type, 0, NULL, &priv->n_devices); UFO_RESOURCES_CHECK_AND_SET (errcode, &priv->construct_error); @@ -455,17 +450,6 @@ initialize_opencl (UfoResourcesPrivate *priv) restrict_to_gpu_subset (priv); - for (guint i = 0; i < priv->n_devices; i++) { - size_t size; - gchar *name; - - UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[i], CL_DEVICE_NAME, 0, NULL, &size)); - name = g_malloc0 (size); - - UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[i], CL_DEVICE_NAME, size, name, NULL)); - g_free (name); - } - priv->context = clCreateContext (NULL, priv->n_devices, priv->devices, NULL, NULL, &errcode); UFO_RESOURCES_CHECK_AND_SET (errcode, &priv->construct_error); @@ -473,22 +457,21 @@ initialize_opencl (UfoResourcesPrivate *priv) return FALSE; priv->gpu_nodes = NULL; + priv->device_names = g_malloc0 (priv->n_devices * sizeof (gchar *)); for (guint i = 0; i < priv->n_devices; i++) { UfoGpuNode *node; size_t size; - gchar *name; node = UFO_GPU_NODE (ufo_gpu_node_new (priv->context, priv->devices[i])); UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[i], CL_DEVICE_NAME, 0, NULL, &size)); - name = g_malloc0 (size); + priv->device_names[i] = g_malloc0 (size); - UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[i], CL_DEVICE_NAME, size, name, NULL)); + UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[i], CL_DEVICE_NAME, size, priv->device_names[i], NULL)); - g_debug("NEW UfoGpuNode-%p [device=%s]", (gpointer) node, name); + g_debug("NEW UfoGpuNode-%p [device=%s]", (gpointer) node, priv->device_names[i]); priv->gpu_nodes = g_list_append (priv->gpu_nodes, node); - g_free (name); } return TRUE; @@ -518,6 +501,21 @@ ufo_resources_add_path (UfoResources *resources, resources->priv->paths = g_list_append (resources->priv->paths, g_strdup (path)); } +static void +append_include_path (const gchar *path, + GString *str) +{ + g_string_append_printf (str, " -I%s", path); +} + +static void +opt_append_include_paths (GString *str, + UfoResourcesPrivate *priv) + +{ + g_list_foreach (priv->paths, (GFunc) append_include_path, str); +} + static gchar * escape_device_name (gchar *name) { @@ -538,40 +536,12 @@ escape_device_name (gchar *name) } static void -append_include_path (const gchar *path, - GString *str) +opt_append_device_options (GString *str, + UfoResourcesPrivate *priv, + guint device_index) { - g_string_append_printf (str, " -I%s", path); -} - -static gchar * -get_device_build_options (UfoResourcesPrivate *priv, - guint device_index, - const gchar *additional) -{ - GString *opts; - gsize size; - gchar *name; - g_assert (device_index < priv->n_devices); - - opts = g_string_new (priv->build_opts->str); - - if (additional != NULL && strlen (additional) > 0) { - g_string_append_printf (opts, " %s", additional); - } - - UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[device_index], CL_DEVICE_NAME, 0, NULL, &size)); - name = g_malloc0 (size); - - UFO_RESOURCES_CHECK_CLERR (clGetDeviceInfo (priv->devices[device_index], CL_DEVICE_NAME, size, name, NULL)); - - g_string_append_printf (opts, " -DDEVICE_%s", escape_device_name (name)); - g_free (name); - - g_list_foreach (priv->paths, (GFunc) append_include_path, opts); - - return g_string_free (opts, FALSE); + g_string_append_printf (str, " -DDEVICE_%s", escape_device_name (priv->device_names[device_index])); } static void @@ -603,7 +573,6 @@ add_program_from_source (UfoResourcesPrivate *priv, { cl_program program; cl_int errcode = CL_SUCCESS; - gchar *build_options; GTimer *timer; program = g_hash_table_lookup (priv->programs, source); @@ -619,26 +588,31 @@ add_program_from_source (UfoResourcesPrivate *priv, return NULL; } - build_options = get_device_build_options (priv, 0, options); timer = g_timer_new (); - errcode = clBuildProgram (program, - priv->n_devices, priv->devices, - build_options, - NULL, NULL); + for (guint i = 0; i < priv->n_devices; i++) { + GString *build_options; - g_timer_stop (timer); - g_debug ("INFO Built with `%s' in %3.5fs", build_options, g_timer_elapsed (timer, NULL)); - g_timer_destroy (timer); + build_options = g_string_new (priv->build_opts->str); + opt_append_device_options (build_options, priv, i); + opt_append_include_paths (build_options, priv); - if (errcode != CL_SUCCESS) { - handle_build_error (program, priv->devices[0], errcode, error); - return NULL; + errcode = clBuildProgram (program, 1, &priv->devices[i], build_options->str, NULL, NULL); + + if (errcode != CL_SUCCESS) { + handle_build_error (program, priv->devices[0], errcode, error); + return NULL; + } + + g_string_free (build_options, TRUE); } + g_timer_stop (timer); + g_debug ("INFO Built with `%s%s' for %i devices in %3.5fs", priv->build_opts->str, options, priv->n_devices, g_timer_elapsed (timer, NULL)); + g_timer_destroy (timer); + g_hash_table_insert (priv->programs, g_strdup (source), program); - g_free (build_options); return program; } @@ -1140,6 +1114,9 @@ ufo_resources_finalize (GObject *object) g_hash_table_destroy (priv->programs); + for (guint i = 0; i < priv->n_devices; i++) + g_free (priv->device_names[i]); + if (priv->context) { g_debug ("FREE context=%p", (gpointer) priv->context); UFO_RESOURCES_CHECK_CLERR (clReleaseContext (priv->context)); @@ -1147,6 +1124,7 @@ ufo_resources_finalize (GObject *object) g_string_free (priv->build_opts, TRUE); + g_free (priv->device_names); g_free (priv->devices); priv->kernels = NULL; diff --git a/ufo/ufo-scheduler.c b/ufo/ufo-scheduler.c index 7b09e0f..9e69546 100644 --- a/ufo/ufo-scheduler.c +++ b/ufo/ufo-scheduler.c @@ -62,6 +62,7 @@ typedef struct { guint *dims; gboolean *finished; gboolean strict; + gboolean timestamps; } TaskLocalData; @@ -299,7 +300,18 @@ run_task (TaskLocalData *tld) break; case UFO_TASK_MODE_GENERATOR: - active = ufo_task_generate (tld->task, output, &requisition); + { + if (tld->timestamps) { + GValue v = { 0, }; + + g_value_init (&v, G_TYPE_INT64); + g_value_set_int64 (&v, g_get_real_time ()); + ufo_buffer_set_metadata (output, "ts", &v); + } + + active = ufo_task_generate (tld->task, output, &requisition); + + } break; default: @@ -391,10 +403,14 @@ setup_tasks (UfoBaseScheduler *scheduler, TaskLocalData **tlds; GList *nodes; guint n_nodes; + gboolean timestamps; gboolean tracing_enabled; resources = ufo_base_scheduler_get_resources (scheduler); - g_object_get (scheduler, "enable-tracing", &tracing_enabled, NULL); + g_object_get (scheduler, + "enable-tracing", &tracing_enabled, + "timestamps", ×tamps, + NULL); nodes = ufo_graph_get_nodes (UFO_GRAPH (task_graph)); n_nodes = g_list_length (nodes); @@ -414,6 +430,7 @@ setup_tasks (UfoBaseScheduler *scheduler, tld->mode = ufo_task_get_mode (tld->task); tld->n_inputs = ufo_task_get_num_inputs (tld->task); tld->dims = g_new0 (guint, tld->n_inputs); + tld->timestamps = timestamps; /* TODO: make this configurable from outside */ tld->strict = FALSE; @@ -589,14 +606,10 @@ ufo_scheduler_run (UfoBaseScheduler *scheduler, GThread **threads; TaskLocalData **tlds; gboolean expand; - gboolean trace; priv = UFO_SCHEDULER_GET_PRIVATE (scheduler); - g_object_get (scheduler, - "enable-tracing", &trace, - "expand", &expand, - NULL); + g_object_get (scheduler, "expand", &expand, NULL); graph = task_graph; resources = ufo_base_scheduler_get_resources (scheduler); diff --git a/ufo/ufo-task-graph.c b/ufo/ufo-task-graph.c index e8acf9d..f23cdf5 100644 --- a/ufo/ufo-task-graph.c +++ b/ufo/ufo-task-graph.c @@ -392,17 +392,18 @@ expand_remotes (UfoTaskGraph *task_graph, g_object_unref (remote_graph); } -static gboolean -has_common_ancestries (UfoTaskGraph *graph, GList *path) +static GList * +nodes_with_common_ancestries (UfoTaskGraph *graph, GList *path) { + GList *result = NULL; GList *it; g_list_for (path, it) { if (ufo_graph_get_num_predecessors (UFO_GRAPH (graph), UFO_NODE (it->data)) > 1) - return TRUE; + result = g_list_append (result, it->data); } - return FALSE; + return result; } /** @@ -423,33 +424,40 @@ ufo_task_graph_expand (UfoTaskGraph *task_graph, gboolean expand_remote) { GList *path; - GList *roots; - guint num_roots; + GList *common; g_return_if_fail (UFO_IS_TASK_GRAPH (task_graph)); - /* - * Check if we start with multiple roots. If so, do not expand and map from - * the beginning. - */ - roots = ufo_graph_get_roots (UFO_GRAPH (task_graph)); - num_roots = g_list_length (roots); - g_list_free (roots); - - if (num_roots > 1) - return; - path = ufo_graph_find_longest_path (UFO_GRAPH (task_graph), (UfoFilterPredicate) is_gpu_task, NULL); - /* - * Check if any node on the path contains multiple inputs and stop expansion - * TODO: we need a better strategy at this point ... - */ - if (has_common_ancestries (task_graph, path)) { + common = nodes_with_common_ancestries (task_graph, path); + + if (g_list_length (common) > 1) { + g_debug ("WARN More than one nodes have multiple inputs, not going to expand"); + g_list_free (common); g_list_free (path); return; } + if (g_list_length (common) == 1) { + GList *it; + + g_debug ("INFO Found node with multiple inputs, going to prune it"); + + g_list_for (path, it) { + if (ufo_graph_get_num_predecessors (UFO_GRAPH (task_graph), UFO_NODE (it->data)) > 1) { + GList *predecessor; + + predecessor = g_list_previous (it); + + if (predecessor != NULL) + path = g_list_remove_link (path, predecessor); + } + } + + g_list_free (common); + } + if (path != NULL && g_list_length (path) > 0) { GList *predecessors; GList *successors; |