daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

Push-down of arithmetics before source operations #668

Open pdamme opened 8 months ago

pdamme commented 8 months ago

Motivation: DaphneDSL offers a couple of source operations, which take only scalars as arguments, but produce a matrix as their result. Examples include: fill(), rand(), and seq(). Subsequent arithmetic operations on this result could be pushed before the source operation, in many cases. That way, the program execution could be improved by avoiding unnecessary large intermediate results, thereby reducing the number processor instructions and the memory footprint.

For instance, fill(a, 10^6, 1) + b creates a (1Mx1) column matrix where all values are the scalar a and performs an addition with the scalar b, thereby creating another matrix of the same size. The memory footprint is 2 x 1M x 8 bytes (=16 MB)(assuming 64-bit floating-point numbers, and no update-in-place optimizations are done). Alternatively, one could calculate fill(a + b, 10^6, 1), where the addition happens on scalars and only one matrix is created, i.e., the footprint is halved (8 MB).

Some further examples: (Lower case letters indicate scalars, upper case letters indicate matrices.)

Task:

Possible task extensions for teams: