Sanitizer Api :: Compute Sanitizer Documentation

-->
Sanitizer Api - v2024.2.0 (older) - Last updated May 8, 2024 - Send Feedback

## 1. Modules

Here is a list of all modules:

- Sanitizer Barrier API
- Sanitizer Callback API
- Sanitizer Memory API
- Sanitizer Patching API
- Sanitizer Result Codes
- Sanitizer Stream API

### 1.1. Sanitizer Barrier API

Functions, types, and enums that implement the Sanitizer Barrier API.

#### Functions

SanitizerResult sanitizerGetCudaBarrierCount ( CUfunction kernel, uint32_t* numBarriers )
  Get number of CUDA barriers used by a function.

#### Functions

SanitizerResult sanitizerGetCudaBarrierCount ( CUfunction kernel, uint32_t* numBarriers )
  Get number of CUDA barriers used by a function.

  ###### Parameters

  `kernel`
    CUDA function
  `numBarriers`
    Number of CUDA barriers in the input CUDA function

  ###### Description

  The module where `kernel` resides must have been instrumented using sanitizerPatchModule prior to calling this function. This function is only available for modules built with nvcc 11.2 or newer, it will return 0 otherwise.

  Note:

  Thread-safety: this function is thread safe.

### 1.2. Sanitizer Callback API

Functions, types, and enums that implement the Sanitizer Callback API.

#### Classes

struct
Sanitizer_BatchMemopData
  Data passed into a batch memop callback function.
struct
Sanitizer_CallbackData
  Data passed into a runtime or driver API callback function.
struct
Sanitizer_EventData
  Data passed into an event callback function.
struct
Sanitizer_ExternalMemoryData
  Data passed into an external memory callback function.
struct
Sanitizer_GraphExecData
  Data passed into a graphexec creation callback function.
struct
Sanitizer_GraphLaunchData
  Data passed into a graph launch callback function.
struct
Sanitizer_GraphNodeLaunchData
  Data passed into a graph node launch callback function.
struct
Sanitizer_LaunchData
  Data passed into a launch callback function.
struct
Sanitizer_MemcpyData
  Data passed into a memcpy callback function.
struct
Sanitizer_MemsetData
  Data passed into a memset callback function.
struct
Sanitizer_ResourceArrayData
  Data passed into a CUDA array callback function.
struct
Sanitizer_ResourceContextData
  Data passed into a context resource callback function.
struct
Sanitizer_ResourceFunctionsLazyLoadedData
  Data passed into a CUDA function callback function.
struct
Sanitizer_ResourceMemoryData
  Data passed into a memory resource callback function.
struct
Sanitizer_ResourceMempoolData
  Data passed into a mempool resource callback function.
struct
Sanitizer_ResourceModuleData
  Data passed into a module resource callback function.
struct
Sanitizer_ResourceStreamData
  Data passed into a stream resource callback function.
struct
Sanitizer_ResourceVirtualRange
  Data passed into a VA reservation callback function.
struct
Sanitizer_SynchronizeData
  Data passed into a synchronization callback function.
struct
Sanitizer_UvmData
  Data passed into a managed memory callback function.

#### Typedefs

typedef void(SANITIZERAPI* Sanitizer_CallbackFunc )( void* userdata, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid, const void* cbdata )
  Function type for a callback.
typedef uint32_t Sanitizer_CallbackId
  Callback ID.
typedef Sanitizer_Subscriber_st * Sanitizer_SubscriberHandle
  A callback subscriber.

#### Enumerations

enum Sanitizer_ApiCallbackSite
  Specifies the point in an API call that a callback is issued.
enum Sanitizer_BatchMemopType
  Specifies the type of batch memory operation.
enum Sanitizer_CallackIdSync
  Callback IDs for synchronization domain.
enum Sanitizer_CallbackDomain
  Callback domains.
enum Sanitizer_CallbackIdBatchMemop
  Callback IDs for batch memop domain.
enum Sanitizer_CallbackIdEvents
  Callback IDs for events domain.
enum Sanitizer_CallbackIdExternalMemory
  Callback IDs for external memory domain.
enum Sanitizer_CallbackIdGraphs
  Callback IDs for graphs domain.
enum Sanitizer_CallbackIdLaunch
  Callback IDs for launch domain.
enum Sanitizer_CallbackIdMemcpy
  Callback IDs for memcpy domain.
enum Sanitizer_CallbackIdMemset
  Callback IDs for memset domain.
enum Sanitizer_CallbackIdResource
  Callback IDs for resource domain.
enum Sanitizer_CallbackIdUvm
  Callback IDs for managed memory domain.
enum Sanitizer_MemcpyDirection
  Memcpy direction.
enum Sanitizer_MemoryVisibility
  Specifies the visibility of an allocation.
enum Sanitizer_ResourceMemoryFlags
  Flags describing a memory allocation.
enum Sanitizer_ResourceMemoryPermissions
  Permissions for a memory allocation.

#### Functions

SanitizerResult sanitizerEnableAllDomains ( uint32_t enable, Sanitizer_SubscriberHandle subscriber )
  Enable or disable all callbacks in all domains.
SanitizerResult sanitizerEnableCallback ( uint32_t enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid )
  Enable or disable callbacks for a specific domain and callback ID.
SanitizerResult sanitizerEnableDomain ( uint32_t enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain )
  Enable or disable all callbacks for a specific domain.
SanitizerResult sanitizerGetCallbackState ( uint32_t* enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid )
  Get the current enabled/disabled state of a callback for a specific domain and function ID.
SanitizerResult sanitizerSubscribe ( Sanitizer_SubscriberHandle* subscriber, Sanitizer_CallbackFunc callback, void* userdata )
  Initialize a callback subscriber with a callback function and user data.
SanitizerResult sanitizerUnsubscribe ( Sanitizer_SubscriberHandle subscriber )
  Unregister a callback subscriber.

#### Typedefs

void(SANITIZERAPI* Sanitizer_CallbackFunc )( void* userdata, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid, const void* cbdata )

  Function type for a callback. Function type for a callback. The type of the data passed to the callback in `cbdata` depends on the domain. If `domain` is SANITIZER_CB_DOMAIN_DRIVER_API or SANITIZER_CB_DOMAIN_RUNTIME_API the type of `cbdata` will be Sanitizer_CallbackData. If `domain` is SANITIZER_CB_DOMAIN_RESOURCE the type of `cbdata` will be dependent on cbid. Refer to Sanitizer_ResourceContextData, Sanitizer_ResourceStreamData, Sanitizer_ResourceModuleData and Sanitizer_ResourceMemoryFlags documentations. If `domain` is SANITIZER_CB_DOMAIN_SYNCHRONIZE the type of `cbdata` will be Sanitizer_SynchronizeData. If `domain` is SANITIZER_CB_DOMAIN_LAUNCH the type of `cbdata` will be Sanitizer_LaunchData. If `domain` is SANITIZER_CB_DOMAIN_MEMCPY the type of `cbdata` will be Sanitizer_MemcpyData. If `domain` is SANITIZER_CB_DOMAIN_MEMSET the type of `cbdata` will be Sanitizer_MemsetData. If `domain` is SANITIZER_CB_DOMAIN_BATCH_MEMOP the type of `cbdata` will be Sanitizer_BatchMemopData.

typedef uint32_t Sanitizer_CallbackId

  Callback ID.

typedef Sanitizer_Subscriber_st * Sanitizer_SubscriberHandle

  A callback subscriber.

#### Enumerations

enum Sanitizer_ApiCallbackSite

  Specifies the point in an API that a callback is issued. This value is communicated to the callback function via Sanitizer_CallbackData::CallbackSize.

  ###### Values

  SANITIZER_API_ENTER = 0
    This callback is at API entry.
  SANITIZER_API_EXIT = 1
    This callback is at API exit.
  SANITIZER_API_CBSITE_FORCE_INT = 0x7fffffff
enum Sanitizer_BatchMemopType

  Specifies the type of batch memory operation reported by a callback in domain SANITIZER_CB_DOMAIN_BATCH_MEMOP. This value is communicated to the callback function via Sanitizer_BatchMemopData::type.

  ###### Values

  SANITIZER_BATCH_MEMOP_TYPE_32B = 0
    Batch memory operation size is 32 bits.
  SANITIZER_BATCH_MEMOP_TYPE_64B = 1
    Batch memory operation size is 64 bits.
  SANITIZER_BATCH_MEMOP_TYPE_FORCE_INT = 0x7fffffff
