项目作者: siquus
项目描述 :
Distributed Algebraic Computations
高级语言: C++
项目地址: git://github.com/siquus/dac.git
DAC (Distributed Algebraic Computations)
DAC provides a C++ library to express and perform algebraic computations on computational graphs. The computational graphs are created through a C++ interface, which then generates C-code to perform the actual computations.
As yet it is restricted to Linux use only. This limitation, however, is only due to the use of pthreads and will be improved upon in the future.
The library is currently in an early proof of concept state, with many interface changes ahead. It contains a plethora of open ends, where it’s not yet clear how to design a scalable architecture for certain problems. The current strategy is to experiment by implementing some use-cases to get a feeling for this.
TL;DR
- The top level makeRun.sh compiles & executes all unit tests & examples and checks that they work as intended.
dac$ ./makeRun.sh
Running unit tests...Passed!
Running examples:
Running solar system...Passed!
Everything passed!
Target use case
DAC focuses on numerical problems requiring many algebraic operations, where the overhead of a function call for such an operation may be neglected. Specifically, problems where the same operations on large arrays are run many times, as is the case in typical optimization / simulation problems (e.g. machine learning, any physical simulation, …).
If only a few dozen vector/matrix operations in a couple of dimensions is required, one will be better off using Eigen or some BLAS-like library.
Features
Standard
Unique
- Everything is a n-Tensor, greatly simplifying derivative handling. In particular, it enables taking more than the first derivative in a consistent fashion, e.g. derivative of a 2-Tensor = Matrix is a 3-Tensor and so forth (notice, that DAC uses the convention that derivative indices are added in the front):
- Easy access to special objects (e.g. Kronecker delta, …) with efficient implementations for operations using them.
- Interface is closer to standard mathematical literature, e.g. one defines a vector space and may then declare something an element of that space
- This enables group representations on that space which in turn optimize numerics: E.g. the product of rotation matrices is a rotation matrix, rotation matrices are orthogonal, …
- The generatated code which performs the actual computations is C-code with no external libraries and may thus be run on any hardware
Workflow
Generation
- Create a program for the computational graph & code generation using this library. In the examples and unit tests of this project, this is done inside the “Generator” folders.
- Have that program generate code into some library folder for the…
Execution
- Create a program which compiles & executes the code generated in the last step. In the examples and unit tests of this project, this is done inside the “Executor” folders.
- Inside that program, set callback functions to interface to the graph, to e.g. get the output of a node whenever it was executed
Computational graphs
A computational graph is a graph where each nodes either holds a variable or an operation on variables, e.g. to express

Why go through this trouble? It enables generating symbolic derivatives by using the chain rule on the graph (“Backpropagation“) and global optimization, e.g.
Notice, that the derivative output does not recalculate the sum and square root, but uses the node already existing - that would be an example of global optimization.
Furthermore, graphs make for easy parallelization, that is destribution of work among multiple processors.
Design Decisions
Why generate code?
- The compiler has an easier time optimizing the code, because many things which would be variables are constants and branching) can be reduced to the absolute minimum
- Enabes using e.g. feedback directed optimization (see solar system example)
- Generating custom code offers (theoretically) the fastest possible solution
- Makes the code less complicated
- Enables customization, e.g. loop-unrolling according to how many floating point units, …
Why C?
- Close to hardware
- Supported on all architectures. In particular embedded.
TODO
Projects
Improvements