mgcpp
A C++ Math Library Based on CUDA
mgcpp Documentation
logo

mgcpp

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

{C++}
#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

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

Planned Features

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)