enum Sanitizer_CallackIdSync

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_SYNCHRONIZE. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_SYNCHRONIZE_INVALID = 0
    Invalid synchronize callback ID.
  SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED = 1
    Stream synchronization has completed for a given stream.
  SANITIZER_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED = 2
    Context synchronization has completed for a given context.
  SANITIZER_CBID_SYNCHRONIZE_SIZE
  SANITIZER_CBID_SYNCHRONIZE_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackDomain

  Callback domain. Each domain represents callback points for a group of related API functions or CUDA driver activity.

  ###### Values

  SANITIZER_CB_DOMAIN_INVALID = 0
    Invalid domain.
  SANITIZER_CB_DOMAIN_DRIVER_API = 1
    Domain containing callback points for all driver API functions.
  SANITIZER_CB_DOMAIN_RUNTIME_API = 2
    Domain containing callback points for all runtime API functions.
  SANITIZER_CB_DOMAIN_RESOURCE = 3
    Domain containing callback points for CUDA resource tracking.
  SANITIZER_CB_DOMAIN_SYNCHRONIZE = 4
    Domain containing callback points for CUDA synchronization.
  SANITIZER_CB_DOMAIN_LAUNCH = 5
    Domain containing callback points for CUDA grid launches.
  SANITIZER_CB_DOMAIN_MEMCPY = 6
    Domain containing callback points for CUDA memcpy operations.
  SANITIZER_CB_DOMAIN_MEMSET = 7
    Domain containing callback points for CUDA memset operations.
  SANITIZER_CB_DOMAIN_BATCH_MEMOP = 8
    Domain containing callback points for CUDA batch memop operations.
  SANITIZER_CB_DOMAIN_UVM = 9
    Domain containing callback points for CUDA managed memory operations.
  SANITIZER_CB_DOMAIN_GRAPHS = 10
    Domain containing callback points for CUDA graphs operations.
  SANITIZER_CB_DOMAIN_EVENTS = 11
    Domain containing callback points for CUDA events.
  SANITIZER_CB_DOMAIN_EXTERNAL_MEMORY = 12
    Domain containing callback points for CUDA external memory.
  SANITIZER_CB_DOMAIN_SIZE
  SANITIZER_CB_DOMAIN_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdBatchMemop

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_BATCH_MEMOP. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_BATCH_MEMOP_INVALID = 0
    Invalid batch memop callback ID.
  SANITIZER_CBID_BATCH_MEMOP_WRITE = 1
    A batch memory operation was initiated.
  SANITIZER_CBID_BATCH_MEMOP_SIZE
  SANITIZER_CBID_BATCH_MEMOP_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdEvents

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_EVENTS. This value is communicated to the callback function via the `cbid` parameter. Available with a driver version of 515 or newer.

  ###### Values

  SANITIZER_CBID_EVENTS_INVALID = 0
    Invalid event callback ID.
  SANITIZER_CBID_EVENTS_CREATED = 1
    An event was created.
  SANITIZER_CBID_EVENTS_DESTROYED = 2
    An event was destroyed.
  SANITIZER_CBID_EVENTS_RECORD = 3
    An event was recorded.
  SANITIZER_CBID_EVENTS_STREAM_WAIT = 4
    A stream was synchronized to an event.
  SANITIZER_CBID_EVENTS_SYNCHRONIZE = 5
    An event was synchronized.
  SANITIZER_CBID_EVENTS_SIZE
  SANITIZER_CBID_EVENTS_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdExternalMemory

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_EXTERNA_MEMORY. This value is communicated to the callback function via the `cbid` parameter. Available with a driver version of 535 or newer.

  ###### Values

  SANITIZER_CBID_EXTERNAL_MEMORY_INVALID = 0
    Invalid external memory callback ID.
  SANITIZER_CBID_EXTERNAL_MEMORY_IMPORT = 1
    External memory was imported.
  SANITIZER_CBID_EXTERNAL_MEMORY_MAPPED = 2
    External memory was mapped.
  SANITIZER_CBID_EXTERNAL_MEMORY_DESTROYED = 3
    External memory was destroyed.
  SANITIZER_CBID_EXTERNAL_MEMORY_SIZE
  SANITIZER_CBID_EXTERNAL_MEMORY_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdGraphs

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_GRAPHS. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_GRAPHS_INVALID = 0
    Invalid graphs callback ID.
  SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATING = 1
    A new graphexec is being created.
  SANITIZER_CBID_GRAPHS_GRAPHEXEC_CREATED = 2
    A new graphexec is created.
  SANITIZER_CBID_GRAPHS_GRAPHEXEC_DESTROYING = 3
    A graphexec is being destroyed
  SANITIZER_CBID_GRAPHS_NODE_LAUNCH_BEGIN = 4
    A node launch was initiated.
  SANITIZER_CBID_GRAPHS_NODE_LAUNCH_END = 5
    A node launch is complete.
  SANITIZER_CBID_GRAPHS_LAUNCH_BEGIN = 6
    A graph launch was initiated.
  SANITIZER_CBID_GRAPHS_LAUNCH_END = 7
    A graph launch is complete.
  SANITIZER_CBID_GRAPHS_SIZE
  SANITIZER_CBID_GRAPHS_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdLaunch

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_LAUNCH. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_LAUNCH_INVALID = 0
    Invalid launch callback ID.
  SANITIZER_CBID_LAUNCH_BEGIN = 1
    A grid launch was initiated.
  SANITIZER_CBID_LAUNCH_AFTER_SYSCALL_SETUP = 2
    A grid launch has completed syscalls setup.
  SANITIZER_CBID_LAUNCH_END = 3
    The grid launch is complete.
  SANITIZER_CBID_LAUNCH_SIZE
  SANITIZER_CBID_LAUNCH_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdMemcpy

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_MEMCPY. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_MEMCPY_INVALID = 0
    Invalid memcpy callback ID.
  SANITIZER_CBID_MEMCPY_STARTING = 1
    A memcpy operation was initiated.
  SANITIZER_CBID_MEMCPY_SIZE
  SANITIZER_CBID_MEMCPY_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdMemset

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_MEMSET. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_MEMSET_INVALID = 0
    Invalid memset callback ID.
  SANITIZER_CBID_MEMSET_STARTING = 1
    A memset operation was initiated.
  SANITIZER_CBID_MEMSET_SIZE
  SANITIZER_CBID_MEMSET_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdResource

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_RESOURCE. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_RESOURCE_INVALID = 0
    Invalid resource callback ID.
  SANITIZER_CBID_RESOURCE_INIT_FINISHED = 1
    Driver initialization is finished.
  SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_STARTING = 2
    A new context is about to be created.
  SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_FINISHED = 3
    A new context was created.
  SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_STARTING = 4
    A context is about to be destroyed.
  SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_FINISHED = 5
    A context was destroyed.
  SANITIZER_CBID_RESOURCE_STREAM_CREATED = 6
    A new stream was created.
  SANITIZER_CBID_RESOURCE_STREAM_DESTROY_STARTING = 7
    A stream is about to be destroyed.
  SANITIZER_CBID_RESOURCE_STREAM_DESTROY_FINISHED = 8
    A stream was destroyed.
  SANITIZER_CBID_RESOURCE_MODULE_LOADED = 9
    A module was loaded.
  SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING = 10
    A module is about to be unloaded.
  SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC = 11
    Device memory was allocated.
  SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE = 12
    Device memory was freed.
  SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC = 13
    Pinned host memory was allocated.
  SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE = 14
    Pinned host memory was freed.
  SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC = 15
    Memory was allocated asynchronously.
  SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC = 16
    Memory was freed asynchronously.
  SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE = 17
    Memory freed asynchronously was released, only happens if a regular allocation (cudaMalloc) is free'd asynchronously (cudaFreeAsync).See CUDA runtime documentation for cudaFreeAsync
  SANITIZER_CBID_RESOURCE_MEMPOOL_CREATED = 18
    A new mempool was created.
  SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING = 19
    A mempool is about to be destroyed.
  SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED = 20
    A mempool is now accessible from a peer device.
  SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING = 21
    A mempool is no longer accessible from a peer device.
  SANITIZER_CBID_RESOURCE_ARRAY_CREATED = 22
    A CUDA array was created.
  SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED = 23
    A CUDA array was destroyed.
  SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_LOADED = 24
    CUDA functions were loaded lazily and are fully loaded.
  SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_PATCHED = 25
    CUDA lazily loaded functions were patched.
  SANITIZER_CBID_RESOURCE_VIRTUAL_RESERVE = 26
    The CUDA driver reserved a virtual address range.
  SANITIZER_CBID_RESOURCE_VIRTUAL_RELEASE = 27
    The CUDA driver released a virtual address range.
  SANITIZER_CBID_RESOURCE_MEMPOOL_IMPORT_POINTER = 28
    A memory pool allocation was imported.
  SANITIZER_CBID_RESOURCE_SIZE
  SANITIZER_CBID_RESOURCE_FORCE_INT = 0x7fffffff
enum Sanitizer_CallbackIdUvm

  Callback IDs for resource domain SANITIZER_CB_DOMAIN_UVM. This value is communicated to the callback function via the `cbid` parameter.

  ###### Values

  SANITIZER_CBID_UVM_INVALID = 0
    Invalid managed memory callback ID.
  SANITIZER_CBID_UVM_ATTACH_MEM = 1
    Modify the stream association of an allocation (see cudaStreamAttachMemAsync)
  SANITIZER_CBID_UVM_SIZE
  SANITIZER_CBID_UVM_FORCE_ITN = 0x7fffffff
