├── debian ├── docs ├── compat ├── source │ └── format ├── libufo-bin.install ├── libufo-data.install ├── libufo0.install ├── ufo-core-doc.install ├── libufo-bin.manpages ├── gir1.2-ufo-0.0.install ├── libufo0-dbg.substvars ├── libufo-dev.install ├── watch ├── rules ├── changelog └── copyright ├── ufo ├── Ufo.types ├── ufo.pc.in ├── ufo-priv.h ├── ufo-enums.h.template ├── ufo.h ├── ufo-enums.c.template ├── ufo-method-iface.c ├── ufo-two-way-queue.h ├── ufo-copyable-iface.h ├── ufo-method-iface.h ├── ufo-copy-task.h ├── ufo-dummy-task.h ├── ufo-cpu-node.h ├── ufo-copyable-iface.c ├── ufo-transform-iface.h ├── ufo-scheduler.h ├── ufo-input-task.h ├── ufo-node.h ├── ufo-processor.h ├── ufo-output-task.h ├── ufo-fixed-scheduler.h ├── ufo-group-scheduler.h ├── ufo-local-scheduler.h ├── ufo-transform-iface.c ├── ufo-dummy-task.c ├── ufo-gpu-node.h ├── meson.build ├── ufo-copy-task.c ├── ufo-two-way-queue.c ├── ufo-base-scheduler.h ├── ufo-cpu-node.c ├── ufo-group.h └── ufo-plugin-manager.h ├── docs ├── manual │ ├── requirements.txt │ ├── changelog.rst │ ├── _static │ │ └── ufo-logo.png │ ├── copyright.rst │ ├── install │ │ ├── index.rst │ │ ├── windows.rst │ │ ├── mac.rst │ │ └── docker.rst │ ├── bugs.rst │ ├── index.rst │ ├── using │ │ ├── index.rst │ │ ├── env.rst │ │ ├── execution.rst │ │ └── json.rst │ ├── meson.build │ ├── conf.py │ └── faq.rst ├── scangobj.sh.in ├── meson.build ├── man │ ├── ufo-query.1.txt │ ├── ufo-prof.1.txt │ ├── ufo-runjson.1.txt │ ├── ufo-mkfilter.1.txt │ ├── meson.build │ └── ufo-launch.1.txt ├── Ufo-docs.xml ├── CMakeLists.txt └── Ufo-sections.txt.in ├── tango ├── .gitignore ├── setup.py └── README.md ├── tests ├── CMakeLists.txt ├── meson.build ├── sh │ ├── test-147.sh │ └── meson.build └── unit │ ├── meson.build │ ├── CMakeLists.txt │ ├── test-suite.h │ ├── test-suite.c │ ├── test-node.c │ ├── test-profiler.c │ └── gtester.xsl ├── python ├── ufo │ ├── numpy.py │ ├── meson.build │ ├── tomopy.py │ └── __init__.py ├── Makefile ├── meson.build ├── pyproject.toml ├── tests │ ├── common.py │ ├── test_regressions.py │ └── test_infrastructure.py ├── src │ └── meson.build ├── setup.py ├── fabfile.py └── README.md ├── bin ├── leakcheck.sh ├── ufo-launch ├── CMakeLists.txt ├── meson.build ├── templates │ └── ufo-task.h.in ├── ufo-mkfilter.in ├── ufo-query.c └── ufo-prof ├── config.h.meson.in ├── config.h.in ├── .gitignore ├── .travis.yml ├── meson_options.txt ├── common └── cmake │ ├── PkgConfigVars.cmake │ └── FindOpenCL.cmake ├── README.md ├── docker ├── Dockerfile.nvidia.ubuntu-16.04 ├── Dockerfile.amd.opensuse-13.1 ├── Dockerfile.nvidia.ubuntu-20.04 └── Dockerfile.intel.ubuntu-20.04 ├── meson.build └── CMakeLists.txt /debian/docs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ufo/Ufo.types: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /docs/manual/requirements.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/libufo-bin.install: -------------------------------------------------------------------------------- 1 | usr/bin -------------------------------------------------------------------------------- /debian/libufo-data.install: -------------------------------------------------------------------------------- 1 | usr/share/ufo -------------------------------------------------------------------------------- /debian/libufo0.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/ufo-core-doc.install: -------------------------------------------------------------------------------- 1 | usr/share/gtk-doc -------------------------------------------------------------------------------- /tango/.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | tangofu.egg-info/ 3 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(unit) 2 | -------------------------------------------------------------------------------- /debian/libufo-bin.manpages: -------------------------------------------------------------------------------- 1 | usr/share/man/man1/*.1 2 | -------------------------------------------------------------------------------- /tests/meson.build: -------------------------------------------------------------------------------- 1 | subdir('sh') 2 | subdir('unit') 3 | -------------------------------------------------------------------------------- /debian/gir1.2-ufo-0.0.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/girepository-1.0 2 | -------------------------------------------------------------------------------- /debian/libufo0-dbg.substvars: -------------------------------------------------------------------------------- 1 | misc:Depends= 2 | misc:Pre-Depends= 3 | -------------------------------------------------------------------------------- /docs/manual/changelog.rst: -------------------------------------------------------------------------------- 1 | .. _whatsnew-index: 2 | 3 | 4 | .. include:: ../../NEWS 5 | -------------------------------------------------------------------------------- /tests/sh/test-147.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | $UFO_LAUNCH_BINARY read path= 4 | exit 0 5 | -------------------------------------------------------------------------------- /python/ufo/numpy.py: -------------------------------------------------------------------------------- 1 | from ._ufo import asarray, fromarray, fromarray_inplace, empty_like 2 | -------------------------------------------------------------------------------- /python/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | @python setup.py install 3 | 4 | check: 5 | @nosetests tests/ 6 | -------------------------------------------------------------------------------- /debian/libufo-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*/lib*.so 3 | usr/lib/*/pkgconfig 4 | usr/share/gir-1.0/ -------------------------------------------------------------------------------- /docs/manual/_static/ufo-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ufo-kit/ufo-core/HEAD/docs/manual/_static/ufo-logo.png -------------------------------------------------------------------------------- /tests/sh/meson.build: -------------------------------------------------------------------------------- 1 | env = ['UFO_LAUNCH_BINARY=@0@'.format(ufo_launch.full_path())] 2 | test('147 regression', find_program('test-147.sh'), env: env) 3 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/ufo-core-$1.tar.gz/ \ 3 | https://github.com/ufo-kit/ufo-core/tags .*/v?(\d\S*)\.tar\.gz -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | #export DH_VERBOSE=1 5 | 6 | %: 7 | dh $@ --with gir,python2 --without autoreconf --buildsystem=cmake 8 | -------------------------------------------------------------------------------- /python/ufo/meson.build: -------------------------------------------------------------------------------- 1 | py3.install_sources([ 2 | '__init__.py', 3 | 'numpy.py', 4 | 'tomopy.py' 5 | ], 6 | pure : false, 7 | subdir : 'ufo' 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | ufo-core (0.10.0-0) unstable; urgency=low 2 | 3 | * Initial release (Closes: #nnnn) 4 | 5 | -- Picca Frédéric-Emmanuel Sat, 27 Jul 2013 09:07:17 +0200 6 | -------------------------------------------------------------------------------- /docs/scangobj.sh.in: -------------------------------------------------------------------------------- 1 | LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${CMAKE_CURRENT_BINARY_DIR}" CFLAGS="${GTK_DOC_CFLAGS}" LDFLAGS="${GTK_DOC_LDFLAGS} -L${CMAKE_CURRENT_BINARY_DIR} -lufo" gtkdoc-scangobj --module=Ufo > /dev/null 2 | -------------------------------------------------------------------------------- /bin/leakcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OPTS="--tool=memcheck --leak-check=full --show-reachable=yes --leak-resolution=high --num-callers=20" 3 | 4 | G_SLICE=always-malloc G_DEBUG=gc-friendly,resident-modules valgrind $OPTS --log-file=vgdump $1 5 | -------------------------------------------------------------------------------- /docs/manual/copyright.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Copyright 3 | ========= 4 | 5 | UFO and this documentation is: 6 | 7 | Copyright 2011 Karlsruhe Institute of Technology (Institute for Data Processing 8 | and Electronics) and Tomsk Polytechnic University 9 | -------------------------------------------------------------------------------- /python/meson.build: -------------------------------------------------------------------------------- 1 | project('ufo-python', 'c', 2 | default_options : ['c_std=c99', 'warning_level=3'], 3 | version : '1.1.0') 4 | 5 | pymod = import('python') 6 | py3 = pymod.find_installation(required : true) 7 | py3_dep = py3.dependency() 8 | 9 | subdir('src') 10 | subdir('ufo') 11 | -------------------------------------------------------------------------------- /config.h.meson.in: -------------------------------------------------------------------------------- 1 | #mesondefine WITH_PYTHON 2 | #mesondefine HAVE_VIENNACL 3 | #mesondefine UFO_PLUGIN_DIR 4 | #mesondefine UFO_KERNEL_DIR 5 | #mesondefine UFO_VERSION 6 | #mesondefine GLIB_VERSION_MIN_REQUIRED 7 | #mesondefine GLIB_VERSION_MAX_ALLOWED 8 | #mesondefine CL_TARGET_OPENCL_VERSION 9 | #mesondefine UFO_MAX_INPUT_NODES 10 | -------------------------------------------------------------------------------- /docs/manual/install/index.rst: -------------------------------------------------------------------------------- 1 | .. _installation: 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | In this section, information about how to install the UFO library and the 8 | accompanying filter suite is described. 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | linux.rst 14 | mac.rst 15 | docker.rst 16 | windows.rst 17 | -------------------------------------------------------------------------------- /python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = 'ufo' 3 | authors = [ 4 | { name = 'Matthias Vogelgesang', email = 'matthias.vogelgesang@kit.edu'}, 5 | ] 6 | requires_python = '>=3.7' 7 | version = '1.1.0' 8 | 9 | [project.urls] 10 | homepage = 'http://ufo.kit.edu' 11 | 12 | [build-system] 13 | requires = ['meson', 'ninja', 'meson-python', 'numpy'] 14 | build-backend = 'mesonpy' 15 | -------------------------------------------------------------------------------- /tango/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name='tangofu', 5 | version='0.0.1', 6 | author='Matthias Vogelgesang', 7 | author_email='matthias.vogelgesang@kit.edu', 8 | url='http://ufo.kit.edu', 9 | license='(?)', 10 | description='TANGO server for UFO', 11 | long_description='TANGO server for UFO', 12 | scripts=['Ufo'], 13 | install_requires=['PyTango'] 14 | ) 15 | -------------------------------------------------------------------------------- /docs/manual/bugs.rst: -------------------------------------------------------------------------------- 1 | .. _reporting-bugs: 2 | 3 | ============== 4 | Reporting Bugs 5 | ============== 6 | 7 | Bug reports regarding the UFO framework should be submitted to the `ufo-core 8 | issue tracker`_. Anything related to 9 | specific filter behaviour should be filed on the `ufo-filters issue tracker`_. 10 | 11 | .. _ufo-core issue tracker: https://github.com/ufo-kit/ufo-core/issues 12 | .. _ufo-filters issue tracker: https://github.com/ufo-kit/ufo-filters/issues 13 | -------------------------------------------------------------------------------- /tests/unit/meson.build: -------------------------------------------------------------------------------- 1 | sources = [ 2 | 'test-suite.c', 3 | 'test-buffer.c', 4 | 'test-graph.c', 5 | 'test-node.c', 6 | 'test-profiler.c', 7 | 'test-max-input-nodes.cpp' 8 | ] 9 | 10 | test('unit tests', 11 | executable('test-suite', 12 | sources: sources + [enums_h], 13 | include_directories: include_dir, 14 | dependencies: deps, 15 | link_with: lib, 16 | override_options : ['cpp_std=c++11'] 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /docs/manual/index.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | UFO Documentation 3 | ================= 4 | 5 | Users 6 | ===== 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | install/index 12 | using/index 13 | devel 14 | faq 15 | 16 | 17 | Developers 18 | ========== 19 | 20 | .. toctree:: 21 | :maxdepth: 2 22 | 23 | bugs 24 | changelog 25 | 26 | 27 | Additional notes 28 | ================ 29 | 30 | .. toctree:: 31 | :maxdepth: 2 32 | 33 | copyright 34 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine WITH_PYTHON 1 2 | #cmakedefine HAVE_VIENNACL 1 3 | #cmakedefine UFO_MAX_INPUT_NODES ${UFO_MAX_INPUT_NODES} 4 | #define UFO_PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PLUGINDIR}" 5 | #define UFO_KERNEL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_KERNELDIR}" 6 | #define UFO_VERSION "${UFO_VERSION}" 7 | #define GLIB_VERSION_MIN_REQUIRED ${GLIB_VERSION_MIN_REQUIRED} 8 | #define GLIB_VERSION_MAX_ALLOWED ${GLIB_VERSION_MAX_ALLOWED} 9 | #define CL_TARGET_OPENCL_VERSION ${CL_TARGET_OPENCL_VERSION} 10 | -------------------------------------------------------------------------------- /docs/meson.build: -------------------------------------------------------------------------------- 1 | ignore_headers = [ 2 | 'ufo-priv.h', 3 | 'ufo-two-way-queue.h', 4 | ] 5 | 6 | if gtk_doc_dep.found() and get_option('gtk_doc') 7 | gnome.gtkdoc('Ufo', 8 | main_xml: 'Ufo-docs.xml', 9 | dependencies: lib_dep, 10 | gobject_typesfile: 'Ufo.types', 11 | src_dir: join_paths(meson.source_root(), 'ufo'), 12 | scan_args: [ 13 | '--rebuild-types', 14 | '--ignore-headers=' + ' '.join(ignore_headers), 15 | ], 16 | install: true, 17 | ) 18 | endif 19 | 20 | subdir('man') 21 | subdir('manual') 22 | -------------------------------------------------------------------------------- /python/tests/common.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | import shutil 4 | import contextlib 5 | 6 | 7 | def disable(func): 8 | def empty(): 9 | pass 10 | 11 | return empty 12 | 13 | 14 | class TestDir(object): 15 | def __init__(self, path): 16 | self.root = path 17 | 18 | def path(self, name): 19 | return os.path.join(self.root, name) 20 | 21 | def __str__(self): 22 | return self.root 23 | 24 | 25 | @contextlib.contextmanager 26 | def tempdir(): 27 | root = tempfile.mkdtemp() 28 | yield TestDir(root) 29 | shutil.rmtree(root) 30 | -------------------------------------------------------------------------------- /ufo/ufo.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | girdir=${prefix}/@CMAKE_INSTALL_GIRDIR@ 6 | typelibdir=${exec_prefix}/@CMAKE_INSTALL_TYPELIBDIR@ 7 | plugindir=${exec_prefix}/@CMAKE_INSTALL_PLUGINDIR@ 8 | kerneldir=${prefix}/@CMAKE_INSTALL_KERNELDIR@ 9 | 10 | Name: @UFO_NAME@ 11 | Description: @UFO_DESCRIPTION_SUMMARY@ 12 | Version: @UFO_VERSION@ 13 | Libs: -L${libdir} -lufo 14 | Cflags: -I${includedir} 15 | Requires: glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0 json-glib-1.0 16 | -------------------------------------------------------------------------------- /docs/man/ufo-query.1.txt: -------------------------------------------------------------------------------- 1 | ufo-query(1) 2 | ============ 3 | 4 | NAME 5 | ---- 6 | ufo-query - List filters and their properties 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | [verse] 12 | 'ufo-query' [-l] [-p ] [-v] [--version] 13 | 14 | 15 | DESCRIPTION 16 | ----------- 17 | 18 | Lists all plugins or queries properties of a single plugin. 19 | 20 | 21 | OPTIONS 22 | ------- 23 | 24 | *--list*:: 25 | *-l*:: 26 | List all available plugins. 27 | 28 | *--props* 'plugin':: 29 | *-p* 'plugin':: 30 | List all properties of the given 'plugin'. 31 | 32 | *--version*:: 33 | Output version number. 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build*/ 2 | 3 | Makefile.in 4 | 5 | /autom4te.cache 6 | /aclocal.m4 7 | /compile 8 | /configure 9 | /config 10 | /depcomp 11 | /install-sh 12 | /m4 13 | /missing 14 | 15 | stamp-h1 16 | libtool 17 | 18 | common/autotools/config.h 19 | common/autotools/config.h.in 20 | config.log 21 | config.status 22 | *.make 23 | .deps 24 | .libs 25 | 26 | ufo/*ufo-enums.* 27 | 28 | *.o 29 | *.lo 30 | *.a 31 | *.la 32 | *.gir 33 | *.typelib 34 | *.pc 35 | ufod 36 | ufo-runjson 37 | Makefile 38 | 39 | *.pyc 40 | *.swp 41 | python/install_manifest.txt 42 | python/dist 43 | python/ufo.egg-info 44 | /.project 45 | CMakeLists.txt.user 46 | -------------------------------------------------------------------------------- /docs/man/ufo-prof.1.txt: -------------------------------------------------------------------------------- 1 | ufo-prof(1) 2 | =========== 3 | 4 | NAME 5 | ---- 6 | ufo-prof - Analyse profile output from UFO 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | [verse] 12 | 'ufo-prof' [--trace | --opencl] 13 | 14 | 15 | DESCRIPTION 16 | ----------- 17 | 18 | Evaluates the run-time and OpenCL profiling output from the UFO tools. If passed 19 | the files generated, it can determine the input type automatically. Otherwise, 20 | the *--trace* and *--opencl* flags have to be passed. 21 | 22 | OPTIONS 23 | ------- 24 | *--trace*:: 25 | Denotes the input is run-time trace data. 26 | 27 | *--opencl*:: 28 | Denotes the input is OpenCL trace data. 29 | -------------------------------------------------------------------------------- /python/src/meson.build: -------------------------------------------------------------------------------- 1 | pygobject_dep = dependency('pygobject-3.0', version : '>=3.2.2') 2 | ufo_dep = dependency('ufo', version : '>=0.4.0') 3 | 4 | incdir_numpy = run_command(py3, 5 | [ 6 | '-c', 7 | 'import numpy; print(numpy.get_include())' 8 | ], 9 | check: true 10 | ).stdout().strip() 11 | 12 | inc_np = include_directories(incdir_numpy) 13 | np_dep = declare_dependency(include_directories: inc_np) 14 | 15 | src = ['ufo.c'] 16 | 17 | dependencies = [py3_dep, np_dep, ufo_dep, pygobject_dep] 18 | 19 | mod = py3.extension_module('_ufo', 20 | sources : src, 21 | dependencies : dependencies, 22 | install : true, 23 | subdir : 'ufo' 24 | ) 25 | -------------------------------------------------------------------------------- /bin/ufo-launch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _ufo_launch() 4 | { 5 | local cur prev opts tasks 6 | COMPREPLY=() 7 | cur="${COMP_WORDS[COMP_CWORD]}" 8 | prev="${COMP_WORDS[COMP_CWORD-1]}" 9 | opts="--progress --trace --time --address --dump" 10 | tasks="$(ufo-query -l)" 11 | 12 | if [[ "${tasks}" == *"${prev}"* ]]; then 13 | COMPREPLY=( $(compgen -W "$(ufo-query -p ${prev} 2> /dev/null)" -- ${cur}) ) 14 | return 0 15 | fi 16 | 17 | if [[ ${cur} == -* ]] ; then 18 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 19 | return 0 20 | else 21 | COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) ) 22 | return 0 23 | fi 24 | } 25 | 26 | complete -F _ufo_launch ufo-launch 27 | -------------------------------------------------------------------------------- /docs/man/ufo-runjson.1.txt: -------------------------------------------------------------------------------- 1 | ufo-runjson(1) 2 | ============== 3 | 4 | NAME 5 | ---- 6 | ufo-runjson - Run UFO workflows defined as JSON 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | [verse] 12 | 'ufo-runjson' [-t] [-a] [-s dynamic|fixed] [-v] 'FILE.json' 13 | 14 | 15 | DESCRIPTION 16 | ----------- 17 | 18 | Execute the workflow defined in 'FILE.json'. 19 | 20 | 21 | OPTIONS 22 | ------- 23 | *--trace*:: 24 | *-t*:: 25 | Output execution profiles that can be analysed with ufo-prof. 26 | 27 | *--address*:: 28 | *-a*:: 29 | Host address of one or more ufod instances. 30 | 31 | *--scheduler*:: 32 | *-s*:: 33 | Choose a scheduler other than the default dynamic scheduler. 34 | 35 | *--version*:: 36 | Output version number. 37 | -------------------------------------------------------------------------------- /tests/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | set(TEST_SRCS 4 | test-suite.c 5 | test-buffer.c 6 | test-graph.c 7 | test-node.c 8 | test-profiler.c 9 | test-max-input-nodes.cpp 10 | ) 11 | 12 | set(SUITE_BIN "test-suite") 13 | 14 | add_executable(${SUITE_BIN} ${TEST_SRCS}) 15 | 16 | set_property(TARGET ${SUITE_BIN} PROPERTY CXX_STANDARD 11) 17 | set_property(TARGET ${SUITE_BIN} PROPERTY CXX_STANDARD_REQUIRED ON) 18 | 19 | 20 | target_link_libraries(${SUITE_BIN} ufo m ${UFOCORE_DEPS}) 21 | 22 | add_test(${SUITE_BIN} ${SUITE_BIN}) 23 | 24 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/gtester.xsl" 25 | "${CMAKE_CURRENT_BINARY_DIR}/gtester.xsl" 26 | @ONLY IMMEDIATE) 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | dist: trusty 3 | 4 | install: 5 | - curl -L "https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip" -o ninja-linux.zip 6 | - sudo unzip ninja-linux.zip -d /usr/local/bin 7 | - sudo chmod 755 /usr/local/bin/ninja 8 | - 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 libpython-dev python3-pip libgirepository1.0-dev 9 | - sudo pip3 install meson==0.44 10 | 11 | before_script: 12 | - mkdir build-cmake 13 | - cd build-cmake 14 | - cmake .. 15 | - cd .. 16 | - meson build-meson 17 | 18 | script: 19 | - cd build-cmake && make && ./tests/unit/test-suite -p /no-opencl 20 | - cd ../build-meson && ninja && ./tests/unit/test-suite -p /no-opencl 21 | -------------------------------------------------------------------------------- /docs/man/ufo-mkfilter.1.txt: -------------------------------------------------------------------------------- 1 | ufo-mkfilter(1) 2 | =============== 3 | 4 | NAME 5 | ---- 6 | ufo-mkfilter - Create filter skeletons 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | [verse] 12 | ufo-mkfilter [-d] [--use-gpu] [--type ] 'NAME' 13 | 14 | 15 | DESCRIPTION 16 | ----------- 17 | 18 | Creates source and header files for a skeleton task. The camel-cased 'NAME' is 19 | transformed to hyphen-separated lowercase names with .c and .h extensions. 20 | 21 | 22 | OPTIONS 23 | ------- 24 | 25 | *--disable-comments*:: 26 | *-d*:: 27 | Do not output any comments in the source file. 28 | 29 | *--use-gpu*:: 30 | Specify that this task uses GPUs. 31 | 32 | *--type* 'TYPE':: 33 | 'TYPE' must be one of "sink", "filter", "reductor" or "generator". 34 | Appropriate support code is generated. 35 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('gtk_doc', 2 | type: 'boolean', value: false, 3 | description: 'Build API references (requires gtk-doc)') 4 | 5 | option('introspection', 6 | type: 'boolean', value: true, 7 | description: 'Build introspection data (requires gobject-introspection)') 8 | 9 | option('bashcompletiondir', 10 | type: 'string', 11 | description: 'directory for bash complection scripts ["no" disables]') 12 | 13 | option('ufo_max_input_nodes', 14 | type: 'integer', value: 64, 15 | description: 'Maximum number of allowed input nodes for a task') 16 | 17 | option('with_tests', 18 | type: 'boolean', value: false, 19 | description: 'Specifies if tests are build.') 20 | 21 | option('python', 22 | type : 'string', 23 | value : 'python3', 24 | description : 'Name of python executable') 25 | -------------------------------------------------------------------------------- /docs/manual/using/index.rst: -------------------------------------------------------------------------------- 1 | .. _using-ufo: 2 | 3 | ========= 4 | Using UFO 5 | ========= 6 | 7 | UFO is a framework for high-speed image processing at Synchrotron_ beamlines. It 8 | facilitates every available hardware device to process tomographic data as fast 9 | as possible with on-line reconstruction as the ultimate goal. 10 | 11 | .. _Synchrotron: http://en.wikipedia.org/wiki/Synchrotron 12 | 13 | It is written in C using the GLib_ and GObject_ libraries to provide an 14 | object-oriented API. 15 | 16 | .. _GLib: http://developer.gnome.org/glib/ 17 | .. _GObject: http://developer.gnome.org/gobject/stable/index.html 18 | 19 | After :ref:`installing ` the framework you're ready to build your 20 | own image processing pipeline or implement a new filter. 21 | 22 | 23 | .. toctree:: 24 | :maxdepth: 2 25 | 26 | quickstart.rst 27 | api.rst 28 | env.rst 29 | execution.rst 30 | json.rst 31 | -------------------------------------------------------------------------------- /docs/man/meson.build: -------------------------------------------------------------------------------- 1 | a2x = find_program(['a2x', 'a2x.py'], required: false) 2 | 3 | manpage_names = [ 4 | 'ufo-launch.1', 5 | 'ufo-mkfilter.1', 6 | 'ufo-query.1', 7 | 'ufo-prof.1', 8 | 'ufo-runjson.1', 9 | ] 10 | 11 | if a2x.found() 12 | foreach manpage: manpage_names 13 | source = '@0@.txt'.format(manpage) 14 | command = [a2x.path()] 15 | command += [ 16 | '-L', '-d', 'manpage', '-f', 'manpage', 17 | '-D', '@OUTDIR@', 18 | '@INPUT@' 19 | ] 20 | 21 | man = custom_target(manpage, 22 | build_by_default: true, 23 | command: command, 24 | input: source, 25 | output: manpage, 26 | install: true, 27 | install_dir: join_paths(get_option('mandir'), 'man1'), 28 | ) 29 | endforeach 30 | else 31 | message('a2x not found, cannot generate manpages.') 32 | endif 33 | 34 | -------------------------------------------------------------------------------- /docs/manual/install/windows.rst: -------------------------------------------------------------------------------- 1 | .. _installation-windows: 2 | 3 | ################################# 4 | Installation on Windows with WSL2 5 | ################################# 6 | 7 | With Windows 11 and WSL2 it is possible to use Intel OpenCL GPU support. Please 8 | follow `Intel's documentation`_ for detailed installation procedure. Long story 9 | short, you need to install WSL2 and Ubuntu 20.04 from Microsoft Store, then the 10 | Intel `driver`_ *inside Windows* and then `OpenCL runtime`_ *inside Ubuntu 20.04 11 | running in the WSL*. After that, follow the normal installation procedure 12 | (without the nvidia packages) described in :ref:`ubuntu20.04`. 13 | 14 | 15 | .. _Intel's documentation: https://www.intel.com/content/www/us/en/artificial-intelligence/harness-the-power-of-intel-igpu-on-your-machine.html 16 | .. _driver: https://www.intel.com/content/www/us/en/download/19344/30579/intel-graphics-windows-dch-drivers.html? 17 | .. _OpenCL runtime: https://github.com/intel/compute-runtime/releases/tag/21.35.20826 18 | -------------------------------------------------------------------------------- /tests/unit/test-suite.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef TEST_SUITE_H 21 | #define TEST_SUITE_H 22 | 23 | void test_add_buffer (void); 24 | void test_add_graph (void); 25 | void test_add_node (void); 26 | void test_add_profiler (void); 27 | void test_add_max_input_nodes(void); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /docs/manual/meson.build: -------------------------------------------------------------------------------- 1 | sources = [ 2 | 'bugs.rst', 3 | 'changelog.rst', 4 | 'copyright.rst', 5 | 'devel.rst', 6 | 'faq.rst', 7 | 'index.rst', 8 | 'install/docker.rst', 9 | 'install/index.rst', 10 | 'install/linux.rst', 11 | 'install/mac.rst', 12 | 'install/windows.rst', 13 | 'using/api.rst', 14 | 'using/env.rst', 15 | 'using/execution.rst', 16 | 'using/index.rst', 17 | 'using/json.rst', 18 | 'using/quickstart.rst', 19 | ] 20 | 21 | sphinx = find_program('sphinx-build', required: false) 22 | 23 | if sphinx.found() 24 | command = [ 25 | sphinx.path(), 26 | '-q', 27 | '-b', 'html', 28 | meson.current_source_dir(), 29 | meson.current_build_dir(), 30 | ] 31 | 32 | manual = custom_target('manual', 33 | build_by_default: true, 34 | command: command, 35 | input: sources, 36 | output: 'index.html', 37 | ) 38 | 39 | install_subdir(meson.current_build_dir(), install_dir: docdir) 40 | else 41 | message('sphinx not found, cannot generate manual.') 42 | endif 43 | 44 | -------------------------------------------------------------------------------- /common/cmake/PkgConfigVars.cmake: -------------------------------------------------------------------------------- 1 | # - determine variables defined in pkg-config files 2 | # 3 | # Usage: 4 | # pkg_check_variable( ) 5 | # 6 | # Checks for a variable in the given package and translates to a call such as 7 | # `pkg-config --variable= `. The output is a cached 8 | # variable named 9 | # 10 | # _ 11 | # 12 | # Note that both names are uppercased and any dashes replaced by underscores. 13 | # 14 | 15 | find_package(PkgConfig REQUIRED) 16 | 17 | function(pkg_check_variable _pkg _name) 18 | string(TOUPPER ${_pkg} _pkg_upper) 19 | string(TOUPPER ${_name} _name_upper) 20 | string(REPLACE "-" "_" _pkg_upper ${_pkg_upper}) 21 | string(REPLACE "-" "_" _name_upper ${_name_upper}) 22 | set(_output_name "${_pkg_upper}_${_name_upper}") 23 | 24 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg} 25 | OUTPUT_VARIABLE _pkg_result 26 | OUTPUT_STRIP_TRAILING_WHITESPACE) 27 | 28 | set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable 29 | ${_name} of ${_pkg}") 30 | endfunction() 31 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import subprocess 4 | import pkgconfig 5 | import numpy 6 | from setuptools import setup, Extension 7 | 8 | 9 | VERSION = '1.1.0' 10 | 11 | 12 | if not pkgconfig.installed('pygobject-3.0', '>=3.2.2') and \ 13 | not pkgconfig.installed('pygobject-2.0', '>=2.28'): 14 | sys.exit("You must install pygobject-2.0 or pygobject-3.0") 15 | 16 | if not pkgconfig.installed('ufo', '>=0.4.0'): 17 | sys.exit("You must install ufo>=0.4.0") 18 | 19 | def listify(d): 20 | return {k: list(v) for k, v in d.items()} 21 | 22 | build_flags = listify(pkgconfig.parse('pygobject-3.0 ufo')) 23 | 24 | build_flags['include_dirs'].append(numpy.get_include()) 25 | build_flags['extra_compile_args'] = ['-std=c99'] 26 | 27 | setup( 28 | name='ufo', 29 | version=VERSION, 30 | author='Matthias Vogelgesang', 31 | author_email='matthias.vogelgesang@kit.edu', 32 | url='http://ufo.kit.edu', 33 | license='GPL v3 (?)', 34 | description='ufo extension module', 35 | long_description='ufo extension module', 36 | packages=['ufo'], 37 | ext_modules=[Extension('_ufo', ['src/ufo.c'], **build_flags)], 38 | zip_safe=False, 39 | ) 40 | -------------------------------------------------------------------------------- /docs/manual/using/env.rst: -------------------------------------------------------------------------------- 1 | .. _using-env: 2 | 3 | Environment variables 4 | ===================== 5 | 6 | You can modify the run-time behaviour by setting environment variables: 7 | 8 | .. envvar:: G_MESSAGES_DEBUG 9 | 10 | Controls the output of the library. By default nothing is printed on stdout. 11 | Set this to `all` to see debug output. 12 | 13 | .. envvar:: UFO_PLUGIN_PATH 14 | 15 | Colon-separated list of paths in which plugin manager looks for additional 16 | task modules. The plugins are load with descending priority. 17 | 18 | .. envvar:: UFO_KERNEL_PATH 19 | 20 | Colon-separated list of search paths for OpenCL kernel files. 21 | 22 | .. envvar:: UFO_DEVICES 23 | 24 | Controls which OpenCL devices should be used. It works similar to the 25 | `CUDA_VISIBLE_DEVICES` environment variables, i.e. set it to `0,2` to choose 26 | the first and third device that's available. 27 | 28 | .. envvar:: UFO_DEVICE_TYPE 29 | 30 | Controls which OpenCL device types should be considered for execution. The 31 | variable is a comma-separated list with strings being `cpu`, `gpu` and 32 | `acc`, i.e. to use both CPU and GPUs set `UFO_DEVICE_TYPE="cpu,gpu"`. 33 | -------------------------------------------------------------------------------- /python/fabfile.py: -------------------------------------------------------------------------------- 1 | from fabric.api import run, local 2 | from fabric.context_managers import hide 3 | 4 | 5 | def start_ufod(cenv=None, limit=None): 6 | exports = "" 7 | n_gpus = 0 8 | 9 | with hide('stdout'): 10 | smi_output = run('nvidia-smi -L') 11 | n_gpus = len(smi_output.split('\n')) 12 | 13 | n_gpus = min(n_gpus, int(limit)) if limit else n_gpus 14 | 15 | if cenv: 16 | cenv_path = "$HOME/.local/share/cenv/{}".format(cenv) 17 | exports = "PATH=$PATH:{cenv}/bin LD_LIBRARY_PATH={cenv}/lib".format(cenv=cenv_path) 18 | 19 | addresses = ['tcp://141.52.65.18:{}'.format(6666 + i) for i in range(n_gpus)] 20 | 21 | for i in range(n_gpus): 22 | address = 'tcp://141.52.65.18:{}'.format(6666 + i) 23 | run("{} bash -c '((nohup ufod -l {} > /dev/null 2> /dev/null) &)'".format(exports, address), pty=False) 24 | 25 | return addresses 26 | 27 | 28 | def start(cmd='ufo-launch', args=None, cenv=None, limit=None): 29 | addresses = start_ufod(cenv=cenv, limit=limit) 30 | cmd_line = '{} {}'.format(cmd, ' '.join('-a {}'.format(a) for a in addresses)) 31 | 32 | if args: 33 | cmd_line = '{} {}'.format(cmd_line, args) 34 | 35 | local(cmd_line) 36 | -------------------------------------------------------------------------------- /ufo/ufo-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef UFO_PRIV_H 21 | #define UFO_PRIV_H 22 | 23 | #include 24 | 25 | void ufo_write_profile_events (GList *nodes); 26 | void ufo_write_opencl_events (GList *nodes); 27 | gchar * ufo_escape_device_name (gchar *name); 28 | 29 | 30 | /* g_list_for() never existed, but it's nice to have anyway. */ 31 | #define g_list_for(list, it) \ 32 | for (it = g_list_first (list); \ 33 | it != NULL; \ 34 | it = g_list_next (it)) 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: ufo-core 3 | Upstream-Contact: matthias.vogelgesang@kit.edu 4 | Source: https://github.com/ufo-kit/ufo-core/ 5 | 6 | Files: * 7 | Copyright: 2011-2016, Karlsruhe Institute of Technology 8 | License: LGPL-3+ 9 | 10 | Files: debian/* 11 | Copyright: 2016, Picca-Frédéric-Emmanuel Synchrotron-Soleil 12 | License: LGPL-3+ 13 | 14 | Files: ./tools/* 15 | Copyright: 2011-2016, Karlsruhe Institute of Technology 16 | License: GPL-3+ 17 | 18 | License: GPL-3+ 19 | This program is free software; you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation; version 3 dated June, 2007, or (at 22 | your option) any later version. 23 | . 24 | On Debian systems, the complete text of version 3 of the GNU General 25 | Public License can be found in '/usr/share/common-licenses/GPL-3'. 26 | 27 | License: LGPL-3+ 28 | This program is free software; you can redistribute it and/or modify it 29 | under the terms of the GNU Lesser General Public License as published by the 30 | Free Software Foundation; version 3 of the License, or (at 31 | your option) any later version. 32 | . 33 | On Debian systems, the complete text of version 3 of the GNU Lesser 34 | Public License can be found in `/usr/share/common-licenses/LGPL-3'. 35 | -------------------------------------------------------------------------------- /bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | #{{{ Binaries 4 | add_executable(ufo-launch ufo-launch.c) 5 | add_executable(ufo-query ufo-query.c) 6 | add_executable(ufo-runjson ufo-runjson.c) 7 | 8 | target_link_libraries(ufo-launch ufo) 9 | target_link_libraries(ufo-query ufo) 10 | target_link_libraries(ufo-runjson ufo) 11 | 12 | install(TARGETS ufo-launch ufo-query ufo-runjson 13 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 14 | 15 | install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/ufo-prof 16 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 17 | 18 | option(INSTALL_COMPLETION "Install Bash completion script" OFF) 19 | 20 | if (INSTALL_COMPLETION) 21 | pkg_check_variable(bash-completion completionsdir) 22 | 23 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ufo-launch 24 | DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR} 25 | OPTIONAL) 26 | endif() 27 | #}}} 28 | #{{{ ufo-mkfilter 29 | set(CMAKE_INSTALL_TEMPLATEDIR "${CMAKE_INSTALL_FULL_DATADIR}/ufo/templates") 30 | 31 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ufo-mkfilter.in 32 | ${CMAKE_CURRENT_BINARY_DIR}/ufo-mkfilter 33 | @ONLY IMMEDIATE) 34 | 35 | file(GLOB templates "templates/*.in") 36 | 37 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ufo-mkfilter 38 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 39 | 40 | install(FILES ${templates} 41 | DESTINATION ${CMAKE_INSTALL_TEMPLATEDIR}) 42 | #}}} 43 | -------------------------------------------------------------------------------- /ufo/ufo-enums.h.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | /* 3 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 4 | * 5 | * This file is part of Ufo. 6 | * 7 | * This library is free software: you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation, either 10 | * version 3 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library. If not, see . 19 | */ 20 | 21 | #ifndef UFO_ENUMS_H 22 | #define UFO_ENUMS_H 23 | 24 | #include 25 | 26 | G_BEGIN_DECLS 27 | /*** END file-header ***/ 28 | 29 | /*** BEGIN file-production ***/ 30 | 31 | /* enumerations from "@filename@" */ 32 | /*** END file-production ***/ 33 | 34 | /*** BEGIN value-header ***/ 35 | GType @enum_name@_get_type (void) G_GNUC_CONST; 36 | #define UFO_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) 37 | /*** END value-header ***/ 38 | 39 | /*** BEGIN file-tail ***/ 40 | G_END_DECLS 41 | 42 | #endif /* !UFO_ENUMS_H */ 43 | /*** END file-tail ***/ 44 | -------------------------------------------------------------------------------- /docs/man/ufo-launch.1.txt: -------------------------------------------------------------------------------- 1 | ufo-launch(1) 2 | ============= 3 | 4 | NAME 5 | ---- 6 | ufo-launch - Run UFO workflows 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | [verse] 12 | 'ufo-launch' [-t] [-a] [-d] [-q | --quieter] [--version] 13 | [KEY=VALUE] ! ! ... 14 | 15 | 16 | DESCRIPTION 17 | ----------- 18 | 19 | Runs the workflow as specified on the command line. Plugins are specified one by 20 | one and separated by exclamation marks. Further parameterization is possible by 21 | specifying key-value assignments before finishing with an exclamation marks. 22 | 23 | To push data from multiple streams enclose input streams in brackets. 24 | 25 | 26 | OPTIONS 27 | ------- 28 | *--trace*:: 29 | *-t*:: 30 | Output execution profiles that can be analysed with ufo-prof. 31 | 32 | *--address*:: 33 | *-a*:: 34 | Host address of one or more ufod instances. 35 | 36 | *-q*:: 37 | Disable output of "[n] items processed ...". 38 | 39 | *--quieter*:: 40 | Disable all output. 41 | 42 | *--version*:: 43 | Output version number. 44 | 45 | 46 | Examples 47 | -------- 48 | 49 | * Convert TIFF to HDF5: 50 | + 51 | ------------- 52 | $ ufo-launch read path=input*.tif ! write filename=output.h5:/foo 53 | ------------- 54 | 55 | 56 | * Do flat-field-correction: 57 | + 58 | ------------- 59 | $ ufo-launch [read path=radios, read path=darks, read path=flats] ! \ 60 | flat-field-correct ! null 61 | ------------- 62 | -------------------------------------------------------------------------------- /bin/meson.build: -------------------------------------------------------------------------------- 1 | progs = [ 2 | 'ufo-query', 3 | 'ufo-runjson', 4 | ] 5 | 6 | foreach prog: progs 7 | sources = [ 8 | '@0@.c'.format(prog), 9 | enums_h 10 | ] 11 | 12 | executable(prog, 13 | sources: sources, 14 | include_directories: include_dir, 15 | dependencies: deps, 16 | link_with: lib, 17 | install: true 18 | ) 19 | endforeach 20 | 21 | ufo_launch = executable('ufo-launch', 22 | sources: ['ufo-launch.c', enums_h], 23 | include_directories: include_dir, 24 | dependencies: deps, 25 | link_with: lib, 26 | install: true 27 | ) 28 | 29 | completiondir = get_option('bashcompletiondir') 30 | 31 | if completiondir == '' 32 | bash_completion = dependency('bash-completion', required: false) 33 | 34 | if bash_completion.found() 35 | completiondir = bash_completion.get_pkgconfig_variable('completionsdir') 36 | else 37 | completiondir = join_paths(datadir, 'bash-completion/completions') 38 | endif 39 | endif 40 | 41 | if completiondir != 'no' 42 | install_data('ufo-launch', 43 | install_dir: completiondir) 44 | endif 45 | 46 | template_dir = join_paths(get_option('prefix'), get_option('datadir'), 'ufo', 'templates') 47 | mkfilter = configuration_data() 48 | mkfilter.set('CMAKE_INSTALL_TEMPLATEDIR', template_dir) 49 | 50 | configure_file( 51 | input: 'ufo-mkfilter.in', 52 | output: 'ufo-mkfilter', 53 | configuration: mkfilter, 54 | install_dir: get_option('bindir'), 55 | ) 56 | 57 | install_data( 58 | ['templates/ufo-task.c.in', 'templates/ufo-task.h.in'], 59 | install_dir: template_dir, 60 | ) 61 | -------------------------------------------------------------------------------- /docs/manual/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import time 4 | import re 5 | 6 | 7 | def get_version(): 8 | patterns = [ 9 | r'^set\(UFO_VERSION_MAJOR "(\d*)"\)', 10 | r'^set\(UFO_VERSION_MINOR "(\d*)"\)', 11 | r'^set\(UFO_VERSION_PATCH "(\d*)"\)' 12 | ] 13 | version = ["0", "0", "0"] 14 | 15 | with open('../../CMakeLists.txt', 'r') as f: 16 | lines = f.readlines() 17 | major_pattern = r'^set\(UFO_VERSION_MAJOR "(\d*)"\)' 18 | 19 | for line in lines: 20 | for i, pattern in enumerate(patterns): 21 | m = re.match(pattern, line) 22 | 23 | if m: 24 | version[i] = m.group(1) 25 | 26 | return '.'.join(version) 27 | 28 | 29 | project = u'UFO' 30 | copyright = u'%s, UFO Development Team a Collaboration of KIT, SCI and TPU' % time.strftime('%Y') 31 | version = get_version() 32 | release = version 33 | 34 | extensions = [ 35 | 'sphinx.ext.imgmath', 36 | ] 37 | 38 | templates_path = ['_templates'] 39 | 40 | master_doc = 'index' 41 | source_suffix = '.rst' 42 | source_encoding = 'utf-8' 43 | 44 | primary_domain = 'c' 45 | 46 | add_function_parentheses = True 47 | pygments_style = 'sphinx' 48 | 49 | try: 50 | import sphinx_rtd_theme 51 | 52 | html_theme = 'sphinx_rtd_theme' 53 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 54 | except ImportError: 55 | pass 56 | 57 | html_logo = "_static/ufo-logo.png" 58 | html_static_path = ['_static'] 59 | html_use_smartypants = True 60 | 61 | htmlhelp_basename = 'UFOdoc' 62 | 63 | latex_documents = [ 64 | ('index', 'UFO.tex', u'UFO Documentation', 65 | u'Matthias Vogelgesang', 'manual'), 66 | ] 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What is the UFO framework? 2 | 3 | [![Build Status](https://travis-ci.org/ufo-kit/ufo-core.png?branch=master)](https://travis-ci.org/ufo-kit/ufo-core) 4 | 5 | UFO is a multi-threaded, GPU-enabled and distributed data processing 6 | *framework*. It provides base classes, scheduler implementations and run-time 7 | management to describe a workflow as a graph of processing nodes. The nodes are 8 | implemented as plugins in the 9 | [ufo-filters](https://github.com/ufo-kit/ufo-filters) sister project. 10 | 11 | See the `python/` directory for enhanced support of the UFO framework with 12 | Python-based projects and accompanying. The 13 | [ufo-scripts](https://github.com/ufo-kit/ufo-scripts) project is a collection of 14 | small programs for offline reconstruction of tomographic data using the UFO 15 | framework. 16 | 17 | If you want to stay updated, subscribe to our [newsletter](mailto:sympa@lists.kit.edu?subject=subscribe%20ufo%20YourFirstName%20YourLastName). Simply leave the body of the e-mail empty and in the subject change ``YourFirstName YourLastName`` accordingly. 18 | 19 | ## Further information 20 | 21 | More information can be found at various locations: 22 | 23 | * [User manual](http://ufo-core.readthedocs.io) 24 | * [API reference](http://ufo.kit.edu/extra/reference/) 25 | * [Task reference](http://ufo-filters.readthedocs.io) 26 | 27 | 28 | ## License 29 | 30 | Both ufo-core and ufo-filters are licensed under LGPL 3. 31 | 32 | 33 | ## Citation 34 | 35 | If you use this software for publishing your data, we kindly ask to cite the article below. 36 | 37 | Vogelgesang, Matthias, et al. "Real-time image-content-based beamline control for smart 4D X-ray imaging." Journal of synchrotron radiation 23.5 (2016): 1254-1263. 38 | -------------------------------------------------------------------------------- /docker/Dockerfile.nvidia.ubuntu-16.04: -------------------------------------------------------------------------------- 1 | # Initial docker draft by Harinarayan Krishnan 2 | 3 | FROM nvidia/cuda:8.0-devel-ubuntu16.04 4 | 5 | RUN apt-get update && apt-get install -y --no-install-recommends --force-yes \ 6 | git \ 7 | gcc \ 8 | g++ \ 9 | gobject-introspection \ 10 | make \ 11 | ca-certificates \ 12 | cmake \ 13 | liblapack-dev \ 14 | libjpeg-dev \ 15 | libtiff-dev \ 16 | libglib2.0-dev \ 17 | libjson-glib-dev \ 18 | libopenmpi-dev \ 19 | libhdf5-dev \ 20 | libclfft-dev \ 21 | libgsl-dev \ 22 | libgirepository1.0-dev \ 23 | python \ 24 | python-dev \ 25 | python-gobject \ 26 | python-pip \ 27 | python-numpy \ 28 | python-tifffile \ 29 | pkg-config \ 30 | ocl-icd-opencl-dev \ 31 | fftw3-dev \ 32 | clinfo \ 33 | zlib1g-dev && \ 34 | rm -rf /var/lib/apt/lists/* 35 | 36 | ENV LD_LIBRARY_PATH /usr/local/lib/:${LD_LIBRARY_PATH} 37 | 38 | RUN mkdir -p /etc/OpenCL/vendors && \ 39 | echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd 40 | 41 | RUN rm /usr/local/cuda-8.0/targets/x86_64-linux/lib/libOpenCL.so* 42 | 43 | RUN git clone https://github.com/ufo-kit/ufo-core.git && \ 44 | git clone https://github.com/ufo-kit/ufo-filters.git && \ 45 | git clone https://github.com/ufo-kit/tofu 46 | 47 | RUN pip install --upgrade pip && pip install setuptools 48 | 49 | RUN cd /ufo-core && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make install 50 | RUN cd /ufo-filters && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr && make install 51 | RUN cd /tofu && python setup.py install 52 | -------------------------------------------------------------------------------- /tests/unit/test-suite.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include 23 | #include "test-suite.h" 24 | 25 | static void 26 | ignore_log (const gchar *domain, 27 | GLogLevelFlags flags, 28 | const gchar *message, 29 | gpointer data) 30 | { 31 | } 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | #if !(GLIB_CHECK_VERSION (2, 36, 0)) 36 | g_type_init (); 37 | #endif 38 | 39 | g_test_init (&argc, &argv, NULL); 40 | g_test_bug_base ("https://github.com/ufo-kit/ufo-core/issues"); 41 | 42 | g_log_set_handler ("Ufo", G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, ignore_log, NULL); 43 | g_log_set_handler ("ocl", G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, ignore_log, NULL); 44 | 45 | test_add_buffer (); 46 | test_add_graph (); 47 | test_add_profiler (); 48 | test_add_node (); 49 | test_add_max_input_nodes(); 50 | 51 | g_test_run(); 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /ufo/ufo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_H 21 | #define __UFO_H 22 | 23 | #define __UFO_H_INSIDE__ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #undef __UFO_H_INSIDE__ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /tango/README.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | Install the server script with 4 | 5 | $ python setup.py install 6 | 7 | and create a new TANGO server `Ufo/xyz` with a class named `Process`. 8 | 9 | 10 | ## Usage 11 | 12 | Start the device server with 13 | 14 | $ Ufo foo 15 | 16 | Now you can specify the graph with the JSON description string and execute it 17 | using the `Run` command. `Run` returns the job ID which you can use to check if 18 | the process is ongoing. Here's a simple example in Python: 19 | 20 | ```python 21 | import PyTango 22 | import sleep 23 | 24 | json = "{}" # add real description 25 | 26 | process = PyTango.DeviceProxy("foo/process/1") 27 | pid = process.Run() 28 | 29 | while process.Running(pid): 30 | time.sleep(0.5) 31 | 32 | # alternatively you could wait for completion 33 | process.Wait(pid) 34 | 35 | print("Exit code: {}".format(process.ExitCode(pid))) 36 | ``` 37 | 38 | 39 | ## Continuous computation 40 | 41 | Instead of running a single job once, you can keep it "alive" by calling 42 | `RunContinuous` instead of `Run`. Unlike `Run`, `RunContinuous` will not start 43 | computation immediately but must be triggered with the `Continue` command. Each 44 | call to `Continue` transmits the *current* JSON attribute, which means you can 45 | update that in between calls to `Continue`. Note, that you *must* call `Stop` in 46 | order to release the resources allocated by the compute process. Here is an 47 | example: 48 | 49 | ```python 50 | pid = process.RunContinuous() 51 | process.Continue(pid) 52 | process.Wait(pid) 53 | 54 | process.json = "..." # Updated description 55 | process.Continue(pid) 56 | process.Wait(pid) 57 | 58 | process.Stop(pid) 59 | ``` 60 | 61 | The only possible update operation on the JSON description is changes of 62 | parameters. Sending a completely new description will result in undefined 63 | behaviour. 64 | -------------------------------------------------------------------------------- /ufo/ufo-enums.c.template: -------------------------------------------------------------------------------- 1 | /*** BEGIN file-header ***/ 2 | /* 3 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 4 | * 5 | * This file is part of Ufo. 6 | * 7 | * This library is free software: you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation, either 10 | * version 3 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library. If not, see . 19 | */ 20 | 21 | #include 22 | 23 | #include "ufo-enums.h" 24 | 25 | /*** END file-header ***/ 26 | 27 | /*** BEGIN file-production ***/ 28 | /* enumerations from "@filename@" */ 29 | #include "@filename@" 30 | /*** END file-production ***/ 31 | 32 | 33 | /*** BEGIN value-header ***/ 34 | GType 35 | @enum_name@_get_type (void) 36 | { 37 | static volatile gsize g_define_type_id__volatile = 0; 38 | 39 | if (g_once_init_enter (&g_define_type_id__volatile)) { 40 | static const G@Type@Value values[] = { 41 | /*** END value-header ***/ 42 | 43 | /*** BEGIN value-production ***/ 44 | { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, 45 | /*** END value-production ***/ 46 | 47 | /*** BEGIN value-tail ***/ 48 | { 0, NULL, NULL } 49 | }; 50 | GType g_define_type_id = 51 | g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); 52 | 53 | g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); 54 | } 55 | 56 | return g_define_type_id__volatile; 57 | } 58 | 59 | /*** END value-tail ***/ 60 | 61 | /*** BEGIN file-tail ***/ 62 | 63 | /*** END file-tail ***/ 64 | -------------------------------------------------------------------------------- /docs/manual/install/mac.rst: -------------------------------------------------------------------------------- 1 | .. _installation-mac: 2 | 3 | Installation on MacOS X 4 | ======================= 5 | 6 | Preface: This information is kindly provided by Andrey Shkarin and Roman 7 | Shkarin. 8 | 9 | .. highlight:: bash 10 | 11 | 1. Install the MacPorts from http://macports.org 12 | 13 | .. note:: 14 | 15 | If you previously installed MacPorts, and it can not be started after 16 | latest installation. `Error: port dlopen (...` 17 | You must download the tar.gz file and install it using a terminal:: 18 | 19 | ./configure 20 | make 21 | sudo make install 22 | 23 | 2. Install the necessary packages through macports:: 24 | 25 | sudo port install glib2 26 | sudo port install gtk2 27 | sudo port install json-glib 28 | 29 | 3. Install CMake from http://cmake.org 30 | 31 | 4. Make ufo-core 32 | 33 | 1. Got to the directory ufo-core and run:: 34 | 35 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 36 | cmake . 37 | 38 | 2. Run:: 39 | 40 | make 41 | sudo make install 42 | 43 | 3. Installation is complete, perhaps the last lines are as follows:: 44 | 45 | -- Installing: /usr/local/lib/pkgconfig/ufo.pc 46 | CMake Error at src/bindings/cmake_install.cmake:33 (FILE): 47 | file INSTALL cannot find 48 | "/Users/Andrey/Desktop/ufo-distr/ufo-core/src/bindings/../src/Ufo-0.1.gir". 49 | Call Stack (most recent call first): 50 | src/cmake_install.cmake:60 (INCLUDE) 51 | cmake_install.cmake:32 (INCLUDE) 52 | make: *** [install] Error 1 53 | 54 | 5. Make filters 55 | 56 | 1. Go to ufo-filters directory. Now, since libufo was installed in lib64, we must update the paths to look 57 | for shared libraries:: 58 | 59 | export DYLD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 60 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 61 | 62 | 2. Run:: 63 | 64 | cmake . 65 | make 66 | sudo make install 67 | 68 | 6. Build the test project and verify that everything works. 69 | 70 | -------------------------------------------------------------------------------- /ufo/ufo-method-iface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | #include "ufo-method-iface.h" 22 | 23 | /** 24 | * SECTION: ufo-method-iface 25 | * @Short_description: This interface describes a method 26 | * @Title: UfoMethod 27 | * 28 | */ 29 | 30 | typedef UfoMethodIface UfoMethodInterface; 31 | 32 | G_DEFINE_INTERFACE (UfoMethod, ufo_method, G_TYPE_OBJECT) 33 | 34 | gboolean 35 | ufo_method_process (UfoMethod *method, 36 | UfoBuffer *input, 37 | UfoBuffer *output, 38 | gpointer pevent) 39 | { 40 | g_return_val_if_fail(UFO_IS_METHOD (method) && 41 | UFO_IS_BUFFER (input) && 42 | UFO_IS_BUFFER (output), 43 | FALSE); 44 | return UFO_METHOD_GET_IFACE (method)->process (method, input, output, pevent); 45 | } 46 | 47 | static gboolean 48 | ufo_method_process_real (UfoMethod *method, 49 | UfoBuffer *input, 50 | UfoBuffer *output, 51 | gpointer pevent) 52 | { 53 | g_warning ("%s: `process' not implemented", G_OBJECT_TYPE_NAME (method)); 54 | return FALSE; 55 | } 56 | 57 | static void 58 | ufo_method_default_init (UfoMethodInterface *iface) 59 | { 60 | iface->process = ufo_method_process_real; 61 | } 62 | -------------------------------------------------------------------------------- /ufo/ufo-two-way-queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_TWO_WAY_QUEUE_H 21 | #define __UFO_TWO_WAY_QUEUE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | typedef struct _UfoTwoWayQueue UfoTwoWayQueue; 32 | 33 | UfoTwoWayQueue * ufo_two_way_queue_new (GList *init); 34 | void ufo_two_way_queue_free (UfoTwoWayQueue *queue); 35 | gpointer ufo_two_way_queue_consumer_pop (UfoTwoWayQueue *queue); 36 | void ufo_two_way_queue_consumer_push (UfoTwoWayQueue *queue, 37 | gpointer data); 38 | gpointer ufo_two_way_queue_producer_pop (UfoTwoWayQueue *queue); 39 | void ufo_two_way_queue_producer_push (UfoTwoWayQueue *queue, 40 | gpointer data); 41 | void ufo_two_way_queue_insert (UfoTwoWayQueue *queue, 42 | gpointer data); 43 | guint ufo_two_way_queue_get_capacity (UfoTwoWayQueue *queue); 44 | GList * ufo_two_way_queue_get_inserted (UfoTwoWayQueue *queue); 45 | 46 | G_END_DECLS 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /ufo/ufo-copyable-iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef COPYABLE_IFACE_H 21 | #define COPYABLE_IFACE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_COPYABLE (ufo_copyable_get_type()) 32 | #define UFO_COPYABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_COPYABLE, UfoCopyable)) 33 | #define UFO_COPYABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_COPYABLE, UfoCopyableIface)) 34 | #define UFO_IS_COPYABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_COPYABLE)) 35 | #define UFO_IS_COPYABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_COPYABLE)) 36 | #define UFO_COPYABLE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), UFO_TYPE_COPYABLE, UfoCopyableIface)) 37 | 38 | typedef struct _UfoCopyable UfoCopyable; 39 | typedef struct _UfoCopyableIface UfoCopyableIface; 40 | 41 | struct _UfoCopyableIface { 42 | /*< private >*/ 43 | GTypeInterface parent_iface; 44 | 45 | UfoCopyable* (*copy) (gpointer origin, 46 | gpointer copy); 47 | }; 48 | 49 | UfoCopyable * ufo_copyable_copy (gpointer origin, 50 | gpointer copy); 51 | 52 | GType ufo_copyable_get_type (void); 53 | G_END_DECLS 54 | #endif 55 | -------------------------------------------------------------------------------- /tests/unit/test-node.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include 21 | #include "test-suite.h" 22 | 23 | static void 24 | test_constructor (void) 25 | { 26 | UfoNode *node; 27 | 28 | node = ufo_node_new ((gpointer) 0xF00BA); 29 | g_assert_cmpuint (ufo_node_get_index (node), ==, 0); 30 | g_assert_cmpuint (ufo_node_get_total (node), ==, 1); 31 | g_assert (ufo_node_get_label (node) == ((gpointer) 0xF00BA)); 32 | 33 | g_object_unref (node); 34 | } 35 | 36 | static void 37 | test_copy (void) 38 | { 39 | UfoNode *node; 40 | UfoNode *copy; 41 | GError *error = NULL; 42 | 43 | node = ufo_node_new ((gpointer) 0x123456); 44 | copy = ufo_node_copy (node, &error); 45 | g_assert_no_error (error); 46 | 47 | g_assert_cmpuint (ufo_node_get_index (node), ==, 0); 48 | g_assert_cmpuint (ufo_node_get_index (copy), ==, 1); 49 | g_assert_cmpuint (ufo_node_get_total (node), ==, 2); 50 | g_assert_cmpuint (ufo_node_get_total (copy), ==, 2); 51 | g_assert (ufo_node_get_label (copy) == ((gpointer) 0x123456)); 52 | g_assert (ufo_node_equal (node, copy) != TRUE); 53 | 54 | g_object_unref (node); 55 | g_object_unref (copy); 56 | } 57 | 58 | void 59 | test_add_node (void) 60 | { 61 | g_test_add_func ("/no-opencl/node/constructor", 62 | test_constructor); 63 | 64 | g_test_add_func ("/no-opencl/node/copy", 65 | test_copy); 66 | } 67 | -------------------------------------------------------------------------------- /python/tests/test_regressions.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import tifffile 3 | from common import tempdir, disable 4 | from gi.repository import Ufo 5 | 6 | 7 | def test_filters_issue_46_varying_fft_size(): 8 | from ufo import Fft, Ifft 9 | 10 | data = [np.random.random((256, 256)), 11 | np.random.random((512, 512)), 12 | np.random.random((1024, 1024))] 13 | 14 | fft = Fft(dimensions=1) 15 | ifft = Ifft(dimensions=1) 16 | result = list(ifft(fft(data))) 17 | 18 | for orig, processed in zip(data, result): 19 | assert(np.sum(orig - processed) < 1.0) 20 | 21 | 22 | def test_core_issue_61_16_bit_tiffs(): 23 | from ufo import Read, Write 24 | 25 | orig = np.random.randint(0, 65535, (512, 512)).astype(np.uint16) 26 | 27 | with tempdir() as d: 28 | tifffile.imsave(d.path('temp.tif'), orig) 29 | 30 | read = Read(path=d.path('temp.tif')) 31 | write = Write(filename=d.path('temp-%i.tif')) 32 | 33 | write(read()).run().join() 34 | 35 | produced = tifffile.imread(d.path('temp-0.tif')) 36 | assert(np.sum(orig - produced) == 0.0) 37 | 38 | 39 | @disable 40 | def test_core_issue_64_fixed_expansion(): 41 | g = Ufo.TaskGraph() 42 | pm = Ufo.PluginManager() 43 | sched = Ufo.FixedScheduler() 44 | arch = Ufo.ArchGraph() 45 | gpus = arch.get_gpu_nodes() 46 | sched.set_gpu_nodes(arch, gpus) 47 | 48 | generate = pm.get_task('generate') 49 | null = pm.get_task('null') 50 | 51 | generate.set_properties(number=5, width=512, height=512) 52 | 53 | for gpu in gpus: 54 | median = pm.get_task('median-filter') 55 | median.set_proc_node(gpu) 56 | g.connect_nodes(generate, median) 57 | g.connect_nodes(median, null) 58 | 59 | sched.run(g) 60 | 61 | 62 | @disable 63 | def test_core_issue_66_remote_list(): 64 | daemon = Ufo.Daemon.new('tcp://127.0.0.1:5554') 65 | daemon.start() 66 | arch = Ufo.ArchGraph(remotes=['tcp://127.0.0.1:5554']) 67 | daemon.stop() 68 | 69 | 70 | def test_filters_issue_79(): 71 | from ufo import Stack, Slice 72 | 73 | data = [np.ones((512, 512)) for i in range(10)] 74 | 75 | stack = Stack(number=2) 76 | unstack = Slice() 77 | 78 | result = list(unstack(stack(data))) 79 | assert len(result) == len(data) 80 | -------------------------------------------------------------------------------- /ufo/ufo-method-iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef UFO_METHOD_IFACE_H 21 | #define UFO_METHOD_IFACE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_METHOD (ufo_method_get_type()) 33 | #define UFO_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_METHOD, UfoMethod)) 34 | #define UFO_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_METHOD, UfoMethodIface)) 35 | #define UFO_IS_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_METHOD)) 36 | #define UFO_IS_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_METHOD)) 37 | #define UFO_METHOD_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), UFO_TYPE_METHOD, UfoMethodIface)) 38 | 39 | typedef struct _UfoMethod UfoMethod; 40 | typedef struct _UfoMethodIface UfoMethodIface; 41 | 42 | struct _UfoMethodIface { 43 | /*< private >*/ 44 | GTypeInterface parent_iface; 45 | 46 | gboolean (*process) (UfoMethod *method, 47 | UfoBuffer *input, 48 | UfoBuffer *output, 49 | gpointer pevent); 50 | }; 51 | 52 | gboolean 53 | ufo_method_process (UfoMethod *method, 54 | UfoBuffer *input, 55 | UfoBuffer *output, 56 | gpointer pevent); 57 | 58 | GType ufo_method_get_type (void); 59 | 60 | G_END_DECLS 61 | #endif 62 | -------------------------------------------------------------------------------- /python/tests/test_infrastructure.py: -------------------------------------------------------------------------------- 1 | import tifffile 2 | from gi.repository import GLib, Ufo 3 | from nose.tools import raises 4 | from common import tempdir, disable 5 | 6 | 7 | @raises(GLib.GError) 8 | def test_wrong_connection(): 9 | from ufo import Read, FlatFieldCorrect, Write 10 | 11 | darks = Read() 12 | flats = Read() 13 | radios = Read() 14 | write = Write() 15 | ffc = FlatFieldCorrect() 16 | 17 | g = Ufo.TaskGraph() 18 | g.connect_nodes_full(radios.task, ffc.task, 0) 19 | g.connect_nodes_full(darks.task, ffc.task, 1) 20 | g.connect_nodes_full(flats.task, ffc.task, 0) 21 | g.connect_nodes(ffc.task, write.task) 22 | 23 | sched = Ufo.Scheduler() 24 | sched.run(g) 25 | 26 | 27 | def test_task_count(): 28 | from ufo import DummyData, Write, Average 29 | 30 | with tempdir() as d: 31 | generate = DummyData(number=5, width=512, height=512) 32 | write = Write(filename=d.path('foo-%i.tif')) 33 | average = Average() 34 | 35 | write(average(generate())).run().join() 36 | 37 | assert(generate.task.props.num_processed == 0) 38 | assert(average.task.props.num_processed == 5) 39 | assert(write.task.props.num_processed == 1) 40 | 41 | 42 | @disable 43 | def test_broadcast(): 44 | from ufo import Generate, Writer 45 | import glob 46 | 47 | with tempdir() as d: 48 | generate = Generate(number=5, width=512, height=512) 49 | write1 = Writer(filename=d.path('foo-%i.tif')) 50 | write2 = Writer(filename=d.path('bar-%i.tif')) 51 | 52 | g = Ufo.TaskGraph() 53 | g.connect_nodes(generate.task, write1.task) 54 | g.connect_nodes(generate.task, write2.task) 55 | 56 | sched = Ufo.Scheduler() 57 | sched.run(g) 58 | 59 | foos = glob.glob(d.path('foo-*')) 60 | bars = glob.glob(d.path('bar-*')) 61 | assert(len(foos) == 5) 62 | assert(len(bars) == 5) 63 | 64 | 65 | def test_resource_info(): 66 | resources = Ufo.Resources() 67 | nodes = resources.get_gpu_nodes() 68 | assert(nodes) 69 | node = nodes[0] 70 | assert(node.get_info(Ufo.GpuNodeInfo.LOCAL_MEM_SIZE) > 0) 71 | assert(node.get_info(Ufo.GpuNodeInfo.MAX_MEM_ALLOC_SIZE) > 0) 72 | assert(node.get_info(Ufo.GpuNodeInfo.GLOBAL_MEM_SIZE) > node.get_info(Ufo.GpuNodeInfo.LOCAL_MEM_SIZE)) 73 | -------------------------------------------------------------------------------- /docs/Ufo-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ]> 7 | 8 | 9 | UFO Reference Manual 10 | 11 | The latest version of this documentation can be found on-line at 12 | http://ufo.kit.edu/ufo/. 13 | 14 | 15 | 16 | 17 | API Reference 18 | 19 | Graph structures 20 | 21 | 22 | 23 | 24 | Tasks 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Resources 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Schedulers 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | API Index 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /bin/templates/ufo-task.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_{{uppercased}}_TASK_H 21 | #define __UFO_{{uppercased}}_TASK_H 22 | 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define UFO_TYPE_{{uppercased}}_TASK (ufo_{{underscored}}_task_get_type()) 28 | #define UFO_{{uppercased}}_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_{{uppercased}}_TASK, Ufo{{camelcased}}Task)) 29 | #define UFO_IS_{{uppercased}}_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_{{uppercased}}_TASK)) 30 | #define UFO_{{uppercased}}_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_{{uppercased}}_TASK, Ufo{{camelcased}}TaskClass)) 31 | #define UFO_IS_{{uppercased}}_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_{{uppercased}}_TASK)) 32 | #define UFO_{{uppercased}}_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_{{uppercased}}_TASK, Ufo{{camelcased}}TaskClass)) 33 | 34 | typedef struct _Ufo{{camelcased}}Task Ufo{{camelcased}}Task; 35 | typedef struct _Ufo{{camelcased}}TaskClass Ufo{{camelcased}}TaskClass; 36 | typedef struct _Ufo{{camelcased}}TaskPrivate Ufo{{camelcased}}TaskPrivate; 37 | 38 | struct _Ufo{{camelcased}}Task { 39 | UfoTaskNode parent_instance; 40 | 41 | Ufo{{camelcased}}TaskPrivate *priv; 42 | }; 43 | 44 | struct _Ufo{{camelcased}}TaskClass { 45 | UfoTaskNodeClass parent_class; 46 | }; 47 | 48 | UfoNode *ufo_{{underscored}}_task_new (void); 49 | GType ufo_{{underscored}}_task_get_type (void); 50 | 51 | G_END_DECLS 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /tests/unit/test-profiler.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "test-suite.h" 26 | 27 | typedef struct { 28 | UfoProfiler *profiler; 29 | } Fixture; 30 | 31 | 32 | static void 33 | fixture_setup (Fixture *fixture, gconstpointer data) 34 | { 35 | fixture->profiler = ufo_profiler_new (); 36 | g_assert (UFO_IS_PROFILER (fixture->profiler)); 37 | } 38 | 39 | static void 40 | fixture_teardown (Fixture *fixture, gconstpointer data) 41 | { 42 | g_object_unref (fixture->profiler); 43 | } 44 | 45 | static void 46 | test_timer_elapsed (Fixture *fixture, gconstpointer data) 47 | { 48 | gulong one_millisecond = G_USEC_PER_SEC / 1000; 49 | 50 | ufo_profiler_start (fixture->profiler, 51 | UFO_PROFILER_TIMER_IO); 52 | 53 | g_usleep (one_millisecond); 54 | 55 | ufo_profiler_stop (fixture->profiler, 56 | UFO_PROFILER_TIMER_IO); 57 | 58 | g_assert (ufo_profiler_elapsed (fixture->profiler, 59 | UFO_PROFILER_TIMER_CPU) <= 0.0); 60 | 61 | g_assert (ufo_profiler_elapsed (fixture->profiler, 62 | UFO_PROFILER_TIMER_IO) >= 0.001); 63 | } 64 | 65 | 66 | void 67 | test_add_profiler (void) 68 | { 69 | g_test_add ("/no-opencl/timer/elapsed", 70 | Fixture, 71 | NULL, 72 | fixture_setup, 73 | test_timer_elapsed, 74 | fixture_teardown); 75 | } 76 | -------------------------------------------------------------------------------- /docker/Dockerfile.amd.opensuse-13.1: -------------------------------------------------------------------------------- 1 | FROM opensuse:13.1 2 | 3 | RUN zypper --non-interactive --gpg-auto-import-keys ref 4 | 5 | RUN zypper in -y gcc gcc-c++ glib2-devel json-glib-devel 6 | RUN zypper in -y gobject-introspection-devel 7 | RUN zypper in -y gtk-doc python-Sphinx 8 | RUN zypper in -y xorg-x11-driver-video 9 | RUN zypper in -y libtiff-devel 10 | RUN zypper in -y lam lam-devel 11 | RUN zypper in -y python-devel 12 | RUN zypper in -y zeromq-devel 13 | RUN zypper in -y lsb-release 14 | RUN zypper in -y rpm-devel 15 | RUN zypper in -y cmake 16 | RUN zypper in -y make 17 | RUN zypper in -y wget 18 | RUN zypper in -y git 19 | RUN zypper in -y vim 20 | 21 | RUN cd tmp && wget http://geeko.ioda.net/mirror/amd-fglrx/raw-src/amd-driver-installer-15.20.1046-x86.x86_64.run --no-check-certificate && sh amd-driver-installer-15.20.1046-x86.x86_64.run --buildpkg SuSE/SUSE-autodetection && zypper in -y fglrx*15.20.1046*.rpm 22 | 23 | ADD AMD-APP-SDK-v3.0-0.113.50-Beta-linux64.tar.bz2 /tmp/ 24 | ADD answers /tmp/ 25 | RUN cd /tmp && cat answers | ./AMD-APP-SDK-v3.0-0.113.50-Beta-linux64.sh 26 | RUN cd /usr/include && mkdir /usr/include/CL && cd /usr/include/CL && wget https://www.khronos.org/registry/cl/api/1.2/{opencl,cl_platform,cl,cl_ext,cl_gl,cl_gl_ext}.h --no-check-certificate 27 | 28 | RUN GIT_SSL_NO_VERIFY=true git clone https://github.com/ufo-kit/ufo-core 29 | RUN GIT_SSL_NO_VERIFY=true git clone https://github.com/ufo-kit/ufo-filters 30 | RUN GIT_SSL_NO_VERIFY=true git clone https://github.com/ufo-kit/ufo-ir.git 31 | 32 | RUN cd /ufo-core && mkdir build && cd build && export AMDAPPSDKROOT=/usr/AMDAPPSDK-3.0-0-Beta && export LD_LIBRARY_PATH="/usr/AMDAPPSDK-3.0-0-Beta/lib/x86_64/" && export OPENCL_VENDOR_PATH="/usr/AMDAPPSDK-3.0-0-Beta/etc/OpenCL/vendors/" && cmake -DLIBDIR=/usr/lib64 /ufo-core && make && make install && mkdir ufo-filters 33 | 34 | RUN cd /ufo-ir && mkdir build && cd build && export AMDAPPSDKROOT=/usr/AMDAPPSDK-3.0-0-Beta && export LD_LIBRARY_PATH="/usr/AMDAPPSDK-3.0-0-Beta/lib/x86_64/" && export OPENCL_VENDOR_PATH="/usr/AMDAPPSDK-3.0-0-Beta/etc/OpenCL/vendors/" && cmake -DLIBDIR=/usr/lib64 /ufo-ir && make && make install 35 | 36 | RUN cd /ufo-core/build/ufo-filters && export AMDAPPSDKROOT=/usr/AMDAPPSDK-3.0-0-Beta && export LD_LIBRARY_PATH="/usr/AMDAPPSDK-3.0-0-Beta/lib/x86_64/" && export OPENCL_VENDOR_PATH="/usr/AMDAPPSDK-3.0-0-Beta/etc/OpenCL/vendors/" && cmake /ufo-filters -DLIBDIR=/usr/lib64 -DPREFIX=/usr && make && make install 37 | -------------------------------------------------------------------------------- /docker/Dockerfile.nvidia.ubuntu-20.04: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | ARG DEBIAN_FRONTEND=noninteractive 3 | 4 | RUN apt-get update && apt-get -y upgrade && apt-get install -y \ 5 | apt-utils \ 6 | build-essential \ 7 | meson \ 8 | ninja-build \ 9 | git \ 10 | gcc \ 11 | g++ \ 12 | gobject-introspection \ 13 | make \ 14 | ca-certificates \ 15 | cmake \ 16 | liblapack-dev \ 17 | libjpeg-dev \ 18 | libtiff5-dev \ 19 | libglib2.0-dev \ 20 | libjson-glib-dev \ 21 | libopenmpi-dev \ 22 | libhdf5-dev \ 23 | libclfft-dev \ 24 | libgsl-dev \ 25 | libgirepository1.0-dev \ 26 | qt5-default \ 27 | python3 \ 28 | python3-dev \ 29 | python3-gi \ 30 | python-gi-dev \ 31 | python3-sphinx \ 32 | python3-pip \ 33 | python3-numpy \ 34 | python3-cairo \ 35 | python3-gi-cairo \ 36 | python3-sphinx \ 37 | python3-pyqt5 \ 38 | python3-pyqtgraph \ 39 | pkg-config \ 40 | ocl-icd-libopencl1 \ 41 | ocl-icd-opencl-dev \ 42 | fftw3-dev \ 43 | opencl-headers \ 44 | clinfo \ 45 | zlib1g-dev && \ 46 | rm -rf /var/lib/apt/lists/* 47 | 48 | ENV LD_LIBRARY_PATH /usr/local/lib/:${LD_LIBRARY_PATH} 49 | ENV GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0:$GI_TYPELIB_PATH 50 | ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH 51 | 52 | RUN mkdir -p /etc/OpenCL/vendors && \ 53 | echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd 54 | ENV NVIDIA_VISIBLE_DEVICES all 55 | ENV NVIDIA_DRIVER_CAPABILITIES compute,utility 56 | 57 | RUN git clone https://github.com/ufo-kit/ufo-core.git && \ 58 | git clone https://github.com/ufo-kit/ufo-filters.git && \ 59 | git clone https://github.com/ufo-kit/tofu 60 | 61 | RUN pip3 install --upgrade pip && pip3 install setuptools 62 | RUN pip3 install tifffile 63 | 64 | RUN cd /ufo-core && meson build --libdir=lib -Dbashcompletiondir=$HOME/.local/share/bash-completion/completions && cd build && ninja install 65 | RUN cd /ufo-core/python && python3 setup.py install 66 | RUN cd /ufo-filters && meson build --libdir=lib -Dcontrib_filters=True && cd build && ninja install 67 | RUN cd /tofu && pip3 install -r requirements-flow.txt && pip3 install -r requirements-flow.txt && python3 setup.py install 68 | RUN rm -rf /ufo-core /ufo-filters /tofu 69 | -------------------------------------------------------------------------------- /ufo/ufo-copy-task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_COPY_TASK_H 21 | #define __UFO_COPY_TASK_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_COPY_TASK (ufo_copy_task_get_type()) 32 | #define UFO_COPY_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_COPY_TASK, UfoCopyTask)) 33 | #define UFO_IS_COPY_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_COPY_TASK)) 34 | #define UFO_COPY_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_COPY_TASK, UfoCopyTaskClass)) 35 | #define UFO_IS_COPY_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_COPY_TASK)) 36 | #define UFO_COPY_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_COPY_TASK, UfoCopyTaskClass)) 37 | 38 | typedef struct _UfoCopyTask UfoCopyTask; 39 | typedef struct _UfoCopyTaskClass UfoCopyTaskClass; 40 | 41 | /** 42 | * UfoCopyTask: 43 | * 44 | * Main object for organizing filters. The contents of the #UfoCopyTask structure 45 | * are private and should only be accessed via the provided API. 46 | */ 47 | struct _UfoCopyTask { 48 | /*< private >*/ 49 | UfoTaskNode parent_instance; 50 | }; 51 | 52 | /** 53 | * UfoCopyTaskClass: 54 | * 55 | * #UfoCopyTask class 56 | */ 57 | struct _UfoCopyTaskClass { 58 | /*< private >*/ 59 | UfoTaskNodeClass parent_class; 60 | }; 61 | 62 | UfoNode * ufo_copy_task_new (void); 63 | GType ufo_copy_task_get_type (void); 64 | 65 | G_END_DECLS 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | find_program(SPHINX sphinx-build PATHS /usr/local/bin /usr/bin) 4 | find_program(A2X NAMES a2x a2x.py) 5 | mark_as_advanced(SPHINX) 6 | mark_as_advanced(A2X) 7 | 8 | # --- End-user manual --------------------------------------------------------- 9 | if(SPHINX) 10 | option(WITH_MANUAL "Build user manual" ON) 11 | 12 | if (WITH_MANUAL) 13 | set(input_dir ${CMAKE_CURRENT_SOURCE_DIR}/manual) 14 | set(output_dir ${CMAKE_CURRENT_BINARY_DIR}/manual/html) 15 | 16 | file(GLOB_RECURSE sphinx_source ${input_dir}/*.rst) 17 | 18 | foreach(file ${sphinx_static}) 19 | configure_file(${input_dir}/${file} ${output_dir}/${file} COPYONLY) 20 | endforeach() 21 | 22 | add_custom_command(OUTPUT ${output_dir}/index.html 23 | COMMAND ${SPHINX} -b html ${input_dir} ${output_dir} 24 | DEPENDS ${sphinx_source} 25 | COMMENT "Build Sphinx HTML") 26 | 27 | add_custom_target(manual ALL DEPENDS ${output_dir}/index.html) 28 | 29 | add_dependencies(manual ufo) 30 | endif() 31 | endif() 32 | 33 | # --- Manpages # -------------------------------------------------------------- 34 | if (A2X) 35 | option(WITH_MANPAGES "Build manpages" ON) 36 | 37 | if (WITH_MANPAGES) 38 | set(MAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/man) 39 | set(MAN_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/man/man1) 40 | 41 | file(MAKE_DIRECTORY ${MAN_BUILD_DIR}) 42 | 43 | set(A2X_OPTS 44 | -L 45 | -D ${MAN_BUILD_DIR} 46 | -d manpage 47 | -f manpage 48 | ) 49 | 50 | set(MAN_NAMES 51 | ufo-launch.1 52 | ufo-mkfilter.1 53 | ufo-query.1 54 | ufo-prof.1 55 | ufo-runjson.1 56 | ) 57 | 58 | set(MAN_FILES) 59 | 60 | foreach(m IN LISTS MAN_NAMES) 61 | set(mf ${MAN_BUILD_DIR}/${m}) 62 | set(ms ${MAN_SOURCE_DIR}/${m}.txt) 63 | 64 | add_custom_command(OUTPUT ${mf} 65 | COMMAND ${A2X} ${A2X_OPTS} ${ms} 66 | DEPENDS ${ms} 67 | COMMENT "Building manpage ${m}" 68 | VERBATIM) 69 | 70 | list(APPEND MAN_FILES ${mf}) 71 | install(FILES ${mf} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 72 | endforeach() 73 | 74 | add_custom_target(man ALL DEPENDS ${MAN_FILES}) 75 | endif () 76 | endif () 77 | -------------------------------------------------------------------------------- /ufo/ufo-dummy-task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_DUMMY_TASK_H 21 | #define __UFO_DUMMY_TASK_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_DUMMY_TASK (ufo_dummy_task_get_type()) 32 | #define UFO_DUMMY_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_DUMMY_TASK, UfoDummyTask)) 33 | #define UFO_IS_DUMMY_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_DUMMY_TASK)) 34 | #define UFO_DUMMY_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_DUMMY_TASK, UfoDummyTaskClass)) 35 | #define UFO_IS_DUMMY_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_DUMMY_TASK)) 36 | #define UFO_DUMMY_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_DUMMY_TASK, UfoDummyTaskClass)) 37 | 38 | typedef struct _UfoDummyTask UfoDummyTask; 39 | typedef struct _UfoDummyTaskClass UfoDummyTaskClass; 40 | typedef struct _UfoDummyTaskPrivate UfoDummyTaskPrivate; 41 | 42 | /** 43 | * UfoDummyTask: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoDummyTask structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoDummyTask { 49 | /*< private >*/ 50 | UfoTaskNode parent_instance; 51 | 52 | UfoDummyTaskPrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoDummyTaskClass: 57 | * 58 | * #UfoDummyTask class 59 | */ 60 | struct _UfoDummyTaskClass { 61 | /*< private >*/ 62 | UfoTaskNodeClass parent_class; 63 | }; 64 | 65 | UfoNode * ufo_dummy_task_new (void); 66 | GType ufo_dummy_task_get_type (void); 67 | 68 | G_END_DECLS 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /ufo/ufo-cpu-node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_CPU_NODE_H 21 | #define __UFO_CPU_NODE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_CPU_NODE (ufo_cpu_node_get_type()) 32 | #define UFO_CPU_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_CPU_NODE, UfoCpuNode)) 33 | #define UFO_IS_CPU_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_CPU_NODE)) 34 | #define UFO_CPU_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_CPU_NODE, UfoCpuNodeClass)) 35 | #define UFO_IS_CPU_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_CPU_NODE)) 36 | #define UFO_CPU_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_CPU_NODE, UfoCpuNodeClass)) 37 | 38 | typedef struct _UfoCpuNode UfoCpuNode; 39 | typedef struct _UfoCpuNodeClass UfoCpuNodeClass; 40 | typedef struct _UfoCpuNodePrivate UfoCpuNodePrivate; 41 | 42 | /** 43 | * UfoCpuNode: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoCpuNode structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoCpuNode { 49 | /*< private >*/ 50 | UfoNode parent_instance; 51 | 52 | UfoCpuNodePrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoCpuNodeClass: 57 | * 58 | * #UfoCpuNode class 59 | */ 60 | struct _UfoCpuNodeClass { 61 | /*< private >*/ 62 | UfoNodeClass parent_class; 63 | }; 64 | 65 | UfoNode *ufo_cpu_node_new (gpointer mask); 66 | gpointer ufo_cpu_node_get_affinity (UfoCpuNode *node); 67 | GType ufo_cpu_node_get_type (void); 68 | 69 | G_END_DECLS 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /ufo/ufo-copyable-iface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | #include "ufo-copyable-iface.h" 22 | 23 | #define MAX_INHERITANCE_DEPTH 100 24 | 25 | typedef UfoCopyableIface UfoCopyableInterface; 26 | 27 | G_DEFINE_INTERFACE (UfoCopyable, ufo_copyable, G_TYPE_OBJECT) 28 | 29 | /** 30 | * ufo_copyable_copy: 31 | * @origin: A source object that implements #UfoCopyable interface. 32 | * @copy: A destination object that implements #UfoCopyable interface. 33 | * 34 | * Returns: (transfer full): A copy of the @origin object. 35 | */ 36 | UfoCopyable * ufo_copyable_copy (gpointer origin, 37 | gpointer copy) 38 | { 39 | if (!origin) return NULL; 40 | g_return_val_if_fail(UFO_IS_COPYABLE (origin), NULL); 41 | 42 | // call top-level interface implementation 43 | UfoCopyable *_copy = UFO_COPYABLE_GET_IFACE (origin)->copy (origin, copy); 44 | UfoCopyableIface *current_iface = G_TYPE_INSTANCE_GET_INTERFACE(origin, UFO_TYPE_COPYABLE, UfoCopyableIface); 45 | UfoCopyableIface *parent_iface = g_type_interface_peek_parent(current_iface); 46 | 47 | // call parental interface functions 48 | int nested_level = 0; 49 | while (parent_iface && nested_level < MAX_INHERITANCE_DEPTH) { 50 | current_iface = parent_iface; 51 | _copy = parent_iface->copy (origin, copy); 52 | parent_iface = g_type_interface_peek_parent(current_iface); 53 | } 54 | 55 | return _copy; 56 | } 57 | 58 | static UfoCopyable * 59 | ufo_copyable_copy_real (gpointer origin, 60 | gpointer copy) 61 | { 62 | g_warning ("%s: `copy' not implemented", G_OBJECT_TYPE_NAME (origin)); 63 | return NULL; 64 | } 65 | 66 | static void 67 | ufo_copyable_default_init (UfoCopyableInterface *iface) 68 | { 69 | iface->copy = ufo_copyable_copy_real; 70 | } 71 | -------------------------------------------------------------------------------- /docs/manual/using/execution.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Task execution 3 | ============== 4 | 5 | This section provides a deeper look into the technical background concerning 6 | scheduling and task execution. The execution model of the UFO framework is based 7 | on the ``Ufo.TaskGraph`` that represents a network of interconnected task 8 | nodes and the ``Ufo.BaseScheduler`` that runs these tasks according to a 9 | pre-defined strategy. The ``Ufo.Scheduler`` is a concrete implementation and is 10 | the default choice because it is able to instantiate tasks in a multi-GPU 11 | environment. For greater flexibility, the ``Ufo.FixedScheduler`` can be used to 12 | define arbitrary GPU mappings. 13 | 14 | 15 | Profiling execution 16 | =================== 17 | 18 | By default, the scheduler measures the run-time from initial setup until 19 | processing of the last data item finished. You can get the time in seconds via the 20 | ``time`` property :: 21 | 22 | g = Ufo.TaskGraph() 23 | scheduler = Ufo.Scheduler() 24 | scheduler.run(g) 25 | print("Time spent: {}s".format(scheduler.time)) 26 | 27 | To get more fine-grained insight into the execution, you can enable tracing :: 28 | 29 | scheduler.props.enable_tracing = True 30 | scheduler.run(g) 31 | 32 | and analyse the generated traces for OpenCL (saved in ``opencl.PID.json``) and 33 | general events (saved in ``trace.PID.json``). To visualize the trace events, you 34 | can either use the distributed ``ufo-prof`` tool or Google Chrome or Chromium by 35 | going to chrome://tracing and loading the JSON files. 36 | 37 | 38 | Broadcasting results 39 | ==================== 40 | 41 | .. highlight:: python 42 | 43 | Connecting a task output to multiple consumers will in most cases cause 44 | undefined results because some data is processed differently than others. A 45 | certain class of problems can be solved by inserting explicit ``Ufo.CopyTask`` 46 | nodes and executing the graph with a ``Ufo.FixedScheduler``. In the following 47 | example, we want write the same data twice with a different prefix:: 48 | 49 | from gi.repository import Ufo 50 | 51 | pm = Ufo.PluginManager() 52 | sched = Ufo.FixedScheduler() 53 | graph = Ufo.TaskGraph() 54 | copy = Ufo.CopyTask() 55 | 56 | data = pm.get_task('read') 57 | 58 | write1 = pm.get_task('write') 59 | write1.set_properties(filename='w1-%05i.tif') 60 | 61 | write2 = pm.get_task('write') 62 | write2.set_properties(filename='w2-%05i.tif') 63 | 64 | graph.connect_nodes(data, copy) 65 | graph.connect_nodes(copy, write1) 66 | graph.connect_nodes(copy, write2) 67 | 68 | sched.run(graph) 69 | 70 | .. note:: 71 | 72 | The copy task node is not a regular plugin but part of the core API and 73 | thus cannot be used with tools like ``ufo-runjson`` or ``ufo-launch``. 74 | -------------------------------------------------------------------------------- /ufo/ufo-transform-iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef UFO_TRANSFORM_IFACE_H 21 | #define UFO_TRANSFORM_IFACE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_TRANSFORM (ufo_transform_get_type()) 33 | #define UFO_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_TRANSFORM, UfoTransform)) 34 | #define UFO_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_TRANSFORM, UfoTransformIface)) 35 | #define UFO_IS_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_TRANSFORM)) 36 | #define UFO_IS_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_TRANSFORM)) 37 | #define UFO_TRANSFORM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), UFO_TYPE_TRANSFORM, UfoTransformIface)) 38 | 39 | typedef struct _UfoTransform UfoTransform; 40 | typedef struct _UfoTransformIface UfoTransformIface; 41 | 42 | struct _UfoTransformIface { 43 | /*< private >*/ 44 | GTypeInterface parent_iface; 45 | 46 | gboolean (*direct) (UfoTransform *transform, 47 | UfoBuffer *input, 48 | UfoBuffer *output, 49 | gpointer pevent); 50 | 51 | gboolean (*inverse) (UfoTransform *transform, 52 | UfoBuffer *input, 53 | UfoBuffer *output, 54 | gpointer pevent); 55 | }; 56 | 57 | gboolean 58 | ufo_transform_direct (UfoTransform *transform, 59 | UfoBuffer *input, 60 | UfoBuffer *output, 61 | gpointer pevent); 62 | gboolean 63 | ufo_transform_inverse (UfoTransform *transform, 64 | UfoBuffer *input, 65 | UfoBuffer *output, 66 | gpointer pevent); 67 | 68 | GType ufo_transform_get_type (void); 69 | 70 | G_END_DECLS 71 | #endif 72 | -------------------------------------------------------------------------------- /ufo/ufo-scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_SCHEDULER_H 21 | #define __UFO_SCHEDULER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_SCHEDULER (ufo_scheduler_get_type()) 32 | #define UFO_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_SCHEDULER, UfoScheduler)) 33 | #define UFO_IS_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_SCHEDULER)) 34 | #define UFO_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_SCHEDULER, UfoSchedulerClass)) 35 | #define UFO_IS_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_SCHEDULER)) 36 | #define UFO_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_SCHEDULER, UfoSchedulerClass)) 37 | 38 | #define UFO_SCHEDULER_ERROR ufo_scheduler_error_quark() 39 | 40 | typedef struct _UfoScheduler UfoScheduler; 41 | typedef struct _UfoSchedulerClass UfoSchedulerClass; 42 | typedef struct _UfoSchedulerPrivate UfoSchedulerPrivate; 43 | 44 | typedef enum { 45 | UFO_SCHEDULER_ERROR_SETUP 46 | } UfoSchedulerError; 47 | 48 | /** 49 | * UfoScheduler: 50 | * 51 | * The base class scheduler is responsible of assigning command queues to 52 | * filters (thus managing GPU device resources) and decide if to run a GPU or a 53 | * CPU. The actual schedule planning can be overriden. 54 | */ 55 | struct _UfoScheduler { 56 | /*< private >*/ 57 | UfoBaseScheduler parent_instance; 58 | 59 | UfoSchedulerPrivate *priv; 60 | }; 61 | 62 | /** 63 | * UfoSchedulerClass: 64 | * 65 | * #UfoScheduler class 66 | */ 67 | struct _UfoSchedulerClass { 68 | /*< private >*/ 69 | UfoBaseSchedulerClass parent_class; 70 | }; 71 | 72 | UfoBaseScheduler 73 | *ufo_scheduler_new (void); 74 | GType ufo_scheduler_get_type (void); 75 | GQuark ufo_scheduler_error_quark (void); 76 | 77 | G_END_DECLS 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('ufo', ['c', 'cpp'], 2 | version: '0.17.0', 3 | default_options: ['c_std=gnu99'], 4 | ) 5 | 6 | version = meson.project_version() 7 | components = version.split('.') 8 | version_major = components[0] 9 | version_minor = components[1] 10 | version_patch = components[2] 11 | 12 | cc = meson.get_compiler('c') 13 | 14 | gnome = import('gnome') 15 | 16 | glib_dep = dependency('glib-2.0', version: '>= 2.38') 17 | gio_dep = dependency('gio-2.0', version: '>= 2.38') 18 | gobject_dep = dependency('gobject-2.0', version: '>= 2.38') 19 | gmodule_dep = dependency('gmodule-2.0', version: '>= 2.38') 20 | json_dep = dependency('json-glib-1.0', version: '>= 0.10.0') 21 | 22 | pymod = import('python') 23 | python = pymod.find_installation(get_option('python')) 24 | python_dep = python.dependency(required: false, embed: true) 25 | 26 | opencl_dep = dependency('OpenCL', required: false) 27 | 28 | if not opencl_dep.found() 29 | if not cc.has_header('CL/cl.h') 30 | error('Cannot find CL/cl.h') 31 | endif 32 | 33 | opencl_dep = declare_dependency(dependencies: cc.find_library('OpenCL')) 34 | endif 35 | 36 | deps = [ 37 | glib_dep, 38 | gio_dep, 39 | gobject_dep, 40 | gmodule_dep, 41 | json_dep, 42 | opencl_dep, 43 | python_dep, 44 | ] 45 | 46 | include_dir = include_directories('.') 47 | 48 | prefixdir = get_option('prefix') 49 | datadir = join_paths(prefixdir, get_option('datadir')) 50 | docdir = join_paths(datadir, 'doc', 'ufo') 51 | plugindir = join_paths(prefixdir, get_option('libdir'), 'ufo') 52 | kerneldir = join_paths(datadir, 'ufo') 53 | header_dir = 'ufo-@0@'.format(version_major) 54 | header_subdir = join_paths(header_dir, 'ufo') 55 | 56 | conf = configuration_data() 57 | conf.set_quoted('UFO_PLUGIN_DIR', plugindir) 58 | conf.set_quoted('UFO_KERNEL_DIR', kerneldir) 59 | conf.set_quoted('UFO_VERSION', version) 60 | conf.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_38') 61 | conf.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_38') 62 | conf.set('CL_TARGET_OPENCL_VERSION', '120') 63 | conf.set('UFO_MAX_INPUT_NODES', get_option('ufo_max_input_nodes')) 64 | 65 | if python_dep.found() 66 | conf.set('WITH_PYTHON', true) 67 | endif 68 | 69 | configure_file( 70 | input: 'config.h.meson.in', 71 | output: 'config.h', 72 | configuration: conf 73 | ) 74 | 75 | add_global_arguments('-DUFO_COMPILATION', language: 'c') 76 | add_global_arguments('-DCL_USE_DEPRECATED_OPENCL_1_1_APIS', language: 'c') 77 | add_global_arguments('-DCL_USE_DEPRECATED_OPENCL_1_2_APIS', language: 'c') 78 | add_global_arguments('-DGLIB_DISABLE_DEPRECATION_WARNINGS', language: 'c') 79 | 80 | subdir('ufo') 81 | subdir('bin') 82 | 83 | if get_option('gtk_doc') 84 | gtk_doc_dep = dependency('gtk-doc', required: false) 85 | if gtk_doc_dep.found() 86 | subdir('docs') 87 | endif 88 | endif 89 | 90 | if get_option('with_tests') 91 | subdir('tests') 92 | endif 93 | -------------------------------------------------------------------------------- /ufo/ufo-input-task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_INPUT_TASK_H 21 | #define __UFO_INPUT_TASK_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_INPUT_TASK (ufo_input_task_get_type()) 32 | #define UFO_INPUT_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_INPUT_TASK, UfoInputTask)) 33 | #define UFO_IS_INPUT_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_INPUT_TASK)) 34 | #define UFO_INPUT_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_INPUT_TASK, UfoInputTaskClass)) 35 | #define UFO_IS_INPUT_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_INPUT_TASK)) 36 | #define UFO_INPUT_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_INPUT_TASK, UfoInputTaskClass)) 37 | 38 | typedef struct _UfoInputTask UfoInputTask; 39 | typedef struct _UfoInputTaskClass UfoInputTaskClass; 40 | typedef struct _UfoInputTaskPrivate UfoInputTaskPrivate; 41 | 42 | /** 43 | * UfoInputTask: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoInputTask structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoInputTask { 49 | /*< private >*/ 50 | UfoTaskNode parent_instance; 51 | 52 | UfoInputTaskPrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoInputTaskClass: 57 | * 58 | * #UfoInputTask class 59 | */ 60 | struct _UfoInputTaskClass { 61 | /*< private >*/ 62 | UfoTaskNodeClass parent_class; 63 | }; 64 | 65 | UfoNode * ufo_input_task_new (void); 66 | void ufo_input_task_stop (UfoInputTask *task); 67 | void ufo_input_task_release_input_buffer (UfoInputTask *task, 68 | UfoBuffer *buffer); 69 | UfoBuffer * ufo_input_task_get_input_buffer (UfoInputTask *task); 70 | GType ufo_input_task_get_type (void); 71 | 72 | G_END_DECLS 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | 3 | The Python tools for UFO, are addons to make interaction with 4 | [UFO](https://github.com/ufo-kit/ufo-core) easier. 5 | 6 | 7 | ### Numpy integration 8 | 9 | UFO and Numpy buffers can be converted freely between each other: 10 | 11 | ```python 12 | import numpy as np 13 | import ufo.numpy 14 | 15 | # Make Ufo.Buffer from Numpy buffer 16 | a = np.ones((640, 480)) 17 | b = ufo.numpy.fromarray(a) 18 | 19 | # Make Numpy buffer from Ufo.Buffer 20 | a = ufo.numpy.asarray(b) 21 | ``` 22 | 23 | 24 | ### Simpler task setup 25 | 26 | Creating tasks becomes as simple as importing a class: 27 | 28 | ```python 29 | from ufo import Read, Backproject, Write 30 | 31 | read = Read(path='../*.tif') 32 | backproject = Backproject(axis_pos=512.2) 33 | write = Write(filename='foo-%05i.tif') 34 | ``` 35 | 36 | Hooking up tasks is wrapped by calls. You can use the outer call to schedule 37 | execution: 38 | 39 | ```python 40 | scheduler = Ufo.Scheduler() 41 | scheduler.run(write(backproject(read())).graph) 42 | ``` 43 | 44 | or use the `run` method to launch execution asynchronously. `join` on the result 45 | if you want to wait: 46 | 47 | ```python 48 | write(backproject(read())).run().join() 49 | ``` 50 | 51 | If no final endpoint is specified, you must iterate over the data: 52 | 53 | ```python 54 | for item in backproject(read()): 55 | print np.mean(item) 56 | ``` 57 | 58 | Similarly you can also input data by specyifing an iterable of NumPy arrays 59 | 60 | ```python 61 | sinogram = np.ones((512, 512)) 62 | 63 | for slice_data in backproject([sinogram]): 64 | print slice_data 65 | ``` 66 | 67 | 68 | ### TomoPy integration 69 | 70 | Using the `tomopy` module we can hook into the TomoPy pipeline: 71 | 72 | ```python 73 | import tomopy 74 | import ufo.tomopy 75 | 76 | proj, flat, dark = dxchange.read_aps_32id('aps_data.h5', sino=(0, 2)) 77 | proj = tomopy.minus_log(tomopy.normalize(proj, flat, dark)) 78 | center = tomopy.find_center(proj, theta, init=290, ind=0, tol=0.5) 79 | tomopy.recon(proj, theta, center=center, algorithm=ufo.tomopy.fbp, ncore=1) 80 | ``` 81 | 82 | 83 | ### Fabfile for easier cluster setup 84 | 85 | Depending on the use case it is necessary to start several instances of `ufod` 86 | on the same machine. To ease startup and connection one can use the provided 87 | Fabric `fabfile.py` to run binaries that accept the `-a` flag for specifying a 88 | host address. This requires Fabric to be installed on the master machine. To run 89 | a simple pipeline you would issue: 90 | 91 | ```bash 92 | fab -H 123.123.123.123 -u user start:cmd='ufo-launch',args='dummy-data ! blur ! null' 93 | ``` 94 | 95 | This starts as many `ufod` instances on 123.123.123.123 as it has GPUs 96 | installed. To limit the number, you can use the `limit` argument, i.e. 97 | 98 | ```bash 99 | fab start:cmd='ufo-launch',limit=2 100 | ``` 101 | -------------------------------------------------------------------------------- /ufo/ufo-node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_NODE_H 21 | #define __UFO_NODE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_NODE (ufo_node_get_type()) 32 | #define UFO_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_NODE, UfoNode)) 33 | #define UFO_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_NODE)) 34 | #define UFO_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_NODE, UfoNodeClass)) 35 | #define UFO_IS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_NODE)) 36 | #define UFO_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_NODE, UfoNodeClass)) 37 | 38 | typedef struct _UfoNode UfoNode; 39 | typedef struct _UfoNodeClass UfoNodeClass; 40 | typedef struct _UfoNodePrivate UfoNodePrivate; 41 | 42 | /** 43 | * UfoNode: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoNode structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoNode { 49 | /*< private >*/ 50 | GObject parent_instance; 51 | 52 | UfoNodePrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoNodeClass: 57 | * 58 | * #UfoNode class 59 | */ 60 | struct _UfoNodeClass { 61 | /*< private >*/ 62 | GObjectClass parent_class; 63 | 64 | UfoNode * (*copy) (UfoNode *node, 65 | GError **error); 66 | gboolean (*equal) (UfoNode *n1, 67 | UfoNode *n2); 68 | }; 69 | 70 | UfoNode *ufo_node_new (gpointer label); 71 | gpointer ufo_node_get_label (UfoNode *node); 72 | UfoNode *ufo_node_copy (UfoNode *node, 73 | GError **error); 74 | gboolean ufo_node_equal (UfoNode *n1, 75 | UfoNode *n2); 76 | guint ufo_node_get_index (UfoNode *node); 77 | guint ufo_node_get_total (UfoNode *node); 78 | GType ufo_node_get_type (void); 79 | 80 | G_END_DECLS 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /docker/Dockerfile.intel.ubuntu-20.04: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | ARG DEBIAN_FRONTEND=noninteractive 3 | 4 | RUN apt-get update && apt-get -y upgrade && apt-get install -y \ 5 | apt-utils \ 6 | wget \ 7 | build-essential \ 8 | meson \ 9 | ninja-build \ 10 | git \ 11 | gcc \ 12 | g++ \ 13 | gobject-introspection \ 14 | make \ 15 | ca-certificates \ 16 | cmake \ 17 | liblapack-dev \ 18 | libjpeg-dev \ 19 | libtiff5-dev \ 20 | libglib2.0-dev \ 21 | libjson-glib-dev \ 22 | libopenmpi-dev \ 23 | libhdf5-dev \ 24 | libclfft-dev \ 25 | libgsl-dev \ 26 | libgirepository1.0-dev \ 27 | qt5-default \ 28 | python3 \ 29 | python3-dev \ 30 | python3-gi \ 31 | python-gi-dev \ 32 | python3-sphinx \ 33 | python3-pip \ 34 | python3-numpy \ 35 | python3-cairo \ 36 | python3-gi-cairo \ 37 | python3-sphinx \ 38 | python3-pyqt5 \ 39 | python3-pyqtgraph \ 40 | pkg-config \ 41 | fftw3-dev \ 42 | opencl-headers \ 43 | clinfo \ 44 | zlib1g-dev && \ 45 | rm -rf /var/lib/apt/lists/* 46 | 47 | ENV LD_LIBRARY_PATH /usr/local/lib/:${LD_LIBRARY_PATH} 48 | ENV GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0:$GI_TYPELIB_PATH 49 | ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH 50 | 51 | RUN mkdir /intel && cd /intel 52 | RUN wget https://github.com/intel/compute-runtime/releases/download/21.35.20826/intel-gmmlib_21.2.1_amd64.deb 53 | RUN wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.8517/intel-igc-core_1.0.8517_amd64.deb 54 | RUN wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.8517/intel-igc-opencl_1.0.8517_amd64.deb 55 | RUN wget https://github.com/intel/compute-runtime/releases/download/21.35.20826/intel-opencl_21.35.20826_amd64.deb 56 | RUN wget https://github.com/intel/compute-runtime/releases/download/21.35.20826/intel-ocloc_21.35.20826_amd64.deb 57 | RUN wget https://github.com/intel/compute-runtime/releases/download/21.35.20826/intel-level-zero-gpu_1.2.20826_amd64.deb 58 | RUN dpkg -i *.deb 59 | 60 | RUN git clone https://github.com/ufo-kit/ufo-core.git && \ 61 | git clone https://github.com/ufo-kit/ufo-filters.git && \ 62 | git clone https://github.com/ufo-kit/tofu 63 | 64 | RUN pip3 install --upgrade pip && pip3 install setuptools 65 | RUN pip3 install tifffile 66 | 67 | RUN cd /ufo-core && meson build --libdir=lib -Dbashcompletiondir=$HOME/.local/share/bash-completion/completions && cd build && ninja install 68 | RUN cd /ufo-core/python && python3 setup.py install 69 | RUN cd /ufo-filters && meson build --libdir=lib -Dcontrib_filters=True && cd build && ninja install 70 | RUN cd /tofu && pip3 install -r requirements-flow.txt && pip3 install -r requirements-flow.txt && python3 setup.py install 71 | RUN rm -rf /ufo-core /ufo-filters /tofu /intel 72 | -------------------------------------------------------------------------------- /ufo/ufo-processor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_PROCESSOR_H 21 | #define __UFO_PROCESSOR_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_PROCESSOR (ufo_processor_get_type()) 33 | #define UFO_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_PROCESSOR, UfoProcessor)) 34 | #define UFO_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_PROCESSOR)) 35 | #define UFO_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_PROCESSOR, UfoProcessorClass)) 36 | #define UFO_IS_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_PROCESSOR) 37 | #define UFO_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_PROCESSOR, UfoProcessorClass)) 38 | 39 | typedef struct _UfoProcessor UfoProcessor; 40 | typedef struct _UfoProcessorClass UfoProcessorClass; 41 | typedef struct _UfoProcessorPrivate UfoProcessorPrivate; 42 | 43 | /** 44 | * UfoProcessor: 45 | * 46 | * Describes a basic processing element that is used inside a filter 47 | * 48 | */ 49 | struct _UfoProcessor { 50 | /*< private >*/ 51 | GObject parent_instance; 52 | UfoProcessorPrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoProcessorClass: 57 | * 58 | * #UfoProcessor class 59 | */ 60 | struct _UfoProcessorClass { 61 | /*< private >*/ 62 | GObjectClass parent_class; 63 | 64 | void (*setup) (UfoProcessor *processor, 65 | UfoResources *resources, 66 | GError **error); 67 | 68 | void (*configure) (UfoProcessor *processor); 69 | }; 70 | 71 | UfoProcessor* ufo_processor_new (void); 72 | void ufo_processor_setup (UfoProcessor *processor, 73 | UfoResources *resources, 74 | GError **error); 75 | void ufo_processor_configure (UfoProcessor *processor); 76 | GType ufo_processor_get_type (void); 77 | 78 | G_END_DECLS 79 | #endif 80 | -------------------------------------------------------------------------------- /ufo/ufo-output-task.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_OUTPUT_TASK_H 21 | #define __UFO_OUTPUT_TASK_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_OUTPUT_TASK (ufo_output_task_get_type()) 32 | #define UFO_OUTPUT_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_OUTPUT_TASK, UfoOutputTask)) 33 | #define UFO_IS_OUTPUT_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_OUTPUT_TASK)) 34 | #define UFO_OUTPUT_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_OUTPUT_TASK, UfoOutputTaskClass)) 35 | #define UFO_IS_OUTPUT_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_OUTPUT_TASK)) 36 | #define UFO_OUTPUT_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_OUTPUT_TASK, UfoOutputTaskClass)) 37 | 38 | typedef struct _UfoOutputTask UfoOutputTask; 39 | typedef struct _UfoOutputTaskClass UfoOutputTaskClass; 40 | typedef struct _UfoOutputTaskPrivate UfoOutputTaskPrivate; 41 | 42 | /** 43 | * UfoOutputTask: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoOutputTask structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoOutputTask { 49 | /*< private >*/ 50 | UfoTaskNode parent_instance; 51 | 52 | UfoOutputTaskPrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoOutputTaskClass: 57 | * 58 | * #UfoOutputTask class 59 | */ 60 | struct _UfoOutputTaskClass { 61 | /*< private >*/ 62 | UfoTaskNodeClass parent_class; 63 | }; 64 | 65 | UfoNode * ufo_output_task_new (guint n_dims); 66 | void ufo_output_task_get_output_requisition (UfoOutputTask *task, 67 | UfoRequisition *requisition); 68 | UfoBuffer * ufo_output_task_get_output_buffer (UfoOutputTask *task); 69 | void ufo_output_task_release_output_buffer (UfoOutputTask *task, 70 | UfoBuffer *buffer); 71 | GType ufo_output_task_get_type (void); 72 | 73 | G_END_DECLS 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ufo/ufo-fixed-scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_FIXED_SCHEDULER_H 21 | #define __UFO_FIXED_SCHEDULER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_FIXED_SCHEDULER (ufo_fixed_scheduler_get_type()) 33 | #define UFO_FIXED_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_FIXED_SCHEDULER, UfoFixedScheduler)) 34 | #define UFO_IS_FIXED_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_FIXED_SCHEDULER)) 35 | #define UFO_FIXED_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_FIXED_SCHEDULER, UfoFixedSchedulerClass)) 36 | #define UFO_IS_FIXED_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_FIXED_SCHEDULER)) 37 | #define UFO_FIXED_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_FIXED_SCHEDULER, UfoFixedSchedulerClass)) 38 | 39 | #define UFO_FIXED_SCHEDULER_ERROR ufo_fixed_scheduler_error_quark() 40 | 41 | typedef struct _UfoFixedScheduler UfoFixedScheduler; 42 | typedef struct _UfoFixedSchedulerClass UfoFixedSchedulerClass; 43 | typedef struct _UfoFixedSchedulerPrivate UfoFixedSchedulerPrivate; 44 | 45 | typedef enum { 46 | UFO_FIXED_SCHEDULER_ERROR_SETUP 47 | } UfoFixedSchedulerError; 48 | 49 | /** 50 | * UfoFixedScheduler: 51 | * 52 | * The base class scheduler is responsible of assigning command queues to 53 | * filters (thus managing GPU device resources) and decide if to run a GPU or a 54 | * CPU. The actual schedule planning can be overriden. 55 | */ 56 | struct _UfoFixedScheduler { 57 | /*< private >*/ 58 | UfoBaseScheduler parent_instance; 59 | 60 | UfoFixedSchedulerPrivate *priv; 61 | }; 62 | 63 | /** 64 | * UfoFixedSchedulerClass: 65 | * 66 | * #UfoFixedScheduler class 67 | */ 68 | struct _UfoFixedSchedulerClass { 69 | /*< private >*/ 70 | UfoBaseSchedulerClass parent_class; 71 | }; 72 | 73 | UfoBaseScheduler *ufo_fixed_scheduler_new (void); 74 | GType ufo_fixed_scheduler_get_type (void); 75 | GQuark ufo_fixed_scheduler_error_quark (void); 76 | 77 | G_END_DECLS 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /ufo/ufo-group-scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_GROUP_SCHEDULER_H 21 | #define __UFO_GROUP_SCHEDULER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_GROUP_SCHEDULER (ufo_group_scheduler_get_type()) 33 | #define UFO_GROUP_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_GROUP_SCHEDULER, UfoGroupScheduler)) 34 | #define UFO_IS_GROUP_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_GROUP_SCHEDULER)) 35 | #define UFO_GROUP_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_GROUP_SCHEDULER, UfoGroupSchedulerClass)) 36 | #define UFO_IS_GROUP_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_GROUP_SCHEDULER)) 37 | #define UFO_GROUP_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_GROUP_SCHEDULER, UfoGroupSchedulerClass)) 38 | 39 | #define UFO_GROUP_SCHEDULER_ERROR ufo_group_scheduler_error_quark() 40 | 41 | typedef struct _UfoGroupScheduler UfoGroupScheduler; 42 | typedef struct _UfoGroupSchedulerClass UfoGroupSchedulerClass; 43 | typedef struct _UfoGroupSchedulerPrivate UfoGroupSchedulerPrivate; 44 | 45 | typedef enum { 46 | UFO_GROUP_SCHEDULER_ERROR_SETUP 47 | } UfoGroupSchedulerError; 48 | 49 | /** 50 | * UfoGroupScheduler: 51 | * 52 | * The base class scheduler is responsible of assigning command queues to 53 | * filters (thus managing GPU device resources) and decide if to run a GPU or a 54 | * CPU. The actual schedule planning can be overriden. 55 | */ 56 | struct _UfoGroupScheduler { 57 | /*< private >*/ 58 | UfoBaseScheduler parent_instance; 59 | 60 | UfoGroupSchedulerPrivate *priv; 61 | }; 62 | 63 | /** 64 | * UfoGroupSchedulerClass: 65 | * 66 | * #UfoGroupScheduler class 67 | */ 68 | struct _UfoGroupSchedulerClass { 69 | /*< private >*/ 70 | UfoBaseSchedulerClass parent_class; 71 | }; 72 | 73 | UfoBaseScheduler *ufo_group_scheduler_new (void); 74 | GType ufo_group_scheduler_get_type (void); 75 | GQuark ufo_group_scheduler_error_quark (void); 76 | 77 | G_END_DECLS 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /ufo/ufo-local-scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_LOCAL_SCHEDULER_H 21 | #define __UFO_LOCAL_SCHEDULER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_LOCAL_SCHEDULER (ufo_local_scheduler_get_type()) 33 | #define UFO_LOCAL_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_LOCAL_SCHEDULER, UfoLocalScheduler)) 34 | #define UFO_IS_LOCAL_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_LOCAL_SCHEDULER)) 35 | #define UFO_LOCAL_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_LOCAL_SCHEDULER, UfoLocalSchedulerClass)) 36 | #define UFO_IS_LOCAL_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_LOCAL_SCHEDULER)) 37 | #define UFO_LOCAL_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_LOCAL_SCHEDULER, UfoLocalSchedulerClass)) 38 | 39 | #define UFO_LOCAL_SCHEDULER_ERROR ufo_local_scheduler_error_quark() 40 | 41 | typedef struct _UfoLocalScheduler UfoLocalScheduler; 42 | typedef struct _UfoLocalSchedulerClass UfoLocalSchedulerClass; 43 | typedef struct _UfoLocalSchedulerPrivate UfoLocalSchedulerPrivate; 44 | 45 | typedef enum { 46 | UFO_LOCAL_SCHEDULER_ERROR_SETUP 47 | } UfoLocalSchedulerError; 48 | 49 | /** 50 | * UfoLocalScheduler: 51 | * 52 | * The base class scheduler is responsible of assigning command queues to 53 | * filters (thus managing GPU device resources) and decide if to run a GPU or a 54 | * CPU. The actual schedule planning can be overriden. 55 | */ 56 | struct _UfoLocalScheduler { 57 | /*< private >*/ 58 | UfoBaseScheduler parent_instance; 59 | 60 | UfoLocalSchedulerPrivate *priv; 61 | }; 62 | 63 | /** 64 | * UfoLocalSchedulerClass: 65 | * 66 | * #UfoLocalScheduler class 67 | */ 68 | struct _UfoLocalSchedulerClass { 69 | /*< private >*/ 70 | UfoBaseSchedulerClass parent_class; 71 | }; 72 | 73 | UfoBaseScheduler *ufo_local_scheduler_new (void); 74 | GType ufo_local_scheduler_get_type (void); 75 | GQuark ufo_local_scheduler_error_quark (void); 76 | 77 | G_END_DECLS 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /docs/manual/install/docker.rst: -------------------------------------------------------------------------------- 1 | .. _installation-docker: 2 | 3 | ######################## 4 | Installation with Docker 5 | ######################## 6 | 7 | Before, proceeding have a look at the `Docker documentation 8 | `_ and install Docker on your 9 | system. 10 | 11 | 12 | ================== 13 | Rady-to-use Images 14 | ================== 15 | 16 | You can pull the following images from the `ufo-kit 17 | `_ repository on dockerhub without 18 | the need of `Build`_\ing them. They contain the complete software stack including 19 | `ufo-core `_, 20 | `ufo-filters `_, 21 | `tofu `_ and their dependencies (except NVIDIA driver), so after the 22 | installation you can start using all the available tools, including GUIs:: 23 | 24 | docker pull tfarago/ufo-kit:ufo-nvidia-ubuntu-20.04 25 | docker pull tfarago/ufo-kit:ufo-intel-ubuntu-20.04 26 | 27 | ===== 28 | Build 29 | ===== 30 | 31 | Depending on the GPUs in your system you have to use a different Dockerfile. 32 | Before doing so, create an empty directory and copy the respective Dockerfile 33 | from the ``docker`` directory and rename it to ``Dockerfile``. In the case of 34 | the AMD-based Dockerfile you have to download 35 | `AMD-APP-SDK-v3.0-0.113.50-Beta-linux64 36 | `_, 37 | and move it into the same directory. Now go into the directory and type:: 38 | 39 | $ docker build -t ufo . 40 | 41 | This will build an image tagged ``ufo`` containing both ufo-core and 42 | ufo-filters. 43 | 44 | ============ 45 | Usage on AMD 46 | ============ 47 | 48 | Run the image in a new Docker container using:: 49 | 50 | $ docker run -it --device=/dev/ati/card0 ufo 51 | 52 | =============== 53 | Usage on NVIDIA 54 | =============== 55 | 56 | Install `nvidia-container-runtime 57 | `_ and then pull the image:: 58 | 59 | $ docker pull tfarago/ufo-kit:ufo-nvidia-ubuntu-20.04 60 | 61 | and run:: 62 | 63 | $ docker run --rm -it --gpus all tfarago/ufo-kit:ufo-nvidia-ubuntu-20.04 64 | 65 | If you want to use the graphical user interfaces (GUIs) run:: 66 | 67 | $ sudo xhost +local:username 68 | $ docker run --rm -it --gpus all -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY tfarago/ufo-kit:ufo-nvidia-ubuntu-20.04 69 | 70 | 71 | =============== 72 | Usage on Intel 73 | =============== 74 | 75 | First install the OpenCL runtime (Ubuntu-specific but it should be similar for 76 | other distributions):: 77 | 78 | $ sudo apt-get install intel-opencl-icd 79 | 80 | then pull the image:: 81 | 82 | $ docker pull tfarago/ufo-kit:ufo-intel-ubuntu-20.04 83 | 84 | and run the following:: 85 | 86 | $ docker run --rm -it --device /dev/dri:/dev/dri tfarago/ufo-kit:ufo-intel-ubuntu-20.04 87 | 88 | or this for GUI support:: 89 | 90 | $ sudo xhost +local:username 91 | $ docker run --rm -it --device /dev/dri:/dev/dri -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY tfarago/ufo-kit:ufo-intel-ubuntu-20.04 92 | -------------------------------------------------------------------------------- /ufo/ufo-transform-iface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include "ufo-transform-iface.h" 23 | 24 | /** 25 | * SECTION: ufo-transform-iface 26 | * @Short_description: This interface describes the transformation of the data 27 | * such as wavelet transform, etc. 28 | * @Title: UfoTransform 29 | * 30 | */ 31 | 32 | typedef UfoTransformIface UfoTransformInterface; 33 | 34 | G_DEFINE_INTERFACE (UfoTransform, ufo_transform, G_TYPE_OBJECT) 35 | 36 | gboolean 37 | ufo_transform_direct (UfoTransform *transform, 38 | UfoBuffer *input, 39 | UfoBuffer *output, 40 | gpointer pevent) 41 | { 42 | g_return_val_if_fail(UFO_IS_TRANSFORM (transform) && 43 | UFO_IS_BUFFER (input) && 44 | UFO_IS_BUFFER (output), 45 | FALSE); 46 | return UFO_TRANSFORM_GET_IFACE (transform)->direct (transform, input, output, pevent); 47 | } 48 | 49 | gboolean 50 | ufo_transform_inverse (UfoTransform *transform, 51 | UfoBuffer *input, 52 | UfoBuffer *output, 53 | gpointer pevent) 54 | { 55 | g_return_val_if_fail(UFO_IS_TRANSFORM (transform) && 56 | UFO_IS_BUFFER (input) && 57 | UFO_IS_BUFFER (output), 58 | FALSE); 59 | return UFO_TRANSFORM_GET_IFACE (transform)->inverse (transform, input, output, pevent); 60 | } 61 | 62 | static gboolean 63 | ufo_transform_direct_real (UfoTransform *transform, 64 | UfoBuffer *input, 65 | UfoBuffer *output, 66 | gpointer pevent) 67 | { 68 | g_warning ("%s: `direct' not implemented", G_OBJECT_TYPE_NAME (transform)); 69 | return FALSE; 70 | } 71 | 72 | static gboolean 73 | ufo_transform_inverse_real (UfoTransform *transform, 74 | UfoBuffer *input, 75 | UfoBuffer *output, 76 | gpointer pevent) 77 | { 78 | g_warning ("%s: `inverse' not implemented", G_OBJECT_TYPE_NAME (transform)); 79 | return FALSE; 80 | } 81 | 82 | static void 83 | ufo_transform_default_init (UfoTransformInterface *iface) 84 | { 85 | iface->direct = ufo_transform_direct_real; 86 | iface->inverse = ufo_transform_inverse_real; 87 | } 88 | -------------------------------------------------------------------------------- /bin/ufo-mkfilter.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | """ 4 | This file generates GObject file templates that a filter author can use, to 5 | implement their own nodes. 6 | """ 7 | 8 | import os 9 | import sys 10 | import re 11 | import string 12 | import textwrap 13 | import argparse 14 | import jinja2 15 | 16 | 17 | class FilternameAction(argparse.Action): 18 | def __call__(self, parser, namespace, values, option_string=None): 19 | if not re.match(r"^[A-Z][a-z]([A-Z][a-z0-9]*)*", values): 20 | raise argparse.ArgumentTypeError('Name must be a camel-cased C identifier') 21 | setattr(namespace, self.dest, values) 22 | 23 | 24 | def generate_file(args, env, suffix='h'): 25 | camelcased = args.name 26 | hyphenated = args.name[0].lower() + args.name[1:] 27 | 28 | for letter in string.ascii_uppercase: 29 | hyphenated = hyphenated.replace(letter, "-" + letter.lower()) 30 | 31 | underscored = hyphenated.replace('-', '_') 32 | uppercased = underscored.upper() 33 | 34 | template = env.get_template('ufo-task.{0}.in'.format(suffix)) 35 | task_mode = [ 'UFO_TASK_MODE_{}'.format(args.type.upper()) ] 36 | 37 | if args.use_gpu: 38 | task_mode.append('UFO_TASK_MODE_GPU') 39 | 40 | res = template.render(camelcased=camelcased, 41 | uppercased=uppercased, 42 | hyphenated=hyphenated, 43 | underscored=underscored, 44 | task_mode=task_mode, 45 | args=args) 46 | 47 | filename = "ufo-%s-task.%s" % (hyphenated, suffix) 48 | 49 | with open(filename, 'w') as f: 50 | f.writelines(res) 51 | f.close() 52 | print("Wrote %s" % filename) 53 | 54 | 55 | if __name__ == '__main__': 56 | parser = argparse.ArgumentParser(description='Generate UfoNode skeletons') 57 | parser.add_argument('-d', '--disable-comments', 58 | action='store_false', 59 | help='Do not insert comments into source files') 60 | parser.add_argument('--use-gpu', 61 | action='store_true', 62 | help='The task requires a GPU') 63 | parser.add_argument('--type', choices=['sink', 'processor', 'reductor', 'generator'], 64 | default='processor', 65 | help='Type of the generated task') 66 | parser.add_argument('name', type=str, 67 | action=FilternameAction, 68 | help='Name of the new filter in CamelCase') 69 | 70 | try: 71 | args = parser.parse_args() 72 | except argparse.ArgumentTypeError as err: 73 | print(err) 74 | sys.exit(1) 75 | 76 | template_dir = '@CMAKE_INSTALL_TEMPLATEDIR@' 77 | 78 | if not os.path.exists(template_dir): 79 | template_dir = 'templates' 80 | 81 | loader = jinja2.FileSystemLoader(template_dir) 82 | env = jinja2.Environment(loader=loader, trim_blocks=True) 83 | 84 | generate_file(args, env, 'h') 85 | generate_file(args, env, 'c') 86 | 87 | message = "If you are about to write a UFO internal filter, you should copy \ 88 | the generated files into core/filters and adapt the CMakeLists.txt file. You \ 89 | should only add the filter sources to ${ufo_SRCS} if all build dependencies are \ 90 | met for your particular plugin. Good luck!" 91 | 92 | print("") 93 | print(textwrap.fill(message)) 94 | -------------------------------------------------------------------------------- /ufo/ufo-dummy-task.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include 23 | 24 | #ifdef __APPLE__ 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | #include "ufo-dummy-task.h" 31 | 32 | /** 33 | * SECTION:ufo-dummy-task 34 | * @Short_description: A dummy task that does nothing 35 | * @Title: UfoDummyTask 36 | * 37 | * A dummy task that can be inserted into a #UfoTaskGraph but does not do 38 | * anything. 39 | */ 40 | 41 | static void ufo_task_interface_init (UfoTaskIface *iface); 42 | 43 | G_DEFINE_TYPE_WITH_CODE (UfoDummyTask, ufo_dummy_task, UFO_TYPE_TASK_NODE, 44 | G_IMPLEMENT_INTERFACE (UFO_TYPE_TASK, 45 | ufo_task_interface_init)) 46 | 47 | #define UFO_DUMMY_TASK_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UFO_TYPE_DUMMY_TASK, UfoDummyTaskPrivate)) 48 | 49 | enum { 50 | PROP_0, 51 | N_PROPERTIES 52 | }; 53 | 54 | UfoNode * 55 | ufo_dummy_task_new (void) 56 | { 57 | return UFO_NODE (g_object_new (UFO_TYPE_DUMMY_TASK, NULL)); 58 | } 59 | 60 | static void 61 | ufo_dummy_task_setup (UfoTask *task, 62 | UfoResources *resources, 63 | GError **error) 64 | { 65 | } 66 | 67 | static void 68 | ufo_dummy_task_get_requisition (UfoTask *task, 69 | UfoBuffer **inputs, 70 | UfoRequisition *requisition, 71 | GError **error) 72 | { 73 | } 74 | 75 | static guint 76 | ufo_dummy_task_get_num_inputs (UfoTask *task) 77 | { 78 | return 0; 79 | } 80 | 81 | static guint 82 | ufo_dummy_task_get_num_dimensions (UfoTask *task, 83 | guint input) 84 | { 85 | return 0; 86 | } 87 | 88 | static UfoTaskMode 89 | ufo_dummy_task_get_mode (UfoTask *task) 90 | { 91 | return UFO_TASK_MODE_PROCESSOR | UFO_TASK_MODE_CPU; 92 | } 93 | 94 | static void 95 | ufo_task_interface_init (UfoTaskIface *iface) 96 | { 97 | iface->setup = ufo_dummy_task_setup; 98 | iface->get_num_inputs = ufo_dummy_task_get_num_inputs; 99 | iface->get_num_dimensions = ufo_dummy_task_get_num_dimensions; 100 | iface->get_mode = ufo_dummy_task_get_mode; 101 | iface->get_requisition = ufo_dummy_task_get_requisition; 102 | } 103 | 104 | static void 105 | ufo_dummy_task_class_init (UfoDummyTaskClass *klass) 106 | { 107 | } 108 | 109 | static void 110 | ufo_dummy_task_init (UfoDummyTask *task) 111 | { 112 | ufo_task_node_set_plugin_name (UFO_TASK_NODE (task), "[dummy]"); 113 | } 114 | -------------------------------------------------------------------------------- /ufo/ufo-gpu-node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_GPU_NODE_H 21 | #define __UFO_GPU_NODE_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_GPU_NODE (ufo_gpu_node_get_type()) 32 | #define UFO_GPU_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_GPU_NODE, UfoGpuNode)) 33 | #define UFO_IS_GPU_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_GPU_NODE)) 34 | #define UFO_GPU_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_GPU_NODE, UfoGpuNodeClass)) 35 | #define UFO_IS_GPU_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_GPU_NODE)) 36 | #define UFO_GPU_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_GPU_NODE, UfoGpuNodeClass)) 37 | 38 | typedef struct _UfoGpuNode UfoGpuNode; 39 | typedef struct _UfoGpuNodeClass UfoGpuNodeClass; 40 | typedef struct _UfoGpuNodePrivate UfoGpuNodePrivate; 41 | 42 | /** 43 | * UfoGpuNode: 44 | * 45 | * Main object for organizing filters. The contents of the #UfoGpuNode structure 46 | * are private and should only be accessed via the provided API. 47 | */ 48 | struct _UfoGpuNode { 49 | /*< private >*/ 50 | UfoNode parent_instance; 51 | 52 | UfoGpuNodePrivate *priv; 53 | }; 54 | 55 | /** 56 | * UfoGpuNodeClass: 57 | * 58 | * #UfoGpuNode class 59 | */ 60 | struct _UfoGpuNodeClass { 61 | /*< private >*/ 62 | UfoNodeClass parent_class; 63 | }; 64 | 65 | /** 66 | * UfoGpuNodeInfo: 67 | * @UFO_GPU_NODE_INFO_GLOBAL_MEM_SIZE: Global memory size 68 | * @UFO_GPU_NODE_INFO_MAX_MEM_ALLOC_SIZE: Maximum allocatable global memory size 69 | * @UFO_GPU_NODE_INFO_LOCAL_MEM_SIZE: Local memory size 70 | * @UFO_GPU_NODE_INFO_MAX_WORK_GROUP_SIZE: Maximum work group size 71 | * @UFO_GPU_NODE_INFO_NAME: Name of the associated device 72 | * 73 | * OpenCL device info types. Refer to the OpenCL standard for complete details 74 | * about each information. 75 | */ 76 | typedef enum { 77 | UFO_GPU_NODE_INFO_GLOBAL_MEM_SIZE = 0, 78 | UFO_GPU_NODE_INFO_MAX_MEM_ALLOC_SIZE, 79 | UFO_GPU_NODE_INFO_LOCAL_MEM_SIZE, 80 | UFO_GPU_NODE_INFO_MAX_WORK_GROUP_SIZE, 81 | UFO_GPU_NODE_INFO_NAME 82 | } UfoGpuNodeInfo; 83 | 84 | UfoNode *ufo_gpu_node_new (gpointer context, 85 | gpointer device); 86 | gpointer ufo_gpu_node_get_cmd_queue (UfoGpuNode *node); 87 | GValue *ufo_gpu_node_get_info (UfoGpuNode *node, 88 | UfoGpuNodeInfo info); 89 | GType ufo_gpu_node_get_type (void); 90 | 91 | G_END_DECLS 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /tests/unit/gtester.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | g_test 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /ufo/meson.build: -------------------------------------------------------------------------------- 1 | sources = [ 2 | 'ufo-base-scheduler.c', 3 | 'ufo-basic-ops.c', 4 | 'ufo-buffer.c', 5 | 'ufo-copy-task.c', 6 | 'ufo-copyable-iface.c', 7 | 'ufo-cpu-node.c', 8 | 'ufo-dummy-task.c', 9 | 'ufo-fixed-scheduler.c', 10 | 'ufo-gpu-node.c', 11 | 'ufo-graph.c', 12 | 'ufo-group.c', 13 | 'ufo-group-scheduler.c', 14 | 'ufo-input-task.c', 15 | 'ufo-local-scheduler.c', 16 | 'ufo-method-iface.c', 17 | 'ufo-node.c', 18 | 'ufo-output-task.c', 19 | 'ufo-plugin-manager.c', 20 | 'ufo-priv.c', 21 | 'ufo-profiler.c', 22 | 'ufo-processor.c', 23 | 'ufo-resources.c', 24 | 'ufo-scheduler.c', 25 | 'ufo-task-iface.c', 26 | 'ufo-task-graph.c', 27 | 'ufo-task-node.c', 28 | 'ufo-transform-iface.c', 29 | 'ufo-two-way-queue.c', 30 | ] 31 | 32 | headers = [ 33 | 'ufo.h', 34 | 'ufo-base-scheduler.h', 35 | 'ufo-basic-ops.h', 36 | 'ufo-buffer.h', 37 | 'ufo-copy-task.h', 38 | 'ufo-copyable-iface.h', 39 | 'ufo-cpu-node.h', 40 | 'ufo-dummy-task.h', 41 | 'ufo-fixed-scheduler.h', 42 | 'ufo-gpu-node.h', 43 | 'ufo-graph.h', 44 | 'ufo-group.h', 45 | 'ufo-group-scheduler.h', 46 | 'ufo-input-task.h', 47 | 'ufo-local-scheduler.h', 48 | 'ufo-method-iface.h', 49 | 'ufo-node.h', 50 | 'ufo-output-task.h', 51 | 'ufo-plugin-manager.h', 52 | 'ufo-profiler.h', 53 | 'ufo-processor.h', 54 | 'ufo-resources.h', 55 | 'ufo-scheduler.h', 56 | 'ufo-task-iface.h', 57 | 'ufo-task-graph.h', 58 | 'ufo-task-node.h', 59 | 'ufo-transform-iface.h', 60 | 'ufo-two-way-queue.h', 61 | ] 62 | 63 | enums = gnome.mkenums('ufo-enums', 64 | sources: headers, 65 | h_template: 'ufo-enums.h.template', 66 | c_template: 'ufo-enums.c.template', 67 | install_header: true, 68 | install_dir: '@0@/@1@'.format(get_option('includedir'), header_subdir), 69 | ) 70 | 71 | enums_c = enums[0] 72 | enums_h = enums[1] 73 | 74 | sources += [enums_c, enums_h] 75 | 76 | m_dep = declare_dependency( 77 | dependencies: cc.find_library('m') 78 | ) 79 | 80 | lib = library('ufo', 81 | sources: sources, 82 | dependencies: deps + [m_dep], 83 | version: version, 84 | soversion: version_major, 85 | include_directories: include_dir, 86 | install: true, 87 | ) 88 | 89 | lib_dep = declare_dependency( 90 | link_with: lib, 91 | include_directories: include_dir, 92 | dependencies: deps + [m_dep] 93 | ) 94 | 95 | gir = find_program('g-ir-scanner', required: false) 96 | 97 | if gir.found() and get_option('introspection') 98 | gnome.generate_gir(lib, 99 | namespace: 'Ufo', 100 | nsversion: '@0@.0'.format(version_major), 101 | sources: sources + headers, 102 | install: true, 103 | includes: [ 104 | 'GLib-2.0', 105 | 'GObject-2.0', 106 | 'GModule-2.0', 107 | 'Json-1.0', 108 | ], 109 | ) 110 | endif 111 | 112 | pkg = import('pkgconfig') 113 | 114 | pkg.generate( 115 | libraries: [lib], 116 | version: version, 117 | name: 'ufo', 118 | description: 'Library for unified scientific camera access', 119 | requires: [ 120 | 'glib-2.0', 121 | 'gobject-2.0', 122 | 'gmodule-2.0', 123 | 'gio-2.0', 124 | 'json-glib-1.0', 125 | ], 126 | variables: [ 127 | 'plugindir=${libdir}/ufo', 128 | 'kerneldir=${prefix}/@0@/ufo'.format(get_option('datadir')), 129 | ], 130 | subdirs: [ 131 | header_dir 132 | ], 133 | ) 134 | 135 | install_headers(headers, subdir: header_subdir) 136 | -------------------------------------------------------------------------------- /docs/manual/using/json.rst: -------------------------------------------------------------------------------- 1 | .. _json-configuration: 2 | 3 | .. highlight:: javascript 4 | 5 | ========================= 6 | JSON Configuration Format 7 | ========================= 8 | 9 | JSON_ is a self-contained, human-readable data-interchange format. It is pure 10 | Unicode text and language independent. The main structures objects containing 11 | key/value pairs (hash-tables, dictionaries, associative arrays ...) and ordered 12 | lists (arrays, vectors, sequences ...) of objects or values. For a complete 13 | description you may refer to the complete reference at `json.org 14 | `_. 15 | 16 | The configuration of a filter setup is stored in a JSON-encoded text file with a 17 | ``.json`` suffix. The root object must at least contain a ``nodes`` and an 18 | ``edges`` array :: 19 | 20 | { "nodes": [], "edges": [] } 21 | 22 | 23 | Nodes array 24 | =========== 25 | 26 | The nodes array contains filter objects that are executed on run-time. 27 | Information how they are connected is provided in the `Edges array`_. 28 | 29 | Filter object 30 | ------------- 31 | 32 | A filter consists at least of a ``plugin`` key string pointing to the filter 33 | that is going to be used and a ``name`` string field for unique identification. 34 | Of course, plugins have to be available as a shared object in UFO's path. 35 | 36 | .. highlight:: python 37 | 38 | To configure the filter, the ``properties`` field can be used. This is an object 39 | that maps string keys specifying the actual filter property to the value. 40 | Therefore, the Python code to set a property :: 41 | 42 | read = graph.get_filter('read') 43 | read.set_properties(path='/home/user/data/*.tif', count=5) 44 | 45 | .. highlight:: javascript 46 | 47 | translates to :: 48 | 49 | { "path": "/home/user/data/*.tif", "count": 5 } 50 | 51 | 52 | Example nodes array 53 | ------------------- 54 | 55 | An example node array looks like this:: 56 | 57 | "nodes" : [ 58 | { 59 | "plugin": "read", 60 | "name": "read", 61 | "properties" : { "path": "/home/user/data/*.tif", "count": 5 } 62 | }, 63 | { 64 | "plugin": "write", 65 | "name": "write" 66 | } 67 | ] 68 | 69 | 70 | Edges array 71 | =========== 72 | 73 | The edges array specifies how the nodes in a `Nodes array`_ are connected. Each 74 | entry is an object that contains two objects ``from`` and ``to``. In both 75 | objects you have to specify at least the node name with the ``name`` key. 76 | Furthermore, if there are several inputs or outputs on a node, you have to tell 77 | which input and output to use with the ``input`` on the ``to`` node and the 78 | ``output`` key on the ``from`` node. If you omit these, they are assumed to be 79 | 0. 80 | 81 | To connect the nodes defined in the `Example nodes array`_ all you have to do is :: 82 | 83 | "edges" : [ 84 | { 85 | "from": {"name": "read"}, 86 | "to": {"name": "write", "input": 2} 87 | } 88 | ] 89 | 90 | Note, that the names specify the name of the node, not the plugin. 91 | 92 | 93 | Loading and Saving the Graph 94 | ============================ 95 | 96 | .. highlight:: python 97 | 98 | The ``UfoGraph`` class exports the ``ufo_graph_read_from_json`` and 99 | ``ufo_graph_read_save_to_json`` methods which are responsible for loading and 100 | saving the graph. In Python this would simply be:: 101 | 102 | from gi.repository import Ufo 103 | 104 | g1 = Ufo.TaskGraph() 105 | 106 | # set up the filters using graph.get_filter() and filter.connect_to() 107 | 108 | g1.run() 109 | g1.save_to_json('graph.json') 110 | 111 | g2 = Ufo.TaskGraph() 112 | g2.load_from_json('graph.json') 113 | g2.run() 114 | 115 | 116 | .. _JSON: http://json.org 117 | -------------------------------------------------------------------------------- /bin/ufo-query.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2015 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of ufo-launch. 5 | * 6 | * runjson is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * runjson is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public 17 | * License along with runjson. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include "ufo/ufo.h" 23 | #include "ufo/ufo-priv.h" 24 | 25 | 26 | static gboolean list = FALSE; 27 | static gchar *prop_name = NULL; 28 | static gboolean verbose = FALSE; 29 | static gboolean version = FALSE; 30 | 31 | 32 | static void 33 | list_tasks (UfoPluginManager *pm) 34 | { 35 | GList *names; 36 | GList *it; 37 | 38 | names = ufo_plugin_manager_get_all_task_names (pm); 39 | 40 | g_list_for (names, it) { 41 | g_print ("%s\n", (const gchar *) it->data); 42 | } 43 | 44 | g_list_free (names); 45 | g_object_unref (pm); 46 | } 47 | 48 | static void 49 | list_properties (UfoPluginManager *pm, const gchar *name) 50 | { 51 | UfoTaskNode *task; 52 | guint n_props; 53 | GParamSpec **props; 54 | GError *error = NULL; 55 | 56 | task = ufo_plugin_manager_get_task (pm, name, &error); 57 | 58 | if (error != NULL) { 59 | g_printerr ("Error: %s\n", error->message); 60 | return; 61 | } 62 | 63 | props = g_object_class_list_properties (G_OBJECT_GET_CLASS (task), &n_props); 64 | 65 | for (guint i = 0; i < n_props; i++) { 66 | if (g_strcmp0 (props[i]->name, "num-processed")) { 67 | g_print ("%s\n", g_param_spec_get_name (props[i])); 68 | 69 | if (verbose) { 70 | g_print (" type: %s\n", g_type_name (props[i]->value_type)); 71 | g_print (" help: %s\n", g_param_spec_get_blurb (props[i])); 72 | 73 | if (i < n_props - 1) 74 | g_print ("\n"); 75 | } 76 | } 77 | } 78 | 79 | g_free (props); 80 | g_object_unref (task); 81 | } 82 | 83 | int 84 | main(int argc, char* argv[]) 85 | { 86 | UfoPluginManager *pm; 87 | GOptionContext *context; 88 | GError *error = NULL; 89 | 90 | static GOptionEntry entries[] = { 91 | { "list", 'l', 0, G_OPTION_ARG_NONE, &list, "list available tasks", NULL }, 92 | { "props", 'p', 0, G_OPTION_ARG_STRING, &prop_name, "Properties of given task", NULL }, 93 | { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL }, 94 | { "version", 0, 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL }, 95 | { NULL } 96 | }; 97 | 98 | #if !(GLIB_CHECK_VERSION (2, 36, 0)) 99 | g_type_init (); 100 | #endif 101 | 102 | context = g_option_context_new (NULL); 103 | g_option_context_add_main_entries (context, entries, NULL); 104 | 105 | if (!g_option_context_parse (context, &argc, &argv, &error)) { 106 | g_printerr ("Error parsing options: %s\n", error->message); 107 | return 1; 108 | } 109 | 110 | if (version) { 111 | g_print ("%s version " UFO_VERSION "\n", argv[0]); 112 | return 0; 113 | } 114 | 115 | 116 | pm = ufo_plugin_manager_new (); 117 | 118 | if (list) 119 | list_tasks (pm); 120 | 121 | if (prop_name) 122 | list_properties (pm, prop_name); 123 | 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /ufo/ufo-copy-task.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #ifdef WITH_PYTHON 23 | #include 24 | #endif 25 | 26 | #ifdef __APPLE__ 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | #include 33 | 34 | #include "ufo-copy-task.h" 35 | #include "ufo-task-iface.h" 36 | #include "ufo-priv.h" 37 | 38 | /** 39 | * SECTION:ufo-copy-task 40 | * @Short_description: Copy data from input to output 41 | * @Title: UfoCopyTask 42 | * 43 | * Copies input to output. This is useful in combination with a 44 | * #UfoFixedScheduler in order to emulate broadcasting behaviour. 45 | */ 46 | 47 | static void ufo_task_interface_init (UfoTaskIface *iface); 48 | 49 | G_DEFINE_TYPE_WITH_CODE (UfoCopyTask, ufo_copy_task, UFO_TYPE_TASK_NODE, 50 | G_IMPLEMENT_INTERFACE (UFO_TYPE_TASK, 51 | ufo_task_interface_init)) 52 | 53 | enum { 54 | PROP_0, 55 | N_PROPERTIES 56 | }; 57 | 58 | UfoNode * 59 | ufo_copy_task_new (void) 60 | { 61 | return UFO_NODE (g_object_new (UFO_TYPE_COPY_TASK, NULL)); 62 | } 63 | 64 | static void 65 | ufo_copy_task_setup (UfoTask *task, 66 | UfoResources *resources, 67 | GError **error) 68 | { 69 | } 70 | 71 | static guint 72 | ufo_copy_task_get_num_inputs (UfoTask *task) 73 | { 74 | return 1; 75 | } 76 | 77 | static guint 78 | ufo_copy_task_get_num_dimensions (UfoTask *task, 79 | guint input) 80 | { 81 | return -1; 82 | } 83 | 84 | static UfoTaskMode 85 | ufo_copy_task_get_mode (UfoTask *task) 86 | { 87 | return UFO_TASK_MODE_PROCESSOR | UFO_TASK_MODE_CPU; 88 | } 89 | 90 | static void 91 | ufo_copy_task_get_requisition (UfoTask *task, 92 | UfoBuffer **inputs, 93 | UfoRequisition *requisition, 94 | GError **error) 95 | { 96 | ufo_buffer_get_requisition (inputs[0], requisition); 97 | } 98 | 99 | static gboolean 100 | ufo_copy_task_process (UfoTask *task, 101 | UfoBuffer **inputs, 102 | UfoBuffer *output, 103 | UfoRequisition *requisition) 104 | { 105 | ufo_buffer_copy (inputs[0], output); 106 | return TRUE; 107 | } 108 | 109 | static void 110 | ufo_task_interface_init (UfoTaskIface *iface) 111 | { 112 | iface->setup = ufo_copy_task_setup; 113 | iface->get_num_inputs = ufo_copy_task_get_num_inputs; 114 | iface->get_num_dimensions = ufo_copy_task_get_num_dimensions; 115 | iface->get_mode = ufo_copy_task_get_mode; 116 | iface->get_requisition = ufo_copy_task_get_requisition; 117 | iface->process = ufo_copy_task_process; 118 | } 119 | 120 | static void 121 | ufo_copy_task_class_init (UfoCopyTaskClass *klass) 122 | { 123 | } 124 | 125 | static void 126 | ufo_copy_task_init (UfoCopyTask *task) 127 | { 128 | ufo_task_node_set_plugin_name (UFO_TASK_NODE (task), "broadcast-task"); 129 | } 130 | -------------------------------------------------------------------------------- /ufo/ufo-two-way-queue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #include "config.h" 21 | 22 | #include "ufo-two-way-queue.h" 23 | #include "ufo-priv.h" 24 | 25 | 26 | struct _UfoTwoWayQueue { 27 | GAsyncQueue *producer_queue; 28 | GAsyncQueue *consumer_queue; 29 | GList *inserted; 30 | guint capacity; 31 | }; 32 | 33 | /** 34 | * ufo_two_way_queue_new: (skip) 35 | * @init: (element-type gpointer): List with elements inserted into 36 | * consumer queue 37 | * 38 | * Create a new two-way queue and optionally initialize the consumer queue with 39 | * elements from @init. 40 | * 41 | * Returns: A new #UfoTwoWayQueue. 42 | */ 43 | UfoTwoWayQueue * 44 | ufo_two_way_queue_new (GList *init) 45 | { 46 | GList *it; 47 | UfoTwoWayQueue *queue = g_new0 (UfoTwoWayQueue, 1); 48 | 49 | queue->producer_queue = g_async_queue_new (); 50 | queue->consumer_queue = g_async_queue_new (); 51 | queue->inserted = NULL; 52 | queue->capacity = 0; 53 | 54 | g_list_for (init, it) { 55 | ufo_two_way_queue_insert (queue, it->data); 56 | } 57 | 58 | return queue; 59 | } 60 | 61 | void 62 | ufo_two_way_queue_free (UfoTwoWayQueue *queue) 63 | { 64 | g_async_queue_unref (queue->producer_queue); 65 | g_async_queue_unref (queue->consumer_queue); 66 | g_list_free (queue->inserted); 67 | g_free (queue); 68 | } 69 | 70 | /** 71 | * ufo_two_way_queue_consumer_pop: 72 | * @queue: A #UfoTwoWayQueue 73 | * 74 | * Fetch an item for consumption. 75 | * 76 | * Returns: (transfer none): A consumable item. 77 | */ 78 | gpointer 79 | ufo_two_way_queue_consumer_pop (UfoTwoWayQueue *queue) 80 | { 81 | return g_async_queue_pop (queue->consumer_queue); 82 | } 83 | 84 | void 85 | ufo_two_way_queue_consumer_push (UfoTwoWayQueue *queue, gpointer data) 86 | { 87 | g_async_queue_push (queue->producer_queue, data); 88 | } 89 | 90 | /** 91 | * ufo_two_way_queue_producer_pop: 92 | * @queue: A #UfoTwoWayQueue 93 | * 94 | * Fetch an item for production. 95 | * 96 | * Returns: (transfer none): A producable item. 97 | */ 98 | gpointer 99 | ufo_two_way_queue_producer_pop (UfoTwoWayQueue *queue) 100 | { 101 | return g_async_queue_pop (queue->producer_queue); 102 | } 103 | 104 | void 105 | ufo_two_way_queue_producer_push (UfoTwoWayQueue *queue, gpointer data) 106 | { 107 | g_async_queue_push (queue->consumer_queue, data); 108 | } 109 | 110 | /** 111 | * ufo_two_way_queue_get_inserted: (skip) 112 | * @queue: A #UfoTwoWayQueue 113 | * 114 | * Fetch all items ever inserted. 115 | * 116 | * Returns: (element-type gpointer) (transfer none): A list with all items. 117 | */ 118 | GList * 119 | ufo_two_way_queue_get_inserted (UfoTwoWayQueue *queue) 120 | { 121 | return queue->inserted; 122 | } 123 | 124 | void 125 | ufo_two_way_queue_insert (UfoTwoWayQueue *queue, gpointer data) 126 | { 127 | g_async_queue_push (queue->producer_queue, data); 128 | queue->inserted = g_list_append (queue->inserted, data); 129 | queue->capacity++; 130 | } 131 | 132 | guint 133 | ufo_two_way_queue_get_capacity (UfoTwoWayQueue *queue) 134 | { 135 | return queue->capacity; 136 | } 137 | -------------------------------------------------------------------------------- /ufo/ufo-base-scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_BASE_SCHEDULER_H 21 | #define __UFO_BASE_SCHEDULER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_BASE_SCHEDULER (ufo_base_scheduler_get_type()) 32 | #define UFO_BASE_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_BASE_SCHEDULER, UfoBaseScheduler)) 33 | #define UFO_IS_BASE_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_BASE_SCHEDULER)) 34 | #define UFO_BASE_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_BASE_SCHEDULER, UfoBaseSchedulerClass)) 35 | #define UFO_IS_BASE_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_BASE_SCHEDULER)) 36 | #define UFO_BASE_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_BASE_SCHEDULER, UfoBaseSchedulerClass)) 37 | 38 | #define UFO_BASE_SCHEDULER_ERROR ufo_base_scheduler_error_quark() 39 | 40 | typedef struct _UfoBaseScheduler UfoBaseScheduler; 41 | typedef struct _UfoBaseSchedulerClass UfoBaseSchedulerClass; 42 | typedef struct _UfoBaseSchedulerPrivate UfoBaseSchedulerPrivate; 43 | 44 | typedef enum { 45 | UFO_BASE_SCHEDULER_ERROR_SETUP, 46 | UFO_BASE_SCHEDULER_ERROR_EXECUTION 47 | } UfoBaseSchedulerError; 48 | 49 | /** 50 | * UfoBaseScheduler: 51 | * 52 | * The base class scheduler is responsible of assigning command queues to 53 | * filters (thus managing GPU device resources) and decide if to run a GPU or a 54 | * CPU. The actual schedule planning can be overriden. 55 | */ 56 | struct _UfoBaseScheduler { 57 | /*< private >*/ 58 | GObject parent_instance; 59 | 60 | UfoBaseSchedulerPrivate *priv; 61 | }; 62 | 63 | /** 64 | * UfoBaseSchedulerClass: 65 | * 66 | * #UfoBaseScheduler class 67 | */ 68 | struct _UfoBaseSchedulerClass { 69 | /*< private >*/ 70 | GObjectClass parent_class; 71 | 72 | void (*run) (UfoBaseScheduler *scheduler, UfoTaskGraph *graph, GError **error); 73 | void (*abort) (UfoBaseScheduler *scheduler); 74 | }; 75 | 76 | void ufo_base_scheduler_run (UfoBaseScheduler *scheduler, 77 | UfoTaskGraph *task_graph, 78 | GError **error); 79 | void ufo_base_scheduler_abort (UfoBaseScheduler *scheduler); 80 | void ufo_base_scheduler_set_resources (UfoBaseScheduler *scheduler, 81 | UfoResources *resources); 82 | UfoResources *ufo_base_scheduler_get_resources (UfoBaseScheduler *scheduler, 83 | GError **error); 84 | void ufo_base_scheduler_set_gpu_nodes (UfoBaseScheduler *scheduler, 85 | GList *gpu_nodes); 86 | GType ufo_base_scheduler_get_type (void); 87 | GQuark ufo_base_scheduler_error_quark (void); 88 | 89 | G_END_DECLS 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /ufo/ufo-cpu-node.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #define _GNU_SOURCE 21 | 22 | #include "config.h" 23 | 24 | #include 25 | 26 | #include "ufo-cpu-node.h" 27 | 28 | G_DEFINE_TYPE (UfoCpuNode, ufo_cpu_node, UFO_TYPE_NODE) 29 | 30 | #define UFO_CPU_NODE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UFO_TYPE_CPU_NODE, UfoCpuNodePrivate)) 31 | 32 | 33 | struct _UfoCpuNodePrivate { 34 | #ifdef __APPLE__ 35 | gpointer mask; 36 | #else 37 | cpu_set_t *mask; 38 | #endif 39 | }; 40 | 41 | UfoNode * 42 | ufo_cpu_node_new (gpointer mask) 43 | { 44 | UfoCpuNode *node; 45 | 46 | g_return_val_if_fail (mask != NULL, NULL); 47 | node = UFO_CPU_NODE (g_object_new (UFO_TYPE_CPU_NODE, NULL)); 48 | #ifdef __APPLE__ 49 | node->priv->mask = g_memdup (mask, sizeof (gpointer)); 50 | #else 51 | node->priv->mask = g_memdup (mask, sizeof (cpu_set_t)); 52 | #endif 53 | return UFO_NODE (node); 54 | } 55 | 56 | /** 57 | * ufo_cpu_node_get_affinity: 58 | * @node: A #UfoCpuNode 59 | * 60 | * Get affinity mask of @node. 61 | * 62 | * Returns: (transfer none): A pointer to the cpu_set_t mask associated with 63 | * @node. 64 | */ 65 | gpointer 66 | ufo_cpu_node_get_affinity (UfoCpuNode *node) 67 | { 68 | g_return_val_if_fail (UFO_IS_CPU_NODE (node), NULL); 69 | return node->priv->mask; 70 | } 71 | 72 | static void 73 | ufo_cpu_node_finalize (GObject *object) 74 | { 75 | UfoCpuNodePrivate *priv; 76 | 77 | priv = UFO_CPU_NODE_GET_PRIVATE (object); 78 | 79 | if (priv->mask) { 80 | g_free (priv->mask); 81 | priv->mask = NULL; 82 | } 83 | 84 | G_OBJECT_CLASS (ufo_cpu_node_parent_class)->finalize (object); 85 | } 86 | 87 | static UfoNode * 88 | ufo_cpu_node_copy_real (UfoNode *node, 89 | GError **error) 90 | { 91 | return UFO_NODE (ufo_cpu_node_new (UFO_CPU_NODE (node)->priv->mask)); 92 | } 93 | 94 | static gboolean 95 | ufo_cpu_node_equal_real (UfoNode *n1, 96 | UfoNode *n2) 97 | { 98 | UfoCpuNodePrivate *priv1; 99 | UfoCpuNodePrivate *priv2; 100 | 101 | #ifndef __APPLE__ 102 | const gsize MAX_CPUS = MIN (16, CPU_SETSIZE); 103 | #else 104 | const gsize MAX_CPUS = 16; 105 | #endif 106 | 107 | g_return_val_if_fail (UFO_IS_CPU_NODE (n1) && UFO_IS_CPU_NODE (n2), FALSE); 108 | priv1 = UFO_CPU_NODE_GET_PRIVATE (n1); 109 | priv2 = UFO_CPU_NODE_GET_PRIVATE (n2); 110 | 111 | #ifndef __APPLE__ 112 | for (gsize i = 0; i < MAX_CPUS; i++) { 113 | if (CPU_ISSET (i, priv1->mask) != CPU_ISSET (i, priv2->mask)) 114 | return FALSE; 115 | } 116 | #endif 117 | 118 | return TRUE; 119 | } 120 | 121 | static void 122 | ufo_cpu_node_class_init (UfoCpuNodeClass *klass) 123 | { 124 | GObjectClass *object_class = G_OBJECT_CLASS (klass); 125 | UfoNodeClass *node_class = UFO_NODE_CLASS (klass); 126 | 127 | object_class->finalize = ufo_cpu_node_finalize; 128 | node_class->copy = ufo_cpu_node_copy_real; 129 | node_class->equal = ufo_cpu_node_equal_real; 130 | 131 | g_type_class_add_private(klass, sizeof(UfoCpuNodePrivate)); 132 | } 133 | 134 | static void 135 | ufo_cpu_node_init (UfoCpuNode *self) 136 | { 137 | UfoCpuNodePrivate *priv; 138 | self->priv = priv = UFO_CPU_NODE_GET_PRIVATE (self); 139 | priv->mask = NULL; 140 | } 141 | -------------------------------------------------------------------------------- /docs/manual/faq.rst: -------------------------------------------------------------------------------- 1 | .. _faq: 2 | 3 | ========================== 4 | Frequently Asked Questions 5 | ========================== 6 | 7 | Installation 8 | ============ 9 | 10 | .. _faq-linker-cant-find-libufo: 11 | 12 | Why can't the linker find libufo.so? 13 | ---------------------------------------- 14 | 15 | In the rare circumstances that you installed UFO from source for the first time 16 | by calling ``make install``, the dynamic linker does not know that the library 17 | exists. If this is the case issue :: 18 | 19 | $ sudo ldconfig 20 | 21 | on Debian systems or :: 22 | 23 | $ su 24 | $ ldconfig 25 | 26 | on openSUSE systems. 27 | 28 | If this is not working, the library is neither installed into ``/usr/lib`` nor 29 | ``/usr/local/lib`` on 32-bit systems or ``/usr/lib64`` and ``/usr/local/lib64`` 30 | on 64-bit systems. 31 | 32 | 33 | How are kernel files loaded? 34 | ---------------------------- 35 | 36 | In a similar way as plugins. However, OpenCL kernel files are not architecture 37 | specific and are installed to ``${PREFIX}/share/ufo``. Additional search paths 38 | can be added at run-time through the :envvar:`UFO_KERNEL_PATH` environment 39 | variable. 40 | 41 | 42 | Usage 43 | ===== 44 | 45 | .. _faq-filter-not-found: 46 | 47 | Why do I get a "libfilter.so not found" message? 48 | ------------------------------------------------------- 49 | 50 | Because the UFO core system is unable to locate the filters. By default it looks 51 | into ``${LIBDIR}/ufo``. If you don't want to install the filters system-wide, 52 | you can tell the system to try other paths as well by appending paths to the 53 | ``UFO_PLUGIN_PATH`` :ref:`environment variable `. 54 | 55 | 56 | How can I control the debug output from libufo? 57 | ----------------------------------------------- 58 | 59 | Generally, UFO emits debug messages under the log domain ``Ufo``. If you use a 60 | UFO-based tool and cannot see debug messages, you might have to enable them by 61 | setting the ``G_MESSAGES_DEBUG`` environment variable, i.e.:: 62 | 63 | export G_MESSAGES_DEBUG=Ufo 64 | 65 | To handle these messages from within a script or program, you must set a log 66 | handler_ that decides what to do with the messages. To ignore all messages in 67 | Python, you would have to write something like this:: 68 | 69 | from gi.repository import Ufo, GLib 70 | 71 | def ignore_message(domain, level, message, user): 72 | pass 73 | 74 | if __name__ == '__main__': 75 | GLib.log_set_handler("Ufo", GLib.LogLevelFlags.LEVEL_MASK, 76 | ignore_message, None) 77 | 78 | .. _handler: http://developer.gnome.org/glib/unstable/glib-Message-Logging.html#g-log-set-handler 79 | 80 | 81 | .. _faq-numpy-output: 82 | 83 | How can I use Numpy output? 84 | --------------------------- 85 | 86 | Install the ``ufo-python-tools``. You can then use the BufferInput filter to 87 | process Numpy arrays data:: 88 | 89 | from gi.repository import Ufo 90 | import ufo.numpy 91 | import numpy as np 92 | 93 | arrays = [ i*np.eye(100, dtype=np.float32) for i in range(1, 10) ] 94 | buffers = [ ufo.numpy.fromarray(a) for a in arrays ] 95 | 96 | pm = Ufo.PluginManager() 97 | numpy_input = pm.get_task('bufferinput') 98 | numpy_input.set_properties(buffers=buffers) 99 | 100 | 101 | .. _faq-synchronize-properties: 102 | 103 | How can I synchronize two properties? 104 | ------------------------------------- 105 | 106 | Although this is a general GObject question, synchronizing two properties is 107 | particularly important if the receiving filter depends on a changed property. 108 | For example, the back-projection should start only if a center-of-rotation is 109 | known. In Python you can use the ``bind_property`` function from the 110 | ``ufotools`` module like this:: 111 | 112 | from gi.repository import Ufo 113 | import ufotools.bind_property 114 | 115 | pm = Ufo.PluginManager() 116 | cor = g.get_task('centerofrotation') 117 | bp = g.get_task('backproject') 118 | 119 | # Now connect the properties 120 | ufotools.bind_property(cor, 'center', bp, 'axis-pos') 121 | 122 | In C, the similar ``g_object_bind_property`` function is provided out-of-the-box. 123 | -------------------------------------------------------------------------------- /ufo/ufo-group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_GROUP_H 21 | #define __UFO_GROUP_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define UFO_TYPE_GROUP (ufo_group_get_type()) 33 | #define UFO_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_GROUP, UfoGroup)) 34 | #define UFO_IS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_GROUP)) 35 | #define UFO_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_GROUP, UfoGroupClass)) 36 | #define UFO_IS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_GROUP)) 37 | #define UFO_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_GROUP, UfoGroupClass)) 38 | 39 | typedef struct _UfoGroup UfoGroup; 40 | typedef struct _UfoGroupClass UfoGroupClass; 41 | typedef struct _UfoGroupPrivate UfoGroupPrivate; 42 | 43 | #define UFO_END_OF_STREAM (GINT_TO_POINTER(1)) 44 | 45 | /** 46 | * UfoSendPattern: 47 | * @UFO_SEND_BROADCAST: Broadcast data to all connected nodes 48 | * @UFO_SEND_SCATTER: Scatter data among connected nodes. 49 | * @UFO_SEND_SEQUENTIAL: Break up a linear input stream and transfer sub streams 50 | * one by one to connected nodes. 51 | * 52 | * The send pattern describes how results are passed to connected nodes. 53 | */ 54 | typedef enum { 55 | UFO_SEND_BROADCAST, 56 | UFO_SEND_SCATTER, 57 | UFO_SEND_SEQUENTIAL 58 | } UfoSendPattern; 59 | 60 | /** 61 | * UfoGroup: 62 | * 63 | * Main object for organizing filters. The contents of the #UfoGroup structure 64 | * are private and should only be accessed via the provided API. 65 | */ 66 | struct _UfoGroup { 67 | /*< private >*/ 68 | GObject parent_instance; 69 | 70 | UfoGroupPrivate *priv; 71 | }; 72 | 73 | /** 74 | * UfoGroupClass: 75 | * 76 | * #UfoGroup class 77 | */ 78 | struct _UfoGroupClass { 79 | /*< private >*/ 80 | GObjectClass parent_class; 81 | }; 82 | 83 | UfoGroup * ufo_group_new (GList *targets, 84 | gpointer context, 85 | UfoSendPattern pattern); 86 | guint ufo_group_get_num_targets (UfoGroup *group); 87 | void ufo_group_set_num_expected (UfoGroup *group, 88 | UfoTask *target, 89 | gint n_expected); 90 | UfoBuffer * ufo_group_pop_output_buffer (UfoGroup *group, 91 | UfoRequisition *requisition); 92 | void ufo_group_push_output_buffer (UfoGroup *group, 93 | UfoBuffer *buffer); 94 | UfoBuffer * ufo_group_pop_input_buffer (UfoGroup *group, 95 | UfoTask *target); 96 | void ufo_group_push_input_buffer (UfoGroup *group, 97 | UfoTask *target, 98 | UfoBuffer *input); 99 | void ufo_group_finish (UfoGroup *group); 100 | GType ufo_group_get_type (void); 101 | 102 | G_END_DECLS 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /docs/Ufo-sections.txt.in: -------------------------------------------------------------------------------- 1 |
2 | ufo-config 3 | UfoConfig 4 | UfoConfig 5 | ufo_config_new 6 | ufo_config_get_paths 7 | 8 | UFO_CONFIG 9 | UFO_CONFIG_CLASS 10 | UFO_CONFIG_GET_CLASS 11 | UFO_IS_CONFIG 12 | UFO_IS_CONFIG_CLASS 13 | UFO_TYPE_CONFIG 14 | ufo_config_get_type 15 | 16 | UfoConfigPrivate 17 |
18 | 19 |
20 | ufo-configurable 21 | UfoConfigurable 22 | UfoConfigurable 23 | 24 | UFO_CONFIGURABLE 25 | UFO_CONFIGURABLE_CLASS 26 | UFO_CONFIGURABLE_GET_IFACE 27 | UFO_IS_CONFIGURABLE 28 | UFO_IS_CONFIGURABLE_CLASS 29 | UFO_TYPE_CONFIGURABLE 30 | ufo_configurable_get_type 31 | 32 | UfoConfigurableIface 33 |
34 | 35 |
36 | ufo-plugin-manager 37 | UfoPluginManager 38 | UfoPluginManagerError 39 | UfoPluginManager 40 | ufo_plugin_manager_new 41 | ufo_plugin_manager_get_task 42 | ufo_plugin_manager_get_all_task_names 43 | 44 | UFO_PLUGIN_MANAGER 45 | UFO_IS_PLUGIN_MANAGER 46 | UFO_TYPE_PLUGIN_MANAGER 47 | ufo_plugin_manager_get_type 48 | UFO_PLUGIN_MANAGER_CLASS 49 | UFO_IS_PLUGIN_MANAGER_CLASS 50 | UFO_PLUGIN_MANAGER_GET_CLASS 51 | 52 | UFO_PLUGIN_MANAGER_ERROR 53 | UfoPluginManagerPrivate 54 | ufo_plugin_manager_error_quark 55 |
56 | 57 |
58 | ufo-resource-manager 59 | UfoResources 60 | UfoResourcesError 61 | UfoResources 62 | ufo_resources_new 63 | ufo_resources_get_kernel 64 | ufo_resources_get_kernel_from_source 65 | ufo_resources_get_context 66 | 67 | UFO_RESOURCES 68 | UFO_IS_RESOURCES 69 | UFO_TYPE_RESOURCES 70 | ufo_resources_get_type 71 | UFO_RESOURCES_CLASS 72 | UFO_IS_RESOURCES_CLASS 73 | UFO_RESOURCES_GET_CLASS 74 | 75 | UFO_RESOURCES_ERROR 76 | UfoResourcesClass 77 | UfoResourcesPrivate 78 | opencl_map_error 79 | ufo_resources_error_quark 80 |
81 | 82 |
83 | ufo-profiler 84 | UfoProfiler 85 | UfoProfilerFunc 86 | UfoProfilerLevel 87 | UfoProfilerTimer 88 | UfoProfiler 89 | UfoProfilerClass 90 | ufo_profiler_new 91 | ufo_profiler_call 92 | ufo_profiler_foreach 93 | ufo_profiler_start 94 | ufo_profiler_stop 95 | ufo_profiler_elapsed 96 | 97 | UFO_TYPE_PROFILER 98 | UFO_IS_PROFILER 99 | UFO_IS_PROFILER_CLASS 100 | UFO_PROFILER 101 | UFO_PROFILER_CLASS 102 | UFO_PROFILER_GET_CLASS 103 | ufo_profiler_get_type 104 | 105 | UfoProfilerPrivate 106 |
107 | 108 |
109 | ufo-graph 110 | UfoGraph 111 | UfoGraph 112 | ufo_graph_new 113 | 114 | UFO_GRAPH 115 | UFO_IS_GRAPH 116 | UFO_TYPE_GRAPH 117 | ufo_graph_get_type 118 | UFO_GRAPH_CLASS 119 | UFO_IS_GRAPH_CLASS 120 | UFO_GRAPH_GET_CLASS 121 | 122 | UFO_GRAPH_ERROR 123 | UfoGraphClass 124 | UfoGraphPrivate 125 | ufo_graph_error_quark 126 |
127 | 128 |
129 | ufo-buffer 130 | UfoBuffer 131 | UfoBufferError 132 | UfoBuffer 133 | UFO_BUFFER_MAX_NDIMS 134 | ufo_buffer_new 135 | ufo_buffer_copy 136 | ufo_buffer_get_size 137 | ufo_buffer_get_2d_dimensions 138 | ufo_buffer_resize 139 | ufo_buffer_get_host_array 140 | ufo_buffer_get_device_array 141 | UfoBufferParamSpec 142 | UfoBufferParamSpec 143 | ufo_buffer_param_spec 144 | 145 | UFO_BUFFER 146 | UFO_IS_BUFFER 147 | UFO_TYPE_BUFFER 148 | ufo_buffer_get_type 149 | UFO_BUFFER_CLASS 150 | UFO_IS_BUFFER_CLASS 151 | UFO_BUFFER_GET_CLASS 152 | UFO_BUFFER_PARAM_SPEC 153 | UFO_IS_PARAM_SPEC_BUFFER 154 | UFO_TYPE_PARAM_BUFFER 155 | ufo_buffer_param_get_type 156 | 157 | UFO_BUFFER_ERROR 158 | UfoBufferPrivate 159 | UfoBufferClass 160 | ufo_buffer_error_quark 161 |
162 | 163 |
164 | ufo-scheduler 165 | UfoScheduler 166 | UfoScheduler 167 | ufo_scheduler_new 168 | ufo_scheduler_run 169 | 170 | UFO_SCHEDULER 171 | UFO_SCHEDULER_CLASS 172 | UFO_SCHEDULER_GET_CLASS 173 | UFO_IS_SCHEDULER 174 | UFO_IS_SCHEDULER_CLASS 175 | UFO_TYPE_SCHEDULER 176 | ufo_scheduler_get_type 177 | 178 | UfoSchedulerClass 179 | UfoSchedulerPrivate 180 |
181 | -------------------------------------------------------------------------------- /common/cmake/FindOpenCL.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindOpenCL 3 | # ---------- 4 | # 5 | # Try to find OpenCL 6 | # 7 | # Once done this will define:: 8 | # 9 | # OpenCL_FOUND - True if OpenCL was found 10 | # OpenCL_INCLUDE_DIRS - include directories for OpenCL 11 | # OpenCL_LIBRARIES - link against this library to use OpenCL 12 | # OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) 13 | # OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation 14 | # OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation 15 | # 16 | # The module will also define two cache variables:: 17 | # 18 | # OpenCL_INCLUDE_DIR - the OpenCL include directory 19 | # OpenCL_LIBRARY - the path to the OpenCL library 20 | # 21 | 22 | #============================================================================= 23 | # Copyright 2014 Matthaeus G. Chajdas 24 | # 25 | # Distributed under the OSI-approved BSD License (the "License"); 26 | # see accompanying file Copyright.txt for details. 27 | # 28 | # This software is distributed WITHOUT ANY WARRANTY; without even the 29 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 30 | # See the License for more information. 31 | #============================================================================= 32 | # (To distribute this file outside of CMake, substitute the full 33 | # License text for the above reference.) 34 | 35 | find_package(PackageHandleStandardArgs) 36 | 37 | function(_FIND_OPENCL_VERSION) 38 | include(CheckSymbolExists) 39 | include(CMakePushCheckState) 40 | set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) 41 | 42 | CMAKE_PUSH_CHECK_STATE() 43 | foreach(VERSION "2_0" "1_2" "1_1" "1_0") 44 | set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") 45 | 46 | if(APPLE) 47 | CHECK_SYMBOL_EXISTS( 48 | CL_VERSION_${VERSION} 49 | "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h" 50 | OPENCL_VERSION_${VERSION}) 51 | else() 52 | CHECK_SYMBOL_EXISTS( 53 | CL_VERSION_${VERSION} 54 | "${OpenCL_INCLUDE_DIR}/CL/cl.h" 55 | OPENCL_VERSION_${VERSION}) 56 | endif() 57 | 58 | if(OPENCL_VERSION_${VERSION}) 59 | string(REPLACE "_" "." VERSION "${VERSION}") 60 | set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE) 61 | string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}") 62 | list(GET version_components 0 major_version) 63 | list(GET version_components 1 minor_version) 64 | set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE) 65 | set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE) 66 | break() 67 | endif() 68 | endforeach() 69 | CMAKE_POP_CHECK_STATE() 70 | endfunction() 71 | 72 | find_path(OpenCL_INCLUDE_DIR 73 | NAMES 74 | CL/cl.h OpenCL/cl.h 75 | PATHS 76 | ENV "PROGRAMFILES(X86)" 77 | ENV AMDAPPSDKROOT 78 | ENV INTELOCLSDKROOT 79 | ENV NVSDKCOMPUTE_ROOT 80 | ENV CUDA_PATH 81 | ENV ATISTREAMSDKROOT 82 | PATH_SUFFIXES 83 | include 84 | OpenCL/common/inc 85 | "AMD APP/include") 86 | 87 | _FIND_OPENCL_VERSION() 88 | 89 | if(WIN32) 90 | if(CMAKE_SIZEOF_VOID_P EQUAL 4) 91 | find_library(OpenCL_LIBRARY 92 | NAMES OpenCL 93 | PATHS 94 | ENV "PROGRAMFILES(X86)" 95 | ENV AMDAPPSDKROOT 96 | ENV INTELOCLSDKROOT 97 | ENV CUDA_PATH 98 | ENV NVSDKCOMPUTE_ROOT 99 | ENV ATISTREAMSDKROOT 100 | PATH_SUFFIXES 101 | "AMD APP/lib/x86" 102 | lib/x86 103 | lib/Win32 104 | OpenCL/common/lib/Win32) 105 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) 106 | find_library(OpenCL_LIBRARY 107 | NAMES OpenCL 108 | PATHS 109 | ENV "PROGRAMFILES(X86)" 110 | ENV AMDAPPSDKROOT 111 | ENV INTELOCLSDKROOT 112 | ENV CUDA_PATH 113 | ENV NVSDKCOMPUTE_ROOT 114 | ENV ATISTREAMSDKROOT 115 | PATH_SUFFIXES 116 | "AMD APP/lib/x86_64" 117 | lib/x86_64 118 | lib/x64 119 | OpenCL/common/lib/x64) 120 | endif() 121 | else() 122 | find_library(OpenCL_LIBRARY NAMES OpenCL) 123 | endif() 124 | 125 | set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) 126 | set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) 127 | 128 | find_package_handle_standard_args( 129 | OpenCL 130 | DEFAULT_MSG 131 | OpenCL_LIBRARY OpenCL_INCLUDE_DIRS) 132 | 133 | mark_as_advanced( 134 | OpenCL_INCLUDE_DIR 135 | OpenCL_LIBRARY) 136 | -------------------------------------------------------------------------------- /ufo/ufo-plugin-manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 Karlsruhe Institute of Technology 3 | * 4 | * This file is part of Ufo. 5 | * 6 | * This library is free software: you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation, either 9 | * version 3 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library. If not, see . 18 | */ 19 | 20 | #ifndef __UFO_PLUGIN_MANAGER_H 21 | #define __UFO_PLUGIN_MANAGER_H 22 | 23 | #if !defined (__UFO_H_INSIDE__) && !defined (UFO_COMPILATION) 24 | #error "Only can be included directly." 25 | #endif 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | #define UFO_TYPE_PLUGIN_MANAGER (ufo_plugin_manager_get_type()) 32 | #define UFO_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UFO_TYPE_PLUGIN_MANAGER, UfoPluginManager)) 33 | #define UFO_IS_PLUGIN_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UFO_TYPE_PLUGIN_MANAGER)) 34 | #define UFO_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UFO_TYPE_PLUGIN_MANAGER, UfoPluginManagerClass)) 35 | #define UFO_IS_PLUGIN_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), UFO_TYPE_PLUGIN_MANAGER)) 36 | #define UFO_PLUGIN_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), UFO_TYPE_PLUGIN_MANAGER, UfoPluginManagerClass)) 37 | 38 | #define UFO_PLUGIN_MANAGER_ERROR ufo_plugin_manager_error_quark() 39 | GQuark ufo_plugin_manager_error_quark(void); 40 | 41 | typedef enum { 42 | UFO_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND, 43 | UFO_PLUGIN_MANAGER_ERROR_MODULE_OPEN, 44 | UFO_PLUGIN_MANAGER_ERROR_SYMBOL_NOT_FOUND 45 | } UfoPluginManagerError; 46 | 47 | typedef struct _UfoPluginManager UfoPluginManager; 48 | typedef struct _UfoPluginManagerClass UfoPluginManagerClass; 49 | typedef struct _UfoPluginManagerPrivate UfoPluginManagerPrivate; 50 | 51 | /** 52 | * UfoPluginManager: 53 | * 54 | * Creates #UfoFilter instances by loading corresponding shared objects. The 55 | * contents of the #UfoPluginManager structure are private and should only be 56 | * accessed via the provided API. 57 | */ 58 | struct _UfoPluginManager { 59 | /*< private >*/ 60 | GObject parent_instance; 61 | 62 | UfoPluginManagerPrivate *priv; 63 | }; 64 | 65 | /** 66 | * UfoPluginManagerClass: 67 | * 68 | * #UfoPluginManager class 69 | */ 70 | struct _UfoPluginManagerClass { 71 | /*< private >*/ 72 | GObjectClass parent_class; 73 | }; 74 | 75 | UfoPluginManager * ufo_plugin_manager_new (void); 76 | GObject * ufo_plugin_manager_get_plugin (UfoPluginManager *manager, 77 | const gchar *func_name, 78 | const gchar *module_name, 79 | GError **error); 80 | GList * ufo_plugin_get_all_plugin_names (UfoPluginManager *manager, 81 | const GRegex *filename_regex, 82 | const gchar *filename_pattern); 83 | UfoTaskNode * ufo_plugin_manager_get_task (UfoPluginManager *manager, 84 | const gchar *name, 85 | GError **error); 86 | UfoTaskNode * ufo_plugin_manager_get_task_from_package(UfoPluginManager *manager, 87 | const gchar *package_name, 88 | const gchar *name, 89 | GError **error); 90 | GList * ufo_plugin_manager_get_all_task_names (UfoPluginManager *manager); 91 | GType ufo_plugin_manager_get_type (void); 92 | 93 | G_END_DECLS 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | if (POLICY CMP0053) 4 | cmake_policy(SET CMP0053 OLD) 5 | endif () 6 | 7 | if (POLICY CMP0054) 8 | cmake_policy(SET CMP0054 OLD) 9 | endif () 10 | 11 | project(ufo) 12 | 13 | set(TARNAME "libufo") 14 | 15 | set(UFO_NAME "libufo") 16 | set(UFO_DESCRIPTION "UFO high-speed image processing core library") 17 | set(UFO_DESCRIPTION_SUMMARY "UFO high-speed image processing core library") 18 | 19 | #{{{ Library version 20 | set(UFO_VERSION_MAJOR "0") 21 | set(UFO_VERSION_MINOR "17") 22 | set(UFO_VERSION_PATCH "0") 23 | set(UFO_VERSION "${UFO_VERSION_MAJOR}.${UFO_VERSION_MINOR}.${UFO_VERSION_PATCH}") 24 | set(UFO_GIR_VERSION "${UFO_VERSION_MAJOR}.0") 25 | #}}} 26 | #{{{ CMake 27 | enable_testing() 28 | 29 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/common/cmake") 30 | 31 | include(GNUInstallDirs) 32 | include(PkgConfigVars) 33 | 34 | set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/ufo-${UFO_VERSION_MAJOR}") 35 | set(CMAKE_INSTALL_KERNELDIR "${CMAKE_INSTALL_DATAROOTDIR}/ufo") 36 | set(CMAKE_INSTALL_GIRDIR "${CMAKE_INSTALL_DATAROOTDIR}/gir-1.0") 37 | set(CMAKE_INSTALL_PLUGINDIR "${CMAKE_INSTALL_LIBDIR}/ufo") 38 | set(CMAKE_INSTALL_TYPELIBDIR "${CMAKE_INSTALL_LIBDIR}/girepository-1.0") 39 | set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 40 | 41 | if (APPLE) 42 | set(CMAKE_MACOSX_RPATH "ON") 43 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") 44 | endif() 45 | 46 | #}}} 47 | #{{{ Options 48 | option(WITH_TESTS "Build test suite" OFF) 49 | option(WITH_DEPRECATED_OPENCL_1_1_API "Build with deprecated OpenCL 1.1 API" ON) 50 | set(UFO_MAX_INPUT_NODES "64" CACHE STRING "Maximum number of allowed input nodes for a task") 51 | 52 | if (WITH_DEPRECATED_OPENCL_1_1_API) 53 | add_definitions ("-DCL_USE_DEPRECATED_OPENCL_1_1_APIS") 54 | endif () 55 | #}}} 56 | #{{{ Dependencies 57 | set(PKG_GLIB2_MIN_REQUIRED "2.38") 58 | set(PKG_JSON_GLIB_MIN_REQUIRED "0.10.0") 59 | 60 | find_package(OpenCL REQUIRED) 61 | find_package(PkgConfig REQUIRED) 62 | 63 | pkg_check_modules(GLIB2 glib-2.0>=${PKG_GLIB2_MIN_REQUIRED} REQUIRED) 64 | pkg_check_modules(GOBJECT2 gobject-2.0>=${PKG_GLIB2_MIN_REQUIRED} REQUIRED) 65 | pkg_check_modules(GMODULE2 gmodule-2.0>=${PKG_GLIB2_MIN_REQUIRED} REQUIRED) 66 | pkg_check_modules(GTHREAD2 gthread-2.0>=${PKG_GLIB2_MIN_REQUIRED} REQUIRED) 67 | pkg_check_modules(GIO2 gio-2.0>=${PKG_GLIB2_MIN_REQUIRED} REQUIRED) 68 | pkg_check_modules(JSON_GLIB json-glib-1.0>=${PKG_JSON_GLIB_MIN_REQUIRED} REQUIRED) 69 | pkg_check_modules(PYTHON python3-embed) 70 | 71 | set(GLIB_VERSION_MIN_REQUIRED "GLIB_VERSION_2_38") 72 | set(GLIB_VERSION_MAX_ALLOWED "GLIB_VERSION_2_38") 73 | set(CL_TARGET_OPENCL_VERSION "120") 74 | 75 | set(UFOCORE_DEPS 76 | m 77 | ${OpenCL_LIBRARIES} 78 | ${GLIB2_LIBRARIES} 79 | ${GOBJECT2_LIBRARIES} 80 | ${GMODULE2_LIBRARIES} 81 | ${GTHREAD2_LIBRARIES} 82 | ${GIO2_LIBRARIES} 83 | ${JSON_GLIB_LIBRARIES}) 84 | 85 | 86 | if (NOT PYTHON_FOUND) 87 | pkg_check_modules(PYTHON python3) 88 | if (NOT PYTHON_FOUND) 89 | pkg_check_modules(PYTHON python) 90 | endif () 91 | endif () 92 | 93 | if (PYTHON_FOUND) 94 | option(WITH_PYTHON "Enable Python multithreading support" ON) 95 | 96 | if (WITH_PYTHON) 97 | include_directories(${PYTHON_INCLUDE_DIRS}) 98 | list(APPEND UFOCORE_DEPS ${PYTHON_LIBRARIES}) 99 | endif () 100 | endif() 101 | 102 | #{{{ Link dirs of dependencies 103 | link_directories( 104 | ${GLIB2_LIBRARY_DIRS} 105 | ${JSON_GLIB_LIBRARY_DIRS}) 106 | #}}} 107 | #{{{ Add include directories 108 | include_directories( 109 | ${CMAKE_CURRENT_SOURCE_DIR} 110 | ${CMAKE_CURRENT_BINARY_DIR} 111 | ${GLIB2_INCLUDE_DIRS} 112 | ${GIO2_INCLUDE_DIRS} 113 | ${OpenCL_INCLUDE_DIRS} 114 | ${JSON_GLIB_INCLUDE_DIRS}) 115 | #}}} 116 | #}}} 117 | #{{{ Definitions 118 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -fPIC -Wno-unused-parameter -Wno-deprecated-declarations") 119 | 120 | add_definitions(-DG_LOG_DOMAIN=\"Ufo\" 121 | -D_FILE_OFFSET_BITS=64) 122 | 123 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in 124 | ${CMAKE_CURRENT_BINARY_DIR}/config.h) 125 | #}}} 126 | #{{{ Subdirectories 127 | add_subdirectory(ufo) 128 | add_subdirectory(docs) 129 | add_subdirectory(bin) 130 | 131 | if (WITH_TESTS) 132 | add_subdirectory(tests) 133 | endif() 134 | #}}} 135 | -------------------------------------------------------------------------------- /bin/ufo-prof: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import argparse 6 | import json 7 | import shutil 8 | import math 9 | import re 10 | import sys 11 | import numpy as np 12 | 13 | 14 | CHARS = ['⣿', '⣷', '⣶', '⣦', '⣤', '⣄', '⡄', '⡀', ''] 15 | 16 | 17 | def get_terminal_size(): 18 | if hasattr(shutil, 'get_terminal_size'): 19 | return shutil.get_terminal_size() 20 | 21 | rows, cols = os.popen('stty size', 'r').read().split() 22 | return (int(rows), int(cols)) 23 | 24 | 25 | def make_bars(begins, ends, total, width): 26 | line = '' 27 | previous = 0 28 | 29 | for i, (begin, end) in enumerate(zip(begins, ends)): 30 | span = float(end - begin) / total 31 | num_full_chars = int(math.floor(width * span)) 32 | remaining = width * span - num_full_chars 33 | full_bar = CHARS[0] * num_full_chars 34 | remaining_bar = CHARS[int((len(CHARS) - 1)* (1 - remaining))] 35 | 36 | if i == 0: 37 | line += '{}{}'.format(full_bar, remaining_bar) 38 | previous = end 39 | else: 40 | spaces = ' ' * int((float(begin - previous) / total) * width) 41 | line += '{}{}{}'.format(spaces, full_bar, remaining_bar) 42 | previous = end 43 | 44 | return line 45 | 46 | 47 | def analyse(fp, name_fmt_func, name_header): 48 | events = json.load(fp)['traceEvents'] 49 | 50 | def select(key, where=lambda e: True): 51 | return [e[key] for e in events if where(e)] 52 | 53 | tasks = set(e['tid'] for e in events) 54 | starts = sorted([(t, min(select('ts', lambda e: e['tid'] == t))) for t in tasks], key=lambda t: t[1]) 55 | ends = sorted([(t, max(select('ts', lambda e: e['tid'] == t))) for t in tasks], key=lambda t: t[1]) 56 | tasks = [t[0] for t in starts] # sorted task names 57 | 58 | start = starts[0][1] 59 | total = ends[-1][1] - start 60 | term_width = get_terminal_size()[0] 61 | 62 | begins = {t: select('ts', lambda e: e['tid'] == t and e['ph'] == 'B') for t in tasks} 63 | ends = {t: select('ts', lambda e: e['tid'] == t and e['ph'] == 'E') for t in tasks} 64 | times = {t: [end - begin for begin, end in zip(begins[t], ends[t])] for t in tasks} 65 | 66 | for task in tasks: 67 | name = name_fmt_func(task) 68 | name = name[:7] + '…' if len(name) > 8 else name + ' ' * (8 - len(name)) 69 | name = name.encode('utf-8') 70 | print(('{} {}'.format(name, make_bars(begins[task], ends[task], total, term_width - 11)))) 71 | 72 | print(("\n {: <24} | {: >4} | {: >12} | {: >12} | {: >5}".format(name_header, '#', 'Total (ms)', 'Mean (ms)', '%'))) 73 | print(('-' * (24 + 4 + 12 + 12 + 9 + 10))) 74 | 75 | for task, tt in ((task, times[task]) for task in tasks): 76 | name = name_fmt_func(task) 77 | total_time = np.sum(tt) / 1000.0 78 | mean_time = np.mean(tt) / 1000.0 79 | num_events = len(tt) 80 | percentage = float(np.sum(tt)) / total * 100 81 | fmt = ' {: <24} | {: >4} | {: >12.4f} | {: >12.4f} | {: >3.2f}' 82 | print((fmt.format(name, num_events, total_time, mean_time, percentage))) 83 | 84 | 85 | def analyse_trace(fp): 86 | def relevant_name(task): 87 | return re.match(r'Ufo([A-Za-z]*)Task-[a-f0-9x]*', task).group(1) 88 | 89 | analyse(fp, relevant_name, 'Task') 90 | 91 | 92 | def analyse_opencl(fp): 93 | analyse(fp, lambda x: x, 'Kernel') 94 | 95 | 96 | def main(): 97 | parser = argparse.ArgumentParser() 98 | 99 | def open_valid_file(arg): 100 | if not os.path.exists(arg): 101 | parser.error("`{}' does not exist.".format(arg)) 102 | else: 103 | return open(arg, 'r'), arg 104 | 105 | group = parser.add_mutually_exclusive_group(required=False) 106 | group.add_argument('--trace', action='store_true', default=None, help="JSON input is a trace file") 107 | group.add_argument('--opencl', action='store_true', default=None, help="JSON input is OpenCL trace") 108 | 109 | parser.add_argument('input', type=open_valid_file) 110 | 111 | args = parser.parse_args() 112 | 113 | if args.trace or re.match(r'trace\..*\.json', args.input[1]): 114 | analyse_trace(args.input[0]) 115 | sys.exit(0) 116 | 117 | if args.opencl or re.match(r'opencl\..*\.json', args.input[1]): 118 | analyse_opencl(args.input[0]) 119 | sys.exit(0) 120 | 121 | print("Could not guess trace file type, please supply --trace or --opencl.") 122 | 123 | 124 | if __name__ == '__main__': 125 | main() 126 | -------------------------------------------------------------------------------- /python/ufo/tomopy.py: -------------------------------------------------------------------------------- 1 | 2 | import math 3 | import numpy as np 4 | 5 | 6 | class Parameters(object): 7 | 8 | def __init__(self, data): 9 | self.num_sinograms = data.shape[0] 10 | self.num_projections = data.shape[1] 11 | self.width = data.shape[2] 12 | self.data = data 13 | 14 | def __repr__(self): 15 | return 'Parameters(n_sinos={}, n_proj={}, width={})'.format(self.num_sinograms, self.num_projections, self.width) 16 | 17 | @property 18 | def sinograms(self): 19 | return (self.data[i,:,:] for i in range(self.num_sinograms)) 20 | 21 | 22 | def _fbp(data, center, volume, theta, kwargs): 23 | from ufo import Fft, Ifft, Filter, Backproject 24 | 25 | p = Parameters(data) 26 | theta = theta[1] - theta[0] 27 | center = np.mean(center) 28 | 29 | bp = Backproject(axis_pos=center, angle_step=theta, angle_offset=np.pi) 30 | fft = Fft() 31 | ifft = Ifft(crop_width=p.width) 32 | flt = Filter() 33 | 34 | for i, slce in enumerate(bp(ifft(flt(fft(p.sinograms))))): 35 | volume[i,:,:] = slce 36 | 37 | 38 | def fbp(*args, **kwargs): 39 | """ 40 | Reconstruct object using UFO's filtered backprojection algorithm 41 | 42 | Note 43 | ---- 44 | You have to set ``ncore`` to 1 because UFO provides multi-threading on its 45 | own. 46 | """ 47 | 48 | # Erm ... okay? 49 | result = [_fbp] 50 | result.extend(args) 51 | result.append(kwargs) 52 | return result 53 | 54 | 55 | def _dfi(data, center, volume, theta, kwargs): 56 | from ufo import Crop, Zeropad, Fft, Ifft, DfiSinc, Ifft, SwapQuadrants 57 | 58 | oversampling = kwargs['options'].get('oversampling', 1) 59 | p = Parameters(data) 60 | theta = theta[1] - theta[0] 61 | center = np.mean(center) 62 | padded_size = pow(2, int(math.ceil(math.log(p.width, 2)))) 63 | frm = padded_size / 2 - p.width / 2 64 | to = padded_size / 2 + p.width / 2 65 | 66 | pad = Zeropad(oversampling=1, center_of_rotation=center) 67 | fft = Fft(dimensions=1, auto_zeropadding=False) 68 | dfi = DfiSinc(angle_step=theta) 69 | ifft = Ifft(dimensions=2) 70 | swap_forward = SwapQuadrants() 71 | swap_backward = SwapQuadrants() 72 | 73 | for i, slce in enumerate(swap_backward(ifft(swap_forward(dfi(fft(pad(p.sinograms))))))): 74 | volume[i,:,:] = slce[frm:to, frm:to] 75 | 76 | 77 | def dfi(*args, **kwargs): 78 | """ 79 | Reconstruct object using UFO's direct Fourier inversion algorithm 80 | 81 | Extra options 82 | ------------- 83 | oversampling : int, optional 84 | Oversampling factor. 85 | 86 | Note 87 | ---- 88 | You have to set ``ncore`` to 1 because UFO provides multi-threading on its 89 | own. 90 | """ 91 | result = [_dfi] 92 | result.extend(args) 93 | result.append(kwargs) 94 | return result 95 | 96 | 97 | def _ir(data, center, volume, theta, kwargs): 98 | from ufo import Null, Task 99 | p = Parameters(data) 100 | theta = theta[1] - theta[0] 101 | center = np.mean(center) 102 | 103 | null = Null() 104 | env = null.env 105 | 106 | 107 | allowed_methods = ('sart', 'sirt', 'asdpocs', 'sbtv') 108 | 109 | opts = kwargs['options'] 110 | method_name = opts.get('method', 'sart') 111 | method_name = method_name if method_name in allowed_methods else 'sart' 112 | 113 | projector = env.pm.get_task_from_package('ir', 'parallel-projector') 114 | projector.set_properties(model='joseph', is_forward=False, axis_position=center, step=theta) 115 | 116 | method = env.pm.get_task_from_package('ir', method_name) 117 | method.set_properties(projector=projector, num_iterations=opts.get('num_iterations', 5)) 118 | 119 | if method_name in ('sart', 'sirt'): 120 | method.set_properties(relaxation_factor=opts.get('relaxation_factor', 0.25)) 121 | 122 | if method_name == 'asdpocs': 123 | minimizer = env.pm.get_task_from_package('ir', 'sirt') 124 | method.set_properties(df_minimizer=minimizer) 125 | 126 | if method_name == 'sbtv': 127 | method.set_properties(mu=opts.get('mu', 0.5)) 128 | 129 | method = Task(env, 'ir', {}, method) 130 | 131 | for i, slce in enumerate(method(p.sinograms)): 132 | volume[i,:,:] = slce[:,:] 133 | 134 | 135 | def ir(*args, **kwargs): 136 | """ 137 | Reconstruct object using UFO's direct iterative reconstruction methods 138 | 139 | Extra options 140 | ------------- 141 | method : str 142 | Any of `sart`, `sirt`, `asdpocs` and `sbtv`. 143 | 144 | num_iterations : int, optional 145 | Number of iterations before stopping reconstruction. 146 | 147 | relaxation_factor : float 148 | Relaxation factor for SART and SIRT methods. 149 | 150 | mu : float 151 | mu for Split Bregman Total Variation algorithm. 152 | 153 | Note 154 | ---- 155 | You have to set ``ncore`` to 1 because UFO provides multi-threading on its 156 | own. 157 | """ 158 | result = [_ir] 159 | result.extend(args) 160 | result.append(kwargs) 161 | return result 162 | -------------------------------------------------------------------------------- /python/ufo/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import sys 4 | import re 5 | import time 6 | import threading 7 | import queue 8 | import numpy as np 9 | import gi 10 | from .numpy import asarray, empty_like 11 | gi.require_version('Ufo', '0.0') 12 | from gi.repository import GObject, Ufo 13 | 14 | 15 | Ufo.Scheduler() 16 | 17 | 18 | class Environment(object): 19 | 20 | def __init__(self, pm): 21 | self.pm = pm 22 | self.reset() 23 | self.done = False 24 | self.started = False 25 | 26 | def reset(self): 27 | self.graph = Ufo.TaskGraph() 28 | 29 | 30 | class Task(object): 31 | 32 | def __init__(self, env, name, cargs, task=None): 33 | self.env = env 34 | self.name = name 35 | self.cargs = cargs 36 | self.task = task or self.env.pm.get_task(self.name) 37 | 38 | def connect(self, *args, **kwargs): 39 | self.task.connect(*args, **kwargs) 40 | 41 | def __call__(self, *args): 42 | self.task.set_properties(**self.cargs) 43 | 44 | if len(args) == 0: 45 | return self 46 | 47 | if any(isinstance(a, Task) for a in args): 48 | for i, source in enumerate(args): 49 | self.env.graph.connect_nodes_full(source.task, self.task, i) 50 | else: 51 | def input_data(*iargs): 52 | tasks = [] 53 | buffers = [] 54 | 55 | for i in range(len(iargs)): 56 | task = Ufo.InputTask() 57 | tasks.append(task) 58 | buffers.append(None) 59 | self.env.graph.connect_nodes_full(task, self.task, i) 60 | 61 | while not self.env.started: 62 | time.sleep(0.01) 63 | 64 | for args in zip(*iargs): 65 | for i, (task, data) in enumerate(zip(tasks, args)): 66 | if buffers[i] is None: 67 | buffers[i] = empty_like(data) 68 | else: 69 | buffers[i] = task.get_input_buffer() 70 | 71 | buffers[i].set_host_array(data.__array_interface__['data'][0], False) 72 | task.release_input_buffer(buffers[i]) 73 | 74 | for task in tasks: 75 | task.stop() 76 | 77 | thread = threading.Thread(target=input_data, args=args) 78 | thread.start() 79 | 80 | return self 81 | 82 | def __iter__(self): 83 | return self.items() 84 | 85 | def run(self, **props): 86 | """ 87 | Run the tasks. 88 | 89 | Args: 90 | props (dict): parameter dict used to create the scheduler. 91 | """ 92 | 93 | sched = Ufo.Scheduler() 94 | sched.set_properties(**props) 95 | 96 | def run_scheduler(): 97 | self.env.done = False 98 | sched.run(self.env.graph) 99 | self.env.done = True 100 | self.env.reset() 101 | 102 | self.thread = threading.Thread(target=run_scheduler) 103 | self.thread.start() 104 | self.env.started = True 105 | return self 106 | 107 | def join(self): 108 | self.thread.join() 109 | 110 | def items(self): 111 | results = queue.Queue() 112 | 113 | def processed(task): 114 | buf = output_task.get_output_buffer() 115 | results.put(asarray(buf).copy()) 116 | output_task.release_output_buffer(buf) 117 | 118 | output_task = Ufo.OutputTask() 119 | output_task.connect('processed', processed) 120 | self.env.graph.connect_nodes(self.task, output_task) 121 | self.run() 122 | 123 | while not self.env.done or not results.empty(): 124 | try: 125 | yield results.get(True, 0.01) 126 | except queue.Empty: 127 | pass 128 | 129 | self.join() 130 | 131 | @property 132 | def graph(self): 133 | return self.env.graph 134 | 135 | 136 | class TaskLoader(object): 137 | 138 | def __init__(self, env, name): 139 | self.env = env 140 | self.name = name 141 | 142 | def __call__(self, **kwargs): 143 | # This should probably be done with using metaclasses, but it looks 144 | # simple and straightforward enough 145 | return Task(self.env, self.name, kwargs) 146 | 147 | 148 | def get_path(fqn): 149 | return fqn.split('.')[1] 150 | 151 | 152 | class Importer(object): 153 | def __init__(self): 154 | self.env = Environment(Ufo.PluginManager()) 155 | self.task_names = self.env.pm.get_all_task_names() 156 | 157 | def find_module(self, fqn, path=None): 158 | if fqn.startswith('ufo.'): 159 | if get_path(fqn).lower() in self.task_names: 160 | return self 161 | 162 | return None 163 | 164 | def load_module(self, fqn): 165 | # Splits according to http://stackoverflow.com/a/1176023/997768 166 | s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', get_path(fqn)) 167 | task_name = re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() 168 | return TaskLoader(self.env, task_name) 169 | 170 | 171 | sys.meta_path += [Importer()] 172 | --------------------------------------------------------------------------------