1. Modules

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 
Data passed into a batch memop callback function.
struct 
Data passed into a runtime or driver API callback function.
struct 
Data passed into a graphexec creation callback function.
struct 
Data passed into a graph node launch callback function.
struct 
Data passed into a launch callback function.
struct 
Data passed into a memcpy callback function.
struct 
Data passed into a memset callback function.
struct 
Data passed into a CUDA array callback function.
struct 
Data passed into a context resource callback function.
struct 
Data passed into a memory resource callback function.
struct 
Data passed into a mempool resource callback function.
struct 
Data passed into a module resource callback function.
struct 
Data passed into a stream resource callback function.
struct 
Data passed into a synchronization callback function.
struct 
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_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.

Variables

uint64_t  Sanitizer_BatchMemopData::address
Sanitizer_StreamHandle  Sanitizer_BatchMemopData::hStream
CUstream  Sanitizer_BatchMemopData::stream
Sanitizer_BatchMemopType Sanitizer_BatchMemopData::type
uint64_t  Sanitizer_BatchMemopData::value
CUcontext  Sanitizer_CallbackData::context
const char * Sanitizer_CallbackData::functionName
const void * Sanitizer_CallbackData::functionParams
const void * Sanitizer_CallbackData::functionReturnValue
const char * Sanitizer_CallbackData::symbolName
CUgraphExec  Sanitizer_GraphExecData::graphExec
uint32_t  Sanitizer_GraphNodeLaunchData::launchId
struct Sanitizer_ResourceMemoryData Sanitizer_GraphNodeLaunchData::memAllocData
uint64_t  Sanitizer_GraphNodeLaunchData::memFreeAddress
CUgraphNode  Sanitizer_GraphNodeLaunchData::node
CUgraphNodeType  Sanitizer_GraphNodeLaunchData::nodeType
CUdevice  Sanitizer_LaunchData::device
CUfunction  Sanitizer_LaunchData::function
const char * Sanitizer_LaunchData::functionName
uint64_t  Sanitizer_LaunchData::gridId
Sanitizer_LaunchHandle  Sanitizer_LaunchData::hLaunch
Sanitizer_StreamHandle  Sanitizer_LaunchData::hStream
CUmodule  Sanitizer_LaunchData::module
CUstream  Sanitizer_LaunchData::stream
Sanitizer_MemcpyDirection Sanitizer_MemcpyData::direction
uint64_t  Sanitizer_MemcpyData::dstAddress
CUcontext  Sanitizer_MemcpyData::dstContext
uint64_t  Sanitizer_MemcpyData::dstPitch
CUstream  Sanitizer_MemcpyData::dstStream
Sanitizer_StreamHandle  Sanitizer_MemcpyData::hDstStream
Sanitizer_StreamHandle  Sanitizer_MemcpyData::hSrcStream
uint32_t  Sanitizer_MemcpyData::isAsync
uint64_t  Sanitizer_MemcpyData::size
uint64_t  Sanitizer_MemcpyData::srcAddress
uint64_t  Sanitizer_MemcpyData::srcPitch
CUstream  Sanitizer_MemcpyData::srcStream
uint64_t  Sanitizer_MemcpyData::width
uint64_t  Sanitizer_MemsetData::address
Sanitizer_StreamHandle  Sanitizer_MemsetData::hStream
uint32_t  Sanitizer_MemsetData::isAsync
CUstream  Sanitizer_MemsetData::stream
uint32_t  Sanitizer_MemsetData::value
uint64_t  Sanitizer_MemsetData::width
CUarray  Sanitizer_ResourceArrayData::hArray
uint64_t  Sanitizer_ResourceArrayData::width
CUdevice  Sanitizer_ResourceContextData::device
CUcontext  Sanitizer_ResourceMemoryData::context
CUdevice  Sanitizer_ResourceMemoryData::device
uint32_t  Sanitizer_ResourceMemoryData::flags
Sanitizer_StreamHandle  Sanitizer_ResourceMemoryData::hStream
CUmemoryPool  Sanitizer_ResourceMemoryData::memoryPool
uint32_t  Sanitizer_ResourceMemoryData::permissions
uint64_t  Sanitizer_ResourceMemoryData::size
CUdevice  Sanitizer_ResourceMemoryData::sourceDevice
CUstream  Sanitizer_ResourceMemoryData::stream
Sanitizer_MemoryVisibility Sanitizer_ResourceMemoryData::visibility
CUdevice  Sanitizer_ResourceMempoolData::device
CUdevice  Sanitizer_ResourceMempoolData::peerDevice
size_t  Sanitizer_ResourceModuleData::cubinSize
CUmodule  Sanitizer_ResourceModuleData::module
const char * Sanitizer_ResourceModuleData::pCubin
Sanitizer_StreamHandle  Sanitizer_ResourceStreamData::hStream
CUstream  Sanitizer_ResourceStreamData::stream
Sanitizer_StreamHandle  Sanitizer_SynchronizeData::hStream
CUstream  Sanitizer_SynchronizeData::stream
uint64_t  Sanitizer_UvmData::address
Sanitizer_StreamHandle  Sanitizer_UvmData::hStream
CUstream  Sanitizer_UvmData::stream
Sanitizer_MemoryVisibility Sanitizer_UvmData::visibility
struct Sanitizer_ResourceMemoryData memAllocData
uint64_t  memFreeAddress

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_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_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_CREATED = 1
A new graphexec was created.
SANITIZER_CBID_GRAPHS_NODE_LAUNCH_BEGIN = 2
A node launch was initiated.
SANITIZER_CBID_GRAPHS_NODE_LAUNCH_END = 3
A node 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_MODULE_LOADED = 8
A module was loaded.
SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING = 9
A module is about to be unloaded.
SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC = 10
Device memory was allocated.
SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE = 11
Device memory was freed.
SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC = 12
Pinned host memory was allocated.
SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE = 13
Pinned host memory was freed.
SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC = 14
Memory was allocated asynchronously.
SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC = 15
Memory was freed asynchronously.
SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE = 16
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 = 17
A new mempool was created.
SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING = 18
A mempool is about to be destroyed.
SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED = 19
A mempool is now accessible from a peer device.
SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING = 20
A mempool is no longer accessible from a peer device.
SANITIZER_CBID_RESOURCE_ARRAY_CREATED = 21
A CUDA array was created.
SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED = 22
A CUDA array was destroyed.
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_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.

