Giter VIP home page Giter VIP logo

libsysml's Introduction

libsysml

A collection of minimal yet performant utilities that are useful for various forms of research at the intersection of machine learning and systems.

Benchmarking

The measure.hpp header provides utilities for measuring the mean, median and minimum runtime of arbitrary functions. Also useful is the ability to limit the execution time of the benchmark.

#include "sysml/measure.hpp"

unsigned iterations = 1000;
double limit_in_seconds = 0.01;
auto time = measure_fastest_time_limited([]() {
  // do something
}, iterations, limit_in_seconds);

std::cout << "fastest run " << time << " seconds";

Parallelism

Threading utilities can be found in the sysml/thread/ folder, with fast primitives for parallel_for and barriers.

Code generation

An X86_64/ARM64 codegenerator based on xbyak/xbyak_aarch64 can be found in sysml/code_generator/code_generator.hpp. There are functions to simplify the use of generated functions, such as automatic shared_ptr wrapping and improved executable memory mapping.

Fast N-dimensional Arrays

Create ndarray_refs from underlying data.

std::vector<int>           v{0, 1, 2, 3, 4, 5, 6, 7, 8};
std::array<std::size_t, 2> shape{3, 3};
sysml::const_ndarray_ref<int, 2> nda(v.data(), shape);

Numerics

Determine the availability of numeric types on the system.

#include "sysml/numeric.hpp"

using namespace sysml;

CHECK(is_arithmetic_v<char32_t>);
CHECK(is_arithmetic_v<uint16x4_t>);

Small array support

Fast stack-allocated arrays with the vek.hpp header:

#include "sysml/ndloop.hpp"
#include "sysml/vek.hpp"

using namespace sysml;

vek<int, 3> range{2, 3, 4};
// Equivalent to three nested loops:
ndloop(range, [&](auto const& v) { me[v[0]][v[1]][v[2]] = 0xdeadbeef; });

for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 3; ++j)
        for (int k = 0; k < 4; ++k)
            CHECK(me[i][j][k] == 0xdeadbeef);
            
// Alternatively:
ndloop(range, [&](auto a, auto b, auto c) { me[a][b][c] = 0x12341234; });

for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 3; ++j)
        for (int k = 0; k < 4; ++k)
            CHECK(me[i][j][k] == 0x12341234);

Iteration

Easily iterate over multiple dimensions with sysml/ndloop.hpp.

Contribution

To contribute, please see the CONTRIBUTING.md file.

License

libsysml is MIT licensed, as found in the LICENSE file.

libsysml's People

Contributors

zlateski avatar bwasti avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.