enum Sanitizer_MemcpyDirection

  Indicates the direction of a memcpy, passed inside `Sanitizer_Memcpydata`.

  ###### Values

  SANITIZER_MEMCPY_DIRECTION_UNKNOWN = 0
    Unknown memcpy direction
  SANITIZER_MEMCPY_DIRECTION_HOST_TO_HOST = 1
    Memcpy from host to host.
  SANITIZER_MEMCPY_DIRECTION_HOST_TO_DEVICE = 2
    Memcpy from host to device.
  SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_HOST = 3
    Memcpy from device to host.
  SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_DEVICE = 4
    Memcpy from device to device.
  SANITIZER_MEMCPY_DIRECTION_SIZE
  SANITIZER_MEMCPY_DIRECTION_FORCE_INT = 0x7fffffff
enum Sanitizer_MemoryVisibility

  Specifies the visibility of an allocation. This is typically GLOBAL on allocations made via cudaMalloc, cudaHostAlloc and similar APIs. This can be GLOBAL or HOST for cudaMallocManaged allocations depending on the flags parameter. This can be changed after allocation time using cudaMemAttachSingle API (see SANITIZER_CBID_UVM_ATTACH_MEM for the corresponding callback).

  ###### Values

  SANITIZER_MEMORY_VISIBILITY_INVALID = 0
    Invalid memory visibility
  SANITIZER_MEMORY_VISIBILITY_GLOBAL = 1
    Memory can be accessed by any stream on any device (see cudaMemAttachGlobal)
  SANITIZER_MEMORY_VISIBILITY_HOST = 2
    Memory cannot be accessed by any stream on any device (see cudaMemAttachHost)
  SANITIZER_MEMORY_VISIBILITY_STREAM = 3
    Memory can only be accessed by a single stream on the associated device (see cudaMemAttachSingle)
  SANITIZER_MEMORY_VISIBILITY_FORCE_INT = 0x7fffffff
enum Sanitizer_ResourceMemoryFlags

  Flags describing a memory allocation. These values are to be used in order to interpret the value of Sanitizer_ResourceMemoryData::flags

  ###### Values

  SANITIZER_MEMORY_FLAG_NONE = 0
    Empty flag.
  SANITIZER_MEMORY_FLAG_MODULE = 0x1
    Specifies that the allocation is static scoped to a module.
  SANITIZER_MEMORY_FLAG_MANAGED = 0x2
    Specifies that the allocation is managed memory.
  SANITIZER_MEMORY_FLAG_HOST_MAPPED = 0x4
    Species that the allocation accessible from the host.
  SANITIZER_MEMORY_FLAG_HOST_PINNED = 0x8
    Specifies that the allocation is pinned on the host.
  SANITIZER_MEMORY_FLAG_PEER = 0x10
    Specifies that the allocation is located on a peer GPU.
  SANITIZER_MEMORY_FLAG_PEER_ATOMIC = 0x20
    Specifies that the allocation is located on a peer GPU supporting native atomics. This implies that SANITIZER_MEMORY_FLAG_PEER is set as well.
  SANITIZER_MEMORY_FLAG_CG_RUNTIME = 0x40
    Specifies that the allocation is used by the Cooperative Groups runtime functions.
  SANITIZER_MEMORY_FLAG_CNP = 0x80
    Specifies that this is an allocation used for CUDA Dynamic Parallelism purposes.
  SANITIZER_MEMORY_FLAG_FORCE_INT = 0x7fffffff
enum Sanitizer_ResourceMemoryPermissions

  Permissions for a memory allocation. These values are to be used in order to interpret the value of Sanitizer_ResourceMemoryData::permissions

  ###### Values

  SANITIZER_MEMORY_PERMISSION_NONE = 0
    No permissions.
  SANITIZER_MEMORY_PERMISSION_READ = 0x1
    Specifies that the allocation is readable.
  SANITIZER_MEMORY_PERMISSION_WRITE = 0x2
    Specifies that the allocation is writable.
  SANITIZER_MEMORY_PERMISSION_ATOMIC = 0x4
    Specifies that the allocation is readable/writable with atomic operations.
  SANITIZER_MEMORY_PERMISSION_ALL = 0x7
    Specifies that the allocation has all permissions.
  SANITIZER_MEMORY_PERMISSION_FORCE_INT = 0x7fffffff

#### Functions

SanitizerResult sanitizerEnableAllDomains ( uint32_t enable, Sanitizer_SubscriberHandle subscriber )
  Enable or disable all callbacks in all domains.

  ###### Parameters

  `enable`
    New enable state for all callbacks in all domains. Zero disables all callbacks, non-zero enables all callbacks.
  `subscriber`
    - Handle of the initialized subscriber

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `subscriber` is invalid

  ###### Description

  Enable or disable all callbacks in all domains.

  Note:

  Thread-safety: a subscriber must serialize access to sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub, d, *) and sanitizerEnableAllDomains(sub) are called concurrently, the results are undefined.

SanitizerResult sanitizerEnableCallback ( uint32_t enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid )
  Enable or disable callbacks for a specific domain and callback ID.

  ###### Parameters

  `enable`
    New enable state for the callback. Zero disables the callback, non-zero enables the callback
  `subscriber`
    - Handle of the initialized subscriber
  `domain`
    The domain of the callback
  `cbid`
    The ID of the callback

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `subscriber`, `domain` or `cbid` is invalid

  ###### Description

  Enable or disable callbacks for a subscriber for a specific domain and callback ID.

  Note:

  Thread-safety: a subscriber must serialize access to sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub, d, c) and sanitizerEnableCallback(sub, d, c) are called concurrently, the results are undefined.

SanitizerResult sanitizerEnableDomain ( uint32_t enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain )
  Enable or disable all callbacks for a specific domain.

  ###### Parameters

  `enable`
    New enable state for all callbacks in the domain. Zero disables all callbacks, non-zero enables all callbacks
  `subscriber`
    - Handle of the initialized subscriber
  `domain`
    The domain of the callback

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `subscriber` or `domain` is invalid

  ###### Description

  Enable or disable all callbacks for a specific domain.

  Note:

  Thread-safety: a subscriber must serialize access to sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and sanitizerEnableAllDomains. For example, if sanitizerGetCallbackEnabled(sub, d, *) and sanitizerEnableDomain(sub, d) are called concurrently, the results are undefined.

SanitizerResult sanitizerGetCallbackState ( uint32_t* enable, Sanitizer_SubscriberHandle subscriber, Sanitizer_CallbackDomain domain, Sanitizer_CallbackId cbid )
  Get the current enabled/disabled state of a callback for a specific domain and function ID.

  ###### Parameters

  `enable`
    Returns non-zero if callback enabled, zero if not enabled
  `subscriber`
    Handle to the initialized subscriber
  `domain`
    The domain of the callback
  `cbid`
    The ID of the callback

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `enabled` is NULL, or if `subscriber`, `domain` or `cbid` is invalid.

  ###### Description

  Returns non-zero in `*enable` if the callback for a domain and callback ID is enabled, and zero if not enabled.

  Note:

  Thread-safety: a subscriber must serialize access to sanitizerGetCallbackState, sanitizerEnableCallback, sanitizerEnableDomain, and sanitizerEnableAllDomains. For example, if sanitizerGetCallbackState(sub, d, c) and sanitizerEnableCallback(sub, d, c) are called concurrently, the results are undefined.

SanitizerResult sanitizerSubscribe ( Sanitizer_SubscriberHandle* subscriber, Sanitizer_CallbackFunc callback, void* userdata )
  Initialize a callback subscriber with a callback function and user data.

  ###### Parameters

  `subscriber`
    Returns handle to initialize subscriber
  `callback`
    The callback function
  `userdata`
    A pointer to user data. This data will be passed to the callback function via the `userdata` parameter

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_MAX_LIMIT_RACHED

    if there is already a sanitizer subscriber

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `subscriber` is NULL

  ###### Description

  Initialize a callback subscriber with a callback function and (optionally) a pointer to user data. The returned subscriber handle can be used to enable and disable the callback for specific domains and callback IDs.

  Note:

  - Only one subscriber can be registered at a time.

  - This function does not enable any callbacks.

  - Thread-safety: this function is thread safe.

SanitizerResult sanitizerUnsubscribe ( Sanitizer_SubscriberHandle subscriber )
  Unregister a callback subscriber.

  ###### Parameters

  `subscriber`
    Handle to the initialized subscriber

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `subscriber` is NULL or not initialized

  ###### Description

  Removes a callback subscriber so that no future callback will be issued to that subscriber.

  Note:

  Thread-safety: this function is thread safe.

### 1.3. Sanitizer Memory API

Functions, types, and enums that implement the Sanitizer Memory API.

#### Functions

SanitizerResult sanitizerAlloc ( CUcontext ctx, void** devPtr, size_t size )
  Allocate memory on the device.