Variables

uint64_t Sanitizer_BatchMemopData::address

The address to be written.

Sanitizer_StreamHandle Sanitizer_BatchMemopData::hStream

Unique handle for the stream.

CUstream Sanitizer_BatchMemopData::stream

The stream where the batch memop is executed.

Sanitizer_BatchMemopType Sanitizer_BatchMemopData::type

Type of batch memory operation.

uint64_t Sanitizer_BatchMemopData::value

The value to be written.

CUcontext Sanitizer_CallbackData::context

Driver context current to the thread, or null if no context is current. This value can change from the entry to exit callback of a runtime API function if the runtime initialized a context.

const char * Sanitizer_CallbackData::functionName

Name of the runtime or driver API function which issued the callback. This string is a global constant and so may be accessed outside of the callback.

const void * Sanitizer_CallbackData::functionParams

Pointer to the arguments passed to the runtime or driver API call. See generated_cuda_runtime_api_meta.h and generated_cuda_meta.h for structure definitions for the parameters for each runtime and driver API function.

const void * Sanitizer_CallbackData::functionReturnValue

Pointer to the return value of the runtime or driver API call. This field is only valid within the SANITIZER_API_EXIT callback. For a runtime API functionReturnValue points to a cudaError_t. For a driver API functionReturnValue points to a CUresult.

const char * Sanitizer_CallbackData::symbolName

Name of the symbol operated on by the runtime or driver API function which issued the callback. This entry is valid only for driver and runtime launch callbacks, where it returns the name of the kernel.

CUgraphExec Sanitizer_GraphExecData::graphExec

Instance of the CUDA graph.

uint32_t Sanitizer_GraphNodeLaunchData::launchId

Launch ID for this CUDA graph instance

struct Sanitizer_ResourceMemoryData Sanitizer_GraphNodeLaunchData::memAllocData

This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_ALLOC.

uint64_t Sanitizer_GraphNodeLaunchData::memFreeAddress

The freed device pointer This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_FREE.

CUgraphNode Sanitizer_GraphNodeLaunchData::node

CUDA graphs node being launched.

CUgraphNodeType Sanitizer_GraphNodeLaunchData::nodeType

CUDA graphs node type.

CUdevice Sanitizer_LaunchData::device

The device where the grid is launched

CUfunction Sanitizer_LaunchData::function

