nvcc -o my_prog my_prog.cu
《CUDA by example》第四章 julia例子 编译代码:
nvcc -lGL -lglut -o julia_gpu julia_gpu.cu
- 《CUDA by example》第五章 问题
void anim_and_exit( void (*f)(uchar4*,void*,int), void(*e)(void*) );
bitmap.anim_and_exit( (void (*)(void*,int))generate_frame,
(void (*)(void*))cleanup );
void generate_frame( DataBlock *d, int ticks ) {
dim3 blocks(DIM/16,DIM/16);
dim3 threads(16,16);
kernel<<<blocks,threads>>>( d->dev_bitmap, ticks );
HANDLE_ERROR( cudaMemcpy( d->bitmap->get_ptr(),
d->dev_bitmap,
d->bitmap->image_size(),
cudaMemcpyDeviceToHost ) );
}
// clean up memory allocated on the GPU
void cleanup( DataBlock *d ) {
HANDLE_ERROR( cudaFree( d->dev_bitmap ) );
}
anim_abd_exit函数参数的写法看不懂,而且它接收的是三个参数,而原函数是两个参数。好像是函数指针,但是看不懂值传递方式。
6.使用__share__
声明变量使得变量驻留在共享内存中。