SanitizerResult sanitizerAllocHost ( CUcontext ctx, void** devPtr, size_t size )
  Allocate host pinned memory.
SanitizerResult sanitizerFree ( CUcontext ctx, void* devPtr )
  Frees memory on the device.
SanitizerResult sanitizerFreeHost ( CUcontext ctx, void* devPtr )
  Frees host memory.
SanitizerResult sanitizerMemcpyDeviceToHost ( void* dst, void* src, size_t count, Sanitizer_StreamHandle stream )
  Copies data from device to host.
SanitizerResult sanitizerMemcpyHostToDeviceAsync ( void* dst, void* src, size_t count, Sanitizer_StreamHandle stream )
  Copies data from host to device.
SanitizerResult sanitizerMemset ( void* devPtr, int value, size_t count, Sanitizer_StreamHandle stream )
  Initializes or sets device memory to a value.

#### Functions

SanitizerResult sanitizerAlloc ( CUcontext ctx, void** devPtr, size_t size )
  Allocate memory on the device.

  ###### Parameters

  `ctx`
    Context for the allocation. If NULL, the current context will be used.
  `devPtr`
    Pointer to allocated device memory
  `size`
    Allocation size in bytes

  ###### Description

  Equivalent of cudaMalloc that can be called within a callback function.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerAllocHost ( CUcontext ctx, void** devPtr, size_t size )
  Allocate host pinned memory.

  ###### Parameters

  `ctx`
    Context for the allocation. If NULL, the current context will be used.
  `devPtr`
    Pointer to allocated host memory
  `size`
    Allocation size in bytes

  ###### Description

  Equivalent of cudaMallocHost that can be called within a callback function.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerFree ( CUcontext ctx, void* devPtr )
  Frees memory on the device.

  ###### Parameters

  `ctx`
    Context for the allocation. If NULL, the current context will be used.
  `devPtr`
    Device pointer to memory to free

  ###### Description

  Equivalent of cudaFree that can be called within a callback function.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerFreeHost ( CUcontext ctx, void* devPtr )
  Frees host memory.

  ###### Parameters

  `ctx`
    Context for the allocation. If NULL, the current context will be used.
  `devPtr`
    Host pointer to memory to free

  ###### Description

  Equivalent of cudaFreeHost that can be called within a callback function.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerMemcpyDeviceToHost ( void* dst, void* src, size_t count, Sanitizer_StreamHandle stream )
  Copies data from device to host.

  ###### Parameters

  `dst`
    Destination memory address
  `src`
    Source memory address
  `count`
    Size in bytes to copy
  `stream`
    Stream handle. If NULL, the NULL stream will be used.

  ###### Description

  Equivalent of cudaMemcpy that can be called within a callback function. The function will return once the copy has completed.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerMemcpyHostToDeviceAsync ( void* dst, void* src, size_t count, Sanitizer_StreamHandle stream )
  Copies data from host to device.

  ###### Parameters

  `dst`
    Destination memory address
  `src`
    Source memory address
  `count`
    Size in bytes to copy
  `stream`
    Stream handle. If NULL, the NULL stream will be used.

  ###### Description

  Equivalent of cudaMemcpyAsync that can be called within a callback function. The function will return once the pageable buffer has been copied to the staging memory for DMA transfer to device memory, but the DMA to final destination may not have completed.

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerMemset ( void* devPtr, int value, size_t count, Sanitizer_StreamHandle stream )
  Initializes or sets device memory to a value.

  ###### Parameters

  `devPtr`
    Pointer to device memory
  `value`
    value to set for each byte of specified memory
  `count`
    Size in bytes to set
  `stream`
    Stream handle. If NULL, the NULL stream will be used.

  ###### Description

  Equivalent of cudaMemset that can be called within a callback function.

  Note:

  Thread-safety: this function is thread safe.

### 1.4. Sanitizer Patching API

Functions, types, and enums that implement the Sanitizer Patching API.

#### Typedefs

typedef SanitizerPatchResult* ( *SanitizerCallbackAsyncReduction )( void* userdata, uint64_t pc, uint32_t address, uint32_t mbarAddress, uint32_t accessSize )
  Function type for an asynchronous reduction operation on shared memory.
typedef SanitizerPatchResult* ( *SanitizerCallbackAsyncStore )( void* userdata, uint64_t pc, uint32_t address, uint32_t mbarAddress, void* pNewValue, uint32_t accessSize )
  Function type for an asynchronous store operation on shared memory.
typedef SanitizerPatchResult* ( *SanitizerCallbackBarrier )( void* userdata, uint64_t pc, uint32_t barIndex, uint32_t threadCount, uint32_t flags )
  Function type for a barrier callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackBlockEnter )( void* userdata, uint64_t pc )
  Function type for a CUDA block enter callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackBlockExit )( void* userdata, uint64_t pc )
  Function type for a CUDA block exit callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackBulkCopyGlobalToShared )( void* userdata, uint64_t pc, uint64_t src, uint32_t dst, uint32_t barrier, uint32_t data, uint32_t isMulticast )
  Function type for a async bulk copy from global to shared memory.
typedef SanitizerPatchResult* ( *SanitizerCallbackCacheControl )( void* userdata, uint64_t pc, void* address, Sanitizer_CacheControlInstructionKind kind )
  Function type for a cache control instruction callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackCall )( void* userdata, uint64_t pc, uint64_t targetPc, uint32_t flags )
  Function type for a function call callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackClusterBarrierArrive )( void* userdata, uint64_t pc )
  Function type for a cluster barrier arrive.
typedef SanitizerPatchResult* ( *SanitizerCallbackCudaBarrier )( void* userdata, uint64_t pc, void* barrier, uint32_t kind, uint32_t data )
  Function type for a CUDA Barrier action callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackDeviceSideFree )( void* userdata, uint64_t pc, void* ptr )
  Function type for a device-side free call.
typedef SanitizerPatchResult* ( *SanitizerCallbackDeviceSideMalloc )( void* userdata, uint64_t pc, void* allocatedPtr, uint64_t allocatedSize )
  Function type for a device-side malloc call.
typedef SanitizerPatchResult* ( *SanitizerCallbackMatrixMemoryAccess )( void* userdata, uint64_t pc, uint32_t address, uint32_t accessSize, uint32_t flags, uint32_t count, const void* pNewValue )
  Function type for a matrix shared memory access callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackMemcpyAsync )( void* userdata, uint64_t pc, void* src, uint32_t dst, uint32_t accessSize )
  Function type for a global to shared memory asynchronous copy.
typedef SanitizerPatchResult* ( *SanitizerCallbackMemoryAccess )( void* userdata, uint64_t pc, void* ptr, uint32_t accessSize, uint32_t flags, const void* pData )
  Function type for a memory access callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackPipelineCommit )( void* userdata, uint64_t pc )
  Function type for a pipeline commit.
typedef SanitizerPatchResult* ( *SanitizerCallbackPipelineWait )( void* userdata, uint64_t pc, uint32_t groups )
  Function type for a pipeline wait.
typedef SanitizerPatchResult* ( *SanitizerCallbackRet )( void* userdata, uint64_t pc )
  Function type for a function return callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackSetSmemSize )( void* userdata, uint64_t pc, uint32_t size )
  Function type for setting the shared memory size allocated to a block.
typedef SanitizerPatchResult* ( *SanitizerCallbackShfl )( void* userdata, uint64_t pc )
  Function type for a shfl callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackSyncwarp )( void* userdata, uint64_t pc, uint32_t mask )
  Function type for a syncwarp callback.
typedef SanitizerPatchResult* ( *SanitizerCallbackWarpgroupFence )( void* userdata, uint64_t pc, uint32_t warpMask )
  Function type for a warpgroup MMA fence.
typedef SanitizerPatchResult* ( *SanitizerCallbackWarpgroupMMAAsync )( void* userdata, uint64_t pc, uint32_t addressMatrixA, uint32_t sizeMatrixA, uint32_t addressMatrixB, uint32_t sizeMatrixB, uint32_t flags, uint32_t warpMask )
  Function type for a warpgroup aligned async MMA.
typedef SanitizerPatchResult* ( *SanitizerCallbackWarpgroupWaitGroup )( void* userdata, uint64_t pc, uint32_t numGroups, uint32_t warpMask )
  Function type for a warpgroup MMA wait group.

#### Enumerations

enum SanitizerPatchResult
  Sanitizer patch result codes.
enum Sanitizer_BarrierFlags
  Flags describing a barrier.
enum Sanitizer_CacheControlInstructionKind
  Cache control action.
enum Sanitizer_CallFlags
  Flags describing a function call.
enum Sanitizer_CudaBarrierInstructionKind
  CUDA Barrier action kind.
enum Sanitizer_DeviceMemoryFlags
  Flags describing a memory access.
enum Sanitizer_InstructionId
  Instrumentation.
enum Sanitizer_WarpgroupMMAAsyncFlags
  Flags describing a warpgroup aligned MMA async.

#### Functions

