aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2024-11-14 16:52:58 +0000
committerAndrzej Janik <[email protected]>2024-11-14 16:52:58 +0000
commitaaf8356a545d284b43d2e89d9d08e1c8c53ad00e (patch)
treeae5f7c003b0229fcbe3f0049ffd468ba5eb0370a
parent13c6d3dd94161be8e6387e3c0230637db4e9a50d (diff)
downloadZLUDA-aaf8356a545d284b43d2e89d9d08e1c8c53ad00e.tar.gz
ZLUDA-aaf8356a545d284b43d2e89d9d08e1c8c53ad00e.zip
Redefine Curesult as Result<...>
-rw-r--r--cuda_base/Cargo.toml4
-rw-r--r--cuda_base/README2
-rw-r--r--cuda_base/src/cuda.rs392
-rw-r--r--cuda_base/src/lib.rs79
4 files changed, 168 insertions, 309 deletions
diff --git a/cuda_base/Cargo.toml b/cuda_base/Cargo.toml
index 997a426..9c9d531 100644
--- a/cuda_base/Cargo.toml
+++ b/cuda_base/Cargo.toml
@@ -2,11 +2,11 @@
name = "cuda_base"
version = "0.0.0"
authors = ["Andrzej Janik <[email protected]>"]
-edition = "2018"
+edition = "2021"
[dependencies]
quote = "1.0"
-syn = { version = "1.0", features = ["full", "visit-mut"] }
+syn = { version = "2.0", features = ["full", "visit-mut"] }
proc-macro2 = "1.0"
rustc-hash = "1.1.0"
diff --git a/cuda_base/README b/cuda_base/README
index a2fb27f..7ee6f45 100644
--- a/cuda_base/README
+++ b/cuda_base/README
@@ -1 +1 @@
-bindgen build/wrapper.h -o src/cuda.rs --no-partialeq "CUDA_HOST_NODE_PARAMS_st" --with-derive-eq --allowlist-type="^CU.*" --allowlist-function="^cu.*" --allowlist-var="^CU.*" --default-enum-style=newtype --no-layout-tests --no-doc-comments --no-derive-debug --new-type-alias "^CUdevice_v\d+$|^CUdeviceptr_v\d+$" --must-use-type "cudaError_enum" -- -I/usr/local/cuda/include \ No newline at end of file
+bindgen build/wrapper.h -o src/cuda.rs --no-partialeq "CUDA_HOST_NODE_PARAMS_st" --with-derive-eq --allowlist-type="^CU.*" --allowlist-function="^cu.*" --allowlist-var="^CU.*" --default-enum-style=newtype --no-layout-tests --no-doc-comments --no-derive-debug --new-type-alias "^CUdevice_v\d+$|^CUdeviceptr_v\d+$" --must-use-type "cudaError_enum" --constified-enum "cudaError_enum" -- -I/usr/local/cuda/include \ No newline at end of file
diff --git a/cuda_base/src/cuda.rs b/cuda_base/src/cuda.rs
index d7a329f..447f6bd 100644
--- a/cuda_base/src/cuda.rs
+++ b/cuda_base/src/cuda.rs
@@ -2399,301 +2399,105 @@ pub struct CUlibraryHostUniversalFunctionAndDataTable_st {
pub dataWindowSize: usize,
}
pub type CUlibraryHostUniversalFunctionAndDataTable = CUlibraryHostUniversalFunctionAndDataTable_st;
-impl cudaError_enum {
- pub const CUDA_SUCCESS: cudaError_enum = cudaError_enum(0);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_VALUE: cudaError_enum = cudaError_enum(1);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_OUT_OF_MEMORY: cudaError_enum = cudaError_enum(2);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_INITIALIZED: cudaError_enum = cudaError_enum(3);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_DEINITIALIZED: cudaError_enum = cudaError_enum(4);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PROFILER_DISABLED: cudaError_enum = cudaError_enum(5);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PROFILER_NOT_INITIALIZED: cudaError_enum = cudaError_enum(6);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PROFILER_ALREADY_STARTED: cudaError_enum = cudaError_enum(7);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PROFILER_ALREADY_STOPPED: cudaError_enum = cudaError_enum(8);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STUB_LIBRARY: cudaError_enum = cudaError_enum(34);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_DEVICE_UNAVAILABLE: cudaError_enum = cudaError_enum(46);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NO_DEVICE: cudaError_enum = cudaError_enum(100);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_DEVICE: cudaError_enum = cudaError_enum(101);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_DEVICE_NOT_LICENSED: cudaError_enum = cudaError_enum(102);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_IMAGE: cudaError_enum = cudaError_enum(200);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_CONTEXT: cudaError_enum = cudaError_enum(201);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CONTEXT_ALREADY_CURRENT: cudaError_enum = cudaError_enum(202);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MAP_FAILED: cudaError_enum = cudaError_enum(205);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNMAP_FAILED: cudaError_enum = cudaError_enum(206);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ARRAY_IS_MAPPED: cudaError_enum = cudaError_enum(207);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ALREADY_MAPPED: cudaError_enum = cudaError_enum(208);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NO_BINARY_FOR_GPU: cudaError_enum = cudaError_enum(209);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ALREADY_ACQUIRED: cudaError_enum = cudaError_enum(210);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_MAPPED: cudaError_enum = cudaError_enum(211);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_MAPPED_AS_ARRAY: cudaError_enum = cudaError_enum(212);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_MAPPED_AS_POINTER: cudaError_enum = cudaError_enum(213);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ECC_UNCORRECTABLE: cudaError_enum = cudaError_enum(214);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNSUPPORTED_LIMIT: cudaError_enum = cudaError_enum(215);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CONTEXT_ALREADY_IN_USE: cudaError_enum = cudaError_enum(216);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PEER_ACCESS_UNSUPPORTED: cudaError_enum = cudaError_enum(217);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_PTX: cudaError_enum = cudaError_enum(218);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_GRAPHICS_CONTEXT: cudaError_enum = cudaError_enum(219);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NVLINK_UNCORRECTABLE: cudaError_enum = cudaError_enum(220);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_JIT_COMPILER_NOT_FOUND: cudaError_enum = cudaError_enum(221);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNSUPPORTED_PTX_VERSION: cudaError_enum = cudaError_enum(222);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_JIT_COMPILATION_DISABLED: cudaError_enum = cudaError_enum(223);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY: cudaError_enum = cudaError_enum(224);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNSUPPORTED_DEVSIDE_SYNC: cudaError_enum = cudaError_enum(225);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_SOURCE: cudaError_enum = cudaError_enum(300);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_FILE_NOT_FOUND: cudaError_enum = cudaError_enum(301);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: cudaError_enum = cudaError_enum(302);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_SHARED_OBJECT_INIT_FAILED: cudaError_enum = cudaError_enum(303);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_OPERATING_SYSTEM: cudaError_enum = cudaError_enum(304);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_HANDLE: cudaError_enum = cudaError_enum(400);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ILLEGAL_STATE: cudaError_enum = cudaError_enum(401);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_LOSSY_QUERY: cudaError_enum = cudaError_enum(402);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_FOUND: cudaError_enum = cudaError_enum(500);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_READY: cudaError_enum = cudaError_enum(600);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ILLEGAL_ADDRESS: cudaError_enum = cudaError_enum(700);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES: cudaError_enum = cudaError_enum(701);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_LAUNCH_TIMEOUT: cudaError_enum = cudaError_enum(702);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING: cudaError_enum = cudaError_enum(703);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED: cudaError_enum = cudaError_enum(704);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PEER_ACCESS_NOT_ENABLED: cudaError_enum = cudaError_enum(705);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE: cudaError_enum = cudaError_enum(708);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CONTEXT_IS_DESTROYED: cudaError_enum = cudaError_enum(709);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ASSERT: cudaError_enum = cudaError_enum(710);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_TOO_MANY_PEERS: cudaError_enum = cudaError_enum(711);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED: cudaError_enum = cudaError_enum(712);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED: cudaError_enum = cudaError_enum(713);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_HARDWARE_STACK_ERROR: cudaError_enum = cudaError_enum(714);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_ILLEGAL_INSTRUCTION: cudaError_enum = cudaError_enum(715);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MISALIGNED_ADDRESS: cudaError_enum = cudaError_enum(716);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_ADDRESS_SPACE: cudaError_enum = cudaError_enum(717);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_PC: cudaError_enum = cudaError_enum(718);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_LAUNCH_FAILED: cudaError_enum = cudaError_enum(719);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE: cudaError_enum = cudaError_enum(720);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_PERMITTED: cudaError_enum = cudaError_enum(800);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_NOT_SUPPORTED: cudaError_enum = cudaError_enum(801);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_SYSTEM_NOT_READY: cudaError_enum = cudaError_enum(802);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_SYSTEM_DRIVER_MISMATCH: cudaError_enum = cudaError_enum(803);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE: cudaError_enum = cudaError_enum(804);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_CONNECTION_FAILED: cudaError_enum = cudaError_enum(805);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_RPC_FAILURE: cudaError_enum = cudaError_enum(806);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_SERVER_NOT_READY: cudaError_enum = cudaError_enum(807);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_MAX_CLIENTS_REACHED: cudaError_enum = cudaError_enum(808);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED: cudaError_enum = cudaError_enum(809);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_MPS_CLIENT_TERMINATED: cudaError_enum = cudaError_enum(810);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CDP_NOT_SUPPORTED: cudaError_enum = cudaError_enum(811);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CDP_VERSION_MISMATCH: cudaError_enum = cudaError_enum(812);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED: cudaError_enum = cudaError_enum(900);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_INVALIDATED: cudaError_enum = cudaError_enum(901);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_MERGE: cudaError_enum = cudaError_enum(902);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_UNMATCHED: cudaError_enum = cudaError_enum(903);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_UNJOINED: cudaError_enum = cudaError_enum(904);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_ISOLATION: cudaError_enum = cudaError_enum(905);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_IMPLICIT: cudaError_enum = cudaError_enum(906);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_CAPTURED_EVENT: cudaError_enum = cudaError_enum(907);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD: cudaError_enum = cudaError_enum(908);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_TIMEOUT: cudaError_enum = cudaError_enum(909);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE: cudaError_enum = cudaError_enum(910);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_EXTERNAL_DEVICE: cudaError_enum = cudaError_enum(911);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_CLUSTER_SIZE: cudaError_enum = cudaError_enum(912);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_FUNCTION_NOT_LOADED: cudaError_enum = cudaError_enum(913);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_RESOURCE_TYPE: cudaError_enum = cudaError_enum(914);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION: cudaError_enum = cudaError_enum(915);
-}
-impl cudaError_enum {
- pub const CUDA_ERROR_UNKNOWN: cudaError_enum = cudaError_enum(999);
-}
-#[repr(transparent)]
+pub const cudaError_enum_CUDA_SUCCESS: cudaError_enum = 0;
+pub const cudaError_enum_CUDA_ERROR_INVALID_VALUE: cudaError_enum = 1;
+pub const cudaError_enum_CUDA_ERROR_OUT_OF_MEMORY: cudaError_enum = 2;
+pub const cudaError_enum_CUDA_ERROR_NOT_INITIALIZED: cudaError_enum = 3;
+pub const cudaError_enum_CUDA_ERROR_DEINITIALIZED: cudaError_enum = 4;
+pub const cudaError_enum_CUDA_ERROR_PROFILER_DISABLED: cudaError_enum = 5;
+pub const cudaError_enum_CUDA_ERROR_PROFILER_NOT_INITIALIZED: cudaError_enum = 6;
+pub const cudaError_enum_CUDA_ERROR_PROFILER_ALREADY_STARTED: cudaError_enum = 7;
+pub const cudaError_enum_CUDA_ERROR_PROFILER_ALREADY_STOPPED: cudaError_enum = 8;
+pub const cudaError_enum_CUDA_ERROR_STUB_LIBRARY: cudaError_enum = 34;
+pub const cudaError_enum_CUDA_ERROR_DEVICE_UNAVAILABLE: cudaError_enum = 46;
+pub const cudaError_enum_CUDA_ERROR_NO_DEVICE: cudaError_enum = 100;
+pub const cudaError_enum_CUDA_ERROR_INVALID_DEVICE: cudaError_enum = 101;
+pub const cudaError_enum_CUDA_ERROR_DEVICE_NOT_LICENSED: cudaError_enum = 102;
+pub const cudaError_enum_CUDA_ERROR_INVALID_IMAGE: cudaError_enum = 200;
+pub const cudaError_enum_CUDA_ERROR_INVALID_CONTEXT: cudaError_enum = 201;
+pub const cudaError_enum_CUDA_ERROR_CONTEXT_ALREADY_CURRENT: cudaError_enum = 202;
+pub const cudaError_enum_CUDA_ERROR_MAP_FAILED: cudaError_enum = 205;
+pub const cudaError_enum_CUDA_ERROR_UNMAP_FAILED: cudaError_enum = 206;
+pub const cudaError_enum_CUDA_ERROR_ARRAY_IS_MAPPED: cudaError_enum = 207;
+pub const cudaError_enum_CUDA_ERROR_ALREADY_MAPPED: cudaError_enum = 208;
+pub const cudaError_enum_CUDA_ERROR_NO_BINARY_FOR_GPU: cudaError_enum = 209;
+pub const cudaError_enum_CUDA_ERROR_ALREADY_ACQUIRED: cudaError_enum = 210;
+pub const cudaError_enum_CUDA_ERROR_NOT_MAPPED: cudaError_enum = 211;
+pub const cudaError_enum_CUDA_ERROR_NOT_MAPPED_AS_ARRAY: cudaError_enum = 212;
+pub const cudaError_enum_CUDA_ERROR_NOT_MAPPED_AS_POINTER: cudaError_enum = 213;
+pub const cudaError_enum_CUDA_ERROR_ECC_UNCORRECTABLE: cudaError_enum = 214;
+pub const cudaError_enum_CUDA_ERROR_UNSUPPORTED_LIMIT: cudaError_enum = 215;
+pub const cudaError_enum_CUDA_ERROR_CONTEXT_ALREADY_IN_USE: cudaError_enum = 216;
+pub const cudaError_enum_CUDA_ERROR_PEER_ACCESS_UNSUPPORTED: cudaError_enum = 217;
+pub const cudaError_enum_CUDA_ERROR_INVALID_PTX: cudaError_enum = 218;
+pub const cudaError_enum_CUDA_ERROR_INVALID_GRAPHICS_CONTEXT: cudaError_enum = 219;
+pub const cudaError_enum_CUDA_ERROR_NVLINK_UNCORRECTABLE: cudaError_enum = 220;
+pub const cudaError_enum_CUDA_ERROR_JIT_COMPILER_NOT_FOUND: cudaError_enum = 221;
+pub const cudaError_enum_CUDA_ERROR_UNSUPPORTED_PTX_VERSION: cudaError_enum = 222;
+pub const cudaError_enum_CUDA_ERROR_JIT_COMPILATION_DISABLED: cudaError_enum = 223;
+pub const cudaError_enum_CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY: cudaError_enum = 224;
+pub const cudaError_enum_CUDA_ERROR_UNSUPPORTED_DEVSIDE_SYNC: cudaError_enum = 225;
+pub const cudaError_enum_CUDA_ERROR_INVALID_SOURCE: cudaError_enum = 300;
+pub const cudaError_enum_CUDA_ERROR_FILE_NOT_FOUND: cudaError_enum = 301;
+pub const cudaError_enum_CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND: cudaError_enum = 302;
+pub const cudaError_enum_CUDA_ERROR_SHARED_OBJECT_INIT_FAILED: cudaError_enum = 303;
+pub const cudaError_enum_CUDA_ERROR_OPERATING_SYSTEM: cudaError_enum = 304;
+pub const cudaError_enum_CUDA_ERROR_INVALID_HANDLE: cudaError_enum = 400;
+pub const cudaError_enum_CUDA_ERROR_ILLEGAL_STATE: cudaError_enum = 401;
+pub const cudaError_enum_CUDA_ERROR_LOSSY_QUERY: cudaError_enum = 402;
+pub const cudaError_enum_CUDA_ERROR_NOT_FOUND: cudaError_enum = 500;
+pub const cudaError_enum_CUDA_ERROR_NOT_READY: cudaError_enum = 600;
+pub const cudaError_enum_CUDA_ERROR_ILLEGAL_ADDRESS: cudaError_enum = 700;
+pub const cudaError_enum_CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES: cudaError_enum = 701;
+pub const cudaError_enum_CUDA_ERROR_LAUNCH_TIMEOUT: cudaError_enum = 702;
+pub const cudaError_enum_CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING: cudaError_enum = 703;
+pub const cudaError_enum_CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED: cudaError_enum = 704;
+pub const cudaError_enum_CUDA_ERROR_PEER_ACCESS_NOT_ENABLED: cudaError_enum = 705;
+pub const cudaError_enum_CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE: cudaError_enum = 708;
+pub const cudaError_enum_CUDA_ERROR_CONTEXT_IS_DESTROYED: cudaError_enum = 709;
+pub const cudaError_enum_CUDA_ERROR_ASSERT: cudaError_enum = 710;
+pub const cudaError_enum_CUDA_ERROR_TOO_MANY_PEERS: cudaError_enum = 711;
+pub const cudaError_enum_CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED: cudaError_enum = 712;
+pub const cudaError_enum_CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED: cudaError_enum = 713;
+pub const cudaError_enum_CUDA_ERROR_HARDWARE_STACK_ERROR: cudaError_enum = 714;
+pub const cudaError_enum_CUDA_ERROR_ILLEGAL_INSTRUCTION: cudaError_enum = 715;
+pub const cudaError_enum_CUDA_ERROR_MISALIGNED_ADDRESS: cudaError_enum = 716;
+pub const cudaError_enum_CUDA_ERROR_INVALID_ADDRESS_SPACE: cudaError_enum = 717;
+pub const cudaError_enum_CUDA_ERROR_INVALID_PC: cudaError_enum = 718;
+pub const cudaError_enum_CUDA_ERROR_LAUNCH_FAILED: cudaError_enum = 719;
+pub const cudaError_enum_CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE: cudaError_enum = 720;
+pub const cudaError_enum_CUDA_ERROR_NOT_PERMITTED: cudaError_enum = 800;
+pub const cudaError_enum_CUDA_ERROR_NOT_SUPPORTED: cudaError_enum = 801;
+pub const cudaError_enum_CUDA_ERROR_SYSTEM_NOT_READY: cudaError_enum = 802;
+pub const cudaError_enum_CUDA_ERROR_SYSTEM_DRIVER_MISMATCH: cudaError_enum = 803;
+pub const cudaError_enum_CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE: cudaError_enum = 804;
+pub const cudaError_enum_CUDA_ERROR_MPS_CONNECTION_FAILED: cudaError_enum = 805;
+pub const cudaError_enum_CUDA_ERROR_MPS_RPC_FAILURE: cudaError_enum = 806;
+pub const cudaError_enum_CUDA_ERROR_MPS_SERVER_NOT_READY: cudaError_enum = 807;
+pub const cudaError_enum_CUDA_ERROR_MPS_MAX_CLIENTS_REACHED: cudaError_enum = 808;
+pub const cudaError_enum_CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED: cudaError_enum = 809;
+pub const cudaError_enum_CUDA_ERROR_MPS_CLIENT_TERMINATED: cudaError_enum = 810;
+pub const cudaError_enum_CUDA_ERROR_CDP_NOT_SUPPORTED: cudaError_enum = 811;
+pub const cudaError_enum_CUDA_ERROR_CDP_VERSION_MISMATCH: cudaError_enum = 812;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED: cudaError_enum = 900;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_INVALIDATED: cudaError_enum = 901;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_MERGE: cudaError_enum = 902;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_UNMATCHED: cudaError_enum = 903;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_UNJOINED: cudaError_enum = 904;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_ISOLATION: cudaError_enum = 905;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_IMPLICIT: cudaError_enum = 906;
+pub const cudaError_enum_CUDA_ERROR_CAPTURED_EVENT: cudaError_enum = 907;
+pub const cudaError_enum_CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD: cudaError_enum = 908;
+pub const cudaError_enum_CUDA_ERROR_TIMEOUT: cudaError_enum = 909;
+pub const cudaError_enum_CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE: cudaError_enum = 910;
+pub const cudaError_enum_CUDA_ERROR_EXTERNAL_DEVICE: cudaError_enum = 911;
+pub const cudaError_enum_CUDA_ERROR_INVALID_CLUSTER_SIZE: cudaError_enum = 912;
+pub const cudaError_enum_CUDA_ERROR_FUNCTION_NOT_LOADED: cudaError_enum = 913;
+pub const cudaError_enum_CUDA_ERROR_INVALID_RESOURCE_TYPE: cudaError_enum = 914;
+pub const cudaError_enum_CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION: cudaError_enum = 915;
+pub const cudaError_enum_CUDA_ERROR_UNKNOWN: cudaError_enum = 999;
#[must_use]
-#[derive(Copy, Clone, Hash, PartialEq, Eq)]
-pub struct cudaError_enum(pub ::std::os::raw::c_uint);
+pub type cudaError_enum = ::std::os::raw::c_uint;
pub use self::cudaError_enum as CUresult;
impl CUdevice_P2PAttribute_enum {
pub const CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK: CUdevice_P2PAttribute_enum =
diff --git a/cuda_base/src/lib.rs b/cuda_base/src/lib.rs
index b7ebe41..c4904d9 100644
--- a/cuda_base/src/lib.rs
+++ b/cuda_base/src/lib.rs
@@ -11,9 +11,9 @@ use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::visit_mut::VisitMut;
use syn::{
- bracketed, parse_macro_input, Abi, Fields, File, FnArg, ForeignItem, ForeignItemFn, Ident,
- Item, ItemForeignMod, LitStr, PatType, Path, PathArguments, PathSegment, ReturnType, Signature,
- Token, Type, TypeArray, TypePath, TypePtr,
+ bracketed, parse_macro_input, parse_quote, Abi, Fields, File, FnArg, ForeignItem,
+ ForeignItemFn, Ident, Item, ItemForeignMod, LitStr, PatType, Path, PathArguments, PathSegment,
+ ReturnType, Signature, Token, Type, TypeArray, TypePath, TypePtr, UseTree,
};
const CUDA_RS: &'static str = include_str! {"cuda.rs"};
@@ -26,22 +26,23 @@ const CUDA_RS: &'static str = include_str! {"cuda.rs"};
#[proc_macro]
pub fn cuda_type_declarations(_: TokenStream) -> TokenStream {
let mut cuda_module = syn::parse_str::<File>(CUDA_RS).unwrap();
+ let mut curesult_constants = Vec::new();
cuda_module.items = cuda_module
.items
.into_iter()
.filter_map(|item| match item {
Item::ForeignMod(_) => None,
Item::Struct(mut struct_) => {
- if "CUdeviceptr_v2" == struct_.ident.to_string() {
- match &mut struct_.fields {
+ let ident_string = struct_.ident.to_string();
+ match &*ident_string {
+ "CUdeviceptr_v2" => match &mut struct_.fields {
Fields::Unnamed(ref mut fields) => {
fields.unnamed[0].ty =
absolute_path_to_mut_ptr(&["std", "os", "raw", "c_void"])
}
_ => unreachable!(),
- }
- } else if "CUuuid_st" == struct_.ident.to_string() {
- match &mut struct_.fields {
+ },
+ "CUuuid_st" => match &mut struct_.fields {
Fields::Named(ref mut fields) => match fields.named[0].ty {
Type::Array(TypeArray { ref mut elem, .. }) => {
*elem = Box::new(Type::Path(TypePath {
@@ -52,17 +53,71 @@ pub fn cuda_type_declarations(_: TokenStream) -> TokenStream {
_ => unreachable!(),
},
_ => panic!(),
- }
+ },
+ _ => {}
}
Some(Item::Struct(struct_))
}
+ Item::Const(const_) => {
+ let name = const_.ident.to_string();
+ if name.starts_with("cudaError_enum_CUDA_") {
+ curesult_constants.push(const_);
+ }
+ None
+ }
+ Item::Use(use_) => {
+ if let UseTree::Path(ref path) = use_.tree {
+ if let UseTree::Rename(ref rename) = &*path.tree {
+ if rename.rename == "CUresult" {
+ return None;
+ }
+ }
+ }
+ Some(Item::Use(use_))
+ }
i => Some(i),
})
.collect::<Vec<_>>();
+ append_curesult(curesult_constants, &mut cuda_module.items);
syn::visit_mut::visit_file_mut(&mut FixAbi, &mut cuda_module);
cuda_module.into_token_stream().into()
}
+fn append_curesult(curesult_constants: Vec<syn::ItemConst>, items: &mut Vec<Item>) {
+ let curesult_constants = curesult_constants.iter().map(|const_| {
+ let ident = const_.ident.to_string();
+ let expr = &const_.expr;
+ if ident.ends_with("CUDA_SUCCESS") {
+ quote! {
+ const SUCCESS: CUresult = CUresult::Ok(());
+ }
+ } else {
+ let prefix = "cudaError_enum_CUDA_ERROR_";
+ let ident = format_ident!("{}", ident[prefix.len()..]);
+ quote! {
+ const #ident: CUresult = CUresult::Err(unsafe { ::core::num::NonZeroU32::new_unchecked(#expr) });
+ }
+ }
+ });
+ items.push(parse_quote! {
+ trait CUresultConsts {
+ #(#curesult_constants)*
+ }
+ });
+ items.push(parse_quote! {
+ impl CUresultConsts for CUresult {}
+ });
+ items.push(parse_quote! {
+ #[must_use]
+ pub type CUresult = ::core::result::Result<(), ::core::num::NonZeroU32>;
+ });
+ items.push(parse_quote! {
+ const _: fn() = || {
+ let _ = std::mem::transmute::<CUresult, u32>;
+ };
+ });
+}
+
fn segments_to_path(path: &[&'static str]) -> Path {
let mut segments = Punctuated::new();
for ident in path {
@@ -245,7 +300,7 @@ impl Parse for FnDeclInput {
input.parse::<Token![,]>()?;
let override_fns_content;
bracketed!(override_fns_content in input);
- let override_fns = override_fns_content.parse_terminated(Ident::parse)?;
+ let override_fns = override_fns_content.parse_terminated(Ident::parse, Token![,])?;
Ok(Self {
type_path,
normal_macro,
@@ -492,11 +547,11 @@ impl Parse for DeriveDisplayInput {
input.parse::<Token![,]>()?;
let ignore_types_buffer;
bracketed!(ignore_types_buffer in input);
- let ignore_types = ignore_types_buffer.parse_terminated(Ident::parse)?;
+ let ignore_types = ignore_types_buffer.parse_terminated(Ident::parse, Token![,])?;
input.parse::<Token![,]>()?;
let ignore_fns_buffer;
bracketed!(ignore_fns_buffer in input);
- let ignore_fns = ignore_fns_buffer.parse_terminated(Ident::parse)?;
+ let ignore_fns = ignore_fns_buffer.parse_terminated(Ident::parse, Token![,])?;
Ok(Self {
type_path,
trait_,