CUDA Virtual memory on Windows - what is the handle type?

178 Views Asked by At

From the CUDA driver API documentation:

enum CUmemAllocationHandleType

Flags for specifying particular handle types
Values

CU_MEM_HANDLE_TYPE_NONE = 0x0
    Does not allow any export mechanism. 
CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR = 0x1
    Allows a file descriptor to be used for exporting. Permitted only on POSIX systems. (int) 
CU_MEM_HANDLE_TYPE_WIN32 = 0x2
    Allows a Win32 NT handle to be used for exporting. (HANDLE) 
CU_MEM_HANDLE_TYPE_WIN32_KMT = 0x4
    Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) 
CU_MEM_HANDLE_TYPE_MAX = 0x7FFFFFFF

What is the HANDLE type? i.e. what is its definition? And - can I define it manually, or must I include some Windows header for it?

2

There are 2 best solutions below

0
On

Well, an answer to this question:

What is a Windows Handle?

suggests that:

typedef void* HANDLE;

may be a valid thing to do. I'm not sure that's the case, but will give it a try.

1
On

HANDLE is defined in winnt.h.

It's a pretty sizable file though, ~22000 lines. Minimal but hardly innocuous. You can reduce the API surface somewhat with #defines:

#define WINAPI_FAMILY WINAPI_FAMILY_SERVER

A precompiled header is your friend, if the compiler allows.