• Stars
    star
    216
  • Rank 183,179 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created over 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Blazing-fast Expression Templates Library (ETL) with GPU support, in C++

Expression Templates Library (ETL) 1.3.0

logo coverage jenkins license doc

ETL is a header only library for C++ that provides vector and matrix classes with support for Expression Templates to perform very efficient operations on them.

At this time, the library support compile-time sized matrix and vector and runtime-sized matrix and vector with all element-wise operations implemented. It also supports 1D and 2D convolution, matrix multiplication (naive algorithm and Strassen) and FFT.

You can clone this repository directly to get all ETL features. I advice using it as a submodule of your current project, but you can install it anywhere you like. There are several branches you can chose from

  • master: The main development branch
  • stable: The last stable version

You can also access by tag to a fixed version such as the tag 1.0.

Usage

The Reference Documentation is always available on the wiki. This document contains the most basic information that should be enough to get you started.

The library is header-only and does not need to be built it at all, you just have to include its header files.

Most of the headers are not meant to be included directly inside a program. Here are the header that are made to be included:

  • etl.hpp: Contains all the features of the library
  • etl_light.hpp: Contains the basic features of the library (no matrix multiplication, no convolution, no FFT)

You should always include one of these headers in your program. You should never include any other header from the library.

Data structures

Several data structures are available:

  • fast_matrix<T, Dim...>: A matrix of variadic size with elements of type T. This must be used when you know the size of the vector at compile-time. The number of dimensions can be anything. The data is stored is stored directly inside the matrix.
  • fast_dyn_matrix<T, Dim...>: Variant of fast_matrix where the data is stored on the heap.
  • dyn_matrix<T, D>: A matrix with element of type T. The size of the matrix can be set at runtime. The matrix can have D dimensions.

There also exists typedefs for vectors:

  • fast_vector<T, Rows>>
  • fast_dyn_vector<T, Rows>>
  • dyn_vector<T>

You have to keep in mind that fast_matrix directly store its values inside it, therefore, it can be very large and should rarely be stored on the stack. Moreover, that also makes it very expensive to move and copy. This is why fast_dyn_matrix may be an interesting alternative.

Element-wise operations

Classic element-wise operations can be done on vector and matrix as if it was done on scalars. Matrices and vectors can also be added,subtracted,divided, ... by scalars.

etl::dyn_vector<double> a{1.0,2.0,3.0};
etl::dyn_vector<double> b{3.0,2.0,1.0};
etl::dyn_vector<double> c;

c = 1.4 * (a + b) / b + b + a / 1.2;

All the operations are only executed once the expression is evaluated to be assigned to a data structure.

Unary operators

Several unary operators are available. Each operation is performed on every element of the vector or the matrix.

Available operators:

  • log
  • abs
  • sign
  • max/min
  • sigmoid
  • noise: Add standard normal noise to each element
  • logistic_noise: Add normal noise of mean zero and variance sigmoid(x) to each element
  • exp
  • softplus
  • bernoulli

Several transformations are also available:

  • hflip: Flip the vector or the matrix horizontally
  • vflip: Flip the vector or the matrix vertically
  • fflip: Flip the vector or the matrix horizontally and vertically. It is the equivalent of hflip(vflip(x))
  • sub: Return a sub part of the matrix. The first dimension is forced to a special value. It works with matrices of any dimension.
  • dim/row/col: Return a vector representing a sub part of a matrix (a row or a col)
  • reshape: Interpret a vector as a matrix

Reduction

Several reduction functions are available:

  • sum: Return the sum of a vector or matrix
  • mean: Return the sum of a vector or matrix
  • dot: Return the dot product of two vector or matrices

Functions

The header convolution.hpp provides several convolution operations both in 1D (vector) and 2D (matrix).

The header mutiplication.hpp provides the matrix multiplication operation. mmul is the naive algorithm (ijk), which strassen_mmul implements Strassen algorithm.

It is possible to pass an expression rather than an data structure to functions. Keep in mind that expression are lazy, therefore if you pass a + b to a matrix multiplication, an addition will be run each time an element is accessed, therefore, it is not often efficient.

Generators

It is also possible to generate sequences of data and perform operations on them.

For now, two generators are available:

  • normal_generator: Generates real numbers distributed on a normal distribution
  • sequence_generator(c=0): Generates numbers in sequence from c

All sequences are considered to have infinite size, therefore, they can be used to initialize or modify any containers or expressions.

Building

This library is completely header-only, there is no need to build it.

However, this library makes extensive use of C++17 and some features of C++20, therefore, a recent compiler is necessary to use it. This library is currently tested on the following compilers:

  • GCC 9.3.0 and greater

If compilation does not work on one of these compilers, or produces warnings, please open an issue on Github and I'll do my best to fix the issue.

The library has never been tested on Windows.

The folders include and lib/include must be included with the -I option.

There are no link-time dependencies.

If you have problems compiling this library, I'd be glad to help, but I do not guarantee that this will work on every compiler. I strongly expect it to not build under Visual Studio.

License

This library is distributed under the terms of the MIT license, see LICENSE file for details.

More Repositories

1

thor-os

Simple operating system in C++, written from scratch
C++
1,637
star
2

dll

Fast Deep Learning Library (DLL) for C++ (ANNs, CNNs, RBMs, DBNs...)
C++
670
star
3

articles

Source code for my articles
C++
145
star
4

budgetwarrior

Personal finance manager, command-line interface, in C++
C++
111
star
5

mnist

