Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:45:12

0001 /*
0002  * SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
0003  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0004  *
0005  * Licensed under the Apache License, Version 2.0 (the "License");
0006  * you may not use this file except in compliance with the License.
0007  * You may obtain a copy of the License at
0008  *
0009  *     http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  *
0017  * Licensed under the Apache License v2.0 with LLVM Exceptions.
0018  * See https://nvidia.github.io/NVTX/LICENSE.txt for license information.
0019  */
0020 
0021 #ifndef NVTX_EXT_IMPL_PAYLOAD_GUARD
0022 #error Never include this file directly -- it is automatically included by nvToolsExtPayload.h (except when NVTX_NO_IMPL is defined).
0023 #endif
0024 
0025 #if defined(NVTX_AS_SYSTEM_HEADER)
0026 #if defined(__clang__)
0027 #pragma clang system_header
0028 #elif defined(__GNUC__) || defined(__NVCOMPILER)
0029 #pragma GCC system_header
0030 #elif defined(_MSC_VER)
0031 #pragma system_header
0032 #endif
0033 #endif
0034 
0035 typedef void* nvtx_payload_pointer_type;
0036 
0037 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
0038 #ifndef __APPLE__
0039 #include <uchar.h>
0040 #endif
0041 #include <stdalign.h>
0042 #endif
0043 
0044 /* `char8_t` is available as of C++20 or C23 */
0045 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201811L)) && !defined(__APPLE__)
0046 #define NVTX_HAVE_CHAR8 1
0047 #else
0048 #define NVTX_HAVE_CHAR8 0
0049 #endif
0050 
0051 /* `char16_t` and `char32_t` are available as of C++11 or C11 */
0052 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(__cplusplus) && __cplusplus >= 200704L)) && !defined(__APPLE__)
0053 #define NVTX_HAVE_CHAR16_CHAR32 1
0054 #else
0055 #define NVTX_HAVE_CHAR16_CHAR32 0
0056 #endif
0057 
0058 /* `alignof` is available as of C11 or C++11. */
0059 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || (defined(__cplusplus) && __cplusplus >= 201103L)
0060 
0061 #define nvtx_alignof(type) alignof(type)
0062 #define nvtx_alignof2(type,tname) alignof(type)
0063 
0064 #else /* (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201103L) */
0065 
0066 /* Create helper structs to determine type alignment. */
0067 #define MKTYPEDEF(type) typedef struct {char c; type d;} _nvtx_##type
0068 #define MKTYPEDEF2(type,tname) typedef struct {char c; type d;} _nvtx_##tname
0069 
0070 MKTYPEDEF(char);
0071 MKTYPEDEF2(unsigned char, uchar);
0072 MKTYPEDEF(short);
0073 MKTYPEDEF2(unsigned short, ushort);
0074 MKTYPEDEF(int);
0075 MKTYPEDEF2(unsigned int, uint);
0076 MKTYPEDEF(long);
0077 MKTYPEDEF2(unsigned long, ulong);
0078 MKTYPEDEF2(long long, longlong);
0079 MKTYPEDEF2(unsigned long long, ulonglong);
0080 
0081 MKTYPEDEF(int8_t);
0082 MKTYPEDEF(uint8_t);
0083 MKTYPEDEF(int16_t);
0084 MKTYPEDEF(uint16_t);
0085 MKTYPEDEF(int32_t);
0086 MKTYPEDEF(uint32_t);
0087 MKTYPEDEF(int64_t);
0088 MKTYPEDEF(uint64_t);
0089 
0090 MKTYPEDEF(float);
0091 MKTYPEDEF(double);
0092 MKTYPEDEF2(long double, longdouble);
0093 
0094 MKTYPEDEF(size_t);
0095 MKTYPEDEF(nvtx_payload_pointer_type);
0096 
0097 MKTYPEDEF(wchar_t);
0098 
0099 #if NVTX_HAVE_CHAR8
0100     MKTYPEDEF(char8_t);
0101 #endif
0102 
0103 #if NVTX_HAVE_CHAR16_CHAR32
0104     MKTYPEDEF(char16_t);
0105     MKTYPEDEF(char32_t);
0106 #endif
0107 
0108 /* C requires to include stddef.h to use `offsetof` */
0109 #ifndef __cplusplus
0110 #include <stddef.h>
0111 #endif
0112 
0113 #define nvtx_alignof(tname) offsetof(_nvtx_##tname, d)
0114 #define nvtx_alignof2(type, tname) offsetof(_nvtx_##tname, d)
0115 
0116 #endif /*  __STDC_VERSION__ >= 201112L */
0117 
0118 #undef MKTYPEDEF
0119 #undef MKTYPEDEF2
0120 
0121 /*
0122  * Helper array to get the alignment for each predefined C/C++ language type.
0123  * The order of entries must match the values in`enum nvtxPayloadSchemaEntryType`.
0124  *
0125  * In C++, `const` variables use internal linkage by default, but we need it to
0126  * be public (extern) since weak declarations must be public.
0127  */
0128 NVTX_LINKONCE_DEFINE_GLOBAL
0129 #ifdef __cplusplus
0130 extern
0131 #endif
0132 const nvtxPayloadEntryTypeInfo_t
0133 NVTX_EXT_PAYLOAD_VERSIONED_ID(nvtxExtPayloadTypeInfo)[NVTX_PAYLOAD_ENTRY_TYPE_INFO_ARRAY_SIZE] =
0134 {
0135     /* The first entry contains this array's length and the size of each entry in this array. */
0136     {NVTX_PAYLOAD_ENTRY_TYPE_INFO_ARRAY_SIZE, sizeof(nvtxPayloadEntryTypeInfo_t)},
0137 
0138     /*** C integer types ***/
0139     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR */   {sizeof(char), nvtx_alignof(char)},
0140     /* NVTX_PAYLOAD_ENTRY_TYPE_UCHAR */  {sizeof(unsigned char), nvtx_alignof2(unsigned char, uchar)},
0141     /* NVTX_PAYLOAD_ENTRY_TYPE_SHORT */  {sizeof(short), nvtx_alignof(short)},
0142     /* NVTX_PAYLOAD_ENTRY_TYPE_USHORT */ {sizeof(unsigned short), nvtx_alignof2(unsigned short, ushort)},
0143     /* NVTX_PAYLOAD_ENTRY_TYPE_INT */    {sizeof(int), nvtx_alignof(int)},
0144     /* NVTX_PAYLOAD_ENTRY_TYPE_UINT */   {sizeof(unsigned int), nvtx_alignof2(unsigned int, uint)},
0145     /* NVTX_PAYLOAD_ENTRY_TYPE_LONG */   {sizeof(long), nvtx_alignof(long)},
0146     /* NVTX_PAYLOAD_ENTRY_TYPE_ULONG */  {sizeof(unsigned long), nvtx_alignof2(unsigned long, ulong)},
0147     /* NVTX_PAYLOAD_ENTRY_TYPE_LONGLONG */  {sizeof(long long), nvtx_alignof2(long long, longlong)},
0148     /* NVTX_PAYLOAD_ENTRY_TYPE_ULONGLONG */ {sizeof(unsigned long long), nvtx_alignof2(unsigned long long,ulonglong)},
0149 
0150     /*** Integer types with explicit size ***/
0151     /* NVTX_PAYLOAD_ENTRY_TYPE_INT8 */   {sizeof(int8_t),   nvtx_alignof(int8_t)},
0152     /* NVTX_PAYLOAD_ENTRY_TYPE_UINT8 */  {sizeof(uint8_t),  nvtx_alignof(uint8_t)},
0153     /* NVTX_PAYLOAD_ENTRY_TYPE_INT16 */  {sizeof(int16_t),  nvtx_alignof(int16_t)},
0154     /* NVTX_PAYLOAD_ENTRY_TYPE_UINT16 */ {sizeof(uint16_t), nvtx_alignof(uint16_t)},
0155     /* NVTX_PAYLOAD_ENTRY_TYPE_INT32 */  {sizeof(int32_t),  nvtx_alignof(int32_t)},
0156     /* NVTX_PAYLOAD_ENTRY_TYPE_UINT32 */ {sizeof(uint32_t), nvtx_alignof(uint32_t)},
0157     /* NVTX_PAYLOAD_ENTRY_TYPE_INT64 */  {sizeof(int64_t),  nvtx_alignof(int64_t)},
0158     /* NVTX_PAYLOAD_ENTRY_TYPE_UINT64 */ {sizeof(uint64_t), nvtx_alignof(uint64_t)},
0159 
0160     /*** C floating point types ***/
0161     /* NVTX_PAYLOAD_ENTRY_TYPE_FLOAT */      {sizeof(float),       nvtx_alignof(float)},
0162     /* NVTX_PAYLOAD_ENTRY_TYPE_DOUBLE */     {sizeof(double),      nvtx_alignof(double)},
0163     /* NVTX_PAYLOAD_ENTRY_TYPE_LONGDOUBLE */ {sizeof(long double), nvtx_alignof2(long double, longdouble)},
0164 
0165     /* NVTX_PAYLOAD_ENTRY_TYPE_SIZE */    {sizeof(size_t),       nvtx_alignof(size_t)},
0166     /* NVTX_PAYLOAD_ENTRY_TYPE_ADDRESS */ {sizeof(nvtx_payload_pointer_type), nvtx_alignof(nvtx_payload_pointer_type)},
0167 
0168     /*** Special character types ***/
0169     /* NVTX_PAYLOAD_ENTRY_TYPE_WCHAR */ {sizeof(wchar_t), nvtx_alignof(wchar_t)},
0170 
0171 #if NVTX_HAVE_CHAR8
0172     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR8 */ {sizeof(char8_t), nvtx_alignof(char8_t)},
0173 #else
0174     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR8 */ {0, 0},
0175 #endif
0176 
0177 #if NVTX_HAVE_CHAR16_CHAR32
0178     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR16 */ {sizeof(char16_t), nvtx_alignof(char16_t)},
0179     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR32 */ {sizeof(char32_t), nvtx_alignof(char32_t)}
0180 #else
0181     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR16 */ {0, 0},
0182     /* NVTX_PAYLOAD_ENTRY_TYPE_CHAR32 */ {0, 0}
0183 #endif
0184 };
0185 
0186 #undef nvtx_alignof
0187 #undef nvtx_alignof2
0188 #undef NVTX_HAVE_CHAR8
0189 #undef NVTX_HAVE_CHAR16_CHAR32