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) 2009-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_MEM_GUARD
0022 #error Never include this file directly -- it is automatically included by nvToolsExtMem.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 #define NVTX_EXT_IMPL_GUARD
0036 #include "nvtxExtImpl.h"
0037 #undef NVTX_EXT_IMPL_GUARD
0038 
0039 #ifndef NVTX_EXT_IMPL_MEM_V1
0040 #define NVTX_EXT_IMPL_MEM_V1
0041 
0042 #ifdef __cplusplus
0043 extern "C" {
0044 #endif /* __cplusplus */
0045 
0046 #ifdef NVTX_DISABLE
0047 
0048 #include "nvtxExtHelperMacros.h"
0049 
0050 #define NVTX_EXT_MEM_IMPL_FN_V1(ret_type, fn_name, signature, arg_names) \
0051 NVTX_DECLSPEC ret_type NVTX_API fn_name signature { \
0052     NVTX_SET_NAME_MANGLING_OPTIONS \
0053     NVTX_EXT_HELPER_UNUSED_ARGS arg_names \
0054     NVTX_EXT_FN_RETURN_INVALID(ret_type) \
0055 }
0056 
0057 #else /* NVTX_DISABLE */
0058 
0059 /*
0060  * Function slots for the memory extension. First entry is the module
0061  * state, initialized to `0` (`NVTX_EXTENSION_FRESH`).
0062  */
0063 #define NVTX_EXT_MEM_SLOT_COUNT 63
0064 
0065 NVTX_LINKONCE_DEFINE_GLOBAL intptr_t
0066 NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemSlots)[NVTX_EXT_MEM_SLOT_COUNT + 1]
0067     = {0};
0068 
0069 /* Avoid warnings about missing prototype. */
0070 NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemInitOnce)(void);
0071 NVTX_LINKONCE_DEFINE_FUNCTION void NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemInitOnce)(void)
0072 {
0073     intptr_t* fnSlots = NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemSlots) + 1;
0074     nvtxExtModuleSegment_t segment = {
0075         1, /* only one segment, hard-code ID */
0076         NVTX_EXT_MEM_SLOT_COUNT,
0077         NVTX_NULLPTR /* function slots */
0078     };
0079 
0080     nvtxExtModuleInfo_t module_info = {
0081         NVTX_VERSION, sizeof(nvtxExtModuleInfo_t),
0082         NVTX_EXT_MODULEID_MEM, NVTX_EXT_COMPATID_MEM,
0083         1, NVTX_NULLPTR, /* number of segments, segments */
0084         NVTX_NULLPTR, /* no export function needed */
0085         NVTX_NULLPTR /* no extension private info */
0086     };
0087 
0088     segment.functionSlots = fnSlots;
0089     module_info.segments = &segment;
0090 
0091     NVTX_INFO( "%s\n", __FUNCTION__  );
0092 
0093     NVTX_VERSIONED_IDENTIFIER(nvtxExtInitOnce)(&module_info,
0094         NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemSlots));
0095 }
0096 
0097 #define NVTX_EXT_MEM_IMPL_FN_V1(ret_type, fn_name, signature, arg_names) \
0098 typedef ret_type (*fn_name##_impl_fntype)signature; \
0099 NVTX_DECLSPEC ret_type NVTX_API fn_name signature { \
0100     NVTX_SET_NAME_MANGLING_OPTIONS \
0101     intptr_t* pSlot = &NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemSlots)[NVTX3EXT_CBID_##fn_name + 1]; \
0102     intptr_t slot = *pSlot; \
0103     if (slot != NVTX_EXTENSION_DISABLED) { \
0104         if (slot != NVTX_EXTENSION_FRESH) { \
0105             NVTX_EXT_FN_RETURN (*NVTX_REINTERPRET_CAST(fn_name##_impl_fntype, slot)) arg_names; \
0106         } else { \
0107             NVTX_EXT_MEM_VERSIONED_ID(nvtxExtMemInitOnce)(); \
0108             /* Re-read function slot after extension initialization. */ \
0109             slot = *pSlot; \
0110             if (slot != NVTX_EXTENSION_DISABLED && slot != NVTX_EXTENSION_FRESH) { \
0111                 NVTX_EXT_FN_RETURN (*NVTX_REINTERPRET_CAST(fn_name##_impl_fntype, slot)) arg_names; \
0112             } \
0113         } \
0114     } \
0115     NVTX_EXT_FN_RETURN_INVALID(ret_type) /* No tool attached. */ \
0116 }
0117 
0118 #endif /* NVTX_DISABLE */
0119 
0120 /* Non-void functions. */
0121 #define NVTX_EXT_FN_RETURN return
0122 #define NVTX_EXT_FN_RETURN_INVALID(rtype) return NVTX_NULLPTR;
0123 
0124 NVTX_EXT_MEM_IMPL_FN_V1(nvtxMemHeapHandle_t, nvtxMemHeapRegister, (nvtxDomainHandle_t domain, nvtxMemHeapDesc_t const* desc), (domain, desc))
0125 
0126 NVTX_EXT_MEM_IMPL_FN_V1(nvtxMemPermissionsHandle_t, nvtxMemPermissionsCreate, (nvtxDomainHandle_t domain, int32_t creationflags), (domain, creationflags))
0127 
0128 #undef NVTX_EXT_FN_RETURN
0129 #undef NVTX_EXT_FN_RETURN_INVALID
0130 /* END: Non-void functions. */
0131 
0132 /* void functions. */
0133 #define NVTX_EXT_FN_RETURN
0134 #define NVTX_EXT_FN_RETURN_INVALID(rtype)
0135 
0136 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemHeapUnregister, (nvtxDomainHandle_t domain, nvtxMemHeapHandle_t heap), (domain, heap))
0137 
0138 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemHeapReset, (nvtxDomainHandle_t domain, nvtxMemHeapHandle_t heap), (domain, heap))
0139 
0140 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemRegionsRegister, (nvtxDomainHandle_t domain, nvtxMemRegionsRegisterBatch_t const* desc), (domain, desc))
0141 
0142 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemRegionsResize, (nvtxDomainHandle_t domain, nvtxMemRegionsResizeBatch_t const* desc), (domain, desc))
0143 
0144 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemRegionsUnregister, (nvtxDomainHandle_t domain, nvtxMemRegionsUnregisterBatch_t const* desc), (domain, desc))
0145 
0146 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemRegionsName, (nvtxDomainHandle_t domain, nvtxMemRegionsNameBatch_t const* desc), (domain, desc))
0147 
0148 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemPermissionsAssign, (nvtxDomainHandle_t domain, nvtxMemPermissionsAssignBatch_t const* desc), (domain, desc))
0149 
0150 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemPermissionsDestroy, (nvtxDomainHandle_t domain, nvtxMemPermissionsHandle_t permissions), (domain, permissions))
0151 
0152 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemPermissionsReset, (nvtxDomainHandle_t domain, nvtxMemPermissionsHandle_t permissions), (domain, permissions))
0153 
0154 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemPermissionsBind, (nvtxDomainHandle_t domain, nvtxMemPermissionsHandle_t permissions, uint32_t bindScope, uint32_t bindFlags), (domain, permissions, bindScope, bindFlags))
0155 
0156 NVTX_EXT_MEM_IMPL_FN_V1(void, nvtxMemPermissionsUnbind, (nvtxDomainHandle_t domain, uint32_t bindScope), (domain, bindScope))
0157 
0158 #undef NVTX_EXT_FN_RETURN
0159 #undef NVTX_EXT_FN_RETURN_INVALID
0160 /* END: void functions. */
0161 
0162 /* Keep NVTX_EXT_MEM_IMPL_FN_V1 defined for a future version of this extension. */
0163 
0164 #ifdef __cplusplus
0165 } /* extern "C" */
0166 #endif /* __cplusplus */
0167 
0168 #endif /* NVTX_EXT_IMPL_MEM_V1 */