Simple C++ reader for MNIST dataset
C++
82
star
6

btrees

C++ implementation of concurrent Binary Search Trees
C++
72
star
7

swr-calculator

Safe Withdrawal Rate (SWR) Calculator
C++
52
star
8

sudoku_dataset

Dataset of Sudoku images for Machine Learning
C++
41
star
9

cpm

Continuous Perfomance Monitor (CPM) for C++ code
C++
40
star
10

cpp_utils

Collection of header-only utilities for C++
C++
35
star
11

eddic

Compiler of the EDDI programming language
C++
33
star
12

systemd-unit-files

Some unit files for systemd
32
star
13

frameworks

Lua
19
star
14

CMakeLatex

Simple CMake configuration for Latex
Awk
18
star
15

cifar-10

Simple C++ reader for CIFAR-10 dataset
C++
18
star
16

zabbix-lld

Script and template export for Zabbix LLD
Shell
16
star
17

dotfiles

My dot files
Lua
14
star
18

java-benchmarks

Performance benchmarks on the Java Platform
9
star
19

etl-gpu-blas

Mini BLAS-like library for GPU (complementary to CUBLAS)
C++
7
star
20

pm

Simple project manager in Python
Python
5
star
21

sudoku_recognizer

Program to detect and recognize Sudoku in images
C++
5
star
22

make-utils

Simple utility to easily write makefile for C++ projects
Makefile
5
star
23

eddivm

Eddi Virtual Machine
C++
4
star
24

word_spotting

C++
4
star
25

HazardManager

Utility class to use Hazard Pointers in C++ Concurrency Code
C++
4
star
26

gooda-to-afdo-converter

Converter from Gooda Spreadsheets to AFDO
C++
4
star
27

GraphMyData

Java
3
star
28

taskwarrior-php

A very simple PHP Front End Viewer for Task Warrior
PHP
3
star
29

jtheque-core

Framework to create modular applications in Java
Java
3
star
30

mafiaspacelife

Java
3
star
31

benchmark-utils

A little benchmark utility to bench Java Code and generate Graphs
Java
3
star
32

cpp_utils_test

Unit tests for cpp_utils
C++
3
star
33

inlining-analyzer

Analyze a callgraph to find the most interesting functions to inline in a C++ applications
C++
3
star
34

cppbench

Benchmark framework for C++ function
C++
2
star
35

analysis-examples

C++
2
star
36

spirit_x3_tests

C++
2
star
37

asgard-server

C++
2
star
38

tetris-ai

Tetris Clone for AI experiments
Java
2
star
39

ICM

International Contract Management
JavaScript
2
star
40

gcc-loop-fusion

GCC Loop Fusion
C++
2
star
41

aggregator-plugin

Sonar plugin to display metrics aggregated over all projects
HTML
2
star
42

dotfiles-vim

Dotfiles for vim
Vim Script
1
star
43

dll-autoencoders

C++
1
star
44

jtheque-films-module

A module of JTheque to manage a collection of films
Java
1
star
45

latex-makefile

A simple makefile for Latex
1
star
46

svm_mnist

C++
1
star
47

jtheque-books-module

A module of JTheque to manage a collection of books
Java
1
star
48

jtheque-tools-module

A module of JTheque providing several tools for other modules
Java
1
star
49

dbn_experiments

Experiments with DBN and RBM
C++
1
star
50

nice_svm

Wrapper around libsvm to make it easier to use and make the code nicer
C++
1
star
51

eddi-commons

Eddi Commons
C++
1
star
52

etl_vs_blaze

C++
1
star
53

VaadinBoard

Java
1
star
54

jtheque-demo-module-2

jtheque-demo-module-2
Java
1
star
55

dotfiles-pentadactyl

Dotfiles for pentadactyl
JavaScript
1
star
56

asgard-lib

Library for asgard system
C++
1
star
57

dotfiles-git

Dotfiles for git
1
star
58

pkg-config

Some of my pkg-config files
1
star
59

jtheque-xml-utils

Utility to write and read XML files
Java
1
star
60

jtheque-primary-utils

An utility module for JTheque
Java
1
star
61

jtheque-utils

Java Library providing general utilities (File, String, Swing, ...)
Java
1
star
62

jtheque-movies-module

A JTheque module to manage a collection of movies
Java
1
star
63

jtheque-unit-utils

A simple utility library to write unit test for file operations and for databases operations
Java
1
star
64

thesis-perfs

C++
1
star
65

jtheque-metrics-module

A module of JTheque to generate metrics about a Java project
Java
1
star
66

MarathonMillions

Le marathon des millions
C#
1
star
67

shell-tools

Reminder for common shell commands
1
star
68

jtheque-stats-module

A module of JTheque to display stats about films
Java
1
star
69

jtheque-demo-module-1

jtheque-demo-module-1
Java
1
star
70

jtheque-films-to-buy-module

A module of JTheque to manage a list of films to buy
Java
1
star
71

test-cppsqlite3

C++
1
star
72

dotfiles-zsh

Dotfiles for zsh
Shell
1
star
73

asgard-system-driver

C++
1
star
74

wichtounet.github.io

The sources of my blog (Generated with Nikola)
HTML
1
star
75

budgetwarrior_web

C++
1
star
76

jtheque-osgi-wrap

Maven wrapper to create OSGI bundle of non-bundle libraries
1
star
77

jtheque-web-search-module

A module of JTheque to search informations about films on internet
Java
1
star
78

jtheque-memory-module

A JTheque module to display the used memory
Java
1
star