简体   繁体   English

如何在 CUDA 中使用 Eigen?

[英]How to use Eigen in CUDA?

the version of Eigen: 3.3.9 I am using Eigen in my simulation project. Eigen 的版本:3.3.9 我在我的模拟项目中使用 Eigen。 There are some big matrix need to be handled.有一些大矩阵需要处理。 If using cpu, too slow.如果使用cpu,太慢了。 Is there a simple example of using eigen on cuda?是否有在 cuda 上使用 eigen 的简单示例? 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 https://eigen.tuxfamily.org/dox/TopicCUDA.html

Disclaimer: this page is about an experimental feature in Eigen.免责声明:此页面是关于 Eigen 中的一个实验性功能

Staring from CUDA 5.0, the CUDA compiler, nvcc, is able to properly parse Eigen's code (almost).从 CUDA 5.0 开始,CUDA 编译器 nvcc 能够正确解析 Eigen 的代码(几乎)。 A few adaptations of the Eigen's code already allows to use some parts of Eigen in your own CUDA kernels. Eigen 代码的一些修改已经允许在您自己的 CUDA 内核中使用 Eigen 的某些部分。 To this end you need the devel branch of Eigen, CUDA 5.0 or greater with GCC.为此,您需要 Eigen 的开发分支,CUDA 5.0 或更高版本以及 GCC。

Known issues:已知的问题:

-nvcc with MS Visual Studio does not work (patch welcome) -nvcc 与 MS Visual Studio 不起作用(欢迎使用补丁)

-nvcc with clang does not work (patch welcome) -nvcc 与 clang 不工作(补丁欢迎)

-nvcc 5.5 with gcc-4.7 (or greater) has issues with the standard header file. -nvcc 5.5 和 gcc-4.7(或更高版本)与标准 header 文件存在问题。 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. - 在 64 位系统上,Eigen 使用 long int 作为索引和大小的默认类型。 On CUDA device, it would make sense to default to 32 bits int.在 CUDA 设备上,默认为 32 位 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). 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目的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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