CUDASafety-1.1¶
Do not use CUDA callbacks
Required inputs: IR
CUDA SAFETY 1.1 [safety.cuda.callback] Do not use CUDA callbacks
CUDA callbacks are not a part of the safety subset.
Scope: Host.
Audience: CUDA C++, CUDA Libraries.
Category: Mandatory.
Hardware Applicability: All Compute Capabilities.
Rationale
CUDA callbacks are not supported in the safety subset.
Example 1 (Bad)
# include <cassert> __host__ void callback(void*) { assert(0); } int main() { // Adding a callback is not supported in the CUDA safety subset. cudaError_t const error0 = cudaLaunchHostFunc(nullptr, &callback, nullptr); assert(cudaSuccess == error0); cudaError_t const error1 = cudaDeviceSynchronize(); assert(cudaSuccess == error1); }Excerpt from NVIDIA CUDA C++ Guidelines for robust and safety-critical programming, Version 3.0.1, Copyright (C) 2018-2023 NVIDIA Corporation.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
cuda_callback |
Do not use CUDA callbacks |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
cuda_callback_registrations¶
cuda_callback_registrations
CUDA API functions taking callbacks as function pointer arguments. Maps the (qualified) function name to the index of the parameter used to pass in a function pointer or a (struct) object containing a function pointer (in a field).Type: dict[bauhaus.analysis.config.QualifiedName, int]
Default:
{ 'cuGraphAddHostNode': 4, 'cuLaunchHostFunc': 1, 'cuStreamAddCallback': 1, 'cudaGraphAddHostNode': 4, 'cudaLaunchHostFunc': 1, 'cudaStreamAddCallback': 1 }