SanitizerResult sanitizerAddPatches ( const void* image, CUcontext ctx )
  Load a module containing patches that can be used by the patching API.
SanitizerResult sanitizerAddPatchesFromFile ( const char* filename, CUcontext ctx )
  Load a module containing patches that can be used by the patching API.
SanitizerResult sanitizerGetCallbackPcAndSize ( CUcontext ctx, const char* deviceCallbackName, uint64_t* pc, uint64_t* size )
  Get PC and size of a device callback.
SanitizerResult sanitizerGetFunctionLoadedStatus ( CUfunction func, Sanitizer_FunctionLoadedStatus* loadingStatus )
  Get the loading status of a function. Requires a driver version >=515.
SanitizerResult sanitizerGetFunctionPcAndSize ( CUmodule module, const char* functionName, uint64_t* pc, uint64_t* size )
  Get PC and size of a CUDA function.
SanitizerResult sanitizerPatchInstructions ( const Sanitizer_InstructionId instructionId, CUmodule module, const char* deviceCallbackName )
  Set instrumentation points and patches to be applied in a module.
SanitizerResult sanitizerPatchModule ( CUmodule module )
  Perform the actual instrumentation of a module.
SanitizerResult sanitizerSetCallbackData ( CUfunction kernel, const void* userdata )
  Specifies the user data pointer for callbacks.
SanitizerResult sanitizerSetDeviceGraphData ( CUgraphExec graphExec, Sanitizer_StreamHandle stream, const void* userdata )
  Specifies the user data pointer accessible from callbacks in the device-launched graphs launched by the specified host-launched graphExec.
SanitizerResult sanitizerSetLaunchCallbackData ( Sanitizer_LaunchHandle launch, CUfunction kernel, Sanitizer_StreamHandle stream, const void* userdata )
  Specifies the user data pointer for callbacks.
SanitizerResult sanitizerUnpatchModule ( CUmodule module )
  Remove existing instrumentation of a module.

#### Typedefs

SanitizerPatchResult* ( *SanitizerCallbackAsyncReduction )( void* userdata, uint64_t pc, uint32_t address, uint32_t mbarAddress, uint32_t accessSize )

  Function type for an asynchronous reduction operation on shared memory. This can be generated by a red.async PTX instruction

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `address` is the destination address in shared memory. `mbarAddress` is the address of the mbarrier object. `accessSize` is the size of the access in bytes. Valid values are 4 and 8.

SanitizerPatchResult* ( *SanitizerCallbackAsyncStore )( void* userdata, uint64_t pc, uint32_t address, uint32_t mbarAddress, void* pNewValue, uint32_t accessSize )

  Function type for an asynchronous store operation on shared memory. This can be generated by a st.async PTX instruction

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `address` is the destination address in shared memory. `mbarAddress` is the address of the mbarrier object. `pNewValue` is a pointer to the new value being written. `accessSize` is the size of the access in bytes. Valid values are 4 and 8.

SanitizerPatchResult* ( *SanitizerCallbackBarrier )( void* userdata, uint64_t pc, uint32_t barIndex, uint32_t threadCount, uint32_t flags )

  Function type for a barrier callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `barIndex` is the barrier index. `threadCount` is the number of expected threads (must be a multiple of the warp size). `flags` contains information about the barrier. See Sanitizer_BarrierFlags to interpret this value. 0 means that all threads are participating in the barrier.

SanitizerPatchResult* ( *SanitizerCallbackBlockEnter )( void* userdata, uint64_t pc )

  Function type for a CUDA block enter callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the entry point of the block

SanitizerPatchResult* ( *SanitizerCallbackBlockExit )( void* userdata, uint64_t pc )

  Function type for a CUDA block exit callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

SanitizerPatchResult* ( *SanitizerCallbackBulkCopyGlobalToShared )( void* userdata, uint64_t pc, uint64_t src, uint32_t dst, uint32_t barrier, uint32_t data, uint32_t isMulticast )

  Function type for a async bulk copy from global to shared memory. This can be generated by a cp.async.bulk.shared::cluster.global instruction

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `dst` is the destination DSMEM address. `barrier` is the DSMEM address for the associated mbarrier completion mechanism `src` is the source global memory address `data` contains in bits 0:15 the number of 16 bytes blocks requested and in bits 16:31 the multicast mask `isMulticast` is a boolean value indicating if the operation is a multicast

  All the active threads in a warp have the same parameter values.

SanitizerPatchResult* ( *SanitizerCallbackCacheControl )( void* userdata, uint64_t pc, void* address, Sanitizer_CacheControlInstructionKind kind )

  Function type for a cache control instruction callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `address` is the address of the memory being controlled `kind` is the type of cache control. See Sanitizer_CacheControlInstructionKind

SanitizerPatchResult* ( *SanitizerCallbackCall )( void* userdata, uint64_t pc, uint64_t targetPc, uint32_t flags )

  Function type for a function call callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `targetPc` is the PC where the called function is located. `flags` contains information about the function call.

SanitizerPatchResult* ( *SanitizerCallbackClusterBarrierArrive )( void* userdata, uint64_t pc )

  Function type for a cluster barrier arrive. Function type for a cluster barrier wait.

  This can be generated by a cg::this_cluster().sync() (C++ API), or a barrier.cluster.arrive (PTX API).

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

  This can be generated by a cg::this_cluster().sync() (C++ API), or a barrier.cluster.wait (PTX API).

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

SanitizerPatchResult* ( *SanitizerCallbackCudaBarrier )( void* userdata, uint64_t pc, void* barrier, uint32_t kind, uint32_t data )

  Function type for a CUDA Barrier action callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `barrier` Barrier address which can be used as a unique identifier `kind` Barrier action type. See Sanitizer_CudaBarrierInstructionKind `data` Barrier data. This is specific to each action type, refer to Sanitizer_CudaBarrierInstructionKind

SanitizerPatchResult* ( *SanitizerCallbackDeviceSideFree )( void* userdata, uint64_t pc, void* ptr )

  Function type for a device-side free call.

  Note:

  This is called prior to the actual call.

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `ptr` is the pointer passed to device-side free.

SanitizerPatchResult* ( *SanitizerCallbackDeviceSideMalloc )( void* userdata, uint64_t pc, void* allocatedPtr, uint64_t allocatedSize )

  Function type for a device-side malloc call.

  Note:

  This is called after the call has completed.

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `allocatedPtr` is the pointer returned by device-side malloc `allocatedSize` is the size requested by the user to device-side malloc.

SanitizerPatchResult* ( *SanitizerCallbackMatrixMemoryAccess )( void* userdata, uint64_t pc, uint32_t address, uint32_t accessSize, uint32_t flags, uint32_t count, const void* pNewValue )

  Function type for a matrix shared memory access callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `address` is the address of the shared memory being read or written. This is an offset within the shared memory window `accessSize` is the size of the access in bytes. Valid value is 16. `flags` contains information about the type of access. See Sanitizer_DeviceMemoryFlags to interpret this value. `count` is the number of matrices accessed. `pNewValue` is a pointer to the new value being written if the access is a write. If the access is a read or an atomic, the pointer will be NULL.

SanitizerPatchResult* ( *SanitizerCallbackMemcpyAsync )( void* userdata, uint64_t pc, void* src, uint32_t dst, uint32_t accessSize )

  Function type for a global to shared memory asynchronous copy. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `src` is the address of the global memory being read. This can be NULL if src-size is 0. `dst` is the address of the shared memory being written. This is an offset within the shared memory window `accessSize` is the size of the access in bytes. Valid values are 4, 8 and 16.

SanitizerPatchResult* ( *SanitizerCallbackMemoryAccess )( void* userdata, uint64_t pc, void* ptr, uint32_t accessSize, uint32_t flags, const void* pData )

  Function type for a memory access callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `ptr` is the address of the memory being accessed. For local or shared memory access, this is the offset within the local or shared memory window. `accessSize` is the size of the access in bytes. Valid values are 1, 2, 4, 8, and 16. `flags` contains information about the type of access. See Sanitizer_DeviceMemoryFlags to interpret this value. `pData` is a pointer which value depends on the type of access:

  - If the access is a write, `pData` points to the new value being written.

  - If the access is a read and `pData` is not `NULL`, then it points to a 32-bit mask of loaded bytes being used (padding bytes will not appear).

  - If the access is an atomic, the pointer will be `NULL`.

SanitizerPatchResult* ( *SanitizerCallbackPipelineCommit )( void* userdata, uint64_t pc )

  Function type for a pipeline commit. This can be generated by a pipeline::producer_commit (C++ API), a pipeline_commit (C API) or a cp.async.commit_group (PTX API).

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

SanitizerPatchResult* ( *SanitizerCallbackPipelineWait )( void* userdata, uint64_t pc, uint32_t groups )

  Function type for a pipeline wait. This can be generated by a pipeline::consumer_wait (C++ API), a pipeline_wait_prior (C API), cp.async.wait_group or cp.async.wait_all (PTX API).

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `groups` is the number of groups the pipeline will wait for. 0 is used to wait for all groups.

