How to enable driver API?

Hello,

I wanted to use page-locked memory for my project, which I need cuMemAllocHost to do.

As I understand it, I would need to first call cuInit(0);

However, VC++ complains when I try to compile, saying the functions don’t exist. My project works fine when I don’t use pagelocked memory and thus never needed to use the driver API. However, I wanted to try speeding up CPU to GPU memory transfers.

 cuInit(0);

  cuMemAllocHost((void**)h_idata, TEST_MEM_SIZE);

The Error:

1>------ Build started: Project: md5, Configuration: Release Win32 ------

1>Performing Custom Build Step

1>“main.cu”, line 110: error: identifier “cuInit” is undefined

1> cuInit(0);

1> ^

1>“main.cu”, line 111: error: identifier “cuMemAllocHost” is undefined

1> cuMemAllocHost((void**)h_idata, (2048 * ( 20 * 4096 )));

1> ^

1>2 errors detected in the compilation…

It must be some dumb configuration thing that I’m doing, but I can’t figure it out. Can anyone help me?

Much obliged.

You can use cudaMallocHost and cudaFreeHost from the high-level API.

Alternatively, you can #include the cuda.h, and initialize the driver by cudaMalloc some memory and immediately cudaFree.