The function of the grid launch.

const char * Sanitizer_LaunchData::functionName

The name of the launched function.

uint64_t Sanitizer_LaunchData::gridId

Unique identifier of the grid launch. For graph node launches, this is only unique within the graphexec launch.

Sanitizer_LaunchHandle Sanitizer_LaunchData::hLaunch

Handle of the grid launch. This is only valid between the launch begin and end callbacks.

Sanitizer_StreamHandle Sanitizer_LaunchData::hStream

Unique handle for the stream.

CUmodule Sanitizer_LaunchData::module

The module containing the grid code.

CUstream Sanitizer_LaunchData::stream

The stream where the grid is launched.

Sanitizer_MemcpyDirection Sanitizer_MemcpyData::direction

The direction of the transfer

uint64_t Sanitizer_MemcpyData::dstAddress

The destination allocation address.

CUcontext Sanitizer_MemcpyData::dstContext

The context where the destination allocation is located

uint64_t Sanitizer_MemcpyData::dstPitch

The destination allocation pitch.

CUstream Sanitizer_MemcpyData::dstStream

The stream where the memcpy is executed on the destination context

Sanitizer_StreamHandle Sanitizer_MemcpyData::hDstStream

Unique handle for the destination context stream.

Sanitizer_StreamHandle Sanitizer_MemcpyData::hSrcStream

Unique handle for the source context stream.

uint32_t Sanitizer_MemcpyData::isAsync

Boolean value indicating if the transfer is asynchronous.

uint64_t Sanitizer_MemcpyData::size

Size of the transfer in bytes.

uint64_t Sanitizer_MemcpyData::srcAddress

The source allocation address.

uint64_t Sanitizer_MemcpyData::srcPitch

The source allocation pitch.

CUstream Sanitizer_MemcpyData::srcStream

The stream where the memcpy is executed on the source context

uint64_t Sanitizer_MemcpyData::width

Memcpy size configuration.

uint64_t Sanitizer_MemsetData::address

The address of the memset start.

Sanitizer_StreamHandle Sanitizer_MemsetData::hStream

Unique handle for the stream.

uint32_t Sanitizer_MemsetData::isAsync

Boolean value indicating if the transfer is asynchronous.

CUstream Sanitizer_MemsetData::stream

The stream where the memset is executed.

uint32_t Sanitizer_MemsetData::value

Value to be written.

uint64_t Sanitizer_MemsetData::width

Memset size configuration.

CUarray Sanitizer_ResourceArrayData::hArray

The CUDA array being created or destroyed.

uint64_t Sanitizer_ResourceArrayData::width

The CUDA array size.

CUdevice Sanitizer_ResourceContextData::device

The device on which the context is being created or destroyed. This field is only valid for SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_* callbacks

CUcontext Sanitizer_ResourceMemoryData::context

Context containing the allocation being created or destroyed. Can be NULL if the allocation is not attached to a context.

CUdevice Sanitizer_ResourceMemoryData::device

Device where the allocation is being created. Available for all cbid with a driver version of 455 or newer.

uint32_t Sanitizer_ResourceMemoryData::flags

Allocation details: use Sanitizer_ResourceMemoryFlags to interpret this field.

Sanitizer_StreamHandle Sanitizer_ResourceMemoryData::hStream

Stream containing the allocation being created or destroyed. Can be NULL if the allocation is not attached to a stream.

CUmemoryPool Sanitizer_ResourceMemoryData::memoryPool

Memory pool containing the allocation being created or destroyed. Can be NULL if the allocation is not attached to a memory pool.

uint32_t Sanitizer_ResourceMemoryData::permissions

Allocation permissions: use Sanitizer_ResourceMemoryPermissions to interpret this field.

uint64_t Sanitizer_ResourceMemoryData::size

Size of the allocation being created or destroyed.

CUdevice Sanitizer_ResourceMemoryData::sourceDevice

Source device of this allocation (different from device if SANITIZER_MEMORY_FLAG_PEER is set).

CUstream Sanitizer_ResourceMemoryData::stream

Public handle for the stream.

Sanitizer_MemoryVisibility Sanitizer_ResourceMemoryData::visibility

Visibility of the allocation.

CUdevice Sanitizer_ResourceMempoolData::device

Device that owns the memory pool.

CUdevice Sanitizer_ResourceMempoolData::peerDevice

Device that access type changed. Avaialble if cbid is SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED or SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING.

