Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
sanitizer_callbacks.h2005 linesDownload Raw Back to include
1/*
2 * Copyright 2018-2023 NVIDIA Corporation.  All rights reserved.
3 *
4 * NOTICE TO LICENSEE:
5 *
6 * This source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
9 *
10 * These Licensed Deliverables contained herein is PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee.  Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
18 *
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
33 *
34 * U.S. Government End Users.  These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39 * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
43 *
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
47 * Users Notice.
48 */
49
50
51#if !defined(__SANITIZER_CALLBACKS_H__)
52#define __SANITIZER_CALLBACKS_H__
53
54#include <sanitizer_patching.h>
55#include <sanitizer_result.h>
56#include <sanitizer_stream.h>
57
58#include <cuda.h>
59
60#include <stdint.h>
61
62#ifndef SANITIZERAPI
63#ifdef _WIN32
64#define SANITIZERAPI __stdcall
65#else
66#define SANITIZERAPI
67#endif
68#endif
69
70#if defined(__cplusplus)
71extern "C" {
72#endif
73
74/**
75 * \defgroup SANITIZER_CALLBACK_API Sanitizer Callback API
76 * Functions, types, and enums that implement the Sanitizer Callback API.
77 * @{
78 */
79
80/**
81 * \addtogroup SANITIZER_CALLBACK_API
82 * @{
83 */
84
85/**
86 * \brief Callback domains.
87 *
88 * Callback domain. Each domain represents callback points for a group of
89 * related API functions or CUDA driver activity.
90 */
91typedef enum {
92    /**
93     * Invalid domain.
94     */
95    SANITIZER_CB_DOMAIN_INVALID          = 0,
96
97    /**
98     * Domain containing callback points for all driver API functions.
99     */
100    SANITIZER_CB_DOMAIN_DRIVER_API       = 1,
101
102    /**
103     * Domain containing callback points for all runtime API functions.
104     */
105    SANITIZER_CB_DOMAIN_RUNTIME_API      = 2,
106
107    /**
108     * Domain containing callback points for CUDA resource tracking.
109     */
110    SANITIZER_CB_DOMAIN_RESOURCE         = 3,
111
112    /**
113     * Domain containing callback points for CUDA synchronization.
114     */
115    SANITIZER_CB_DOMAIN_SYNCHRONIZE      = 4,
116
117    /**
118     * Domain containing callback points for CUDA grid launches.
119     */
120    SANITIZER_CB_DOMAIN_LAUNCH           = 5,
121
122    /**
123     * Domain containing callback points for CUDA memcpy operations.
124     */
125    SANITIZER_CB_DOMAIN_MEMCPY           = 6,
126
127    /**
128     * Domain containing callback points for CUDA memset operations.
129     */
130    SANITIZER_CB_DOMAIN_MEMSET           = 7,
131
132    /**
133     * Domain containing callback points for CUDA batch memop operations.
134     */
135    SANITIZER_CB_DOMAIN_BATCH_MEMOP      = 8,
136
137    /**
138     * Domain containing callback points for CUDA managed memory operations.
139     */
140    SANITIZER_CB_DOMAIN_UVM              = 9,
141
142    /**
143     * Domain containing callback points for CUDA graphs operations.
144     */
145    SANITIZER_CB_DOMAIN_GRAPHS           = 10,
146
147    /**
148     * Domain containing callback points for CUDA events.
149     */
150    SANITIZER_CB_DOMAIN_EVENTS           = 11,
151
152    /**
153     * Domain containing callback points for CUDA external memory.
154     */
155    SANITIZER_CB_DOMAIN_EXTERNAL_MEMORY  = 12,
156
157    SANITIZER_CB_DOMAIN_SIZE,
158    SANITIZER_CB_DOMAIN_FORCE_INT        = 0x7fffffff
159} Sanitizer_CallbackDomain;
160
161/**
162 * \brief Specifies the point in an API call that a callback is issued.
163 *
164 * Specifies the point in an API that a callback is issued. This value is
165 * communicated to the callback function via \ref
166 * Sanitizer_CallbackData::CallbackSize.
167 */
168typedef enum {
169    /**
170     * This callback is at API entry.
171     */
172    SANITIZER_API_ENTER            = 0,
173
174    /**
175     * This callback is at API exit.
176     */
177    SANITIZER_API_EXIT             = 1,
178
179    SANITIZER_API_CBSITE_FORCE_INT = 0x7fffffff
180} Sanitizer_ApiCallbackSite;
181
182/**
183 * \brief Data passed into a runtime or driver API callback function.
184 *
185 * Data passed into a runtime or driver API callback function as the
186 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The \p cbdata will
187 * be this type for \p domain equal to SANITIZER_CB_DOMAIN_DRIVER_API or
188 * SANITIZER_CB_DOMAIN_RUNTIME_API. The callback data is valid only within
189 * the invocation of the callback function that is passed the data. If
190 * you need to retain some data for use outside of the callback, you
191 * must make of a copy of that data. For example, if you make a shallow
192 * copy of Sanitizer_CallbackData within a callback, you cannot
193 * dereference \p functionParams outside of that callback to access
194 * the function parameters. \p functionName is an exception: the
195 * string pointed to by \p functionName is a global constant and so
196 * may be accessed outside of the callback.
197 */
198typedef struct {
199    /**
200     * Point in the runtime or driver function from where the callback
201     * was issued.
202     */
203    Sanitizer_ApiCallbackSite callbackSite;
204
205    /**
206     * Name of the runtime or driver API function which issued the
207     * callback. This string is a global constant and so may be
208     * accessed outside of the callback.
209     */
210    const char* functionName;
211
212    /**
213     * Pointer to the arguments passed to the runtime or driver API
214     * call. See generated_cuda_runtime_api_meta.h and
215     * generated_cuda_meta.h for structure definitions for the
216     * parameters for each runtime and driver API function.
217     */
218    const void* functionParams;
219
220    /**
221     * Pointer to the return value of the runtime or driver API
222     * call. This field is only valid within the SANITIZER_API_EXIT
223     * callback. For a runtime API \p functionReturnValue points to a
224     * \p cudaError_t. For a driver API \p functionReturnValue points
225     * to a \p CUresult.
226     */
227    const void* functionReturnValue;
228
229    /**
230     * Name of the symbol operated on by the runtime or driver API
231     * function which issued the callback. This entry is valid only for
232     * driver and runtime launch callbacks, where it returns the name of
233     * the kernel.
234     */
235    const char* symbolName;
236
237    /**
238     * Driver context current to the thread, or null if no context is
239     * current. This value can change from the entry to exit callback
240     * of a runtime API function if the runtime initialized a context.
241     */
242    CUcontext context;
243} Sanitizer_CallbackData;
244
245/**
246 * \brief Callback IDs for resource domain.
247 *
248 * Callback IDs for resource domain SANITIZER_CB_DOMAIN_RESOURCE. This
249 * value is communicated to the callback function via the \p cbid
250 * parameter.
251 */
252typedef enum {
253    /**
254     * Invalid resource callback ID.
255     */
256    SANITIZER_CBID_RESOURCE_INVALID                       = 0,
257
258    /**
259     * Driver initialization is finished.
260     */
261    SANITIZER_CBID_RESOURCE_INIT_FINISHED                 = 1,
262
263    /**
264     * A new context is about to be created.
265     */
266    SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_STARTING     = 2,
267
268    /**
269     * A new context was created.
270     */
271    SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_FINISHED     = 3,
272
273    /**
274     * A context is about to be destroyed.
275     */
276    SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_STARTING      = 4,
277
278    /**
279     * A context was destroyed.
280     */
281    SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_FINISHED      = 5,
282
283    /**
284     * A new stream was created.
285     */
286    SANITIZER_CBID_RESOURCE_STREAM_CREATED                = 6,
287
288    /**
289     * A stream is about to be destroyed.
290     */
291    SANITIZER_CBID_RESOURCE_STREAM_DESTROY_STARTING       = 7,
292
293    /**
294     * A stream was destroyed.
295     */
296    SANITIZER_CBID_RESOURCE_STREAM_DESTROY_FINISHED       = 8,
297
298    /**
299     * A module was loaded.
300     */
301    SANITIZER_CBID_RESOURCE_MODULE_LOADED                 = 9,
302
303    /**
304     * A module is about to be unloaded.
305     */
306    SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING        = 10,
307
308    /**
309     * Device memory was allocated.
310     */
311    SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC           = 11,
312
313    /**
314     * Device memory was freed.
315     */
316    SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE            = 12,
317
318    /**
319     * Pinned host memory was allocated.
320     */
321    SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC             = 13,
322
323    /**
324     * Pinned host memory was freed.
325     */
326    SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE              = 14,
327
328    /**
329     * Memory was allocated asynchronously.
330     */
331    SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC            = 15,
332
333    /**
334     * Memory was freed asynchronously.
335     */
336    SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC             = 16,
337
338    /**
339     * Memory freed asynchronously was released, only happens if a regular
340     * allocation (cudaMalloc) is free'd asynchronously (cudaFreeAsync).
341     *
342     * See CUDA runtime documentation for cudaFreeAsync
343     */
344    SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE        = 17,
345
346    /**
347     * A new mempool was created.
348     */
349    SANITIZER_CBID_RESOURCE_MEMPOOL_CREATED               = 18,
350
351    /**
352     * A mempool is about to be destroyed.
353     */
354    SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING            = 19,
355
356    /**
357     * A mempool is now accessible from a peer device.
358     */
359    SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED   = 20,
360
361    /**
362     * A mempool is no longer accessible from a peer device.
363     */
364    SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING = 21,
365
366    /**
367     * A CUDA array was created.
368     */
369    SANITIZER_CBID_RESOURCE_ARRAY_CREATED                 = 22,
370
371    /**
372     * A CUDA array was destroyed.
373     */
374    SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED               = 23,
375
376    /**
377     * CUDA functions were loaded lazily and are fully loaded.
378     */
379    SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_LOADED         = 24,
380
381    /**
382     * CUDA lazily loaded functions were patched.
383     */
384    SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_PATCHED        = 25,
385
386    /**
387     * The CUDA driver reserved a virtual address range.
388     */
389    SANITIZER_CBID_RESOURCE_VIRTUAL_RESERVE               = 26,
390
391    /**
392     * The CUDA driver released a virtual address range.
393     */
394    SANITIZER_CBID_RESOURCE_VIRTUAL_RELEASE               = 27,
395
396    /**
397     * A memory pool allocation was imported.
398     */
399    SANITIZER_CBID_RESOURCE_MEMPOOL_IMPORT_POINTER       = 28,
400
401    SANITIZER_CBID_RESOURCE_SIZE,
402    SANITIZER_CBID_RESOURCE_FORCE_INT                     = 0x7fffffff
403} Sanitizer_CallbackIdResource;
404
405/**
406 * \brief Data passed into a context resource callback function.
407 *
408 * Data passed into a context resource callback function as the
409 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
410 * \p cbdata will be this type for \p domain equal to
411 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
412 * SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_STARTING,
413 * SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_FINISHED,
414 * SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_STARTING or
415 * SANITIZER_CBID_RESOURCE_CONTEXT_DESTROY_FINISHED.
416 * The callback data is only valid within the invocation of the
417 * callback function that is passed the data. If you need to
418 * retain some data for use outside of the callback, you must
419 * make a copy of it.
420 */
421typedef struct {
422    /**
423     * The context being created or destroyed.
424     */
425    CUcontext context;
426
427    /**
428     * The device on which the context is being created or destroyed.
429     * This field is only valid for SANITIZER_CBID_RESOURCE_CONTEXT_CREATION_*
430     * callbacks
431     */
432    CUdevice device;
433} Sanitizer_ResourceContextData;
434
435/**
436 * \brief Data passed into a stream resource callback function.
437 *
438 * Data passed into a stream resource callback function as the
439 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
440 * \p cbdata will be this type for \p domain equal to
441 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
442 * SANITIZER_CBID_RESOURCE_STREAM_CREATED,
443 * SANITIZER_CBID_RESOURCE_STREAM_DESTROY_STARTING or
444 * SANITIZER_CBID_RESOURCE_STREAM_DESTROY_FINISHED.
445 * The callback data is only valid within the invocation of the
446 * callback function that is passed the data. If you need to
447 * retain some data for use outside of the callback, you must
448 * make a copy of it.
449 */
450typedef struct {
451    /**
452     * The context containing the stream being created or
453     * destroyed.
454     */
455    CUcontext context;
456
457    /**
458     * The stream being created or destroyed. This handle
459     * will be NULL for the STREAM_DESTROY_FINISHED cbid.
460     */
461    CUstream stream;
462
463    /**
464     * Unique handle for the stream.
465     */
466    Sanitizer_StreamHandle hStream;
467} Sanitizer_ResourceStreamData;
468
469/**
470 * \brief Data passed into a module resource callback function.
471 *
472 * Data passed into a module resource callback function as the
473 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
474 * \p cbdata will be this type for \p domain equal to
475 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
476 * SANITIZER_CBID_RESOURCE_MODULE_LOADED or
477 * SANITIZER_CBID_RESOURCE_MODULE_UNLOAD_STARTING.
478 * The callback data is only valid within the invocation of the
479 * callback function that is passed the data. If you need to
480 * retain some data for use outside of the callback, you must
481 * make a copy of it.
482 */
483typedef struct {
484    /**
485     * The context containing the module being loaded or
486     * unloaded.
487     */
488    CUcontext context;
489
490    /**
491     * The module being loaded or unloaded.
492     */
493    CUmodule module;
494
495    /**
496     * The size of the cubin.
497     */
498    size_t cubinSize;
499
500    /**
501     * Pointer to the associated cubin.
502     */
503    const char* pCubin;
504
505    /**
506     * Library associated with the module.
507     */
508    CUlibrary library;
509} Sanitizer_ResourceModuleData;
510
511/**
512 * \brief Flags describing a memory allocation.
513 *
514 * Flags describing a memory allocation. These values are to
515 * be used in order to interpret the value of
516 * \ref Sanitizer_ResourceMemoryData::flags
517 */
518typedef enum {
519    /**
520     * Empty flag.
521     */
522    SANITIZER_MEMORY_FLAG_NONE            = 0,
523
524    /**
525     * Specifies that the allocation is static scoped to a
526     * module.
527     */
528    SANITIZER_MEMORY_FLAG_MODULE          = 0x1,
529
530    /**
531     * Specifies that the allocation is managed memory.
532     */
533    SANITIZER_MEMORY_FLAG_MANAGED         = 0x2,
534
535    /**
536     * Species that the allocation accessible from the
537     * host.
538     */
539    SANITIZER_MEMORY_FLAG_HOST_MAPPED     = 0x4,
540
541    /**
542     * Specifies that the allocation is pinned on the host.
543     */
544    SANITIZER_MEMORY_FLAG_HOST_PINNED     = 0x8,
545
546    /**
547     * Specifies that the allocation is located on a peer GPU.
548     */
549    SANITIZER_MEMORY_FLAG_PEER            = 0x10,
550
551    /**
552     * Specifies that the allocation is located on a peer GPU
553     * supporting native atomics. This implies that
554     * SANITIZER_MEMORY_FLAG_PEER is set as well.
555     */
556    SANITIZER_MEMORY_FLAG_PEER_ATOMIC     = 0x20,
557
558    /**
559     * Specifies that the allocation is used by the
560     * Cooperative Groups runtime functions.
561     */
562    SANITIZER_MEMORY_FLAG_CG_RUNTIME      = 0x40,
563
564    /**
565     * Specifies that this is an allocation used for
566     * CUDA Dynamic Parallelism purposes.
567     */
568    SANITIZER_MEMORY_FLAG_CNP              = 0x80,
569
570    SANITIZER_MEMORY_FLAG_FORCE_INT        = 0x7fffffff
571} Sanitizer_ResourceMemoryFlags;
572
573/**
574 * \brief Permissions for a memory allocation.
575 *
576 * Permissions for a memory allocation. These values
577 * are to be used in order to interpret the value of
578 * \ref Sanitizer_ResourceMemoryData::permissions
579 */
580typedef enum {
581    /**
582     * No permissions.
583     */
584    SANITIZER_MEMORY_PERMISSION_NONE           = 0,
585
586    /**
587     * Specifies that the allocation is readable.
588     */
589    SANITIZER_MEMORY_PERMISSION_READ           = 0x1,
590
591    /**
592     * Specifies that the allocation is writable.
593     */
594    SANITIZER_MEMORY_PERMISSION_WRITE          = 0x2,
595
596    /**
597     * Specifies that the allocation is readable/writable with atomic
598     * operations.
599     */
600    SANITIZER_MEMORY_PERMISSION_ATOMIC         = 0x4,
601
602    /**
603     * Specifies that the allocation has all permissions.
604     */
605    SANITIZER_MEMORY_PERMISSION_ALL            = 0x7,
606
607    SANITIZER_MEMORY_PERMISSION_FORCE_INT      = 0x7fffffff
608} Sanitizer_ResourceMemoryPermissions;
609
610/**
611 * \brief Specifies the visibility of an allocation
612 *
613 * Specifies the visibility of an allocation. This is typically GLOBAL on
614 * allocations made via cudaMalloc, cudaHostAlloc and similar APIs. This can
615 * be GLOBAL or HOST for cudaMallocManaged allocations depending on the flags
616 * parameter. This can be changed after allocation time using cudaMemAttachSingle
617 * API (see SANITIZER_CBID_UVM_ATTACH_MEM for the corresponding callback).
618 */
619typedef enum {
620    /**
621     * Invalid memory visibility
622     */
623    SANITIZER_MEMORY_VISIBILITY_INVALID   = 0,
624
625    /**
626     * Memory can be accessed by any stream on any device
627     * (see cudaMemAttachGlobal)
628     */
629    SANITIZER_MEMORY_VISIBILITY_GLOBAL    = 1,
630
631    /**
632     * Memory cannot be accessed by any stream on any device
633     * (see cudaMemAttachHost)
634     */
635    SANITIZER_MEMORY_VISIBILITY_HOST      = 2,
636
637    /**
638     * Memory can only be accessed by a single stream on the associated device
639     * (see cudaMemAttachSingle)
640     */
641    SANITIZER_MEMORY_VISIBILITY_STREAM    = 3,
642
643    SANITIZER_MEMORY_VISIBILITY_FORCE_INT = 0x7fffffff
644} Sanitizer_MemoryVisibility;
645
646/**
647 * \brief Data passed into a memory resource callback function.
648 *
649 * Data passed into a memory resource callback function as the
650 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
651 * \p cbdata will be this type for \p domain equal to
652 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
653 * SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_ALLOC,
654 * SANITIZER_CBID_RESOURCE_DEVICE_MEMORY_FREE,
655 * SANITIZER_CBID_RESOURCE_HOST_MEMORY_ALLOC,
656 * SANITIZER_CBID_RESOURCE_HOST_MEMORY_FREE,
657 * SANITIZER_CBID_RESOURCE_MEMORY_ALLOC_ASYNC,
658 * SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC or
659 * SANITIZER_CBID_RESOURCE_MEMORY_FREE_ASYNC_DONE or
660 * SANITIZER_CBID_RESOURCE_MEMPOOL_IMPORT_POINTER.
661 * The callback data is only valid within the invocation of the
662 * callback function that is passed the data. If you need to
663 * retain some data for use outside of the callback, you must
664 * make a copy of it.
665 */
666typedef struct {
667    /**
668     * Address of the allocation being created or destroyed.
669     */
670    uint64_t address;
671
672    /**
673     * Size of the allocation being created or destroyed.
674     */
675    uint64_t size;
676
677    /**
678     * Context containing the allocation being created or
679     * destroyed. Can be NULL if the allocation is not attached to a
680     * context.
681     */
682    CUcontext context;
683
684    /**
685     * Device where the allocation is being created.
686     * Available for all cbid with a driver version of 455 or newer.
687     */
688    CUdevice device;
689
690    /**
691     * Public handle for the stream.
692     */
693    CUstream stream;
694
695    /**
696     * Stream containing the allocation being created or
697     * destroyed. Can be NULL if the allocation is not attached to a
698     * stream.
699     */
700    Sanitizer_StreamHandle hStream;
701
702    /**
703     * Memory pool containing the allocation being created or
704     * destroyed. Can be NULL if the allocation is not attached to a
705     * memory pool.
706     */
707    CUmemoryPool memoryPool;
708
709    /**
710     * Allocation details: use Sanitizer_ResourceMemoryFlags
711     * to interpret this field.
712     */
713    uint32_t flags;
714
715    /**
716     * Allocation permissions: use Sanitizer_ResourceMemoryPermissions
717     * to interpret this field.
718     */
719    uint32_t permissions;
720
721    /**
722     * Visibility of the allocation.
723     */
724    Sanitizer_MemoryVisibility visibility;
725
726    /**
727     * Source device of this allocation (different from device if
728     * SANITIZER_MEMORY_FLAG_PEER is set).
729     */
730    CUdevice sourceDevice;
731} Sanitizer_ResourceMemoryData;
732
733/**
734 * \brief Data passed into a mempool resource callback function.
735 *
736 * Data passed into a mempool resource callback function as the
737 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
738 * \p cbdata will be this type for \p domain equal to
739 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
740 * SANITIZER_CBID_RESOURCE_MEMPOOL_CREATED,
741 * SANITIZER_CBID_RESOURCE_MEMPOOL_DESTROYING,
742 * SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED or
743 * SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING.
744 * The callback data is only valid within the invocation of the
745 * callback function that is passed the data. If you need to
746 * retain some data for use outside of the callback, you must
747 * make a copy of it.
748 */
749typedef struct {
750    /**
751     * Memory pool being created or destroyed.
752     */
753    CUmemoryPool memoryPool;
754
755    /**
756     * Device that owns the memory pool.
757     */
758    CUdevice device;
759
760    /**
761     * Device that access type changed. Available if cbid is
762     * SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_ENABLED or
763     * SANITIZER_CBID_RESOURCE_MEMPOOL_PEER_ACCESS_DISABLING.
764     */
765    CUdevice peerDevice;
766} Sanitizer_ResourceMempoolData;
767
768/**
769 *
770 * \brief Data passed into a CUDA array callback function.
771 *
772 * Data passed into a  CUDA array callback function as the
773 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
774 * \p cbdata will be this type for \p domain equal tp
775 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
776 * SANITIZER_CBID_RESOURCE_ARRAY_CREATED or
777 * SANITIZER_CBID_RESOURCE_ARRAY_DESTROYED.
778 * The callback data is only valid within the invocation of the
779 * callback function that is passed the data. If you need to
780 * retain some data for use outside of the callback, you must
781 * make a copy of it.
782 */
783typedef struct {
784    /**
785     * The context containing the array being created or
786     * destroyed.
787     */
788    CUcontext context;
789
790    /**
791     * The CUDA array being created or destroyed.
792     */
793    CUarray hArray;
794
795    /**
796     * The CUDA array size.
797     */
798    uint64_t width;
799    uint64_t height;
800    uint64_t depth;
801} Sanitizer_ResourceArrayData;
802
803/**
804 *
805 * \brief Data passed into a CUDA function callback function.
806 *
807 * Data passed into a CUDA function callback function as the
808 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
809 * \p cbdata will be this type for \p domain equal tp
810 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
811 * SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_LOADED or
812 * SANITIZER_CBID_RESOURCE_FUNCTIONS_LAZY_PATCHED.
813 * The callback data is only valid within the invocation of the
814 * callback function that is passed the data. If you need to
815 * retain some data for use outside of the callback, you must
816 * make a copy of it.
817 */
818typedef struct {
819    /**
820     * The context containing the functions.
821     */
822    CUcontext context;
823
824    /**
825     * The module containing the functions.
826     */
827    CUmodule module;
828
829    /**
830     * An array containing the functions.
831     */
832    const CUfunction* functions;
833
834    /**
835     * The size of the function array.
836     */
837    uint32_t numFunctions;
838} Sanitizer_ResourceFunctionsLazyLoadedData;
839
840/**
841 *
842 * \brief Data passed into a VA reservation callback function.
843 *
844 * Data passed into a VA reservation callback function as the
845 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
846 * \p cbdata will be this type for \p domain equal tp
847 * SANITIZER_CB_DOMAIN_RESOURCE and \p cbid equal to
848 * SANITIZER_CBID_RESOURCE_VIRTUAL_RESERVE.
849 * or SANITIZER_CBID_RESOURCE_VIRTUAL_RELEASE.
850 * The callback data is only valid within the invocation of the
851 * callback function that is passed the data. If you need to
852 * retain some data for use outside of the callback, you must
853 * make a copy of it.
854 * Available with a driver version of 535 or newer.
855 */
856typedef struct {
857    /**
858     * Address of the VA range being reserved or released.
859     */
860    uint64_t address;
861
862    /**
863     * Size of the VA range being reserved or released.
864     */
865    uint64_t size;
866} Sanitizer_ResourceVirtualRange;
867
868
869/**
870 * \brief Callback IDs for synchronization domain.
871 *
872 * Callback IDs for resource domain
873 * SANITIZER_CB_DOMAIN_SYNCHRONIZE. This value is
874 * communicated to the callback function via the \p cbid
875 * parameter.
876 */
877typedef enum {
878    /**
879     * Invalid synchronize callback ID.
880     */
881    SANITIZER_CBID_SYNCHRONIZE_INVALID              = 0,
882
883    /**
884     * Stream synchronization has completed for a given stream.
885     */
886    SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED  = 1,
887
888    /**
889     * Context synchronization has completed for a given context.
890     */
891    SANITIZER_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED = 2,
892
893    SANITIZER_CBID_SYNCHRONIZE_SIZE,
894    SANITIZER_CBID_SYNCHRONIZE_FORCE_INT            = 0x7fffffff
895} Sanitizer_CallackIdSync;
896
897/**
898 * \brief Data passed into a synchronization callback function.
899 *
900 * Data passed into a synchronization callback function as the
901 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
902 * \p cbdata will be this type for \p domain equal to
903 * SANITIZER_CB_DOMAIN_SYNCHRONIZE. The callback data is
904 * only valid within the invocation of the callback function
905 * that is passed the data. If you need to retain some data
906 * for use outside of the callback, you must make a copy of it.
907 */
908typedef struct {
909    /**
910     * For SANITIZER_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED, this
911     * is the context being synchronized. For
912     * SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED, this is
913     * the context of the stream being synchronized.
914     */
915    CUcontext context;
916
917    /**
918     * This field is only valid for
919     * SANITIZER_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED. This is
920     * the stream being synchronized.
921     */
922    CUstream stream;
923
924    /**
925     * Unique handle for the stream.
926     */
927    Sanitizer_StreamHandle hStream;
928} Sanitizer_SynchronizeData;
929
930/**
931 * \brief Callback IDs for launch domain.
932 *
933 * Callback IDs for resource domain SANITIZER_CB_DOMAIN_LAUNCH.
934 * This value is communicated to the callback function via
935 * the \p cbid parameter.
936 */
937typedef enum {
938    /**
939     * Invalid launch callback ID.
940     */
941    SANITIZER_CBID_LAUNCH_INVALID             = 0,
942
943    /**
944     * A grid launch was initiated.
945     */
946    SANITIZER_CBID_LAUNCH_BEGIN               = 1,
947
948    /**
949     * A grid launch has completed syscalls setup.
950     */
951    SANITIZER_CBID_LAUNCH_AFTER_SYSCALL_SETUP = 2,
952
953    /**
954     * The grid launch is complete.
955     */
956    SANITIZER_CBID_LAUNCH_END                 = 3,
957
958    SANITIZER_CBID_LAUNCH_SIZE,
959    SANITIZER_CBID_LAUNCH_FORCE_INT           = 0x7fffffff
960} Sanitizer_CallbackIdLaunch;
961
962/**
963 * \brief Data passed into a launch callback function.
964 *
965 * Data passed into a launch callback function as the
966 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
967 * \p cbdata will be this type for \p domain equal to
968 * SANITIZER_CB_DOMAIN_LAUNCH. The callback data is
969 * only valid within the invocation of the callback function
970 * that is passed the data. If you need to retain some data
971 * for use outside of the callback, you must make a copy of it.
972 */
973typedef struct {
974    /**
975     * The context where the grid is launched. For graph node launches,
976     * this is the context in which the kernel will run.
977     */
978    CUcontext context;
979
980    /**
981     * The stream where the grid is launched.
982     */
983    CUstream stream;
984
985    /**
986     * Unique handle for the stream.
987     */
988    Sanitizer_StreamHandle hStream;
989
990    /**
991     * The module containing the grid code.
992     */
993    CUmodule module;
994
995    /**
996     * The function of the grid launch.
997     */
998    CUfunction function;
999
1000    /**
1001     * The name of the launched function.
1002     */
1003    const char *functionName;
1004
1005    /** @{
1006     * Launch properties of the grid.
1007     * These values are only valid for SANITIZER_CBID_LAUNCH_BEGIN and graph
1008     * node launch callbacks
1009     */
1010    uint32_t gridDim_x;
1011    uint32_t gridDim_y;
1012    uint32_t gridDim_z;
1013    uint32_t blockDim_x;
1014    uint32_t blockDim_y;
1015    uint32_t blockDim_z;
1016    uint32_t clusterDim_x;
1017    uint32_t clusterDim_y;
1018    uint32_t clusterDim_z;
1019    /** @} */
1020
1021    /**
1022     * Unique identifier of the grid launch.
1023     * For graph node launches, this is only unique within the graphexec launch.
1024     */
1025    uint64_t gridId;
1026
1027    /**
1028     * Handle of the grid launch. This is only valid between the launch begin
1029     * and end callbacks.
1030     */
1031    Sanitizer_LaunchHandle hLaunch;
1032
1033    /**
1034     * The device where the grid is launched
1035     */
1036    CUdevice device;
1037
1038    /**
1039     * Only valid for graph node launches. This is the context of the stream used
1040     * in the graph launch API call.
1041     */
1042    CUcontext apiContext;
1043
1044    /**
1045     * Only valid for graph node launches. This is the stream used in the graph
1046     * launch API call.
1047     */
1048    CUstream apiStream;
1049
1050    /**
1051     * Unique handle for the API stream.
1052     */
1053    Sanitizer_StreamHandle hApiStream;
1054} Sanitizer_LaunchData;
1055
1056/**
1057 * \brief Callback IDs for memcpy domain.
1058 *
1059 * Callback IDs for resource domain SANITIZER_CB_DOMAIN_MEMCPY.
1060 * This value is communicated to the callback function via
1061 * the \p cbid parameter.
1062 */
1063typedef enum {
1064    /**
1065     * Invalid memcpy callback ID.
1066     */
1067    SANITIZER_CBID_MEMCPY_INVALID   = 0,
1068
1069    /**
1070     * A memcpy operation was initiated.
1071     */
1072    SANITIZER_CBID_MEMCPY_STARTING  = 1,
1073
1074    SANITIZER_CBID_MEMCPY_SIZE,
1075    SANITIZER_CBID_MEMCPY_FORCE_INT = 0x7fffffff
1076} Sanitizer_CallbackIdMemcpy;
1077
1078/**
1079 * \brief Memcpy direction.
1080 *
1081 * Indicates the direction of a memcpy, passed inside \p Sanitizer_Memcpydata.
1082 */
1083typedef enum {
1084    /**
1085     * Unknown memcpy direction
1086     */
1087    SANITIZER_MEMCPY_DIRECTION_UNKNOWN          = 0,
1088    /**
1089     * Memcpy from host to host.
1090     */
1091    SANITIZER_MEMCPY_DIRECTION_HOST_TO_HOST     = 1,
1092    /**
1093     * Memcpy from host to device.
1094     */
1095    SANITIZER_MEMCPY_DIRECTION_HOST_TO_DEVICE   = 2,
1096    /**
1097     * Memcpy from device to host.
1098     */
1099    SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_HOST   = 3,
1100    /**
1101     * Memcpy from device to device.
1102     */
1103    SANITIZER_MEMCPY_DIRECTION_DEVICE_TO_DEVICE = 4,
1104
1105    SANITIZER_MEMCPY_DIRECTION_SIZE,
1106    SANITIZER_MEMCPY_DIRECTION_FORCE_INT        = 0x7fffffff
1107} Sanitizer_MemcpyDirection;
1108
1109/**
1110 * \brief Data passed into a memcpy callback function.
1111 *
1112 * Data passed into a launch callback function as the
1113 * \p cbdata argument to \ref Sanitizer_CallbackFunc. The
1114 * \p cbdata will be this type for \p domain equal to
1115 * SANITIZER_CB_DOMAIN_MEMCPY. The callback data is
1116 * only valid within the invocation of the callback function
1117 * that is passed the data. If you need to retain some data
1118 * for use outside of the callback, you must make a copy of it.
1119 */
1120typedef struct {
1121    /**
1122     * The context where the source allocation is located
1123     */
1124    CUcontext srcContext;
1125
1126    /**
1127     * The context where the destination allocation is located
1128     */
1129    CUcontext dstContext;
1130
1131    /**
1132     * The stream where the memcpy is executed on the source context
1133     */
1134    CUstream srcStream;
1135
1136    /**
1137     * Unique handle for the source context stream.
1138     */
1139    Sanitizer_StreamHandle hSrcStream;
1140
1141    /**
1142     * The stream where the memcpy is executed on the destination context
1143     */
1144    CUstream dstStream;
1145
1146    /**
1147     * Unique handle for the destination context stream.
1148     */
1149    Sanitizer_StreamHandle hDstStream;
1150
1151    /**
1152     * The source allocation address.
1153     */
1154    uint64_t srcAddress;
1155
1156    /**
1157     * The destination allocation address.
1158     */
1159    uint64_t dstAddress;
1160
1161    /**
1162     * Size of the transfer in bytes.
1163     */
1164    uint64_t size;
1165
1166    /**
1167     * Memcpy size configuration.
1168     */
1169    uint64_t width;
1170    uint64_t height;
1171    uint64_t depth;
1172
1173    /**
1174     * The source allocation pitch.
1175     */
1176    uint64_t srcPitch;
1177
1178    /**
1179     * The destination allocation pitch.
1180     */
1181    uint64_t dstPitch;
1182
1183    /**
1184     * Boolean value indicating if the transfer is
1185     * asynchronous.
1186     */
1187    uint32_t isAsync;
1188
1189    /**
1190     * The direction of the transfer
1191     */
1192    Sanitizer_MemcpyDirection direction;
1193
1194    /**
1195     * The context on which the operation was requested
1196     */
1197    CUcontext apiContext;
1198
1199    /**
1200     * The stream on which the operation was requested

Showing the first 1,200 of 2005 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai