Skip to content

Commit

Permalink
Added some information about compilation targets
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Oct 3, 2018
1 parent 2d166c0 commit b1e8331
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions source/ohuac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,65 @@ generally **prepended** to the options passed to the subcommand.

Supported targets for code generation
-------------------------------------

The standalone compiler currently supports two compilation targets. One is a
universal format, which simply encodes the dataflow graph directly in JSON and a
second which creates a java class.

.. _code-gen-json:

JSON Graph repesentation
^^^^^^^^^^^^^^^^^^^^^^^^

The JSON output from ``ohua`` is selected with the ``-g json-graph`` option.
The default file extension is ``.ohuao``.

This representation only encodes the dataflow graph and the stateful functions
used. It is intended to be a universal, easily to use intermediate for backeds
which have no direct support in ``ohuac`` yet. Such a backend only has to define
the runtime for the dataflow execution and the loading and linking of stateful
functions, ``ohuac`` will take care of parsing, interpreting and optimising the
algorithms.

.. _code-gen-simple-java:

A simple runnable java class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``-g simple-java-class`` code gen option is a very lightweight code
generation for the java platform.

It generates a class where the module path is its package and the algorithm name
is the name of the class. E.g. namespace ``foo.bar.baz`` with the ``main``
algorithm selected generates a class ``foo.bar.baz.Main``.

For an algorithm ``main`` with arguments ``A``, ``B``, ``C`` and return type of ``D``,
the class has the following structure

.. code-block:: java
class Main {
public static C invoke(A argument0, B argument1, C argument2);
public static Configured configure(RuntimeProcessConfiguration configuration);
public static class Configured {
public Prepared prepare(A argument0, B argument1, C argument2);
}
public static class Prepared {
public static D invoke();
}
}
The argument and return types default to ``Object``.


The structure of the class follows a simple schema. Each algorithm class has two
``static`` methods ``invoke`` and ``configure``. ``invoke`` simply executes the
algorithm with the default runtime parameters. ``configure`` allows
customization of runtime parameters.

Furthermore there are always two inner classes, ``Configured`` and ``Prepared``.
The two inner classes represent stages of algorithm configuration.
``Configured`` is a graph with an associated runtime configuration and can be
turned into a ``Prepared`` by calling ``prepare`` with the arguments specified
in the algorithm description.

0 comments on commit b1e8331

Please sign in to comment.