size_t Sanitizer_ResourceModuleData::cubinSize

The size of the cubin.

CUmodule Sanitizer_ResourceModuleData::module

The module being loaded or unloaded.

const char * Sanitizer_ResourceModuleData::pCubin

Pointer to the associated cubin.

Sanitizer_StreamHandle Sanitizer_ResourceStreamData::hStream

Unique handle for the stream.

CUstream Sanitizer_ResourceStreamData::stream

The stream being created or destroyed.

Sanitizer_StreamHandle Sanitizer_SynchronizeData::hStream

Unique handle for the stream.

CUstream Sanitizer_SynchronizeData::stream

This field is only valid for SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED. This is the stream being synchronized.

uint64_t Sanitizer_UvmData::address

The address of the allocation.

Sanitizer_StreamHandle Sanitizer_UvmData::hStream

Unique handle for the stream.

CUstream Sanitizer_UvmData::stream

The stream on which the memory is attached. This is only valid if visibility is SANITIZER_MEMORY_VISIBILITY_STREAM

Sanitizer_MemoryVisibility Sanitizer_UvmData::visibility

New visibility for the allocation.

uint32_t SANITIZER_CALLBACK_API::blockDim_x [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

uint32_t SANITIZER_CALLBACK_API::blockDim_y [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

uint32_t SANITIZER_CALLBACK_API::blockDim_z [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

uint32_t SANITIZER_CALLBACK_API::gridDim_x [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

uint32_t SANITIZER_CALLBACK_API::gridDim_y [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

uint32_t SANITIZER_CALLBACK_API::gridDim_z [inherited]

Launch properties of the grid. These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph node launch callbacks

struct Sanitizer_ResourceMemoryData memAllocData

This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_ALLOC.

uint64_t memFreeAddress

The freed device pointer This is only valid if nodeType is CU_GRAPH_NODE_TYPE_MEM_FREE.

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 sanitizerFree ( CUcontext ctx, void* devPtr )
Frees memory on the device.
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 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 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. If the function is called from a SANITIZER_CB_DOMAIN_LAUNCH callback, only pinned host memory may be used as destination.

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*  ( *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*  ( *SanitizerCallbackCall )( void*  userdata,  uint64_t pc,  uint64_t targetPc,  uint32_t flags )
Function type for a function call callback.
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*  ( *SanitizerCallbackMemoryAccess )( void*  userdata,  uint64_t pc, void*  ptr,  uint32_t accessSize,  uint32_t flags, const void*  newValue )
Function type for a memory access callback.
typedef SanitizerPatchResult*  ( *SanitizerCallbackRet )( void*  userdata,  uint64_t pc )
Function type for a function return callback.
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.

Enumerations

enum SanitizerPatchResult
Sanitizer patch result codes.
enum Sanitizer_BarrierFlags
Flags describing a barrier.
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.

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 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 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* ( *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 sanitizerPatchModulepc 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 sanitizerPatchModulepc 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 sanitizerPatchModulepc is the program counter of the patched instruction

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 sanitizerPatchModulepc 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* ( *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 sanitizerPatchModulepc 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_CudaBarrierInstructionKinddata 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 sanitizerPatchModulepc 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 sanitizerPatchModulepc 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* ( *SanitizerCallbackMemoryAccess )( void*  userdata,  uint64_t pc, void*  ptr,  uint32_t accessSize,  uint32_t flags, const void*  newValue )

Function type for a memory access callback. userdata is a pointer to user data. See sanitizerPatchModulepc 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. newValue is a pointer to the new value being written if the acces is a write. If the access is a read or an atomic, the pointer will be NULL.

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

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

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

Function type for a shfl callback. userdata is a pointer to user data. See sanitizerPatchModulepc 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 sanitizerPatchModulepc is the program counter of the patched instruction mask is the thread mask passed to __syncwarp().

Enumerations

enum SanitizerPatchResult

Error and result codes returned by Sanitizer patches. If a patch returns SANITIZER_PATCH_ERROR, the thread 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_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.
SANITIZER_CUDA_BARRIER_ARRIVE_NOCOMPLETE = 3
Barrier arrive operation without phase completion. Barrier data is the count argument to the arrive-on operation.
SANITIZER_CUDA_BARRIER_WAIT = 4
Barrier wait operation.
SANITIZER_CUDA_BARRIER_INVALIDATE = 5
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_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_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 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 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_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.