简体   繁体   中英

How to use Eigen in CUDA?

the version of Eigen: 3.3.9 I am using Eigen in my simulation project. There are some big matrix need to be handled. If using cpu, too slow. Is there a simple example of using eigen on cuda? I didn't find it in the official documentation, and now I don't know how to start the first step.

below is the content taken from the official page:

https://eigen.tuxfamily.org/dox/TopicCUDA.html

Disclaimer: this page is about an experimental feature in Eigen.

Staring from CUDA 5.0, the CUDA compiler, nvcc, is able to properly parse Eigen's code (almost). A few adaptations of the Eigen's code already allows to use some parts of Eigen in your own CUDA kernels. To this end you need the devel branch of Eigen, CUDA 5.0 or greater with GCC.

Known issues:

-nvcc with MS Visual Studio does not work (patch welcome)

-nvcc with clang does not work (patch welcome)

-nvcc 5.5 with gcc-4.7 (or greater) has issues with the standard header file. To workaround this, you can add the following before including any other files:

// workaround issue between gcc >= 4.7 and cuda 5.5
#if (defined __GNUC__) && (__GNUC__>4 || __GNUC_MINOR__>=7)
  #undef _GLIBCXX_ATOMIC_BUILTINS
  #undef _GLIBCXX_USE_INT128
#endif

-On 64bits system Eigen uses long int as the default type for indexes and sizes. On CUDA device, it would make sense to default to 32 bits int. However, to keep host and CUDA code compatible, this cannot be done automatically by Eigen, and the user is thus required to define EIGEN_DEFAULT_DENSE_INDEX_TYPE to int throughout his code (or only for CUDA code if there is no interaction between host and CUDA code through Eigen's object).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM