Skip to content

MGfoundation/mgcpp

Repository files navigation

logo

mgcpp

Build Status Documentation

Introduction

mgcpp is a CUDA based C++ linear algebra library.
It provides a standard C++ interface without any CUDA specific syntax.

This library is heavily under development and in pre-alpha state.
If our library lacks a feature that you need, please leave an issue.
We can raise the priority for most needed features.

For contribution, please contact us personally or join our discord server

Example

#include <mgcpp/mgcpp.hpp>

mgcpp::device_matrix<float> A({4, 3}, 2);
mgcpp::device_matrix<float> B({3, 2}, 2);

auto C = ref(A) * ref(B);

// Lazy evaluation
auto result = mgcpp::eval(C);

The above code invokes cuBLAS's gemm function.
All mgcpp expressions are lazily computed and optimized using C++ expression template method.

Notable Features

  • cuBLAS backend for efficient BLAS computation.
  • Expression templates notation for efficient, expressive code
  • Half precision operation for extra performance on modern Nvidia GPU architectures.
  • Automatic GPU memory management.
  • Fill, reduce, outer-product and more custom BLAS extensions.

Build

git clone --recursive https://github.com/Red-Portal/mgcpp.git
cmake -G "<Generator>"
make -j4
make install

for building without half type support,

git clone --recursive https://github.com/Red-Portal/mgcpp.git
cmake -DUSE_HALF=OFF -G "<Generator>"
make -j4
make install

The library probes your system cuda gpu-architecture and gpu-code code automatically.
However if you want to specify the computability code,
add the argument below to the command line.

-DCUDA_ARCH=<arch>

In order to use a different C++ compiler for cuda code and native C++ code,
provide the argument below.

-DCUDA_HOST_COMPILER=<full path to compiler>

You must provide the FULL PATH to your cuda host compiler.
Different cuda versions have different C++ compiler constraints.
For example cuda 8.0 only support gcc up to 5.3.

So, for an example case that you want to use cuda 8.0 for cuda code, gcc-5.3 for native C++ code,

git clone --recursive https://github.com/Red-Portal/mgcpp.git
cmake -DCUDA_HOST_COMPILER=/usr/bin/g++-5.3 -DCMAKE_CXX_COMPILER=g++7 -G "<Generator>"
make -j4
make install

-DISCLAIMER-
Windows build is currently not supported because CUDA 9.1 doesn't support latest version of Visual Studio 15.
Windows support should be back when this issue is resolved.

On Windows, after installing all dependencies, execute the following on the Developer Command Prompt for VS 2017:

git clone --recursive https://github.com/Red-Portal/mgcpp.git
cd mgcpp
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -T v140,host=x64 ..
msbuild ALL_BUILD.vcxproj

Dependencies

  • cmake 3.8 or later
  • gcc 6, clang 3.9, Visual Studio 14.0 (2015) or later(currently not supported)
  • boost-outcome
  • boost
  • cuda 8.0 or later
  • half(optional)
  • magma(optional)
  • google test (optional)
  • google benchmark (optional)

Planned Features

  • Various GPU memory allocators.
  • Expression template optimization for all operations.
  • Convolution operation.
  • sparse matrix, sparse vector, sparse tensor types.
  • Batch matrix type and batch matrix operations.
  • Tensor type and tensor operations.
  • cuSPARSE support.
  • Full compatibility with uBLAS, Eigen, blaze

Contact

Red-Portal

mujjingun

License

Copyright RedPortal, mujjingun 2017 - 2018.

Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •