Package: linnea
LinneaLinnea is an experimental tool for the automatic generation of optimized code for linear algebra problems. It is developed at theHigh-Performance and Automatic Computing groupat RWTH Aachen University.InstallationLinnea requires Python 3.6 and can be installed withpip install git+git://github.com/HPAC/linnea.git. (Depending on your setup, you may have to usepip3instead ofpip.) To uninstall Linnea, usepip uninstall linnea. This also removes the commandline tool.Development InstallationIf you intend to contribute to Linnea, you can install it from local sources by runningpip install -e .in your local development directory.OverviewLinnea is a prototype of a compiler/program synthesis tool that automates the translation of the mathematical description of a linear algebra problem to an efficient sequence of calls to BLAS and LAPACK kernels. The main idea of Linnea is to construct a search graph that represents a large number of programs, taking into account knowledge about linear algebra, numerical linear algebra and high-performance computing. The algebraic nature of the domain is used to reduce the size of the search graph, without reducing the size of the search space that is explored.The input to Linnea are linear algebra expressions. As operands, matrices, vectors and scalars are supported. Operands can be annotated with properties, such as 'lower triangular' or 'symmetric'. Supported operations are addition, multiplication, transposition and inversion. At the moment, Linnea generates Julia code (seehttps://julialang.org), using BLAS and LAPACK wrappers whenever possible.UsageLinnea can be used in two different ways.Python ModuleAt the moment, Linnea is primarily a Python module. An example script for how to use Linnea within Python can found inexamples/run_linnea.py. The input expressions are represented as Python objects. As an example, consider the description of a lower triangular linear system (omitting imports):n=1000L=Matrix("L",(n,n))L.set_property(properties.LOWER_TRIANGULAR)L.set_property(properties.FULL_RANK)x=Vector("x",(n,1))y=Vector("y",(n,1))input=Equations(Equal(y,Times(Inverse(L),x)))Further examples of input problems are provided in theexamples/inputX.pyfiles.Options can be set with a number oflinnea.config.set_X()functions.Commandline ToolWhen installing Linnea viapip, the commandline toollinneais installed. As input, it takes a description of the input problem in a simple custom language. With this language, the same lower triangular system is described as:n = 1000

Matrix L(n, n) <LowerTriangular, FullRank>
ColumnVector x(n) <>
ColumnVector y(n) <>

y = inv(L)*xFurther examples are provided inexamples/inputX.la. Notice that the primary purpose of this input format is to make it slightly easier to try out Linnea. There are no plans to establish this as an actual language. New features will probably not be immediately available in this language, and the language may change in the future without being backward compatible.The list of commandline options is available vialinnea -h.OutputAs output, Linnea generates a directory structure that contains code files, as well a file containing a description of the derivation graph, the primary datastructure used by Linnea. Which files are generated can be set as options. Likewise, the location of the output can be specified. By default, it is the current directory.For the linear system from the previous examples, the following code will be generated:usingLinearAlgebra.BLASusingLinearAlgebrafunctionalgorithm0(ml0,ml1)# cost 1e+06# L: ml0, full, x: ml1, full# tmp1 = (L^-1 x)trsv!('L','N','N',ml0,ml1)# tmp1: ml1, full# y = tmp1return(ml1)endOptionsLinnea offers a number of options which can be set throughlinnea.configin Python or as commandline options for the commandline tool. Alternatively, all options can also be specified in alinnea_config.jsonfile (seeexamples) which has to be located in the same directory where Linnea is run, or at the user's$HOMEfolder. Both commandline options andlinnea.configoptions override what is specified inlinnea_config.json. As a fallback, reasonable default values are used.There are the following options (those are the names used in Python, the commandline options have slightly different names. Seelinnea -h):output_code_pathThe output of Linnea will be stored in this directory. The default is the current directory.output_nameLinnea creates a new directory that contains all output files. This is the name of this directory. The default istmp.languageNot available for the commandline tool. For now, the only allowed option isJulia.julia_data_typeThe data type used in the generated code. EitherFloat32orFloat64. The default isFloat64.merging_branchesWhether or not to merge branches in the derivation graph. The default istrue.dead_endsWhether or not to eliminate dead ends in the derivation graph early. The default istrue.algorithms_limitThe upper limit for the number of algorithms that are written to files. The default is100.strategyThe strategy used to find algorithms. Eitherconstructiveorexhaustive. The default isconstructive.generate_graphWhether or not to generate a.gvfile of the derivation graph. The default isfalse.graph_styleStyle of the derivation graph. Eitherfull,simple, orminimal. The default isfull. Only applies ifgenerate_graphis set toTrue.generate_derivationWhether or not to generate a description of how the algorithms were derived. The default isfalse.generate_codeWhether or not to generate the actual code of the algorithms. The default istrue.generate_experimentsWhether or not to generate code that can be used to run the algorithms. The default isfalse.verbosityLevel of verbosity. The default is1.PublicationsA number of publications that discuss different aspects of Linnea can be foundhere.ContributorsHenrik BarthelsMarcin CopikDiego Fabregat TraverJulius HohnerleinManuel Krebber