identifier ... is undefined when trying to run pure C code in Cuda using nvcc

Posted by Lostsoul on Stack Overflow See other posts from Stack Overflow or by Lostsoul
Published on 2012-06-21T21:11:28Z Indexed on 2012/06/21 21:16 UTC
Read the original article Hit count: 195

Filed under:

I'm new and learning Cuda. A approach that I'm trying to use to learn is to write code in C and once I know its working start converting it to Cuda since I read that nvcc compiles Cuda code but complies everything else using plain old c.

My code works in c(using gcc) but when I try to compile it using nvcc(after changing the file name from main.c to main.cu) I get

main.cu(155): error: identifier "num_of_rows" is undefined
main.cu(155): error: identifier "num_items_in_row" is undefined
2 errors detected in the compilation of "/tmp/tmpxft_00002898_00000000-4_main.cpp1.ii".

Basically in my main method I send data to a function like this:

process_list(count, countListItem, list);

the first two items are ints and the last item(list) is a matrix. Then I create my function like this:

void process_list(int num_of_rows, int num_items_in_row, int current_list[num_of_rows][num_items_in_row]) {

This line is where I get my errors when using nvcc(line 155). I need to convert this code to cuda anyway so no need to troubleshoot this specific issue(plus code is quite large) but I'm wondering if I'm wrong about nvcc treating the C part of your code like plain C.

In the book cuda by example I just used nvcc to compile but do I need any extra flags when just using pure c?

© Stack Overflow or respective owner

Related posts about cuda