Git Product home page Git Product logo

thirdparty-freestanding's Introduction

A freestanding Standard C++ library for GPU programs.

Implements the eponymous subset of C++ with some exceptions.

How to use this library

Clone this repo

git clone --recurse-submodules https://github.com/ogiroux/freestanding

Run the sample

On Linux, for example.

cd samples
./linux.sh
./books.sh
./trie

(Note: you will need curl, and obviously CUDA with a Volta, Xavier or Turing GPU.)

What is supported

Nothing. This repository holds a useful demo. That's all.

You may, however, enjoy creating your own demo application.

What happens to work

Toolchains based on CUDA 9.0 and above:

  1. NVCC with GCC or Clang, and the libstdc++ host library.
  2. NVCC with VC++, and the VC++ host library.
  3. Clang, with the libstdc++ host library.
  4. NVRTC, with access to the C host library.

Assuming you compile with -I<path-to-include/>:

  1. Each header named <simt/X> conforms to the specification for the header <X> from ISO C++, except that each occurrence of std:: is prefixed with simt::.
  2. Except for limitations specified below, each facility thus introduced in simt:: works in both __host__ and __device__ functions, under -std=c++11 and -std=c++14, on Windows and Linux with CUDA 9 or 10 on Volta, Xavier and Turing. (Though, obviously, not all combinations are possible.)

Considerations for use under NVRTC

If you choose to use this facility with the run-time compiler then you will need to ensure it can find the necessary headers. The simplest way to achieve that is to point to headers on your filesystem.

For example, hypothetically speaking, these might be the paths you need to provide:

  const char *opts[] = {"-std=c++11",
                        "-I/usr/include/linux",
                        "-I/usr/include/c++/7.3.0",
                        "-I/usr/local/cuda/include",
                        "-I/home/olivier/freestanding/include",
                        "--gpu-architecture=compute_70",
                        "--relocatable-device-code=true",
                        "-default-device"};
  nvrtcResult compileResult = nvrtcCompileProgram(prog,  // prog
                                                  8,     // numOptions
                                                  opts); // options

What does not work

In general, for the language support library (<simt/initializer_list>, <simt/new>, <simt/typeinfo>, <simt/exception>) the header <simt/X> only introduces aliases to the declarations of <X> under the simt:: namespace. Use in __device__ functions is limited to intrinsic support for the facility by the compiler used.

In specific, see the table below.

Header Limitation in function Requires
<simt/atomic> Except fence functions also add the suffix _simt. <simt/cstddef>, <simt/cstdint>, <simt/type_traits>
<simt/cfloat> <float.h>
<simt/ciso646> <iso646.h>
<simt/climits> <limits.h>
<simt/cstdalign> Unsupported. Unsupported.
<simt/cstdarg> Except __device__ functions. <stdarg.h>
<simt/cstdbool>
<simt/cstddef> <stddef.h>
<simt/cstdint> <stdint.h>
<simt/cstdlib> Except __device__ functions. <stdlib.h>
<simt/exception> Except __device__ functions. <simt/cstddef>, <simt/cstdint>, <simt/type_traits>
<simt/initializer_list> <simt/cstddef>
<simt/limits> <simt/type_traits>
<simt/new> Except __device__ functions. <simt/exception>, <simt/type_traits>, <simt/cstddef>, <simt/cstdlib>
<simt/type_traits> <simt/cstddef>
<simt/typeinfo> Except __device__ functions. <simt/exception>, <simt/cstddef>, <simt/cstdint>, <simt/cstdlib>

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.