For those who are seeking the answer in 2016 (and even 2017) …
Disclaimer
- I’ve failed to emulate GPU after all.
- It might be possible to use
gpuocelotif you satisfy its list of
dependencies.
I’ve tried to get an emulator for BunsenLabs (Linux 3.16.0-4-686-pae #1 SMP
Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) i686 GNU/Linux).
I’ll tell you what I’ve learnt.
-
nvccused to have a-deviceemuoption back in CUDA Toolkit 3.0I downloaded CUDA Toolkit 3.0, installed it and tried to run a simple
program:#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; }Note that in CUDA Toolkit 3.0
nvccwas in the/usr/local/cuda/bin/.It turned out that I had difficulties with compiling it:
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".I’ve found on the Internet that if I used
gcc-4.2or similarly ancient instead ofgcc-4.9.2the errors might disappear. I gave up.
-
gpuocelotThe answer by Stringer has a link to a very old
gpuocelotproject website. So at first I thought that the project was abandoned in 2012 or so. Actually, it was abandoned few years later.Here are some up to date websites:
- GitHub;
- Project’s website;
- Installation guide.
I tried to install gpuocelot following the guide. I had several errors during installation though and I gave up again.
gpuocelotis no longer supported and depends on a set of very specific versions of libraries and software.You might try to follow this tutorial from July, 2015 but I don’t guarantee it’ll work. I’ve not tested it.
-
MCUDA
The MCUDA translation framework is a linux-based tool designed to
effectively compile the CUDA programming model to a CPU architecture.It might be useful. Here is a link to the website.
-
CUDA Waste
It is an emulator to use on Windows 7 and 8. I’ve not tried it though. It doesn’t seem to be developed anymore (the last commit is dated on Jul 4, 2013).
Here’s the link to the project’s website: https://code.google.com/archive/p/cuda-waste/
-
CU2CL
Last update: 12.03.2017
As dashesy pointed out in the comments, CU2CL seems to be an interesting project. It seems to be able to translate CUDA code to OpenCL code. So if your GPU is capable of running OpenCL code then the CU2CL project might be of your interest.
Links:
- CU2CL homepage
- CU2CL GitHub repository