SanitizerPatchResult* ( *SanitizerCallbackRet )( void* userdata, uint64_t pc )

  Function type for a function return callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

SanitizerPatchResult* ( *SanitizerCallbackSetSmemSize )( void* userdata, uint64_t pc, uint32_t size )

  Function type for setting the shared memory size allocated to a block. This can be generated by a setsmemsize.sync instruction

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `size` is the requested size in bytes.

SanitizerPatchResult* ( *SanitizerCallbackShfl )( void* userdata, uint64_t pc )

  Function type for a shfl callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction

SanitizerPatchResult* ( *SanitizerCallbackSyncwarp )( void* userdata, uint64_t pc, uint32_t mask )

  Function type for a syncwarp callback. `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `mask` is the thread mask passed to __syncwarp().

SanitizerPatchResult* ( *SanitizerCallbackWarpgroupFence )( void* userdata, uint64_t pc, uint32_t warpMask )

  Function type for a warpgroup MMA fence. This can be generated by a wgmma.fence in PTX.

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `warpMask` is a mask of threads that will perform the fence operation. Expected values are either 0x0 or 0xffffffff (full). The value is expected to be the same across the warpgroup. Other values can be reported but signal a programming error in the target application.

SanitizerPatchResult* ( *SanitizerCallbackWarpgroupMMAAsync )( void* userdata, uint64_t pc, uint32_t addressMatrixA, uint32_t sizeMatrixA, uint32_t addressMatrixB, uint32_t sizeMatrixB, uint32_t flags, uint32_t warpMask )

  Function type for a warpgroup aligned async MMA. This can be generated by a wgmma.mma_async in PTX.

  `userdata` is a pointer to user data. See sanitizerPatchModule `pc` is the program counter of the patched instruction `addressMatrixA` is the address in shared memory of the matrix A being read. This field is only valid if sizeMatrixA is non-zero and warpMask is full. `sizeMatrixA` is the size of the matrix A in shared memory. A value of 0 means that the matrix A is read from registers instead. `addressMatrixB` is the address in shared memory of the matrix B being read. This field is only valid if warpMask is full. `sizeMatrixB` is the size of the matrix B in shared memory. The value will always be non-zero. `flags` of type Sanitizer_WarpgroupMMAAsyncFlags provide information about the access. These flags are to be taken into account even if the warpMask is zero. `warpMask` is a mask of threads that will perform the operation and read the operands. Expected values are either 0x0 or 0xffffffff (full). The value is expected to be the same across the warpgroup. Other values can be reported but signal a programming error in the target application.

SanitizerPatchResult* ( *SanitizerCallbackWarpgroupWaitGroup )( void* userdata, uint64_t pc, uint32_t numGroups, uint32_t warpMask )

  Function type for a warpgroup MMA wait group. This can be generated by a wgmma.wait_group in PTX.

  `userdata` is a pointer to user data. See sanitizerPatchModule. `pc` is the program counter of the patched instruction. `numGroups` is the maximum number of group that will be left pending after the operation. A value of zero means that all MMA async of the warpgroup are guaranteed to have completed after the operation. `warpMask` is a mask of threads for which the expected values are either 0x0 or 0xffffffff (full). The value is expected to be the same across the warpgroup. Other values can be reported but signal a programming error in the target application. If the value is valid, the value has no influence on the operation.

#### Enumerations

enum SanitizerPatchResult

  Error and result codes returned by Sanitizer patches. If a patch returns SANITIZER_PATCH_ERROR, the thread will be exited. On Volta and newer architectures, the full warp which the thread belongs to will be exited.

  ###### Values

  SANITIZER_PATCH_SUCCESS = 0
    No error.
  SANITIZER_PATCH_ERROR = 1
    An error was detected in the patch.
  SANITIZER_PATCH_FORCE_INT = 0x7fffffff
enum Sanitizer_BarrierFlags

  Flags describing a barrier. These values are to be or-combined in the value of flags for a SanitizerCallbackBarrier callback.

  ###### Values

  SANITIZER_BARRIER_FLAG_NONE = 0
    Empty flag.
  SANITIZER_BARRIER_FLAG_UNALIGNED_ALLOWED = 0x1
    Specifies that the barrier can be called unaligned. This flag is only valid on SM 7.0 and above.
  SANITIZER_BARRIER_FLAG_FORCE_INT = 0x7fffffff
enum Sanitizer_CacheControlInstructionKind

  ###### Values

  SANITIZER_CACHE_CONTROL_INVALID = 0
    Invalid action ID.
  SANITIZER_CACHE_CONTROL_L1_PREFETCH = 1
    Prefetch to L1.
  SANITIZER_CACHE_CONTROL_L2_PREFETCH = 2
    Prefetch to L2.
  SANITIZER_CACHE_CONTROL_FORCE_INT = 0x7fffffff
enum Sanitizer_CallFlags

  Flags describing a function call. These values are to be or-combined in the value of flags for a SanitizerCallbackCall callback.

  ###### Values

  SANITIZER_CALL_FLAG_NONE = 0
    Empty flag.
  SANITIZER_CALL_FLAG_UNALIGNED_ALLOWED = 0x1
    Specifies that barriers within this function call can be called unaligned. This flag is only valid on SM 7.0 and above.
  SANITIZER_CALL_FLAG_FORCE_INT = 0x7fffffff
enum Sanitizer_CudaBarrierInstructionKind

  Refer to the CUDA Barrier interface section of the CUDA toolkit documentation for a more extensive description of these actions.

  ###### Values

  SANITIZER_CUDA_BARRIER_INVALID = 0
    Invalid action ID.
  SANITIZER_CUDA_BARRIER_INIT = 1
    Barrier initialization.
  SANITIZER_CUDA_BARRIER_ARRIVE = 2
    Barrier arrive operation. On Hopper and newer architectures, barrier data is the count argument to the arrive-on operation.
  SANITIZER_CUDA_BARRIER_ARRIVE_DROP = 3
    Barrier arrive and drop operation. On Hopper and newer architectures, barrier data is the count argument to the arrive-on operation.
  SANITIZER_CUDA_BARRIER_ARRIVE_NOCOMPLETE = 4
    Barrier arrive operation without phase completion. Barrier data is the count argument to the arrive-on operation.
  SANITIZER_CUDA_BARRIER_ARRIVE_DROP_NOCOMPLETE = 5
    Barrier arrive and drop operation without phase completion. Barrier data is the count argument to the arrive-on operation.
  SANITIZER_CUDA_BARRIER_WAIT = 6
    Barrier wait operation.
  SANITIZER_CUDA_BARRIER_INVALIDATE = 7
    Barrier invalidation.
  SANITIZER_CUDA_BARRIER_FORCE_INT = 0x7fffffff
enum Sanitizer_DeviceMemoryFlags

  Flags describing a memory access. These values are to be or-combined in the value of flags for a SanitizerCallbackMemoryAccess callback.

  ###### Values

  SANITIZER_MEMORY_DEVICE_FLAG_NONE = 0
    Empty flag.
  SANITIZER_MEMORY_DEVICE_FLAG_READ = 0x1
    Specifies that the access is a read.
  SANITIZER_MEMORY_DEVICE_FLAG_WRITE = 0x2
    Specifies that the access is a write.
  SANITIZER_MEMORY_DEVICE_FLAG_ATOMSYS = 0x4
    Specifies that the access is a system-scoped atomic.
  SANITIZER_MEMORY_DEVICE_FLAG_PREFETCH = 0x8
    Specifies that the access is a cache prefetch.
  SANITIZER_MEMORY_DEVICE_FLAG_FORCE_INT = 0x7fffffff
enum Sanitizer_InstructionId

  Instrumentation. Every entry represent an instruction type or a function call where a callback patch can be inserted.

  ###### Values

  SANITIZER_INSTRUCTION_INVALID = 0
    Invalid instruction ID.
  SANITIZER_INSTRUCTION_BLOCK_ENTER = 1
    CUDA block enter. This is called prior to any user code. The type of the callback must be SanitizerCallbackBlockEnter.
  SANITIZER_INSTRUCTION_BLOCK_EXIT = 2
    CUDA block exit. This is called after all user code has executed. The type of the callback must be SanitizerCallbackBlockExit.
  SANITIZER_INSTRUCTION_GLOBAL_MEMORY_ACCESS = 3
    Global Memory Access. This can be a store, load or atomic operation. The type of the callback must be SanitizerCallbackMemoryAccess.
  SANITIZER_INSTRUCTION_SHARED_MEMORY_ACCESS = 4
    Shared Memory Access. This can be a store, load or atomic operation. The type of the callback must be SanitizerCallbackMemoryAccess.
  SANITIZER_INSTRUCTION_LOCAL_MEMORY_ACCESS = 5
    Local Memory Access. This can be a store or load operation. The type of the callback must be SanitizerCallbackMemoryAccess.
  SANITIZER_INSTRUCTION_BARRIER = 6
    Barrier. The type of the callback must be SanitizerCallbackBarrier.
  SANITIZER_INSTRUCTION_SYNCWARP = 7
    Syncwarp. The type of the callback must be SanitizerCallbackSyncwarp.
  SANITIZER_INSTRUCTION_SHFL = 8
    Shfl. The type of the callback must be SanitizerCallbackShfl.
  SANITIZER_INSTRUCTION_CALL = 9
    Function call. The type of the callback must be SanitizerCallbackCall.
  SANITIZER_INSTRUCTION_RET = 10
    Function return. The type of the callback must be SanitizerCallbackRet.
  SANITIZER_INSTRUCTION_DEVICE_SIDE_MALLOC = 11
    Device-side malloc. The type of the callback must be SanitizerCallbackDeviceSideMalloc.
  SANITIZER_INSTRUCTION_DEVICE_SIDE_FREE = 12
    Device-side free. The type of the callback must be SanitizerCallbackDeviceSideFree.
  SANITIZER_INSTRUCTION_CUDA_BARRIER = 13
    CUDA Barrier operation. The type of the callback must be SanitizerCallbackCudaBarrier.
  SANITIZER_INSTRUCTION_MEMCPY_ASYNC = 14
    Global to shared memory asynchronous copy. The type of the callback must be SanitizerCallbackMemcpyAsync.
  SANITIZER_INSTRUCTION_PIPELINE_COMMIT = 15
    Pipeline commit. The type of the callback must be SanitizerCallbackPipelineCommit.
  SANITIZER_INSTRUCTION_PIPELINE_WAIT = 16
    Pipeline wait. The type of the callback must be SanitizerCallbackPipelineWait.
  SANITIZER_INSTRUCTION_REMOTE_SHARED_MEMORY_ACCESS = 17
    Remote Shared Memory Access. This can be a store or load operation. The type of the callback must be SanitizerCallbackMemoryAccess.
  SANITIZER_INSTRUCTION_DEVICE_ALIGNED_MALLOC = 18
    Device-side aligned malloc. The type of the callback must be SanitizerCallbackDeviceSideMalloc.
  SANITIZER_INSTRUCTION_MATRIX_MEMORY_ACCESS = 19
    Matrix shared memory access. The type of the callback must be SanitizerCallbackMatrixMemoryAccess.
  SANITIZER_INSTRUCTION_CACHE_CONTROL = 20
    Cache control instruction. The type of the callback must be SanitizerCallbackCacheControl.
  SANITIZER_INSTRUCTION_CLUSTER_BARRIER_ARRIVE = 21
    Cluster barrier arrive instruction. The type of the callback must be SanitizerCallbackClusterBarrierArrive.
  SANITIZER_INSTRUCTION_CLUSTER_BARRIER_WAIT = 22
    Cluster barrier wait instruction. The type of the callback must be SanitizerCallbackClusterBarrierWait.
  SANITIZER_INSTRUCTION_WARPGROUP_MMA_ASYNC = 23
    Warpgroup aligned async MMA instruction. The type of the callback must be SanitizerCallbackWarpgroupMMAAsync.
  SANITIZER_INSTRUCTION_WARPGROUP_WAIT_GROUP = 24
    Warpgroup wait MMA group instruction. The type of the callback must be SanitizerCallbackWarpgroupWaitGroup.
  SANITIZER_INSTRUCTION_WARPGROUP_FENCE = 25
    Warpgroup fence instruction. The type of the callback must be SanitizerCallbackWarpgroupFence.
  SANITIZER_INSTRUCTION_ASYNC_STORE = 26
    Asynchronous store instruction. The type of the callback must be SanitizerCallbackAsyncStore.
  SANITIZER_INSTRUCTION_ASYNC_REDUCTION = 27
    Asynchronous reduction instruction. The type of the callback must be SanitizerCallbackAsyncReduction.
  SANITIZER_INSTRUCTION_SET_SHARED_MEMORY_SIZE = 28
    Set the shared memory size allocated to a block instruction. The type of the callback must be SanitizerCallbackSetSmemSize.
  SANITIZER_INSTRUCTION_BARRIER_RELEASE = 29
    Barrier after it is released. The type of the callback must be SanitizerCallbackBarrier.
  SANITIZER_INSTRUCTION_BULK_COPY_GLOBAL_TO_SHARED = 30
    Bulk copy instruction from global to shared memory. The type of the callback must be SanitizerCallbackBulkCopyGlobalToShared.
  SANITIZER_INSTRUCTION_FORCE_INT = 0x7fffffff
enum Sanitizer_WarpgroupMMAAsyncFlags

  Flags describing a warpgroup aligned MMA async. These values are to be or-combined in the value of flags for a SanitizerCallbackWarpgroupMMAAsync callback.

  ###### Values

  SANITIZER_WARPGROUP_MMA_ASYNC_FLAG_NONE = 0
    Empty flag.
  SANITIZER_WARPGROUP_MMA_ASYNC_FLAG_COMMIT_GROUP = 0x1
    Specifies that the MMA async delimits a MMA async group of which it is the last instruction. Please refer to the PTX documentation for wgmma_async.commit_group for more details. This property is valid even if the warpMask is zero.
  SANITIZER_WARPGROUP_MMA_ASYNC_FLAG_FORCE_INT = 0x7fffffff

#### Functions

SanitizerResult sanitizerAddPatches ( const void* image, CUcontext ctx )
  Load a module containing patches that can be used by the patching API.

  ###### Parameters

  `image`
    Pointer to module data to load. This API supports the same module formats as the cuModuleLoadData and cuModuleLoadFatBinary functions from the CUDA driver API.
  `ctx`
    CUDA context in which to load the patches. If ctx is NULL, the current context will be used.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `image` does not point to a valid CUDA module.

  ###### Description

  Note:

  - Thread-safety: an API user must serialize access to sanitizerAddPatchesFromFile, sanitizerAddPatches, sanitizerPatchInstructions, and sanitizerPatchModule. For example if sanitizerAddPatches(image) and sanitizerPatchInstruction(*, *, cbName) are called concurrently and cbName is intended to be found in the loaded image, the results are undefined.

  - The patches loaded are only valid for the specified CUDA context.

SanitizerResult sanitizerAddPatchesFromFile ( const char* filename, CUcontext ctx )
  Load a module containing patches that can be used by the patching API.

  ###### Parameters

  `filename`
    Path to the module file. This API supports the same module formats as the cuModuleLoad function from the CUDA driver API.
  `ctx`
    CUDA context in which to load the patches. If ctx is NULL, the current context will be used.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `filename` is not a path to a valid CUDA module.

  ###### Description

  Note:

  - Thread-safety: an API user must serialize access to sanitizerAddPatchesFromFile, sanitizerAddPatches, sanitizerPatchInstructions, and sanitizerPatchModule. For example if sanitizerAddPatchesFromFile(filename) and sanitizerPatchInstruction(*, *, cbName) are called concurrently and cbName is intended to be found in the loaded module, the results are undefined.

  - The patches loaded are only valid for the specified CUDA context.

SanitizerResult sanitizerGetCallbackPcAndSize ( CUcontext ctx, const char* deviceCallbackName, uint64_t* pc, uint64_t* size )
  Get PC and size of a device callback.

  ###### Parameters

  `ctx`
    CUDA context in which the patches were loaded. If ctx is NULL, the current context will be used.
  `deviceCallbackName`
    device function callback name
  `pc`
    Callback PC returned
  `size`
    Callback size returned

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `deviceCallbackName` function cannot be located, if pc is NULL or if size is NULL.

  ###### Description

SanitizerResult sanitizerGetFunctionLoadedStatus ( CUfunction func, Sanitizer_FunctionLoadedStatus* loadingStatus )
  Get the loading status of a function. Requires a driver version >=515.

  ###### Parameters

  `func`
    CUDA function for which the loading status is queried.
  `loadingStatus`
    Loading status returned

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `func` is NULL or if loadingStatus is NULL.

  - SANITIZER_ERROR_NOT_SUPPORTED

    if the loading status cannot be queried with this driver version.

  ###### Description

SanitizerResult sanitizerGetFunctionPcAndSize ( CUmodule module, const char* functionName, uint64_t* pc, uint64_t* size )
  Get PC and size of a CUDA function.

  ###### Parameters

  `module`
    CUDA module containing the function
  `functionName`
  `pc`
    Function start program counter (PC) returned
  `size`
    Function size in bytes returned

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `functionName` function cannot be located, if pc is NULL or if size is NULL.

  ###### Description

SanitizerResult sanitizerPatchInstructions ( const Sanitizer_InstructionId instructionId, CUmodule module, const char* deviceCallbackName )
  Set instrumentation points and patches to be applied in a module.

  ###### Parameters

  `instructionId`
    Instrumentation point for which to insert patches
  `module`
    CUDA module to instrument
  `deviceCallbackName`
    Name of the device function callback that the inserted patch will call at the instrumented points. This function is expected to be found in code previously loaded by sanitizerAddPatchesFromFile or sanitizerAddPatches.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_NOT_INITIALIZED

    if unable to initialize the sanitizer

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `module` is not a CUDA module or if `deviceCallbackName` function cannot be located.

  ###### Description

  Mark that all instrumentation points matching instructionId are to be patched in order to call the device function identified by deviceCallbackName. It is up to the API client to ensure that this device callback exists and match the correct callback format for this instrumentation point.

  Note:

  Thread-safety: an API user must serialize access to sanitizerAddPatchesFromFile, sanitizerAddPatches, sanitizerPatchInstructions, and sanitizerPatchModule. For example if sanitizerAddPatches(fileName) and sanitizerPatchInstruction(*, *, cbName) are called concurrently and cbName is intended to be found in the loaded module, the results are undefined.

SanitizerResult sanitizerPatchModule ( CUmodule module )
  Perform the actual instrumentation of a module.

  ###### Parameters

  `module`
    CUDA module to instrument

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `module` is not a CUDA module

  ###### Description

  Perform the instrumentation of a CUDA module based on previous calls to sanitizerPatchInstructions. This function also specifies the device memory buffer to be passed in as userdata to all callback functions.

  Note:

  Thread-safety: an API user must serialize access to sanitizerAddPatchesFromFile, sanitizerAddPatches, sanitizerPatchInstructions, and sanitizerPatchModule. For example if sanitizerPatchModule(mod, *) and sanitizerPatchInstruction(*, mod, *) are called concurrently, the results are undefined.

SanitizerResult sanitizerSetCallbackData ( CUfunction kernel, const void* userdata )
  Specifies the user data pointer for callbacks.

  ###### Parameters

  `kernel`
    CUDA function to link to user data. Callbacks in subsequent launches on this kernel will use `userdata` as callback data.
  `userdata`
    Device memory buffer. This data will be passed to callback functions via the `userdata` parameter.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  ###### Description

  Mark all subsequent launches of `kernel` to use `userdata` pointer as the device memory buffer to pass in to callback functions.

SanitizerResult sanitizerSetDeviceGraphData ( CUgraphExec graphExec, Sanitizer_StreamHandle stream, const void* userdata )
  Specifies the user data pointer accessible from callbacks in the device-launched graphs launched by the specified host-launched graphExec.

  ###### Parameters

  `graphExec`
    CUDA graphExec that will launch CUDA graphs from the device.
  `stream`
    CUDA stream associated with the stream launch.
  `userdata`
    Device memory buffer.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  ###### Description

  Mark all subsequent launch of `graphExec` to make available `userdata` in device callbacks from device-launched graphs. `userdata` will not be set in the callback userdata parameter but must be accessed through another mean instead. Please refer to the Sanitizer API reference manual. This function is only available if the driver version is 535 or newer.

SanitizerResult sanitizerSetLaunchCallbackData ( Sanitizer_LaunchHandle launch, CUfunction kernel, Sanitizer_StreamHandle stream, const void* userdata )
  Specifies the user data pointer for callbacks.

  ###### Parameters

  `launch`
    Kernel launch to link to user data. Callbacks in this kernel launch will use `userdata` as callback data.
  `kernel`
    CUDA function associated with the kernel launch.
  `stream`
    CUDA stream associated with the stream launch.
  `userdata`
    Device memory buffer. This data will be passed to callback functions via the `userdata` parameter.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  ###### Description

  Mark `launch` to use `userdata` pointer as the device memory buffer to pass in to callback functions. This function is only available if the driver version is 455 or newer.

SanitizerResult sanitizerUnpatchModule ( CUmodule module )
  Remove existing instrumentation of a module.

  ###### Parameters

  `module`
    CUDA module on which to remove instrumentation

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  ###### Description

  Remove any instrumentation of a CUDA module performed by previous calls to sanitizerPatchModule.

  Note:

  Thread-safety: an API user must serialize access to sanitizerPatchModule and sanitizerUnpatchModule on the same module. For example, if sanitizerPatchModule(mod) and sanitizerUnpatchModule(mod) are called concurrently, the results are undefined.

### 1.5. Sanitizer Result Codes

Error and result codes returned by Sanitizer functions.

#### Enumerations

enum SanitizerResult
  Sanitizer result codes.

#### Functions

SanitizerResult sanitizerGetResultString ( SanitizerResult result, const char** str )

#### Enumerations

enum SanitizerResult

  Error and result codes returned by Sanitizer functions.

  ###### Values

  SANITIZER_SUCCESS = 0
    No error.
  SANITIZER_ERROR_INVALID_PARAMETER = 1
    One or more of the parameters is invalid.
  SANITIZER_ERROR_INVALID_DEVICE = 2
    The device does not correspond to a valid CUDA device.
  SANITIZER_ERROR_INVALID_CONTEXT = 3
    The context is NULL or not valid.
  SANITIZER_ERROR_INVALID_DOMAIN_ID = 4
    The domain ID is invalid.
  SANITIZER_ERROR_INVALID_CALLBACK_ID = 5
    The callback ID is invalid.
  SANITIZER_ERROR_INVALID_OPERATION = 6
    The current operation cannot be performed due to dependency on other factors.
  SANITIZER_ERROR_OUT_OF_MEMORY = 7
    Unable to allocate enough memory to perform the requested operation.
  SANITIZER_ERROR_PARAMETER_SIZE_NOT_SUFFICIENT = 8
    The output buffer size is not sufficient to return all requested data.
  SANITIZER_ERROR_API_NOT_IMPLEMENTED = 9
    API is not implemented.
  SANITIZER_ERROR_MAX_LIMIT_REACHED = 10
    The maximum limit is reached.
  SANITIZER_ERROR_NOT_READY = 11
    The object is not ready to perform the requested operation.
  SANITIZER_ERROR_NOT_COMPATIBLE = 12
    The current operation is not compatible with the current state of the object.
  SANITIZER_ERROR_NOT_INITIALIZED = 13
    Sanitizer is unable to initialize its connection to the CUDA driver.
  SANITIZER_ERROR_NOT_SUPPORTED = 14
    The attempted operation is not supported on the current system or device
  SANITIZER_ERROR_ADDRESS_NOT_IN_DEVICE_MEMORY = 15
    The attempted device operation has a parameter not in device memory
  SANITIZER_ERROR_UNKNOWN = 999
    An unknown internal error has occurred.
  SANITIZER_ERROR_FORCE_INT = 0x7fffffff

#### Functions

SanitizerResult sanitizerGetResultString ( SanitizerResult result, const char** str )

  ###### Parameters

  `result`
    The result to get the string for
  `str`
    Returns the string

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `str` is NULL or `result` is not a valid SanitizerResult.

  ###### Description

  Get the descriptive string for a SanitizerResult.

  Return the descriptive string for a SanitizerResult in `*str`.

  Note:

  Thread-safety: this function is thread-safe.

### 1.6. Sanitizer Stream API

Functions, types, and enums that implement the Sanitizer Stream API.

#### Functions

SanitizerResult sanitizerGetStream ( Sanitizer_StreamHandle hStream, CUstream* stream )
  Retrieve a CUstream handle from a Sanitizer_StreamHandle handle.
SanitizerResult sanitizerGetStreamHandle ( CUcontext ctx, CUstream stream, Sanitizer_StreamHandle* hStream )
  Retrieve a Sanitizer_StreamHandle handle from a CUstream handle.
SanitizerResult sanitizerStreamSynchronize ( Sanitizer_StreamHandle stream )
  Synchronize a given stream.

#### Functions

SanitizerResult sanitizerGetStream ( Sanitizer_StreamHandle hStream, CUstream* stream )
  Retrieve a CUstream handle from a Sanitizer_StreamHandle handle.

  ###### Parameters

  `hStream`
    Sanitizer Stream handle.
  `stream`
    Output CUstream handle.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `hStream` is not a valid Sanitizer stream handle or if `stream` is NULL.

  ###### Description

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerGetStreamHandle ( CUcontext ctx, CUstream stream, Sanitizer_StreamHandle* hStream )
  Retrieve a Sanitizer_StreamHandle handle from a CUstream handle.

  ###### Parameters

  `ctx`
    Context owning the stream. If NULL, the current context will be used.
  `stream`
    CUstream handle. If NULL, the NULL stream will be used.
  `hStream`
    Output Sanitizer Stream handle.

  ###### Returns

  - SANITIZER_SUCCESS

    on success

  - SANITIZER_ERROR_INVALID_PARAMETER

    if `stream` is not a valid CUstream handle or if `hStream` is NULL.

  ###### Description

  Note:

  Thread-safety: this function is thread safe.

SanitizerResult sanitizerStreamSynchronize ( Sanitizer_StreamHandle stream )
  Synchronize a given stream.

  ###### Parameters

  `stream`
    Stream handle. If NULL, the NULL stream will be used.

  ###### Description

  Equivalent of cudaStreamSynchronize that can be called with a sanitizer stream handle

  Note:

  Thread-safety: this function is thread safe.