20 #include <kvikio/shim/utils.hpp>
33 decltype(cuInit)* Init{
nullptr};
34 decltype(cuMemHostAlloc)* MemHostAlloc{
nullptr};
35 decltype(cuMemFreeHost)* MemFreeHost{
nullptr};
36 decltype(cuMemcpyHtoD)* MemcpyHtoD{
nullptr};
37 decltype(cuMemcpyDtoH)* MemcpyDtoH{
nullptr};
38 decltype(cuPointerGetAttribute)* PointerGetAttribute{
nullptr};
39 decltype(cuPointerGetAttributes)* PointerGetAttributes{
nullptr};
40 decltype(cuCtxPushCurrent)* CtxPushCurrent{
nullptr};
41 decltype(cuCtxPopCurrent)* CtxPopCurrent{
nullptr};
42 decltype(cuCtxGetCurrent)* CtxGetCurrent{
nullptr};
43 decltype(cuMemGetAddressRange)* MemGetAddressRange{
nullptr};
44 decltype(cuGetErrorName)* GetErrorName{
nullptr};
45 decltype(cuGetErrorString)* GetErrorString{
nullptr};
46 decltype(cuDeviceGet)* DeviceGet{
nullptr};
47 decltype(cuDevicePrimaryCtxRetain)* DevicePrimaryCtxRetain{
nullptr};
48 decltype(cuDevicePrimaryCtxRelease)* DevicePrimaryCtxRelease{
nullptr};
49 decltype(cuStreamSynchronize)* StreamSynchronize{
nullptr};
54 void* lib = load_library(
"libcuda.so.1");
59 get_symbol(MemHostAlloc, lib, KVIKIO_STRINGIFY(cuMemHostAlloc));
60 get_symbol(MemFreeHost, lib, KVIKIO_STRINGIFY(cuMemFreeHost));
61 get_symbol(MemcpyHtoD, lib, KVIKIO_STRINGIFY(cuMemcpyHtoD));
62 get_symbol(MemcpyDtoH, lib, KVIKIO_STRINGIFY(cuMemcpyDtoH));
63 get_symbol(PointerGetAttribute, lib, KVIKIO_STRINGIFY(cuPointerGetAttribute));
64 get_symbol(PointerGetAttributes, lib, KVIKIO_STRINGIFY(cuPointerGetAttributes));
65 get_symbol(CtxPushCurrent, lib, KVIKIO_STRINGIFY(cuCtxPushCurrent));
66 get_symbol(CtxPopCurrent, lib, KVIKIO_STRINGIFY(cuCtxPopCurrent));
67 get_symbol(CtxGetCurrent, lib, KVIKIO_STRINGIFY(cuCtxGetCurrent));
68 get_symbol(MemGetAddressRange, lib, KVIKIO_STRINGIFY(cuMemGetAddressRange));
69 get_symbol(GetErrorName, lib, KVIKIO_STRINGIFY(cuGetErrorName));
70 get_symbol(GetErrorString, lib, KVIKIO_STRINGIFY(cuGetErrorString));
71 get_symbol(DeviceGet, lib, KVIKIO_STRINGIFY(cuDeviceGet));
72 get_symbol(DevicePrimaryCtxRetain, lib, KVIKIO_STRINGIFY(cuDevicePrimaryCtxRetain));
73 get_symbol(DevicePrimaryCtxRelease, lib, KVIKIO_STRINGIFY(cuDevicePrimaryCtxRelease));
74 get_symbol(StreamSynchronize, lib, KVIKIO_STRINGIFY(cuStreamSynchronize));
79 void operator=(
cudaAPI const&) =
delete;
Shim layer of the cuda C-API.