nvcc
曾经在CUDA Toolkit 3.0中有一个-deviceemu
选项
我下载了CUDA Toolkit 3.0,安装了它并尝试运行一个简单的程序:
#include <stdio.h>
__global__ void helloWorld() {
printf("Hello world! I am %d (Warp %d) from %d.\n",
threadIdx.x, threadIdx.x / warpSize, blockIdx.x);
}
int main() {
int blocks, threads;
scanf("%d%d", &blocks, &threads);
helloWorld<<<blocks, threads>>>();
cudaDeviceSynchronize();
return 0;
}
注意,在CUDA Toolkit 3.0中,nvcc
位于/usr/local/cuda/bin/
目录中。
我遇到了编译的一些困难。NOTE: device emulation mode is deprecated in this release
and will be removed in a future release.
/usr/include/i386-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined
/usr/include/i386-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined
/home/user/Downloads/helloworld.cu(12): error: identifier "cudaDeviceSynchronize" is undefined
3 errors detected in the compilation of "/tmp/tmpxft_000011c2_00000000-4_helloworld.cpp1.ii".
我在网上找到了一些资料,说如果使用gcc-4.2
或类似的古老版本而不是gcc-4.9.2
,那么错误可能会消失。我放弃了。
gpuocelot
Stringer的答案中提供了一个非常古老的gpuocelot
项目网站链接。所以我一开始以为这个项目在2012年左右就被放弃了。实际上,它在几年后才被放弃。
这里有一些最新的网站:
我尝试按照指南来安装gpuocelot。然而在安装过程中出现了几个错误,我又放弃了。 gpuocelot
不再得到支持,并且依赖于一组非常特定的库和软件版本。
您可以尝试按照这篇教程从2015年7月开始,但我不能保证它会起作用。我没有测试过。
MCUDA
MCUDA翻译框架是一个基于Linux的工具,旨在有效地将CUDA编程模型编译为CPU架构。
这可能很有用。这里是该网站链接。
CUDA Waste
这是一个可以在Windows 7和8上使用的模拟器。虽然我没有尝试过,但它似乎不再开发(最后一次提交日期为2013年7月4日)。
这是该项目网站的链接:https://code.google.com/archive/p/cuda-waste/
CU2CL
最近更新:12.03.2017
正如dashesy在评论中指出的那样,CU2CL似乎是一个有趣的项目。它似乎能够将CUDA代码转换为OpenCL代码。因此,如果您的GPU能够运行OpenCL代码,则CU2CL项目可能会引起您的兴趣。
链接: