error C3861: 'cudaFree': identifier not found
Hi
I just start to use CUDA and I tried to do some example from this book"cuda by example...".
this example in in page 25 of the book and I exactly copy and past it to my main.cpp but I got lots of error like;
error C3861: 'cudaMemcpy': identifier not found
error C2065: 'threadIdx' : undeclared identifier

this is the code:
#include<iostream>

#include "book.h"

__global__ void add( int a, int b, int *c ) {
*c = a + b;
}
int main( void ) {
int c;
int *dev_c;
HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );

add<<<1,1>>>( 2, 7, dev_c );

HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int),cudaMemcpyDeviceToHost ) );
printf( "2 + 7 = %d\n", c );
HANDLE_ERROR( cudaFree( dev_c ) );

return 0;
}

I would appreciate you if help me. or if some one can give a simple program that can help me to start learning CUDA, I really appreciate that.
Hi

I just start to use CUDA and I tried to do some example from this book"cuda by example...".

this example in in page 25 of the book and I exactly copy and past it to my main.cpp but I got lots of error like;

error C3861: 'cudaMemcpy': identifier not found

error C2065: 'threadIdx' : undeclared identifier



this is the code:

#include<iostream>



#include "book.h"



__global__ void add( int a, int b, int *c ) {

*c = a + b;

}

int main( void ) {

int c;

int *dev_c;

HANDLE_ERROR( cudaMalloc( (void**)&dev_c, sizeof(int) ) );



add<<<1,1>>>( 2, 7, dev_c );



HANDLE_ERROR( cudaMemcpy( &c, dev_c, sizeof(int),cudaMemcpyDeviceToHost ) );

printf( "2 + 7 = %d\n", c );

HANDLE_ERROR( cudaFree( dev_c ) );



return 0;

}



I would appreciate you if help me. or if some one can give a simple program that can help me to start learning CUDA, I really appreciate that.

#1
Posted 05/09/2012 05:20 PM   
You ahve to include the file book.h provided with sample codes.
You ahve to include the file book.h provided with sample codes.

#2
Posted 05/10/2012 08:27 PM   
Scroll To Top