Giter Club home page Giter Club logo

nanostl's Introduction

NanoSTL, a portable and small subset of C++ STL.

Build Status

NanoSTL is good for using STL-like feature in your C++ application and C++-like JIT compiler.

NanoSTL is portable, it should run well on many environments including Windows, Linux, macOS, x86, ARM, SPARC, etc.

NanoSTL should work well on C++11 compiler or later. C++03 would also work well.

Status

Eearly testing stage. Not ready for the production use.

Features

  • Experimental CUDA support. You can use NanoSTL on device functions.
    • See sandbox/cuda/

Supported features

  • vector
  • string
  • algorithm
  • limits
  • map

Be careful! Not all C++ STL functions are supported for each module.

Limited support

  • math : Approximate math functions. Please keep in mind this is basically not be IEEE-754 compliant and does not consier a processor's rounding mode.
  • valarray

math functions

  • isnan
  • isinf
  • isfinite
  • isnormal
  • fabs(float)
  • copysign(float)
  • sqrt(float) Approximated.
  • exp(float)
  • pow(float)
  • log(float)
  • log10(float)
  • sin(float)
  • cos(float)
  • tanh(float)
  • cbrt(float)
  • erf(float)
  • erfc(float)
  • ierf(float)

Supported architectures

  • 64bit and 32bit machine.
  • Big endian and little endian
    • Some math functions may not run on big endian machine.
  • CUDA device.

Supported compilers

Even though NanoSTL should be compilable with older and various C++ compilers, at least following compilers shold work well.

  • gcc 4.4.7+
    • NanoSTL itself can be compilable with gcc 4.2.4(fails to compile Catch unit test code)
  • clang 3.4+

Types

NanoSTL assumes following type definitions.

  • char : 8bit(NOTE: unsigned is default for some ARM compiler. Use signed char if you want signed 8bit type)
  • short : 16bit
  • int : 32bit
  • long long : 64bit
  • float : 32bit IEEE754 floating point.
  • double : 64bit IEEE754 floating point.

Compiler macros

  • NANOSTL_BIG_ENDIAN Set endianness to big endian. Considering to support various compilers, user must explicitly specify endianness to the compiler. Default is little endian.

Differences compared to (full featured) C++ STL

  • No thread safety Currently NanoSTL is not thread safe
    • Application must care about the thread safety
    • For example, need to use mutex or lock for nanostl::vector::push_back() operation if you are accesing nanostl::vector object from multiple threads.
  • RTTI and exception is not supported.
  • Returns NULL when memory allocation failed(no bad_alloc)

TODO

  • iostream, fstream(stdout/stdin, file IO)
  • Math complex type
  • CUDA support(experimental)
  • isnan/isinf/isfinite support
  • Unit tests
    • Unit tests on CUDA platform
    • Write mote unit tests for CPU platform
  • Multithread support
  • Backport of some C++11 features(e.g. unordered_map)
  • Replace oiio math functions so that we can have clean MIT licensed code.
  • FLOAT16 and BFLOAT16 support.

Developer note

Generate single header file.

$ python scripts/generateSingleHeader.py

Unit tests

Compiling unit test requires C++11 compiler since unit test uses some C++11 math functions for the reference.

$ cd tests
$ make
$ ./test

Debugging

Use NANOSTL_DEBUG define for debugging.

Licenss

MIT license. Some functions in nanomath is licenced under modified BSD license.

Third party licenses

  • acutest : MIT license.
  • faster math functions: Some math functions implemented in nanomath is grabbed from OpenImageIO fmath.h, which is licensed under modified BSD license. https://github.com/OpenImageIO/oiio/

nanostl's People

Contributors

syoyo 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.