|
| 1 | +// Minimal CUPTI type definitions for building mock libraries. |
| 2 | +// Only the types referenced by parcagpu's test/mock_cupti.c are needed. |
| 3 | +// Struct layouts must be ABI-compatible with the real CUPTI headers. |
| 4 | +#ifndef MOCK_CUPTI_H |
| 5 | +#define MOCK_CUPTI_H |
| 6 | + |
| 7 | +#include <stdint.h> |
| 8 | +#include <stddef.h> |
| 9 | +#include "cuda.h" |
| 10 | + |
| 11 | +typedef int CUptiResult; |
| 12 | +#define CUPTI_SUCCESS 0 |
| 13 | +#define CUPTI_ERROR_MAX_LIMIT_REACHED 21 |
| 14 | +#define CUPTI_ERROR_INVALID_KIND 46 |
| 15 | + |
| 16 | +typedef void *CUpti_SubscriberHandle; |
| 17 | + |
| 18 | +typedef enum { |
| 19 | + CUPTI_CB_DOMAIN_RUNTIME_API = 2, |
| 20 | + CUPTI_CB_DOMAIN_DRIVER_API = 3, |
| 21 | + CUPTI_CB_DOMAIN_RESOURCE = 4, |
| 22 | +} CUpti_CallbackDomain; |
| 23 | + |
| 24 | +typedef uint32_t CUpti_CallbackId; |
| 25 | + |
| 26 | +#define CUPTI_CBID_RESOURCE_CONTEXT_CREATED 1 |
| 27 | +#define CUPTI_CBID_RESOURCE_MODULE_LOADED 4 |
| 28 | + |
| 29 | +typedef void (*CUpti_CallbackFunc)(void *userdata, |
| 30 | + CUpti_CallbackDomain domain, |
| 31 | + CUpti_CallbackId cbid, |
| 32 | + const void *cbdata); |
| 33 | + |
| 34 | +typedef void (*CUpti_BufferRequestFunc)(uint8_t **buffer, size_t *size, |
| 35 | + size_t *maxNumRecords); |
| 36 | +typedef void (*CUpti_BufferCompletedFunc)(CUcontext ctx, uint32_t streamId, |
| 37 | + uint8_t *buffer, size_t size, |
| 38 | + size_t validSize); |
| 39 | + |
| 40 | +typedef uint32_t CUpti_ActivityKind; |
| 41 | +#define CUPTI_ACTIVITY_KIND_KERNEL 3 |
| 42 | +#define CUPTI_ACTIVITY_KIND_CONCURRENT_KERNEL 10 |
| 43 | +#define CUPTI_ACTIVITY_KIND_GRAPH_TRACE 34 |
| 44 | + |
| 45 | +typedef struct { |
| 46 | + uint32_t kind; |
| 47 | +} CUpti_Activity; |
| 48 | + |
| 49 | +// CUpti_ActivityKernel5 — 160 bytes, matching cupti_activity.h. |
| 50 | +typedef struct { |
| 51 | + uint32_t kind; // offset 0 |
| 52 | + uint8_t _pad1[12]; // offset 4 |
| 53 | + uint64_t start; // offset 16 |
| 54 | + uint64_t end; // offset 24 |
| 55 | + uint64_t completed; // offset 32 |
| 56 | + uint32_t deviceId; // offset 40 |
| 57 | + uint32_t contextId; // offset 44 |
| 58 | + uint32_t streamId; // offset 48 |
| 59 | + uint8_t _pad2[40]; // offset 52 |
| 60 | + uint32_t correlationId; // offset 92 |
| 61 | + int64_t gridId; // offset 96 |
| 62 | + const char *name; // offset 104 |
| 63 | + uint64_t _reserved0; // offset 112 |
| 64 | + uint64_t queued; // offset 120 |
| 65 | + uint64_t submitted; // offset 128 |
| 66 | + uint8_t _pad3[8]; // offset 136 |
| 67 | + uint64_t graphNodeId; // offset 144 |
| 68 | + uint32_t shmemLimitCfg; // offset 152 |
| 69 | + uint32_t graphId; // offset 156 |
| 70 | +} __attribute__((aligned(8))) CUpti_ActivityKernel5; |
| 71 | + |
| 72 | +// CUpti_ActivityGraphTrace — 64 bytes. |
| 73 | +typedef struct { |
| 74 | + uint32_t kind; |
| 75 | + uint8_t _pad[60]; |
| 76 | +} __attribute__((aligned(8))) CUpti_ActivityGraphTrace; |
| 77 | + |
| 78 | +// Resource callback data. |
| 79 | +typedef struct { |
| 80 | + CUcontext context; |
| 81 | + void *resourceDescriptor; |
| 82 | +} CUpti_ResourceData; |
| 83 | + |
| 84 | +typedef struct { |
| 85 | + const char *pCubin; |
| 86 | + size_t cubinSize; |
| 87 | +} CUpti_ModuleResourceData; |
| 88 | + |
| 89 | +// cuptiGetCubinCrc params. |
| 90 | +typedef struct { |
| 91 | + const char *cubin; |
| 92 | + size_t cubinSize; |
| 93 | + uint64_t cubinCrc; |
| 94 | +} CUpti_GetCubinCrcParams; |
| 95 | + |
| 96 | +// cuptiGetSassToSourceCorrelation params. |
| 97 | +typedef struct { |
| 98 | + uint64_t pcOffset; |
| 99 | + const char *functionName; |
| 100 | + uint32_t lineNumber; |
| 101 | + char *fileName; |
| 102 | + char *dirName; |
| 103 | +} CUpti_GetSassToSourceCorrelationParams; |
| 104 | + |
| 105 | +// cuptiActivitySetAttribute placeholder. |
| 106 | +typedef uint32_t CUpti_ActivityAttribute; |
| 107 | + |
| 108 | +#endif // MOCK_CUPTI_H |
0 commit comments