Writing host and gpu code independently

Hi,

I am looking for a simple example on how to write host and gpu code independently (two different files). My goal is to write the equivalent of the output of the first call to cudafe when using nvcc. The first call to cudafe outputs a x.cudafe1.c and a x.cudafe1.gpu files. I would like to write those files myself. One way would be to use the -keep switch and look at those two files. I tried this but cudafe’s output goes thru some preprocessing that makes the code look really ugly. I was wondering if someone had tried this or had a simple example.

Thank you,

Rodrigo

You can have a host_code.cu file :

#include “gpu_code.cu”

kernel_call<<<>>>();

And you write your cuda code in the gpu_code.cu file, the host code in the host_code.cu file.

I don’t know, sounds like a bad idea. These details of nvcc aren’t really documented and are liable to change. Plus there’s probably many subtle bugs that NVIDIA hasn’t fixed because it only tests code cudafe itself produces. What are you trying to accomplish?