jasonfan commited on
Commit
ddbeb29
·
verified ·
1 Parent(s): f6d1f18

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/device_host_transport/nvshmem_constants.h +85 -0
  2. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_api.h +489 -0
  3. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_coll_api.h +111 -0
  4. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_macros.h +23 -0
  5. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmemx_api.h +470 -0
  6. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmemx_coll_api.h +214 -0
  7. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/alltoall.cuh +157 -0
  8. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/barrier.cuh +281 -0
  9. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/broadcast.cuh +412 -0
  10. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/defines.cuh +19 -0
  11. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/fcollect.cuh +1080 -0
  12. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/reduce.cuh +0 -0
  13. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/reducescatter.cuh +203 -0
  14. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/utils.cuh +54 -0
  15. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/common/nvshmemi_common_device.cuh +1037 -0
  16. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/common/nvshmemi_tile_utils.cuh +288 -0
  17. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/ibgda_device.cuh +0 -0
  18. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh +42 -0
  19. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/proxy_device.cuh +572 -0
  20. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/transfer_device.cuh +302 -0
  21. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/utils_device.h +111 -0
  22. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/team/nvshmemi_team_defines.cuh +174 -0
  23. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh +117 -0
  24. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/wait/nvshmemi_wait_until_apis.cuh +158 -0
  25. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmem_build_options.h +37 -0
  26. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmem_version.h +19 -0
  27. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmemx_error.h +161 -0
  28. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_mpi.so.3 +0 -0
  29. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmi.so.3 +0 -0
  30. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmi2.so.3 +0 -0
  31. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmix.so.3 +0 -0
  32. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_shmem.so.3 +0 -0
  33. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_uid.so.3 +0 -0
  34. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_transport_ucx.so.3 +0 -0
  35. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/__init__.py +0 -0
  36. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/__init__.py +0 -0
  37. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExt.h +1578 -0
  38. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtCuda.h +164 -0
  39. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtCudaRt.h +140 -0
  40. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtOpenCL.h +214 -0
  41. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtSync.h +406 -0
  42. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExt.h +1499 -0
  43. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCuda.h +170 -0
  44. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCudaRt.h +146 -0
  45. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtOpenCL.h +220 -0
  46. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtSync.h +411 -0
  47. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImpl.h +469 -0
  48. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCore.h +299 -0
  49. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCudaRt_v3.h +112 -0
  50. miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCuda_v3.h +133 -0
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/device_host_transport/nvshmem_constants.h ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEM_CONSTANTS_H_
14
+ #define _NVSHMEM_CONSTANTS_H_
15
+
16
+ #if !defined __CUDACC_RTC__
17
+ #include <limits.h>
18
+ #else
19
+ #include <cuda/std/climits>
20
+ #endif
21
+ #include "non_abi/nvshmem_version.h"
22
+
23
+ #define CHANNEL_BUF_SIZE (1 << CHANNEL_BUF_SIZE_LOG)
24
+ #define CHANNEL_BUF_SIZE_LOG 22
25
+ #define CHANNEL_ENTRY_BYTES 8
26
+
27
+ /* This is not the NVSHMEM release version, it is the supported OpenSHMEM spec version. */
28
+ #define NVSHMEM_MAJOR_VERSION 1
29
+ #define NVSHMEM_MINOR_VERSION 3
30
+
31
+ #define NVSHMEM_VENDOR_VERSION \
32
+ ((NVSHMEM_VENDOR_MAJOR_VERSION)*10000 + (NVSHMEM_VENDOR_MINOR_VERSION)*100 + \
33
+ (NVSHMEM_VENDOR_PATCH_VERSION))
34
+
35
+ #define NVSHMEMI_SUBST_AND_STRINGIFY_HELPER(S) #S
36
+ #define NVSHMEMI_SUBST_AND_STRINGIFY(S) NVSHMEMI_SUBST_AND_STRINGIFY_HELPER(S)
37
+
38
+ #define NVSHMEM_VENDOR_STRING \
39
+ "NVSHMEM v" \
40
+ NVSHMEMI_SUBST_AND_STRINGIFY(NVSHMEM_VENDOR_MAJOR_VERSION) "." \
41
+ NVSHMEMI_SUBST_AND_STRINGIFY(NVSHMEM_VENDOR_MINOR_VERSION) "." \
42
+ NVSHMEMI_SUBST_AND_STRINGIFY(NVSHMEM_VENDOR_PATCH_VERSION)
43
+
44
+ #define NVSHMEM_MAX_NAME_LEN 256
45
+
46
+ typedef enum nvshmemi_cmp_type {
47
+ NVSHMEM_CMP_EQ = 0,
48
+ NVSHMEM_CMP_NE,
49
+ NVSHMEM_CMP_GT,
50
+ NVSHMEM_CMP_LE,
51
+ NVSHMEM_CMP_LT,
52
+ NVSHMEM_CMP_GE,
53
+ NVSHMEM_CMP_SENTINEL = INT_MAX,
54
+ } nvshmemx_cmp_type_t;
55
+
56
+ enum nvshmemi_thread_support {
57
+ NVSHMEM_THREAD_SINGLE = 0,
58
+ NVSHMEM_THREAD_FUNNELED,
59
+ NVSHMEM_THREAD_SERIALIZED,
60
+ NVSHMEM_THREAD_MULTIPLE,
61
+ NVSHMEM_THREAD_TYPE_SENTINEL = INT_MAX,
62
+ };
63
+
64
+ enum {
65
+ PROXY_GLOBAL_EXIT_NOT_REQUESTED = 0,
66
+ PROXY_GLOBAL_EXIT_INIT,
67
+ PROXY_GLOBAL_EXIT_REQUESTED,
68
+ PROXY_GLOBAL_EXIT_FINISHED,
69
+ PROXY_GLOBAL_EXIT_MAX_STATE = INT_MAX
70
+ };
71
+
72
+ #define PROXY_DMA_REQ_BYTES 32
73
+ #define PROXY_AMO_REQ_BYTES 40
74
+ #define PROXY_INLINE_REQ_BYTES 24
75
+
76
+ typedef enum {
77
+ NVSHMEM_STATUS_NOT_INITIALIZED = 0,
78
+ NVSHMEM_STATUS_IS_BOOTSTRAPPED,
79
+ NVSHMEM_STATUS_IS_INITIALIZED,
80
+ NVSHMEM_STATUS_LIMITED_MPG,
81
+ NVSHMEM_STATUS_FULL_MPG,
82
+ NVSHMEM_STATUS_INVALID = INT_MAX,
83
+ } nvshmemx_init_status_t;
84
+
85
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_api.h ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEM_API_H_
14
+ #define _NVSHMEM_API_H_
15
+
16
+ #include <cuda_runtime.h>
17
+ #include <stdint.h>
18
+ #include <stddef.h>
19
+ #include <errno.h>
20
+ #include <stdio.h>
21
+ #include <stdlib.h>
22
+ #include <string.h>
23
+ #include "device_host/nvshmem_common.cuh"
24
+ #include "device_host_transport/nvshmem_constants.h"
25
+ #include "host/nvshmem_macros.h"
26
+ #include "non_abi/nvshmem_version.h"
27
+
28
+ int nvshmemi_init_thread(int requested_thread_support, int *provided_thread_support,
29
+ unsigned int bootstrap_flags, nvshmemx_init_attr_t *bootstrap_attr,
30
+ nvshmemi_version_t);
31
+
32
+ #ifdef __cplusplus
33
+ extern "C" {
34
+ #endif
35
+
36
+ #define NVSHMEMI_UNUSED_ARG(ARG) (void)(ARG)
37
+
38
+ // Library initialization
39
+ #define NONZERO_EXIT(status, ...) \
40
+ do { \
41
+ if (status != 0) { \
42
+ fprintf(stderr, "%s:%d: non-zero status: %d: %s, exiting... ", __FILE__, __LINE__, \
43
+ status, strerror(errno)); \
44
+ fprintf(stderr, __VA_ARGS__); \
45
+ exit(-1); \
46
+ } \
47
+ } while (0)
48
+
49
+ int nvshmemx_init_status();
50
+
51
+ static inline void nvshmem_init() {
52
+ int status = 0, requested = NVSHMEM_THREAD_SERIALIZED, provided;
53
+ nvshmemi_version_t app_nvshmem_version = {
54
+ NVSHMEM_VENDOR_MAJOR_VERSION, NVSHMEM_VENDOR_MINOR_VERSION, NVSHMEM_VENDOR_PATCH_VERSION};
55
+ status = nvshmemi_init_thread(requested, &provided, 0, NULL, app_nvshmem_version);
56
+ NONZERO_EXIT(status, "aborting due to error in nvshmemi_init_thread \n");
57
+ }
58
+
59
+ static inline int nvshmem_init_thread(int requested, int *provided) {
60
+ int status = 0;
61
+ nvshmemi_version_t app_nvshmem_version = {
62
+ NVSHMEM_VENDOR_MAJOR_VERSION, NVSHMEM_VENDOR_MINOR_VERSION, NVSHMEM_VENDOR_PATCH_VERSION};
63
+ status = nvshmemi_init_thread(requested, provided, 0, NULL, app_nvshmem_version);
64
+ NONZERO_EXIT(status, "aborting due to error in nvshmemi_init_thread \n");
65
+ return status;
66
+ }
67
+
68
+ void nvshmem_query_thread(int *provided);
69
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_global_exit(int status);
70
+ void nvshmemi_finalize();
71
+ static inline void nvshmem_finalize() { nvshmemi_finalize(); }
72
+
73
+ // PE info query
74
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_my_pe();
75
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_n_pes();
76
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_info_get_version(int *major, int *minor);
77
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_info_get_name(char *name);
78
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmemx_vendor_get_version_info(int *major, int *minor,
79
+ int *patch);
80
+
81
+ // Heap management
82
+ void *nvshmem_malloc(size_t size);
83
+ void *nvshmem_calloc(size_t, size_t);
84
+ void *nvshmem_align(size_t, size_t);
85
+
86
+ void nvshmem_free(void *ptr);
87
+ void *nvshmem_realloc(void *ptr, size_t size);
88
+ NVSHMEMI_HOSTDEVICE_PREFIX void *nvshmem_ptr(const void *ptr, int pe);
89
+ NVSHMEMI_HOSTDEVICE_PREFIX void *nvshmemx_mc_ptr(nvshmem_team_t team, const void *ptr);
90
+
91
+ //////////////////// OpenSHMEM 1.3 Atomics ////////////////////
92
+
93
+ #define NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(OPGRPNAME, opname) \
94
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(uint, unsigned int, opname) \
95
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(ulong, unsigned long, opname) \
96
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(ulonglong, unsigned long long, opname) \
97
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(int32, int32_t, opname) \
98
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(uint32, uint32_t, opname) \
99
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(int64, int64_t, opname) \
100
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(uint64, uint64_t, opname)
101
+
102
+ #define NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(OPGRPNAME, opname) \
103
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(int, int, opname) \
104
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(long, long, opname) \
105
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(longlong, long long, opname) \
106
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(size, size_t, opname) \
107
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(ptrdiff, ptrdiff_t, opname)
108
+
109
+ #define NVSHMEMI_REPT_OPGROUP_FOR_EXTENDED_AMO(OPGRPNAME, opname) \
110
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(float, float, opname) \
111
+ NVSHMEMI_DECL_TYPE_##OPGRPNAME(double, double, opname)
112
+
113
+ /* inc */
114
+ #define NVSHMEMI_DECL_TYPE_INC(type, TYPE, opname) \
115
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##type##_atomic_##opname(TYPE *dest, int pe);
116
+
117
+ /* finc */
118
+ #define NVSHMEMI_DECL_TYPE_FINC(type, TYPE, opname) \
119
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##type##_atomic_##opname(TYPE *dest, int pe);
120
+
121
+ /* fetch */
122
+ #define NVSHMEMI_DECL_TYPE_FETCH(type, TYPE, opname) \
123
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##type##_atomic_##opname(const TYPE *dest, int pe);
124
+
125
+ /* add, set */
126
+ #define NVSHMEMI_DECL_TYPE_ADD_SET(type, TYPE, opname) \
127
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##type##_atomic_##opname(TYPE *dest, TYPE value, \
128
+ int pe);
129
+
130
+ /* fadd, swap */
131
+ #define NVSHMEMI_DECL_TYPE_FADD_SWAP(type, TYPE, opname) \
132
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##type##_atomic_##opname(TYPE *dest, TYPE value, \
133
+ int pe);
134
+
135
+ /* cswap */
136
+ #define NVSHMEMI_DECL_TYPE_CSWAP(type, TYPE, opname) \
137
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##type##_atomic_##opname(TYPE *dest, TYPE cond, \
138
+ TYPE value, int pe);
139
+
140
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(INC, inc)
141
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(INC, inc)
142
+
143
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FINC, fetch_inc)
144
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(FINC, fetch_inc)
145
+
146
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FETCH, fetch)
147
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(FETCH, fetch)
148
+ NVSHMEMI_REPT_OPGROUP_FOR_EXTENDED_AMO(FETCH, fetch)
149
+
150
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(ADD_SET, add)
151
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(ADD_SET, add)
152
+
153
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(ADD_SET, set)
154
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(ADD_SET, set)
155
+ NVSHMEMI_REPT_OPGROUP_FOR_EXTENDED_AMO(ADD_SET, set)
156
+
157
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FADD_SWAP, fetch_add)
158
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(FADD_SWAP, fetch_add)
159
+
160
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FADD_SWAP, swap)
161
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(FADD_SWAP, swap)
162
+ NVSHMEMI_REPT_OPGROUP_FOR_EXTENDED_AMO(FADD_SWAP, swap)
163
+
164
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(CSWAP, compare_swap)
165
+ NVSHMEMI_REPT_OPGROUP_FOR_STANDARD_AMO(CSWAP, compare_swap)
166
+
167
+ #undef NVSHMEMI_DECL_TYPE_INC
168
+ #undef NVSHMEMI_DECL_TYPE_FINC
169
+ #undef NVSHMEMI_DECL_TYPE_FETCH
170
+ #undef NVSHMEMI_DECL_TYPE_ADD_SET
171
+ #undef NVSHMEMI_DECL_TYPE_FADD_SWAP
172
+ #undef NVSHMEMI_DECL_TYPE_CSWAP
173
+
174
+ //////////////////// OpenSHMEM 1.4 Atomics ////////////////////
175
+
176
+ /* and, or, xor */
177
+ #define NVSHMEMI_DECL_TYPE_AND_OR_XOR(type, TYPE, opname) \
178
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##type##_atomic_##opname(TYPE *dest, TYPE value, \
179
+ int pe);
180
+
181
+ /* fand, for, fxor */
182
+ #define NVSHMEMI_DECL_TYPE_FAND_FOR_FXOR(type, TYPE, opname) \
183
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##type##_atomic_fetch_##opname(TYPE *dest, TYPE value, \
184
+ int pe);
185
+
186
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(AND_OR_XOR, and)
187
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(AND_OR_XOR, or)
188
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(AND_OR_XOR, xor)
189
+
190
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FAND_FOR_FXOR, and)
191
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FAND_FOR_FXOR, or)
192
+ NVSHMEMI_REPT_OPGROUP_FOR_BITWISE_AMO(FAND_FOR_FXOR, xor)
193
+
194
+ #undef NVSHMEMI_DECL_TYPE_AND_OR_XOR
195
+ #undef NVSHMEMI_DECL_TYPE_FAND_FOR_FXOR
196
+
197
+ //////////////////// Put ////////////////////
198
+
199
+ #define NVSHMEMI_DECL_TYPE_P(NAME, TYPE) \
200
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_p(TYPE *dest, const TYPE value, int pe);
201
+
202
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_P)
203
+ #undef NVSHMEMI_DECL_TYPE_P
204
+
205
+ #define NVSHMEMI_DECL_TYPE_PUT(NAME, TYPE) \
206
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_put(TYPE *dest, const TYPE *source, \
207
+ size_t nelems, int pe);
208
+
209
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_PUT)
210
+ #undef NVSHMEMI_DECL_TYPE_PUT
211
+
212
+ #define NVSHMEMI_DECL_TYPE_PUT(NAME, TYPE) \
213
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_put(TYPE *dest, const TYPE *source, \
214
+ size_t nelems, int pe);
215
+
216
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_PUT)
217
+ #undef NVSHMEMI_DECL_TYPE_PUT
218
+
219
+ #define NVSHMEMI_DECL_SIZE_PUT(NAME) \
220
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_put##NAME(void *dest, const void *source, \
221
+ size_t nelems, int pe);
222
+
223
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_PUT)
224
+ #undef NVSHMEMI_DECL_SIZE_PUT
225
+
226
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_putmem(void *dest, const void *source, size_t bytes,
227
+ int pe);
228
+
229
+ #define NVSHMEMI_DECL_TYPE_IPUT(NAME, TYPE) \
230
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_iput( \
231
+ TYPE *dest, const TYPE *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int pe);
232
+
233
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_IPUT)
234
+ #undef NVSHMEMI_DECL_TYPE_IPUT
235
+
236
+ #define NVSHMEMI_DECL_SIZE_IPUT(NAME) \
237
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_iput##NAME( \
238
+ void *dest, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int pe);
239
+
240
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_IPUT)
241
+ #undef NVSHMEMI_DECL_SIZE_IPUT
242
+
243
+ #define NVSHMEMI_DECL_TYPE_PUT_NBI(NAME, TYPE) \
244
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_put_nbi(TYPE *dest, const TYPE *source, \
245
+ size_t nelems, int pe);
246
+
247
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_PUT_NBI)
248
+ #undef NVSHMEM_DECL_TYPE_PUT_NBI
249
+
250
+ #define NVSHMEMI_DECL_SIZE_PUT_NBI(NAME) \
251
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_put##NAME##_nbi(void *dest, const void *source, \
252
+ size_t nelems, int pe);
253
+
254
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_PUT_NBI)
255
+ #undef NVSHMEMI_DECL_SIZE_PUT_NBI
256
+
257
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_putmem_nbi(void *dest, const void *source, size_t bytes,
258
+ int pe);
259
+
260
+ //////////////////// Get ////////////////////
261
+
262
+ #define NVSHMEMI_DECL_TYPE_G(NAME, TYPE) \
263
+ NVSHMEMI_HOSTDEVICE_PREFIX TYPE nvshmem_##NAME##_g(const TYPE *src, int pe);
264
+
265
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_G)
266
+ #undef NVSHMEMI_DECL_TYPE_G
267
+
268
+ #define NVSHMEMI_DECL_TYPE_GET(NAME, TYPE) \
269
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_get(TYPE *dest, const TYPE *source, \
270
+ size_t nelems, int pe);
271
+
272
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_GET)
273
+ #undef NVSHMEMI_DECL_TYPE_GET
274
+
275
+ #define NVSHMEMI_DECL_SIZE_GET(NAME) \
276
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_get##NAME(void *dest, const void *source, \
277
+ size_t nelems, int pe);
278
+
279
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_GET)
280
+ #undef NVSHMEMI_DECL_SIZE_GET
281
+
282
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_getmem(void *dest, const void *source, size_t bytes,
283
+ int pe);
284
+
285
+ #define NVSHMEMI_DECL_TYPE_IGET(NAME, TYPE) \
286
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_iget( \
287
+ TYPE *dest, const TYPE *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int pe);
288
+
289
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_IGET)
290
+ #undef NVSHMEMI_DECL_TYPE_IGET
291
+
292
+ #define NVSHMEMI_DECL_SIZE_IGET(NAME) \
293
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_iget##NAME( \
294
+ void *dest, const void *source, ptrdiff_t dst, ptrdiff_t sst, size_t nelems, int pe);
295
+
296
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_IGET)
297
+ #undef NVSHMEMI_DECL_SIZE_IGET
298
+
299
+ #define NVSHMEMI_DECL_TYPE_GET_NBI(NAME, TYPE) \
300
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_##NAME##_get_nbi(TYPE *dest, const TYPE *source, \
301
+ size_t nelems, int pe);
302
+
303
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_TYPE_GET_NBI)
304
+ #undef NVSHMEMI_DECL_TYPE_GET_NBI
305
+
306
+ #define NVSHMEMI_DECL_SIZE_GET_NBI(NAME) \
307
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_get##NAME##_nbi(void *dest, const void *source, \
308
+ size_t nelems, int pe);
309
+
310
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_GET_NBI)
311
+ #undef NVSHMEMI_DECL_SIZE_GET_NBI
312
+
313
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_getmem_nbi(void *dest, const void *source, size_t bytes,
314
+ int pe);
315
+
316
+ #ifdef __CUDACC__
317
+ /* Signal API */
318
+ #define NVSHMEMI_DECL_PUT_SIGNAL(TYPENAME, TYPE) \
319
+ __device__ void nvshmem_##TYPENAME##_put_signal(TYPE *dest, const TYPE *source, size_t nelems, \
320
+ uint64_t *sig_addr, uint64_t signal, \
321
+ int sig_op, int pe);
322
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_PUT_SIGNAL)
323
+ #undef NVSHMEMI_DECL_PUT_SIGNAL
324
+
325
+ #define NVSHMEMI_DECL_PUT_SIGNAL_NBI(TYPENAME, TYPE) \
326
+ __device__ void nvshmem_##TYPENAME##_put_signal_nbi(TYPE *dest, const TYPE *source, \
327
+ size_t nelems, uint64_t *sig_addr, \
328
+ uint64_t signal, int sig_op, int pe);
329
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMI_DECL_PUT_SIGNAL_NBI)
330
+ #undef NVSHMEMI_DECL_PUT_SIGNAL_NBI
331
+ #endif
332
+
333
+ #ifdef __CUDACC__
334
+ #define NVSHMEMI_DECL_SIZE_PUT_SIGNAL(BITS) \
335
+ __device__ void nvshmem_put##BITS##_signal(void *dest, const void *source, size_t nelems, \
336
+ uint64_t *sig_addr, uint64_t signal, int sig_op, \
337
+ int pe);
338
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_PUT_SIGNAL)
339
+ #undef NVSHMEMI_DECL_SIZE_PUT_SIGNAL
340
+
341
+ #define NVSHMEMI_DECL_SIZE_PUT_SIGNAL_NBI(BITS) \
342
+ __device__ void nvshmem_put##BITS##_signal_nbi(void *dest, const void *source, size_t nelems, \
343
+ uint64_t *sig_addr, uint64_t signal, \
344
+ int sig_op, int pe);
345
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMI_DECL_SIZE_PUT_SIGNAL_NBI)
346
+ #undef NVSHMEMI_DECL_SIZE_PUT_SIGNAL_NBI
347
+
348
+ __device__ void nvshmem_putmem_signal(void *dest, const void *source, size_t bytes,
349
+ uint64_t *sig_addr, uint64_t signal, int sig_op, int pe);
350
+
351
+ __device__ void nvshmem_putmem_signal_nbi(void *dest, const void *source, size_t bytes,
352
+ uint64_t *sig_addr, uint64_t signal, int sig_op, int pe);
353
+ #endif
354
+
355
+ NVSHMEMI_HOSTDEVICE_PREFIX uint64_t nvshmem_signal_fetch(uint64_t *sig_addr);
356
+
357
+ //////////////////// Point-to-Point Synchronization ////////////////////
358
+
359
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_quiet();
360
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_fence();
361
+ #ifdef __CUDACC__
362
+ __device__ uint64_t nvshmem_signal_wait_until(uint64_t *sig_addr, int cmp, uint64_t cmp_val);
363
+
364
+ #define NVSHMEMI_DECL_WAIT_UNTIL(NAME, TYPE) \
365
+ __device__ void nvshmem_##NAME##_wait_until(TYPE *ivar, int cmp, TYPE cmp_value);
366
+
367
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL)
368
+ #undef NVSHMEMI_DECL_WAIT_UNTIL
369
+
370
+ #define NVSHMEMI_DECL_WAIT_UNTIL_ALL(NAME, TYPE) \
371
+ __device__ void nvshmem_##NAME##_wait_until_all(TYPE *ivar, size_t nelems, const int *status, \
372
+ int cmp, TYPE cmp_value);
373
+
374
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_ALL)
375
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_ALL
376
+
377
+ #define NVSHMEMI_DECL_WAIT_UNTIL_ANY(NAME, TYPE) \
378
+ __device__ size_t nvshmem_##NAME##_wait_until_any(TYPE *ivar, size_t nelems, \
379
+ const int *status, int cmp, TYPE cmp_value);
380
+
381
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_ANY)
382
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_ANY
383
+
384
+ #define NVSHMEMI_DECL_WAIT_UNTIL_SOME(NAME, TYPE) \
385
+ __device__ size_t nvshmem_##NAME##_wait_until_some( \
386
+ TYPE *ivar, size_t nelems, size_t *indices, const int *status, int cmp, TYPE cmp_value);
387
+
388
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_SOME)
389
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_SOME
390
+
391
+ #define NVSHMEMI_DECL_WAIT_UNTIL_ALL_VECTOR(NAME, TYPE) \
392
+ __device__ void nvshmem_##NAME##_wait_until_all_vector( \
393
+ TYPE *ivars, size_t nelems, const int *status, int cmp, TYPE *cmp_values);
394
+
395
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_ALL_VECTOR)
396
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_ALL_VECTOR
397
+
398
+ #define NVSHMEMI_DECL_WAIT_UNTIL_ANY_VECTOR(NAME, TYPE) \
399
+ __device__ size_t nvshmem_##NAME##_wait_until_any_vector( \
400
+ TYPE *ivars, size_t nelems, const int *status, int cmp, TYPE *cmp_values);
401
+
402
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_ANY_VECTOR)
403
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_ANY_VECTOR
404
+
405
+ #define NVSHMEMI_DECL_WAIT_UNTIL_SOME_VECTOR(NAME, TYPE) \
406
+ __device__ size_t nvshmem_##NAME##_wait_until_some_vector(TYPE *ivars, size_t nelems, \
407
+ size_t *indices, const int *status, \
408
+ int cmp, TYPE *cmp_values);
409
+
410
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_WAIT_UNTIL_SOME_VECTOR)
411
+ #undef NVSHMEMI_DECL_WAIT_UNTIL_SOME_VECTOR
412
+
413
+ #define NVSHMEMI_DECL_TEST(NAME, TYPE) \
414
+ __device__ int nvshmem_##NAME##_test(TYPE *ivar, int cmp, TYPE cmp_value);
415
+
416
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST)
417
+ #undef NVSHMEMI_DECL_TEST
418
+
419
+ #define NVSHMEMI_DECL_TEST_ALL(Name, Type) \
420
+ __device__ int nvshmem_##Name##_test_all(Type *ivars, size_t nelems, const int *status, \
421
+ int cmp, Type cmp_value);
422
+
423
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_ALL)
424
+ #undef NVSHMEMI_DECL_TEST_ALL
425
+
426
+ #define NVSHMEMI_DECL_TEST_ANY(Name, Type) \
427
+ __device__ size_t nvshmem_##Name##_test_any(Type *ivars, size_t nelems, const int *status, \
428
+ int cmp, Type cmp_value);
429
+
430
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_ANY)
431
+ #undef NVSHMEMI_DECL_TEST_ANY
432
+
433
+ #define NVSHMEMI_DECL_TEST_SOME(Name, Type) \
434
+ __device__ size_t nvshmem_##Name##_test_some(Type *ivars, size_t nelems, size_t *indices, \
435
+ const int *status, int cmp, Type cmp_value);
436
+
437
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_SOME)
438
+ #undef NVSHMEMI_DECL_TEST_SOME
439
+
440
+ #define NVSHMEMI_DECL_TEST_ALL_VECTOR(NAME, TYPE) \
441
+ __device__ int nvshmem_##NAME##_test_all_vector(TYPE *ivars, size_t nelems, const int *status, \
442
+ int cmp, TYPE *cmp_values);
443
+
444
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_ALL_VECTOR)
445
+ #undef NVSHMEMI_DECL_TEST_ALL_VECTOR
446
+
447
+ #define NVSHMEMI_DECL_TEST_ANY_VECTOR(NAME, TYPE) \
448
+ __device__ size_t nvshmem_##NAME##_test_any_vector( \
449
+ TYPE *ivars, size_t nelems, const int *status, int cmp, TYPE *cmp_values);
450
+
451
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_ANY_VECTOR)
452
+ #undef NVSHMEMI_DECL_TEST_ANY_VECTOR
453
+
454
+ #define NVSHMEMI_DECL_TEST_SOME_VECTOR(NAME, TYPE) \
455
+ __device__ size_t nvshmem_##NAME##_test_some_vector(TYPE *ivars, size_t nelems, \
456
+ size_t *indices, const int *status, \
457
+ int cmp, TYPE *cmp_values);
458
+
459
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMI_DECL_TEST_SOME_VECTOR)
460
+ #undef NVSHMEMI_DECL_TEST_SOME_VECTOR
461
+ #endif /* __CUDACC__ */
462
+
463
+ //////////////////// Teams API ////////////////////
464
+
465
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_team_my_pe(nvshmem_team_t team);
466
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_team_n_pes(nvshmem_team_t team);
467
+
468
+ void nvshmem_team_get_config(nvshmem_team_t team, nvshmem_team_config_t *config);
469
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_team_translate_pe(nvshmem_team_t src_team, int src_pe,
470
+ nvshmem_team_t dest_team);
471
+ int nvshmem_team_split_strided(nvshmem_team_t parent_team, int PE_start, int PE_stride, int PE_size,
472
+ const nvshmem_team_config_t *config, long config_mask,
473
+ nvshmem_team_t *new_team);
474
+
475
+ int nvshmemx_team_get_uniqueid(nvshmemx_team_uniqueid_t *uniqueid);
476
+ int nvshmemx_team_init(nvshmem_team_t *team, nvshmem_team_config_t *config, long config_mask,
477
+ int npes, int pe_idx_in_team);
478
+ int nvshmem_team_split_2d(nvshmem_team_t parent_team, int xrange,
479
+ const nvshmem_team_config_t *xaxis_config, long xaxis_mask,
480
+ nvshmem_team_t *xaxis_team, const nvshmem_team_config_t *yaxis_config,
481
+ long yaxis_mask, nvshmem_team_t *yaxis_team);
482
+ void nvshmem_team_destroy(nvshmem_team_t team);
483
+
484
+ #ifdef __cplusplus
485
+ }
486
+ #endif
487
+
488
+ #include "host/nvshmem_coll_api.h"
489
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_coll_api.h ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEM_COLL_API_H_
14
+ #define _NVSHMEM_COLL_API_H_
15
+ #include "device_host/nvshmem_types.h"
16
+ #include "device_host/nvshmem_common.cuh"
17
+ #include "host/nvshmem_macros.h"
18
+
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+ //===============================
23
+ // standard nvshmem collective calls
24
+ //===============================
25
+
26
+ // alltoall(s) collectives
27
+ #define DECL_NVSHMEM_TYPENAME_ALLTOALL(TYPENAME, TYPE) \
28
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##TYPENAME##_alltoall(nvshmem_team_t team, TYPE *dest, \
29
+ const TYPE *src, size_t nelems);
30
+
31
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEM_TYPENAME_ALLTOALL)
32
+ #undef DECL_NVSHMEM_TYPENAME_ALLTOALL
33
+
34
+ #define DECL_NVSHMEM_TYPENAME_ALLTOALLS(TYPENAME, TYPE) \
35
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##TYPENAME##_alltoalls(nvshmem_team_t team, TYPE *dest, \
36
+ const TYPE *src, ptrdiff_t dst, \
37
+ ptrdiff_t sst, size_t nelems);
38
+
39
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEM_TYPENAME_ALLTOALLS)
40
+ #undef DECL_NVSHMEM_TYPENAME_ALLTOALLS
41
+
42
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_alltoallmem(nvshmem_team_t team, void *dest, const void *src,
43
+ size_t nelems);
44
+
45
+ // barrier collectives
46
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_barrier(nvshmem_team_t team);
47
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_barrier_all();
48
+
49
+ // sync collectives
50
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_team_sync(nvshmem_team_t team);
51
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmem_sync_all();
52
+ #define nvshmem_sync nvshmem_team_sync
53
+
54
+ // broadcast collectives
55
+ #define DECL_NVSHMEM_TYPENAME_BROADCAST(TYPENAME, TYPE) \
56
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##TYPENAME##_broadcast( \
57
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nelem, int PE_root);
58
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEM_TYPENAME_BROADCAST)
59
+ #undef DECL_NVSHMEM_TYPENAME_BROADCAST
60
+
61
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_broadcastmem(nvshmem_team_t team, void *dest,
62
+ const void *src, size_t nelems, int PE_root);
63
+
64
+ // fcollect collective
65
+ #define DECL_NVSHMEM_TYPENAME_FCOLLECT(TYPENAME, TYPE) \
66
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##TYPENAME##_fcollect(nvshmem_team_t team, TYPE *dest, \
67
+ const TYPE *src, size_t nelem);
68
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEM_TYPENAME_FCOLLECT)
69
+ #undef DECL_NVSHMEM_TYPENAME_FCOLLECT
70
+
71
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_fcollectmem(nvshmem_team_t team, void *dest, const void *src,
72
+ size_t nelems);
73
+ // reduction collectives
74
+ #define NVSHMEMI_DECL_TEAM_REDUCE(NAME, TYPE, OP) \
75
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##NAME##_##OP##_reduce( \
76
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce);
77
+
78
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, and)
79
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, or)
80
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, xor)
81
+
82
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, max)
83
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, min)
84
+
85
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, sum)
86
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCE, prod)
87
+
88
+ #undef NVSHMEMI_DECL_TEAM_REDUCE
89
+
90
+ // reducescatter collectives
91
+ #define NVSHMEMI_DECL_TEAM_REDUCESCATTER(NAME, TYPE, OP) \
92
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmem_##NAME##_##OP##_reducescatter( \
93
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce);
94
+
95
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, and)
96
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, or)
97
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, xor)
98
+
99
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, max)
100
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, min)
101
+
102
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, sum)
103
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_TEAM_REDUCESCATTER, prod)
104
+
105
+ #undef NVSHMEMI_DECL_TEAM_REDUCESCATTER
106
+
107
+ #ifdef __cplusplus
108
+ }
109
+ #endif
110
+
111
+ #endif /* NVSHMEM_COLL_H */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmem_macros.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #ifndef _NVSHMEM_MACROS_H_
3
+ #define _NVSHMEM_MACROS_H_
4
+
5
+ #include <cuda_runtime.h>
6
+ #include "non_abi/nvshmem_build_options.h"
7
+
8
+ #ifdef __CUDA_ARCH__
9
+ #ifdef NVSHMEMI_HOST_ONLY
10
+ #define NVSHMEMI_HOSTDEVICE_PREFIX __host__
11
+ #else
12
+ #define NVSHMEMI_HOSTDEVICE_PREFIX __host__ __device__
13
+ #endif
14
+ #else
15
+ #define NVSHMEMI_HOSTDEVICE_PREFIX
16
+ #endif
17
+
18
+ #if defined NVSHMEM_HOSTLIB_ONLY
19
+ #undef NVSHMEMI_HOSTDEVICE_PREFIX
20
+ #define NVSHMEMI_HOSTDEVICE_PREFIX __host__ __device__ __attribute__((always_inline))
21
+ #endif
22
+
23
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmemx_api.h ADDED
@@ -0,0 +1,470 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEMX_API_H_
14
+ #define _NVSHMEMX_API_H_
15
+
16
+ #include <cuda.h>
17
+ #include <cuda_runtime.h>
18
+ #include <stdint.h>
19
+ #include <stddef.h>
20
+ #include "device_host_transport/nvshmem_constants.h"
21
+ #include "device_host/nvshmem_common.cuh"
22
+ #include "non_abi/nvshmem_version.h"
23
+ #include "host/nvshmemx_coll_api.h"
24
+ #include "host/nvshmem_macros.h"
25
+ #include "non_abi/nvshmemx_error.h"
26
+ #include "host/nvshmem_api.h"
27
+
28
+ int nvshmemi_collective_launch(const void *func, dim3 gridDims, dim3 blockDims, void **args,
29
+ size_t sharedMem, cudaStream_t stream);
30
+
31
+ int nvshmemi_collective_launch_query_gridsize(const void *func, dim3 blockDims, void **args,
32
+ size_t sharedMem, int *gridsize);
33
+
34
+ #ifdef __cplusplus
35
+ extern "C" {
36
+ #endif
37
+
38
+ enum flags {
39
+ NVSHMEMX_INIT_THREAD_PES = 1,
40
+ NVSHMEMX_INIT_WITH_MPI_COMM = 1 << 1,
41
+ NVSHMEMX_INIT_WITH_SHMEM = 1 << 2,
42
+ NVSHMEMX_INIT_WITH_UNIQUEID = 1 << 3,
43
+ NVSHMEMX_INIT_MAX = 1 << 31
44
+ };
45
+
46
+ // Heap management extensions
47
+ int nvshmemx_buffer_register(void *addr, size_t length);
48
+ int nvshmemx_buffer_unregister(void *addr);
49
+ void nvshmemx_buffer_unregister_all();
50
+
51
+ // Initialization & Finalization extensions
52
+ int nvshmemx_hostlib_init_attr(unsigned int flags, nvshmemx_init_attr_t *attr);
53
+ void nvshmemx_hostlib_finalize();
54
+
55
+ static inline int nvshmemx_init_attr(unsigned int flags, nvshmemx_init_attr_t *attributes) {
56
+ int status = 0, requested = NVSHMEM_THREAD_SERIALIZED, provided;
57
+ nvshmemi_version_t app_nvshmem_version = {
58
+ NVSHMEM_VENDOR_MAJOR_VERSION, NVSHMEM_VENDOR_MINOR_VERSION, NVSHMEM_VENDOR_PATCH_VERSION};
59
+ if (attributes != NULL) {
60
+ nvshmemx_init_init_attr_ver_only((*attributes));
61
+ }
62
+ status = nvshmemi_init_thread(requested, &provided, flags, attributes, app_nvshmem_version);
63
+ NONZERO_EXIT(status, "aborting due to error in nvshmemi_init_thread \n");
64
+ return status;
65
+ }
66
+
67
+ int nvshmemx_set_attr_uniqueid_args(const int myrank, const int nranks,
68
+ const nvshmemx_uniqueid_t *uniqueid,
69
+ nvshmemx_init_attr_t *attr);
70
+ int nvshmemx_set_attr_mpi_comm_args(void *mpi_comm, nvshmemx_init_attr_t *nvshmem_attr);
71
+ int nvshmemx_get_uniqueid(nvshmemx_uniqueid_t *uniqueid);
72
+
73
+ int nvshmemx_cumodule_init(CUmodule module);
74
+ int nvshmemx_cumodule_finalize(CUmodule module);
75
+
76
+ void *nvshmemx_buffer_register_symmetric(void *buf_ptr, size_t size, int flags);
77
+ int nvshmemx_buffer_unregister_symmetric(void *mmap_ptr, size_t size);
78
+ #if defined(CUDA_VERSION) && CUDART_VERSION < 12000
79
+ /**
80
+ * CULibrary is a CUDA 12 type
81
+ * This is handled "correctly" by wrappers in `cudawrap.h`
82
+ * But that's not #include-able from here since it's in `internal/`
83
+ * This type needs to match the one in `cudawrap.h`
84
+ */
85
+ typedef void *CUlibrary;
86
+ #endif
87
+
88
+ int nvshmemx_culibrary_init(CUlibrary library);
89
+ int nvshmemx_culibrary_finalize(CUlibrary library);
90
+
91
+ //////////////////// Put On Stream ////////////////////
92
+
93
+ #define NVSHMEMX_DECL_TYPE_P_ON_STREAM(NAME, TYPE) \
94
+ void nvshmemx_##NAME##_p_on_stream(TYPE *dest, const TYPE value, int pe, cudaStream_t cstrm);
95
+
96
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_P_ON_STREAM)
97
+ #undef NVSHMEMX_DECL_TYPE_P_ON_STREAM
98
+
99
+ #define NVSHMEMX_DECL_TYPE_PUT_ON_STREAM(NAME, TYPE) \
100
+ void nvshmemx_##NAME##_put_on_stream(TYPE *dest, const TYPE *source, size_t nelems, int pe, \
101
+ cudaStream_t cstrm);
102
+
103
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_ON_STREAM)
104
+ #undef NVSHMEMX_DECL_TYPE_PUT_ON_STREAM
105
+
106
+ #define NVSHMEMX_DECL_SIZE_PUT_ON_STREAM(NAME) \
107
+ void nvshmemx_put##NAME##_on_stream(void *dest, const void *source, size_t nelems, int pe, \
108
+ cudaStream_t cstrm);
109
+
110
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_ON_STREAM)
111
+ #undef NVSHMEMX_DECL_SIZE_PUT_ON_STREAM
112
+
113
+ void nvshmemx_putmem_on_stream(void *dest, const void *source, size_t bytes, int pe,
114
+ cudaStream_t cstrm);
115
+
116
+ #define NVSHMEMX_DECL_TYPE_PUT_SIGNAL_ON_STREAM(NAME, TYPE) \
117
+ void nvshmemx_##NAME##_put_signal_on_stream(TYPE *dest, const TYPE *source, size_t nelems, \
118
+ uint64_t *sig_addr, uint64_t signal, int sig_op, \
119
+ int pe, cudaStream_t cstrm);
120
+
121
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_SIGNAL_ON_STREAM)
122
+ #undef NVSHMEMX_DECL_TYPE_PUT_SIGNAL_ON_STREAM
123
+
124
+ #define NVSHMEMX_DECL_SIZE_PUT_SIGNAL_ON_STREAM(NAME) \
125
+ void nvshmemx_put##NAME##_signal_on_stream(void *dest, const void *source, size_t nelems, \
126
+ uint64_t *sig_addr, uint64_t signal, int sig_op, \
127
+ int pe, cudaStream_t cstrm);
128
+
129
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_SIGNAL_ON_STREAM)
130
+ #undef NVSHMEMX_DECL_SIZE_PUT_SIGNAL_ON_STREAM
131
+
132
+ void nvshmemx_putmem_signal_on_stream(void *dest, const void *source, size_t bytes,
133
+ uint64_t *sig_addr, uint64_t signal, int sig_op, int pe,
134
+ cudaStream_t cstrm);
135
+
136
+ #define NVSHMEMX_DECL_TYPE_PUT_SIGNAL_NBI_ON_STREAM(NAME, TYPE) \
137
+ void nvshmemx_##NAME##_put_signal_nbi_on_stream(TYPE *dest, const TYPE *source, size_t nelems, \
138
+ uint64_t *sig_addr, uint64_t signal, \
139
+ int sig_op, int pe, cudaStream_t cstrm);
140
+
141
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_SIGNAL_NBI_ON_STREAM)
142
+ #undef NVSHMEMX_DECL_TYPE_PUT_SIGNAL_NBI_ON_STREAM
143
+
144
+ #define NVSHMEMX_DECL_SIZE_PUT_SIGNAL_NBI_ON_STREAM(NAME) \
145
+ void nvshmemx_put##NAME##_signal_nbi_on_stream(void *dest, const void *source, size_t nelems, \
146
+ uint64_t *sig_addr, uint64_t signal, \
147
+ int sig_op, int pe, cudaStream_t cstrm);
148
+
149
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_SIGNAL_NBI_ON_STREAM)
150
+ #undef NVSHMEMX_DECL_SIZE_PUT_SIGNAL_NBI_ON_STREAM
151
+
152
+ void nvshmemx_putmem_signal_nbi_on_stream(void *dest, const void *source, size_t bytes,
153
+ uint64_t *sig_addr, uint64_t signal, int sig_op, int pe,
154
+ cudaStream_t cstrm);
155
+
156
+ #define NVSHMEMX_DECL_TYPE_IPUT_ON_STREAM(NAME, TYPE) \
157
+ void nvshmemx_##NAME##_iput_on_stream(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
158
+ ptrdiff_t sst, size_t nelems, int pe, \
159
+ cudaStream_t cstrm);
160
+
161
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_IPUT_ON_STREAM)
162
+ #undef NVSHMEMX_DECL_TYPE_IPUT_ON_STREAM
163
+
164
+ #define NVSHMEMX_DECL_SIZE_IPUT_ON_STREAM(NAME) \
165
+ void nvshmemx_iput##NAME##_on_stream(void *dest, const void *source, ptrdiff_t dst, \
166
+ ptrdiff_t sst, size_t nelems, int pe, \
167
+ cudaStream_t cstrm);
168
+
169
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_IPUT_ON_STREAM)
170
+ #undef NVSHMEMX_DECL_SIZE_IPUT_ON_STREAM
171
+
172
+ #define NVSHMEMX_DECL_TYPE_PUT_NBI_ON_STREAM(NAME, TYPE) \
173
+ void nvshmemx_##NAME##_put_nbi_on_stream(TYPE *dest, const TYPE *source, size_t nelems, \
174
+ int pe, cudaStream_t cstrm);
175
+
176
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_NBI_ON_STREAM)
177
+ #undef NVSHMEMX_DECL_TYPE_PUT_NBI_ON_STREAM
178
+
179
+ #define NVSHMEMX_DECL_SIZE_PUT_NBI_ON_STREAM(NAME) \
180
+ void nvshmemx_put##NAME##_nbi_on_stream(void *dest, const void *source, size_t nelems, int pe, \
181
+ cudaStream_t cstrm);
182
+
183
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_NBI_ON_STREAM)
184
+ #undef NVSHMEMX_DECL_SIZE_PUT_NBI_ON_STREAM
185
+
186
+ void nvshmemx_putmem_nbi_on_stream(void *dest, const void *source, size_t bytes, int pe,
187
+ cudaStream_t cstrm);
188
+
189
+ //////////////////// Get On Stream ////////////////////
190
+
191
+ #define NVSHMEMX_DECL_TYPE_G_ON_STREAM(NAME, TYPE) \
192
+ TYPE nvshmemx_##NAME##_g_on_stream(const TYPE *src, int pe, cudaStream_t cstrm);
193
+
194
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_G_ON_STREAM)
195
+ #undef NVSHMEMX_DECL_TYPE_G_ON_STREAM
196
+
197
+ #define NVSHMEMX_DECL_TYPE_GET_ON_STREAM(NAME, TYPE) \
198
+ void nvshmemx_##NAME##_get_on_stream(TYPE *dest, const TYPE *source, size_t nelems, int pe, \
199
+ cudaStream_t cstrm);
200
+
201
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_GET_ON_STREAM)
202
+ #undef NVSHMEMX_DECL_TYPE_GET_ON_STREAM
203
+
204
+ #define NVSHMEMX_DECL_TYPE_IGET_ON_STREAM(NAME, TYPE) \
205
+ void nvshmemx_##NAME##_iget_on_stream(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
206
+ ptrdiff_t sst, size_t nelems, int pe, \
207
+ cudaStream_t cstrm);
208
+
209
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_IGET_ON_STREAM)
210
+ #undef NVSHMEMX_DECL_TYPE_IGET_ON_STREAM
211
+
212
+ #define NVSHMEMX_DECL_SIZE_GET_ON_STREAM(NAME) \
213
+ void nvshmemx_get##NAME##_on_stream(void *dest, const void *source, size_t nelems, int pe, \
214
+ cudaStream_t cstrm);
215
+
216
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_GET_ON_STREAM)
217
+ #undef NVSHMEMX_DECL_SIZE_GET_ON_STREAM
218
+
219
+ void nvshmemx_getmem_on_stream(void *dest, const void *source, size_t bytes, int pe,
220
+ cudaStream_t cstrm);
221
+
222
+ #define NVSHMEMX_DECL_SIZE_IGET_ON_STREAM(NAME) \
223
+ void nvshmemx_iget##NAME##_on_stream(void *dest, const void *source, ptrdiff_t dst, \
224
+ ptrdiff_t sst, size_t nelems, int pe, \
225
+ cudaStream_t cstrm);
226
+
227
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_IGET_ON_STREAM)
228
+ #undef NVSHMEMX_DECL_SIZE_IGET_ON_STREAM
229
+
230
+ #define NVSHMEMX_DECL_TYPE_GET_NBI_ON_STREAM(NAME, TYPE) \
231
+ void nvshmemx_##NAME##_get_nbi_on_stream(TYPE *dest, const TYPE *source, size_t nelems, \
232
+ int pe, cudaStream_t cstrm);
233
+
234
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_GET_NBI_ON_STREAM)
235
+ #undef NVSHMEMX_DECL_TYPE_GET_NBI_ON_STREAM
236
+
237
+ #define NVSHMEMX_DECL_SIZE_GET_NBI_ON_STREAM(NAME) \
238
+ void nvshmemx_get##NAME##_nbi_on_stream(void *dest, const void *source, size_t nelems, int pe, \
239
+ cudaStream_t cstrm);
240
+
241
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_GET_NBI_ON_STREAM)
242
+ #undef NVSHMEMX_DECL_SIZE_GET_NBI_ON_STREAM
243
+
244
+ void nvshmemx_getmem_nbi_on_stream(void *dest, const void *source, size_t bytes, int pe,
245
+ cudaStream_t cstrm);
246
+
247
+ //////////////////// Synchronization On Stream ////////////////////
248
+
249
+ void nvshmemx_quiet_on_stream(cudaStream_t cstrm);
250
+
251
+ void nvshmemx_signal_op_on_stream(uint64_t *sig_addr, uint64_t signal, int sig_op, int pe,
252
+ cudaStream_t cstrm);
253
+
254
+ #define NVSHMEMX_DECL_WAIT_UNTIL_ON_STREAM(NAME, Type) \
255
+ void nvshmemx_##NAME##_wait_until_on_stream(Type *ivar, int cmp, Type cmp_value, \
256
+ cudaStream_t cstream);
257
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMX_DECL_WAIT_UNTIL_ON_STREAM)
258
+ #undef NVSHMEMX_DECL_WAIT_UNTIL_ON_STREAM
259
+
260
+ #define NVSHMEMX_DECL_WAIT_UNTIL_ALL_ON_STREAM(NAME, Type) \
261
+ void nvshmemx_##NAME##_wait_until_all_on_stream(Type *ivars, size_t nelems, const int *status, \
262
+ int cmp, Type cmp_value, \
263
+ cudaStream_t cstream);
264
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMX_DECL_WAIT_UNTIL_ALL_ON_STREAM)
265
+ #undef NVSHMEMX_DECL_WAIT_UNTIL_ALL_ON_STREAM
266
+
267
+ #define NVSHMEMX_DECL_WAIT_UNTIL_ALL_VECTOR_ON_STREAM(NAME, Type) \
268
+ void nvshmemx_##NAME##_wait_until_all_vector_on_stream(Type *ivars, size_t nelems, \
269
+ const int *status, int cmp, \
270
+ Type *cmp_value, cudaStream_t cstream);
271
+ NVSHMEMI_REPT_FOR_WAIT_TYPES(NVSHMEMX_DECL_WAIT_UNTIL_ALL_VECTOR_ON_STREAM)
272
+ #undef NVSHMEMX_DECL_WAIT_UNTIL_ALL_VECTOR_ON_STREAM
273
+
274
+ void nvshmemx_signal_wait_until_on_stream(uint64_t *sig_addr, int cmp, uint64_t cmp_value,
275
+ cudaStream_t cstream);
276
+ //////////////////// Put on Thread Group ////////////////////
277
+
278
+ #define NVSHMEMX_DECL_TYPE_PUT_THREADGROUP(NAME, TYPE) \
279
+ __device__ void nvshmemx_##NAME##_put_warp(TYPE *dest, const TYPE *source, size_t nelems, \
280
+ int pe); \
281
+ __device__ void nvshmemx_##NAME##_put_block(TYPE *dest, const TYPE *source, size_t nelems, \
282
+ int pe);
283
+
284
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_THREADGROUP)
285
+ #undef NVSHMEMX_DECL_TYPE_PUT_THREADGROUP
286
+
287
+ #define NVSHMEMX_DECL_SIZE_PUT_THREADGROUP(NAME) \
288
+ __device__ void nvshmemx_put##NAME##_warp(void *dest, const void *source, size_t nelems, \
289
+ int pe); \
290
+ __device__ void nvshmemx_put##NAME##_block(void *dest, const void *source, size_t nelems, \
291
+ int pe);
292
+
293
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_THREADGROUP)
294
+ #undef NVSHMEMX_DECL_SIZE_PUT_THREADGROUP
295
+
296
+ __device__ void nvshmemx_putmem_warp(void *dest, const void *source, size_t bytes, int pe);
297
+ __device__ void nvshmemx_putmem_block(void *dest, const void *source, size_t bytes, int pe);
298
+
299
+ /* __device__ nvshmem_<typename>_put_signal_scope */
300
+ #define NVSHMEMI_TYPENAME_PUT_SIGNAL_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX, TYPENAME, TYPE) \
301
+ __device__ void nvshmemx_##TYPENAME##_put_signal##SC_SUFFIX( \
302
+ TYPE *dest, const TYPE *source, size_t nelems, uint64_t *sig_addr, uint64_t signal, \
303
+ int sig_op, int pe);
304
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE2(NVSHMEMI_TYPENAME_PUT_SIGNAL_SCOPE_DECL, warp,
305
+ _warp, x)
306
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE2(NVSHMEMI_TYPENAME_PUT_SIGNAL_SCOPE_DECL, block,
307
+ _block, x)
308
+ #undef NVSHMEMI_TYPENAME_PUT_SIGNAL_SCOPE_DECL
309
+
310
+ /* __device__ nvshmem_putmem_signal_scope */
311
+ #define NVSHMEMI_PUTMEM_SIGNAL_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX) \
312
+ __device__ void nvshmemx_putmem_signal##SC_SUFFIX(void *dest, const void *source, \
313
+ size_t nelems, uint64_t *sig_addr, \
314
+ uint64_t signal, int sig_op, int pe);
315
+
316
+ NVSHMEMI_PUTMEM_SIGNAL_SCOPE_DECL(warp, _warp, x)
317
+ NVSHMEMI_PUTMEM_SIGNAL_SCOPE_DECL(block, _block, x)
318
+ #undef NVSHMEMI_PUTMEM_SIGNAL_SCOPE_DECL
319
+
320
+ /* __device__ nvshmem_putsize_signal_scope */
321
+ #define NVSHMEMI_PUTSIZE_SIGNAL_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX, BITS) \
322
+ __device__ void nvshmemx_put##BITS##_signal##SC_SUFFIX(void *dest, const void *source, \
323
+ size_t nelems, uint64_t *sig_addr, \
324
+ uint64_t signal, int sig_op, int pe);
325
+
326
+ NVSHMEMI_REPT_FOR_SIZES_WITH_SCOPE2(NVSHMEMI_PUTSIZE_SIGNAL_SCOPE_DECL, warp, _warp, x)
327
+ NVSHMEMI_REPT_FOR_SIZES_WITH_SCOPE2(NVSHMEMI_PUTSIZE_SIGNAL_SCOPE_DECL, block, _block, x)
328
+ #undef NVSHMEMI_REPT_PUTSIZE_SIGNAL_FOR_SCOPE
329
+
330
+ /* __device__ nvshmem_<typename>_put_signal_nbi_scope */
331
+ #define NVSHMEMI_TYPENAME_PUT_SIGNAL_NBI_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX, TYPENAME, TYPE) \
332
+ __device__ void nvshmemx_##TYPENAME##_put_signal_nbi##SC_SUFFIX( \
333
+ TYPE *dest, const TYPE *source, size_t nelems, uint64_t *sig_addr, uint64_t signal, \
334
+ int sig_op, int pe);
335
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE2(NVSHMEMI_TYPENAME_PUT_SIGNAL_NBI_SCOPE_DECL, warp,
336
+ _warp, x)
337
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE2(NVSHMEMI_TYPENAME_PUT_SIGNAL_NBI_SCOPE_DECL, block,
338
+ _block, x)
339
+ #undef NVSHMEMI_TYPENAME_PUT_SIGNAL_NBI_SCOPE_DECL
340
+
341
+ /* __device__ nvshmem_putmem_signal_nbi_scope */
342
+ #define NVSHMEMI_PUTMEM_SIGNAL_NBI_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX) \
343
+ __device__ void nvshmemx_putmem_signal_nbi##SC_SUFFIX(void *dest, const void *source, \
344
+ size_t nelems, uint64_t *sig_addr, \
345
+ uint64_t signal, int sig_op, int pe);
346
+
347
+ NVSHMEMI_PUTMEM_SIGNAL_NBI_SCOPE_DECL(warp, _warp, x)
348
+ NVSHMEMI_PUTMEM_SIGNAL_NBI_SCOPE_DECL(block, _block, x)
349
+ #undef NVSHMEMI_PUTMEM_SIGNAL_NBI_SCOPE_DECL
350
+
351
+ /* __device__ nvshmem_putsize_signal_nbi_scope */
352
+ #define NVSHMEMI_PUTSIZE_SIGNAL_NBI_SCOPE_DECL(SCOPE, SC_SUFFIX, SC_PREFIX, BITS) \
353
+ __device__ void nvshmemx_put##BITS##_signal_nbi##SC_SUFFIX( \
354
+ void *dest, const void *source, size_t nelems, uint64_t *sig_addr, uint64_t signal, \
355
+ int sig_op, int pe);
356
+
357
+ NVSHMEMI_REPT_FOR_SIZES_WITH_SCOPE2(NVSHMEMI_PUTSIZE_SIGNAL_NBI_SCOPE_DECL, warp, _warp, x)
358
+ NVSHMEMI_REPT_FOR_SIZES_WITH_SCOPE2(NVSHMEMI_PUTSIZE_SIGNAL_NBI_SCOPE_DECL, block, _block, x)
359
+ #undef NVSHMEMI_REPT_PUTSIZE_SIGNAL_NBI_FOR_SCOPE
360
+
361
+ #define NVSHMEMX_DECL_TYPE_IPUT_THREADGROUP(NAME, TYPE) \
362
+ __device__ void nvshmemx_##NAME##_iput_warp(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
363
+ ptrdiff_t sst, size_t nelems, int pe); \
364
+ __device__ void nvshmemx_##NAME##_iput_block(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
365
+ ptrdiff_t sst, size_t nelems, int pe);
366
+
367
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_IPUT_THREADGROUP)
368
+ #undef NVSHMEMX_DECL_TYPE_IPUT_THREADGROUP
369
+
370
+ #define NVSHMEMX_DECL_SIZE_IPUT_THREADGROUP(NAME) \
371
+ __device__ void nvshmemx_iput##NAME##_warp(void *dest, const void *source, ptrdiff_t dst, \
372
+ ptrdiff_t sst, size_t nelems, int pe); \
373
+ __device__ void nvshmemx_iput##NAME##_block(void *dest, const void *source, ptrdiff_t dst, \
374
+ ptrdiff_t sst, size_t nelems, int pe);
375
+
376
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_IPUT_THREADGROUP)
377
+ #undef NVSHMEMX_DECL_SIZE_IPUT_THREADGROUP
378
+
379
+ #define NVSHMEMX_DECL_TYPE_PUT_NBI_THREADGROUP(NAME, TYPE) \
380
+ __device__ void nvshmemx_##NAME##_put_nbi_warp(TYPE *dest, const TYPE *source, size_t nelems, \
381
+ int pe); \
382
+ __device__ void nvshmemx_##NAME##_put_nbi_block(TYPE *dest, const TYPE *source, size_t nelems, \
383
+ int pe);
384
+
385
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_PUT_NBI_THREADGROUP)
386
+ #undef NVSHMEMX_DECL_TYPE_PUT_NBI_THREADGROUP
387
+
388
+ #define NVSHMEMX_DECL_SIZE_PUT_NBI_THREADGROUP(NAME) \
389
+ __device__ void nvshmemx_put##NAME##_nbi_warp(void *dest, const void *source, size_t nelems, \
390
+ int pe); \
391
+ __device__ void nvshmemx_put##NAME##_nbi_block(void *dest, const void *source, size_t nelems, \
392
+ int pe);
393
+
394
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_PUT_NBI_THREADGROUP)
395
+ #undef NVSHMEMX_DECL_SIZE_PUT_NBI_THREADGROUP
396
+
397
+ __device__ void nvshmemx_putmem_nbi_warp(void *dest, const void *source, size_t bytes, int pe);
398
+ __device__ void nvshmemx_putmem_nbi_block(void *dest, const void *source, size_t bytes, int pe);
399
+
400
+ //////////////////// Get on Thread Group ////////////////////
401
+
402
+ #define NVSHMEMX_DECL_TYPE_GET_THREADGROUP(NAME, TYPE) \
403
+ __device__ void nvshmemx_##NAME##_get_warp(TYPE *dest, const TYPE *source, size_t nelems, \
404
+ int pe); \
405
+ __device__ void nvshmemx_##NAME##_get_block(TYPE *dest, const TYPE *source, size_t nelems, \
406
+ int pe);
407
+
408
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_GET_THREADGROUP)
409
+ #undef NVSHMEMX_DECL_TYPE_GET_THREADGROUP
410
+
411
+ #define NVSHMEMX_DECL_TYPE_IGET_THREADGROUP(NAME, TYPE) \
412
+ __device__ void nvshmemx_##NAME##_iget_warp(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
413
+ ptrdiff_t sst, size_t nelems, int pe); \
414
+ __device__ void nvshmemx_##NAME##_iget_block(TYPE *dest, const TYPE *source, ptrdiff_t dst, \
415
+ ptrdiff_t sst, size_t nelems, int pe);
416
+
417
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_IGET_THREADGROUP)
418
+ #undef NVSHMEMX_DECL_TYPE_IGET_THREADGROUP
419
+
420
+ #define NVSHMEMX_DECL_SIZE_GET_THREADGROUP(NAME) \
421
+ __device__ void nvshmemx_get##NAME##_warp(void *dest, const void *source, size_t nelems, \
422
+ int pe); \
423
+ __device__ void nvshmemx_get##NAME##_block(void *dest, const void *source, size_t nelems, \
424
+ int pe);
425
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_GET_THREADGROUP)
426
+ #undef NVSHMEMX_DECL_SIZE_GET_THREADGROUP
427
+
428
+ __device__ void nvshmemx_getmem_warp(void *dest, const void *source, size_t bytes, int pe);
429
+ __device__ void nvshmemx_getmem_block(void *dest, const void *source, size_t bytes, int pe);
430
+
431
+ #define NVSHMEMX_DECL_SIZE_IGET_THREADGROUP(NAME) \
432
+ __device__ void nvshmemx_iget##NAME##_warp(void *dest, const void *source, ptrdiff_t dst, \
433
+ ptrdiff_t sst, size_t nelems, int pe); \
434
+ __device__ void nvshmemx_iget##NAME##_block(void *dest, const void *source, ptrdiff_t dst, \
435
+ ptrdiff_t sst, size_t nelems, int pe);
436
+
437
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_IGET_THREADGROUP)
438
+ #undef NVSHMEMX_DECL_SIZE_IGET_THREADGROUP
439
+
440
+ #define NVSHMEMX_DECL_TYPE_GET_NBI_THREADGROUP(NAME, TYPE) \
441
+ __device__ void nvshmemx_##NAME##_get_nbi_warp(TYPE *dest, const TYPE *source, size_t nelems, \
442
+ int pe); \
443
+ __device__ void nvshmemx_##NAME##_get_nbi_block(TYPE *dest, const TYPE *source, size_t nelems, \
444
+ int pe);
445
+
446
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(NVSHMEMX_DECL_TYPE_GET_NBI_THREADGROUP)
447
+ #undef NVSHMEMX_DECL_TYPE_GET_NBI_THREADGROUP
448
+
449
+ #define NVSHMEMX_DECL_SIZE_GET_NBI_THREADGROUP(NAME) \
450
+ __device__ void nvshmemx_get##NAME##_nbi_warp(void *dest, const void *source, size_t nelems, \
451
+ int pe); \
452
+ __device__ void nvshmemx_get##NAME##_nbi_block(void *dest, const void *source, size_t nelems, \
453
+ int pe);
454
+
455
+ NVSHMEMI_REPT_FOR_SIZES(NVSHMEMX_DECL_SIZE_GET_NBI_THREADGROUP)
456
+ #undef NVSHMEMX_DECL_SIZE_GET_NBI_THREADGROUP
457
+
458
+ __device__ void nvshmemx_getmem_nbi_warp(void *dest, const void *source, size_t bytes, int pe);
459
+ __device__ void nvshmemx_getmem_nbi_block(void *dest, const void *source, size_t bytes, int pe);
460
+
461
+ //////////////////// Signal ////////////////////
462
+
463
+ NVSHMEMI_HOSTDEVICE_PREFIX void nvshmemx_signal_op(uint64_t *sig_addr, uint64_t signal, int sig_op,
464
+ int pe);
465
+
466
+ #ifdef __cplusplus
467
+ }
468
+ #endif
469
+
470
+ #endif /* _NVSHMEMX_API_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/host/nvshmemx_coll_api.h ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEMX_COLL_API_H_
14
+ #define _NVSHMEMX_COLL_API_H_
15
+ #include <cuda_runtime.h>
16
+ #include "host/nvshmem_macros.h"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+ //==========================================
22
+ // nvshmem collective calls with stream param
23
+ //==========================================
24
+
25
+ // alltoall(s) collectives
26
+ #define DECL_NVSHMEMX_TYPENAME_ALLTOALL_ON_STREAM(TYPENAME, TYPE) \
27
+ int nvshmemx_##TYPENAME##_alltoall_on_stream(nvshmem_team_t team, TYPE *dest, const TYPE *src, \
28
+ size_t nelem, cudaStream_t stream);
29
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEMX_TYPENAME_ALLTOALL_ON_STREAM)
30
+ #undef DECL_NVSHMEMX_TYPENAME_ALLTOALL_ON_STREAM
31
+
32
+ int nvshmemx_alltoallmem_on_stream(nvshmem_team_t team, void *dest, const void *src, size_t nelem,
33
+ cudaStream_t stream);
34
+
35
+ // barrier collectives
36
+ int nvshmemx_barrier_on_stream(nvshmem_team_t team, cudaStream_t stream);
37
+ void nvshmemx_barrier_all_on_stream(cudaStream_t);
38
+
39
+ // sync collectives
40
+ int nvshmemx_team_sync_on_stream(nvshmem_team_t team, cudaStream_t stream);
41
+ void nvshmemx_sync_all_on_stream(cudaStream_t);
42
+
43
+ // broadcast collectives
44
+ #define DECL_NVSHMEMX_TYPENAME_BROADCAST_ON_STREAM(TYPENAME, TYPE) \
45
+ int nvshmemx_##TYPENAME##_broadcast_on_stream(nvshmem_team_t team, TYPE *dest, \
46
+ const TYPE *src, size_t nelem, int PE_root, \
47
+ cudaStream_t stream);
48
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEMX_TYPENAME_BROADCAST_ON_STREAM)
49
+ #undef DECL_NVSHMEMX_TYPENAME_BROADCAST_ON_STREAM
50
+
51
+ int nvshmemx_broadcastmem_on_stream(nvshmem_team_t team, void *dest, const void *src, size_t nelem,
52
+ int PE_root, cudaStream_t stream);
53
+
54
+ // fcollect collectives
55
+ #define DECL_NVSHMEMX_TYPENAME_FCOLLECT_ON_STREAM(TYPENAME, TYPE) \
56
+ int nvshmemx_##TYPENAME##_fcollect_on_stream(nvshmem_team_t team, TYPE *dest, const TYPE *src, \
57
+ size_t nelem, cudaStream_t stream);
58
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES(DECL_NVSHMEMX_TYPENAME_FCOLLECT_ON_STREAM)
59
+ #undef DECL_NVSHMEMX_TYPENAME_FCOLLECT_ON_STREAM
60
+
61
+ int nvshmemx_fcollectmem_on_stream(nvshmem_team_t team, void *dest, const void *src, size_t nelem,
62
+ cudaStream_t stream);
63
+
64
+ // reduction collectives
65
+ #define NVSHMEMI_DECL_REDUCE_ONSTREAM(NAME, TYPE, OP) \
66
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmemx_##NAME##_##OP##_reduce_on_stream( \
67
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce, cudaStream_t stream);
68
+
69
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, and)
70
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, or)
71
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, xor)
72
+
73
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, max)
74
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, min)
75
+
76
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, sum)
77
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_REDUCE_ONSTREAM, prod)
78
+
79
+ #undef NVSHMEMI_DECL_REDUCE_ONSTREAM
80
+
81
+ #define NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM(NAME, TYPE, OP) \
82
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmemx_##NAME##_##OP##_reducescatter_on_stream( \
83
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce, cudaStream_t stream);
84
+
85
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, and)
86
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, or)
87
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, xor)
88
+
89
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, max)
90
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, min)
91
+
92
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, sum)
93
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES(NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM, prod)
94
+
95
+ #undef NVSHMEMI_DECL_REDUCESCATTER_ONSTREAM
96
+
97
+ //==========================================
98
+ // nvshmem collective calls on threadgroup
99
+ //==========================================
100
+
101
+ // alltoall(s) collectives
102
+ #define DECL_NVSHMEMX_TYPENAME_ALLTOALL_SCOPE(SCOPE, TYPENAME, TYPE) \
103
+ __device__ int nvshmemx_##TYPENAME##_alltoall_##SCOPE(nvshmem_team_t team, TYPE *dest, \
104
+ const TYPE *src, size_t nelem);
105
+
106
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_ALLTOALL_SCOPE, warp)
107
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_ALLTOALL_SCOPE, block)
108
+ #undef DECL_NVSHMEMX_TYPENAME_ALLTOALL_SCOPE
109
+
110
+ __device__ int nvshmemx_alltoallmem_warp(nvshmem_team_t team, void *dest, const void *src,
111
+ size_t nelem);
112
+ __device__ int nvshmemx_alltoallmem_block(nvshmem_team_t team, void *dest, const void *src,
113
+ size_t nelem);
114
+
115
+ // barrier collectives
116
+ __device__ int nvshmemx_barrier_warp(nvshmem_team_t team);
117
+ __device__ void nvshmemx_barrier_all_warp();
118
+ __device__ int nvshmemx_barrier_warpgroup(nvshmem_team_t team);
119
+ __device__ int nvshmemx_barrier_block(nvshmem_team_t team);
120
+ __device__ void nvshmemx_barrier_all_block();
121
+
122
+ // sync collectives
123
+ __device__ int nvshmemx_team_sync_warp(nvshmem_team_t team);
124
+ __device__ void nvshmemx_sync_all_warp();
125
+ __device__ int nvshmemx_team_sync_block(nvshmem_team_t team);
126
+ __device__ void nvshmemx_sync_all_block();
127
+
128
+ // broadcast collectives
129
+ #define DECL_NVSHMEMX_TYPENAME_BROADCAST_SCOPE(SCOPE, TYPENAME, TYPE) \
130
+ __device__ int nvshmemx_##TYPENAME##_broadcast_##SCOPE( \
131
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nelem, int PE_root);
132
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_BROADCAST_SCOPE, warp)
133
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_BROADCAST_SCOPE, block)
134
+ #undef DECL_NVSHMEMX_TYPENAME_BROADCAST_SCOPE
135
+
136
+ __device__ int nvshmemx_broadcastmem_warp(nvshmem_team_t team, void *dest, const void *src,
137
+ size_t nelem);
138
+ __device__ int nvshmemx_broadcastmem_block(nvshmem_team_t team, void *dest, const void *src,
139
+ size_t nelem);
140
+
141
+ // fcollect collectives
142
+ #define DECL_NVSHMEMX_TYPENAME_FCOLLECT_SCOPE(SCOPE, TYPENAME, TYPE) \
143
+ __device__ int nvshmemx_##TYPENAME##_fcollect_##SCOPE(nvshmem_team_t team, TYPE *dest, \
144
+ const TYPE *src, size_t nelem);
145
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_FCOLLECT_SCOPE, warp)
146
+ NVSHMEMI_REPT_FOR_STANDARD_RMA_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_FCOLLECT_SCOPE, block)
147
+ #undef DECL_NVSHMEMX_TYPENAME_FCOLLECT_SCOPE
148
+
149
+ __device__ int nvshmemx_fcollectmem_warp(nvshmem_team_t team, void *dest, const void *src,
150
+ size_t nelem);
151
+ __device__ int nvshmemx_fcollectmem_block(nvshmem_team_t team, void *dest, const void *src,
152
+ size_t nelem);
153
+
154
+ // reduction collectives
155
+ #define DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP(SCOPE, TYPENAME, TYPE, OP) \
156
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmemx_##TYPENAME##_##OP##_reduce_##SCOPE( \
157
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce);
158
+
159
+ #define DECL_NVSHMEMX_TYPENAME_OP_REDUCE(SC) \
160
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
161
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, SC, and) \
162
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
163
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, SC, or) \
164
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
165
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, SC, xor) \
166
+ \
167
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES_WITH_SCOPE( \
168
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, SC, max) \
169
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES_WITH_SCOPE( \
170
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, SC, min) \
171
+ \
172
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, \
173
+ SC, sum) \
174
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES_WITH_SCOPE(DECL_NVSHMEMX_TYPENAME_OP_REDUCE_THREADGROUP, \
175
+ SC, prod)
176
+
177
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE(warp);
178
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCE(block);
179
+
180
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmemx_double2_maxloc_reduce_block(nvshmem_team_t team,
181
+ double2 *dest,
182
+ const double2 *src,
183
+ size_t nreduce);
184
+
185
+ #define DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP(SCOPE, TYPENAME, TYPE, OP) \
186
+ NVSHMEMI_HOSTDEVICE_PREFIX int nvshmemx_##TYPENAME##_##OP##_reducescatter_##SCOPE( \
187
+ nvshmem_team_t team, TYPE *dest, const TYPE *src, size_t nreduce);
188
+
189
+ #define DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER(SC) \
190
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
191
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, and) \
192
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
193
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, or) \
194
+ NVSHMEMI_REPT_FOR_BITWISE_REDUCE_TYPES_WITH_SCOPE( \
195
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, xor) \
196
+ \
197
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES_WITH_SCOPE( \
198
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, max) \
199
+ NVSHMEMI_REPT_FOR_STANDARD_REDUCE_TYPES_WITH_SCOPE( \
200
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, min) \
201
+ \
202
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES_WITH_SCOPE( \
203
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, sum) \
204
+ NVSHMEMI_REPT_FOR_ARITH_REDUCE_TYPES_WITH_SCOPE( \
205
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER_THREADGROUP, SC, prod)
206
+
207
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER(warp);
208
+ DECL_NVSHMEMX_TYPENAME_OP_REDUCESCATTER(block);
209
+
210
+ #ifdef __cplusplus
211
+ }
212
+ #endif
213
+
214
+ #endif /* NVSHMEMX_COLL_H */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/alltoall.cuh ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef ALLTOALL_DEVICE_CUH
8
+ #define ALLTOALL_DEVICE_CUH
9
+ #include <cuda_runtime.h>
10
+ #include "non_abi/device/wait/nvshmemi_wait_until_apis.cuh"
11
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
12
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
13
+ #include "barrier.cuh"
14
+
15
+ #ifdef __CUDA_ARCH__
16
+
17
+ #define NVSHMEMI_ALLTOALL_SMALL_MSGSIZE 16
18
+ #define NVSHMEMI_ALLTOALL_MEDIUM_MSGSIZE 16384
19
+
20
+ template <typename T, threadgroup_t SCOPE>
21
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_alltoall_allpush_threadgroup(
22
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems) {
23
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
24
+ int PE_size = teami->size;
25
+ int next_rank, src_offset, dst_offset;
26
+ const int mype = nvshmemi_device_state_d.mype;
27
+ int my_idx_in_active_set = teami->my_pe;
28
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
29
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
30
+ uint64_t *psync = (uint64_t *)nvshmemi_team_get_psync(teami, ALLTOALL);
31
+ uint64_t *pwrk = &teami->alltoall_pwrk[teami->alltoall_count % 2];
32
+ const size_t msgsize = nelems * sizeof(T);
33
+ const int first_unused_warp = (PE_size + (warpSize - 1)) / warpSize;
34
+ const int my_warp_idx = myIdx / warpSize;
35
+ const int num_warps = groupSize / warpSize;
36
+
37
+ dst_offset = nelems * my_idx_in_active_set;
38
+
39
+ /* Do remote ops and local ops < 16 bytes from a single thread */
40
+ /* TODO: Find a more optimal transfer point than 16 bytes */
41
+ for (int i = myIdx; i < PE_size; i += groupSize) {
42
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + i);
43
+ void *peer_base_addr = (void *)__ldg(
44
+ (const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + next_rank);
45
+ src_offset = nelems * ((i + my_idx_in_active_set) % PE_size);
46
+ if (!peer_base_addr) {
47
+ /* We are breaking rank with the rest of the group here so send the RMA with thread
48
+ * scope. */
49
+ nvshmemi_transfer_put_signal<NVSHMEMI_THREADGROUP_THREAD>(
50
+ (void *)(dest + dst_offset), (void *)(source + src_offset), msgsize,
51
+ (void *)(psync + mype), 1ULL, NVSHMEMI_AMO_SIGNAL_ADD, next_rank, true);
52
+ } else if (msgsize <= NVSHMEMI_ALLTOALL_SMALL_MSGSIZE) {
53
+ nvshmemi_put_nbi_threadgroup<T, NVSHMEMI_THREADGROUP_THREAD>(
54
+ dest + dst_offset, source + src_offset, nelems, next_rank);
55
+ }
56
+ }
57
+
58
+ if (SCOPE == NVSHMEMI_THREADGROUP_BLOCK && PE_size < groupSize &&
59
+ num_warps > first_unused_warp && msgsize > NVSHMEMI_ALLTOALL_SMALL_MSGSIZE &&
60
+ msgsize <= NVSHMEMI_ALLTOALL_MEDIUM_MSGSIZE) {
61
+ if (my_warp_idx >= first_unused_warp) {
62
+ for (int ii = my_warp_idx - first_unused_warp; ii < PE_size;
63
+ ii += (num_warps - first_unused_warp)) {
64
+ next_rank =
65
+ nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + ii);
66
+ src_offset = nelems * ((my_idx_in_active_set + ii) % PE_size);
67
+ void *peer_base_addr = (void *)__ldg(
68
+ (const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p +
69
+ next_rank);
70
+ if (peer_base_addr) {
71
+ nvshmemi_put_nbi_threadgroup<T, NVSHMEMI_THREADGROUP_WARP>(
72
+ dest + dst_offset, source + src_offset, nelems, next_rank);
73
+ }
74
+ }
75
+ }
76
+ } else if (msgsize > NVSHMEMI_ALLTOALL_SMALL_MSGSIZE) {
77
+ for (int ii = 0; ii < PE_size; ii++) {
78
+ next_rank =
79
+ nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + ii);
80
+ src_offset = nelems * ((my_idx_in_active_set + ii) % PE_size);
81
+ void *peer_base_addr = (void *)__ldg(
82
+ (const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + next_rank);
83
+ if (peer_base_addr) {
84
+ nvshmemi_put_nbi_threadgroup<T, SCOPE>(dest + dst_offset, source + src_offset,
85
+ nelems, next_rank);
86
+ }
87
+ }
88
+ }
89
+
90
+ nvshmemi_threadgroup_sync<SCOPE>();
91
+ /* A fence and signal is required - note that we can skip any size check here because it's
92
+ * inherent in the boolean. */
93
+ if (myIdx == 0) {
94
+ atomicAdd((unsigned long long *)pwrk, 1ULL);
95
+ __threadfence_system();
96
+ }
97
+ nvshmemi_threadgroup_sync<SCOPE>();
98
+ for (int i = myIdx; i < PE_size; i += groupSize) {
99
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + i);
100
+ void *peer_base_addr = (void *)__ldg(
101
+ (const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + next_rank);
102
+ if (peer_base_addr) {
103
+ nvshmemi_signal_op((psync + mype), 1ULL, NVSHMEMI_AMO_SIGNAL_ADD, next_rank);
104
+ }
105
+ }
106
+
107
+ nvshmemi_threadgroup_sync<SCOPE>();
108
+ for (int i = myIdx; i < PE_size; i += groupSize) {
109
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + i);
110
+ nvshmemi_wait_until_greater_than_equals<uint64_t>((psync + next_rank), *pwrk,
111
+ NVSHMEMI_CALL_SITE_SIGNAL_WAIT_UNTIL_GE);
112
+ }
113
+ if (SCOPE == NVSHMEMI_THREADGROUP_BLOCK && PE_size < groupSize) {
114
+ if (my_warp_idx == first_unused_warp)
115
+ nvshmemi_transfer_quiet<NVSHMEMI_THREADGROUP_WARP>(false);
116
+ } else
117
+ nvshmemi_transfer_quiet<SCOPE>(false);
118
+ nvshmemi_threadgroup_sync<SCOPE>();
119
+ if (myIdx == 0) teami->alltoall_count++;
120
+ }
121
+
122
+ template <typename T, threadgroup_t SCOPE>
123
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_alltoall_p2p_allpush_threadgroup(
124
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems) {
125
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
126
+ int PE_size = teami->size;
127
+ int next_rank;
128
+ int src_offset;
129
+ int dst_offset;
130
+ int my_idx_in_active_set = teami->my_pe;
131
+ T *dst_ptr;
132
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
133
+
134
+ for (int ii = 0; ii < PE_size; ii++) {
135
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, my_idx_in_active_set + ii);
136
+ src_offset = nelems * ((my_idx_in_active_set + ii) % PE_size);
137
+ dst_offset = nelems * teami->my_pe;
138
+ dst_ptr = (T *)nvshmemi_ptr((void *)(dest + dst_offset), next_rank);
139
+ nvshmemi_memcpy_threadgroup<SCOPE>(dst_ptr, source + src_offset, nelems * sizeof(T));
140
+ }
141
+
142
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
143
+ }
144
+
145
+ template <typename T, threadgroup_t SCOPE>
146
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_alltoall_threadgroup(nvshmem_team_t team,
147
+ T *dest,
148
+ const T *source,
149
+ size_t nelems) {
150
+ if (nvshmemi_device_state_d.job_connectivity <= NVSHMEMI_JOB_GPU_LDST_REMOTE_ATOMICS)
151
+ nvshmemi_alltoall_p2p_allpush_threadgroup<T, SCOPE>(team, dest, source, nelems);
152
+ else
153
+ nvshmemi_alltoall_allpush_threadgroup<T, SCOPE>(team, dest, source, nelems);
154
+ }
155
+
156
+ #endif /* __CUDA_ARCH__ */
157
+ #endif /* ALLTOALL_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/barrier.cuh ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+ #ifndef BARRIER_DEVICE_CUH
7
+ #define BARRIER_DEVICE_CUH
8
+ #include <cuda_runtime.h>
9
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
10
+ #include "non_abi/nvshmem_build_options.h"
11
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
12
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
13
+ #else
14
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
15
+ #endif
16
+ #include "non_abi/device/wait/nvshmemi_wait_until_apis.cuh"
17
+ #include "device_host/nvshmem_tensor.h"
18
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
19
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
20
+ #include "utils.cuh"
21
+
22
+ #ifdef __CUDA_ARCH__
23
+
24
+ template <int k, int logk, threadgroup_t SCOPE>
25
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE void sync_dissem_pow2_threadgroup(
26
+ nvshmem_team_t team) {
27
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
28
+ int size = teami->size;
29
+ volatile long *pSync = (volatile long *)nvshmemi_team_get_psync(teami, SYNC);
30
+ volatile long *sync_counter = (volatile long *)nvshmemi_team_get_sync_counter(teami);
31
+ volatile long *sync_arr = NULL;
32
+ int shift;
33
+ int to_nbr_idx, to_nbr;
34
+ int from_nbr_idx, from_nbr;
35
+ int temp = size - 1; /* used to calculate number of phases */
36
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
37
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
38
+ sync_arr = (volatile long *)pSync;
39
+ int pow_k = 1;
40
+ int phase_num = 0;
41
+ volatile long *counter = sync_counter;
42
+ while (temp) {
43
+ /* notify neighbors */
44
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
45
+ shift = j << phase_num;
46
+ if (shift >= size) break;
47
+
48
+ to_nbr_idx = teami->my_pe + shift;
49
+ to_nbr = nvshmemi_team_translate_pe_to_team_world_wrap(teami, to_nbr_idx);
50
+ nvshmemi_signal_for_barrier<long>(((long *)sync_arr + nvshmemi_device_state_d.mype),
51
+ counter[0], to_nbr);
52
+ }
53
+
54
+ /* wait for neighbors notification */
55
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
56
+ shift = j << phase_num;
57
+ if (shift >= size) break;
58
+
59
+ from_nbr_idx = teami->my_pe - shift;
60
+ if (from_nbr_idx < 0) from_nbr_idx = size + from_nbr_idx;
61
+ from_nbr = nvshmemi_team_translate_pe_to_team_world_wrap(teami, from_nbr_idx);
62
+ nvshmemi_wait_until_greater_than_equals<volatile long>(sync_arr + from_nbr, counter[0],
63
+ NVSHMEMI_CALL_SITE_BARRIER_WARP);
64
+ }
65
+ pow_k <<= logk;
66
+ temp >>= logk;
67
+ phase_num++;
68
+ nvshmemi_threadgroup_sync<SCOPE>();
69
+ }
70
+ if (!myIdx) sync_counter[0] += 1;
71
+ nvshmemi_threadgroup_sync<SCOPE>();
72
+ }
73
+
74
+ template <threadgroup_t SCOPE>
75
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE void sync_dissem_threadgroup_non_strided(
76
+ nvshmem_team_t team) {
77
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
78
+
79
+ volatile long *pSync = (volatile long *)nvshmemi_team_get_psync(teami, SYNC);
80
+ volatile long *sync_counter = (volatile long *)nvshmemi_team_get_sync_counter(teami);
81
+ int num_phases = 0;
82
+
83
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
84
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
85
+ int my_idx_in_active_set = teami->my_pe;
86
+ int shift, to_nbr_idx, to_nbr, from_nbr_idx, from_nbr;
87
+ int size = teami->size;
88
+ int temp = size - 1; /* used to calculate number of phases */
89
+ /* radix for the dissemination algorithm */
90
+ int k = min(nvshmemi_device_state_d.gpu_coll_env_params_var.barrier_tg_dissem_kval, size);
91
+ int pow_k = 1;
92
+ while (temp) {
93
+ num_phases++;
94
+ temp /= k;
95
+ }
96
+
97
+ volatile long *counter = sync_counter;
98
+ for (int i = 0; i < num_phases; i++) {
99
+ /* notify neighbors */
100
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
101
+ shift = j * pow_k;
102
+ if (shift >= size) break;
103
+ to_nbr_idx = (my_idx_in_active_set + shift) % size;
104
+ to_nbr = teami->pe_mapping[to_nbr_idx];
105
+ nvshmemi_signal_for_barrier<long>(((long *)pSync + nvshmemi_device_state_d.mype),
106
+ counter[0], to_nbr);
107
+ }
108
+
109
+ /* wait for neighbors notification */
110
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
111
+ shift = j * pow_k;
112
+ if (shift >= size) break;
113
+
114
+ from_nbr_idx = my_idx_in_active_set - shift;
115
+ if (from_nbr_idx < 0) from_nbr_idx = size + from_nbr_idx;
116
+ from_nbr = teami->pe_mapping[from_nbr_idx];
117
+ nvshmemi_wait_until_greater_than_equals<volatile long>(pSync + from_nbr, counter[0],
118
+ NVSHMEMI_CALL_SITE_BARRIER_WARP);
119
+ }
120
+ pow_k *= k;
121
+ nvshmemi_threadgroup_sync<SCOPE>();
122
+ }
123
+ if (!myIdx) sync_counter[0] += 1;
124
+ nvshmemi_threadgroup_sync<SCOPE>();
125
+ }
126
+
127
+ template <threadgroup_t SCOPE>
128
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE void sync_dissem_threadgroup_2(
129
+ int start, int stride, int size, volatile long *pSync, volatile long *sync_counter) {
130
+ int num_phases = 0;
131
+ int k =
132
+ min(nvshmemi_device_state_d.gpu_coll_env_params_var.barrier_tg_dissem_kval, size); /* radix
133
+ for the dissemination algorithm */
134
+ int my_idx_in_active_set = (nvshmemi_device_state_d.mype - start) / stride;
135
+ volatile long *sync_arr = NULL;
136
+ int shift;
137
+ int to_nbr_idx, to_nbr;
138
+ int from_nbr_idx, from_nbr;
139
+ int temp = size - 1; /* used to calculate number of phases */
140
+ while (temp) {
141
+ num_phases++;
142
+ temp /= k;
143
+ }
144
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
145
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
146
+ sync_arr = (volatile long *)pSync;
147
+ int pow_k = 1;
148
+ volatile long *counter = sync_counter;
149
+ for (int i = 0; i < num_phases; i++) {
150
+ /* notify neighbors */
151
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
152
+ shift = j * pow_k;
153
+ if (shift >= size) break;
154
+ to_nbr_idx = (my_idx_in_active_set + shift) % size;
155
+ to_nbr = start + to_nbr_idx * stride;
156
+ nvshmemi_signal_for_barrier<long>(((long *)sync_arr + nvshmemi_device_state_d.mype),
157
+ counter[0], to_nbr);
158
+ }
159
+
160
+ /* wait for neighbors notification */
161
+ for (int j = myIdx + 1; j <= k - 1; j += groupSize) {
162
+ shift = j * pow_k;
163
+ if (shift >= size) break;
164
+
165
+ from_nbr_idx = my_idx_in_active_set - shift;
166
+ if (from_nbr_idx < 0) from_nbr_idx = size + from_nbr_idx;
167
+ from_nbr = start + from_nbr_idx * stride;
168
+ nvshmemi_wait_until_greater_than_equals<volatile long>(sync_arr + from_nbr, counter[0],
169
+ NVSHMEMI_CALL_SITE_BARRIER_WARP);
170
+ }
171
+ pow_k *= k;
172
+ nvshmemi_threadgroup_sync<SCOPE>();
173
+ }
174
+ if (!myIdx) sync_counter[0] += 1;
175
+ nvshmemi_threadgroup_sync<SCOPE>();
176
+ }
177
+
178
+ template <threadgroup_t SCOPE>
179
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE void sync_dissem_threadgroup(
180
+ nvshmem_team_t team) {
181
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
182
+ int start = teami->start;
183
+ int stride = teami->stride;
184
+ int size = teami->size;
185
+ volatile long *pSync = (volatile long *)nvshmemi_team_get_psync(teami, SYNC);
186
+ volatile long *sync_counter = (volatile long *)nvshmemi_team_get_sync_counter(teami);
187
+
188
+ if (stride > 0) {
189
+ sync_dissem_threadgroup_2<SCOPE>(start, stride, size, pSync, sync_counter);
190
+ } else {
191
+ sync_dissem_threadgroup_non_strided<SCOPE>(team);
192
+ }
193
+ }
194
+
195
+ template <threadgroup_t SCOPE>
196
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_sync_algo_threadgroup(
197
+ nvshmem_team_t team) {
198
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
199
+ int size = teami->size;
200
+ int k = min(nvshmemi_device_state_d.gpu_coll_env_params_var.barrier_tg_dissem_kval, size);
201
+ k = max(k, 2);
202
+ /* only p2p connected team for BLOCK scoped collectives should use larger radix of dissem
203
+ * algorithm */
204
+ if (teami->are_gpus_p2p_connected && SCOPE == NVSHMEMI_THREADGROUP_BLOCK) k = teami->size;
205
+ switch (k) {
206
+ case 2:
207
+ sync_dissem_pow2_threadgroup<2, 1, SCOPE>(team);
208
+ break;
209
+ case 4:
210
+ sync_dissem_pow2_threadgroup<4, 2, SCOPE>(team);
211
+ break;
212
+ case 8:
213
+ sync_dissem_pow2_threadgroup<8, 3, SCOPE>(team);
214
+ break;
215
+ case 16:
216
+ sync_dissem_pow2_threadgroup<16, 4, SCOPE>(team);
217
+ break;
218
+ case 32:
219
+ sync_dissem_pow2_threadgroup<32, 5, SCOPE>(team);
220
+ break;
221
+ default:
222
+ sync_dissem_threadgroup<SCOPE>(team);
223
+ break;
224
+ }
225
+ }
226
+
227
+ template <threadgroup_t SCOPE>
228
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_sync_threadgroup(nvshmem_team_t team) {
229
+ nvshmemi_threadgroup_sync<SCOPE>();
230
+ nvshmemi_sync_algo_threadgroup<SCOPE>(team);
231
+ }
232
+
233
+ template <threadgroup_t SCOPE>
234
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_barrier_threadgroup(nvshmem_team_t team) {
235
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
236
+ nvshmemi_threadgroup_sync<SCOPE>();
237
+ if ((nvshmemi_device_state_d.job_connectivity > NVSHMEMI_JOB_GPU_LDST)) {
238
+ nvshmemi_transfer_quiet<SCOPE>(true);
239
+ } else if (!myIdx) {
240
+ __threadfence_system();
241
+ }
242
+ nvshmemi_threadgroup_sync<SCOPE>();
243
+
244
+ nvshmemi_sync_algo_threadgroup<SCOPE>(team);
245
+
246
+ if (!myIdx) {
247
+ if (nvshmemi_device_state_d.job_connectivity > NVSHMEMI_JOB_GPU_PROXY)
248
+ nvshmemi_transfer_enforce_consistency_at_target(false);
249
+ }
250
+ nvshmemi_threadgroup_sync<SCOPE>();
251
+ }
252
+
253
+ /******** tile APIs **************/
254
+ template <nvshmemx::tile_coll_algo_t algo, threadgroup_t scope>
255
+ __device__ inline int nvshmemi_tile_collective_wait(nvshmem_team_t team, uint64_t flag) {
256
+ static_assert((algo == nvshmemx::tile_coll_algo_t::NVLS_ONE_SHOT_PULL_NBI) ||
257
+ (algo == nvshmemx::tile_coll_algo_t::NVLS_ONE_SHOT_PUSH_NBI) ||
258
+ (algo == nvshmemx::tile_coll_algo_t::NVLS_TWO_SHOT_PUSH_NBI),
259
+ "Unsupported tile algorithm");
260
+
261
+ assert(!flag && "Currently non-zero flag value is unsupported");
262
+
263
+ if constexpr ((algo == nvshmemx::tile_coll_algo_t::NVLS_TWO_SHOT_PUSH_NBI) ||
264
+ (algo == nvshmemx::tile_coll_algo_t::NVLS_ONE_SHOT_PUSH_NBI)) {
265
+ nvshmemi_threadgroup_sync<scope>();
266
+ if (!nvshmemi_thread_id_in_threadgroup<scope>()) {
267
+ __threadfence_system();
268
+ }
269
+ nvshmemi_sync_algo_threadgroup<scope>(team);
270
+ return 0;
271
+ } else {
272
+ // PULL variants store only to local HBM mem
273
+ __threadfence(); // ensure stores are visible in local GPU mem
274
+ nvshmemi_threadgroup_sync<scope>();
275
+ return 0;
276
+ }
277
+ }
278
+
279
+ #endif /* __CUDA_ARCH__ */
280
+
281
+ #endif /* BARRIER_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/broadcast.cuh ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef BROADCAST_DEVICE_CUH
8
+ #define BROADCAST_DEVICE_CUH
9
+
10
+ #include <cuda_runtime.h>
11
+ #include "device_host_transport/nvshmem_common_transport.h" // for NVSHMEMI_OP_PUT
12
+ #include "non_abi/nvshmem_build_options.h"
13
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
14
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
15
+ #else
16
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
17
+ #endif
18
+ #include "non_abi/device/wait/nvshmemi_wait_until_apis.cuh"
19
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
20
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
21
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
22
+
23
+ #ifdef __CUDA_ARCH__
24
+ template <typename T, threadgroup_t SCOPE>
25
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_intranode_tree_threadgroup(
26
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root, int k) {
27
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
28
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
29
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
30
+ if (!myIdx) { /* Only one thread should increment */
31
+ teami->ll_flag++;
32
+ teami->bcast_count++;
33
+ if (teami->bcast_sync_offset + nelems * sizeof(T) * 2 >
34
+ sizeof(long) * NVSHMEMI_BCAST_SYNC_SIZE) {
35
+ nvshmemi_barrier_threadgroup<NVSHMEMI_THREADGROUP_THREAD>(team);
36
+ teami->bcast_sync_offset = 0;
37
+ }
38
+ }
39
+ nvshmemi_threadgroup_sync<SCOPE>();
40
+ const uint32_t ll_flag = teami->ll_flag;
41
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, BCAST);
42
+ size_t recv_offset = teami->bcast_sync_offset;
43
+ const int my_pe_in_team = nvshmemi_team_my_pe(team);
44
+
45
+ if (PE_root != my_pe_in_team) {
46
+ nvshmemi_recvLL<T, SCOPE>(dest, (uint64_t *)(pWrk + recv_offset), nelems, ll_flag);
47
+ } else {
48
+ nvshmemi_packLL_naive<T, SCOPE>((uint64_t *)(pWrk + recv_offset), source, nelems, ll_flag);
49
+ }
50
+
51
+ /*if (SCOPE == NVSHMEMI_THREADGROUP_BLOCK) {
52
+ nvshmemi_threadgroup_sync<SCOPE>(); // wait for block scoped recvLL/packLL to complete
53
+ int warp_id = myIdx / 32;
54
+ int num_warps = (groupSize + 31) / 32;
55
+ size_t size_per_peer = nelems * sizeof(T) * 2;
56
+ int num_peers = k;
57
+ size_t total_size = size_per_peer * num_peers;
58
+ int size_per_warp = min (nelems * sizeof(T) * 2, 512l);
59
+ for (size_t start = warp_id * size_per_warp; start < total_size; start += num_warps *
60
+ size_per_warp) { int peer_id = start / size_per_peer; size_t offset = start % size_per_peer; int
61
+ child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + peer_id + 1; if
62
+ (child_in_team >= teami->size) break; child_in_team = (child_in_team + PE_root) % teami->size;
63
+ int child =
64
+ nvshmemi_team_translate_pe(teami, child_in_team,
65
+ nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_WORLD_INDEX]);
66
+ //printf("sending data %d to %d at offset %llu, peer_id: %d, size_per_peer: %llu,
67
+ nelems: %llu\n", size_per_warp, child, offset, peer_id, size_per_peer, nelems);
68
+ //printf("myIdx: %d, start: %lld, num_warps: %d\n", myIdx, start, num_warps);
69
+ nvshmemi_put_nbi_threadgroup<char, NVSHMEMI_THREADGROUP_WARP>(pWrk + recv_offset +
70
+ offset, pWrk + recv_offset + offset, size_per_warp, child);
71
+ }
72
+ } else */
73
+ {
74
+ nvshmemi_threadgroup_sync<SCOPE>();
75
+ for (int i = 0; i < k; i++) {
76
+ int child_in_team =
77
+ ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
78
+ if (child_in_team >= teami->size) break;
79
+ child_in_team = (child_in_team + PE_root) % teami->size;
80
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
81
+
82
+ nvshmemii_put_nbi_threadgroup<uint64_t, SCOPE>(
83
+ (uint64_t *)(pWrk + recv_offset), (uint64_t *)(pWrk + recv_offset),
84
+ nelems * sizeof(T) / sizeof(uint32_t), child);
85
+ }
86
+ }
87
+ if (PE_root == my_pe_in_team && dest != source)
88
+ nvshmemi_memcpy_threadgroup<SCOPE>(dest, source, nelems * sizeof(T));
89
+ if (!myIdx) { /* Only one thread should increment */
90
+ teami->bcast_sync_offset += sizeof(T) * nelems * 2;
91
+ }
92
+ nvshmemi_threadgroup_sync<SCOPE>();
93
+ }
94
+
95
+ template <typename T, threadgroup_t SCOPE>
96
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_internode_tree_threadgroup(
97
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root, int k) {
98
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
99
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
100
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
101
+ if (!myIdx) { /* Only one thread should increment */
102
+ teami->ll_flag++;
103
+ teami->bcast_count++;
104
+ if ((teami->bcast_sync_offset + nelems * sizeof(T) * 2) >
105
+ (sizeof(long) * NVSHMEMI_BCAST_SYNC_SIZE)) {
106
+ nvshmemi_barrier_threadgroup<NVSHMEMI_THREADGROUP_THREAD>(team);
107
+ teami->bcast_sync_offset = 0;
108
+ }
109
+ }
110
+ nvshmemi_threadgroup_sync<SCOPE>();
111
+ const uint32_t ll_flag = teami->ll_flag;
112
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, BCAST);
113
+ size_t recv_offset = teami->bcast_sync_offset;
114
+ const int my_pe_in_team = nvshmemi_team_my_pe(team);
115
+
116
+ if (PE_root != my_pe_in_team) {
117
+ nvshmemi_recvLL<T, SCOPE>(dest, (uint64_t *)(pWrk + recv_offset), nelems, ll_flag);
118
+ } else {
119
+ nvshmemi_packLL_naive<T, SCOPE>((uint64_t *)(pWrk + recv_offset), source, nelems, ll_flag);
120
+ }
121
+ nvshmemi_threadgroup_sync<SCOPE>();
122
+ for (int i = myIdx; i < k; i += groupSize) {
123
+ int child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
124
+ if (child_in_team >= teami->size) break;
125
+ child_in_team = (child_in_team + PE_root) % teami->size;
126
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
127
+
128
+ nvshmemi_put_nbi_threadgroup<uint64_t, NVSHMEMI_THREADGROUP_THREAD>(
129
+ (uint64_t *)(pWrk + recv_offset), (uint64_t *)(pWrk + recv_offset),
130
+ nelems * sizeof(T) / sizeof(uint32_t), child);
131
+ }
132
+ if (PE_root == my_pe_in_team && dest != source)
133
+ nvshmemi_memcpy_threadgroup<SCOPE>(dest, source, nelems * sizeof(T));
134
+ if (!myIdx) { /* Only one thread should increment */
135
+ teami->bcast_sync_offset += sizeof(T) * nelems * 2;
136
+ }
137
+ nvshmemi_threadgroup_sync<SCOPE>();
138
+ }
139
+
140
+ template <typename T, threadgroup_t SCOPE>
141
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_tree_threadgroup(
142
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root, int k) {
143
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
144
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
145
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
146
+ if (!myIdx) { /* Only one thread should increment */
147
+ teami->ll_flag++;
148
+ teami->bcast_count++;
149
+ if ((teami->bcast_sync_offset + nelems * sizeof(T) * 2) >
150
+ (sizeof(long) * NVSHMEMI_BCAST_SYNC_SIZE)) {
151
+ nvshmemi_barrier_threadgroup<NVSHMEMI_THREADGROUP_THREAD>(team);
152
+ teami->bcast_sync_offset = 0;
153
+ }
154
+ }
155
+ nvshmemi_threadgroup_sync<SCOPE>();
156
+ const uint32_t ll_flag = teami->ll_flag;
157
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, BCAST);
158
+ size_t recv_offset = teami->bcast_sync_offset;
159
+ const int my_pe_in_team = nvshmemi_team_my_pe(team);
160
+
161
+ if (PE_root != my_pe_in_team) {
162
+ nvshmemi_recvLL<T, SCOPE>(dest, (uint64_t *)(pWrk + recv_offset), nelems, ll_flag);
163
+ } else {
164
+ nvshmemi_packLL_naive<T, SCOPE>((uint64_t *)(pWrk + recv_offset), source, nelems, ll_flag);
165
+ }
166
+ nvshmemi_threadgroup_sync<SCOPE>();
167
+ /* Do remote transfers first */
168
+ for (int i = myIdx; i < k; i += groupSize) {
169
+ int child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
170
+ if (child_in_team >= teami->size) break;
171
+ child_in_team = (child_in_team + PE_root) % teami->size;
172
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
173
+ bool is_remote = (nvshmemi_ptr(pWrk, child) == NULL) ? true : false;
174
+ if (is_remote)
175
+ nvshmemi_put_nbi_threadgroup<uint64_t, NVSHMEMI_THREADGROUP_THREAD>(
176
+ (uint64_t *)(pWrk + recv_offset), (uint64_t *)(pWrk + recv_offset),
177
+ nelems * sizeof(T) / sizeof(uint32_t), child);
178
+ }
179
+
180
+ /* Do P2P transfers */
181
+ for (int i = 0; i < k; i++) {
182
+ int child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
183
+ if (child_in_team >= teami->size) break;
184
+ child_in_team = (child_in_team + PE_root) % teami->size;
185
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
186
+
187
+ bool is_remote = (nvshmemi_ptr(pWrk, child) == NULL) ? true : false;
188
+ if (!is_remote)
189
+ nvshmemii_put_nbi_threadgroup<uint64_t, SCOPE>(
190
+ (uint64_t *)(pWrk + recv_offset), (uint64_t *)(pWrk + recv_offset),
191
+ nelems * sizeof(T) / sizeof(uint32_t), child);
192
+ }
193
+
194
+ if (PE_root == my_pe_in_team && dest != source)
195
+ nvshmemi_memcpy_threadgroup<SCOPE>(dest, source, nelems * sizeof(T));
196
+ if (!myIdx) { /* Only one thread should increment */
197
+ teami->bcast_sync_offset += sizeof(T) * nelems * 2;
198
+ }
199
+ nvshmemi_threadgroup_sync<SCOPE>();
200
+ }
201
+
202
+ template <typename T, threadgroup_t SCOPE>
203
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_nonLL_tree_threadgroup(
204
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root, int k) {
205
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
206
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
207
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
208
+ if (!myIdx) { /* Only one thread should increment */
209
+ teami->ll_flag++;
210
+ teami->bcast_count++;
211
+ if ((teami->bcast_sync_offset + sizeof(uint64_t)) >
212
+ (sizeof(long) * NVSHMEMI_BCAST_SYNC_SIZE)) {
213
+ nvshmemi_barrier_threadgroup<NVSHMEMI_THREADGROUP_THREAD>(team);
214
+ teami->bcast_sync_offset = 0;
215
+ }
216
+ }
217
+ nvshmemi_threadgroup_sync<SCOPE>();
218
+ const uint32_t ll_flag = teami->ll_flag;
219
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, BCAST);
220
+ size_t recv_offset = teami->bcast_sync_offset;
221
+ const int my_pe_in_team = nvshmemi_team_my_pe(team);
222
+
223
+ if (PE_root != my_pe_in_team) {
224
+ nvshmemi_wait_until<uint64_t>((uint64_t *)(pWrk + recv_offset), NVSHMEM_CMP_EQ, ll_flag);
225
+ }
226
+ nvshmemi_threadgroup_sync<SCOPE>();
227
+ /* Do remote transfers first */
228
+ for (int i = myIdx; i < k; i += groupSize) {
229
+ int child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
230
+ if (child_in_team >= teami->size) break;
231
+ child_in_team = (child_in_team + PE_root) % teami->size;
232
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
233
+ bool is_remote = (nvshmemi_ptr(pWrk, child) == NULL) ? true : false;
234
+ if (is_remote)
235
+ nvshmemi_put_signal_threadgroup<T, NVSHMEMI_THREADGROUP_THREAD>(
236
+ dest, (PE_root == my_pe_in_team) ? source : dest, nelems,
237
+ (uint64_t *)(pWrk + recv_offset), ll_flag, NVSHMEMI_AMO_SIGNAL_SET, child, 1);
238
+ }
239
+
240
+ /* Do P2P transfers */
241
+ for (int i = 0; i < k; i++) {
242
+ int child_in_team = ((my_pe_in_team + (teami->size - PE_root)) % teami->size) * k + i + 1;
243
+ if (child_in_team >= teami->size) break;
244
+ child_in_team = (child_in_team + PE_root) % teami->size;
245
+ int child = nvshmemi_team_translate_pe(team, child_in_team, NVSHMEM_TEAM_WORLD_INDEX);
246
+
247
+ bool is_remote = (nvshmemi_ptr(pWrk, child) == NULL) ? true : false;
248
+ if (!is_remote)
249
+ nvshmemii_put_signal_threadgroup<T, SCOPE>(
250
+ dest, (PE_root == my_pe_in_team) ? source : dest, nelems,
251
+ (uint64_t *)(pWrk + recv_offset), ll_flag, NVSHMEMI_AMO_SIGNAL_SET, child, 1);
252
+ }
253
+
254
+ if (PE_root == my_pe_in_team && dest != source)
255
+ nvshmemi_memcpy_threadgroup<SCOPE>(dest, source, nelems * sizeof(T));
256
+ if (!myIdx) { /* Only one thread should increment */
257
+ nvshmemi_quiet<NVSHMEMI_THREADGROUP_THREAD>();
258
+ teami->bcast_sync_offset +=
259
+ 2 * sizeof(uint64_t); /* incrementing minimally by 16 bytes because this buffer is used
260
+ by packLL and packLL does 16byte writes */
261
+ }
262
+ nvshmemi_threadgroup_sync<SCOPE>();
263
+ }
264
+
265
+ template <typename T, threadgroup_t SCOPE>
266
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_put2all_threadgroup(
267
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root) {
268
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
269
+ int i;
270
+ int root = nvshmemi_team_translate_pe(team, PE_root, NVSHMEM_TEAM_WORLD_INDEX);
271
+ if (root == nvshmemi_device_state_d.mype) {
272
+ for (i = 0; i < teami->size; i++) {
273
+ int pe = nvshmemi_team_translate_pe_to_team_world_wrap(teami, i);
274
+ nvshmemi_put_nbi_threadgroup<T, SCOPE>(dest, source, nelems, pe);
275
+ }
276
+ }
277
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
278
+ }
279
+
280
+ template <typename T, threadgroup_t SCOPE>
281
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_put2all_direct_threadgroup(
282
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root) {
283
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
284
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
285
+ int i;
286
+ int root = nvshmemi_team_translate_pe(team, PE_root, NVSHMEM_TEAM_WORLD_INDEX);
287
+ T *dst_ptr;
288
+ if (root == nvshmemi_device_state_d.mype) {
289
+ for (i = 0; i < teami->size; i++) {
290
+ int pe = nvshmemi_team_translate_pe_to_team_world_wrap(teami, i);
291
+ dst_ptr = (T *)nvshmemi_ptr(dest, pe);
292
+ nvshmemi_memcpy_threadgroup<SCOPE>(dst_ptr, source, nelems * sizeof(T));
293
+ }
294
+ }
295
+
296
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
297
+ }
298
+
299
+ template <typename T, threadgroup_t SCOPE>
300
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_bcast_hierarchical_threadgroup(
301
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root) {
302
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
303
+ if (teami->is_team_same_mype_node) {
304
+ nvshmemi_bcast_internode_tree_threadgroup<T, SCOPE>(
305
+ team, dest, source, nelems, PE_root,
306
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_tree_kval);
307
+ } else if (teami->is_team_node) {
308
+ nvshmemi_bcast_intranode_tree_threadgroup<T, SCOPE>(
309
+ team, dest, source, nelems, PE_root,
310
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_tree_kval);
311
+ } else {
312
+ int team_npes_node = nvshmemi_team_n_pes(teami->team_node);
313
+ int PE_root_idx_in_team_node = PE_root % team_npes_node;
314
+ int my_idx_in_team_node = nvshmemi_team_my_pe(team) % team_npes_node;
315
+ if (PE_root_idx_in_team_node == my_idx_in_team_node) {
316
+ nvshmemi_bcast_internode_tree_threadgroup<T, SCOPE>(
317
+ teami->team_same_mype_node, dest, source, nelems, PE_root / team_npes_node,
318
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_tree_kval);
319
+ }
320
+ nvshmemi_bcast_intranode_tree_threadgroup<T, SCOPE>(
321
+ teami->team_node, dest, dest, nelems, PE_root_idx_in_team_node,
322
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_tree_kval);
323
+ }
324
+ }
325
+
326
+ template <typename T, threadgroup_t SCOPE>
327
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_broadcast_threadgroup(
328
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems, int PE_root) {
329
+ int bcast_algo = nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_algo;
330
+ switch (bcast_algo) {
331
+ case 0:
332
+ if (NVSHMEMI_BCAST_SYNC_SIZE * sizeof(long) >= (nelems * sizeof(T) * 2) &&
333
+ sizeof(T) >= sizeof(uint32_t) && nelems % 2 == 0 &&
334
+ nelems * sizeof(T) <= 16384) { /* LL algos */
335
+ if (nvshmemi_team_n_pes(team) > 32 &&
336
+ nvshmemi_device_state_d.pe_dist ==
337
+ NVSHMEMI_PE_DIST_BLOCK) { /* hierarchical topo-aware */
338
+ bcast_algo = 2;
339
+ } else
340
+ bcast_algo = 3;
341
+ } else /* non-LL algorithm */
342
+ bcast_algo = 4;
343
+ break;
344
+ case 1: /* Brutefoce algorithm: send one to all followed by barrier */
345
+ break;
346
+ case 2: /* Topology aware - two level hierarchical algorithm with LL approach */
347
+ if (NVSHMEMI_BCAST_SYNC_SIZE * sizeof(long) >= (nelems * sizeof(T) * 2) &&
348
+ sizeof(T) >= sizeof(uint32_t) && nelems % 2 == 0 &&
349
+ nvshmemi_device_state_d.pe_dist == NVSHMEMI_PE_DIST_BLOCK) {
350
+ } else {
351
+ /*printf("User selected algo: %d, but it is not supported with currect config, \
352
+ using default algo selection strategy..\n", \
353
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_algo);*/
354
+ bcast_algo = 1;
355
+ }
356
+ break;
357
+ case 3: /* Topology unaware tree algrithm with LL approach*/
358
+ if (NVSHMEMI_BCAST_SYNC_SIZE * sizeof(long) >= (nelems * sizeof(T) * 2) &&
359
+ sizeof(T) >= sizeof(uint32_t) && nelems % 2 == 0) {
360
+ } else {
361
+ /*printf("User selected algo: %d, but it is not supported with currect config, \
362
+ using default algo selection strategy..\n",
363
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_algo);*/
364
+ bcast_algo = 1;
365
+ }
366
+ break;
367
+ case 4: /* Topology unaware flat tree algrithm with LL approach*/
368
+ if (NVSHMEMI_BCAST_SYNC_SIZE * sizeof(long) >= (nelems * sizeof(T) * 2) &&
369
+ sizeof(T) >= sizeof(uint32_t) && nelems % 2 == 0) {
370
+ } else {
371
+ /* printf("User selected algo: %d, but it is not supported with currect config, \
372
+ using default algo selection strategy..\n",
373
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_algo);*/
374
+ bcast_algo = 1;
375
+ }
376
+ break;
377
+ default:
378
+ printf("Specified bcast algo:%d not supported, aborting...\n", bcast_algo);
379
+ assert(0);
380
+ break;
381
+ }
382
+
383
+ switch (bcast_algo) {
384
+ case 1: /* Brutefoce algorithm: send one to all followed by barrier */
385
+ if (nvshmemi_device_state_d.job_connectivity <= NVSHMEMI_JOB_GPU_LDST_REMOTE_ATOMICS) {
386
+ nvshmemi_bcast_put2all_direct_threadgroup<T, SCOPE>(team, dest, source, nelems,
387
+ PE_root);
388
+ } else {
389
+ nvshmemi_bcast_put2all_threadgroup<T, SCOPE>(team, dest, source, nelems, PE_root);
390
+ }
391
+ break;
392
+ case 2: /* Topology aware - two level hierarchical algorithm with LL approach */
393
+ nvshmemi_bcast_hierarchical_threadgroup<T, SCOPE>(team, dest, source, nelems, PE_root);
394
+ break;
395
+ case 3: /* Topology unaware tree algrithm with LL approach*/
396
+ nvshmemi_bcast_tree_threadgroup<T, SCOPE>(
397
+ team, dest, source, nelems, PE_root,
398
+ nvshmemi_device_state_d.gpu_coll_env_params_var.bcast_tree_kval);
399
+ break;
400
+ case 4: /* Topology unaware flat tree algrithm with LL approach*/
401
+ nvshmemi_bcast_nonLL_tree_threadgroup<T, SCOPE>(team, dest, source, nelems, PE_root,
402
+ nvshmemi_team_n_pes(team) - 1);
403
+ break;
404
+ default:
405
+ assert(0);
406
+ break;
407
+ }
408
+ }
409
+
410
+ #endif /* __CUDA_ARCH__ */
411
+
412
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/defines.cuh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef _NVSHMEMI_DEVICE_COLL_DEFINES_H_
8
+ #define _NVSHMEMI_DEVICE_COLL_DEFINES_H_
9
+
10
+ #include "alltoall.cuh"
11
+ #include "barrier.cuh"
12
+ #include "broadcast.cuh"
13
+ #include "fcollect.cuh"
14
+ #include "reduce.cuh"
15
+ #include "reducescatter.cuh"
16
+ #include "broadcast.cuh"
17
+ #include "fcollect.cuh"
18
+
19
+ #endif /* NVSHMEMI_DEVICE_COLL_DEFINES_H */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/fcollect.cuh ADDED
@@ -0,0 +1,1080 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+ #ifndef FCOLLECT_DEVICE_CUH
7
+ #define FCOLLECT_DEVICE_CUH
8
+
9
+ #if !defined __CUDACC_RTC__
10
+ #include <stdint.h>
11
+ #include <limits.h>
12
+ #else
13
+ #include "cuda/std/cstdint"
14
+ #include <cuda/std/climits>
15
+ #endif
16
+
17
+ #include <cuda_runtime.h>
18
+ #include "device_host/nvshmem_common.cuh"
19
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
20
+ #include "non_abi/device/common/nvshmemi_tile_utils.cuh"
21
+ #include "non_abi/nvshmem_build_options.h"
22
+ #include "device_host/nvshmem_tensor.h"
23
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
24
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
25
+ #else
26
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
27
+ #endif
28
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
29
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
30
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
31
+
32
+ #define _FCOLLECT_LL8_PSYNC_SCALE_FACTOR 2
33
+
34
+ #define _FCOLLECT_MAX(x, y) ((x) > (y) ? (x) : (y))
35
+ #define _FCOLLECT_MIN(x, y) ((x) < (y) ? (x) : (y))
36
+
37
+ typedef enum { LL8 = 0, LL128 } ll_version_t;
38
+
39
+ #ifdef __CUDA_ARCH__
40
+
41
+ template <typename T, threadgroup_t SCOPE>
42
+ __device__ NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE void nvshmemi_fcollect_nvls_ll_threadgroup(
43
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems) {
44
+ #if defined __clang_llvm_bitcode_lib__
45
+ if (__nvvm_reflect("__CUDA_ARCH") >= 900) {
46
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
47
+ const size_t fcollect_ll_threshold =
48
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold;
49
+ const size_t fcollect_count = teami->fcollect_count;
50
+ const uint32_t ll_flag = teami->fcollect_count;
51
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, FCOLLECT) +
52
+ (2 * teami->size * fcollect_ll_threshold *
53
+ (fcollect_count % 2)); /* same for NVLS in terms of size */
54
+ const size_t pack_offset = (nvshmemi_team_my_pe(team) * nelems * sizeof(T)) /
55
+ sizeof(uint32_t); /* offset in pSync space */
56
+ /* Find the multicast ptr for pWrk + pack_offset and do a store to remote pSync */
57
+ void *mcast_pWrk = nvshmemi_mc_ptr(teami, (void *)((uint64_t *)pWrk + pack_offset));
58
+ nvshmemi_mcast_packLL<T, SCOPE>((uint64_t *)mcast_pWrk, source, nelems, ll_flag);
59
+ for (int ii = 0; ii < teami->size; ii += 1) {
60
+ size_t prev_offset = (nelems * ii * sizeof(T)) / sizeof(uint32_t);
61
+ nvshmemi_mcast_recvLL<T, SCOPE>(dest + (ii * nelems), (uint64_t *)pWrk + prev_offset,
62
+ nelems, ll_flag);
63
+ }
64
+
65
+ nvshmemi_threadgroup_sync<SCOPE>();
66
+ } else {
67
+ assert(0 && "NVLink SHARP is not supported on this platform");
68
+ }
69
+ #else
70
+ #if __CUDA_ARCH__ >= 900 && CUDART_VERSION >= 12010
71
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
72
+ const size_t fcollect_ll_threshold =
73
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold;
74
+ const size_t fcollect_count = teami->fcollect_count;
75
+ const uint32_t ll_flag = teami->fcollect_count;
76
+ char *pWrk = (char *)nvshmemi_team_get_psync(teami, FCOLLECT) +
77
+ (2 * teami->size * fcollect_ll_threshold *
78
+ (fcollect_count % 2)); /* same for NVLS in terms of size */
79
+ const size_t pack_offset = (nvshmemi_team_my_pe(team) * nelems * sizeof(T)) /
80
+ sizeof(uint32_t); /* offset in pSync space */
81
+ /* Find the multicast ptr for pWrk + pack_offset and do a store to remote pSync */
82
+ void *mcast_pWrk = nvshmemi_mc_ptr(teami, (void *)((uint64_t *)pWrk + pack_offset));
83
+ nvshmemi_mcast_packLL<T, SCOPE>((uint64_t *)mcast_pWrk, source, nelems, ll_flag);
84
+ for (int ii = 0; ii < teami->size; ii += 1) {
85
+ size_t prev_offset = (nelems * ii * sizeof(T)) / sizeof(uint32_t);
86
+ nvshmemi_mcast_recvLL<T, SCOPE>(dest + (ii * nelems), (uint64_t *)pWrk + prev_offset,
87
+ nelems, ll_flag);
88
+ }
89
+
90
+ nvshmemi_threadgroup_sync<SCOPE>();
91
+ #else
92
+ assert(0 && "NVLink SHARP is not supported on this platform");
93
+ #endif
94
+ #endif
95
+ }
96
+
97
+ /* This function must not ever call a block-scoped synchronization API.
98
+ * See call-site in nvshmemi_fcollect_threadgroup
99
+ */
100
+ template <typename T, threadgroup_t SCOPE, ll_version_t LL_VERSION, bool NODE_SAFE>
101
+ __device__ NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE void nvshmemi_fcollect_allpush_ll_threadgroup(
102
+ nvshmem_team_t team, T *dest, const T *source, size_t nelems) {
103
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
104
+ nvshmemi_team_t *teami_node = NULL;
105
+ const size_t fcollect_count = teami->fcollect_count;
106
+ const uint32_t ll_flag = teami->fcollect_count;
107
+ const int my_pe_in_team = teami->my_pe;
108
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
109
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
110
+ const int myWarpIdx = nvshmemi_thread_id_in_threadgroup<NVSHMEMI_THREADGROUP_WARP>();
111
+ size_t data_element_offset;
112
+ size_t psync_element_offset;
113
+ size_t psync_remote_write_elements;
114
+ T *peer_addr;
115
+
116
+ T *pWrk;
117
+ size_t pack_offset;
118
+ size_t max_data_elems_per_warp;
119
+ size_t max_psync_elems_per_warp;
120
+ int next_pe, start_pe;
121
+ int num_pes_per_group, remaining_pes;
122
+ int num_warp_groups, num_warps_per_group;
123
+ int warp_id, warp_count, warp_group_id;
124
+
125
+ if (NODE_SAFE) {
126
+ /*
127
+ * Really we mean team shared here, but that is not a team that exists today.
128
+ * TODO: Replace team_node with team_shared.
129
+ */
130
+ if (teami->are_gpus_p2p_connected) {
131
+ teami_node = teami;
132
+ } else if (teami->team_node != NVSHMEM_TEAM_INVALID &&
133
+ nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_SHARED]->is_team_node) {
134
+ teami_node = nvshmemi_device_state_d.team_pool[teami->team_node];
135
+ }
136
+ }
137
+
138
+ warp_count = nvshmemi_threadgroup_size<SCOPE>() / 32;
139
+ warp_id = myIdx / 32;
140
+
141
+ if (LL_VERSION == LL8) {
142
+ const size_t fcollect_ll_threshold =
143
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold / sizeof(T);
144
+ pWrk = (T *)nvshmemi_team_get_psync(teami, FCOLLECT) +
145
+ (_FCOLLECT_LL8_PSYNC_SCALE_FACTOR * teami->size * fcollect_ll_threshold *
146
+ (fcollect_count % 2));
147
+ /* round up to 16 bytes*/
148
+ psync_remote_write_elements =
149
+ NVSHMEMI_TEAM_ROUND_UP((nelems * _FCOLLECT_LL8_PSYNC_SCALE_FACTOR), 16 / sizeof(T));
150
+ pack_offset = my_pe_in_team * psync_remote_write_elements;
151
+ if (!NODE_SAFE || !teami->is_team_node) {
152
+ nvshmemi_packLL<T, SCOPE, 1>((T *)(pWrk + pack_offset), source, nelems, ll_flag, teami,
153
+ 1, my_pe_in_team);
154
+ }
155
+ } else {
156
+ const size_t fcollect_ll_threshold =
157
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll128_threshold / sizeof(T);
158
+ pWrk = (T *)nvshmemi_team_get_psync(teami, FCOLLECT_128) +
159
+ (teami->size * NVSHMEMI_FCOLLECT_LL128_CALC_PSYNC_SIZE(fcollect_ll_threshold, T) *
160
+ (fcollect_count % 2));
161
+ psync_remote_write_elements = NVSHMEMI_FCOLLECT_LL128_CALC_PSYNC_SIZE(nelems, T);
162
+ pack_offset = my_pe_in_team * psync_remote_write_elements;
163
+ if (!NODE_SAFE || !teami->is_team_node) {
164
+ nvshmemi_packLL128<T, SCOPE, 1>(pWrk + pack_offset, source, nelems, ll_flag, teami, 1,
165
+ my_pe_in_team, 0);
166
+ }
167
+ }
168
+
169
+ /* send out non blocking puts for all remote PEs */
170
+ if (teami_node != teami) {
171
+ for (uint32_t ii = myIdx + 1 + my_pe_in_team; ii < teami->size + my_pe_in_team;
172
+ ii += groupSize) {
173
+ next_pe = nvshmemi_team_translate_pe_to_team_world_wrap(teami, ii);
174
+ if (NODE_SAFE) {
175
+ if (nvshmemi_ptr(pWrk, next_pe) == NULL) {
176
+ nvshmemi_put_nbi_threadgroup<T, NVSHMEMI_THREADGROUP_THREAD>(
177
+ pWrk + pack_offset, pWrk + pack_offset, psync_remote_write_elements,
178
+ next_pe);
179
+ }
180
+ } else {
181
+ nvshmemi_put_nbi_threadgroup<T, NVSHMEMI_THREADGROUP_THREAD>(
182
+ pWrk + pack_offset, pWrk + pack_offset, psync_remote_write_elements, next_pe);
183
+ }
184
+ }
185
+ nvshmemi_threadgroup_sync<NVSHMEMI_THREADGROUP_WARP>();
186
+ }
187
+
188
+ if (LL_VERSION == LL8) {
189
+ max_data_elems_per_warp = _LL_8_DATA_BYTES_PER_WARP * _LL_MAX_UNROLL / sizeof(T);
190
+ max_psync_elems_per_warp = _LL_8_PSYNC_BYTES_PER_WARP * _LL_MAX_UNROLL / sizeof(T);
191
+ if (nelems < max_data_elems_per_warp) {
192
+ if (teami_node) {
193
+ for (uint32_t ii = warp_id + my_pe_in_team; ii < teami_node->size + my_pe_in_team;
194
+ ii += warp_count) {
195
+ next_pe = nvshmemi_team_translate_pe_to_team_world_wrap(teami_node, ii);
196
+ peer_addr = (T *)nvshmemi_ptr(pWrk, next_pe) + pack_offset;
197
+ nvshmemi_packLL_naive<T, NVSHMEMI_THREADGROUP_WARP>((uint64_t *)peer_addr,
198
+ source, nelems, ll_flag);
199
+ }
200
+ }
201
+
202
+ for (uint32_t ii = warp_id; ii < teami->size; ii += warp_count) {
203
+ next_pe = ii;
204
+ pack_offset =
205
+ next_pe * NVSHMEMI_TEAM_ROUND_UP((nelems * _FCOLLECT_LL8_PSYNC_SCALE_FACTOR),
206
+ 16 / sizeof(T));
207
+ nvshmemi_recvLL<T, NVSHMEMI_THREADGROUP_WARP>(
208
+ dest + (next_pe * nelems), (uint64_t *)(pWrk + pack_offset), nelems, ll_flag);
209
+ }
210
+ return;
211
+ }
212
+ } else {
213
+ max_data_elems_per_warp = _LL_128_DATA_BYTES_PER_WARP * _LL_MAX_UNROLL / sizeof(T);
214
+ max_psync_elems_per_warp = _LL_128_PSYNC_BYTES_PER_WARP * _LL_MAX_UNROLL / sizeof(T);
215
+ }
216
+
217
+ num_warp_groups =
218
+ _FCOLLECT_MAX(1, warp_count / _FCOLLECT_MAX(1, nelems / max_data_elems_per_warp));
219
+ num_warps_per_group = warp_count / num_warp_groups;
220
+ warp_group_id = warp_id / num_warps_per_group;
221
+
222
+ if (teami_node != NULL) {
223
+ /* first n ggroups take on an extra PE in the case of remainder */
224
+ num_pes_per_group = teami_node->size / num_warp_groups;
225
+ remaining_pes = teami_node->size % num_warp_groups;
226
+ num_pes_per_group += warp_group_id < remaining_pes ? 1 : 0;
227
+
228
+ start_pe = num_pes_per_group * warp_group_id;
229
+ start_pe += warp_group_id >= remaining_pes ? remaining_pes : 0;
230
+
231
+ data_element_offset = warp_id % num_warps_per_group * max_data_elems_per_warp;
232
+ psync_element_offset = warp_id % num_warps_per_group * max_psync_elems_per_warp;
233
+ /* All warps except final one per-pe should be full. */
234
+ for (; data_element_offset + max_data_elems_per_warp < nelems;
235
+ data_element_offset += num_warps_per_group * max_data_elems_per_warp,
236
+ psync_element_offset += num_warps_per_group * max_psync_elems_per_warp) {
237
+ if (LL_VERSION == LL8) {
238
+ nvshmemi_packLL<T, NVSHMEMI_THREADGROUP_WARP, _LL_MAX_UNROLL>(
239
+ pWrk + pack_offset + psync_element_offset, source + data_element_offset,
240
+ max_data_elems_per_warp, ll_flag, teami_node, num_pes_per_group, start_pe);
241
+ } else {
242
+ nvshmemi_packLL128<T, NVSHMEMI_THREADGROUP_WARP, _LL_MAX_UNROLL>(
243
+ pWrk + pack_offset + psync_element_offset, source + data_element_offset,
244
+ max_data_elems_per_warp, ll_flag, teami_node, num_pes_per_group, start_pe,
245
+ warp_id % num_warps_per_group);
246
+ }
247
+ }
248
+
249
+ if (nelems > data_element_offset) {
250
+ if (LL_VERSION == LL8) {
251
+ nvshmemi_packLL<T, NVSHMEMI_THREADGROUP_WARP, 1>(
252
+ pWrk + pack_offset + psync_element_offset, source + data_element_offset,
253
+ nelems - data_element_offset, ll_flag, teami_node, num_pes_per_group, start_pe);
254
+ } else {
255
+ nvshmemi_packLL128<T, NVSHMEMI_THREADGROUP_WARP, 1>(
256
+ pWrk + pack_offset + psync_element_offset, source + data_element_offset,
257
+ nelems - data_element_offset, ll_flag, teami_node, num_pes_per_group, start_pe,
258
+ warp_id % num_warps_per_group);
259
+ ;
260
+ }
261
+ }
262
+ }
263
+
264
+ /* todo: also try unrolling in recvLL */
265
+ num_pes_per_group = teami->size / num_warp_groups;
266
+ remaining_pes = teami->size % num_warp_groups;
267
+ /* first n ggroups take on an extra PE in the case of remainder */
268
+ num_pes_per_group += warp_group_id < remaining_pes ? 1 : 0;
269
+
270
+ start_pe = num_pes_per_group * warp_group_id;
271
+ start_pe += warp_group_id >= remaining_pes ? remaining_pes : 0;
272
+ data_element_offset = warp_id % num_warps_per_group * max_data_elems_per_warp;
273
+ psync_element_offset = warp_id % num_warps_per_group * max_psync_elems_per_warp;
274
+ for (; data_element_offset + max_data_elems_per_warp < nelems;
275
+ data_element_offset += num_warps_per_group * max_data_elems_per_warp,
276
+ psync_element_offset += num_warps_per_group * max_psync_elems_per_warp) {
277
+ for (next_pe = start_pe; next_pe < start_pe + num_pes_per_group; next_pe++) {
278
+ if (LL_VERSION == LL8) {
279
+ pack_offset =
280
+ next_pe * NVSHMEMI_TEAM_ROUND_UP((nelems * _FCOLLECT_LL8_PSYNC_SCALE_FACTOR),
281
+ 16 / sizeof(T)) +
282
+ psync_element_offset;
283
+ nvshmemi_recvLL<T, NVSHMEMI_THREADGROUP_WARP>(
284
+ dest + (next_pe * nelems) + data_element_offset,
285
+ (uint64_t *)(pWrk + pack_offset), max_data_elems_per_warp, ll_flag);
286
+ } else {
287
+ pack_offset = next_pe * NVSHMEMI_FCOLLECT_LL128_CALC_PSYNC_SIZE(nelems, T) +
288
+ psync_element_offset;
289
+ nvshmemi_recvLL128<T, _LL_MAX_UNROLL>(
290
+ dest + (next_pe * nelems) + data_element_offset, pWrk + pack_offset,
291
+ max_data_elems_per_warp, ll_flag);
292
+ }
293
+ }
294
+ }
295
+
296
+ if (nelems > data_element_offset) {
297
+ for (next_pe = start_pe; next_pe < start_pe + num_pes_per_group; next_pe++) {
298
+ if (LL_VERSION == LL8) {
299
+ pack_offset =
300
+ next_pe * NVSHMEMI_TEAM_ROUND_UP((nelems * _FCOLLECT_LL8_PSYNC_SCALE_FACTOR),
301
+ 16 / sizeof(T)) +
302
+ psync_element_offset;
303
+ nvshmemi_recvLL<T, NVSHMEMI_THREADGROUP_WARP>(
304
+ dest + (next_pe * nelems) + data_element_offset,
305
+ (uint64_t *)(pWrk + pack_offset), nelems - data_element_offset, ll_flag);
306
+ } else {
307
+ pack_offset = next_pe * NVSHMEMI_FCOLLECT_LL128_CALC_PSYNC_SIZE(nelems, T) +
308
+ psync_element_offset;
309
+ nvshmemi_recvLL128<T, 1>(dest + (next_pe * nelems) + data_element_offset,
310
+ pWrk + pack_offset, nelems - data_element_offset, ll_flag);
311
+ }
312
+ }
313
+ }
314
+ }
315
+
316
+ template <typename T, threadgroup_t SCOPE>
317
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_fcollect_allpush_threadgroup(
318
+ nvshmem_team_t team, T *dest, const T *source, int dest_offset, size_t nelems) {
319
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
320
+ int next_rank;
321
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
322
+
323
+ // nvshmemi_threadgroup_sync<SCOPE>();
324
+ for (int ii = teami->my_pe; ii < teami->size + teami->my_pe; ii++) {
325
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, ii);
326
+ nvshmemi_put_nbi_threadgroup<T, SCOPE>(dest + dest_offset, source, nelems, next_rank);
327
+ }
328
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
329
+ }
330
+
331
+ template <typename T, threadgroup_t SCOPE>
332
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_fcollect_p2p_allpush_threadgroup(
333
+ nvshmem_team_t team, T *dest, const T *source, int dest_offset, size_t nelems) {
334
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
335
+ int next_rank;
336
+ T *dst_ptr;
337
+ nvshmemi_threadgroup_sync<SCOPE>();
338
+ for (int ii = teami->my_pe; ii < teami->size + teami->my_pe; ii++) {
339
+ next_rank = nvshmemi_team_translate_pe_to_team_world_wrap(teami, ii);
340
+ dst_ptr = (T *)nvshmemi_ptr((void *)(dest + dest_offset), next_rank);
341
+ nvshmemi_memcpy_threadgroup<SCOPE>(dst_ptr, source, nelems * sizeof(T));
342
+ }
343
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
344
+ }
345
+
346
+ template <typename T, threadgroup_t SCOPE>
347
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_fcollect_nvls_allpush_threadgroup(
348
+ nvshmem_team_t team, T *dest, const T *source, int dest_offset, size_t nelems) {
349
+ #if defined __clang_llvm_bitcode_lib__
350
+ if (__nvvm_reflect("__CUDA_ARCH") >= 900) {
351
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
352
+ nvshmemi_threadgroup_sync<SCOPE>();
353
+ T *dst_ptr = (T *)nvshmemi_mc_ptr(teami, (void *)(dest + dest_offset));
354
+ nvshmemi_mcast_memcpy_threadgroup<T, SCOPE>(dst_ptr, source, nelems * sizeof(T));
355
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
356
+ } else {
357
+ assert(0 && "NVLS is not supported on this platform");
358
+ }
359
+ #else
360
+ #if __CUDA_ARCH__ >= 900 && CUDART_VERSION >= 12010
361
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
362
+ nvshmemi_threadgroup_sync<SCOPE>();
363
+ T *dst_ptr = (T *)nvshmemi_mc_ptr(teami, (void *)(dest + dest_offset));
364
+ nvshmemi_mcast_memcpy_threadgroup<T, SCOPE>(dst_ptr, source, nelems * sizeof(T));
365
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
366
+ #else
367
+ assert(0 && "NVLS is not supported on this platform");
368
+ #endif
369
+ #endif
370
+ }
371
+
372
+ template <typename T, threadgroup_t SCOPE>
373
+ __device__ NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE void nvshmemi_fcollect_threadgroup(
374
+ nvshmem_team_t team, T *dest, const T *source, int dest_offset, size_t nelems) {
375
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
376
+ int nthreads = nvshmemi_threadgroup_size<SCOPE>();
377
+ if (!myIdx) /* Only one thread should increment fcollect_count */
378
+ nvshmemi_device_state_d.team_pool[team]->fcollect_count += 1;
379
+ nvshmemi_threadgroup_sync<SCOPE>();
380
+ constexpr bool is_half_prec =
381
+ is_half<T>::value || is_bfloat<T>::value || is_uint16<T>::value || is_int16<T>::value;
382
+ int fcollect_algo = nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_algo;
383
+ int p2p_direct =
384
+ (nvshmemi_device_state_d.job_connectivity <= NVSHMEMI_JOB_GPU_LDST_REMOTE_ATOMICS);
385
+ const size_t fcollect_ll_threshold =
386
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold;
387
+ const size_t fcollect_ll128_threshold =
388
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll128_threshold;
389
+ /* NVLS LL performs better with block scoped than thread/warp scoped operations
390
+ due to better efficiency of distributing cvt/pack/unpack ops across threads across GPUs */
391
+ const uint8_t prefer_nvls_ll = (SCOPE == NVSHMEMI_THREADGROUP_BLOCK);
392
+ bool valid_ll_configuration = (SCOPE != NVSHMEMI_THREADGROUP_THREAD &&
393
+ ((sizeof(T) >= sizeof(uint32_t) && (nelems % 2 == 0)) ||
394
+ (is_half_prec && (nelems % 4 == 0) &&
395
+ (nvshmemi_device_state_d.team_pool[team]->size % 2 == 0))));
396
+ /* DISABLE non NVLS LL for hybrid MNNVL configurations. */
397
+ valid_ll_configuration &=
398
+ (nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_WORLD_INDEX]->are_gpus_p2p_connected ||
399
+ nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_SHARED]->is_team_node ||
400
+ !nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_NODE_INDEX]->are_gpus_p2p_connected);
401
+ /* This 2-level selection logic is implemented to reduce code duplication of calling leaf
402
+ * functions on the device code */
403
+ switch (fcollect_algo) {
404
+ case 0: /* default selection */ {
405
+ if (valid_ll_configuration && fcollect_ll_threshold >= (nelems * sizeof(T))) {
406
+ fcollect_algo = FCOLLECT_LL8; /* LL algorithm */
407
+ } else if (valid_ll_configuration && (nelems * sizeof(T)) < fcollect_ll128_threshold) {
408
+ fcollect_algo = FCOLLECT_LL128;
409
+ } else if (sizeof(T) >= sizeof(uint32_t) && (nelems % 2 == 0) &&
410
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold >=
411
+ (nelems * sizeof(T)) &&
412
+ nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL &&
413
+ prefer_nvls_ll) {
414
+ fcollect_algo = FCOLLECT_NVLS_LL; /* NVLS LL algorithm */
415
+ } else if (nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL &&
416
+ (nelems * sizeof(T)) % 4 == 0) {
417
+ fcollect_algo = FCOLLECT_NVLS; /* NVLS One shot algorithm */
418
+ } else {
419
+ fcollect_algo = FCOLLECT_ONESHOT; /* P2P One shot algorithm */
420
+ }
421
+ } break;
422
+ case FCOLLECT_LL8: /* LL algorithm */
423
+ if (!valid_ll_configuration) {
424
+ fcollect_algo = FCOLLECT_ONESHOT;
425
+ }
426
+ break;
427
+ case FCOLLECT_ONESHOT: /* One shot */
428
+ break;
429
+ case FCOLLECT_NVLS:
430
+ if (nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL &&
431
+ (nelems * sizeof(T)) % 4 == 0) {
432
+ /* NVLS simple */
433
+ break;
434
+ } else {
435
+ fcollect_algo = FCOLLECT_ONESHOT; /* One shot */
436
+ break;
437
+ }
438
+ case FCOLLECT_NVLS_LL:
439
+ if (sizeof(T) >= sizeof(uint32_t) && (nelems % 2 == 0) &&
440
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold >=
441
+ (nelems * sizeof(T)) &&
442
+ nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL) {
443
+ fcollect_algo = FCOLLECT_NVLS_LL; /* Use NVLS LL */
444
+ } else if (nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL &&
445
+ (nelems * sizeof(T)) % 4 == 0) {
446
+ fcollect_algo = FCOLLECT_NVLS; /* Switch to NVLS simple */
447
+ } else {
448
+ fcollect_algo = FCOLLECT_ONESHOT; /* One shot */
449
+ }
450
+ break;
451
+ case FCOLLECT_LL128: /* LL 128 */
452
+ if (!valid_ll_configuration) {
453
+ fcollect_algo = FCOLLECT_ONESHOT;
454
+ }
455
+ break;
456
+ default:
457
+ assert(0 && "Unsupported fcollect algo");
458
+ break;
459
+ }
460
+
461
+ switch (fcollect_algo) {
462
+ case FCOLLECT_LL8:
463
+ if (myIdx < nthreads / 32 * 32) {
464
+ if (nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_NODE_INDEX]
465
+ ->are_gpus_p2p_connected) {
466
+ nvshmemi_fcollect_allpush_ll_threadgroup<T, SCOPE, LL8, true>(team, dest,
467
+ source, nelems);
468
+ } else {
469
+ nvshmemi_fcollect_allpush_ll_threadgroup<T, SCOPE, LL8, false>(team, dest,
470
+ source, nelems);
471
+ }
472
+ }
473
+ nvshmemi_threadgroup_sync<SCOPE>();
474
+ break;
475
+ case FCOLLECT_ONESHOT:
476
+ if (p2p_direct)
477
+ nvshmemi_fcollect_p2p_allpush_threadgroup<T, SCOPE>(team, dest, source, dest_offset,
478
+ nelems);
479
+ else
480
+ nvshmemi_fcollect_allpush_threadgroup<T, SCOPE>(team, dest, source, dest_offset,
481
+ nelems);
482
+ break;
483
+ case FCOLLECT_NVLS:
484
+ nvshmemi_fcollect_nvls_allpush_threadgroup<T, SCOPE>(team, dest, source, dest_offset,
485
+ nelems);
486
+ break;
487
+ case FCOLLECT_LL128:
488
+ if (myIdx < nthreads / 32 * 32) {
489
+ if (nvshmemi_device_state_d.team_pool[NVSHMEM_TEAM_NODE_INDEX]
490
+ ->are_gpus_p2p_connected) {
491
+ nvshmemi_fcollect_allpush_ll_threadgroup<T, SCOPE, LL128, true>(team, dest,
492
+ source, nelems);
493
+ } else {
494
+ nvshmemi_fcollect_allpush_ll_threadgroup<T, SCOPE, LL128, false>(
495
+ team, dest, source, nelems);
496
+ }
497
+ }
498
+ nvshmemi_threadgroup_sync<SCOPE>();
499
+ break;
500
+ case FCOLLECT_NVLS_LL:
501
+ nvshmemi_fcollect_nvls_ll_threadgroup<T, SCOPE>(team, dest, source, nelems);
502
+ break;
503
+ default:
504
+ assert(0);
505
+ break;
506
+ }
507
+ }
508
+
509
+ // ************** Tile allgather **************/
510
+
511
+ template <typename elemType, threadgroup_t SCOPE, typename tuple_t, int major_dim, int minor_dim>
512
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_tile_allgather_mcast_threadgroup_v4(
513
+ int4 *dest, const int4 *source, const int nelem_major_dim, const int nelem_minor_dim,
514
+ const int src_stride_minor_dim, const int dst_stride_minor_dim, const int src_stride_major_dim,
515
+ const int dst_stride_major_dim, tuple_t start_coord, tuple_t boundary) {
516
+ /*src_stride_major_dim == 0 && dst_stride_major_dim == 0 for vectorized implementation*/
517
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
518
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
519
+ int nelems = nelem_major_dim * nelem_minor_dim; /* # vec elems*/
520
+ if constexpr (std::is_empty<tuple_t>::value) {
521
+ /* If no predicate, we vectorize the operation */
522
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
523
+ uint32_t u4[4];
524
+ asm("ld.global.v4.b32 {%0, %1, %2, %3}, [%4];"
525
+ : "=r"(u4[0]), "=r"(u4[1]), "=r"(u4[2]), "=r"(u4[3])
526
+ : "l"(source + ((j) % nelem_major_dim) +
527
+ ((j) / nelem_major_dim) * src_stride_minor_dim));
528
+
529
+ asm("multimem.st.global.v4.f32 [%0], {%1, %2, %3, %4};" ::"l"(
530
+ dest + ((j) % nelem_major_dim) +
531
+ (((j) / nelem_major_dim) * dst_stride_minor_dim)),
532
+ "r"(u4[0]), "r"(u4[1]), "r"(u4[2]), "r"(u4[3])
533
+ : "memory");
534
+ }
535
+ } else {
536
+ using vtype = int4;
537
+ using cxx_type = uint32_t;
538
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
539
+ uint32_t u4[4];
540
+ /* nelem_major_dim is in vector units*/
541
+ uint32_t elem_coord_major = (j % nelem_major_dim) * (sizeof(vtype) / sizeof(elemType));
542
+ uint32_t elem_coord_minor = (j / nelem_major_dim);
543
+
544
+ /* start_coord, boundary are in elemType units */
545
+ /* Check if entire vector is within boundary */
546
+ /* start_coord_major_dim + elem_coord_major_dim + vector len (in elements) <=
547
+ * boundary_major_dim */
548
+ if (is_less_than<tuple_t, major_dim>(
549
+ start_coord, create_coord_tuple<major_dim>(elem_coord_major, elem_coord_minor),
550
+ boundary, (sizeof(vtype) / sizeof(elemType)))) {
551
+ asm("ld.global.v4.b32 {%0, %1, %2, %3}, [%4];"
552
+ : "=r"(u4[0]), "=r"(u4[1]), "=r"(u4[2]), "=r"(u4[3])
553
+ : "l"(source + ((j) % nelem_major_dim) +
554
+ ((j) / nelem_major_dim) * src_stride_minor_dim));
555
+
556
+ asm("multimem.st.global.v4.f32 [%0], {%1, %2, %3, %4};" ::"l"(
557
+ dest + ((j) % nelem_major_dim) +
558
+ (((j) / nelem_major_dim) * dst_stride_minor_dim)),
559
+ "r"(u4[0]), "r"(u4[1]), "r"(u4[2]), "r"(u4[3])
560
+ : "memory");
561
+
562
+ } else { /* not all pred elems in vector are 1 */
563
+ /* perform operations one elem at a time */
564
+ /* if elem type is < 4B (e.g., f16, bf16), we check at granularity of 4B */
565
+
566
+ /* convert elem_coord_major from elemType to cxx_type units */
567
+ /* no change to elem_coord_minor */
568
+ elem_coord_major = (elem_coord_major * sizeof(elemType)) / sizeof(cxx_type);
569
+
570
+ /* vector is partially within boundary, check each element */
571
+ cxx_type val;
572
+ for (int u = 0; u < sizeof(vtype) / sizeof(cxx_type); ++u) {
573
+ /* check if elem is within boundary, use u & elem_coord_major in elemType units
574
+ */
575
+ if (is_less_than<tuple_t, major_dim>(
576
+ start_coord,
577
+ create_coord_tuple<major_dim>(
578
+ ((elem_coord_major + u) * sizeof(cxx_type) / sizeof(elemType)),
579
+ elem_coord_minor),
580
+ boundary)) {
581
+ /* convert strides from vector to cxx_type units */
582
+ asm("ld.global.b32 %0, [%1];"
583
+ : "=r"(val)
584
+ : "l"(reinterpret_cast<const cxx_type *>(source) +
585
+ (elem_coord_major + u) +
586
+ (elem_coord_minor * src_stride_minor_dim *
587
+ (sizeof(vtype) / sizeof(cxx_type)))));
588
+
589
+ asm("multimem.st.global.u32 [%0], %1;" ::"l"(
590
+ reinterpret_cast<cxx_type *>(dest) + (elem_coord_major + u) +
591
+ (elem_coord_minor * dst_stride_minor_dim *
592
+ (sizeof(vtype) / sizeof(cxx_type)))),
593
+ "r"(val)
594
+ : "memory");
595
+ }
596
+ }
597
+ }
598
+ }
599
+ } /*end of if else*/
600
+ }
601
+
602
+ template <typename elemType, threadgroup_t SCOPE, typename tuple_t, int major_dim, int minor_dim>
603
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_tile_allgather_mcast_threadgroup_v2(
604
+ uint64_t *dest, const uint64_t *source, const int nelem_major_dim, const int nelem_minor_dim,
605
+ const int src_stride_minor_dim, const int dst_stride_minor_dim, const int src_stride_major_dim,
606
+ const int dst_stride_major_dim, tuple_t start_coord, tuple_t boundary) {
607
+ /* src_stride_major_dim == 0 && dst_stride_major_dim == 0 for vectorized implementation */
608
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
609
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
610
+ int nelems = nelem_major_dim * nelem_minor_dim; /* # vec elems*/
611
+
612
+ if constexpr (std::is_empty<tuple_t>::value) {
613
+ /* If no predicate, we vectorize the operation */
614
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
615
+ uint64_t val1;
616
+ asm("ld.global.b64 %0, [%1];"
617
+ : "=l"(val1)
618
+ : "l"(source + ((j) % nelem_major_dim) +
619
+ ((j) / nelem_major_dim) * src_stride_minor_dim));
620
+
621
+ asm("multimem.st.global.u64 [%0], %1;" ::"l"(
622
+ dest + ((j) % nelem_major_dim) +
623
+ (((j) / nelem_major_dim) * dst_stride_minor_dim)),
624
+ "l"(val1)
625
+ : "memory");
626
+ }
627
+ } else {
628
+ using vtype = uint64_t;
629
+ using cxx_type = uint32_t;
630
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
631
+ uint64_t val1;
632
+ /* nelem_major_dim is in vector units*/
633
+ /* compute elem_coord_major in elemType units*/
634
+ uint32_t elem_coord_major = (j % nelem_major_dim) * (sizeof(vtype) / sizeof(elemType));
635
+ uint32_t elem_coord_minor = (j / nelem_major_dim);
636
+
637
+ /* start_coord, boundary are in elemType units */
638
+ /* Check if entire vector is within boundary */
639
+ /* start_coord_major_dim + elem_coord_major_dim + vector len (in elements) <=
640
+ * boundary_major_dim */
641
+ if (is_less_than<tuple_t, major_dim>(
642
+ start_coord, create_coord_tuple<major_dim>(elem_coord_major, elem_coord_minor),
643
+ boundary, (sizeof(vtype) / sizeof(elemType)))) {
644
+ asm("ld.global.b64 %0, [%1];"
645
+ : "=l"(val1)
646
+ : "l"(source + ((j) % nelem_major_dim) +
647
+ ((j) / nelem_major_dim) * src_stride_minor_dim));
648
+
649
+ asm("multimem.st.global.u64 [%0], %1;" ::"l"(
650
+ dest + ((j) % nelem_major_dim) +
651
+ (((j) / nelem_major_dim) * dst_stride_minor_dim)),
652
+ "l"(val1)
653
+ : "memory");
654
+
655
+ } else { /* not all pred elems in vector are 1 */
656
+ /* perform operations one elem at a time */
657
+ /* if elem type is < 4B (e.g., f16, bf16), we check at granularity of 4B */
658
+
659
+ /* convert elem_coord_major from elemType to cxx_type units */
660
+ /* no change to elem_coord_minor */
661
+ elem_coord_major = (elem_coord_major * sizeof(elemType)) / sizeof(cxx_type);
662
+
663
+ /* vector is partially within boundary, check each element */
664
+ cxx_type val;
665
+ for (int u = 0; u < sizeof(vtype) / sizeof(cxx_type); ++u) {
666
+ /* check if elem is within boundary, use u and elem_coord_major in elemType
667
+ * units */
668
+ if (is_less_than<tuple_t, major_dim>(
669
+ start_coord,
670
+ create_coord_tuple<major_dim>(
671
+ ((elem_coord_major + u) * sizeof(cxx_type) / sizeof(elemType)),
672
+ elem_coord_minor),
673
+ boundary)) {
674
+ /* convert strides from vector to cxx_type units */
675
+ asm("ld.global.b32 %0, [%1];"
676
+ : "=r"(val)
677
+ : "l"(reinterpret_cast<const cxx_type *>(source) +
678
+ (elem_coord_major + u) +
679
+ (elem_coord_minor * src_stride_minor_dim *
680
+ (sizeof(vtype) / sizeof(cxx_type)))));
681
+
682
+ asm("multimem.st.global.u32 [%0], %1;" ::"l"(
683
+ reinterpret_cast<cxx_type *>(dest) + (elem_coord_major + u) +
684
+ (elem_coord_minor * dst_stride_minor_dim *
685
+ (sizeof(vtype) / sizeof(cxx_type)))),
686
+ "r"(val)
687
+ : "memory");
688
+ }
689
+ }
690
+ }
691
+ }
692
+ } /*end of if else*/
693
+ }
694
+
695
+ template <typename elemType, threadgroup_t SCOPE, typename tuple_t, int major_dim, int minor_dim>
696
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_tile_allgather_mcast_threadgroup_v1(
697
+ uint32_t *dest, const uint32_t *source, const int nelem_major_dim, const int nelem_minor_dim,
698
+ const int src_stride_minor_dim, const int dst_stride_minor_dim, const int src_stride_major_dim,
699
+ const int dst_stride_major_dim, tuple_t start_coord, tuple_t boundary) {
700
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
701
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
702
+ int nelems = nelem_major_dim * nelem_minor_dim; /* # vec elems*/
703
+ using vtype = uint32_t;
704
+ using cxx_type = uint32_t;
705
+ if constexpr (std::is_empty<tuple_t>::value) {
706
+ cxx_type val;
707
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
708
+ asm("ld.global.b32 %0, [%1];"
709
+ : "=r"(val)
710
+ : "l"(source + ((j % nelem_major_dim) * src_stride_major_dim) +
711
+ ((j / nelem_major_dim) * src_stride_minor_dim)));
712
+
713
+ asm("multimem.st.global.u32 [%0], %1;" ::"l"(
714
+ dest + ((j % nelem_major_dim) * dst_stride_major_dim) +
715
+ ((j / nelem_major_dim) * dst_stride_minor_dim)),
716
+ "r"(val)
717
+ : "memory");
718
+ }
719
+ } else {
720
+ for (size_t j = myIdx; j < nelems; j += groupSize) {
721
+ /* nelem_major_dim is in vector units*/
722
+ /* compute elem_coord_major in elemType units*/
723
+ uint32_t elem_coord_major = (j % nelem_major_dim) * (sizeof(vtype) / sizeof(elemType));
724
+ uint32_t elem_coord_minor = (j / nelem_major_dim);
725
+ cxx_type val;
726
+
727
+ /* convert elem_coord_major from elemType to cxx_type units */
728
+ /* no change to elem_coord_minor */
729
+ elem_coord_major = (elem_coord_major * sizeof(elemType)) / sizeof(cxx_type);
730
+
731
+ for (int u = 0; u < sizeof(vtype) / sizeof(cxx_type); ++u) {
732
+ /* check if elem is within boundary, use u and elem_coord_major in elemType units */
733
+ if (is_less_than<tuple_t, major_dim>(
734
+ start_coord,
735
+ create_coord_tuple<major_dim>(
736
+ ((elem_coord_major + u) * sizeof(cxx_type) / sizeof(elemType)),
737
+ elem_coord_minor),
738
+ boundary)) {
739
+ /* convert strides from vector to cxx_type units */
740
+ asm("ld.global.b32 %0, [%1];"
741
+ : "=r"(val)
742
+ : "l"(reinterpret_cast<const cxx_type *>(source) + (elem_coord_major + u) +
743
+ (elem_coord_minor * src_stride_minor_dim *
744
+ (sizeof(vtype) / sizeof(cxx_type)))));
745
+
746
+ asm("multimem.st.global.u32 [%0], %1;" ::"l"(
747
+ reinterpret_cast<cxx_type *>(dest) + (elem_coord_major + u) +
748
+ (elem_coord_minor * dst_stride_minor_dim *
749
+ (sizeof(vtype) / sizeof(cxx_type)))),
750
+ "r"(val)
751
+ : "memory");
752
+ }
753
+ }
754
+ }
755
+ } /*end of if else*/
756
+ }
757
+
758
+ // Select implementation based on the operation, datatype
759
+ template <typename vtype, typename T, threadgroup_t scope, typename tuple_t, int major_dim,
760
+ int minor_dim>
761
+ __device__ inline void nvshmemi_tile_allgather_nvls_threadgroup_vec(
762
+ nvshmem_team_t team, T *src, T *dst,
763
+ const int size_major_dim, // size along the major dimension in elements
764
+ const int size_minor_dim, // size along the minor dimension in elements
765
+ const int src_stride_minor_dim, // src stride along minor dimension in elements
766
+ const int dst_stride_minor_dim, // dst stride along minor dimension in elements
767
+ const int src_stride_major_dim, // src stride along major dimension in elements
768
+ const int dst_stride_major_dim, // dst stride along major dimension in elements
769
+ tuple_t start_coord, tuple_t boundary) {
770
+ // src is local, dst is multicast address
771
+ vtype *src_v = reinterpret_cast<vtype *>(src);
772
+ vtype *dst_v = reinterpret_cast<vtype *>(nvshmemx_mc_ptr(team, dst));
773
+ assert((dst_v != nullptr) && "Failed to get multicast ptr for destination");
774
+
775
+ int src_stride_minor_dim_v = src_stride_minor_dim;
776
+ if (src_stride_minor_dim > 1) {
777
+ src_stride_minor_dim_v = (src_stride_minor_dim * sizeof(T)) / sizeof(vtype);
778
+ }
779
+ int dst_stride_minor_dim_v = dst_stride_minor_dim;
780
+ if (dst_stride_minor_dim > 1) {
781
+ dst_stride_minor_dim_v = (dst_stride_minor_dim * sizeof(T)) / sizeof(vtype);
782
+ }
783
+ int src_stride_major_dim_v = src_stride_major_dim; // keep stride as is if ==1
784
+ if (src_stride_major_dim > 1) {
785
+ src_stride_major_dim_v = (src_stride_major_dim * sizeof(T)) / sizeof(vtype);
786
+ }
787
+ int dst_stride_major_dim_v = dst_stride_major_dim;
788
+ if (dst_stride_major_dim > 1) {
789
+ dst_stride_major_dim_v = (dst_stride_major_dim * sizeof(T)) / sizeof(vtype);
790
+ }
791
+
792
+ int nelem_major_dim = (size_major_dim * sizeof(T)) / sizeof(vtype);
793
+ int nelem_minor_dim = size_minor_dim;
794
+
795
+ if constexpr (std::is_same<vtype, int4>::value) {
796
+ nvshmemi_tile_allgather_mcast_threadgroup_v4<T, scope, tuple_t, major_dim, minor_dim>(
797
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
798
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
799
+ boundary);
800
+
801
+ } else if constexpr (std::is_same<vtype, uint64_t>::value) {
802
+ nvshmemi_tile_allgather_mcast_threadgroup_v2<T, scope, tuple_t, major_dim, minor_dim>(
803
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
804
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
805
+ boundary);
806
+
807
+ } else if constexpr (std::is_same<vtype, uint32_t>::value) {
808
+ nvshmemi_tile_allgather_mcast_threadgroup_v1<T, scope, tuple_t, major_dim, minor_dim>(
809
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
810
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
811
+ boundary);
812
+
813
+ } else {
814
+ if (std::is_same<vtype, int4>::value) {
815
+ nvshmemi_tile_allgather_mcast_threadgroup_v4<T, scope, tuple_t, major_dim, minor_dim>(
816
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
817
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
818
+ boundary);
819
+
820
+ } else if (std::is_same<vtype, uint64_t>::value) {
821
+ nvshmemi_tile_allgather_mcast_threadgroup_v2<T, scope, tuple_t, major_dim, minor_dim>(
822
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
823
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
824
+ boundary);
825
+
826
+ } else if (std::is_same<vtype, uint32_t>::value) {
827
+ nvshmemi_tile_allgather_mcast_threadgroup_v1<T, scope, tuple_t, major_dim, minor_dim>(
828
+ dst_v, src_v, nelem_major_dim, nelem_minor_dim, src_stride_minor_dim_v,
829
+ dst_stride_minor_dim_v, src_stride_major_dim_v, dst_stride_major_dim_v, start_coord,
830
+ boundary);
831
+ } else {
832
+ assert(0 && "unsupported vector type");
833
+ }
834
+ }
835
+ }
836
+
837
+ template <typename src_tensor_t, typename dst_tensor_t, typename tuple_t, threadgroup_t scope,
838
+ int major_dim, int minor_dim>
839
+ __device__ inline void nvshmemi_tile_allgather_nvls_dim(nvshmem_team_t team,
840
+ src_tensor_t src_tensor,
841
+ dst_tensor_t dst_tensor,
842
+ tuple_t start_coord, tuple_t boundary) {
843
+ using T = typename src_tensor_t::value_type;
844
+ int mype = nvshmem_team_my_pe(team);
845
+
846
+ /* The destination tensor is npes * src_tensor size
847
+ * Assume 4 PEs, with src_tensor as shown below
848
+ * __ __ __ __
849
+ * |__| |__| |__| |__| // src_tensor of 4 PEs
850
+ *
851
+ * dest_tensor is 4 x src_tensor
852
+ * __ __
853
+ * |__|__| // dest_tensor of a PE (4xsrc_tensor)
854
+ * |__|__|
855
+ *
856
+ * Other shapes are possible for dst_tensor
857
+ * __ __ __ __ __
858
+ * |__|__|__|__| |__|
859
+ * |__|
860
+ * |__|
861
+ * |__|
862
+ *
863
+ * For every src_tensor from a given PE, we need to find the starting offset within
864
+ * dest_tensor.
865
+ */
866
+
867
+ // Compute the offset within dst tile specific for the PE
868
+ T *dst =
869
+ (dst_tensor.data() +
870
+ (((mype * get_shape_element<major_dim>(src_tensor)) %
871
+ get_shape_element<major_dim>(dst_tensor)) *
872
+ get_stride_element<major_dim>(dst_tensor)) +
873
+ (((mype * get_shape_element<major_dim>(src_tensor)) /
874
+ get_shape_element<major_dim>(dst_tensor)) *
875
+ (get_shape_element<minor_dim>(src_tensor) * get_stride_element<minor_dim>(dst_tensor))));
876
+
877
+ // Since it is PUSH based implementation, number of elements being copied is same as
878
+ // src_tensor so, elements in each dimension is based on src_tensor but stride is based on
879
+ // dst_tensor
880
+
881
+ // check for vector len == 4
882
+ // Conditions: ptr must be aligned to int4, shape must be a multiple of 16, stride must be a
883
+ // multiple of 16
884
+ if (((size_t)src_tensor.data() % sizeof(int4) == 0) &&
885
+ ((size_t)dst_tensor.data() % sizeof(int4) == 0) &&
886
+ (((get_tuple_val<major_dim>(src_tensor.shape()) * sizeof(T)) % sizeof(int4)) == 0) &&
887
+ (((get_stride_element<minor_dim>(src_tensor) * sizeof(T)) % sizeof(int4)) == 0) &&
888
+ (((get_stride_element<minor_dim>(dst_tensor) * sizeof(T)) % sizeof(int4)) == 0)) {
889
+ nvshmemi_tile_allgather_nvls_threadgroup_vec<int4, T, scope, tuple_t, major_dim, minor_dim>(
890
+ team, src_tensor.data(), dst,
891
+ get_shape_element<major_dim>(src_tensor), // contiguous size
892
+ get_shape_element<minor_dim>(src_tensor), // strided size
893
+ get_stride_element<minor_dim>(src_tensor), // src stride minor_dim
894
+ get_stride_element<minor_dim>(dst_tensor), // dst stride minor_dim
895
+ get_stride_element<major_dim>(src_tensor), // src stride major_dim; equal to 1
896
+ get_stride_element<major_dim>(dst_tensor), // dst stride major_dim; equal to 1
897
+ start_coord, boundary);
898
+
899
+ } else if (((size_t)src_tensor.data() % sizeof(uint64_t) == 0) &&
900
+ ((size_t)dst_tensor.data() % sizeof(uint64_t) == 0) &&
901
+ (((get_tuple_val<major_dim>(src_tensor.shape()) * sizeof(T)) % sizeof(uint64_t)) ==
902
+ 0) &&
903
+ (((get_stride_element<minor_dim>(src_tensor) * sizeof(T)) % sizeof(uint64_t)) ==
904
+ 0) &&
905
+ (((get_stride_element<minor_dim>(dst_tensor) * sizeof(T)) % sizeof(uint64_t)) ==
906
+ 0)) {
907
+ nvshmemi_tile_allgather_nvls_threadgroup_vec<uint64_t, T, scope, tuple_t, major_dim,
908
+ minor_dim>(
909
+ team, src_tensor.data(), dst,
910
+ get_shape_element<major_dim>(src_tensor), // contiguous size
911
+ get_shape_element<minor_dim>(src_tensor), // strided size
912
+ get_stride_element<minor_dim>(src_tensor), // src stride minor_dim
913
+ get_stride_element<minor_dim>(dst_tensor), // dst stride minor_dim
914
+ get_stride_element<major_dim>(src_tensor), // src stride major_dim; equal to 1
915
+ get_stride_element<major_dim>(dst_tensor), // dst stride major_dim; equal to 1
916
+ start_coord, boundary);
917
+
918
+ } else { // vector len 1
919
+ nvshmemi_tile_allgather_nvls_threadgroup_vec<uint32_t, T, scope, tuple_t, major_dim,
920
+ minor_dim>(
921
+ team, src_tensor.data(), dst,
922
+ get_shape_element<major_dim>(src_tensor), // contiguous size
923
+ get_shape_element<minor_dim>(src_tensor), // strided size
924
+ get_stride_element<minor_dim>(src_tensor), // src stride minor_dim
925
+ get_stride_element<minor_dim>(dst_tensor), // dst stride minor_dim
926
+ get_stride_element<major_dim>(src_tensor), // src stride major_dim; equal to 1
927
+ get_stride_element<major_dim>(dst_tensor), // dst stride major_dim; equal to 1
928
+ start_coord, boundary);
929
+ }
930
+ }
931
+ // specialize for the vectorization
932
+ template <typename src_tensor_t, typename dst_tensor_t, typename tuple_t, threadgroup_t scope>
933
+ __device__ inline void nvshmemi_tile_allgather_nvls_threadgroup(nvshmem_team_t team,
934
+ src_tensor_t src_tensor,
935
+ dst_tensor_t dst_tensor,
936
+ tuple_t start_coord,
937
+ tuple_t boundary) {
938
+ using T = typename src_tensor_t::value_type;
939
+ if constexpr ((get_constant(safe_get<0>(decltype(src_tensor.stride()){})) == 1) &&
940
+ (get_constant(safe_get<0>(decltype(dst_tensor.stride()){})) == 1)) {
941
+ // dim 0 major
942
+ constexpr int major_dim = 0;
943
+ constexpr int minor_dim = 1;
944
+
945
+ if constexpr (sizeof(T) < 4) {
946
+ // Shape along major dimension should be divisible by 2, because we operate at fp16x2
947
+ assert(((get_shape_element<major_dim>(src_tensor) % 2) == 0) &&
948
+ ((get_shape_element<major_dim>(dst_tensor) % 2) == 0) &&
949
+ "Currently for 16B datatypes, we only support tensors which are 32b aligned "
950
+ "along their continuous dimension");
951
+ }
952
+
953
+ nvshmemi_tile_allgather_nvls_dim<src_tensor_t, dst_tensor_t, tuple_t, scope, major_dim,
954
+ minor_dim>(team, src_tensor, dst_tensor, start_coord,
955
+ boundary);
956
+ } else if constexpr ((get_constant(safe_get<1>(decltype(src_tensor.stride()){})) == 1) &&
957
+ (get_constant(safe_get<1>(decltype(dst_tensor.stride()){})) == 1)) {
958
+ // dim 1 major
959
+ constexpr int major_dim = 1;
960
+ constexpr int minor_dim = 0;
961
+
962
+ if constexpr (sizeof(T) < 4) {
963
+ // Shape along major dimension should be divisible by 2, because we operate at fp16x2
964
+ assert(((get_shape_element<major_dim>(src_tensor) % 2) == 0) &&
965
+ ((get_shape_element<major_dim>(dst_tensor) % 2) == 0) &&
966
+ "Currently for 16B datatypes, we only support tensors which are 32b aligned "
967
+ "along their continuous dimension");
968
+ }
969
+
970
+ nvshmemi_tile_allgather_nvls_dim<src_tensor_t, dst_tensor_t, tuple_t, scope, major_dim,
971
+ minor_dim>(team, src_tensor, dst_tensor, start_coord,
972
+ boundary);
973
+ } else {
974
+ // No contiguous dimension found at compile time
975
+ // TODO support when major dimension for src and tensor are different
976
+ if ((get_stride_element<1>(src_tensor) == 1) && (get_stride_element<1>(dst_tensor) == 1)) {
977
+ constexpr int major_dim = 1;
978
+ constexpr int minor_dim = 0;
979
+
980
+ if constexpr (sizeof(T) < 4) {
981
+ // Shape along major dimension should be divisible by 2, because we operate at
982
+ // fp16x2
983
+ assert(((get_shape_element<major_dim>(src_tensor) % 2) == 0) &&
984
+ ((get_shape_element<major_dim>(dst_tensor) % 2) == 0) &&
985
+ "Currently for 16B datatypes, we only support tensors which are 32b aligned "
986
+ "along their continuous dimension");
987
+ }
988
+
989
+ nvshmemi_tile_allgather_nvls_dim<src_tensor_t, dst_tensor_t, tuple_t, scope, major_dim,
990
+ minor_dim>(team, src_tensor, dst_tensor, start_coord,
991
+ boundary);
992
+ } else {
993
+ // setting major_dim to 0, minor_dim to 1
994
+ constexpr int major_dim = 0;
995
+ constexpr int minor_dim = 1;
996
+
997
+ if constexpr (sizeof(T) < 4) {
998
+ // Shape along major dimension should be divisible by 2, because we operate at
999
+ // fp16x2
1000
+ assert(((get_shape_element<major_dim>(src_tensor) % 2) == 0) &&
1001
+ ((get_shape_element<major_dim>(dst_tensor) % 2) == 0) &&
1002
+ "Currently for 16B datatypes, we only support tensors which are 32b aligned "
1003
+ "along their continuous dimension");
1004
+ }
1005
+ nvshmemi_tile_allgather_nvls_dim<src_tensor_t, dst_tensor_t, tuple_t, scope, major_dim,
1006
+ minor_dim>(team, src_tensor, dst_tensor, start_coord,
1007
+ boundary);
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ // Tile allgather entrypoint
1013
+ // Call underlying function based on scope and algo
1014
+ template <nvshmemx::tile_coll_algo_t algo, typename src_tensor_t, typename dst_tensor_t,
1015
+ typename tuple_t, threadgroup_t scope>
1016
+ __device__ inline int nvshmemi_tile_allgather(nvshmem_team_t team, src_tensor_t src_tensor,
1017
+ dst_tensor_t dst_tensor, tuple_t start_coord,
1018
+ tuple_t boundary, uint64_t flag) {
1019
+ #if defined(__cplusplus) && __cplusplus < 201703L
1020
+ assert(0 && "Tile-granular APIs need C++ 17");
1021
+ #endif
1022
+ using T = typename src_tensor_t::value_type;
1023
+
1024
+ static_assert(
1025
+ std::is_same<typename src_tensor_t::value_type, typename dst_tensor_t::value_type>::value,
1026
+ "Source and destination tensors must have the same type");
1027
+
1028
+ static_assert((algo == nvshmemx::tile_coll_algo_t::NVLS_ONE_SHOT_PUSH_NBI),
1029
+ "Unsupported tile AllGather algorithm. "
1030
+ "Currently NVLS_ONE_SHOT_PUSH_NBI is supported for tile allgather");
1031
+
1032
+ static_assert((scope == NVSHMEMI_THREADGROUP_THREAD) || (scope == NVSHMEMI_THREADGROUP_WARP) ||
1033
+ (scope == NVSHMEMI_THREADGROUP_WARPGROUP) ||
1034
+ (scope == NVSHMEMI_THREADGROUP_BLOCK),
1035
+ "Unsupported scope");
1036
+
1037
+ assert((src_tensor.data() != nullptr) && (dst_tensor.data() != nullptr) &&
1038
+ "Null pointers passed");
1039
+
1040
+ // check shape
1041
+ assert((get_shape_element<0>(src_tensor) * get_shape_element<1>(src_tensor) *
1042
+ nvshmem_team_n_pes(team)) &&
1043
+ (get_shape_element<0>(dst_tensor) * get_shape_element<1>(dst_tensor)));
1044
+
1045
+ // TODO add other data types
1046
+ static_assert(((is_half<T>::value) || (is_bfloat<T>::value) || (is_float<T>::value)),
1047
+ "Unsupported datatype");
1048
+
1049
+ // check if both src and dst have same continuous dimension
1050
+ // TODO relax this constraint
1051
+ assert(
1052
+ (((get_stride_element<0>(src_tensor) == 1) && (get_stride_element<0>(dst_tensor) == 1)) ||
1053
+ ((get_stride_element<1>(src_tensor) == 1) && (get_stride_element<1>(dst_tensor) == 1))) &&
1054
+ "Currently we only support cases where source and destination tile are continuous "
1055
+ "along one dimension");
1056
+
1057
+ assert(!flag && "Currently non-zero flag value is unsupported");
1058
+
1059
+ // NVLS Gather only has one-shot push support currently
1060
+ if constexpr (algo == nvshmemx::tile_coll_algo_t::NVLS_ONE_SHOT_PUSH_NBI) {
1061
+ // check for NVLS support in hardware
1062
+ #if __CUDA_ARCH__ >= 900 && CUDART_VERSION >= 12010
1063
+
1064
+ // NVLS ONE_SHOT AllGather is PUSH based algo, so we can directly start communicating
1065
+ // User should ensure src data is ready
1066
+
1067
+ nvshmemi_tile_allgather_nvls_threadgroup<src_tensor_t, dst_tensor_t, tuple_t, scope>(
1068
+ team, src_tensor, dst_tensor, start_coord, boundary);
1069
+ #else
1070
+ assert(__CUDA_ARCH__ >= 900 && CUDART_VERSION >= 12010 &&
1071
+ "Unsupported NVLS on this platform");
1072
+ #endif
1073
+ return 0;
1074
+ } else {
1075
+ // Extend as other algorithms are added
1076
+ return 0;
1077
+ }
1078
+ }
1079
+ #endif /* __CUDA_ARCH__ */
1080
+ #endif /* FCOLLECT_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/reduce.cuh ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/reducescatter.cuh ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef REDUCESCATTER_DEVICE_CUH
8
+ #define REDUCESCATTER_DEVICE_CUH
9
+
10
+ #include <cuda_runtime.h>
11
+ #include "non_abi/device/pt-to-pt/proxy_device.cuh"
12
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
13
+ #include "non_abi/device/common/nvshmemi_common_device.cuh"
14
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
15
+ #include "non_abi/nvshmem_build_options.h"
16
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
17
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
18
+ #else
19
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
20
+ #endif
21
+ #include "non_abi/device/wait/nvshmemi_wait_until_apis.cuh"
22
+ #include "utils.cuh"
23
+ #include "fcollect.cuh"
24
+ #include "broadcast.cuh"
25
+ #include "reduce.cuh"
26
+
27
+ #ifdef __CUDACC__
28
+ #include <cooperative_groups.h>
29
+ #include <cooperative_groups/reduce.h>
30
+ namespace cg = cooperative_groups;
31
+ #endif
32
+
33
+ #ifdef __CUDA_ARCH__
34
+
35
+ template <typename TYPE, rdxn_ops_t OP, threadgroup_t SCOPE>
36
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_reducescatter_allpush_threadgroup(
37
+ nvshmem_team_t team, TYPE *dest, const TYPE *source, size_t nreduce) {
38
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
39
+ TYPE *pWrk = (TYPE *)nvshmemi_team_get_psync(teami, REDUCE);
40
+
41
+ if (teami->size == 1) {
42
+ nvshmemi_memcpy_threadgroup<SCOPE>((char *)dest, (char *)source, sizeof(TYPE) * nreduce);
43
+ nvshmemi_threadgroup_sync<SCOPE>();
44
+ return;
45
+ }
46
+
47
+ if (nreduce * sizeof(TYPE) * teami->size >
48
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size * 0.5) {
49
+ assert(0 &&
50
+ "Not enough space to perform reducescatter. Increase value of "
51
+ "NVSHMEM_REDUCE_SCRATCH_SIZE");
52
+ }
53
+
54
+ /* pWrk: pe0 data array, pe1 data array, pe2 data array, .... */
55
+ for (int i = 1; i < teami->size; i++) { // don't send to self
56
+ int peer_pe_idx = (teami->my_pe + i) % teami->size;
57
+ int peer_pe = nvshmemi_team_translate_pe(team, peer_pe_idx, NVSHMEM_TEAM_WORLD);
58
+ nvshmemii_put_nbi_threadgroup<TYPE, SCOPE>(
59
+ (TYPE *)((char *)pWrk + teami->my_pe * nreduce * sizeof(TYPE)),
60
+ source + peer_pe_idx * nreduce, nreduce, peer_pe);
61
+ }
62
+ nvshmemi_barrier_threadgroup<SCOPE>(team);
63
+
64
+ TYPE *op1, *op2;
65
+ TYPE *op3;
66
+ for (int pe = 1; pe < teami->size; pe++) { // Need to perform npes - 1 reductions
67
+ op3 = dest;
68
+ if (pe == 1) { // this is the first reduction
69
+ if (nvshmemi_team_my_pe(team) == 0) {
70
+ op1 = (TYPE *)source;
71
+ op2 = (TYPE *)((char *)pWrk + nreduce * sizeof(TYPE));
72
+ } else if (nvshmemi_team_my_pe(team) == 1) {
73
+ op1 = (TYPE *)(char *)pWrk;
74
+ op2 = (TYPE *)source + nreduce;
75
+ } else {
76
+ op1 = (TYPE *)(char *)pWrk;
77
+ op2 = (TYPE *)((char *)pWrk + nreduce * sizeof(TYPE));
78
+ }
79
+ } else {
80
+ op1 = dest;
81
+ if (pe == nvshmemi_team_my_pe(team))
82
+ op2 = (TYPE *)source + pe * nreduce;
83
+ else
84
+ op2 = (TYPE *)((char *)pWrk + pe * nreduce * sizeof(TYPE));
85
+ }
86
+ gpu_linear_reduce_threadgroup<TYPE, OP, SCOPE>(op1, op2, op3, nreduce);
87
+ }
88
+ nvshmemi_threadgroup_sync<SCOPE>();
89
+ }
90
+
91
+ template <typename TYPE, rdxn_ops_t OP, threadgroup_t SCOPE>
92
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_reducescatter_nvls_allpush_threadgroup(
93
+ nvshmem_team_t team, TYPE *dest, const TYPE *source, int source_offset, size_t nreduce) {
94
+ #if defined __clang_llvm_bitcode_lib__
95
+ if (__nvvm_reflect("__CUDA_ARCH") >= 900) {
96
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
97
+ TYPE *src_ptr = (TYPE *)nvshmemi_mc_ptr(teami, (void *)(source + source_offset));
98
+ nvshmemi_threadgroup_sync<SCOPE>();
99
+ nvshmemi_local_reduce_mcast_threadgroup<TYPE, OP, SCOPE>(dest, src_ptr, nreduce);
100
+ /* Since ld.red is done atomically on the NVSwitch, the value obtained into local dest
101
+ * ref for a given PE would be ready, right away. We can still have a case that after
102
+ * returning from this kernel, source buffer can be mutated on one PE, while another PE is
103
+ * still performing ld.red, causing data correctness issue. We don't however need to add
104
+ * threadfence_system for ordering since the subsequent load to source buffer will be
105
+ * ordered already to prior ld.reduce (RAR) by HW.
106
+ */
107
+ nvshmemi_sync_threadgroup<SCOPE>(team);
108
+ } else {
109
+ assert(0 && "Unsupported NVLS algo on this platform");
110
+ }
111
+ #else
112
+ #if __CUDA_ARCH__ >= 900 && CUDART_VERSION >= 12010
113
+ nvshmemi_team_t *teami = nvshmemi_device_state_d.team_pool[team];
114
+ TYPE *src_ptr = (TYPE *)nvshmemi_mc_ptr(teami, (void *)(source + source_offset));
115
+ nvshmemi_threadgroup_sync<SCOPE>();
116
+ nvshmemi_local_reduce_mcast_threadgroup<TYPE, OP, SCOPE>(dest, src_ptr, nreduce);
117
+ /* Since ld.red is done atomically on the NVSwitch, the value obtained into local dest
118
+ * ref for a given PE would be ready, right away. We can still have a case that after returning
119
+ * from this kernel, source buffer can be mutated on one PE, while another PE is still
120
+ * performing ld.red, causing data correctness issue. We don't however need to add
121
+ * threadfence_system for ordering since the subsequent load to source buffer will be ordered
122
+ * already to prior ld.reduce (RAR) by HW.
123
+ */
124
+ nvshmemi_sync_threadgroup<SCOPE>(team);
125
+ #else
126
+ assert(0 && "Unsupported NVLS algo on this platform");
127
+ #endif
128
+ #endif
129
+ }
130
+
131
+ template <typename TYPE, rdxn_ops_t OP, threadgroup_t SCOPE>
132
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_reducescatter_threadgroup(
133
+ nvshmem_team_t team, TYPE *dest, const TYPE *source, int source_offset, size_t nreduce) {
134
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
135
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
136
+
137
+ if (!myIdx) /* Only one thread should increment rdxn_count */
138
+ nvshmemi_device_state_d.team_pool[team]->rdxn_count += 1;
139
+ nvshmemi_threadgroup_sync<SCOPE>();
140
+
141
+ constexpr bool is_float_v = is_float<TYPE>::value;
142
+ constexpr bool is_double_v = is_double<TYPE>::value;
143
+ constexpr bool is_half_prec = is_half<TYPE>::value || is_bfloat<TYPE>::value;
144
+ /* For SUM/AND/XOR/OR, support is untyped */
145
+ /* For MIN/MAX, support is type specific */
146
+ constexpr bool is_mcast_red_op =
147
+ NVSHMEMI_MCAST_RDXN_OP_IS_CAP_UNTYPED(OP) ||
148
+ ((OP == RDXN_OPS_MIN || OP == RDXN_OPS_MAX) && (!is_float_v && !is_double_v));
149
+ constexpr bool is_mcast_canoncial_type = (sizeof(TYPE) >= sizeof(uint32_t));
150
+ bool is_half_precondition =
151
+ is_half_prec && nreduce >= 2 && (nvshmemi_device_state_d.team_pool[team]->size % 2 == 0);
152
+ bool is_nvls_algo_supported =
153
+ ((is_mcast_red_op && is_mcast_canoncial_type) ||
154
+ (OP == RDXN_OPS_SUM && is_half_precondition)) &&
155
+ (nvshmemi_device_state_d.team_pool[team]->nvls_rsc_base_ptr != NULL) &&
156
+ ((nreduce * sizeof(TYPE)) % 4 == 0);
157
+
158
+ int reducescatter_algo = nvshmemi_device_state_d.gpu_coll_env_params_var.reducescatter_algo;
159
+ /* This 2-level selection logic is implemented to reduce code duplication of calling leaf
160
+ * functions on the device code */
161
+ switch (reducescatter_algo) {
162
+ case 0: /* default selection */
163
+ if (is_nvls_algo_supported) {
164
+ reducescatter_algo = 3; /* NVLS One Shot */
165
+ } else {
166
+ reducescatter_algo = 2; /* P2P One Shot */
167
+ }
168
+ break;
169
+ case 2: /* One Shot */
170
+ break;
171
+ case 3:
172
+ if (is_nvls_algo_supported) {
173
+ /* NVLS one shot */
174
+ break;
175
+ } else {
176
+ reducescatter_algo = 2; /* One shot */
177
+ break;
178
+ }
179
+ default:
180
+ assert(0 && "Specified reducescatter algo not supported, aborting...\n");
181
+ break;
182
+ }
183
+
184
+ switch (reducescatter_algo) {
185
+ case 2:
186
+ nvshmemi_reducescatter_allpush_threadgroup<TYPE, OP, SCOPE>(team, dest, source,
187
+ nreduce);
188
+ break;
189
+ case 3:
190
+ nvshmemi_reducescatter_nvls_allpush_threadgroup<TYPE, OP, SCOPE>(
191
+ team, dest, source, source_offset, nreduce);
192
+ break;
193
+ default:
194
+ assert(0);
195
+ break;
196
+ }
197
+
198
+ /* since both allpush and nvls one-shot algos don't store data remotely at the end of the
199
+ * collective, threadfence_system when cuda_graph is enabled is not required */
200
+ }
201
+
202
+ #endif /* __CUDA_ARCH__ */
203
+ #endif /* REDUCESCATTER_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/coll/utils.cuh ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2017-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef _NVSHMEMI_DEVICE_COLL_UTILS_H_
8
+ #define _NVSHMEMI_DEVICE_COLL_UTILS_H_
9
+
10
+ #include <cuda_runtime.h>
11
+ #if !defined __CUDACC_RTC__
12
+ #include <type_traits>
13
+ #else
14
+ #include <cuda/std/type_traits>
15
+ #endif
16
+ #include "non_abi/nvshmem_build_options.h"
17
+ #include "device/nvshmem_device_macros.h"
18
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
19
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
20
+ #else
21
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
22
+ #endif
23
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
24
+
25
+ /* This is signaling function used in barrier algorithm.
26
+ nvshmem_<type>_signal function cannot be used in barrier because it uses a
27
+ combination of P2P path and IB path depending on how the peer GPU is
28
+ connected. In contrast to that, this fuction uses either P2P path (when all GPUs
29
+ are NVLink connected) or IB path (when any of the GPU is not NVLink connected).
30
+
31
+ Using this function in barrier is necessary to ensure any previous RMA
32
+ operations are visible. When combination of P2P and IB path are used
33
+ as in nvshmem_<type>_signal function, it can lead to race conditions.
34
+ For example NVLink writes (of data and signal) can overtake IB writes.
35
+ And hence the data may not be visible after the barrier operation.
36
+ */
37
+ #ifdef __CUDA_ARCH__
38
+ template <typename T>
39
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_signal_for_barrier(T *dest, const T value,
40
+ int pe) {
41
+ const void *peer_base_addr =
42
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
43
+ if (nvshmemi_device_state_d.job_connectivity <= NVSHMEMI_JOB_GPU_LDST) {
44
+ volatile T *dest_actual =
45
+ (volatile T *)((char *)(peer_base_addr) +
46
+ ((char *)dest - (char *)(nvshmemi_device_state_d.heap_base)));
47
+ *dest_actual = value;
48
+ } else {
49
+ nvshmemi_transfer_amo_nonfetch<T>((void *)dest, value, pe, NVSHMEMI_AMO_SIGNAL);
50
+ }
51
+ }
52
+ #endif /* __CUDA_ARCH__ */
53
+
54
+ #endif /* NVSHMEMI_DEVICE_COLL_UTILS_H */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/common/nvshmemi_common_device.cuh ADDED
@@ -0,0 +1,1037 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+ #ifndef _NVSHMEM_COMMON_DEVICE_CUH_
7
+ #define _NVSHMEM_COMMON_DEVICE_CUH_
8
+
9
+ #include <cuda_runtime.h>
10
+ #if !defined __CUDACC_RTC__
11
+ #include <stdint.h>
12
+ #include <stddef.h>
13
+ #include <type_traits>
14
+ #else
15
+ #include <cuda/std/cstdint>
16
+ #include <cuda/std/cstddef>
17
+ #include <cuda/std/type_traits>
18
+ #endif
19
+ #include "non_abi/nvshmem_build_options.h"
20
+ #include "device_host/nvshmem_common.cuh"
21
+ #include "device_host_transport/nvshmem_common_transport.h"
22
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
23
+ #if defined(NVSHMEM_ENABLE_ALL_DEVICE_INLINING) || defined(__NVSHMEM_NUMBA_SUPPORT__)
24
+ #include "non_abi/device/pt-to-pt/transfer_device.cuh"
25
+ #else
26
+ #include "non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh"
27
+ #endif
28
+ #include "non_abi/device/pt-to-pt/proxy_device.cuh"
29
+ #include "non_abi/device/team/nvshmemi_team_defines.cuh"
30
+
31
+ #define _LL_MAX_UNROLL 4
32
+
33
+ #define _LL_128_FLAG_THREAD 8
34
+ #define _LL_128_FLAG_SIZE 8
35
+ #define _LL_128_STORE_SIZE 16
36
+ #define _LL_128_PACKETS_PER_WARP 4
37
+ #define _LL_128_PACKET_DATA_SIZE 120
38
+ #define _LL_128_PACKET_PSYNC_SIZE 128
39
+ #define _LL_128_NUM_DATA_ELEMS_PER_PACKET(T) (_LL_128_PACKET_DATA_SIZE / sizeof(T))
40
+ #define _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(T) (_LL_128_PACKET_PSYNC_SIZE / sizeof(T))
41
+ #define _LL_128_NUM_ELEMS_PER_STORE(T) (_LL_128_STORE_SIZE / sizeof(T))
42
+ #define _LL_128_NUM_ELEMS_PER_FLAG(T) (_LL_128_FLAG_SIZE / sizeof(T))
43
+ #define _LL_128_NUM_DATA_ELEMS_PER_WARP(UNROLL, T) \
44
+ (UNROLL * _LL_128_PACKETS_PER_WARP * _LL_128_NUM_DATA_ELEMS_PER_PACKET(T))
45
+ #define _LL_128_NUM_PSYNC_ELEMS_PER_WARP(UNROLL, T) \
46
+ (UNROLL * _LL_128_PACKETS_PER_WARP * _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(T))
47
+
48
+ #define _LL_8_DATA_BYTES_PER_WARP 256
49
+ #define _LL_8_PSYNC_BYTES_PER_WARP 512
50
+ #define _LL_128_DATA_BYTES_PER_WARP 480
51
+ #define _LL_128_PSYNC_BYTES_PER_WARP 512
52
+
53
+ typedef enum { _LL_PSYNC_NON_VOLATILE = 0, _LL_PSYNC_VOLATILE } nvshmemi_psync_volatile_t;
54
+
55
+ #ifdef __CUDA_ARCH__
56
+
57
+ /* This is used to create custom floating type traits such fp16, fp8, and native float types etc
58
+ */
59
+ #if !defined __CUDACC_RTC__
60
+ template <typename T>
61
+ struct is_float : std::false_type {};
62
+ template <>
63
+ struct is_float<float> : std::true_type {};
64
+
65
+ template <typename T>
66
+ struct is_half : std::false_type {};
67
+ template <>
68
+ struct is_half<half> : std::true_type {};
69
+
70
+ template <typename T>
71
+ struct is_bfloat : std::false_type {};
72
+ template <>
73
+ struct is_bfloat<__nv_bfloat16> : std::true_type {};
74
+
75
+ template <typename T>
76
+ struct is_double : std::false_type {};
77
+ template <>
78
+ struct is_double<double> : std::true_type {};
79
+
80
+ template <typename T>
81
+ struct is_uint16 : std::false_type {};
82
+ template <>
83
+ struct is_uint16<uint16_t> : std::true_type {};
84
+
85
+ template <typename T>
86
+ struct is_int16 : std::false_type {};
87
+ template <>
88
+ struct is_int16<int16_t> : std::true_type {};
89
+
90
+ #else
91
+
92
+ template <typename T>
93
+ struct is_float : cuda::std::false_type {};
94
+ template <>
95
+ struct is_float<float> : cuda::std::true_type {};
96
+
97
+ template <typename T>
98
+ struct is_double : cuda::std::false_type {};
99
+ template <>
100
+ struct is_double<double> : cuda::std::true_type {};
101
+
102
+ template <typename T>
103
+ struct is_half : cuda::std::false_type {};
104
+ template <>
105
+ struct is_half<half> : cuda::std::true_type {};
106
+
107
+ template <typename T>
108
+ struct is_bfloat : cuda::std::false_type {};
109
+ template <>
110
+ struct is_bfloat<__nv_bfloat16> : cuda::std::true_type {};
111
+
112
+ template <typename T>
113
+ struct is_uint16 : cuda::std::false_type {};
114
+ template <>
115
+ struct is_uint16<uint16_t> : cuda::std::true_type {};
116
+
117
+ template <typename T>
118
+ struct is_int16 : cuda::std::false_type {};
119
+ template <>
120
+ struct is_int16<int16_t> : cuda::std::true_type {};
121
+
122
+ #endif
123
+
124
+ __device__ int nvshmemi_team_translate_pe(nvshmemi_team_t *src_team, int src_pe,
125
+ nvshmemi_team_t *dest_team);
126
+ __device__ long *nvshmemi_team_get_psync(nvshmemi_team_t *team, nvshmemi_team_op_t op);
127
+ __device__ long *nvshmemi_team_get_sync_counter(nvshmemi_team_t *team);
128
+
129
+ template <threadgroup_t SCOPE>
130
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_quiet() {
131
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
132
+ if ((nvshmemi_device_state_d.job_connectivity > NVSHMEMI_JOB_GPU_LDST)) {
133
+ nvshmemi_transfer_quiet<SCOPE>(true);
134
+ } else {
135
+ if (!myIdx)
136
+ __threadfence_system(); /* Use __threadfence_system instead of __threadfence
137
+ for data visibility in case of intra-node GPU transfers */
138
+ nvshmemi_threadgroup_sync<SCOPE>();
139
+ }
140
+ }
141
+
142
+ template __device__ void nvshmemi_quiet<NVSHMEMI_THREADGROUP_THREAD>();
143
+ template __device__ void nvshmemi_quiet<NVSHMEMI_THREADGROUP_WARP>();
144
+ template __device__ void nvshmemi_quiet<NVSHMEMI_THREADGROUP_BLOCK>();
145
+
146
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_fence() {
147
+ if (nvshmemi_device_state_d.job_connectivity > NVSHMEMI_JOB_GPU_LDST) {
148
+ nvshmemi_transfer_fence<NVSHMEMI_THREADGROUP_THREAD>();
149
+ }
150
+ __threadfence_system(); /* Use __threadfence_system instead of __threadfence
151
+ for data visibility in case of intra-node GPU transfers */
152
+ }
153
+
154
+ template <typename T>
155
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE int nvshmemi_test(volatile T *ivar, int cmp, T cmp_value) {
156
+ int return_value = 0;
157
+ if (NVSHMEM_CMP_GE == cmp) {
158
+ if (*ivar >= cmp_value) return_value = 1;
159
+ } else if (NVSHMEM_CMP_EQ == cmp) {
160
+ if (*ivar == cmp_value) return_value = 1;
161
+ } else if (NVSHMEM_CMP_NE == cmp) {
162
+ if (*ivar != cmp_value) return_value = 1;
163
+ } else if (NVSHMEM_CMP_GT == cmp) {
164
+ if (*ivar > cmp_value) return_value = 1;
165
+ } else if (NVSHMEM_CMP_LT == cmp) {
166
+ if (*ivar < cmp_value) return_value = 1;
167
+ } else if (NVSHMEM_CMP_LE == cmp) {
168
+ if (*ivar <= cmp_value) return_value = 1;
169
+ }
170
+ return return_value;
171
+ }
172
+
173
+ #if !defined __CUDACC_RTC__
174
+ #define TYPE_IS_FLOAT(T) std::is_floating_point<T>::value
175
+ #else
176
+ #define TYPE_IS_FLOAT(T) cuda::std::is_floating_point<T>::value
177
+ #endif
178
+
179
+ // mcast store of 16B
180
+ template <typename T, threadgroup_t SCOPE>
181
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_mcast16_store_threadgroup(int4 *dest,
182
+ const int4 *source,
183
+ size_t len) {
184
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
185
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
186
+ for (size_t j = myIdx * 4; j < (len / sizeof(uint32_t)); j += groupSize * 4) {
187
+ uint32_t u4[4];
188
+ asm("ld.global.v4.b32 {%0, %1, %2, %3}, [%4]; "
189
+ : "=r"(u4[0]), "=r"(u4[1]), "=r"(u4[2]), "=r"(u4[3])
190
+ : "l"(source + j / 4));
191
+ asm("multimem.st.global.v4.f32 [%0], {%1, %2, %3, %4};" ::"l"(dest + j / 4), "r"(u4[0]),
192
+ "r"(u4[1]), "r"(u4[2]), "r"(u4[3])
193
+ : "memory");
194
+ }
195
+ }
196
+
197
+ // mcast store of 8B
198
+ template <typename T, threadgroup_t SCOPE>
199
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_mcast8_store_threadgroup(
200
+ uint64_t *dest, const uint64_t *source, size_t len) {
201
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
202
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
203
+ for (size_t j = myIdx; j < (len / sizeof(uint64_t)); j += groupSize) {
204
+ uint64_t val1;
205
+ asm("ld.global.b64 %0, [%1];" : "=l"(val1) : "l"(source + j));
206
+ asm("multimem.st.global.u64 [%0], %1;" ::"l"(dest + j), "l"(val1) : "memory");
207
+ }
208
+ }
209
+
210
+ // mcast store of 4B
211
+ template <typename T, threadgroup_t SCOPE>
212
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_mcast4_store_threadgroup(
213
+ uint32_t *dest, const uint32_t *source, size_t len) {
214
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
215
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
216
+ for (size_t j = myIdx; j < (len / sizeof(uint32_t)); j += groupSize) {
217
+ uint32_t val1;
218
+ asm("ld.global.b32 %0, [%1];" : "=r"(val1) : "l"(source + j));
219
+ asm("multimem.st.global.u32 [%0], %1;" ::"l"(dest + j), "r"(val1) : "memory");
220
+ }
221
+ }
222
+
223
+ /**
224
+ * This function returns non-zero unaligned bytes that require a unicast store
225
+ */
226
+ template <typename T, threadgroup_t SCOPE>
227
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE size_t
228
+ nvshmemi_mcast_memcpy_threadgroup(T *__restrict__ dst, const T *__restrict__ src, size_t len) {
229
+ /*
230
+ * If src and dst are 16B aligned copy as much as possible using 16B chunks
231
+ */
232
+ if ((uintptr_t)dst % 16 == 0 && (uintptr_t)src % 16 == 0 && len >= 16) {
233
+ int4 *__restrict__ dst_p = (int4 *)dst;
234
+ const int4 *__restrict__ src_p = (const int4 *)src;
235
+ const size_t nelems = len / 16;
236
+ nvshmemi_mcast16_store_threadgroup<T, SCOPE>(dst_p, src_p, len);
237
+ len -= nelems * 16;
238
+
239
+ if (0 == len) return 0;
240
+ dst = (T *)(dst_p + nelems);
241
+ src = (T *)(src_p + nelems);
242
+ }
243
+
244
+ /*
245
+ * If src and dst are 8B aligned copy as much as possible using 8B chunks
246
+ */
247
+ if ((uintptr_t)dst % 8 == 0 && (uintptr_t)src % 8 == 0 && len >= 8) {
248
+ const size_t nelems = len / 8;
249
+ uint64_t *__restrict__ dst_p = (uint64_t *)dst;
250
+ const uint64_t *__restrict__ src_p = (const uint64_t *)src;
251
+ nvshmemi_mcast8_store_threadgroup<T, SCOPE>(dst_p, src_p, len);
252
+ len -= nelems * 8;
253
+
254
+ if (0 == len) return 0;
255
+ dst = (T *)(dst_p + nelems);
256
+ src = (T *)(src_p + nelems);
257
+ }
258
+
259
+ /*
260
+ * If src and dst are 4B aligned copy as much as possible using 4B chunks
261
+ */
262
+ if ((uintptr_t)dst % 4 == 0 && (uintptr_t)src % 4 == 0 && len >= 4) {
263
+ const size_t nelems = len / 4;
264
+ uint32_t *__restrict__ dst_p = (uint32_t *)dst;
265
+ const uint32_t *__restrict__ src_p = (const uint32_t *)src;
266
+ nvshmemi_mcast4_store_threadgroup<T, SCOPE>(dst_p, src_p, len);
267
+ len -= nelems * 4;
268
+
269
+ if (0 == len) return 0;
270
+ dst = (T *)(dst_p + nelems);
271
+ src = (T *)(src_p + nelems);
272
+ }
273
+
274
+ /* if len is non-zero, caller will retry with unicast stores */
275
+ return (len);
276
+ }
277
+
278
+ template <threadgroup_t SCOPE>
279
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_memcpy_threadgroup(
280
+ void *__restrict__ dst, const void *__restrict__ src, size_t len) {
281
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
282
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
283
+ /*
284
+ * If src and dst are 16B aligned copy as much as possible using 16B chunks
285
+ */
286
+ if ((uintptr_t)dst % 16 == 0 && (uintptr_t)src % 16 == 0) {
287
+ const size_t nelems = len / 16;
288
+
289
+ #ifdef __clang_llvm_bitcode_lib__
290
+ uint32_t *__restrict__ dst_p = (uint32_t *)dst;
291
+ const uint32_t *__restrict__ src_p = (const uint32_t *)src;
292
+ for (size_t i = myIdx * 4; i < nelems * 4; i += groupSize * 4) {
293
+ asm volatile("st.volatile.global.v4.u32 [%0], {%1,%2,%3,%4};" ::"l"((dst_p + i)),
294
+ "r"(*(src_p + i)), "r"(*(src_p + i + 1)), "r"(*(src_p + i + 2)),
295
+ "r"(*(src_p + i + 3)));
296
+ }
297
+ #else
298
+ int4 *__restrict__ dst_p = (int4 *)dst;
299
+ const int4 *__restrict__ src_p = (const int4 *)src;
300
+ for (size_t i = myIdx; i < nelems; i += groupSize) dst_p[i] = src_p[i];
301
+ #endif
302
+ len -= nelems * 16;
303
+
304
+ if (0 == len) return;
305
+
306
+ #ifdef __clang_llvm_bitcode_lib__
307
+ dst = (void *)(dst_p + nelems * 4);
308
+ src = (void *)(src_p + nelems * 4);
309
+ #else
310
+ dst = (void *)(dst_p + nelems);
311
+ src = (void *)(src_p + nelems);
312
+ #endif
313
+ }
314
+
315
+ /*
316
+ * If src and dst are 8B aligned copy as much as possible using 8B chunks
317
+ */
318
+ if ((uintptr_t)dst % 8 == 0 && (uintptr_t)src % 8 == 0) {
319
+ uint64_t *__restrict__ dst_p = (uint64_t *)dst;
320
+ const uint64_t *__restrict__ src_p = (const uint64_t *)src;
321
+ const size_t nelems = len / 8;
322
+
323
+ for (size_t i = myIdx; i < nelems; i += groupSize) dst_p[i] = src_p[i];
324
+
325
+ len -= nelems * 8;
326
+
327
+ if (0 == len) return;
328
+
329
+ dst = (void *)(dst_p + nelems);
330
+ src = (void *)(src_p + nelems);
331
+ }
332
+
333
+ /*
334
+ * If src and dst are 4B aligned copy as much as possible using 4B chunks
335
+ */
336
+ if ((uintptr_t)dst % 4 == 0 && (uintptr_t)src % 4 == 0) {
337
+ uint32_t *__restrict__ dst_p = (uint32_t *)dst;
338
+ const uint32_t *__restrict__ src_p = (const uint32_t *)src;
339
+ const size_t nelems = len / 4;
340
+
341
+ for (size_t i = myIdx; i < nelems; i += groupSize) dst_p[i] = src_p[i];
342
+
343
+ len -= nelems * 4;
344
+
345
+ if (0 == len) return;
346
+
347
+ dst = (void *)(dst_p + nelems);
348
+ src = (void *)(src_p + nelems);
349
+ }
350
+
351
+ /*
352
+ * If src and dst are 2B aligned copy as much as possible using 2B chunks
353
+ */
354
+ if ((uintptr_t)dst % 2 == 0 && (uintptr_t)src % 2 == 0) {
355
+ uint16_t *__restrict__ dst_p = (uint16_t *)dst;
356
+ const uint16_t *__restrict__ src_p = (const uint16_t *)src;
357
+ const size_t nelems = len / 2;
358
+
359
+ for (size_t i = myIdx; i < nelems; i += groupSize) dst_p[i] = src_p[i];
360
+
361
+ len -= nelems * 2;
362
+
363
+ if (0 == len) return;
364
+
365
+ dst = (void *)(dst_p + nelems);
366
+ src = (void *)(src_p + nelems);
367
+ }
368
+
369
+ unsigned char *__restrict__ dst_c = (unsigned char *)dst;
370
+ const unsigned char *__restrict__ src_c = (const unsigned char *)src;
371
+
372
+ for (size_t i = myIdx; i < len; i += groupSize) dst_c[i] = src_c[i];
373
+ }
374
+
375
+ template <typename T>
376
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_p(T *dest, const T value, int pe) {
377
+ const void *peer_base_addr =
378
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
379
+ if (peer_base_addr) {
380
+ T *dest_actual = (T *)((char *)(peer_base_addr) +
381
+ ((char *)dest - (char *)(nvshmemi_device_state_d.heap_base)));
382
+ *dest_actual = value;
383
+ } else {
384
+ nvshmemi_transfer_rma_p<T>((void *)dest, value, pe);
385
+ }
386
+ }
387
+
388
+ template <typename T>
389
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE T nvshmemi_g(const T *source, int pe) {
390
+ const void *peer_base_addr =
391
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
392
+ if (peer_base_addr) {
393
+ T *source_actual = (T *)((char *)(peer_base_addr) +
394
+ ((char *)source - (char *)(nvshmemi_device_state_d.heap_base)));
395
+ return *source_actual;
396
+ } else {
397
+ return nvshmemi_transfer_rma_g<T>((void *)source, pe);
398
+ }
399
+ }
400
+
401
+ template <typename T, threadgroup_t SCOPE>
402
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_put_threadgroup(T *dest, const T *source,
403
+ size_t nelems, int pe) {
404
+ nvshmemi_threadgroup_sync<SCOPE>();
405
+ void *peer_base_addr =
406
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
407
+ if (peer_base_addr) {
408
+ char *dest_actual =
409
+ (char *)(peer_base_addr) + ((char *)dest - (char *)(nvshmemi_device_state_d.heap_base));
410
+ nvshmemi_memcpy_threadgroup<SCOPE>((void *)dest_actual, (const void *)source,
411
+ nelems * sizeof(T));
412
+ } else {
413
+ nvshmemi_transfer_rma<SCOPE, NVSHMEMI_OP_PUT>((void *)dest, (void *)source,
414
+ nelems * sizeof(T), pe);
415
+ }
416
+ nvshmemi_threadgroup_sync<SCOPE>();
417
+ }
418
+
419
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_signal_op(uint64_t *sig_addr,
420
+ uint64_t signal, int sig_op,
421
+ int pe) {
422
+ const void *peer_base_addr =
423
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
424
+ if (sig_op == NVSHMEMI_AMO_SIGNAL_SET && peer_base_addr != NULL) {
425
+ volatile uint64_t *dest_actual =
426
+ (volatile uint64_t *)((char *)(peer_base_addr) +
427
+ ((char *)sig_addr - (char *)(nvshmemi_device_state_d.heap_base)));
428
+ *dest_actual = signal;
429
+ } else if (nvshmemi_device_state_d.job_connectivity <= NVSHMEMI_JOB_GPU_LDST) {
430
+ volatile uint64_t *dest_actual =
431
+ (volatile uint64_t *)((char *)(peer_base_addr) +
432
+ ((char *)sig_addr - (char *)(nvshmemi_device_state_d.heap_base)));
433
+ /* sig_op == NVSHMEM_SIGNAL_ADD */
434
+ atomicAdd_system((unsigned long long *)dest_actual, signal);
435
+ } else {
436
+ nvshmemi_transfer_amo_nonfetch<uint64_t>((void *)sig_addr, signal, pe,
437
+ (nvshmemi_amo_t)sig_op);
438
+ }
439
+ }
440
+
441
+ template <typename T, threadgroup_t SCOPE>
442
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemii_put_signal_threadgroup(
443
+ T *dest, const T *source, size_t nelems, uint64_t *sig_addr, uint64_t signal, int sig_op,
444
+ int pe, bool is_nbi) {
445
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
446
+ void *peer_base_addr =
447
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
448
+ if (peer_base_addr) {
449
+ char *dest_actual =
450
+ (char *)(peer_base_addr) + ((char *)dest - (char *)(nvshmemi_device_state_d.heap_base));
451
+ nvshmemi_memcpy_threadgroup<SCOPE>((void *)dest_actual, (const void *)source,
452
+ nelems * sizeof(T));
453
+ nvshmemi_threadgroup_sync<SCOPE>();
454
+ if (!myIdx) {
455
+ __threadfence_system();
456
+ nvshmemi_signal_op(sig_addr, signal, sig_op, pe);
457
+ }
458
+ } else {
459
+ nvshmemi_transfer_put_signal<SCOPE>((void *)dest, (void *)source, nelems * sizeof(T),
460
+ (void *)sig_addr, signal, (nvshmemi_amo_t)sig_op, pe,
461
+ is_nbi);
462
+ }
463
+ }
464
+
465
+ template <typename T, threadgroup_t SCOPE>
466
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_put_signal_threadgroup(
467
+ T *dest, const T *source, size_t nelems, uint64_t *sig_addr, uint64_t signal, int sig_op,
468
+ int pe, bool is_nbi) {
469
+ nvshmemi_threadgroup_sync<SCOPE>();
470
+ nvshmemii_put_signal_threadgroup<T, SCOPE>(dest, source, nelems, sig_addr, signal, sig_op, pe,
471
+ is_nbi);
472
+ nvshmemi_threadgroup_sync<SCOPE>();
473
+ }
474
+
475
+ template <typename T, threadgroup_t SCOPE>
476
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_get_threadgroup(T *dest, const T *source,
477
+ size_t nelems, int pe) {
478
+ nvshmemi_threadgroup_sync<SCOPE>();
479
+ void *peer_base_addr =
480
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
481
+ if (peer_base_addr) {
482
+ char *source_actual = (char *)(peer_base_addr) +
483
+ ((char *)source - (char *)(nvshmemi_device_state_d.heap_base));
484
+ nvshmemi_memcpy_threadgroup<SCOPE>((void *)dest, (const void *)source_actual,
485
+ nelems * sizeof(T));
486
+ } else {
487
+ nvshmemi_transfer_rma<SCOPE, NVSHMEMI_OP_GET>((void *)source, (void *)dest,
488
+ nelems * sizeof(T), pe);
489
+ }
490
+ nvshmemi_threadgroup_sync<SCOPE>();
491
+ }
492
+
493
+ template <typename T, threadgroup_t SCOPE>
494
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemii_put_nbi_threadgroup(T *dest,
495
+ const T *source,
496
+ size_t nelems, int pe) {
497
+ void *peer_base_addr =
498
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
499
+ if (peer_base_addr) {
500
+ char *dest_actual =
501
+ (char *)(peer_base_addr) + ((char *)dest - (char *)(nvshmemi_device_state_d.heap_base));
502
+ nvshmemi_memcpy_threadgroup<SCOPE>((void *)dest_actual, (const void *)source,
503
+ nelems * sizeof(T));
504
+ } else {
505
+ nvshmemi_transfer_rma_nbi<SCOPE, NVSHMEMI_OP_PUT>((void *)dest, (void *)source,
506
+ nelems * sizeof(T), pe);
507
+ }
508
+ }
509
+
510
+ template <typename T, threadgroup_t SCOPE>
511
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_put_nbi_threadgroup(T *dest, const T *source,
512
+ size_t nelems, int pe) {
513
+ nvshmemi_threadgroup_sync<SCOPE>();
514
+ nvshmemii_put_nbi_threadgroup<T, SCOPE>(dest, source, nelems, pe);
515
+ nvshmemi_threadgroup_sync<SCOPE>();
516
+ }
517
+
518
+ template <typename T, threadgroup_t SCOPE>
519
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_get_nbi_threadgroup(T *dest, const T *source,
520
+ size_t nelems, int pe) {
521
+ nvshmemi_threadgroup_sync<SCOPE>();
522
+ void *peer_base_addr =
523
+ (void *)__ldg((const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
524
+ if (peer_base_addr) {
525
+ char *source_actual = (char *)(peer_base_addr) +
526
+ ((char *)source - (char *)(nvshmemi_device_state_d.heap_base));
527
+ nvshmemi_memcpy_threadgroup<SCOPE>((void *)dest, (const void *)source_actual,
528
+ nelems * sizeof(T));
529
+ } else {
530
+ nvshmemi_transfer_rma_nbi<SCOPE, NVSHMEMI_OP_GET>((void *)source, (void *)dest,
531
+ nelems * sizeof(T), pe);
532
+ }
533
+ nvshmemi_threadgroup_sync<SCOPE>();
534
+ }
535
+
536
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void *nvshmemi_mc_ptr(nvshmemi_team_t *team,
537
+ const void *ptr) {
538
+ ptrdiff_t offset = (char *)ptr - (char *)nvshmemi_device_state_d.heap_base;
539
+ if (ptr >= nvshmemi_device_state_d.heap_base && offset < nvshmemi_device_state_d.heap_size &&
540
+ team->nvls_rsc_base_ptr != NULL) {
541
+ void *mc_addr = (void *)__ldg((const long long unsigned *)team->nvls_rsc_base_ptr);
542
+ if (mc_addr != NULL) mc_addr = (void *)((char *)mc_addr + offset);
543
+ return mc_addr;
544
+ } else
545
+ return NULL;
546
+ }
547
+
548
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void *nvshmemi_ptr(const void *ptr, int pe) {
549
+ ptrdiff_t offset = (char *)ptr - (char *)nvshmemi_device_state_d.heap_base;
550
+
551
+ if (ptr >= nvshmemi_device_state_d.heap_base && offset < nvshmemi_device_state_d.heap_size) {
552
+ void *peer_addr = (void *)__ldg(
553
+ (const long long unsigned *)nvshmemi_device_state_d.peer_heap_base_p2p + pe);
554
+ if (peer_addr != NULL) peer_addr = (void *)((char *)peer_addr + offset);
555
+ return peer_addr;
556
+ } else
557
+ return NULL;
558
+ }
559
+
560
+ template <typename T, int UNROLL>
561
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_store_128b_register(
562
+ uint64_t dest_regs[2 * UNROLL], uint64_t ll_flag, uint64_t ll_flag_mask, T *src,
563
+ uint8_t unroll_stride) {
564
+ union {
565
+ uint64_t regs8[2];
566
+ uint32_t regs4[4];
567
+ };
568
+ int myIdx = nvshmemi_thread_id_in_threadgroup<NVSHMEMI_THREADGROUP_WARP>();
569
+
570
+ /* in both 16 and 8 byte cases, the flag thread needs to write two 8 byte chunks. */
571
+
572
+ #pragma unroll
573
+ for (int unroll = 0; unroll < UNROLL; unroll++) {
574
+ if (sizeof(T) >= 8) {
575
+ uint64_t *src8 = (uint64_t *)(src + unroll * unroll_stride);
576
+ asm("ld.b64 %0, [%1];" : "=l"(regs8[0]) : "l"(src8));
577
+ asm("ld.b64 %0, [%1];" : "=l"(regs8[1]) : "l"(src8 + 1));
578
+ } else if (sizeof(T) == 4) {
579
+ uint32_t *src4 = (uint32_t *)(src + unroll * unroll_stride);
580
+ asm("ld.b32 %0, [%1];" : "=r"(regs4[0]) : "l"(src4));
581
+ asm("ld.b32 %0, [%1];" : "=r"(regs4[1]) : "l"(src4 + 1));
582
+ asm("ld.b32 %0, [%1];" : "=r"(regs4[2]) : "l"(src4 + 2));
583
+ asm("ld.b32 %0, [%1];" : "=r"(regs4[3]) : "l"(src4 + 3));
584
+ } else {
585
+ uint32_t lower, upper;
586
+ /* funnelshift_r will use shift to select the
587
+ * proper four bytes depending on the alignment.
588
+ * 0x10 = 2, 0x11 = 3, 0x01 = 1
589
+ */
590
+ uint8_t shift = (uintptr_t)src % 4;
591
+ /* We need to align the buffer to the nearest 4 bytes
592
+ * Shift down 2 bytes in the case of 2B alignment down
593
+ * 1B in the case of 1B alignment. Shifting down is always
594
+ * appropriate due to 256 B alignment of cudaMalloc().
595
+ */
596
+ uint32_t *src4 =
597
+ (uint32_t *)((uintptr_t)(src + unroll * unroll_stride) & -(uintptr_t)4);
598
+ /* 2 Byte aligned - 2B in lower, 2B in upper */
599
+ /* 1 Byte aligned (0x01) - 1B in upper, 3B in lower */
600
+ /* 1 Byte aligned (0x11) - 3B in upper, 1B in lower */
601
+ asm("ld.b32 %0, [%1];" : "=r"(lower) : "l"(src4));
602
+ asm("ld.b32 %0, [%1];" : "=r"(upper) : "l"(src4 + 1));
603
+ regs4[0] = __funnelshift_r(lower, upper, 8 * shift);
604
+ asm("ld.b32 %0, [%1];" : "=r"(lower) : "l"(src4 + 1));
605
+ asm("ld.b32 %0, [%1];" : "=r"(upper) : "l"(src4 + 2));
606
+ regs4[1] = __funnelshift_r(lower, upper, 8 * shift);
607
+ asm("ld.b32 %0, [%1];" : "=r"(lower) : "l"(src4 + 2));
608
+ asm("ld.b32 %0, [%1];" : "=r"(upper) : "l"(src4 + 3));
609
+ regs4[2] = __funnelshift_r(lower, upper, 8 * shift);
610
+ asm("ld.b32 %0, [%1];" : "=r"(lower) : "l"(src4 + 4));
611
+ asm("ld.b32 %0, [%1];" : "=r"(upper) : "l"(src4 + 5));
612
+ regs4[3] = __funnelshift_r(lower, upper, 8 * shift);
613
+ }
614
+ dest_regs[unroll * 2] = regs8[0];
615
+ dest_regs[unroll * 2 + 1] = (regs8[1] & ll_flag) | ll_flag_mask;
616
+ }
617
+ }
618
+
619
+ template <typename T>
620
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_store_varlen_register(
621
+ uint64_t dest_regs[2], uint64_t ll_flag, uint64_t ll_flag_mask, void *src, uint8_t nelems) {
622
+ uint8_t i;
623
+ union {
624
+ uint64_t regs8[2];
625
+ uint32_t regs4[4];
626
+ };
627
+
628
+ /* in both 16 and 8 byte cases, the flag thread needs to write two 8 byte chunks. */
629
+ if (sizeof(T) >= 8) {
630
+ uint64_t *src8 = (uint64_t *)src;
631
+ for (i = 0; i < nelems; i++) {
632
+ asm("ld.b64 %0, [%1];" : "=l"(regs8[i]) : "l"(src8 + i));
633
+ }
634
+ } else if (sizeof(T) == 4) {
635
+ uint32_t *src4 = (uint32_t *)src;
636
+ for (i = 0; i < nelems; i++) {
637
+ asm("ld.b32 %0, [%1];" : "=r"(regs4[i]) : "l"(src4 + i));
638
+ }
639
+ } else {
640
+ uint32_t lower, upper;
641
+ /* funnelshift_r will use shift to select the
642
+ * proper four bytes depending on the alignment.
643
+ * 0x10 = 2, 0x11 = 3, 0x01 = 1
644
+ */
645
+ uint8_t shift = (uintptr_t)src % 4;
646
+ /* We need to align the buffer to the nearest 4 bytes
647
+ * Shift down 2 bytes in the case of 2B alignment down
648
+ * 1B in the case of 1B alignment. Shifting down is always
649
+ * appropriate due to 256 B alignment of cudaMalloc().
650
+ */
651
+ uint32_t *src4 = (uint32_t *)((uintptr_t)src & -(uintptr_t)4);
652
+ /* 2 Byte aligned - 2B in lower, 2B in upper */
653
+ /* 1 Byte aligned (0x01) - 1B in upper, 3B in lower */
654
+ /* 1 Byte aligned (0x11) - 3B in upper, 1B in lower */
655
+ for (i = 0; i < nelems; i++) {
656
+ asm("ld.b32 %0, [%1];" : "=r"(lower) : "l"(src4 + i));
657
+ asm("ld.b32 %0, [%1];" : "=r"(upper) : "l"(src4 + i + 1));
658
+ regs4[i] = __funnelshift_r(lower, upper, 8 * shift);
659
+ }
660
+ }
661
+
662
+ dest_regs[0] = regs8[0];
663
+ dest_regs[1] = (regs8[1] & ll_flag) | ll_flag_mask;
664
+ }
665
+
666
+ template <typename T, threadgroup_t SCOPE, int UNROLL>
667
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_packLL128(T *psync, const T *source,
668
+ size_t nelems, uint64_t ll_flag,
669
+ nvshmemi_team_t *teami,
670
+ int pe_count, int team_offset,
671
+ int pe_group_offset) {
672
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
673
+ const uint32_t warp_mask = 0x000000FF << (8 * (myIdx / 8));
674
+ const int num_warps = nvshmemi_threadgroup_size<SCOPE>() / NVSHMEMI_WARP_SIZE;
675
+ /* max 127 */
676
+ const uint8_t remain = nelems % _LL_128_NUM_DATA_ELEMS_PER_PACKET(T);
677
+ /* max ~ 2048 * 16 * 4*/
678
+ const uint32_t source_offset =
679
+ (myIdx / _LL_128_FLAG_THREAD) * UNROLL * _LL_128_NUM_DATA_ELEMS_PER_PACKET(T) +
680
+ myIdx % _LL_128_FLAG_THREAD * _LL_128_NUM_ELEMS_PER_STORE(T);
681
+ const uint32_t psync_offset =
682
+ (myIdx / _LL_128_FLAG_THREAD) * UNROLL * _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(T) +
683
+ myIdx % _LL_128_FLAG_THREAD * _LL_128_NUM_ELEMS_PER_STORE(T);
684
+ const uint32_t source_stride = num_warps * _LL_128_NUM_DATA_ELEMS_PER_WARP(UNROLL, T);
685
+ const uint32_t psync_stride = num_warps * _LL_128_NUM_PSYNC_ELEMS_PER_WARP(UNROLL, T);
686
+ int current_global_pe_index;
687
+ const bool is_flag_thread = !((myIdx + 1) % _LL_128_FLAG_THREAD);
688
+
689
+ /* We will always have a SCOPES worth of elements when doing unrolling */
690
+ if (UNROLL > 1) {
691
+ assert(remain == 0);
692
+ assert(nelems % _LL_128_NUM_DATA_ELEMS_PER_WARP(UNROLL, T) == 0);
693
+ }
694
+
695
+ /* Both source_end and psync_end remove the last < 128 bytes.
696
+ * These will be handled after the loop. */
697
+ T *source_end = (T *)(source + nelems - remain);
698
+
699
+ uint64_t regs[2 * UNROLL];
700
+ T *source_ptr;
701
+ T *psync_ptr;
702
+ T *remote_psync_ptr;
703
+ uint64_t ll_flag_mask;
704
+
705
+ assert(nvshmemi_threadgroup_size<SCOPE>() % NVSHMEMI_WARP_SIZE == 0);
706
+ assert((uintptr_t)psync % 16 == 0);
707
+ assert(sizeof(T) <= 8);
708
+
709
+ if (!is_flag_thread) {
710
+ ll_flag = UINT64_MAX;
711
+ ll_flag_mask = 0x0ULL;
712
+ } else {
713
+ ll_flag_mask = ll_flag;
714
+ }
715
+ __syncwarp();
716
+
717
+ /* Initial offset by thread */
718
+ source_ptr = (T *)source + source_offset;
719
+ psync_ptr = (T *)psync + psync_offset;
720
+
721
+ /* Only gate on source_end. psync_end is not important here. */
722
+ for (; source_ptr < source_end; source_ptr += source_stride, psync_ptr += psync_stride) {
723
+ nvshmemi_store_128b_register<T, UNROLL>(regs, ll_flag, ll_flag_mask, source_ptr,
724
+ _LL_128_NUM_DATA_ELEMS_PER_PACKET(T));
725
+
726
+ /* definitely possible we are not synchronized before loads to psync. Significant perf
727
+ * overhead? */
728
+ for (int pe = 0; pe < pe_count; pe++) {
729
+ current_global_pe_index = nvshmemi_team_translate_pe_to_team_world_wrap(
730
+ teami, team_offset + (pe_group_offset + pe) % pe_count);
731
+ /* if (VOLATILE && current_global_pe_index == my_pe_idx) {
732
+ continue;
733
+ } */
734
+ remote_psync_ptr = (T *)nvshmemi_ptr(psync_ptr, current_global_pe_index);
735
+ #pragma unroll
736
+ for (int unroll = 0; unroll < UNROLL * 2; unroll += 2) {
737
+ asm volatile(
738
+ "st.volatile.global.v2.b64 [%0], {%1,%2};" ::"l"((int4 *)remote_psync_ptr),
739
+ "l"(regs[unroll]), "l"(regs[unroll + 1]));
740
+ remote_psync_ptr += _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(T);
741
+ }
742
+ }
743
+ }
744
+
745
+ if (UNROLL == 1 && remain) {
746
+ uint8_t num_elems_per_store;
747
+ T *psync_end =
748
+ psync + (nelems - remain) +
749
+ (nelems / _LL_128_NUM_DATA_ELEMS_PER_PACKET(T)) * _LL_128_NUM_ELEMS_PER_FLAG(T);
750
+ /* Last packet will contain < 128 bytes. the variable remain is usually > 0. */
751
+ /* only need 1/4th of a warp */
752
+ if (myIdx < 8) {
753
+ source_ptr = source_end + source_offset;
754
+ psync_ptr = psync_end + psync_offset;
755
+ if (source_offset + _LL_128_NUM_ELEMS_PER_STORE(T) <= remain) {
756
+ nvshmemi_store_128b_register<T, 1>(regs, UINT64_MAX, ll_flag_mask, source_ptr,
757
+ _LL_128_NUM_DATA_ELEMS_PER_PACKET(T));
758
+ } else {
759
+ num_elems_per_store = source_offset > remain ? 0 : remain - source_offset;
760
+ nvshmemi_store_varlen_register<T>(regs, ll_flag, ll_flag_mask, source_ptr,
761
+ num_elems_per_store);
762
+ }
763
+ __syncwarp(warp_mask);
764
+ for (int pe = 0; pe < pe_count; pe++) {
765
+ current_global_pe_index = nvshmemi_team_translate_pe_to_team_world_wrap(
766
+ teami, team_offset + (pe_group_offset + pe) % pe_count);
767
+ /* if (VOLATILE && current_global_pe_index == my_pe_idx) {
768
+ continue;
769
+ } */
770
+ remote_psync_ptr = (T *)nvshmemi_ptr(psync_ptr, current_global_pe_index);
771
+ asm volatile(
772
+ "st.volatile.global.v2.b64 [%0], {%1,%2};" ::"l"((int4 *)remote_psync_ptr),
773
+ "l"(regs[0]), "l"(regs[1]));
774
+ }
775
+ }
776
+ }
777
+ nvshmemi_threadgroup_sync<SCOPE>();
778
+ }
779
+
780
+ template <int UNROLL>
781
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_ll128_load_psync(uint64_t reg[UNROLL * 2],
782
+ uint64_t *src,
783
+ uint64_t ll_flag,
784
+ uint32_t warp_mask,
785
+ bool is_flag_thread) {
786
+ uint64_t *offset_src;
787
+ int i;
788
+ bool flag_arrived;
789
+ do {
790
+ flag_arrived = true;
791
+ #pragma unroll
792
+ for (i = 0; i < UNROLL * 2; i += 2) {
793
+ offset_src = src + _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(uint64_t) * (i / 2);
794
+ asm volatile("ld.volatile.global.v2.b64 {%0,%1}, [%2];"
795
+ : "=l"(reg[i]), "=l"(reg[i + 1])
796
+ : "l"((int4 *)offset_src));
797
+ flag_arrived &= (reg[i + 1] == ll_flag);
798
+ flag_arrived |= !is_flag_thread;
799
+ }
800
+ flag_arrived = __all_sync(warp_mask, flag_arrived != false);
801
+ } while (!flag_arrived);
802
+ }
803
+
804
+ template <typename T, int UNROLL>
805
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_recvLL128(T *dest, const T *psync,
806
+ size_t nelems, uint64_t flag) {
807
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<NVSHMEMI_THREADGROUP_WARP>();
808
+ const uint32_t warp_mask = 0x000000FF << (8 * (myIdx / 8));
809
+ /* max 127 */
810
+ const uint8_t remain = nelems % _LL_128_NUM_DATA_ELEMS_PER_PACKET(T);
811
+ /* max ~ 2048 * 16 * 4*/
812
+ const uint32_t dest_offset =
813
+ (myIdx / _LL_128_FLAG_THREAD) * UNROLL * _LL_128_NUM_DATA_ELEMS_PER_PACKET(T) +
814
+ myIdx % _LL_128_FLAG_THREAD * _LL_128_NUM_ELEMS_PER_STORE(T);
815
+ const uint32_t psync_offset =
816
+ (myIdx / _LL_128_FLAG_THREAD) * UNROLL * _LL_128_NUM_PSYNC_ELEMS_PER_PACKET(T) +
817
+ myIdx % _LL_128_FLAG_THREAD * _LL_128_NUM_ELEMS_PER_STORE(T);
818
+ const bool is_flag_thread = !((myIdx + 1) % _LL_128_FLAG_THREAD);
819
+ uint8_t source_copy_len = 16 >> is_flag_thread;
820
+
821
+ /* We will always have a SCOPES worth of elements when doing unrolling */
822
+ if (UNROLL > 1) {
823
+ assert(remain == 0);
824
+ assert(nelems % _LL_128_NUM_DATA_ELEMS_PER_WARP(UNROLL, T) == 0);
825
+ }
826
+
827
+ /* Both dest_end and psync_end remove the last < 128 bytes.
828
+ * These will be handled after the loop. */
829
+ T *dest_end = (T *)(dest + nelems - remain);
830
+
831
+ uint64_t regs[2 * UNROLL];
832
+ T *dest_ptr;
833
+ T *cur_dest_ptr;
834
+ T *psync_ptr;
835
+
836
+ assert((uintptr_t)psync % 16 == 0);
837
+ assert(sizeof(T) <= 8);
838
+
839
+ /* Initial offset by thread */
840
+ dest_ptr = (T *)dest + dest_offset;
841
+ psync_ptr = (T *)psync + psync_offset;
842
+ for (; dest_ptr < dest_end; dest_ptr += _LL_128_NUM_DATA_ELEMS_PER_WARP(UNROLL, T),
843
+ psync_ptr += _LL_128_NUM_PSYNC_ELEMS_PER_WARP(UNROLL, T)) {
844
+ if (UNROLL > 1) {
845
+ nvshmemi_ll128_load_psync<UNROLL>(regs, (uint64_t *)psync_ptr, flag, 0xFFFFFFFF,
846
+ is_flag_thread);
847
+ } else {
848
+ nvshmemi_ll128_load_psync<UNROLL>(regs, (uint64_t *)psync_ptr, flag, warp_mask,
849
+ is_flag_thread);
850
+ }
851
+
852
+ cur_dest_ptr = dest_ptr;
853
+ #pragma unroll
854
+ for (int i = 0; i < UNROLL * 2; i += 2) {
855
+ asm("st.global.b64 [%0], %1;" ::"l"((uint64_t *)cur_dest_ptr), "l"(regs[i]));
856
+ if (!is_flag_thread) {
857
+ asm("st.global.b64 [%0], %1;" ::"l"((uint64_t *)cur_dest_ptr + 1),
858
+ "l"(regs[i + 1]));
859
+ }
860
+ if (UNROLL > 1) {
861
+ __syncwarp();
862
+ } else {
863
+ __syncwarp(warp_mask);
864
+ }
865
+ cur_dest_ptr += _LL_128_NUM_DATA_ELEMS_PER_PACKET(T);
866
+ }
867
+ }
868
+
869
+ if (UNROLL == 1 && remain) {
870
+ T *psync_end =
871
+ (T *)psync + (nelems - remain) +
872
+ (nelems / _LL_128_NUM_DATA_ELEMS_PER_PACKET(T)) * _LL_128_NUM_ELEMS_PER_FLAG(T);
873
+ if (remain && myIdx < 8) {
874
+ dest_ptr = dest_end + dest_offset;
875
+ psync_ptr = psync_end + psync_offset;
876
+ nvshmemi_ll128_load_psync<1>(regs, (uint64_t *)psync_ptr, flag, warp_mask,
877
+ is_flag_thread);
878
+ if (dest_offset < remain) {
879
+ source_copy_len = dest_offset + _LL_128_NUM_ELEMS_PER_STORE(T) < remain
880
+ ? _LL_128_STORE_SIZE
881
+ : ((remain - dest_offset) * sizeof(T));
882
+ nvshmemi_memcpy_threadgroup<NVSHMEMI_THREADGROUP_THREAD>(dest_ptr, regs,
883
+ source_copy_len);
884
+ }
885
+ }
886
+ }
887
+ __syncwarp();
888
+ }
889
+
890
+ template <typename T, threadgroup_t SCOPE>
891
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_mcast_recvLL(T *dest, const uint64_t *src,
892
+ size_t nelems, uint32_t flag) {
893
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
894
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
895
+ size_t num_subelems = (nelems * sizeof(T)) / sizeof(uint32_t);
896
+ if (TYPE_IS_FLOAT(T)) {
897
+ for (int i = myIdx; i < num_subelems; i += groupSize) {
898
+ float data1, flag1;
899
+ volatile uint32_t flagu32;
900
+ do {
901
+ asm volatile("ld.volatile.global.v2.f32 {%0, %1}, [%2];"
902
+ : "=f"(data1), "=f"(flag1)
903
+ : "l"(&src[i]));
904
+ asm("cvt.rni.u32.f32 %0, %1;" : "=r"(flagu32) : "f"(flag1));
905
+ } while ((flagu32 != flag));
906
+ *(float *)((char *)dest + i * sizeof(float)) = data1;
907
+ }
908
+ } else {
909
+ for (int i = 2 * myIdx; i < num_subelems; i += 2 * groupSize) {
910
+ uint32_t flag1, flag2, data1, data2;
911
+ do {
912
+ asm volatile("ld.volatile.global.v4.u32 {%0,%1,%2,%3}, [%4];"
913
+ : "=r"(data1), "=r"(flag1), "=r"(data2), "=r"(flag2)
914
+ : "l"(&src[i]));
915
+ } while ((flag1 != flag) || (flag2 != flag));
916
+ *(uint32_t *)((char *)dest + i * sizeof(uint32_t)) = data1;
917
+ *(uint32_t *)((char *)dest + (i + 1) * sizeof(uint32_t)) = data2;
918
+ }
919
+ }
920
+ }
921
+
922
+ template <typename T, threadgroup_t SCOPE>
923
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_mcast_packLL(uint64_t *dest, const T *source,
924
+ size_t nelems,
925
+ uint32_t ll_flag) {
926
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
927
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
928
+ const size_t num_subelems = (nelems * sizeof(T)) / sizeof(float);
929
+ float flagf32;
930
+ if (TYPE_IS_FLOAT(T)) asm("cvt.rn.f32.u32 %0, %1;" : "=f"(flagf32) : "r"(ll_flag));
931
+ for (int i = 2 * myIdx; i < num_subelems; i += 2 * groupSize) {
932
+ if (TYPE_IS_FLOAT(T)) {
933
+ float val1 = *(float *)((char *)source + i * sizeof(float));
934
+ float val2 = *(float *)((char *)source + (i + 1) * sizeof(float));
935
+ asm("multimem.st.global.v4.f32 [%0], {%1, %2, %3, %4};" ::"l"(&dest[i]), "f"(val1),
936
+ "f"(flagf32), "f"(val2), "f"(flagf32)
937
+ : "memory");
938
+ } else {
939
+ uint32_t val1 = *(uint32_t *)((char *)source + i * sizeof(uint32_t));
940
+ uint32_t val2 = *(uint32_t *)((char *)source + (i + 1) * sizeof(uint32_t));
941
+ asm("multimem.st.global.v4.f32 [%0], {%1, %2, %3, %4};" ::"l"(&dest[i]), "r"(val1),
942
+ "r"(ll_flag), "r"(val2), "r"(ll_flag)
943
+ : "memory");
944
+ }
945
+ }
946
+ }
947
+
948
+ template <typename T, threadgroup_t SCOPE>
949
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_recvLL(T *dest, const uint64_t *src,
950
+ size_t nelems, uint32_t flag) {
951
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
952
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
953
+ size_t num_subelems = (nelems * sizeof(T)) / sizeof(uint32_t);
954
+ for (int i = 2 * myIdx; i < num_subelems; i += 2 * groupSize) {
955
+ uint32_t flag1, flag2, data1, data2;
956
+ do {
957
+ asm volatile("ld.volatile.global.v4.u32 {%0,%1,%2,%3}, [%4];"
958
+ : "=r"(data1), "=r"(flag1), "=r"(data2), "=r"(flag2)
959
+ : "l"(&src[i]));
960
+
961
+ } while ((flag1 != flag) || (flag2 != flag));
962
+ *(uint32_t *)((char *)dest + i * sizeof(uint32_t)) = data1;
963
+ *(uint32_t *)((char *)dest + (i + 1) * sizeof(uint32_t)) = data2;
964
+ }
965
+ }
966
+
967
+ template <typename T, threadgroup_t SCOPE>
968
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_packLL_naive(uint64_t *dest, const T *source,
969
+ size_t nelems,
970
+ uint32_t ll_flag) {
971
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
972
+ int groupSize = nvshmemi_threadgroup_size<SCOPE>();
973
+ size_t num_subelems = (nelems * sizeof(T)) / sizeof(uint32_t);
974
+ for (int i = myIdx * 2; i < num_subelems; i += groupSize * 2) {
975
+ size_t dst_offset = 2 * i * sizeof(uint32_t);
976
+ size_t src_offset = i * sizeof(uint32_t);
977
+ asm volatile("st.volatile.global.v4.u32 [%0], {%1,%2,%3,%4};" ::"l"(
978
+ (uint32_t *)((char *)dest + dst_offset)),
979
+ "r"(*(uint32_t *)((char *)source + src_offset)), "r"(ll_flag),
980
+ "r"(*(uint32_t *)((char *)source + src_offset + sizeof(uint32_t))),
981
+ "r"(ll_flag));
982
+ }
983
+ }
984
+
985
+ template <typename T, threadgroup_t SCOPE, int UNROLL>
986
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_packLL(T *psync, const T *source,
987
+ size_t nelems, uint32_t ll_flag,
988
+ nvshmemi_team_t *teami, int pe_count,
989
+ int team_offset) {
990
+ const size_t num_subelems = (nelems * sizeof(T)) / sizeof(uint32_t);
991
+ const int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
992
+ const int groupSize = nvshmemi_threadgroup_size<SCOPE>();
993
+ /* each thread will write 2 subelements (8 bytes) */
994
+ const size_t element_start = myIdx * UNROLL * 2;
995
+ const size_t element_stride = groupSize * UNROLL * 2;
996
+ size_t element_offset;
997
+ uint32_t regs[2 * UNROLL];
998
+
999
+ int current_global_pe_index;
1000
+ uint32_t *current_dest_address;
1001
+
1002
+ /* We need to be sure to fill each unrolled loop */
1003
+ assert(num_subelems % UNROLL * 2 == 0);
1004
+ assert((uintptr_t)psync % 16 == 0);
1005
+
1006
+ for (element_offset = element_start; element_offset < num_subelems;
1007
+ element_offset += element_stride) {
1008
+ #pragma unroll
1009
+ for (int unroll = 0; unroll < UNROLL * 2; unroll += 2) {
1010
+ if (sizeof(T) == sizeof(uint64_t)) {
1011
+ asm("ld.global.v2.u32 {%0,%1}, [%2];"
1012
+ : "=r"(regs[unroll]), "=r"(regs[unroll + 1])
1013
+ : "l"((uint32_t *)source + element_offset + unroll));
1014
+ } else {
1015
+ regs[unroll] = *((uint32_t *)source + element_offset + unroll);
1016
+ regs[unroll + 1] = *((uint32_t *)source + element_offset + unroll + 1);
1017
+ }
1018
+ }
1019
+ for (int pe = 0; pe < pe_count; pe++) {
1020
+ current_global_pe_index =
1021
+ nvshmemi_team_translate_pe_to_team_world_wrap(teami, team_offset + pe);
1022
+ current_dest_address =
1023
+ (uint32_t *)nvshmemi_ptr(psync, current_global_pe_index) + element_offset * 2;
1024
+
1025
+ #pragma unroll
1026
+ for (int unroll = 0; unroll < UNROLL * 2; unroll += 2) {
1027
+ asm volatile("st.volatile.global.v4.u32 [%0], {%1,%2,%3,%4};" ::"l"(
1028
+ (int4 *)current_dest_address),
1029
+ "r"(regs[unroll]), "r"(ll_flag), "r"(regs[unroll + 1]), "r"(ll_flag));
1030
+ current_dest_address += sizeof(int4) / sizeof(uint32_t);
1031
+ }
1032
+ }
1033
+ }
1034
+ }
1035
+
1036
+ #endif /* __CUDA__ARCH__ */
1037
+ #endif /* _NVSHMEM_COMMON_DEVICE_CUH_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/common/nvshmemi_tile_utils.cuh ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+ #ifndef _NVSHMEM_TILE_UTILS_CUH_
7
+ #define _NVSHMEM_TILE_UTILS_CUH_
8
+
9
+ #include <cuda_runtime.h>
10
+ #include "cuda/std/tuple"
11
+ #include "cuda/std/type_traits"
12
+ #include "cuda/std/utility"
13
+ #include "host/nvshmem_macros.h"
14
+ #include "device_host/nvshmem_tensor.h"
15
+
16
+ using tuple5Int_t = cuda::std::tuple<int, int, int, int, int>;
17
+
18
+ /**** Functions to get constant values at compile time ****/
19
+
20
+ template <typename T, typename Enable = void>
21
+ struct is_integral_constant {
22
+ static const bool value = false;
23
+ };
24
+
25
+ // Specialization for integral_constant types
26
+ template <typename T>
27
+ struct is_integral_constant<
28
+ T, typename cuda::std::enable_if<cuda::std::is_base_of<
29
+ cuda::std::integral_constant<typename T::value_type, T::value>, T>::value>::type> {
30
+ static const bool value = true;
31
+ };
32
+
33
+ // Check if T is an integral constant with specific value
34
+ template <typename T, int N, typename Enable = void>
35
+ struct is_integral_constant_value {
36
+ static const bool value = false;
37
+ };
38
+
39
+ template <typename T, int N>
40
+ struct is_integral_constant_value<
41
+ T, N, typename cuda::std::enable_if<is_integral_constant<T>::value>::type> {
42
+ static const bool value = (T::value == N);
43
+ };
44
+
45
+ // Helper function to get integral constant value at compile time
46
+ template <typename T, typename Enable = void>
47
+ struct get_constant_value {
48
+ __host__ __device__ __forceinline__ static constexpr int value() { return 0; } // default case
49
+ };
50
+
51
+ template <typename T>
52
+ struct get_constant_value<T, typename cuda::std::enable_if<is_integral_constant<T>::value>::type> {
53
+ __host__ __device__ __forceinline__ static constexpr int value() { return T::value; }
54
+ };
55
+
56
+ // Convenience wrapper function
57
+ template <typename T>
58
+ __host__ __device__ __forceinline__ constexpr int get_constant() {
59
+ return get_constant_value<T>::value();
60
+ }
61
+
62
+ template <typename T>
63
+ __host__ __device__ __forceinline__ constexpr int get_constant(T val) {
64
+ return get_constant_value<T>::value();
65
+ }
66
+ /**** End of Functions to get constant values at compile time ****/
67
+
68
+ /***** Helper functions for tuples ******/
69
+ // Traits to get tuple size at compile time
70
+ template <typename Tuple>
71
+ struct tuple_size_traits {
72
+ static constexpr size_t value = cuda::std::tuple_size<Tuple>::value;
73
+ };
74
+
75
+ // Check if index is in bounds
76
+ template <int I, typename Tuple>
77
+ struct is_index_in_bounds {
78
+ static constexpr bool value = (I >= 0 && I < tuple_size_traits<Tuple>::value);
79
+ };
80
+ /**** End of Helper functions for tuples ******/
81
+
82
+ /*** Function to return the size of a tuple at compile time ****/
83
+ // TODO: overload for cute::tuple
84
+ template <typename... Args>
85
+ NVSHMEMI_HOSTDEVICE_PREFIX constexpr size_t get_tuple_size(
86
+ cuda::std::tuple<Args...> const& /*tuple*/) { // The instance isn't needed
87
+ return cuda::std::tuple_size<cuda::std::tuple<Args...>>::value;
88
+ }
89
+
90
+ template <int I, typename... Args>
91
+ /*NVSHMEMI_HOSTDEVICE_PREFIX constexpr*/
92
+ __host__ __device__ __forceinline__ constexpr decltype(
93
+ cuda::std::get<I>(cuda::std::declval<const cuda::std::tuple<Args...>&>()))
94
+ get_tuple_val(cuda::std::tuple<Args...> const& tuple) {
95
+ return cuda::std::get<I>(tuple);
96
+ }
97
+
98
+ /*** Accessor functions for shape ***/
99
+ /*** if index used is out of bounds, return 1 ***/
100
+ // Primary template for shape access (out-of-bounds)
101
+ template <int I, typename T, class Layout, bool InBounds>
102
+ struct tensor_shape_element_impl {
103
+ NVSHMEMI_HOSTDEVICE_PREFIX static constexpr int get(const nvshmemx::Tensor<T, Layout>& tensor) {
104
+ return 1; // Out of bounds, return 1
105
+ }
106
+ };
107
+
108
+ // Specialization for in-bounds shape access
109
+ template <int I, typename T, class Layout>
110
+ struct tensor_shape_element_impl<I, T, Layout, true> {
111
+ NVSHMEMI_HOSTDEVICE_PREFIX static constexpr auto get(const nvshmemx::Tensor<T, Layout>& tensor)
112
+ -> decltype(cuda::std::get<I>(tensor.shape())) {
113
+ return cuda::std::get<I>(tensor.shape());
114
+ }
115
+ };
116
+
117
+ // Public interface for shape
118
+ template <int I, typename T, class Layout>
119
+ NVSHMEMI_HOSTDEVICE_PREFIX constexpr auto get_shape_element(
120
+ const nvshmemx::Tensor<T, Layout>& tensor)
121
+ -> decltype(
122
+ tensor_shape_element_impl<
123
+ I, T, Layout, is_index_in_bounds<I, decltype(tensor.shape())>::value>::get(tensor)) {
124
+ return tensor_shape_element_impl<
125
+ I, T, Layout, is_index_in_bounds<I, decltype(tensor.shape())>::value>::get(tensor);
126
+ }
127
+
128
+ /*** Accessor functions for stride ***/
129
+ /*** if index used is out of bounds, return 0 ***/
130
+
131
+ // Primary template for stride access (out-of-bounds)
132
+ template <int I, typename T, class Layout, bool InBounds>
133
+ struct tensor_stride_element_impl {
134
+ NVSHMEMI_HOSTDEVICE_PREFIX static constexpr int get(const nvshmemx::Tensor<T, Layout>& tensor) {
135
+ return 0; // Out of bounds, return 0 for stride
136
+ }
137
+ };
138
+
139
+ // Specialization for in-bounds stride access
140
+ template <int I, typename T, class Layout>
141
+ struct tensor_stride_element_impl<I, T, Layout, true> {
142
+ NVSHMEMI_HOSTDEVICE_PREFIX static constexpr auto get(const nvshmemx::Tensor<T, Layout>& tensor)
143
+ -> decltype(cuda::std::get<I>(tensor.stride())) {
144
+ return cuda::std::get<I>(tensor.stride());
145
+ }
146
+ };
147
+
148
+ // Public interface for stride
149
+ template <int I, typename T, class Layout>
150
+ NVSHMEMI_HOSTDEVICE_PREFIX constexpr auto get_stride_element(
151
+ const nvshmemx::Tensor<T, Layout>& tensor)
152
+ -> decltype(
153
+ tensor_stride_element_impl<
154
+ I, T, Layout, is_index_in_bounds<I, decltype(tensor.stride())>::value>::get(tensor)) {
155
+ return tensor_stride_element_impl<
156
+ I, T, Layout, is_index_in_bounds<I, decltype(tensor.stride())>::value>::get(tensor);
157
+ }
158
+
159
+ /**** Safe access functions for tuples ******/
160
+ /*** Returns 0 for out-of-bounds access ***/
161
+
162
+ // Primary template for safe tuple access (out-of-bounds)
163
+ template <int I, typename Tuple, bool InBounds>
164
+ struct safe_get_impl {
165
+ // Out of bounds access returns int
166
+ NVSHMEMI_HOSTDEVICE_PREFIX
167
+ static constexpr int get(const Tuple&) {
168
+ return 0; // Default to 0 for out-of-bounds
169
+ }
170
+ };
171
+
172
+ // Specialization for in-bounds access
173
+ template <int I, typename Tuple>
174
+ struct safe_get_impl<I, Tuple, true> {
175
+ // Define the return type for in-bounds access
176
+ typedef decltype(cuda::std::get<I>(cuda::std::declval<const Tuple&>())) return_type;
177
+
178
+ NVSHMEMI_HOSTDEVICE_PREFIX
179
+ static constexpr return_type get(const Tuple& tuple) { return cuda::std::get<I>(tuple); }
180
+ };
181
+
182
+ // Public interface for safe tuple access
183
+ template <int I, typename Tuple>
184
+ NVSHMEMI_HOSTDEVICE_PREFIX constexpr
185
+ typename cuda::std::conditional<(I < tuple_size_traits<Tuple>::value),
186
+ decltype(cuda::std::get<I>(cuda::std::declval<const Tuple&>())),
187
+ int>::type
188
+ safe_get(const Tuple& tuple) {
189
+ return safe_get_impl<I, Tuple, (I < tuple_size_traits<Tuple>::value)>::get(tuple);
190
+ }
191
+
192
+ /**** Function to tuple of size 2 accounting for the major dimension */
193
+ // TODO: expand this to support more than 2 dimensions
194
+ template <int major_dim>
195
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__ tuple5Int_t create_coord_tuple(int coord_major,
196
+ int coord_minor) {
197
+ if (major_dim == 0) {
198
+ return cuda::std::make_tuple(coord_major, coord_minor, 0, 0, 0);
199
+ } else {
200
+ return cuda::std::make_tuple(coord_minor, coord_major, 0, 0, 0);
201
+ }
202
+ }
203
+
204
+ /*
205
+ * Functionto compare elements of tuples
206
+ */
207
+ // TODO make a cute variant of this
208
+ // Helper to check bounds for each dimension
209
+ // Helper to check if a dimension is valid
210
+ template <typename tuple_t>
211
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__ bool check_dimension_valid(const tuple_t& start_coord,
212
+ const tuple5Int_t& elem_coord,
213
+ const tuple_t& boundary,
214
+ int dim, int major_dim,
215
+ int vlen) {
216
+ if (dim == major_dim) {
217
+ return (get_tuple_val<0>(start_coord) + get_tuple_val<0>(elem_coord) + (vlen - 1) <
218
+ get_tuple_val<0>(boundary));
219
+ } else {
220
+ return (get_tuple_val<0>(start_coord) + get_tuple_val<0>(elem_coord) <
221
+ get_tuple_val<0>(boundary));
222
+ }
223
+ }
224
+
225
+ // Primary template for dimension checking
226
+ template <int Dim, int MaxDim, typename tuple_t, bool = (Dim < MaxDim)>
227
+ struct dimension_checker {
228
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__ static bool check(const tuple_t& start_coord,
229
+ const tuple5Int_t& elem_coord,
230
+ const tuple_t& boundary,
231
+ int major_dim, int vlen) {
232
+ bool current_valid;
233
+
234
+ if (Dim == major_dim) {
235
+ current_valid =
236
+ (get_tuple_val<Dim>(start_coord) + get_tuple_val<Dim>(elem_coord) + (vlen - 1) <
237
+ get_tuple_val<Dim>(boundary));
238
+ } else {
239
+ current_valid = (get_tuple_val<Dim>(start_coord) + get_tuple_val<Dim>(elem_coord) <
240
+ get_tuple_val<Dim>(boundary));
241
+ }
242
+
243
+ return current_valid && dimension_checker<Dim + 1, MaxDim, tuple_t>::check(
244
+ start_coord, elem_coord, boundary, major_dim, vlen);
245
+ }
246
+ };
247
+
248
+ // Base case: When Dim == MaxDim
249
+ template <int Dim, int MaxDim, typename tuple_t>
250
+ struct dimension_checker<Dim, MaxDim, tuple_t, false> {
251
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__ static bool check(const tuple_t&, const tuple5Int_t&,
252
+ const tuple_t&, int, int) {
253
+ return true; // End of recursion
254
+ }
255
+ };
256
+
257
+ // Special case for 1D tuples
258
+ template <typename tuple_t, int major_dim>
259
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__
260
+ typename cuda::std::enable_if<(tuple_size_traits<tuple_t>::value == 1), bool>::type
261
+ is_less_than_impl(const tuple_t& start_coord, const tuple5Int_t& elem_coord,
262
+ const tuple_t& boundary, int vlen) {
263
+ return check_dimension_valid(start_coord, elem_coord, boundary, 0, major_dim, vlen);
264
+ }
265
+
266
+ // Special case for 2D tuples
267
+ template <typename tuple_t, int major_dim>
268
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__
269
+ typename cuda::std::enable_if<(tuple_size_traits<tuple_t>::value == 2), bool>::type
270
+ is_less_than_impl(const tuple_t& start_coord, const tuple5Int_t& elem_coord,
271
+ const tuple_t& boundary, int vlen) {
272
+ return dimension_checker<0, 2, tuple_t>::check(start_coord, elem_coord, boundary, major_dim,
273
+ vlen);
274
+ }
275
+
276
+ // Main function with runtime dispatching based on tuple size
277
+ template <typename tuple_t, int major_dim>
278
+ NVSHMEMI_HOSTDEVICE_PREFIX __forceinline__ bool is_less_than(const tuple_t& start_coord,
279
+ const tuple5Int_t& elem_coord,
280
+ const tuple_t& boundary,
281
+ int vlen = 1) {
282
+ static_assert(tuple_size_traits<tuple_t>::value <= 2,
283
+ "Tuples with more than 2 dimensions are not supported");
284
+
285
+ return is_less_than_impl<tuple_t, major_dim>(start_coord, elem_coord, boundary, vlen);
286
+ }
287
+
288
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/ibgda_device.cuh ADDED
The diff for this file is too large to render. See raw diff
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/nvshmemi_transfer_api.cuh ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #include <cuda_runtime.h>
8
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
9
+
10
+ #ifndef _NVSHMEMI_TRANSFER_H_
11
+ #define _NVSHMEMI_TRANSFER_H_
12
+ template <typename T>
13
+ __device__ void nvshmemi_transfer_rma_p(void *rptr, const T value, int pe);
14
+
15
+ template <typename T>
16
+ __device__ T nvshmemi_transfer_rma_g(void *rptr, int pe);
17
+
18
+ template <threadgroup_t SCOPE, nvshmemi_op_t channel_op>
19
+ __device__ void nvshmemi_transfer_rma(void *rptr, void *lptr, size_t bytes, int pe);
20
+
21
+ template <threadgroup_t SCOPE>
22
+ __device__ void nvshmemi_transfer_put_signal(void *rptr, void *lptr, size_t bytes, void *sig_addr,
23
+ uint64_t signal, nvshmemi_amo_t sig_op, int pe,
24
+ bool is_nbi);
25
+
26
+ template <threadgroup_t SCOPE, nvshmemi_op_t channel_op>
27
+ __device__ void nvshmemi_transfer_rma_nbi(void *rptr, void *lptr, size_t bytes, int pe);
28
+
29
+ template <typename T>
30
+ __device__ T nvshmemi_transfer_amo_fetch(void *rptr, T value, T compare, int pe, nvshmemi_amo_t op);
31
+
32
+ template <typename T>
33
+ __device__ void nvshmemi_transfer_amo_nonfetch(void *rptr, T value, int pe, nvshmemi_amo_t op);
34
+
35
+ template <threadgroup_t SCOPE>
36
+ __device__ void nvshmemi_transfer_quiet(bool use_membar);
37
+
38
+ template <threadgroup_t SCOPE>
39
+ __device__ void nvshmemi_transfer_fence();
40
+ __device__ void nvshmemi_transfer_enforce_consistency_at_target(bool use_membar);
41
+ __device__ void nvshmemi_transfer_syncapi_update_mem();
42
+ #endif /* _NVSHMEMI_TRANSFER_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/proxy_device.cuh ADDED
@@ -0,0 +1,572 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /****
2
+ * Copyright (c) 2014, NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ *
7
+ * * Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ * * Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ * * Neither the name of the NVIDIA Corporation nor the names of its
13
+ * contributors may be used to endorse or promote products derived from
14
+ * this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26
+ * THE POSSIBILITY OF SUCH DAMAGE.
27
+ *
28
+ *
29
+ * The U.S. Department of Energy funded the development of this software
30
+ * under subcontract 7078610 with Lawrence Berkeley National Laboratory.
31
+ *
32
+ ****/
33
+
34
+ #ifndef PROXY_DEVICE_CUH
35
+ #define PROXY_DEVICE_CUH
36
+
37
+ #include <cuda_runtime.h>
38
+ #include "utils_device.h"
39
+ #include "non_abi/device/wait/nvshmemi_wait_until_apis.cuh"
40
+ /* this file does not directly use the definitions from device_host/nvshmem_proxy_channel.h */
41
+ /* But the way the requests are filled in directly represents those structures. */
42
+ #include "device_host/nvshmem_proxy_channel.h" // IWYU pragma: keep
43
+
44
+ #ifdef __CUDA_ARCH__
45
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE __device__ void check_channel_availability(
46
+ uint64_t tail_idx) {
47
+ uint64_t complete;
48
+ complete = *((volatile uint64_t *)nvshmemi_device_state_d.proxy_channels_complete_local_ptr);
49
+ if ((complete + nvshmemi_device_state_d.proxy_channel_buf_size - 1) < tail_idx) {
50
+ nvshmemi_wait_until_greater_than_equals_add<uint64_t>(
51
+ nvshmemi_device_state_d.proxy_channels_complete,
52
+ nvshmemi_device_state_d.proxy_channel_buf_size - 1, tail_idx,
53
+ NVSHMEMI_CALL_SITE_PROXY_CHECK_CHANNEL_AVAILABILITY);
54
+ atomicMax(
55
+ (unsigned long long int *)nvshmemi_device_state_d.proxy_channels_complete_local_ptr,
56
+ *nvshmemi_device_state_d.proxy_channels_complete);
57
+ __threadfence_system(); // XXX: prevents store to buf_d reordered to before load from
58
+ // complete_d (breaks rma)
59
+ }
60
+ }
61
+
62
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_quiet(
63
+ bool use_membar) {
64
+ uint64_t quiet_issue;
65
+ quiet_issue = (*(volatile uint64_t *)nvshmemi_device_state_d.proxy_channels_issue);
66
+ atomicMax((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_quiet_issue,
67
+ quiet_issue);
68
+
69
+ nvshmemi_wait_until_greater_than_equals<uint64_t>(
70
+ nvshmemi_device_state_d.proxy_channels_quiet_ack, quiet_issue,
71
+ NVSHMEMI_CALL_SITE_PROXY_QUIET);
72
+ if (use_membar) {
73
+ __threadfence_system(); // XXX: prevents store to issue_d reordered to before load from
74
+ // quiet_ack_d (breaks quiet -> rma)
75
+ }
76
+ }
77
+
78
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_global_exit(
79
+ int status) {
80
+ int rc;
81
+
82
+ rc = atomicCAS(nvshmemi_device_state_d.global_exit_request_state,
83
+ PROXY_GLOBAL_EXIT_NOT_REQUESTED, PROXY_GLOBAL_EXIT_INIT);
84
+ if (rc == PROXY_GLOBAL_EXIT_NOT_REQUESTED) {
85
+ *nvshmemi_device_state_d.global_exit_code = status;
86
+ __threadfence_system();
87
+ rc = atomicCAS(nvshmemi_device_state_d.global_exit_request_state, PROXY_GLOBAL_EXIT_INIT,
88
+ PROXY_GLOBAL_EXIT_REQUESTED);
89
+ assert(rc == PROXY_GLOBAL_EXIT_INIT);
90
+ }
91
+ /* Note, this will block indefinitely, but that is fine as nvshmemi_global_exit should never
92
+ * return. */
93
+ long long int now, later;
94
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(now));
95
+ do {
96
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(later));
97
+ } while (later >= now);
98
+ }
99
+
100
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void
101
+ nvshmemi_proxy_enforce_consistency_at_target(bool use_membar) {
102
+ uint64_t cst_issue;
103
+ cst_issue = (*(volatile uint64_t *)nvshmemi_device_state_d.proxy_channels_issue);
104
+ atomicMax((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_cst_issue,
105
+ cst_issue);
106
+
107
+ nvshmemi_wait_until_greater_than_equals<uint64_t>(
108
+ nvshmemi_device_state_d.proxy_channels_cst_ack, cst_issue,
109
+ NVSHMEMI_CALL_SITE_PROXY_ENFORCE_CONSISTENCY_AT_TARGET);
110
+ if (use_membar) {
111
+ __threadfence_system(); // XXX: prevents store to issue_d reordered to before load from
112
+ // cst_ack_d (breaks cst -> rma)
113
+ }
114
+ }
115
+
116
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void copy_to_channel(void *ptr,
117
+ uint32_t size) {
118
+ channel_bounce_buffer_t bounce;
119
+ uint64_t idx, tail_idx;
120
+ volatile uint64_t *channel_ptr;
121
+ char *src_ptr = (char *)ptr;
122
+ uint32_t size_with_flags;
123
+ uint32_t size_remaining;
124
+
125
+ /* idx is an every increasing counter. Since it is 64 bit integer, practically
126
+ it will not overflow */
127
+ size_with_flags = (size * 8) / 7;
128
+ if (size_with_flags % 8) {
129
+ size_with_flags += (8 - (size_with_flags % 8));
130
+ }
131
+ idx = atomicAdd((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_issue,
132
+ size_with_flags);
133
+ tail_idx = idx + (size_with_flags - 1);
134
+
135
+ // flow-control
136
+ check_channel_availability(tail_idx);
137
+
138
+ for (size_remaining = size; size_remaining > 7; idx += sizeof(uint64_t), size_remaining -= 7) {
139
+ channel_ptr = (volatile uint64_t *)((uint64_t)nvshmemi_device_state_d.proxy_channels_buf +
140
+ (idx & (CHANNEL_BUF_SIZE - 1)));
141
+ memcpy(&bounce.bytes[1], src_ptr, 7);
142
+ /* Note, the second to last bit being set denotes a continuation of the same request to the
143
+ * other side. */
144
+ bounce.bytes[0] =
145
+ (char)(!((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1) | 0x10);
146
+ *channel_ptr = bounce.whole_buffer;
147
+ src_ptr += 7;
148
+ }
149
+
150
+ channel_ptr = (volatile uint64_t *)((uint64_t)nvshmemi_device_state_d.proxy_channels_buf +
151
+ (idx & (CHANNEL_BUF_SIZE - 1)));
152
+ memcpy(&bounce.bytes[1], src_ptr, size_remaining);
153
+ bounce.bytes[0] = (char)!((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
154
+ *channel_ptr = bounce.whole_buffer;
155
+ }
156
+
157
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE __device__ void transfer_dma(
158
+ void *rptr, void *lptr, size_t bytes, int pe, int channel_op) {
159
+ uint64_t idx, tail_idx, *req;
160
+ int size = PROXY_DMA_REQ_BYTES;
161
+ int group_size = 1;
162
+ void *buf_ptr = nvshmemi_device_state_d.proxy_channels_buf;
163
+ void *base_ptr = nvshmemi_device_state_d.heap_base;
164
+ const uint64_t mask_lowest_byte = 0xFFFFFFFFFFFFFF00u;
165
+ const uint64_t mask_upper_7_bytes = 0x00000000000000FFu;
166
+
167
+ __threadfence();
168
+
169
+ /* idx is an every increasing counter. Since it is 64 bit integer, practically
170
+ it will not overflow */
171
+ idx = atomicAdd((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_issue, size);
172
+ tail_idx = idx + (size - 1);
173
+
174
+ // flow-control
175
+ check_channel_availability(tail_idx);
176
+
177
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
178
+ uint64_t curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
179
+ /* curr_flag is either 0 or 1. Starting at idx = 0 to idx =
180
+ * nvshmemi_device_state_d.proxy_channel_buf_size - 1, it will be 1, then for next
181
+ * nvshmemi_device_state_d.proxy_channel_buf_size idx values it will be 0, and so
182
+ * on.
183
+ */
184
+ uint64_t roffset = (uint64_t)((char *)rptr - (char *)base_ptr);
185
+ uint64_t laddr = (uint64_t)lptr;
186
+ uint64_t op = channel_op;
187
+ uint16_t pe_u16 = pe;
188
+ uint64_t size_u64 = bytes;
189
+
190
+ /* base_request_t
191
+ * 32 | 8 | 8 | 8 | 8
192
+ * roffset_high | roffset_low | op | group_size | flag */
193
+ *((volatile uint64_t *)req) =
194
+ (uint64_t)((roffset << 24) | (op << 16) | (group_size << 8) | curr_flag);
195
+
196
+ /* put_dma_request_0
197
+ * 56 | 8
198
+ * laddr_high | flag */
199
+ idx += CHANNEL_ENTRY_BYTES;
200
+ uint64_t laddr_high = laddr & mask_lowest_byte;
201
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
202
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
203
+ *((volatile uint64_t *)req) = laddr_high | curr_flag;
204
+
205
+ /* put_dma_request_1
206
+ * 32 | 16 | 8 | 8
207
+ * size_high | size_low | laddr_low | flag */
208
+ idx += CHANNEL_ENTRY_BYTES;
209
+ uint64_t laddr_low = laddr & mask_upper_7_bytes;
210
+ req = (uint64_t *)((uint8_t *)buf_ptr +
211
+ (idx & (nvshmemi_device_state_d.proxy_channel_buf_size - 1)));
212
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
213
+ *((volatile uint64_t *)req) = (uint64_t)(size_u64 << 16 | laddr_low << 8 | curr_flag);
214
+
215
+ /* put_dma_request_2
216
+ * 32 | 16 | 8 | 8
217
+ * resv2 | pe | resv1 | flag */
218
+ idx += CHANNEL_ENTRY_BYTES;
219
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
220
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
221
+ *((volatile uint64_t *)req) = (uint64_t)((pe_u16 << 16) | curr_flag);
222
+ }
223
+
224
+ /*XXX : Only no const version is used*/
225
+ template <nvshmemi_op_t channel_op>
226
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_rma(void *rptr,
227
+ void *lptr,
228
+ size_t bytes,
229
+ int pe) {
230
+ assert(0);
231
+ /*XXX:to be used for 1) NVSHMEMI_DEVICE_ALWAYS_INLINE 2) DMA with ack 3) DMA by staging in
232
+ * another buffer*/
233
+ }
234
+
235
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE void nvshmemi_proxy_rma_nbi(
236
+ void *rptr, void *lptr, size_t bytes, int pe, nvshmemi_op_t op) {
237
+ if (!bytes) return;
238
+ transfer_dma(rptr, lptr, bytes, pe, op);
239
+ }
240
+
241
+ template <typename T>
242
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE T nvshmemi_proxy_rma_g(void *source,
243
+ int pe) {
244
+ // check for CC >= 7.0 because the code depends on __match_all_sync
245
+ #if __CUDA_ARCH__ >= 700
246
+ constexpr unsigned int full_warp = 0xffffffffu;
247
+ const unsigned int amask = __activemask();
248
+ unsigned int laneId;
249
+ asm("mov.u32 %0, %%laneid;" : "=r"(laneId));
250
+ int pred_pe = 0;
251
+ int pred_contigous = 0;
252
+
253
+ // check if warp is coalesced, if all lanes put to the same PE and if buffer is contigous
254
+ if (full_warp == amask && full_warp == __match_all_sync(full_warp, pe, &pred_pe) &&
255
+ full_warp == __match_all_sync(full_warp,
256
+ reinterpret_cast<uintptr_t>(reinterpret_cast<char *>(source) -
257
+ (laneId * sizeof(T))),
258
+ &pred_contigous)) {
259
+ assert(pred_pe && pred_contigous);
260
+
261
+ g_elem_t *elem = nullptr;
262
+ int coalescing_buf_byte_offset = -1;
263
+ if (0 == laneId) {
264
+ uint64_t counter = atomicAdd(
265
+ (unsigned long long int *)nvshmemi_device_state_d.proxy_channel_g_buf_head_ptr, 1);
266
+ uint64_t idx = counter * sizeof(g_elem_t);
267
+ uint64_t idx_in_buf = idx & (nvshmemi_device_state_d.proxy_channel_g_buf_size - 1);
268
+ elem = (g_elem_t *)(nvshmemi_device_state_d.proxy_channel_g_buf + idx_in_buf);
269
+ coalescing_buf_byte_offset =
270
+ (idx_in_buf / sizeof(g_elem_t)) * NVSHMEMI_WARP_SIZE * sizeof(uint64_t);
271
+ // Using a g_elem_t as to for a coalescing buffer at the same index
272
+ uint64_t flag = (idx >> nvshmemi_device_state_d.proxy_channel_g_buf_log_size) * 2;
273
+
274
+ /* wait until element can be used */
275
+ nvshmemi_wait_until_greater_than_equals<uint64_t>((volatile uint64_t *)&(elem->flag),
276
+ flag, NVSHMEMI_CALL_SITE_G_WAIT_FLAG);
277
+ static_assert(sizeof(T) <= sizeof(uint64_t), "sizeof(T) exceeds sizeof(uint64_t)");
278
+ nvshmemi_proxy_rma_nbi(source,
279
+ (void *)(nvshmemi_device_state_d.proxy_channel_g_coalescing_buf +
280
+ coalescing_buf_byte_offset),
281
+ NVSHMEMI_WARP_SIZE * sizeof(T), pe, NVSHMEMI_OP_G);
282
+ nvshmemi_proxy_quiet(false);
283
+ }
284
+ coalescing_buf_byte_offset = __shfl_sync(amask, coalescing_buf_byte_offset, 0);
285
+ T *__restrict__ coalescing_buf = reinterpret_cast<T *>(
286
+ nvshmemi_device_state_d.proxy_channel_g_coalescing_buf + coalescing_buf_byte_offset);
287
+ T return_val = coalescing_buf[laneId];
288
+ __syncwarp(amask);
289
+ if (0 == laneId) {
290
+ __threadfence();
291
+ /* release the element for the next thread */
292
+ elem->flag += 2;
293
+ }
294
+
295
+ return return_val;
296
+ } else
297
+ #endif //__CUDA_ARCH__ >= 700
298
+ {
299
+ uint64_t counter = atomicAdd(
300
+ (unsigned long long int *)nvshmemi_device_state_d.proxy_channel_g_buf_head_ptr, 1);
301
+ uint64_t idx = counter * sizeof(g_elem_t);
302
+ uint64_t idx_in_buf = idx & (nvshmemi_device_state_d.proxy_channel_g_buf_size - 1);
303
+ g_elem_t *elem = (g_elem_t *)(nvshmemi_device_state_d.proxy_channel_g_buf + idx_in_buf);
304
+ uint64_t flag = (idx >> nvshmemi_device_state_d.proxy_channel_g_buf_log_size) * 2;
305
+
306
+ /* wait until element can be used */
307
+ nvshmemi_wait_until_greater_than_equals<uint64_t>((volatile uint64_t *)&(elem->flag), flag,
308
+ NVSHMEMI_CALL_SITE_G_WAIT_FLAG);
309
+
310
+ nvshmemi_proxy_rma_nbi(source, (void *)elem, sizeof(T), pe, NVSHMEMI_OP_G);
311
+ nvshmemi_proxy_quiet(false);
312
+
313
+ __threadfence();
314
+ T return_val = *(T *)(&(elem->data));
315
+ __threadfence();
316
+ /* release the element for the next thread */
317
+ elem->flag += 2;
318
+
319
+ return return_val;
320
+ }
321
+ }
322
+
323
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE __device__ void convert_val_to_uint64(
324
+ uint64_t *dest, void *value, size_t size) {
325
+ uint8_t byte_buffer_1;
326
+ uint16_t byte_buffer_2;
327
+ uint32_t byte_buffer_4;
328
+ uint64_t byte_buffer_8;
329
+
330
+ switch (size) {
331
+ case 1:
332
+ memcpy(&byte_buffer_1, value, size);
333
+ *dest = byte_buffer_1;
334
+ break;
335
+ case 2:
336
+ memcpy(&byte_buffer_2, value, size);
337
+ *dest = byte_buffer_2;
338
+ break;
339
+ case 4:
340
+ memcpy(&byte_buffer_4, value, size);
341
+ *dest = byte_buffer_4;
342
+ break;
343
+ case 8:
344
+ memcpy(&byte_buffer_8, value, size);
345
+ *dest = byte_buffer_8;
346
+ break;
347
+ default:
348
+ printf("Invalid size value provided to convert_val_to_uint64 in proxy_device.cu.\n");
349
+ }
350
+ }
351
+
352
+ template <typename T>
353
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_FORCE_INLINE __device__ void transfer_inline(
354
+ void *rptr, T value, int pe, nvshmemi_op_t optype) {
355
+ uint64_t idx, tail_idx, *req;
356
+ int size = PROXY_INLINE_REQ_BYTES;
357
+ int group_size = 1;
358
+ void *buf_ptr = nvshmemi_device_state_d.proxy_channels_buf;
359
+ void *base_ptr = nvshmemi_device_state_d.heap_base;
360
+
361
+ idx = atomicAdd((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_issue, size);
362
+ tail_idx = idx + (size - 1);
363
+
364
+ // flow-control
365
+ check_channel_availability(tail_idx);
366
+
367
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
368
+ uint64_t curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
369
+ uint64_t roffset = (uint64_t)((char *)rptr - (char *)base_ptr);
370
+ uint64_t op = optype;
371
+ uint16_t pe_u16 = pe;
372
+ uint64_t size_u64 = sizeof(T);
373
+
374
+ uint64_t lvalue_buffer = 0;
375
+ const uint64_t mask_4_bytes = 0x00000000ffffffff;
376
+
377
+ convert_val_to_uint64(&lvalue_buffer, &value, sizeof(T));
378
+
379
+ /* base_request_t
380
+ * 32 | 8 | 8 | 8 | 8
381
+ * roffset_high | roffset_low | op | group_size | flag */
382
+ *((volatile uint64_t *)req) =
383
+ (uint64_t)((roffset << 24) | (op << 16) | (group_size << 8) | curr_flag);
384
+
385
+ /* put_inline_request_0
386
+ * 32 | 16 | 8 | 8
387
+ * lvalue (low) | pe | resv | flag */
388
+ idx += CHANNEL_ENTRY_BYTES;
389
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
390
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
391
+ /* mask lower four bytes. */
392
+ const uint64_t lvalue_low = lvalue_buffer & mask_4_bytes;
393
+ *((volatile uint64_t *)req) = (lvalue_low << 32 | ((uint64_t)pe_u16 << 16) | curr_flag);
394
+
395
+ /* put_inline_request_1
396
+ * 32 | 16 | 8 | 8
397
+ * lvalue(high) | size | resv | flag */
398
+ idx += CHANNEL_ENTRY_BYTES;
399
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
400
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
401
+ const uint64_t lvalue_high = lvalue_buffer & ~mask_4_bytes;
402
+ *((volatile uint64_t *)req) = (lvalue_high | size_u64 << 16 | curr_flag);
403
+ }
404
+
405
+ template <typename T>
406
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_rma_p(void *rptr,
407
+ const T value,
408
+ int pe) {
409
+ transfer_inline<T>(rptr, value, pe, NVSHMEMI_OP_P);
410
+ }
411
+
412
+ template <typename T>
413
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void amo(
414
+ void *rptr, uint64_t g_buf_counter /* used only for fetch atomics */, T swap_add, T compare,
415
+ int pe, nvshmemi_amo_t amo_op) {
416
+ uint64_t idx, tail_idx, *req;
417
+ int size = PROXY_AMO_REQ_BYTES;
418
+ int group_size = 1;
419
+ void *buf_ptr = nvshmemi_device_state_d.proxy_channels_buf;
420
+ void *base_ptr = nvshmemi_device_state_d.heap_base;
421
+
422
+ idx = atomicAdd((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_issue, size);
423
+ tail_idx = idx + (size - 1);
424
+
425
+ // flow-control
426
+ check_channel_availability(tail_idx);
427
+
428
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
429
+ uint64_t curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
430
+ uint64_t roffset = (uint64_t)((char *)rptr - (char *)base_ptr);
431
+ uint64_t op = NVSHMEMI_OP_AMO;
432
+ uint64_t amo = amo_op;
433
+ uint16_t pe_u16 = pe;
434
+ uint64_t size_u64 = sizeof(T);
435
+ uint64_t swap_add_buffer;
436
+ uint64_t compare_buffer;
437
+ const uint64_t mask_1_byte = 0x00FFFFFFFFFFFFFF;
438
+ const uint64_t mask_4_bytes = 0x00000000FFFFFFFF;
439
+ const uint64_t mask_7_bytes = 0x00000000000000FF;
440
+
441
+ convert_val_to_uint64(&swap_add_buffer, &swap_add, sizeof(T));
442
+ convert_val_to_uint64(&compare_buffer, &compare, sizeof(T));
443
+
444
+ /* base_request_t
445
+ * 32 | 8 | 8 | 8 | 8
446
+ * roffset_high | roffset_low | op | group_size | flag */
447
+ *((volatile uint64_t *)req) =
448
+ (uint64_t)((roffset << 24) | (op << 16) | (group_size << 8) | curr_flag);
449
+
450
+ /* amo_request_0
451
+ * 32 | 16 | 8 | 8
452
+ * swap_add_low | pe | amo | flag */
453
+ idx += CHANNEL_ENTRY_BYTES;
454
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
455
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
456
+ const uint64_t swap_add_low = swap_add_buffer & mask_4_bytes;
457
+ *((volatile uint64_t *)req) =
458
+ (swap_add_low << 32 | ((uint64_t)pe_u16 << 16) | (amo << 8) | curr_flag);
459
+
460
+ /* amo_request_1
461
+ * 32 | 16 | 8 | 8
462
+ * swap_add_high | size | compare_low | flag */
463
+ idx += CHANNEL_ENTRY_BYTES;
464
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
465
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
466
+ const uint64_t swap_add_high = swap_add_buffer & ~mask_4_bytes;
467
+ const uint64_t compare_low = compare_buffer & mask_7_bytes;
468
+ *((volatile uint64_t *)req) = (swap_add_high | size_u64 << 16 | compare_low << 8 | curr_flag);
469
+
470
+ /* amo_request_2
471
+ * 32 | 16 | 8 | 8
472
+ * comapare_high | flag */
473
+ idx += CHANNEL_ENTRY_BYTES;
474
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
475
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
476
+ /* only mask the low byte for */
477
+ const uint64_t compare_high = compare_buffer & ~mask_7_bytes;
478
+ *((volatile uint64_t *)req) = (compare_high | curr_flag);
479
+
480
+ /* amo_request_3
481
+ * 32 | 16 | 8 | 8
482
+ * g_buf_counter_low | flag */
483
+ idx += CHANNEL_ENTRY_BYTES;
484
+ req = (uint64_t *)((uint8_t *)buf_ptr + (idx & (CHANNEL_BUF_SIZE - 1)));
485
+ curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
486
+ /* assumes g_buf_counter <= (1 << 56) */
487
+ const uint64_t g_buf_counter_low = g_buf_counter & mask_1_byte;
488
+ *((volatile uint64_t *)req) = (g_buf_counter_low << 8 | curr_flag);
489
+ }
490
+
491
+ template <typename T>
492
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_amo_nonfetch(
493
+ void *rptr, T swap_add, int pe, nvshmemi_amo_t op) {
494
+ amo<T>(rptr, 0 /* dummy value */, swap_add, 0, pe, op);
495
+ }
496
+
497
+ template <typename T>
498
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_amo_fetch(
499
+ void *rptr, void *lptr, T swap_add, T compare, int pe, nvshmemi_amo_t op) {
500
+ uint64_t counter = atomicAdd(
501
+ (unsigned long long int *)nvshmemi_device_state_d.proxy_channel_g_buf_head_ptr, 1);
502
+ uint64_t idx = counter * sizeof(g_elem_t);
503
+ uint64_t idx_in_buf = idx & (nvshmemi_device_state_d.proxy_channel_g_buf_size - 1);
504
+ g_elem_t *elem = (g_elem_t *)(nvshmemi_device_state_d.proxy_channel_g_buf + idx_in_buf);
505
+ uint64_t flag = (idx >> nvshmemi_device_state_d.proxy_channel_g_buf_log_size) * 2;
506
+ size_t atomic_size = sizeof(T);
507
+
508
+ /* wait until element can be used */
509
+ nvshmemi_wait_until_greater_than_equals<uint64_t>((volatile uint64_t *)&(elem->flag), flag,
510
+ NVSHMEMI_CALL_SITE_AMO_FETCH_WAIT_FLAG);
511
+ __threadfence();
512
+
513
+ amo<T>(rptr, counter, swap_add, compare, pe, op);
514
+
515
+ /* The IBDEVX transport doesn't rely on an active message from the receiver for atomics. */
516
+ if (nvshmemi_device_state_d.atomics_complete_on_quiet) {
517
+ nvshmemi_proxy_quiet(false);
518
+ elem->flag += 1;
519
+ /* MLNX NICs will typically return 8 byte atomics in host-endian and 4 byte atomics in
520
+ * big-enian. This behavior is controlled by flags read from the NIC at runtime.
521
+ */
522
+ if (atomic_size < nvshmemi_device_state_d.atomics_le_min_size) {
523
+ if (atomic_size == 8) {
524
+ NTOH64(&elem->data);
525
+ } else if (atomic_size == 4) {
526
+ NTOH32(&elem->data);
527
+ } else {
528
+ /* Our APIs currently only support 4 and 8-byte atomics. Any other size is a fatal
529
+ * error. */
530
+ assert(false);
531
+ }
532
+ }
533
+ } else {
534
+ nvshmemi_wait_until_greater_than_equals<uint64_t>(
535
+ (volatile uint64_t *)&(elem->flag), flag + 1, NVSHMEMI_CALL_SITE_AMO_FETCH_WAIT_DATA);
536
+ }
537
+ __threadfence();
538
+ T return_val = *(T *)(&(elem->data));
539
+ __threadfence();
540
+
541
+ /* release the element for the next thread */
542
+ elem->flag += 1;
543
+
544
+ *((T *)lptr) = return_val;
545
+ }
546
+
547
+ NVSHMEMI_STATIC __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_proxy_fence() {
548
+ // making it a no-op as it is a no-op for IB RC, the only transport
549
+ uint64_t idx, tail_idx, *req;
550
+ int size = sizeof(uint64_t);
551
+
552
+ idx = atomicAdd((unsigned long long int *)nvshmemi_device_state_d.proxy_channels_issue, size);
553
+ tail_idx = idx + (size - 1);
554
+
555
+ // flow-control
556
+ check_channel_availability(tail_idx);
557
+
558
+ req = (uint64_t *)((uint64_t)nvshmemi_device_state_d.proxy_channels_buf +
559
+ (idx & (nvshmemi_device_state_d.proxy_channel_buf_size - 1)));
560
+ uint64_t curr_flag = !((idx >> nvshmemi_device_state_d.proxy_channel_buf_logsize) & 1);
561
+ uint64_t op = NVSHMEMI_OP_FENCE;
562
+
563
+ /* base_request_t
564
+ * 32 | 8 | 8 | 8 | 8
565
+ * resv | resv | op | resv | flag */
566
+ *((volatile uint64_t *)req) = (uint64_t)((op << 16) | curr_flag);
567
+
568
+ return;
569
+ }
570
+
571
+ #endif /* __CUDA_ARCH__ */
572
+ #endif /* PROXY_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/transfer_device.cuh ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef TRANSFER_DEVICE_CUH
8
+ #define TRANSFER_DEVICE_CUH
9
+
10
+ #include <cuda_runtime.h>
11
+ #include "non_abi/nvshmem_build_options.h"
12
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
13
+ #include "device_host/nvshmem_common.cuh"
14
+ #include "device/nvshmem_device_macros.h"
15
+ #include "non_abi/device/pt-to-pt/proxy_device.cuh"
16
+
17
+ #ifdef NVSHMEM_IBGDA_SUPPORT
18
+ #include "non_abi/device/pt-to-pt/ibgda_device.cuh"
19
+ #endif
20
+
21
+ #if defined __clang_llvm_bitcode_lib__
22
+ #define NVSHMEMI_TRANSFER_INLINE \
23
+ __attribute__((noinline, section(".text.compute"), not_tail_called))
24
+ #define NVSHMEMI_TRANSFER_STATIC
25
+ #elif defined NVSHMEM_ENABLE_ALL_DEVICE_INLINING
26
+ #define NVSHMEMI_TRANSFER_INLINE inline
27
+ #define NVSHMEMI_TRANSFER_STATIC static
28
+ #else
29
+ #define NVSHMEMI_TRANSFER_INLINE __noinline__
30
+ #define NVSHMEMI_TRANSFER_STATIC
31
+ #endif
32
+
33
+ #define TRANSFER_REPT_FOR_STANDARD_RMA_TYPES(FN_TEMPLATE) \
34
+ FN_TEMPLATE(char) \
35
+ FN_TEMPLATE(unsigned char) \
36
+ FN_TEMPLATE(short) \
37
+ FN_TEMPLATE(unsigned short) \
38
+ FN_TEMPLATE(int) \
39
+ FN_TEMPLATE(unsigned int) \
40
+ FN_TEMPLATE(long) \
41
+ FN_TEMPLATE(unsigned long) \
42
+ FN_TEMPLATE(long long) \
43
+ FN_TEMPLATE(unsigned long long) \
44
+ FN_TEMPLATE(float) \
45
+ FN_TEMPLATE(double)
46
+
47
+ #define TRANSFER_REPT_FOR_STANDARD_AMO_TYPES(FN_TEMPLATE) \
48
+ FN_TEMPLATE(short) \
49
+ FN_TEMPLATE(unsigned short) \
50
+ FN_TEMPLATE(int) \
51
+ FN_TEMPLATE(unsigned int) \
52
+ FN_TEMPLATE(long) \
53
+ FN_TEMPLATE(unsigned long) \
54
+ FN_TEMPLATE(long long) \
55
+ FN_TEMPLATE(unsigned long long)
56
+
57
+ #define TRANSFER_REPT_FOR_EXTENDED_AMO_TYPES(FN_TEMPLATE) \
58
+ FN_TEMPLATE(float) \
59
+ FN_TEMPLATE(double)
60
+
61
+ #define TRANSFER_REPT_FOR_ALL_SCOPES(FN_TEMPLATE) \
62
+ FN_TEMPLATE(NVSHMEMI_THREADGROUP_THREAD) \
63
+ FN_TEMPLATE(NVSHMEMI_THREADGROUP_WARP) \
64
+ FN_TEMPLATE(NVSHMEMI_THREADGROUP_BLOCK)
65
+
66
+ #ifdef __CUDA_ARCH__
67
+ __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_syncapi_update_mem() {
68
+ __threadfence(); /* 1. Ensures consitency op is not called before the prior test/wait condition
69
+ has been met
70
+ 2. Needed to prevent reorder of instructions after sync api (when the
71
+ following if condition is false) */
72
+ if (nvshmemi_device_state_d.job_connectivity > NVSHMEMI_JOB_GPU_PROXY) {
73
+ nvshmemi_proxy_enforce_consistency_at_target(true);
74
+ }
75
+ }
76
+
77
+ template <typename T>
78
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_rma_p(
79
+ void *rptr, const T value, int pe) {
80
+ #ifdef NVSHMEM_IBGDA_SUPPORT
81
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
82
+ nvshmemi_ibgda_rma_p<T>(rptr, value, pe);
83
+ } else
84
+ #endif
85
+ {
86
+ nvshmemi_proxy_rma_p<T>(rptr, value, pe);
87
+ }
88
+ }
89
+
90
+ #define TRANSFER_DECL_RMA_P(Type) \
91
+ template __device__ void nvshmemi_transfer_rma_p<Type>(void *rptr, const Type value, int pe);
92
+
93
+ TRANSFER_REPT_FOR_STANDARD_RMA_TYPES(TRANSFER_DECL_RMA_P)
94
+
95
+ template <typename T>
96
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE T nvshmemi_transfer_rma_g(void *rptr,
97
+ int pe) {
98
+ #ifdef NVSHMEM_IBGDA_SUPPORT
99
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
100
+ return nvshmemi_ibgda_rma_g<T>(rptr, pe);
101
+ } else
102
+ #endif
103
+ {
104
+ return nvshmemi_proxy_rma_g<T>(rptr, pe);
105
+ }
106
+ }
107
+
108
+ #define TRANSFER_DECL_RMA_G(Type) \
109
+ template __device__ Type nvshmemi_transfer_rma_g<Type>(void *rptr, int pe);
110
+
111
+ TRANSFER_REPT_FOR_STANDARD_RMA_TYPES(TRANSFER_DECL_RMA_G)
112
+
113
+ template <threadgroup_t SCOPE, nvshmemi_op_t channel_op>
114
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_rma(
115
+ void *rptr, void *lptr, size_t bytes, int pe) {
116
+ #ifdef NVSHMEM_IBGDA_SUPPORT
117
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
118
+ nvshmemi_ibgda_rma<SCOPE, channel_op>(rptr, lptr, bytes, pe);
119
+ } else
120
+ #endif
121
+ {
122
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
123
+ if (!myIdx) {
124
+ nvshmemi_proxy_rma_nbi(rptr, lptr, bytes, pe, channel_op);
125
+ nvshmemi_proxy_quiet(false);
126
+ if (SCOPE == nvshmemi_threadgroup_thread)
127
+ __threadfence_block(); /* to prevent reuse of src buffer before quiet completion;
128
+ for warp/block scope, following sync op will accomplish that */
129
+ }
130
+ }
131
+ }
132
+
133
+ #define TRANSFER_DECL_RMA(SCOPE) \
134
+ template __device__ void nvshmemi_transfer_rma<SCOPE, NVSHMEMI_OP_PUT>(void *rptr, void *lptr, \
135
+ size_t bytes, int pe); \
136
+ template __device__ void nvshmemi_transfer_rma<SCOPE, NVSHMEMI_OP_GET>(void *rptr, void *lptr, \
137
+ size_t bytes, int pe);
138
+
139
+ TRANSFER_REPT_FOR_ALL_SCOPES(TRANSFER_DECL_RMA)
140
+
141
+ template <threadgroup_t SCOPE>
142
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_put_signal(
143
+ void *rptr, void *lptr, size_t bytes, void *sig_addr, uint64_t signal, nvshmemi_amo_t sig_op,
144
+ int pe, bool is_nbi) {
145
+ #ifdef NVSHMEM_IBGDA_SUPPORT
146
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
147
+ nvshmemi_ibgda_put_signal<SCOPE>(rptr, lptr, bytes, sig_addr, signal, sig_op, pe, is_nbi);
148
+ } else
149
+ #endif
150
+ {
151
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
152
+ if (!myIdx) {
153
+ nvshmemi_proxy_rma_nbi(rptr, lptr, bytes, pe, NVSHMEMI_OP_PUT);
154
+ nvshmemi_proxy_fence();
155
+ nvshmemi_proxy_amo_nonfetch<uint64_t>(sig_addr, signal, pe, sig_op);
156
+ if (is_nbi == 0) {
157
+ nvshmemi_proxy_quiet(false);
158
+ if (SCOPE == nvshmemi_threadgroup_thread)
159
+ __threadfence_block(); /* to prevent reuse of src buffer before quiet completion
160
+ for warp/block scope, following sync op will accomplish that
161
+ */
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ #define TRANSFER_DECL_PUT_SIGNAL(SCOPE) \
168
+ template __device__ void nvshmemi_transfer_put_signal<SCOPE>( \
169
+ void *rptr, void *lptr, size_t bytes, void *sig_rptr, uint64_t signal, \
170
+ nvshmemi_amo_t sig_op, int pe, bool is_nbi);
171
+
172
+ TRANSFER_REPT_FOR_ALL_SCOPES(TRANSFER_DECL_PUT_SIGNAL)
173
+
174
+ template <threadgroup_t SCOPE, nvshmemi_op_t channel_op>
175
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_rma_nbi(
176
+ void *rptr, void *lptr, size_t bytes, int pe) {
177
+ #ifdef NVSHMEM_IBGDA_SUPPORT
178
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
179
+ nvshmemi_ibgda_rma_nbi<SCOPE, channel_op>(rptr, lptr, bytes, pe);
180
+ } else
181
+ #endif
182
+ {
183
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
184
+ if (!myIdx) nvshmemi_proxy_rma_nbi(rptr, lptr, bytes, pe, channel_op);
185
+ }
186
+ }
187
+
188
+ #define TRANSFER_DECL_RMA_NBI(SCOPE) \
189
+ template __device__ void nvshmemi_transfer_rma_nbi<SCOPE, NVSHMEMI_OP_PUT>( \
190
+ void *rptr, void *lptr, size_t bytes, int pe); \
191
+ template __device__ void nvshmemi_transfer_rma_nbi<SCOPE, NVSHMEMI_OP_GET>( \
192
+ void *rptr, void *lptr, size_t bytes, int pe);
193
+
194
+ TRANSFER_REPT_FOR_ALL_SCOPES(TRANSFER_DECL_RMA_NBI)
195
+
196
+ template <typename T>
197
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE T
198
+ nvshmemi_transfer_amo_fetch(void *rptr, T value, T compare, int pe, nvshmemi_amo_t op) {
199
+ #ifdef NVSHMEM_IBGDA_SUPPORT
200
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
201
+ return nvshmemi_ibgda_amo_fetch<T>(rptr, value, compare, pe, op);
202
+ } else
203
+ #endif
204
+ {
205
+ T retval;
206
+ nvshmemi_proxy_amo_fetch<T>(rptr, (void *)&retval, value, compare, pe, op);
207
+ return retval;
208
+ }
209
+ }
210
+
211
+ #define TRANSFER_DECL_AMO_FETCH(Type) \
212
+ template __device__ Type nvshmemi_transfer_amo_fetch<Type>( \
213
+ void *rptr, const Type value, const Type compare, int pe, nvshmemi_amo_t op);
214
+
215
+ TRANSFER_REPT_FOR_STANDARD_AMO_TYPES(TRANSFER_DECL_AMO_FETCH);
216
+ TRANSFER_REPT_FOR_EXTENDED_AMO_TYPES(TRANSFER_DECL_AMO_FETCH);
217
+
218
+ template <typename T>
219
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_amo_nonfetch(
220
+ void *rptr, T value, int pe, nvshmemi_amo_t op) {
221
+ #ifdef NVSHMEM_IBGDA_SUPPORT
222
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
223
+ nvshmemi_ibgda_amo_nonfetch<T>(rptr, value, pe, op);
224
+ } else
225
+ #endif
226
+ {
227
+ nvshmemi_proxy_amo_nonfetch<T>(rptr, value, pe, op);
228
+ }
229
+ }
230
+
231
+ #define TRANSFER_DECL_AMO_NONFETCH(Type) \
232
+ template __device__ void nvshmemi_transfer_amo_nonfetch<Type>(void *rptr, const Type value, \
233
+ int pe, nvshmemi_amo_t op);
234
+
235
+ TRANSFER_REPT_FOR_STANDARD_AMO_TYPES(TRANSFER_DECL_AMO_NONFETCH);
236
+ TRANSFER_REPT_FOR_EXTENDED_AMO_TYPES(TRANSFER_DECL_AMO_NONFETCH);
237
+
238
+ template <threadgroup_t SCOPE>
239
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_quiet(
240
+ bool use_membar) {
241
+ // quiet_on_stream also shares this code path.
242
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
243
+ #ifdef NVSHMEM_IBGDA_SUPPORT
244
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
245
+ nvshmemi_ibgda_quiet<SCOPE>();
246
+ if (use_membar) {
247
+ if (!myIdx) {
248
+ __threadfence_system();
249
+ }
250
+ }
251
+ } else
252
+ #endif
253
+ if (nvshmemi_device_state_d.proxy == NVSHMEMI_PROXY_FULL) {
254
+ if (!myIdx) {
255
+ nvshmemi_proxy_quiet(use_membar);
256
+ }
257
+ }
258
+ nvshmemi_threadgroup_sync<SCOPE>();
259
+ }
260
+
261
+ #define TRANSFER_DECL_QUIET(SCOPE) \
262
+ template __device__ void nvshmemi_transfer_quiet<SCOPE>(bool use_membar);
263
+
264
+ TRANSFER_REPT_FOR_ALL_SCOPES(TRANSFER_DECL_QUIET);
265
+ #undef TRANSFER_DECL_QUIET
266
+
267
+ template <threadgroup_t SCOPE>
268
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void nvshmemi_transfer_fence() {
269
+ #ifdef NVSHMEM_IBGDA_SUPPORT
270
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
271
+ nvshmemi_ibgda_fence<SCOPE>();
272
+ } else
273
+ #endif
274
+ if ((nvshmemi_device_state_d.proxy == NVSHMEMI_PROXY_FULL) &&
275
+ !nvshmemi_device_state_d.proxy_ops_are_ordered) {
276
+ int myIdx = nvshmemi_thread_id_in_threadgroup<SCOPE>();
277
+ if (!myIdx) {
278
+ nvshmemi_proxy_fence();
279
+ }
280
+ }
281
+ nvshmemi_threadgroup_sync<SCOPE>();
282
+ }
283
+
284
+ #define TRANSFER_DECL_FENCE(SCOPE) template __device__ void nvshmemi_transfer_fence<SCOPE>();
285
+
286
+ TRANSFER_REPT_FOR_ALL_SCOPES(TRANSFER_DECL_FENCE);
287
+ #undef TRANSFER_DECL_FENCE
288
+
289
+ NVSHMEMI_TRANSFER_STATIC __device__ NVSHMEMI_TRANSFER_INLINE void
290
+ nvshmemi_transfer_enforce_consistency_at_target(bool use_membar) {
291
+ #ifdef NVSHMEM_IBGDA_SUPPORT
292
+ if (nvshmemi_device_state_d.ibgda_is_initialized) {
293
+ nvshmemi_ibgda_enforce_consistency_at_target(use_membar);
294
+ } else
295
+ #endif
296
+ {
297
+ nvshmemi_proxy_enforce_consistency_at_target(use_membar);
298
+ }
299
+ }
300
+ #endif /* __CUDA_ARCH__ */
301
+
302
+ #endif /* TRANSFER_DEVICE_CUH */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/pt-to-pt/utils_device.h ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef _COMM_DEVICE_UTILS_H
8
+ #define _COMM_DEVICE_UTILS_H
9
+
10
+ #if !defined __CUDACC_RTC__
11
+ #include <stdint.h>
12
+ #else
13
+ #include "cuda/std/cstdint"
14
+ #endif
15
+
16
+ #include <cuda_runtime.h>
17
+
18
+ #if defined __CUDACC__
19
+ #define NVSHMEMI_COMM_DEVICE_UTILS_USE_PTX
20
+ #endif
21
+ #define NTOH64(x) \
22
+ *x = ((*(x)&0xFF00000000000000) >> 56 | (*(x)&0x00FF000000000000) >> 40 | \
23
+ (*(x)&0x0000FF0000000000) >> 24 | (*(x)&0x000000FF00000000) >> 8 | \
24
+ (*(x)&0x00000000FF000000) << 8 | (*(x)&0x0000000000FF0000) << 24 | \
25
+ (*(x)&0x000000000000FF00) << 40 | (*(x)&0x00000000000000FF) << 56)
26
+
27
+ #define NTOH32(x) \
28
+ *x = ((*(x)&0xFF000000) >> 24 | (*(x)&0x00FF0000) >> 8 | (*(x)&0x0000FF00) << 8 | \
29
+ (*(x)&0x000000FF) << 24)
30
+
31
+ #ifdef NVSHMEMI_COMM_DEVICE_UTILS_USE_PTX
32
+
33
+ #if defined __CUDACC__
34
+
35
+ __device__ static inline uint64_t BSWAP64(uint64_t x) {
36
+ uint64_t ret;
37
+ asm volatile(
38
+ "{\n\t"
39
+ ".reg .b32 mask;\n\t"
40
+ ".reg .b32 ign;\n\t"
41
+ ".reg .b32 lo;\n\t"
42
+ ".reg .b32 hi;\n\t"
43
+ ".reg .b32 new_lo;\n\t"
44
+ ".reg .b32 new_hi;\n\t"
45
+ "mov.b32 mask, 0x0123;\n\t"
46
+ "mov.b64 {lo,hi}, %1;\n\t"
47
+ "prmt.b32 new_hi, lo, ign, mask;\n\t"
48
+ "prmt.b32 new_lo, hi, ign, mask;\n\t"
49
+ "mov.b64 %0, {new_lo,new_hi};\n\t"
50
+ "}"
51
+ : "=l"(ret)
52
+ : "l"(x));
53
+ return ret;
54
+ }
55
+
56
+ __device__ static inline uint32_t BSWAP32(uint32_t x) {
57
+ uint32_t ret;
58
+ asm volatile(
59
+ "{\n\t"
60
+ ".reg .b32 mask;\n\t"
61
+ ".reg .b32 ign;\n\t"
62
+ "mov.b32 mask, 0x0123;\n\t"
63
+ "prmt.b32 %0, %1, ign, mask;\n\t"
64
+ "}"
65
+ : "=r"(ret)
66
+ : "r"(x));
67
+ return ret;
68
+ }
69
+
70
+ __device__ static inline uint16_t BSWAP16(uint16_t x) {
71
+ uint16_t ret;
72
+
73
+ uint32_t a = (uint32_t)x;
74
+ uint32_t d;
75
+ asm volatile(
76
+ "{\n\t"
77
+ ".reg .b32 mask;\n\t"
78
+ ".reg .b32 ign;\n\t"
79
+ "mov.b32 mask, 0x4401;\n\t"
80
+ "mov.b32 ign, 0x0;\n\t"
81
+ "prmt.b32 %0, %1, ign, mask;\n\t"
82
+ "}"
83
+ : "=r"(d)
84
+ : "r"(a));
85
+ ret = (uint16_t)d;
86
+ return ret;
87
+ }
88
+
89
+ #endif /*! __CUDACC__ */
90
+
91
+ #else /* NVSHMEMI_COMM_DEVICE_UTILS_USE_PTX */
92
+
93
+ #define BSWAP64(x) \
94
+ ((((x)&0xff00000000000000ull) >> 56) | (((x)&0x00ff000000000000ull) >> 40) | \
95
+ (((x)&0x0000ff0000000000ull) >> 24) | (((x)&0x000000ff00000000ull) >> 8) | \
96
+ (((x)&0x00000000ff000000ull) << 8) | (((x)&0x0000000000ff0000ull) << 24) | \
97
+ (((x)&0x000000000000ff00ull) << 40) | (((x)&0x00000000000000ffull) << 56))
98
+
99
+ #define BSWAP32(x) \
100
+ ((((x)&0xff000000) >> 24) | (((x)&0x00ff0000) >> 8) | (((x)&0x0000ff00) << 8) | \
101
+ (((x)&0x000000ff) << 24))
102
+
103
+ #define BSWAP16(x) ((((x)&0xff00) >> 8) | (((x)&0x00ff) << 8))
104
+
105
+ #endif /* NVSHMEMI_COMM_DEVICE_UTILS_USE_PTX */
106
+
107
+ #define HTOBE64(x) BSWAP64(x)
108
+ #define HTOBE32(x) BSWAP32(x)
109
+ #define HTOBE16(x) BSWAP16(x)
110
+
111
+ #endif /* _COMM_DEVICE_UTILS_H */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/team/nvshmemi_team_defines.cuh ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef _NVSHMEMI_TEAM_DEFINES_CUH_
2
+ #define _NVSHMEMI_TEAM_DEFINES_CUH_
3
+
4
+ #include "device_host/nvshmem_common.cuh"
5
+ #include <cuda_runtime.h>
6
+ #if !defined __CUDACC_RTC__
7
+ #include <assert.h>
8
+ #else
9
+ #include <cuda/std/cassert>
10
+ #endif
11
+
12
+ #ifdef __CUDA_ARCH__
13
+
14
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE int nvshmemi_team_my_pe(
15
+ nvshmem_team_t team) {
16
+ if (team == NVSHMEM_TEAM_INVALID)
17
+ return -1;
18
+ else if (team == NVSHMEM_TEAM_WORLD)
19
+ return nvshmemi_device_state_d.mype;
20
+ else if (team == NVSHMEMX_TEAM_NODE)
21
+ return nvshmemi_device_state_d.node_mype;
22
+ else
23
+ return nvshmemi_device_state_d.team_pool[team]->my_pe;
24
+ }
25
+
26
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE int nvshmemi_team_n_pes(nvshmem_team_t team) {
27
+ if (team == NVSHMEM_TEAM_INVALID)
28
+ return -1;
29
+ else if (team == NVSHMEM_TEAM_WORLD)
30
+ return nvshmemi_device_state_d.npes;
31
+ else if (team == NVSHMEMX_TEAM_NODE)
32
+ return nvshmemi_device_state_d.node_npes;
33
+ else
34
+ return nvshmemi_device_state_d.team_pool[team]->size;
35
+ }
36
+
37
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE __device__ size_t get_fcollect_psync_len_per_team() {
38
+ size_t fcollect_ll_threshold =
39
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll_threshold;
40
+ size_t fcollect_sync_size =
41
+ (2 * 2 * nvshmemi_device_state_d.npes * fcollect_ll_threshold) / sizeof(long);
42
+
43
+ return fcollect_sync_size;
44
+ }
45
+
46
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE __device__ size_t
47
+ get_fcollect_ll128_psync_len_per_team() {
48
+ size_t fcollect_ll128_threshold =
49
+ nvshmemi_device_state_d.gpu_coll_env_params_var.fcollect_ll128_threshold;
50
+ size_t fcollect_ll128_sync_size =
51
+ NVSHMEMI_FCOLLECT_LL128_CALC_PSYNC_SIZE(fcollect_ll128_threshold, char);
52
+
53
+ /* scale for npes and two separate psyncs */
54
+ fcollect_ll128_sync_size =
55
+ fcollect_ll128_sync_size * 2 * nvshmemi_device_state_d.npes / sizeof(long);
56
+
57
+ return fcollect_ll128_sync_size;
58
+ }
59
+
60
+ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE __device__ size_t get_psync_len_per_team() {
61
+ size_t fcollect_sync_size = get_fcollect_psync_len_per_team();
62
+ size_t fcollect_ll128_sync_size = get_fcollect_ll128_psync_len_per_team();
63
+ /* sync: Two buffers are used - one for sync/barrier collective ops, the second one during team
64
+ split operation reduce: Two pWrk's are used alternatively across consecutive reduce calls,
65
+ this is to avoid having to put a barrier in between bcast: The buffer is split to do multiple
66
+ consecutive broadcast, when all buffers are used, a barrier is called and then again we begin
67
+ from the start of the buffer fcollect: Two sets of buffer are used to alternate between -
68
+ same way as in reduce. The other fator of 2 is because when using LL double the space is
69
+ needed to fuse flag with data */
70
+
71
+ return (2 * NVSHMEMI_SYNC_SIZE +
72
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size / sizeof(long) +
73
+ NVSHMEMI_BCAST_SYNC_SIZE + fcollect_sync_size + 2 * NVSHMEMI_ALLTOALL_SYNC_SIZE +
74
+ fcollect_ll128_sync_size);
75
+ }
76
+
77
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE int
78
+ nvshmemi_team_translate_pe_to_team_world_wrap(nvshmemi_team_t *src_team, int src_pe) {
79
+ return src_team->pe_mapping[src_pe % src_team->size];
80
+ }
81
+
82
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE int
83
+ nvshmemi_team_translate_pe_from_team_world(nvshmemi_team_t *dest_team, int src_pe) {
84
+ return dest_team->pe_mapping[dest_team->size + src_pe];
85
+ }
86
+
87
+ __device__ NVSHMEMI_STATIC NVSHMEMI_DEVICE_ALWAYS_INLINE bool nvshmemi_team_is_identical(
88
+ nvshmemi_team_t *t1, nvshmemi_team_t *t2) {
89
+ if (t1->start != t2->start || t1->size != t2->size) {
90
+ return false;
91
+ }
92
+
93
+ /* shortcut for teams with linear stride */
94
+ if (t1->stride > 0 && t2->stride == t1->stride) {
95
+ return true;
96
+ }
97
+
98
+ for (int i = 0; i < t1->size; i++) {
99
+ if (t1->pe_mapping[i] != t2->pe_mapping[i]) {
100
+ return false;
101
+ }
102
+ }
103
+
104
+ return true;
105
+ }
106
+
107
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE int nvshmemi_team_translate_pe(nvshmem_team_t src_team,
108
+ int src_pe,
109
+ nvshmem_team_t dest_team) {
110
+ if (src_team == NVSHMEM_TEAM_INVALID || dest_team == NVSHMEM_TEAM_INVALID) return -1;
111
+ nvshmemi_team_t *src_teami, *dest_teami;
112
+
113
+ src_teami = nvshmemi_device_state_d.team_pool[src_team];
114
+ dest_teami = nvshmemi_device_state_d.team_pool[dest_team];
115
+ int src_pe_world, dest_pe = -1;
116
+
117
+ if (src_pe > src_teami->size) return -1;
118
+
119
+ src_pe_world = src_teami->pe_mapping[src_pe];
120
+ assert(src_pe_world >= src_teami->start && src_pe_world < nvshmemi_device_state_d.npes);
121
+ dest_pe = dest_teami->pe_mapping[dest_teami->size + src_pe_world];
122
+
123
+ return dest_pe;
124
+ }
125
+
126
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE long *nvshmemi_team_get_psync(nvshmemi_team_t *team,
127
+ nvshmemi_team_op_t op) {
128
+ long *team_psync;
129
+ size_t psync_fcollect_len;
130
+ psync_fcollect_len = get_fcollect_psync_len_per_team();
131
+ team_psync = &nvshmemi_device_state_d.psync_pool[team->team_idx * get_psync_len_per_team()];
132
+ switch (op) {
133
+ case SYNC:
134
+ return team_psync;
135
+ case REDUCE:
136
+ return &team_psync
137
+ [2 * NVSHMEMI_SYNC_SIZE +
138
+ (((nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size / 2) /
139
+ sizeof(long)) *
140
+ (team->rdxn_count % 2))];
141
+ case BCAST:
142
+ return &team_psync[2 * NVSHMEMI_SYNC_SIZE +
143
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size /
144
+ sizeof(long)];
145
+ case FCOLLECT:
146
+ return &team_psync[2 * NVSHMEMI_SYNC_SIZE +
147
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size /
148
+ sizeof(long) +
149
+ NVSHMEMI_BCAST_SYNC_SIZE];
150
+ case ALLTOALL:
151
+ return &team_psync[2 * NVSHMEMI_SYNC_SIZE +
152
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size /
153
+ sizeof(long) +
154
+ NVSHMEMI_BCAST_SYNC_SIZE + psync_fcollect_len +
155
+ (NVSHMEMI_ALLTOALL_SYNC_SIZE * (team->alltoall_count % 2))];
156
+ case FCOLLECT_128:
157
+ return &team_psync[2 * NVSHMEMI_SYNC_SIZE +
158
+ nvshmemi_device_state_d.gpu_coll_env_params_var.reduce_scratch_size /
159
+ sizeof(long) +
160
+ NVSHMEMI_BCAST_SYNC_SIZE + psync_fcollect_len +
161
+ 2 * NVSHMEMI_ALLTOALL_SYNC_SIZE];
162
+ default:
163
+ printf("Incorrect argument to nvshmemi_team_get_psync\n");
164
+ return NULL;
165
+ }
166
+ }
167
+
168
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE long *nvshmemi_team_get_sync_counter(
169
+ nvshmemi_team_t *team) {
170
+ return &nvshmemi_device_state_d.sync_counter[2 * team->team_idx];
171
+ }
172
+ #endif
173
+
174
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+ #ifndef _NVSHMEM_COMMON_DEVICE_DEFINES_CUH_
7
+ #define _NVSHMEM_COMMON_DEVICE_DEFINES_CUH_
8
+ #include <cuda_runtime.h>
9
+ #include "device_host/nvshmem_common.cuh"
10
+
11
+ #if defined(__CUDACC_RDC__) && !defined(__NVSHMEM_NUMBA_SUPPORT__)
12
+ #define EXTERN_CONSTANT extern __constant__
13
+ #elif defined(__clang__)
14
+ #define EXTERN_CONSTANT extern __constant__ __attribute__((address_space(4)))
15
+ #else
16
+ #define EXTERN_CONSTANT static __constant__
17
+ #endif
18
+ EXTERN_CONSTANT nvshmemi_device_host_state_t nvshmemi_device_state_d;
19
+ #undef EXTERN_CONSTANT
20
+
21
+ #ifdef __NVSHMEM_NUMBA_SUPPORT__
22
+ static __constant__ nvshmemi_version_t nvshmemi_device_lib_version_d = {
23
+ NVSHMEM_VENDOR_MAJOR_VERSION, NVSHMEM_VENDOR_MINOR_VERSION, NVSHMEM_VENDOR_PATCH_VERSION};
24
+ #endif
25
+
26
+ typedef enum {
27
+ nvshmemi_threadgroup_thread = 0,
28
+ NVSHMEMI_THREADGROUP_THREAD = 0,
29
+ nvshmemi_threadgroup_warp = 1,
30
+ NVSHMEMI_THREADGROUP_WARP = 1,
31
+ nvshmemi_threadgroup_warpgroup = 2,
32
+ NVSHMEMI_THREADGROUP_WARPGROUP = 2,
33
+ nvshmemi_threadgroup_block = 3,
34
+ NVSHMEMI_THREADGROUP_BLOCK = 3
35
+ } threadgroup_t;
36
+
37
+ #ifdef __CUDA_ARCH__
38
+
39
+ template <threadgroup_t scope>
40
+ __device__ __forceinline__ int nvshmemi_thread_id_in_threadgroup() {
41
+ switch (scope) {
42
+ case NVSHMEMI_THREADGROUP_THREAD:
43
+ return 0;
44
+ case NVSHMEMI_THREADGROUP_WARP:
45
+ int myIdx;
46
+ asm volatile("mov.u32 %0, %%laneid;" : "=r"(myIdx));
47
+ return myIdx;
48
+ case NVSHMEMI_THREADGROUP_WARPGROUP:
49
+ return (
50
+ (threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.x * blockDim.y) %
51
+ (4 * warpSize));
52
+ case NVSHMEMI_THREADGROUP_BLOCK:
53
+ return (threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.x * blockDim.y);
54
+ default:
55
+ printf("unrecognized threadscope passed\n");
56
+ assert(0);
57
+ return -1;
58
+ }
59
+ }
60
+
61
+ template <threadgroup_t scope>
62
+ __device__ inline int nvshmemi_threadgroup_size() {
63
+ switch (scope) {
64
+ case NVSHMEMI_THREADGROUP_THREAD:
65
+ return 1;
66
+ case NVSHMEMI_THREADGROUP_WARP:
67
+ return ((blockDim.x * blockDim.y * blockDim.z) < warpSize)
68
+ ? (blockDim.x * blockDim.y * blockDim.z)
69
+ : warpSize;
70
+ case NVSHMEMI_THREADGROUP_WARPGROUP:
71
+ // warpgroup = 4 warps
72
+ return ((blockDim.x * blockDim.y * blockDim.z) < (4 * warpSize))
73
+ ? (blockDim.x * blockDim.y * blockDim.z)
74
+ : (4 * warpSize);
75
+ case NVSHMEMI_THREADGROUP_BLOCK:
76
+ return (blockDim.x * blockDim.y * blockDim.z);
77
+ default:
78
+ printf("unrecognized threadscope passed\n");
79
+ assert(0);
80
+ return -1;
81
+ }
82
+ }
83
+
84
+ template <threadgroup_t scope>
85
+ __device__ inline void nvshmemi_threadgroup_sync() {
86
+ uint32_t tid, barrierId;
87
+ switch (scope) {
88
+ case NVSHMEMI_THREADGROUP_THREAD:
89
+ return;
90
+ case NVSHMEMI_THREADGROUP_WARP:
91
+ __syncwarp();
92
+ break;
93
+ case NVSHMEMI_THREADGROUP_WARPGROUP:
94
+ // break;
95
+ tid =
96
+ threadIdx.x + (threadIdx.y * blockDim.x) + (threadIdx.z * blockDim.x * blockDim.y);
97
+
98
+ // each warpgroup has a unique barrier id per CTA
99
+ barrierId = (tid / (4 * warpSize));
100
+ // Ensure blocksize is a multiple of warpgroup size
101
+ assert((blockDim.x * blockDim.y * blockDim.z) % (4 * warpSize) == 0);
102
+ // Hardware limit on named barriers (max 16)
103
+ assert((barrierId < 16) && "Reduce blocksize");
104
+ asm volatile("bar.sync %0, %1;" : : "r"(barrierId), "r"(4 * warpSize));
105
+ break;
106
+ case NVSHMEMI_THREADGROUP_BLOCK:
107
+ __syncthreads();
108
+ break;
109
+ default:
110
+ printf("unrecognized threadscope passed\n");
111
+ assert(0);
112
+ break;
113
+ }
114
+ }
115
+ #endif
116
+
117
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/device/wait/nvshmemi_wait_until_apis.cuh ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * See License.txt for license information
5
+ */
6
+
7
+ #ifndef _NVSHMEM_WAIT_UNTIL_APIS_CUH_
8
+ #define _NVSHMEM_WAIT_UNTIL_APIS_CUH_
9
+
10
+ #ifdef __CUDA_ARCH__
11
+
12
+ #include <cuda_runtime.h>
13
+ #include "device_host_transport/nvshmem_constants.h"
14
+ #include "device/nvshmem_device_macros.h"
15
+ #include "non_abi/device/threadgroup/nvshmemi_common_device_defines.cuh"
16
+ #include "device_host/nvshmem_common.cuh"
17
+ #include "non_abi/nvshmem_build_options.h"
18
+
19
+ #define TIMEOUT_NCYCLES 1e10
20
+
21
+ template <typename T>
22
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_check_timeout_and_log(
23
+ long long int start, int caller, uintptr_t signal_addr, T signal_val_found,
24
+ T signal_val_expected) {
25
+ long long int now;
26
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(now));
27
+ if ((now - start) > TIMEOUT_NCYCLES) {
28
+ nvshmemi_timeout_t *timeout_d = nvshmemi_device_state_d.timeout;
29
+ timeout_d->caller = caller;
30
+ timeout_d->signal_addr = signal_addr;
31
+ *(T *)(&timeout_d->signal_val_found) = signal_val_found;
32
+ *(T *)(&timeout_d->signal_val_expected) = signal_val_expected;
33
+ *((volatile uint64_t *)(&timeout_d->signal)) = 1;
34
+ }
35
+ }
36
+
37
+ template <typename T>
38
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_greater_than(volatile T *addr,
39
+ T val, int caller) {
40
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
41
+ long long int start;
42
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
43
+ #endif
44
+ while (*addr <= val) {
45
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
46
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
47
+ #endif
48
+ }
49
+ }
50
+
51
+ template <typename T>
52
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_greater_than_equals(
53
+ volatile T *addr, T val, int caller) {
54
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
55
+ long long int start;
56
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
57
+ #endif
58
+ while (*addr < val) {
59
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
60
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
61
+ #endif
62
+ }
63
+ }
64
+
65
+ template <typename T>
66
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_lesser_than(volatile T *addr,
67
+ T val, int caller) {
68
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
69
+ long long int start;
70
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
71
+ #endif
72
+ while (*addr >= val) {
73
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
74
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
75
+ #endif
76
+ }
77
+ }
78
+
79
+ template <typename T>
80
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_lesser_than_equals(
81
+ volatile T *addr, T val, int caller) {
82
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
83
+ long long int start;
84
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
85
+ #endif
86
+ while (*addr > val) {
87
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
88
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
89
+ #endif
90
+ }
91
+ }
92
+
93
+ template <typename T>
94
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_equals(volatile T *addr, T val,
95
+ int caller) {
96
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
97
+ long long int start;
98
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
99
+ #endif
100
+ while (*addr != val) {
101
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
102
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
103
+ #endif
104
+ }
105
+ }
106
+
107
+ template <typename T>
108
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_not_equals(volatile T *addr,
109
+ T val, int caller) {
110
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
111
+ long long int start;
112
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
113
+ #endif
114
+ while (*addr == val) {
115
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
116
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, *addr, val);
117
+ #endif
118
+ }
119
+ }
120
+
121
+ template <typename T>
122
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until_greater_than_equals_add(
123
+ volatile T *addr, uint64_t toadd, T val, int caller) {
124
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
125
+ long long int start;
126
+ asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(start));
127
+ #endif
128
+ T valataddr;
129
+ do {
130
+ valataddr = *addr;
131
+ #ifdef NVSHMEM_TIMEOUT_DEVICE_POLLING
132
+ nvshmemi_check_timeout_and_log<T>(start, caller, (uintptr_t)addr, valataddr + toadd, val);
133
+ #endif
134
+ } while (valataddr + toadd < val);
135
+ }
136
+
137
+ template <typename T>
138
+ __device__ NVSHMEMI_DEVICE_ALWAYS_INLINE void nvshmemi_wait_until(volatile T *ivar, int cmp,
139
+ T cmp_value) {
140
+ if (NVSHMEM_CMP_GE == cmp) {
141
+ nvshmemi_wait_until_greater_than_equals<T>(ivar, cmp_value,
142
+ NVSHMEMI_CALL_SITE_WAIT_UNTIL_GE);
143
+ } else if (NVSHMEM_CMP_EQ == cmp) {
144
+ nvshmemi_wait_until_equals<T>(ivar, cmp_value, NVSHMEMI_CALL_SITE_WAIT_UNTIL_EQ);
145
+ } else if (NVSHMEM_CMP_NE == cmp) {
146
+ nvshmemi_wait_until_not_equals<T>(ivar, cmp_value, NVSHMEMI_CALL_SITE_WAIT_UNTIL_NE);
147
+ } else if (NVSHMEM_CMP_GT == cmp) {
148
+ nvshmemi_wait_until_greater_than<T>(ivar, cmp_value, NVSHMEMI_CALL_SITE_WAIT_UNTIL_GT);
149
+ } else if (NVSHMEM_CMP_LT == cmp) {
150
+ nvshmemi_wait_until_lesser_than<T>(ivar, cmp_value, NVSHMEMI_CALL_SITE_WAIT_UNTIL_LT);
151
+ } else if (NVSHMEM_CMP_LE == cmp) {
152
+ nvshmemi_wait_until_lesser_than_equals<T>(ivar, cmp_value,
153
+ NVSHMEMI_CALL_SITE_WAIT_UNTIL_LE);
154
+ }
155
+ }
156
+
157
+ #endif
158
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmem_build_options.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pragma once
2
+
3
+ /* #undef NVSHMEM_COMPLEX_SUPPORT */
4
+ /* #undef NVSHMEM_DEBUG */
5
+ /* #undef NVSHMEM_DEVEL */
6
+ /* #undef NVSHMEM_TRACE */
7
+ /* #undef NVSHMEM_DEFAULT_PMI2 */
8
+ /* #undef NVSHMEM_DEFAULT_PMIX */
9
+ /* #undef NVSHMEM_DEFAULT_UCX */
10
+ /* #undef NVSHMEM_GPU_COLL_USE_LDST */
11
+ #define NVSHMEM_IBDEVX_SUPPORT
12
+ #define NVSHMEM_IBRC_SUPPORT
13
+ #define NVSHMEM_LIBFABRIC_SUPPORT
14
+ #define NVSHMEM_MPI_SUPPORT
15
+ #define NVSHMEM_NVTX
16
+ #define NVSHMEM_PMIX_SUPPORT
17
+ #define NVSHMEM_SHMEM_SUPPORT
18
+ /* #undef NVSHMEM_TEST_STATIC_LIB */
19
+ /* #undef NVSHMEM_TIMEOUT_DEVICE_POLLING */
20
+ #define NVSHMEM_UCX_SUPPORT
21
+ /* #undef NVSHMEM_USE_DLMALLOC */
22
+ #define NVSHMEM_USE_NCCL
23
+ #define NVSHMEM_USE_GDRCOPY
24
+ #define NVSHMEM_USE_MLX5DV
25
+ /* #undef NVSHMEM_VERBOSE */
26
+ #define NVSHMEM_BUILD_TESTS
27
+ #define NVSHMEM_BUILD_EXAMPLES
28
+ #define NVSHMEM_IBGDA_SUPPORT
29
+ /* #undef NVSHMEM_IBGDA_SUPPORT_GPUMEM_ONLY */
30
+ /* #undef NVSHMEM_ENABLE_ALL_DEVICE_INLINING */
31
+ /* #undef NVSHMEM_HOSTLIB_ONLY */
32
+
33
+ #if defined __clang_llvm_bitcode_lib__ || defined NVSHMEM_HOSTLIB_ONLY
34
+ #undef NVSHMEM_IBGDA_SUPPORT
35
+ #undef NVSHMEM_IBGDA_SUPPORT_GPUMEM_ONLY
36
+ #define NVSHMEM_ENABLE_ALL_DEVICE_INLINING
37
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmem_version.h ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Note - For packaging reasons, do not move this file from src/include/non_abi */
2
+
3
+ #pragma once
4
+
5
+ // clang-format off
6
+
7
+ #define NVSHMEM_VENDOR_MAJOR_VERSION 3
8
+ #define NVSHMEM_VENDOR_MINOR_VERSION 4
9
+ #define NVSHMEM_VENDOR_PATCH_VERSION 5
10
+ #define NVSHMEM_VENDOR_PACKAGE_VERSION 0
11
+ #define NVSHMEM_TRANSPORT_PLUGIN_MAJOR_VERSION 3
12
+ #define NVSHMEM_TRANSPORT_PLUGIN_MINOR_VERSION 0
13
+ #define NVSHMEM_TRANSPORT_PLUGIN_PATCH_VERSION 0
14
+ #define NVSHMEM_BOOTSTRAP_PLUGIN_MAJOR_VERSION 3
15
+ #define NVSHMEM_BOOTSTRAP_PLUGIN_MINOR_VERSION 0
16
+ #define NVSHMEM_BOOTSTRAP_PLUGIN_PATCH_VERSION 0
17
+ #define NVSHMEM_BUILD_VARS "NVSHMEM_DEBUG=OFF NVSHMEM_DEVEL=OFF NVSHMEM_DEFAULT_PMI2=OFF NVSHMEM_DEFAULT_PMIX=OFF NVSHMEM_DEFAULT_UCX=OFF NVSHMEM_ENABLE_ALL_DEVICE_INLINING=OFF NVSHMEM_GPU_COLL_USE_LDST=OFF NVSHMEM_IBGDA_SUPPORT=ON NVSHMEM_IBGDA_SUPPORT_GPUMEM_ONLY=OFF NVSHMEM_IBDEVX_SUPPORT=ON NVSHMEM_IBRC_SUPPORT=ON NVSHMEM_LIBFABRIC_SUPPORT=ON NVSHMEM_MPI_SUPPORT=ON NVSHMEM_NVTX=ON NVSHMEM_PMIX_SUPPORT=ON NVSHMEM_SHMEM_SUPPORT=ON NVSHMEM_TEST_STATIC_LIB=OFF NVSHMEM_TIMEOUT_DEVICE_POLLING=OFF NVSHMEM_TRACE=OFF NVSHMEM_UCX_SUPPORT=ON NVSHMEM_USE_DLMALLOC=OFF NVSHMEM_USE_NCCL=ON NVSHMEM_USE_GDRCOPY=ON NVSHMEM_VERBOSE=OFF CUDA_HOME=/dvs/p4/build/sw/rel/gpgpu/toolkit/r12.9/build/cuda GDRCOPY_HOME=/dvs/p4/build/sw/rel/gpgpu/toolkit/r12.9/gdrcopy_build LIBFABRIC_HOME=/data/tmp/libfabric_install MPI_HOME=/data/tmp/openmpi_install NCCL_HOME=/dvs/p4/build/sw/rel/gpgpu/toolkit/r12.9/nccl/build NVSHMEM_PREFIX=/dvs/p4/build/sw/rel/gpgpu/toolkit/r12.9/main_nvshmem/install PMIX_HOME=/data/tmp/pmix_install SHMEM_HOME=/data/tmp/openmpi_install UCX_HOME=/dvs/p4/build/sw/gpgpu/openucx/build"
18
+
19
+ // clang-format on
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/include/non_abi/nvshmemx_error.h ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
3
+ *
4
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ * and proprietary rights in and to this software, related documentation
6
+ * and any modifications thereto. Any use, reproduction, disclosure or
7
+ * distribution of this software and related documentation without an express
8
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ *
10
+ * See License.txt for license information
11
+ */
12
+
13
+ #ifndef _NVSHMEMX_ERROR_H_
14
+ #define _NVSHMEMX_ERROR_H_
15
+ #if !defined __CUDACC_RTC__
16
+ #include <errno.h> // for errno
17
+ #include <limits.h>
18
+ #include <stdio.h> // for stderr, stdout, NULL
19
+ #include <string.h> // IWYU pragma: keep for strerror
20
+ #include <stdlib.h> // IWYU pragma: keep for exit
21
+ #else
22
+ #define fprintf(...)
23
+ #define exit(...)
24
+ #include <cuda/std/climits>
25
+ #include <cuda/std/cstdlib>
26
+ #endif
27
+
28
+ /* The !! idiom is used to convert non-boolean types to booleans.
29
+ * Doing so in this case allows us to ensure that __builtin_expect
30
+ * will be given a clean boolean value for the comparison. */
31
+ #define nvshmemxi_error_unlikely(x) __builtin_expect(!!(x), 0)
32
+
33
+ #if defined __cplusplus || defined __clang_llvm_bitcode_lib__
34
+ extern "C" {
35
+ #endif
36
+
37
+ enum nvshmemx_status {
38
+ NVSHMEMX_SUCCESS = 0,
39
+ NVSHMEMX_ERROR_INVALID_VALUE,
40
+ NVSHMEMX_ERROR_OUT_OF_MEMORY,
41
+ NVSHMEMX_ERROR_NOT_SUPPORTED,
42
+ NVSHMEMX_ERROR_SYMMETRY,
43
+ NVSHMEMX_ERROR_GPU_NOT_SELECTED,
44
+ NVSHMEMX_ERROR_COLLECTIVE_LAUNCH_FAILED,
45
+ NVSHMEMX_ERROR_INTERNAL,
46
+ NVSHMEMX_ERROR_SENTINEL = INT_MAX
47
+ };
48
+
49
+ #define NVSHMEMI_ERROR_EXIT(...) \
50
+ do { \
51
+ fprintf(stderr, "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__); \
52
+ fprintf(stderr, __VA_ARGS__); \
53
+ fprintf(stderr, "\n"); \
54
+ exit(-1); \
55
+ } while (0)
56
+
57
+ #define NVSHMEMI_ERROR_PRINT(...) \
58
+ do { \
59
+ fprintf(stderr, "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__); \
60
+ fprintf(stderr, __VA_ARGS__); \
61
+ fprintf(stderr, "\n"); \
62
+ } while (0)
63
+
64
+ #define NVSHMEMI_WARN_PRINT(...) \
65
+ do { \
66
+ fprintf(stdout, "WARN: "); \
67
+ fprintf(stdout, __VA_ARGS__); \
68
+ fprintf(stdout, "\n"); \
69
+ } while (0)
70
+
71
+ #define NVSHMEMI_ERROR_JMP(status, err, label, ...) \
72
+ do { \
73
+ fprintf(stderr, "%s:%d: non-zero status: %d ", __FILE__, __LINE__, err); \
74
+ fprintf(stderr, __VA_ARGS__); \
75
+ fprintf(stderr, "\n"); \
76
+ status = err; \
77
+ goto label; \
78
+ } while (0)
79
+
80
+ #define NVSHMEMI_NULL_ERROR_JMP(var, status, err, label, ...) \
81
+ do { \
82
+ if (nvshmemxi_error_unlikely(var == NULL)) { \
83
+ fprintf(stderr, "%s:%d: NULL value ", __FILE__, __LINE__); \
84
+ fprintf(stderr, __VA_ARGS__); \
85
+ fprintf(stderr, "\n"); \
86
+ status = err; \
87
+ goto label; \
88
+ } \
89
+ } while (0)
90
+
91
+ #define NVSHMEMI_EQ_ERROR_JMP(status, expected, err, label, ...) \
92
+ do { \
93
+ if (nvshmemxi_error_unlikely(status == expected)) { \
94
+ fprintf(stderr, "%s:%d: error status: %d ", __FILE__, __LINE__, status); \
95
+ fprintf(stderr, __VA_ARGS__); \
96
+ fprintf(stderr, "\n"); \
97
+ status = err; \
98
+ goto label; \
99
+ } \
100
+ } while (0)
101
+
102
+ #define NVSHMEMI_NE_ERROR_JMP(status, expected, err, label, ...) \
103
+ do { \
104
+ if (nvshmemxi_error_unlikely(status != expected)) { \
105
+ fprintf(stderr, "%s:%d: non-zero status: %d ", __FILE__, __LINE__, status); \
106
+ fprintf(stderr, __VA_ARGS__); \
107
+ fprintf(stderr, "\n"); \
108
+ status = err; \
109
+ goto label; \
110
+ } \
111
+ } while (0)
112
+
113
+ #define NVSHMEMI_NZ_ERROR_JMP(status, err, label, ...) \
114
+ do { \
115
+ if (nvshmemxi_error_unlikely(status != 0)) { \
116
+ fprintf(stderr, "%s:%d: non-zero status: %d ", __FILE__, __LINE__, status); \
117
+ fprintf(stderr, __VA_ARGS__); \
118
+ fprintf(stderr, "\n"); \
119
+ status = err; \
120
+ goto label; \
121
+ } \
122
+ } while (0)
123
+
124
+ #define NVSHMEMI_CHECK_ERROR_JMP(statement, status, err, label, ...) \
125
+ do { \
126
+ if (nvshmemxi_error_unlikely(statement)) { \
127
+ fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
128
+ fprintf(stderr, __VA_ARGS__); \
129
+ fprintf(stderr, "\n"); \
130
+ status = err; \
131
+ goto label; \
132
+ } \
133
+ } while (0)
134
+
135
+ #define NVSHMEMI_NZ_EXIT(status, ...) \
136
+ do { \
137
+ if (nvshmemxi_error_unlikely(status != 0)) { \
138
+ fprintf(stderr, "%s:%d: non-zero status: %d: %s, exiting... ", __FILE__, __LINE__, \
139
+ status, strerror(errno)); \
140
+ fprintf(stderr, __VA_ARGS__); \
141
+ fprintf(stderr, "\n"); \
142
+ exit(-1); \
143
+ } \
144
+ } while (0)
145
+
146
+ #define NVSHMEMI_NZ_SYSCHECK_EXIT(sys_status, ...) \
147
+ do { \
148
+ if (nvshmemxi_error_unlikely((sys_status) != 0)) { \
149
+ fprintf(stderr, "%s:%d: non-zero status: %d: %s, exiting... ", __FILE__, __LINE__, \
150
+ (sys_status), strerror(sys_status)); \
151
+ fprintf(stderr, __VA_ARGS__); \
152
+ fprintf(stderr, "\n"); \
153
+ exit(-1); \
154
+ } \
155
+ } while (0)
156
+
157
+ #if defined __cplusplus || defined __clang_llvm_bitcode_lib__
158
+ }
159
+ #endif
160
+
161
+ #endif
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_mpi.so.3 ADDED
Binary file (24 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmi.so.3 ADDED
Binary file (39.5 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmi2.so.3 ADDED
Binary file (54.1 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_pmix.so.3 ADDED
Binary file (56.5 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_shmem.so.3 ADDED
Binary file (19.7 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_bootstrap_uid.so.3 ADDED
Binary file (73.7 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvshmem/lib/nvshmem_transport_ucx.so.3 ADDED
Binary file (55.9 kB). View file
 
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/__init__.py ADDED
File without changes
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/__init__.py ADDED
File without changes
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExt.h ADDED
@@ -0,0 +1,1578 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2024 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ /** \file nvToolsExt.h
39
+ */
40
+
41
+ /*
42
+ * Deprecation and upcoming removal warning for NVTX version 2
43
+ * This warning can be suppressed by defining NVTX_SUPPRESS_V2_DEPRECATION_WARNING
44
+ */
45
+ #ifndef NVTX_SUPPRESS_V2_DEPRECATION_WARNING
46
+ #ifndef NVTX_V2_DEPRECATION_WARNING_MESSAGE
47
+ #define NVTX_V2_DEPRECATION_WARNING_MESSAGE "DEPRECATION NOTICE: NVTX 2 is deprecated and will be removed from toolkits that distribute it in their next major version (CUDA 12.9). Please use NVTX 3 instead. All NVTX 2 API functions are supported in version 3. The implementation is now header-only, so you no longer need to link with and distribute a dynamic library to use NVTX. Ensure you are explicitly using NVTX 3 by writing #include <nvtx3/nvToolsExt.h> instead of #include <nvToolsExt.h>. Remove nvToolsExt from your link command and linker search paths, and stop deploying libnvToolsExt.so or nvToolsExt64_1.dll -- these binary libraries will not be shipped with NVTX 3 for C/C++ usage. A new library called 'libnvtx3interop.so' or 'nvtx3interop.dll' will be provided for interop with other languages. This message can be suppressed by defining NVTX_SUPPRESS_V2_DEPRECATION_WARNING before including the NVTX 2 headers."
48
+ #ifdef _MSC_VER
49
+ #define NVTX_V2_WARNING_HELPER2(x) #x
50
+ #define NVTX_V2_WARNING_HELPER(x) NVTX_V2_WARNING_HELPER2(x)
51
+ #pragma message(__FILE__ ":" NVTX_V2_WARNING_HELPER(__LINE__) ": note: \"" NVTX_V2_DEPRECATION_WARNING_MESSAGE "\"\n")
52
+ #else
53
+ #pragma message NVTX_V2_DEPRECATION_WARNING_MESSAGE
54
+ #endif
55
+ #endif /* NVTX_V2_DEPRECATION_WARNING_MESSAGE */
56
+ #endif /* NVTX_SUPPRESS_V2_DEPRECATION_WARNING */
57
+
58
+ /* ========================================================================= */
59
+ /** \mainpage
60
+ * \tableofcontents
61
+ * \section INTRODUCTION Introduction
62
+ *
63
+ * The NVIDIA Tools Extension library is a set of functions that a
64
+ * developer can use to provide additional information to tools.
65
+ * The additional information is used by the tool to improve
66
+ * analysis and visualization of data.
67
+ *
68
+ * The library introduces close to zero overhead if no tool is
69
+ * attached to the application. The overhead when a tool is
70
+ * attached is specific to the tool.
71
+ *
72
+ * \section INITIALIZATION_SECTION Initialization
73
+ *
74
+ * Typically the tool's library that plugs into NVTX is indirectly
75
+ * loaded via enviromental properties that are platform specific.
76
+ * For some platform or special cases, the user may be required
77
+ * to instead explicity initialize instead though. This can also
78
+ * be helpful to control when the API loads a tool's library instead
79
+ * of what would typically be the first function call to emit info.
80
+ * For these rare case, see \ref INITIALIZATION for additional information.
81
+ *
82
+ * \section MARKERS_AND_RANGES Markers and Ranges
83
+ *
84
+ * Markers and ranges are used to describe events at a specific time (markers)
85
+ * or over a time span (ranges) during the execution of the application
86
+ * respectively.
87
+ *
88
+ * \subsection MARKERS Markers
89
+ *
90
+ * Markers denote specific moments in time.
91
+ *
92
+ *
93
+ * See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
94
+ * how to specify the domain.
95
+ *
96
+ * \subsection THREAD_RANGES Thread Ranges
97
+ *
98
+ * Thread ranges denote nested time ranges. Nesting is maintained per thread
99
+ * per domain and does not require any additional correlation mechanism. The
100
+ * duration of a thread range is defined by the corresponding pair of
101
+ * nvtxRangePush* to nvtxRangePop API calls.
102
+ *
103
+ * See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
104
+ * how to specify the domain.
105
+ *
106
+ * \subsection PROCESS_RANGES Process Ranges
107
+ *
108
+ * Process ranges denote a time span that can expose arbitrary concurrency, as
109
+ * opposed to thread ranges that only support nesting. In addition the range
110
+ * start event can happen on a different thread than the end marker. For the
111
+ * correlation of a start/end pair an unique correlation ID is used that is
112
+ * returned from the start API call and needs to be passed into the end API
113
+ * call.
114
+ *
115
+ * \subsection EVENT_ATTRIBUTES Event Attributes
116
+ *
117
+ * \ref MARKERS_AND_RANGES can be annotated with various attributes to provide
118
+ * additional information for an event or to guide the tool's visualization of
119
+ * the data. Each of the attributes is optional and if left unused the
120
+ * attributes fall back to a default value. The attributes include:
121
+ * - color
122
+ * - category
123
+ *
124
+ * To specify any attribute other than the text message, the \ref
125
+ * EVENT_ATTRIBUTE_STRUCTURE "Event Attribute Structure" must be used.
126
+ *
127
+ * \section DOMAINS Domains
128
+ *
129
+ * Domains enable developers to scope annotations. By default all events and
130
+ * annotations are in the default domain. Additional domains can be registered.
131
+ * This allows developers to scope markers, ranges, and resources names to
132
+ * avoid conflicts.
133
+ *
134
+ * The function ::nvtxDomainCreateA or ::nvtxDomainCreateW is used to create
135
+ * a named domain.
136
+ *
137
+ * Each domain maintains its own
138
+ * - categories
139
+ * - thread range stacks
140
+ * - registered strings
141
+ *
142
+ * The function ::nvtxDomainDestroy marks the end of the domain. Destroying
143
+ * a domain unregisters and destroys all objects associated with it such as
144
+ * registered strings, resource objects, named categories, and started ranges.
145
+ *
146
+ * \section RESOURCE_NAMING Resource Naming
147
+ *
148
+ * This section covers calls that allow to annotate objects with user-provided
149
+ * names in order to allow for a better analysis of complex trace data. All of
150
+ * the functions take the handle or the ID of the object to name and the name.
151
+ * The functions can be called multiple times during the execution of an
152
+ * application, however, in that case it is implementation dependent which
153
+ * name will be reported by the tool.
154
+ *
155
+ * \subsection CATEGORY_NAMING Category Naming
156
+ *
157
+ * Some function in this library support associating an integer category
158
+ * to enable filtering and sorting. The category naming functions allow
159
+ * the application to associate a user friendly name with the integer
160
+ * category. Support for domains have been added in NVTX_VERSION_2 to
161
+ * avoid collisions when domains are developed independantly.
162
+ *
163
+ * \subsection RESOURCE_OBJECTS Resource Objects
164
+ *
165
+ * Resource objects are a generic mechanism for attaching data to an application
166
+ * resource. The identifier field makes the association to a pointer or handle,
167
+ * while the type field helps provide deeper understanding of the identifier as
168
+ * well as enabling differentiation in cases where handles generated by different
169
+ * APIs may collide. The resource object may also have an associated message to
170
+ * associate with the application resource, enabling further annotation of this
171
+ * object and how it is used.
172
+ *
173
+ * The resource object was introduced in NVTX_VERSION_2 to supersede existing naming
174
+ * functions and allow the application resource identified by those functions to be
175
+ * associated to a domain. The other naming functions are still supported for backward
176
+ * compatibility but will be associated only to the default domain.
177
+ *
178
+ * \subsection RESOURCE_NAMING_OS Resource Naming
179
+ *
180
+ * Some operating system resources creation APIs do not support providing a user friendly
181
+ * name, such as some OS thread creation APIs. This API support resource naming though
182
+ * both through resource objects and functions following the pattern
183
+ * nvtxName[RESOURCE_TYPE][A|W](identifier, name). Resource objects introduced in NVTX_VERSION 2
184
+ * supersede the other functions with a a more general method of assigning names to OS resources,
185
+ * along with associating them to domains too. The older nvtxName* functions are only associated
186
+ * with the default domain.
187
+ * \section EXTENSIONS Optional Extensions
188
+ * Optional extensions will either appear within the existing sections the extend or appear
189
+ * in the "Related Pages" when they introduce new concepts.
190
+ */
191
+
192
+ #ifndef NVTOOLSEXT_H_
193
+ #define NVTOOLSEXT_H_
194
+
195
+ #if defined(_MSC_VER)
196
+ #ifdef NVTX_EXPORTS
197
+ #define NVTX_DECLSPEC
198
+ #else
199
+ #define NVTX_DECLSPEC __declspec(dllimport)
200
+ #endif /* NVTX_EXPORTS */
201
+ #define NVTX_API __stdcall
202
+ #define NVTX_INLINE_STATIC __inline static
203
+ #else /*defined(__GNUC__)*/
204
+ #define NVTX_DECLSPEC
205
+ #define NVTX_API
206
+ #define NVTX_INLINE_STATIC inline static
207
+ #endif /* Platform */
208
+
209
+ /**
210
+ * The nvToolsExt library depends on stdint.h. If the build tool chain in use
211
+ * does not include stdint.h then define NVTX_STDINT_TYPES_ALREADY_DEFINED
212
+ * and define the following types:
213
+ * <ul>
214
+ * <li>uint8_t
215
+ * <li>int8_t
216
+ * <li>uint16_t
217
+ * <li>int16_t
218
+ * <li>uint32_t
219
+ * <li>int32_t
220
+ * <li>uint64_t
221
+ * <li>int64_t
222
+ * <li>uintptr_t
223
+ * <li>intptr_t
224
+ * </ul>
225
+ #define NVTX_STDINT_TYPES_ALREADY_DEFINED if you are using your own header file.
226
+ */
227
+ #ifndef NVTX_STDINT_TYPES_ALREADY_DEFINED
228
+ #include <stdint.h>
229
+ #endif
230
+
231
+ #include <stddef.h>
232
+
233
+ #ifdef __cplusplus
234
+ extern "C" {
235
+ #endif /* __cplusplus */
236
+
237
+ /**
238
+ * Tools Extension API version
239
+ */
240
+ #define NVTX_VERSION 2
241
+
242
+ /**
243
+ * Size of the nvtxEventAttributes_t structure.
244
+ */
245
+ #define NVTX_EVENT_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxEventAttributes_t) ) )
246
+
247
+ /**
248
+ * Size of the nvtxInitializationAttributes_t structure.
249
+ */
250
+ #define NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxInitializationAttributes_t) ) )
251
+
252
+ #define NVTX_NO_PUSH_POP_TRACKING ((int)-2)
253
+
254
+ typedef uint64_t nvtxRangeId_t;
255
+
256
+
257
+ /* \brief String Handle Structure.
258
+ * \anchor STRING_HANDLE_STRUCTURE
259
+ *
260
+ * This structure is opaque to the user and is used as a handle to reference
261
+ * a string. The tools will return a pointer through the API for the application
262
+ * to hold on it's behalf to reference the string in the future.
263
+ *
264
+ */
265
+ typedef struct nvtxStringHandle* nvtxStringHandle_t;
266
+
267
+ /* \brief Domain Handle Structure.
268
+ * \anchor DOMAIN_HANDLE_STRUCTURE
269
+ *
270
+ * This structure is opaque to the user and is used as a handle to reference
271
+ * a domain. The tools will return a pointer through the API for the application
272
+ * to hold on its behalf to reference the domain in the future.
273
+ *
274
+ */
275
+ typedef struct nvtxDomainHandle* nvtxDomainHandle_t;
276
+
277
+
278
+
279
+
280
+
281
+
282
+ /* ========================================================================= */
283
+ /** \defgroup GENERAL General
284
+ * @{
285
+ */
286
+
287
+ /** ---------------------------------------------------------------------------
288
+ * Color Types
289
+ * ------------------------------------------------------------------------- */
290
+ typedef enum nvtxColorType_t
291
+ {
292
+ NVTX_COLOR_UNKNOWN = 0, /**< Color attribute is unused. */
293
+ NVTX_COLOR_ARGB = 1 /**< An ARGB color is provided. */
294
+ } nvtxColorType_t;
295
+
296
+ /** ---------------------------------------------------------------------------
297
+ * Message Types
298
+ * ------------------------------------------------------------------------- */
299
+ typedef enum nvtxMessageType_t
300
+ {
301
+ NVTX_MESSAGE_UNKNOWN = 0, /**< Message payload is unused. */
302
+ NVTX_MESSAGE_TYPE_ASCII = 1, /**< A character sequence is used as payload. */
303
+ NVTX_MESSAGE_TYPE_UNICODE = 2, /**< A wide character sequence is used as payload. */
304
+ /* NVTX_VERSION_2 */
305
+ NVTX_MESSAGE_TYPE_REGISTERED = 3 /**< A unique string handle that was registered
306
+ with \ref nvtxDomainRegisterStringA() or
307
+ \ref nvtxDomainRegisterStringW(). */
308
+ } nvtxMessageType_t;
309
+
310
+ typedef union nvtxMessageValue_t
311
+ {
312
+ const char* ascii;
313
+ const wchar_t* unicode;
314
+ /* NVTX_VERSION_2 */
315
+ nvtxStringHandle_t registered;
316
+ } nvtxMessageValue_t;
317
+
318
+
319
+ /** @} */ /*END defgroup*/
320
+
321
+ /* ========================================================================= */
322
+ /** \defgroup INITIALIZATION Initialization
323
+ * @{
324
+ * Typically the tool's library that plugs into NVTX is indirectly
325
+ * loaded via enviromental properties that are platform specific.
326
+ * For some platform or special cases, the user may be required
327
+ * to instead explicity initialize instead though. This can also
328
+ * be helpful to control when the API loads a tool's library instead
329
+ * of what would typically be the first function call to emit info.
330
+ */
331
+
332
+ /** ---------------------------------------------------------------------------
333
+ * Initialization Modes
334
+ * ------------------------------------------------------------------------- */
335
+ typedef enum nvtxInitializationMode_t
336
+ {
337
+ NVTX_INITIALIZATION_MODE_UNKNOWN = 0, /**< A platform that supports indirect initialization will attempt this style, otherwise expect failure. */
338
+ NVTX_INITIALIZATION_MODE_CALLBACK_V1 = 1, /**< A function pointer conforming to NVTX_VERSION=1 will be used. */
339
+ NVTX_INITIALIZATION_MODE_CALLBACK_V2 = 2, /**< A function pointer conforming to NVTX_VERSION=2 will be used. */
340
+ NVTX_INITIALIZATION_MODE_SIZE
341
+ } nvtxInitializationMode_t;
342
+
343
+
344
+ /** \brief Initialization Attribute Structure.
345
+ * \anchor INITIALIZATION_ATTRIBUTE_STRUCTURE
346
+ *
347
+ * This structure is used to describe the attributes used for initialization
348
+ * of the NVTX API.
349
+ *
350
+ * \par Initializing the Attributes
351
+ *
352
+ * The caller should always perform the following three tasks when using
353
+ * attributes:
354
+ * <ul>
355
+ * <li>Zero the structure
356
+ * <li>Set the version field
357
+ * <li>Set the size field
358
+ * </ul>
359
+ *
360
+ * Zeroing the structure sets all the event attributes types and values
361
+ * to the default value.
362
+ *
363
+ * The version and size field are used by the Tools Extension
364
+ * implementation to handle multiple versions of the attributes structure.
365
+ * NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE may be used for the size.
366
+ *
367
+ * It is recommended that the caller use one of the following to methods
368
+ * to initialize the event attributes structure:
369
+ *
370
+ * \par Method 1: Initializing nvtxInitializationAttributes_t for future compatibility
371
+ * \code
372
+ * nvtxInitializationAttributes_t initAttribs = {0};
373
+ * initAttribs.version = NVTX_VERSION;
374
+ * initAttribs.size = NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE;
375
+ * \endcode
376
+ *
377
+ * \par Method 2: Initializing nvtxInitializationAttributes_t for a specific version
378
+ * \code
379
+ * nvtxInitializationAttributes_t initAttribs = {0};
380
+ * initAttribs.version =2;
381
+ * initAttribs.size = (uint16_t)(sizeof(nvtxInitializationAttributes_v2));
382
+ * \endcode
383
+ *
384
+ * If the caller uses Method 1 it is critical that the entire binary
385
+ * layout of the structure be configured to 0 so that all fields
386
+ * are initialized to the default value.
387
+ *
388
+ * The caller should either use both NVTX_VERSION and
389
+ * NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
390
+ * and a versioned type (Method 2). Using a mix of the two methods
391
+ * will likely cause either source level incompatibility or binary
392
+ * incompatibility in the future.
393
+ *
394
+ * \par Settings Attribute Types and Values
395
+ *
396
+ *
397
+ * \par Example:
398
+ * \code
399
+ * // Initialize
400
+ * nvtxInitializationAttributes_t initAttribs = {0};
401
+ * initAttribs.version = NVTX_VERSION;
402
+ * initAttribs.size = NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE;
403
+ *
404
+ * // Configure the Attributes
405
+ * initAttribs.mode = NVTX_INITIALIZATION_MODE_CALLBACK_V2;
406
+ * initAttribs.fnptr = InitializeInjectionNvtx2;
407
+ * \endcode
408
+
409
+ * \sa
410
+ * ::nvtxInitializationMode_t
411
+ * ::nvtxInitialize
412
+ */
413
+ typedef struct nvtxInitializationAttributes_v2
414
+ {
415
+ /**
416
+ * \brief Version flag of the structure.
417
+ *
418
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
419
+ * supported in this header file. This can optionally be overridden to
420
+ * another version of the tools extension library.
421
+ */
422
+ uint16_t version;
423
+
424
+ /**
425
+ * \brief Size of the structure.
426
+ *
427
+ * Needs to be set to the size in bytes of the event attribute
428
+ * structure used to specify the event.
429
+ */
430
+ uint16_t size;
431
+
432
+ /**
433
+ * \brief Mode of initialization.
434
+ *
435
+ * The mode of initialization dictates the overall behavior and which
436
+ * attributes in this struct will be used.
437
+ *
438
+ * Default Value is NVTX_INITIALIZATION_MODE_UNKNOWN = 0
439
+ * \sa
440
+ * ::nvtxInitializationMode_t
441
+ */
442
+ uint32_t mode;
443
+
444
+ /**
445
+ * \brief Function pointer used for initialization if the mode requires
446
+ *
447
+ * The user has retrieved this function pointer from the tool library
448
+ * and would like to use it to initialize. The mode must be set to a
449
+ * NVTX_INITIALIZATION_MODE_CALLBACK_V# for this to be used. The mode
450
+ * will dictate the expectations for this member. The function signature
451
+ * will be cast from void(*)() to the appropriate signature for the mode.
452
+ * the expected behavior of the function will also depend on the mode
453
+ * beyond the simple function signature.
454
+ *
455
+ * Default Value is NVTX_INITIALIZATION_MODE_UNKNOWN which will either
456
+ * initialize based on external properties or fail if not supported on
457
+ * the given platform.
458
+
459
+ * \sa
460
+ * ::nvtxInitializationMode_t
461
+ */
462
+ void(*fnptr)(void);
463
+
464
+ } nvtxInitializationAttributes_v2;
465
+
466
+ typedef struct nvtxInitializationAttributes_v2 nvtxInitializationAttributes_t;
467
+
468
+
469
+ /* ------------------------------------------------------------------------- */
470
+ /** \brief Force initialization (optional on most platforms)
471
+ *
472
+ * Force NVTX library to initialize. On some platform NVTX will implicit initialize
473
+ * upon the first function call into an NVTX API.
474
+ *
475
+ * \return Result codes are simplest to assume NVTX_SUCCESS or !NVTX_SUCCESS
476
+ *
477
+ * \param initAttrib - The initialization attribute structure
478
+ *
479
+ * \sa
480
+ * ::nvtxInitializationAttributes_t
481
+ *
482
+ * \version \NVTX_VERSION_2
483
+ * @{ */
484
+ NVTX_DECLSPEC int NVTX_API nvtxInitialize(const nvtxInitializationAttributes_t* initAttrib);
485
+ /** @} */
486
+
487
+
488
+ /** @} */ /*END defgroup*/
489
+
490
+ /* ========================================================================= */
491
+ /** \defgroup EVENT_ATTRIBUTES Event Attributes
492
+ * @{
493
+ */
494
+
495
+ /** ---------------------------------------------------------------------------
496
+ * Payload Types
497
+ * ------------------------------------------------------------------------- */
498
+ typedef enum nvtxPayloadType_t
499
+ {
500
+ NVTX_PAYLOAD_UNKNOWN = 0, /**< Color payload is unused. */
501
+ NVTX_PAYLOAD_TYPE_UNSIGNED_INT64 = 1, /**< A 64 bit unsigned integer value is used as payload. */
502
+ NVTX_PAYLOAD_TYPE_INT64 = 2, /**< A 64 bit signed integer value is used as payload. */
503
+ NVTX_PAYLOAD_TYPE_DOUBLE = 3, /**< A 64 bit floating point value is used as payload. */
504
+ /* NVTX_VERSION_2 */
505
+ NVTX_PAYLOAD_TYPE_UNSIGNED_INT32 = 4, /**< A 32 bit floating point value is used as payload. */
506
+ NVTX_PAYLOAD_TYPE_INT32 = 5, /**< A 32 bit floating point value is used as payload. */
507
+ NVTX_PAYLOAD_TYPE_FLOAT = 6 /**< A 32 bit floating point value is used as payload. */
508
+ } nvtxPayloadType_t;
509
+
510
+ /** \brief Event Attribute Structure.
511
+ * \anchor EVENT_ATTRIBUTE_STRUCTURE
512
+ *
513
+ * This structure is used to describe the attributes of an event. The layout of
514
+ * the structure is defined by a specific version of the tools extension
515
+ * library and can change between different versions of the Tools Extension
516
+ * library.
517
+ *
518
+ * \par Initializing the Attributes
519
+ *
520
+ * The caller should always perform the following three tasks when using
521
+ * attributes:
522
+ * <ul>
523
+ * <li>Zero the structure
524
+ * <li>Set the version field
525
+ * <li>Set the size field
526
+ * </ul>
527
+ *
528
+ * Zeroing the structure sets all the event attributes types and values
529
+ * to the default value.
530
+ *
531
+ * The version and size field are used by the Tools Extension
532
+ * implementation to handle multiple versions of the attributes structure.
533
+ *
534
+ * It is recommended that the caller use one of the following to methods
535
+ * to initialize the event attributes structure:
536
+ *
537
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
538
+ * \code
539
+ * nvtxEventAttributes_t eventAttrib = {0};
540
+ * eventAttrib.version = NVTX_VERSION;
541
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
542
+ * \endcode
543
+ *
544
+ * \par Method 2: Initializing nvtxEventAttributes for a specific version
545
+ * \code
546
+ * nvtxEventAttributes_t eventAttrib = {0};
547
+ * eventAttrib.version = 1;
548
+ * eventAttrib.size = (uint16_t)(sizeof(nvtxEventAttributes_v1));
549
+ * \endcode
550
+ *
551
+ * If the caller uses Method 1 it is critical that the entire binary
552
+ * layout of the structure be configured to 0 so that all fields
553
+ * are initialized to the default value.
554
+ *
555
+ * The caller should either use both NVTX_VERSION and
556
+ * NVTX_EVENT_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
557
+ * and a versioned type (Method 2). Using a mix of the two methods
558
+ * will likely cause either source level incompatibility or binary
559
+ * incompatibility in the future.
560
+ *
561
+ * \par Settings Attribute Types and Values
562
+ *
563
+ *
564
+ * \par Example:
565
+ * \code
566
+ * // Initialize
567
+ * nvtxEventAttributes_t eventAttrib = {0};
568
+ * eventAttrib.version = NVTX_VERSION;
569
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
570
+ *
571
+ * // Configure the Attributes
572
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
573
+ * eventAttrib.color = 0xFF880000;
574
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
575
+ * eventAttrib.message.ascii = "Example";
576
+ * \endcode
577
+ *
578
+ * In the example the caller does not have to set the value of
579
+ * \ref ::nvtxEventAttributes_v2::category or
580
+ * \ref ::nvtxEventAttributes_v2::payload as these fields were set to
581
+ * the default value by {0}.
582
+ * \sa
583
+ * ::nvtxDomainMarkEx
584
+ * ::nvtxDomainRangeStartEx
585
+ * ::nvtxDomainRangePushEx
586
+ */
587
+ typedef struct nvtxEventAttributes_v2
588
+ {
589
+ /**
590
+ * \brief Version flag of the structure.
591
+ *
592
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
593
+ * supported in this header file. This can optionally be overridden to
594
+ * another version of the tools extension library.
595
+ */
596
+ uint16_t version;
597
+
598
+ /**
599
+ * \brief Size of the structure.
600
+ *
601
+ * Needs to be set to the size in bytes of the event attribute
602
+ * structure used to specify the event.
603
+ */
604
+ uint16_t size;
605
+
606
+ /**
607
+ * \brief ID of the category the event is assigned to.
608
+ *
609
+ * A category is a user-controlled ID that can be used to group
610
+ * events. The tool may use category IDs to improve filtering or
611
+ * enable grouping of events in the same category. The functions
612
+ * \ref ::nvtxNameCategoryA or \ref ::nvtxNameCategoryW can be used
613
+ * to name a category.
614
+ *
615
+ * Default Value is 0
616
+ */
617
+ uint32_t category;
618
+
619
+ /** \brief Color type specified in this attribute structure.
620
+ *
621
+ * Defines the color format of the attribute structure's \ref COLOR_FIELD
622
+ * "color" field.
623
+ *
624
+ * Default Value is NVTX_COLOR_UNKNOWN
625
+ */
626
+ int32_t colorType; /* nvtxColorType_t */
627
+
628
+ /** \brief Color assigned to this event. \anchor COLOR_FIELD
629
+ *
630
+ * The color that the tool should use to visualize the event.
631
+ */
632
+ uint32_t color;
633
+
634
+ /**
635
+ * \brief Payload type specified in this attribute structure.
636
+ *
637
+ * Defines the payload format of the attribute structure's \ref PAYLOAD_FIELD
638
+ * "payload" field.
639
+ *
640
+ * Default Value is NVTX_PAYLOAD_UNKNOWN
641
+ */
642
+ int32_t payloadType; /* nvtxPayloadType_t */
643
+
644
+ int32_t reserved0;
645
+
646
+ /**
647
+ * \brief Payload assigned to this event. \anchor PAYLOAD_FIELD
648
+ *
649
+ * A numerical value that can be used to annotate an event. The tool could
650
+ * use the payload data to reconstruct graphs and diagrams.
651
+ */
652
+ union payload_t
653
+ {
654
+ uint64_t ullValue;
655
+ int64_t llValue;
656
+ double dValue;
657
+ /* NVTX_VERSION_2 */
658
+ uint32_t uiValue;
659
+ int32_t iValue;
660
+ float fValue;
661
+ } payload;
662
+
663
+ /** \brief Message type specified in this attribute structure.
664
+ *
665
+ * Defines the message format of the attribute structure's \ref MESSAGE_FIELD
666
+ * "message" field.
667
+ *
668
+ * Default Value is NVTX_MESSAGE_UNKNOWN
669
+ */
670
+ int32_t messageType; /* nvtxMessageType_t */
671
+
672
+ /** \brief Message assigned to this attribute structure. \anchor MESSAGE_FIELD
673
+ *
674
+ * The text message that is attached to an event.
675
+ */
676
+ nvtxMessageValue_t message;
677
+
678
+ } nvtxEventAttributes_v2;
679
+
680
+ typedef struct nvtxEventAttributes_v2 nvtxEventAttributes_t;
681
+
682
+ /** @} */ /*END defgroup*/
683
+ /* ========================================================================= */
684
+ /** \defgroup MARKERS_AND_RANGES Markers and Ranges
685
+ *
686
+ * See \ref MARKERS_AND_RANGES for more details
687
+ *
688
+ * @{
689
+ */
690
+
691
+ /** \name Marker */
692
+
693
+ /* ------------------------------------------------------------------------- */
694
+ /** \brief Marks an instantaneous event in the application.
695
+ *
696
+ * A marker can contain a text message or specify additional information
697
+ * using the event attributes structure. These attributes include a text
698
+ * message, color, category, and a payload. Each of the attributes is optional
699
+ * and can only be sent out using the \ref nvtxDomainMarkEx function.
700
+ *
701
+ * nvtxDomainMarkEx(NULL, event) is equivalent to calling
702
+ * nvtxMarkEx(event).
703
+ *
704
+ * \param domain - The domain of scoping the category.
705
+ * \param eventAttrib - The event attribute structure defining the marker's
706
+ * attribute types and attribute values.
707
+ *
708
+ * \sa
709
+ * ::nvtxMarkEx
710
+ *
711
+ * \version \NVTX_VERSION_2
712
+ * @{ */
713
+ NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
714
+ /** @} */
715
+
716
+ /* ------------------------------------------------------------------------- */
717
+ /** \brief Marks an instantaneous event in the application.
718
+ *
719
+ * A marker can contain a text message or specify additional information
720
+ * using the event attributes structure. These attributes include a text
721
+ * message, color, category, and a payload. Each of the attributes is optional
722
+ * and can only be sent out using the \ref nvtxMarkEx function.
723
+ * If \ref nvtxMarkA or \ref nvtxMarkW are used to specify the marker
724
+ * or if an attribute is unspecified then a default value will be used.
725
+ *
726
+ * \param eventAttrib - The event attribute structure defining the marker's
727
+ * attribute types and attribute values.
728
+ *
729
+ * \par Example:
730
+ * \code
731
+ * // zero the structure
732
+ * nvtxEventAttributes_t eventAttrib = {0};
733
+ * // set the version and the size information
734
+ * eventAttrib.version = NVTX_VERSION;
735
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
736
+ * // configure the attributes. 0 is the default for all attributes.
737
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
738
+ * eventAttrib.color = 0xFF880000;
739
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
740
+ * eventAttrib.message.ascii = "Example nvtxMarkEx";
741
+ * nvtxMarkEx(&eventAttrib);
742
+ * \endcode
743
+ *
744
+ * \sa
745
+ * ::nvtxDomainMarkEx
746
+ *
747
+ * \version \NVTX_VERSION_1
748
+ * @{ */
749
+ NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib);
750
+ /** @} */
751
+
752
+ /* ------------------------------------------------------------------------- */
753
+ /** \brief Marks an instantaneous event in the application.
754
+ *
755
+ * A marker created using \ref nvtxMarkA or \ref nvtxMarkW contains only a
756
+ * text message.
757
+ *
758
+ * \param message - The message associated to this marker event.
759
+ *
760
+ * \par Example:
761
+ * \code
762
+ * nvtxMarkA("Example nvtxMarkA");
763
+ * nvtxMarkW(L"Example nvtxMarkW");
764
+ * \endcode
765
+ *
766
+ * \sa
767
+ * ::nvtxDomainMarkEx
768
+ * ::nvtxMarkEx
769
+ *
770
+ * \version \NVTX_VERSION_0
771
+ * @{ */
772
+ NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message);
773
+ NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message);
774
+ /** @} */
775
+
776
+
777
+ /** \name Process Ranges */
778
+
779
+ /* ------------------------------------------------------------------------- */
780
+ /** \brief Starts a process range in a domain.
781
+ *
782
+ * \param domain - The domain of scoping the category.
783
+ * \param eventAttrib - The event attribute structure defining the range's
784
+ * attribute types and attribute values.
785
+ *
786
+ * \return The unique ID used to correlate a pair of Start and End events.
787
+ *
788
+ * \remarks Ranges defined by Start/End can overlap.
789
+ *
790
+ * \par Example:
791
+ * \code
792
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
793
+ * nvtxEventAttributes_t eventAttrib = {0};
794
+ * eventAttrib.version = NVTX_VERSION;
795
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
796
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
797
+ * eventAttrib.message.ascii = "my range";
798
+ * nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
799
+ * // ...
800
+ * nvtxDomainRangeEnd(rangeId);
801
+ * \endcode
802
+ *
803
+ * \sa
804
+ * ::nvtxDomainRangeEnd
805
+ *
806
+ * \version \NVTX_VERSION_2
807
+ * @{ */
808
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
809
+ /** @} */
810
+
811
+ /* ------------------------------------------------------------------------- */
812
+ /** \brief Starts a process range.
813
+ *
814
+ * \param eventAttrib - The event attribute structure defining the range's
815
+ * attribute types and attribute values.
816
+ *
817
+ * \return The unique ID used to correlate a pair of Start and End events.
818
+ *
819
+ * \remarks Ranges defined by Start/End can overlap.
820
+ *
821
+ * \par Example:
822
+ * \code
823
+ * nvtxEventAttributes_t eventAttrib = {0};
824
+ * eventAttrib.version = NVTX_VERSION;
825
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
826
+ * eventAttrib.category = 3;
827
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
828
+ * eventAttrib.color = 0xFF0088FF;
829
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
830
+ * eventAttrib.message.ascii = "Example Range";
831
+ * nvtxRangeId_t rangeId = nvtxRangeStartEx(&eventAttrib);
832
+ * // ...
833
+ * nvtxRangeEnd(rangeId);
834
+ * \endcode
835
+ *
836
+ * \sa
837
+ * ::nvtxRangeEnd
838
+ * ::nvtxDomainRangeStartEx
839
+ *
840
+ * \version \NVTX_VERSION_1
841
+ * @{ */
842
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib);
843
+ /** @} */
844
+
845
+ /* ------------------------------------------------------------------------- */
846
+ /** \brief Starts a process range.
847
+ *
848
+ * \param message - The event message associated to this range event.
849
+ *
850
+ * \return The unique ID used to correlate a pair of Start and End events.
851
+ *
852
+ * \remarks Ranges defined by Start/End can overlap.
853
+ *
854
+ * \par Example:
855
+ * \code
856
+ * nvtxRangeId_t r1 = nvtxRangeStartA("Range 1");
857
+ * nvtxRangeId_t r2 = nvtxRangeStartW(L"Range 2");
858
+ * nvtxRangeEnd(r1);
859
+ * nvtxRangeEnd(r2);
860
+ * \endcode
861
+ *
862
+ * \sa
863
+ * ::nvtxRangeEnd
864
+ * ::nvtxRangeStartEx
865
+ * ::nvtxDomainRangeStartEx
866
+ *
867
+ * \version \NVTX_VERSION_0
868
+ * @{ */
869
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message);
870
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message);
871
+ /** @} */
872
+
873
+ /* ------------------------------------------------------------------------- */
874
+ /** \brief Ends a process range.
875
+ *
876
+ * \param domain - The domain
877
+ * \param id - The correlation ID returned from a nvtxRangeStart call.
878
+ *
879
+ * \remarks This function is offered completeness but is an alias for ::nvtxRangeEnd.
880
+ * It does not need a domain param since that is associated iwth the range ID at ::nvtxDomainRangeStartEx
881
+ *
882
+ * \par Example:
883
+ * \code
884
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
885
+ * nvtxEventAttributes_t eventAttrib = {0};
886
+ * eventAttrib.version = NVTX_VERSION;
887
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
888
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
889
+ * eventAttrib.message.ascii = "my range";
890
+ * nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
891
+ * // ...
892
+ * nvtxDomainRangeEnd(rangeId);
893
+ * \endcode
894
+ *
895
+ * \sa
896
+ * ::nvtxDomainRangeStartEx
897
+ *
898
+ * \version \NVTX_VERSION_2
899
+ * @{ */
900
+ NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id);
901
+ /** @} */
902
+
903
+ /* ------------------------------------------------------------------------- */
904
+ /** \brief Ends a process range.
905
+ *
906
+ * \param id - The correlation ID returned from an nvtxRangeStart call.
907
+ *
908
+ * \sa
909
+ * ::nvtxDomainRangeStartEx
910
+ * ::nvtxRangeStartEx
911
+ * ::nvtxRangeStartA
912
+ * ::nvtxRangeStartW
913
+ *
914
+ * \version \NVTX_VERSION_0
915
+ * @{ */
916
+ NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id);
917
+ /** @} */
918
+
919
+ /** \name Thread Ranges */
920
+
921
+ /* ------------------------------------------------------------------------- */
922
+ /** \brief Starts a nested thread range.
923
+ *
924
+ * \param domain - The domain of scoping.
925
+ * \param eventAttrib - The event attribute structure defining the range's
926
+ * attribute types and attribute values.
927
+ *
928
+ * \return The 0 based level of range being started. This value is scoped to the domain.
929
+ * If an error occurs, a negative value is returned.
930
+ *
931
+ * \par Example:
932
+ * \code
933
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
934
+ * nvtxEventAttributes_t eventAttrib = {0};
935
+ * eventAttrib.version = NVTX_VERSION;
936
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
937
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
938
+ * eventAttrib.color = 0xFFFF0000;
939
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
940
+ * eventAttrib.message.ascii = "Level 0";
941
+ * nvtxDomainRangePushEx(domain, &eventAttrib);
942
+ *
943
+ * // Re-use eventAttrib
944
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
945
+ * eventAttrib.message.unicode = L"Level 1";
946
+ * nvtxDomainRangePushEx(domain, &eventAttrib);
947
+ *
948
+ * nvtxDomainRangePop(domain); //level 1
949
+ * nvtxDomainRangePop(domain); //level 0
950
+ * \endcode
951
+ *
952
+ * \sa
953
+ * ::nvtxDomainRangePop
954
+ *
955
+ * \version \NVTX_VERSION_2
956
+ * @{ */
957
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
958
+ /** @} */
959
+
960
+ /* ------------------------------------------------------------------------- */
961
+ /** \brief Starts a nested thread range.
962
+ *
963
+ * \param eventAttrib - The event attribute structure defining the range's
964
+ * attribute types and attribute values.
965
+ *
966
+ * \return The 0 based level of range being started. This level is per domain.
967
+ * If an error occurs a negative value is returned.
968
+ *
969
+ * \par Example:
970
+ * \code
971
+ * nvtxEventAttributes_t eventAttrib = {0};
972
+ * eventAttrib.version = NVTX_VERSION;
973
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
974
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
975
+ * eventAttrib.color = 0xFFFF0000;
976
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
977
+ * eventAttrib.message.ascii = "Level 0";
978
+ * nvtxRangePushEx(&eventAttrib);
979
+ *
980
+ * // Re-use eventAttrib
981
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
982
+ * eventAttrib.message.unicode = L"Level 1";
983
+ * nvtxRangePushEx(&eventAttrib);
984
+ *
985
+ * nvtxRangePop();
986
+ * nvtxRangePop();
987
+ * \endcode
988
+ *
989
+ * \sa
990
+ * ::nvtxDomainRangePushEx
991
+ * ::nvtxRangePop
992
+ *
993
+ * \version \NVTX_VERSION_1
994
+ * @{ */
995
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib);
996
+ /** @} */
997
+
998
+ /* ------------------------------------------------------------------------- */
999
+ /** \brief Starts a nested thread range.
1000
+ *
1001
+ * \param message - The event message associated to this range event.
1002
+ *
1003
+ * \return The 0 based level of range being started. If an error occurs a
1004
+ * negative value is returned.
1005
+ *
1006
+ * \par Example:
1007
+ * \code
1008
+ * nvtxRangePushA("Level 0");
1009
+ * nvtxRangePushW(L"Level 1");
1010
+ * nvtxRangePop();
1011
+ * nvtxRangePop();
1012
+ * \endcode
1013
+ *
1014
+ * \sa
1015
+ * ::nvtxDomainRangePushEx
1016
+ * ::nvtxRangePop
1017
+ *
1018
+ * \version \NVTX_VERSION_0
1019
+ * @{ */
1020
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message);
1021
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message);
1022
+ /** @} */
1023
+
1024
+
1025
+ /* ------------------------------------------------------------------------- */
1026
+ /** \brief Ends a nested thread range.
1027
+ *
1028
+ * \return The level of the range being ended. If an error occurs a negative
1029
+ * value is returned on the current thread.
1030
+ *
1031
+ * \par Example:
1032
+ * \code
1033
+ * nvtxDomainHandle_t domain = nvtxDomainCreate("example library");
1034
+ * nvtxDomainRangePushA(domain, "Level 0");
1035
+ * nvtxDomainRangePushW(domain, L"Level 1");
1036
+ * nvtxDomainRangePop(domain);
1037
+ * nvtxDomainRangePop(domain);
1038
+ * \endcode
1039
+ *
1040
+ * \sa
1041
+ * ::nvtxRangePushEx
1042
+ * ::nvtxRangePushA
1043
+ * ::nvtxRangePushW
1044
+ *
1045
+ * \version \NVTX_VERSION_2
1046
+ * @{ */
1047
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain);
1048
+ /** @} */
1049
+
1050
+ /* ------------------------------------------------------------------------- */
1051
+ /** \brief Ends a nested thread range.
1052
+ *
1053
+ * \return The level of the range being ended. If an error occurs a negative
1054
+ * value is returned on the current thread.
1055
+ *
1056
+ * \par Example:
1057
+ * \code
1058
+ * nvtxRangePushA("Level 0");
1059
+ * nvtxRangePushW(L"Level 1");
1060
+ * nvtxRangePop();
1061
+ * nvtxRangePop();
1062
+ * \endcode
1063
+ *
1064
+ * \sa
1065
+ * ::nvtxRangePushEx
1066
+ * ::nvtxRangePushA
1067
+ * ::nvtxRangePushW
1068
+ *
1069
+ * \version \NVTX_VERSION_0
1070
+ * @{ */
1071
+ NVTX_DECLSPEC int NVTX_API nvtxRangePop(void);
1072
+ /** @} */
1073
+
1074
+
1075
+ /** @} */ /*END defgroup*/
1076
+ /* ========================================================================= */
1077
+ /** \defgroup RESOURCE_NAMING Resource Naming
1078
+ *
1079
+ * See \ref RESOURCE_NAMING for more details
1080
+ *
1081
+ * @{
1082
+ */
1083
+
1084
+
1085
+ /* ------------------------------------------------------------------------- */
1086
+ /** \name Functions for Generic Resource Naming*/
1087
+ /* ------------------------------------------------------------------------- */
1088
+
1089
+ /* ------------------------------------------------------------------------- */
1090
+ /** \cond SHOW_HIDDEN
1091
+ * \brief Resource typing helpers.
1092
+ *
1093
+ * Classes are used to make it easy to create a series of resource types
1094
+ * per API without collisions
1095
+ */
1096
+ #define NVTX_RESOURCE_MAKE_TYPE(CLASS, INDEX) ((((uint32_t)(NVTX_RESOURCE_CLASS_ ## CLASS))<<16)|((uint32_t)(INDEX)))
1097
+ #define NVTX_RESOURCE_CLASS_GENERIC 1
1098
+ /** \endcond */
1099
+
1100
+ /* ------------------------------------------------------------------------- */
1101
+ /** \brief Generic resource type for when a resource class is not available.
1102
+ *
1103
+ * \sa
1104
+ * ::nvtxDomainResourceCreate
1105
+ *
1106
+ * \version \NVTX_VERSION_2
1107
+ */
1108
+ typedef enum nvtxResourceGenericType_t
1109
+ {
1110
+ NVTX_RESOURCE_TYPE_UNKNOWN = 0,
1111
+ NVTX_RESOURCE_TYPE_GENERIC_POINTER = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 1), /**< Generic pointer assumed to have no collisions with other pointers. */
1112
+ NVTX_RESOURCE_TYPE_GENERIC_HANDLE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 2), /**< Generic handle assumed to have no collisions with other handles. */
1113
+ NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 3), /**< OS native thread identifier. */
1114
+ NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 4) /**< POSIX pthread identifier. */
1115
+ } nvtxResourceGenericType_t;
1116
+
1117
+
1118
+
1119
+ /** \brief Resource Attribute Structure.
1120
+ * \anchor RESOURCE_ATTRIBUTE_STRUCTURE
1121
+ *
1122
+ * This structure is used to describe the attributes of a resource. The layout of
1123
+ * the structure is defined by a specific version of the tools extension
1124
+ * library and can change between different versions of the Tools Extension
1125
+ * library.
1126
+ *
1127
+ * \par Initializing the Attributes
1128
+ *
1129
+ * The caller should always perform the following three tasks when using
1130
+ * attributes:
1131
+ * <ul>
1132
+ * <li>Zero the structure
1133
+ * <li>Set the version field
1134
+ * <li>Set the size field
1135
+ * </ul>
1136
+ *
1137
+ * Zeroing the structure sets all the resource attributes types and values
1138
+ * to the default value.
1139
+ *
1140
+ * The version and size field are used by the Tools Extension
1141
+ * implementation to handle multiple versions of the attributes structure.
1142
+ *
1143
+ * It is recommended that the caller use one of the following to methods
1144
+ * to initialize the event attributes structure:
1145
+ *
1146
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
1147
+ * \code
1148
+ * nvtxResourceAttributes_t attribs = {0};
1149
+ * attribs.version = NVTX_VERSION;
1150
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1151
+ * \endcode
1152
+ *
1153
+ * \par Method 2: Initializing nvtxEventAttributes for a specific version
1154
+ * \code
1155
+ * nvtxResourceAttributes_v0 attribs = {0};
1156
+ * attribs.version = 2;
1157
+ * attribs.size = (uint16_t)(sizeof(nvtxResourceAttributes_v0));
1158
+ * \endcode
1159
+ *
1160
+ * If the caller uses Method 1 it is critical that the entire binary
1161
+ * layout of the structure be configured to 0 so that all fields
1162
+ * are initialized to the default value.
1163
+ *
1164
+ * The caller should either use both NVTX_VERSION and
1165
+ * NVTX_RESOURCE_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
1166
+ * and a versioned type (Method 2). Using a mix of the two methods
1167
+ * will likely cause either source level incompatibility or binary
1168
+ * incompatibility in the future.
1169
+ *
1170
+ * \par Settings Attribute Types and Values
1171
+ *
1172
+ *
1173
+ * \par Example:
1174
+ * \code
1175
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1176
+ *
1177
+ * // Initialize
1178
+ * nvtxResourceAttributes_t attribs = {0};
1179
+ * attribs.version = NVTX_VERSION;
1180
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1181
+ *
1182
+ * // Configure the Attributes
1183
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1184
+ * attribs.identifier.pValue = (const void*)pMutex;
1185
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1186
+ * attribs.message.ascii = "Single thread access to database.";
1187
+ *
1188
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1189
+ * \endcode
1190
+ *
1191
+ * \sa
1192
+ * ::nvtxDomainResourceCreate
1193
+ */
1194
+ typedef struct nvtxResourceAttributes_v0
1195
+ {
1196
+ /**
1197
+ * \brief Version flag of the structure.
1198
+ *
1199
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
1200
+ * supported in this header file. This can optionally be overridden to
1201
+ * another version of the tools extension library.
1202
+ */
1203
+ uint16_t version;
1204
+
1205
+ /**
1206
+ * \brief Size of the structure.
1207
+ *
1208
+ * Needs to be set to the size in bytes of this attribute
1209
+ * structure.
1210
+ */
1211
+ uint16_t size;
1212
+
1213
+ /**
1214
+ * \brief Identifier type specifies how to interpret the identifier field
1215
+ *
1216
+ * Defines the identifier format of the attribute structure's \ref RESOURCE_IDENTIFIER_FIELD
1217
+ * "identifier" field.
1218
+ *
1219
+ * Default Value is NVTX_RESOURCE_TYPE_UNKNOWN
1220
+ */
1221
+ int32_t identifierType; /* values from enums following the pattern nvtxResource[name]Type_t */
1222
+
1223
+ /**
1224
+ * \brief Identifier for the resource.
1225
+ * \anchor RESOURCE_IDENTIFIER_FIELD
1226
+ *
1227
+ * An identifier may be a pointer or a handle to an OS or middleware API object.
1228
+ * The resource type will assist in avoiding collisions where handles values may collide.
1229
+ */
1230
+ union identifier_t
1231
+ {
1232
+ const void* pValue;
1233
+ uint64_t ullValue;
1234
+ } identifier;
1235
+
1236
+ /** \brief Message type specified in this attribute structure.
1237
+ *
1238
+ * Defines the message format of the attribute structure's \ref RESOURCE_MESSAGE_FIELD
1239
+ * "message" field.
1240
+ *
1241
+ * Default Value is NVTX_MESSAGE_UNKNOWN
1242
+ */
1243
+ int32_t messageType; /* nvtxMessageType_t */
1244
+
1245
+ /** \brief Message assigned to this attribute structure. \anchor RESOURCE_MESSAGE_FIELD
1246
+ *
1247
+ * The text message that is attached to a resource.
1248
+ */
1249
+ nvtxMessageValue_t message;
1250
+
1251
+ } nvtxResourceAttributes_v0;
1252
+
1253
+ typedef struct nvtxResourceAttributes_v0 nvtxResourceAttributes_t;
1254
+
1255
+ /* \cond SHOW_HIDDEN
1256
+ * \version \NVTX_VERSION_2
1257
+ */
1258
+ #define NVTX_RESOURCE_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxResourceAttributes_v0) ) )
1259
+ typedef struct nvtxResourceHandle* nvtxResourceHandle_t;
1260
+ /** \endcond */
1261
+
1262
+
1263
+
1264
+ /* ------------------------------------------------------------------------- */
1265
+ /** \brief Create a resource object to track and associate data with OS and middleware objects
1266
+ *
1267
+ * Allows users to associate an API handle or pointer with a user-provided name.
1268
+ *
1269
+ *
1270
+ * \param domain - Domain to own the resource object
1271
+ * \param attribs - Attributes to be associated with the resource
1272
+ *
1273
+ * \return A handle that represents the newly created resource object.
1274
+ *
1275
+ * \par Example:
1276
+ * \code
1277
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1278
+ * nvtxResourceAttributes_t attribs = {0};
1279
+ * attribs.version = NVTX_VERSION;
1280
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1281
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1282
+ * attribs.identifier.pValue = (const void*)pMutex;
1283
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1284
+ * attribs.message.ascii = "Single thread access to database.";
1285
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1286
+ * \endcode
1287
+ *
1288
+ * \sa
1289
+ * ::nvtxResourceAttributes_t
1290
+ * ::nvtxDomainResourceDestroy
1291
+ *
1292
+ * \version \NVTX_VERSION_2
1293
+ * @{ */
1294
+ NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
1295
+ /** @} */
1296
+
1297
+ /* ------------------------------------------------------------------------- */
1298
+ /** \brief Destroy a resource object to track and associate data with OS and middleware objects
1299
+ *
1300
+ * Allows users to associate an API handle or pointer with a user-provided name.
1301
+ *
1302
+ * \param resource - Handle to the resource in which to operate.
1303
+ *
1304
+ * \par Example:
1305
+ * \code
1306
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1307
+ * nvtxResourceAttributes_t attribs = {0};
1308
+ * attribs.version = NVTX_VERSION;
1309
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1310
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1311
+ * attribs.identifier.pValue = (const void*)pMutex;
1312
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1313
+ * attribs.message.ascii = "Single thread access to database.";
1314
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1315
+ * nvtxDomainResourceDestroy(handle);
1316
+ * \endcode
1317
+ *
1318
+ * \sa
1319
+ * ::nvtxDomainResourceCreate
1320
+ *
1321
+ * \version \NVTX_VERSION_2
1322
+ * @{ */
1323
+ NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource);
1324
+ /** @} */
1325
+
1326
+
1327
+ /** \name Functions for NVTX Category Naming*/
1328
+
1329
+ /* ------------------------------------------------------------------------- */
1330
+ /**
1331
+ * \brief Annotate an NVTX category used within a domain.
1332
+ *
1333
+ * Categories are used to group sets of events. Each category is identified
1334
+ * through a unique ID and that ID is passed into any of the marker/range
1335
+ * events to assign that event to a specific category. The nvtxDomainNameCategory
1336
+ * function calls allow the user to assign a name to a category ID that is
1337
+ * specific to the domain.
1338
+ *
1339
+ * nvtxDomainNameCategory(NULL, category, name) is equivalent to calling
1340
+ * nvtxNameCategory(category, name).
1341
+ *
1342
+ * \param domain - The domain of scoping the category.
1343
+ * \param category - The category ID to name.
1344
+ * \param name - The name of the category.
1345
+ *
1346
+ * \remarks The category names are tracked per domain.
1347
+ *
1348
+ * \par Example:
1349
+ * \code
1350
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example");
1351
+ * nvtxDomainNameCategoryA(domain, 1, "Memory Allocation");
1352
+ * nvtxDomainNameCategoryW(domain, 2, L"Memory Transfer");
1353
+ * \endcode
1354
+ *
1355
+ * \version \NVTX_VERSION_2
1356
+ * @{ */
1357
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name);
1358
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
1359
+ /** @} */
1360
+
1361
+ /** \brief Annotate an NVTX category.
1362
+ *
1363
+ * Categories are used to group sets of events. Each category is identified
1364
+ * through a unique ID and that ID is passed into any of the marker/range
1365
+ * events to assign that event to a specific category. The nvtxNameCategory
1366
+ * function calls allow the user to assign a name to a category ID.
1367
+ *
1368
+ * \param category - The category ID to name.
1369
+ * \param name - The name of the category.
1370
+ *
1371
+ * \remarks The category names are tracked per process.
1372
+ *
1373
+ * \par Example:
1374
+ * \code
1375
+ * nvtxNameCategory(1, "Memory Allocation");
1376
+ * nvtxNameCategory(2, "Memory Transfer");
1377
+ * nvtxNameCategory(3, "Memory Object Lifetime");
1378
+ * \endcode
1379
+ *
1380
+ * \version \NVTX_VERSION_1
1381
+ * @{ */
1382
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name);
1383
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name);
1384
+ /** @} */
1385
+
1386
+ /** \name Functions for OS Threads Naming*/
1387
+
1388
+ /* ------------------------------------------------------------------------- */
1389
+ /** \brief Annotate an OS thread.
1390
+ *
1391
+ * Allows the user to name an active thread of the current process. If an
1392
+ * invalid thread ID is provided or a thread ID from a different process is
1393
+ * used the behavior of the tool is implementation dependent.
1394
+ *
1395
+ * The thread name is associated to the default domain. To support domains
1396
+ * use resource objects via ::nvtxDomainResourceCreate.
1397
+ *
1398
+ * \param threadId - The ID of the thread to name.
1399
+ * \param name - The name of the thread.
1400
+ *
1401
+ * \par Example:
1402
+ * \code
1403
+ * nvtxNameOsThread(GetCurrentThreadId(), "MAIN_THREAD");
1404
+ * \endcode
1405
+ *
1406
+ * \version \NVTX_VERSION_1
1407
+ * @{ */
1408
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name);
1409
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name);
1410
+ /** @} */
1411
+
1412
+
1413
+ /** @} */ /*END defgroup*/
1414
+ /* ========================================================================= */
1415
+ /** \defgroup STRING_REGISTRATION String Registration
1416
+ *
1417
+ * Registered strings are intended to increase performance by lowering instrumentation
1418
+ * overhead. String may be registered once and the handle may be passed in place of
1419
+ * a string where an the APIs may allow.
1420
+ *
1421
+ * See \ref STRING_REGISTRATION for more details
1422
+ *
1423
+ * @{
1424
+ */
1425
+
1426
+ /* ------------------------------------------------------------------------- */
1427
+ /** \brief Register a string.
1428
+
1429
+ * Registers an immutable string with NVTX. Once registered the pointer used
1430
+ * to register the domain name can be used in nvtxEventAttributes_t
1431
+ * \ref MESSAGE_FIELD. This allows NVTX implementation to skip copying the
1432
+ * contents of the message on each event invocation.
1433
+ *
1434
+ * String registration is an optimization. It is recommended to use string
1435
+ * registration if the string will be passed to an event many times.
1436
+ *
1437
+ * String are not unregistered, except that by unregistering the entire domain
1438
+ *
1439
+ * \param domain - Domain handle. If NULL then the global domain is used.
1440
+ * \param string - A unique pointer to a sequence of characters.
1441
+ *
1442
+ * \return A handle representing the registered string.
1443
+ *
1444
+ * \par Example:
1445
+ * \code
1446
+ * nvtxDomainCreateA("com.nvidia.nvtx.example");
1447
+ * nvtxStringHandle_t message = nvtxDomainRegisterStringA(domain, "registered string");
1448
+ * nvtxEventAttributes_t eventAttrib = {0};
1449
+ * eventAttrib.version = NVTX_VERSION;
1450
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1451
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_REGISTERED;
1452
+ * eventAttrib.message.registered = message;
1453
+ * \endcode
1454
+ *
1455
+ * \version \NVTX_VERSION_2
1456
+ * @{ */
1457
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string);
1458
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string);
1459
+ /** @} */
1460
+
1461
+ /** @} */ /*END defgroup*/
1462
+ /* ========================================================================= */
1463
+ /** \defgroup DOMAINS Domains
1464
+ *
1465
+ * Domains are used to group events to a developer defined scope. Middleware
1466
+ * vendors may also scope their own events to avoid collisions with the
1467
+ * the application developer's events, so that the application developer may
1468
+ * inspect both parts and easily differentiate or filter them. By default
1469
+ * all events are scoped to a global domain where NULL is provided or when
1470
+ * using APIs provided b versions of NVTX below v2
1471
+ *
1472
+ * Domains are intended to be typically long lived objects with the intention
1473
+ * of logically separating events of large modules from each other such as
1474
+ * middleware libraries from each other and the main application.
1475
+ *
1476
+ * See \ref DOMAINS for more details
1477
+ *
1478
+ * @{
1479
+ */
1480
+
1481
+ /* ------------------------------------------------------------------------- */
1482
+ /** \brief Register a NVTX domain.
1483
+ *
1484
+ * Domains are used to scope annotations. All NVTX_VERSION_0 and NVTX_VERSION_1
1485
+ * annotations are scoped to the global domain. The function nvtxDomainCreate
1486
+ * creates a new named domain.
1487
+ *
1488
+ * Each domain maintains its own nvtxRangePush and nvtxRangePop stack.
1489
+ *
1490
+ * \param name - A unique string representing the domain.
1491
+ *
1492
+ * \return A handle representing the domain.
1493
+ *
1494
+ * \par Example:
1495
+ * \code
1496
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
1497
+ *
1498
+ * nvtxMarkA("nvtxMarkA to global domain");
1499
+ *
1500
+ * nvtxEventAttributes_t eventAttrib1 = {0};
1501
+ * eventAttrib1.version = NVTX_VERSION;
1502
+ * eventAttrib1.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1503
+ * eventAttrib1.message.ascii = "nvtxDomainMarkEx to global domain";
1504
+ * nvtxDomainMarkEx(NULL, &eventAttrib1);
1505
+ *
1506
+ * nvtxEventAttributes_t eventAttrib2 = {0};
1507
+ * eventAttrib2.version = NVTX_VERSION;
1508
+ * eventAttrib2.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1509
+ * eventAttrib2.message.ascii = "nvtxDomainMarkEx to com.nvidia.nvtx.example";
1510
+ * nvtxDomainMarkEx(domain, &eventAttrib2);
1511
+ * nvtxDomainDestroy(domain);
1512
+ * \endcode
1513
+ *
1514
+ * \sa
1515
+ * ::nvtxDomainDestroy
1516
+ *
1517
+ * \version \NVTX_VERSION_2
1518
+ * @{ */
1519
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* name);
1520
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* name);
1521
+ /** @} */
1522
+
1523
+ /* ------------------------------------------------------------------------- */
1524
+ /** \brief Unregister a NVTX domain.
1525
+ *
1526
+ * Unregisters the domain handle and frees all domain specific resources.
1527
+ *
1528
+ * \param domain - the domain handle
1529
+ *
1530
+ * \par Example:
1531
+ * \code
1532
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
1533
+ * nvtxDomainDestroy(domain);
1534
+ * \endcode
1535
+ *
1536
+ * \sa
1537
+ * ::nvtxDomainCreateA
1538
+ * ::nvtxDomainCreateW
1539
+ *
1540
+ * \version \NVTX_VERSION_2
1541
+ * @{ */
1542
+ NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain);
1543
+ /** @} */
1544
+
1545
+
1546
+ /** @} */ /*END defgroup*/
1547
+ /* ========================================================================= */
1548
+ /** \cond SHOW_HIDDEN */
1549
+
1550
+ #ifdef UNICODE
1551
+ #define nvtxMark nvtxMarkW
1552
+ #define nvtxRangeStart nvtxRangeStartW
1553
+ #define nvtxRangePush nvtxRangePushW
1554
+ #define nvtxNameCategory nvtxNameCategoryW
1555
+ #define nvtxNameOsThread nvtxNameOsThreadW
1556
+ /* NVTX_VERSION_2 */
1557
+ #define nvtxDomainCreate nvtxDomainCreateW
1558
+ #define nvtxDomainRegisterString nvtxDomainRegisterStringW
1559
+ #define nvtxDomainNameCategory nvtxDomainNameCategoryW
1560
+ #else
1561
+ #define nvtxMark nvtxMarkA
1562
+ #define nvtxRangeStart nvtxRangeStartA
1563
+ #define nvtxRangePush nvtxRangePushA
1564
+ #define nvtxNameCategory nvtxNameCategoryA
1565
+ #define nvtxNameOsThread nvtxNameOsThreadA
1566
+ /* NVTX_VERSION_2 */
1567
+ #define nvtxDomainCreate nvtxDomainCreateA
1568
+ #define nvtxDomainRegisterString nvtxDomainRegisterStringA
1569
+ #define nvtxDomainNameCategory nvtxDomainNameCategoryA
1570
+ #endif
1571
+
1572
+ /** \endcond */
1573
+
1574
+ #ifdef __cplusplus
1575
+ }
1576
+ #endif /* __cplusplus */
1577
+
1578
+ #endif /* NVTOOLSEXT_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtCuda.h ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #ifndef NVTOOLSEXT_CUDA_H_
39
+ #define NVTOOLSEXT_CUDA_H_
40
+
41
+ #include "cuda.h"
42
+
43
+ #include "nvToolsExt.h"
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif /* __cplusplus */
48
+
49
+ /* ========================================================================= */
50
+ /** \name Functions for CUDA Resource Naming
51
+ */
52
+ /** \addtogroup RESOURCE_NAMING
53
+ * \section RESOURCE_NAMING_CUDA CUDA Resource Naming
54
+ *
55
+ * This section covers the API functions that allow to annotate CUDA resources
56
+ * with user-provided names.
57
+ *
58
+ * @{
59
+ */
60
+
61
+ /* ------------------------------------------------------------------------- */
62
+ /* \cond SHOW_HIDDEN
63
+ * \brief Used to build a non-colliding value for resource types separated class
64
+ * \version \NVTX_VERSION_2
65
+ */
66
+ #define NVTX_RESOURCE_CLASS_CUDA 4
67
+ /** \endcond */
68
+
69
+ /* ------------------------------------------------------------------------- */
70
+ /** \brief Resource types for CUDA
71
+ */
72
+ typedef enum nvtxResourceCUDAType_t
73
+ {
74
+ NVTX_RESOURCE_TYPE_CUDA_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDA, 1), /* CUdevice */
75
+ NVTX_RESOURCE_TYPE_CUDA_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 2), /* CUcontext */
76
+ NVTX_RESOURCE_TYPE_CUDA_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDA, 3), /* CUstream */
77
+ NVTX_RESOURCE_TYPE_CUDA_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 4) /* CUevent */
78
+ } nvtxResourceCUDAType_t;
79
+
80
+
81
+ /* ------------------------------------------------------------------------- */
82
+ /** \brief Annotates a CUDA device.
83
+ *
84
+ * Allows the user to associate a CUDA device with a user-provided name.
85
+ *
86
+ * \param device - The handle of the CUDA device to name.
87
+ * \param name - The name of the CUDA device.
88
+ *
89
+ * \version \NVTX_VERSION_1
90
+ * @{ */
91
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceA(CUdevice device, const char* name);
92
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceW(CUdevice device, const wchar_t* name);
93
+ /** @} */
94
+
95
+ /* ------------------------------------------------------------------------- */
96
+ /** \brief Annotates a CUDA context.
97
+ *
98
+ * Allows the user to associate a CUDA context with a user-provided name.
99
+ *
100
+ * \param context - The handle of the CUDA context to name.
101
+ * \param name - The name of the CUDA context.
102
+ *
103
+ * \par Example:
104
+ * \code
105
+ * CUresult status = cuCtxCreate( &cuContext, 0, cuDevice );
106
+ * if ( CUDA_SUCCESS != status )
107
+ * goto Error;
108
+ * nvtxNameCuContext(cuContext, "CTX_NAME");
109
+ * \endcode
110
+ *
111
+ * \version \NVTX_VERSION_1
112
+ * @{ */
113
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextA(CUcontext context, const char* name);
114
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextW(CUcontext context, const wchar_t* name);
115
+ /** @} */
116
+
117
+ /* ------------------------------------------------------------------------- */
118
+ /** \brief Annotates a CUDA stream.
119
+ *
120
+ * Allows the user to associate a CUDA stream with a user-provided name.
121
+ *
122
+ * \param stream - The handle of the CUDA stream to name.
123
+ * \param name - The name of the CUDA stream.
124
+ *
125
+ * \version \NVTX_VERSION_1
126
+ * @{ */
127
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamA(CUstream stream, const char* name);
128
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamW(CUstream stream, const wchar_t* name);
129
+ /** @} */
130
+
131
+ /* ------------------------------------------------------------------------- */
132
+ /** \brief Annotates a CUDA event.
133
+ *
134
+ * Allows the user to associate a CUDA event with a user-provided name.
135
+ *
136
+ * \param event - The handle of the CUDA event to name.
137
+ * \param name - The name of the CUDA event.
138
+ *
139
+ * \version \NVTX_VERSION_1
140
+ * @{ */
141
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventA(CUevent event, const char* name);
142
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventW(CUevent event, const wchar_t* name);
143
+ /** @} */
144
+
145
+ /** @} */ /* END RESOURCE_NAMING */
146
+
147
+ /* ========================================================================= */
148
+ #ifdef UNICODE
149
+ #define nvtxNameCuDevice nvtxNameCuDeviceW
150
+ #define nvtxNameCuContext nvtxNameCuContextW
151
+ #define nvtxNameCuStream nvtxNameCuStreamW
152
+ #define nvtxNameCuEvent nvtxNameCuEventW
153
+ #else
154
+ #define nvtxNameCuDevice nvtxNameCuDeviceA
155
+ #define nvtxNameCuContext nvtxNameCuContextA
156
+ #define nvtxNameCuStream nvtxNameCuStreamA
157
+ #define nvtxNameCuEvent nvtxNameCuEventA
158
+ #endif
159
+
160
+ #ifdef __cplusplus
161
+ }
162
+ #endif /* __cplusplus */
163
+
164
+ #endif /* NVTOOLSEXT_CUDA_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtCudaRt.h ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #ifndef NVTOOLSEXT_CUDART_H_
39
+ #define NVTOOLSEXT_CUDART_H_
40
+
41
+ #include "cuda.h"
42
+ #include "driver_types.h"
43
+
44
+ #include "nvToolsExt.h"
45
+
46
+ #ifdef __cplusplus
47
+ extern "C" {
48
+ #endif /* __cplusplus */
49
+
50
+ /* ========================================================================= */
51
+ /** \name Functions for CUDA Resource Naming
52
+ */
53
+ /** \addtogroup RESOURCE_NAMING
54
+ * \section RESOURCE_NAMING_CUDART CUDA Runtime Resource Naming
55
+ *
56
+ * This section covers the API functions that allow to annotate CUDA resources
57
+ * with user-provided names.
58
+ *
59
+ * @{
60
+ */
61
+
62
+ /* ------------------------------------------------------------------------- */
63
+ /* \cond SHOW_HIDDEN
64
+ * \brief Used to build a non-colliding value for resource types separated class
65
+ * \version \NVTX_VERSION_2
66
+ */
67
+ #define NVTX_RESOURCE_CLASS_CUDART 5
68
+ /** \endcond */
69
+
70
+ /* ------------------------------------------------------------------------- */
71
+ /** \brief Resource types for CUDART
72
+ */
73
+ typedef enum nvtxResourceCUDARTType_t
74
+ {
75
+ NVTX_RESOURCE_TYPE_CUDART_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDART, 0), /* int device */
76
+ NVTX_RESOURCE_TYPE_CUDART_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDART, 1), /* cudaStream_t */
77
+ NVTX_RESOURCE_TYPE_CUDART_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDART, 2) /* cudaEvent_t */
78
+ } nvtxResourceCUDARTType_t;
79
+
80
+
81
+ /* ------------------------------------------------------------------------- */
82
+ /** \brief Annotates a CUDA device.
83
+ *
84
+ * Allows the user to associate a CUDA device with a user-provided name.
85
+ *
86
+ * \param device - The id of the CUDA device to name.
87
+ * \param name - The name of the CUDA device.
88
+ *
89
+ * \version \NVTX_VERSION_1
90
+ * @{ */
91
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceA(int device, const char* name);
92
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceW(int device, const wchar_t* name);
93
+ /** @} */
94
+
95
+ /* ------------------------------------------------------------------------- */
96
+ /** \brief Annotates a CUDA stream.
97
+ *
98
+ * Allows the user to associate a CUDA stream with a user-provided name.
99
+ *
100
+ * \param stream - The handle of the CUDA stream to name.
101
+ * \param name - The name of the CUDA stream.
102
+ *
103
+ * \version \NVTX_VERSION_1
104
+ * @{ */
105
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamA(cudaStream_t stream, const char* name);
106
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamW(cudaStream_t stream, const wchar_t* name);
107
+ /** @} */
108
+
109
+ /* ------------------------------------------------------------------------- */
110
+ /** \brief Annotates a CUDA event.
111
+ *
112
+ * Allows the user to associate a CUDA event with a user-provided name.
113
+ *
114
+ * \param event - The handle of the CUDA event to name.
115
+ * \param name - The name of the CUDA event.
116
+ *
117
+ * \version \NVTX_VERSION_1
118
+ * @{ */
119
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventA(cudaEvent_t event, const char* name);
120
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventW(cudaEvent_t event, const wchar_t* name);
121
+ /** @} */
122
+
123
+ /** @} */ /* END RESOURCE_NAMING */
124
+
125
+ /* ========================================================================= */
126
+ #ifdef UNICODE
127
+ #define nvtxNameCudaDevice nvtxNameCudaDeviceW
128
+ #define nvtxNameCudaStream nvtxNameCudaStreamW
129
+ #define nvtxNameCudaEvent nvtxNameCudaEventW
130
+ #else
131
+ #define nvtxNameCudaDevice nvtxNameCudaDeviceA
132
+ #define nvtxNameCudaStream nvtxNameCudaStreamA
133
+ #define nvtxNameCudaEvent nvtxNameCudaEventA
134
+ #endif
135
+
136
+ #ifdef __cplusplus
137
+ }
138
+ #endif /* __cplusplus */
139
+
140
+ #endif /* NVTOOLSEXT_CUDART_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtOpenCL.h ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #ifndef NVTOOLSEXT_OPENCL_H_
39
+ #define NVTOOLSEXT_OPENCL_H_
40
+
41
+ #include <CL/cl.h>
42
+
43
+ #include "nvToolsExt.h"
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif /* __cplusplus */
48
+
49
+ /* ========================================================================= */
50
+ /** \name Functions for OpenCL Resource Naming
51
+ */
52
+ /** \addtogroup RESOURCE_NAMING
53
+ * \section RESOURCE_NAMING_OPENCL OpenCL Resource Naming
54
+ *
55
+ * This section covers the API functions that allow to annotate OpenCL resources
56
+ * with user-provided names.
57
+ *
58
+ * @{
59
+ */
60
+
61
+ /* ------------------------------------------------------------------------- */
62
+ /* \cond SHOW_HIDDEN
63
+ * \brief Used to build a non-colliding value for resource types separated class
64
+ * \version \NVTX_VERSION_2
65
+ */
66
+ #define NVTX_RESOURCE_CLASS_OPENCL 6
67
+ /** \endcond */
68
+
69
+ /* ------------------------------------------------------------------------- */
70
+ /** \brief Resource types for OpenCL
71
+ */
72
+ typedef enum nvtxResourceOpenCLType_t
73
+ {
74
+ NVTX_RESOURCE_TYPE_OPENCL_DEVICE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 1),
75
+ NVTX_RESOURCE_TYPE_OPENCL_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 2),
76
+ NVTX_RESOURCE_TYPE_OPENCL_COMMANDQUEUE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 3),
77
+ NVTX_RESOURCE_TYPE_OPENCL_MEMOBJECT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 4),
78
+ NVTX_RESOURCE_TYPE_OPENCL_SAMPLER = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 5),
79
+ NVTX_RESOURCE_TYPE_OPENCL_PROGRAM = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 6),
80
+ NVTX_RESOURCE_TYPE_OPENCL_EVENT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 7)
81
+ } nvtxResourceOpenCLType_t;
82
+
83
+
84
+ /* ------------------------------------------------------------------------- */
85
+ /** \brief Annotates an OpenCL device.
86
+ *
87
+ * Allows to associate an OpenCL device with a user-provided name.
88
+ *
89
+ * \param device - The handle of the OpenCL device to name.
90
+ * \param name - The name of the OpenCL device.
91
+ *
92
+ * \version \NVTX_VERSION_1
93
+ * @{ */
94
+ NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceA(cl_device_id device, const char* name);
95
+ NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceW(cl_device_id device, const wchar_t* name);
96
+ /** @} */
97
+
98
+ /* ------------------------------------------------------------------------- */
99
+ /** \brief Annotates an OpenCL context.
100
+ *
101
+ * Allows to associate an OpenCL context with a user-provided name.
102
+ *
103
+ * \param context - The handle of the OpenCL context to name.
104
+ * \param name - The name of the OpenCL context.
105
+ *
106
+ * \version \NVTX_VERSION_1
107
+ * @{ */
108
+ NVTX_DECLSPEC void NVTX_API nvtxNameClContextA(cl_context context, const char* name);
109
+ NVTX_DECLSPEC void NVTX_API nvtxNameClContextW(cl_context context, const wchar_t* name);
110
+ /** @} */
111
+
112
+ /* ------------------------------------------------------------------------- */
113
+ /** \brief Annotates an OpenCL command queue.
114
+ *
115
+ * Allows to associate an OpenCL command queue with a user-provided name.
116
+ *
117
+ * \param command_queue - The handle of the OpenCL command queue to name.
118
+ * \param name - The name of the OpenCL command queue.
119
+ *
120
+ * \version \NVTX_VERSION_1
121
+ * @{ */
122
+ NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueA(cl_command_queue command_queue, const char* name);
123
+ NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueW(cl_command_queue command_queue, const wchar_t* name);
124
+ /** @} */
125
+
126
+ /* ------------------------------------------------------------------------- */
127
+ /** \brief Annotates an OpenCL memory object.
128
+ *
129
+ * Allows to associate an OpenCL memory object with a user-provided name.
130
+ *
131
+ * \param memobj - The handle of the OpenCL memory object to name.
132
+ * \param name - The name of the OpenCL memory object.
133
+ *
134
+ * \version \NVTX_VERSION_1
135
+ * @{ */
136
+ NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectA(cl_mem memobj, const char* name);
137
+ NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectW(cl_mem memobj, const wchar_t* name);
138
+ /** @} */
139
+
140
+ /* ------------------------------------------------------------------------- */
141
+ /** \brief Annotates an OpenCL sampler.
142
+ *
143
+ * Allows to associate an OpenCL sampler with a user-provided name.
144
+ *
145
+ * \param sampler - The handle of the OpenCL sampler to name.
146
+ * \param name - The name of the OpenCL sampler.
147
+ *
148
+ * \version \NVTX_VERSION_1
149
+ * @{ */
150
+ NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerA(cl_sampler sampler, const char* name);
151
+ NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerW(cl_sampler sampler, const wchar_t* name);
152
+ /** @} */
153
+
154
+ /* ------------------------------------------------------------------------- */
155
+ /** \brief Annotates an OpenCL program.
156
+ *
157
+ * Allows to associate an OpenCL program with a user-provided name.
158
+ *
159
+ * \param program - The handle of the OpenCL program to name.
160
+ * \param name - The name of the OpenCL program.
161
+ *
162
+ * \code
163
+ * cpProgram = clCreateProgramWithSource(cxGPUContext, 1,
164
+ * (const char **) &cSourceCL, &program_length, &ciErrNum);
165
+ * shrCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
166
+ * nvtxNameClProgram(cpProgram, L"PROGRAM_NAME");
167
+ * \endcode
168
+ *
169
+ * \version \NVTX_VERSION_1
170
+ * @{ */
171
+ NVTX_DECLSPEC void NVTX_API nvtxNameClProgramA(cl_program program, const char* name);
172
+ NVTX_DECLSPEC void NVTX_API nvtxNameClProgramW(cl_program program, const wchar_t* name);
173
+ /** @} */
174
+
175
+ /* ------------------------------------------------------------------------- */
176
+ /** \brief Annotates an OpenCL event.
177
+ *
178
+ * Allows to associate an OpenCL event with a user-provided name.
179
+ *
180
+ * \param evnt - The handle of the OpenCL event to name.
181
+ * \param name - The name of the OpenCL event.
182
+ *
183
+ * \version \NVTX_VERSION_1
184
+ * @{ */
185
+ NVTX_DECLSPEC void NVTX_API nvtxNameClEventA(cl_event evnt, const char* name);
186
+ NVTX_DECLSPEC void NVTX_API nvtxNameClEventW(cl_event evnt, const wchar_t* name);
187
+ /** @} */
188
+
189
+ /** @} */ /* END RESOURCE_NAMING */
190
+
191
+ /* ========================================================================= */
192
+ #ifdef UNICODE
193
+ #define nvtxNameClDevice nvtxNameClDeviceW
194
+ #define nvtxNameClContext nvtxNameClContextW
195
+ #define nvtxNameClCommandQueue nvtxNameClCommandQueueW
196
+ #define nvtxNameClMemObject nvtxNameClMemObjectW
197
+ #define nvtxNameClSampler nvtxNameClSamplerW
198
+ #define nvtxNameClProgram nvtxNameClProgramW
199
+ #define nvtxNameClEvent nvtxNameClEventW
200
+ #else
201
+ #define nvtxNameClDevice nvtxNameClDeviceA
202
+ #define nvtxNameClContext nvtxNameClContextA
203
+ #define nvtxNameClCommandQueue nvtxNameClCommandQueueA
204
+ #define nvtxNameClMemObject nvtxNameClMemObjectA
205
+ #define nvtxNameClSampler nvtxNameClSamplerA
206
+ #define nvtxNameClProgram nvtxNameClProgramA
207
+ #define nvtxNameClEvent nvtxNameClEventA
208
+ #endif
209
+
210
+ #ifdef __cplusplus
211
+ }
212
+ #endif /* __cplusplus */
213
+
214
+ #endif /* NVTOOLSEXT_OPENCL_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvToolsExtSync.h ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #ifndef NVTOOLSEXT_SYNC_H_
39
+ #define NVTOOLSEXT_SYNC_H_
40
+
41
+ #include "nvToolsExt.h"
42
+
43
+
44
+ #ifdef __cplusplus
45
+ extern "C" {
46
+ #endif /* __cplusplus */
47
+
48
+ /* \cond SHOW_HIDDEN
49
+ * \version \NVTX_VERSION_2
50
+ */
51
+ #define NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxSyncUserAttributes_v0) ) )
52
+ /** \endcond */
53
+
54
+
55
+ /**
56
+ * \page PAGE_SYNCHRONIZATION Synchronization
57
+ *
58
+ * This section covers a subset of the API that allow users to track additional
59
+ * synchronization details of their application. Naming OS synchronization primitives
60
+ * may allow users to better understand the data collected by traced synchronization
61
+ * APIs. Additionally, a user defined synchronization object can allow the users to
62
+ * to tell the tools when the user is building their own synchronization system
63
+ * that do not rely on the OS to provide behaviors and instead use techniques like
64
+ * atomic operations and spinlocks.
65
+ *
66
+ * See module \ref SYNCHRONIZATION for details.
67
+ *
68
+ * \par Example:
69
+ * \code
70
+ * class MyMutex
71
+ * {
72
+ * volatile long bLocked;
73
+ * nvtxSyncUser_t hSync;
74
+ * public:
75
+ * MyMutex(const char* name, nvtxDomainHandle_t d){
76
+ * bLocked = 0;
77
+ *
78
+ * nvtxSyncUserAttributes_t attribs = { 0 };
79
+ * attribs.version = NVTX_VERSION;
80
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
81
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
82
+ * attribs.message.ascii = name;
83
+ * hSync = nvtxDomainSyncUserCreate(d, &attribs);
84
+ * }
85
+ *
86
+ * ~MyMutex() {
87
+ * nvtxDomainSyncUserDestroy(hSync);
88
+ * }
89
+ *
90
+ * bool Lock() {
91
+ * nvtxDomainSyncUserAcquireStart(hSync);
92
+ * bool acquired = __sync_bool_compare_and_swap(&bLocked, 0, 1);//atomic compiler intrinsic
93
+
94
+ * if (acquired) {
95
+ * nvtxDomainSyncUserAcquireSuccess(hSync);
96
+ * }
97
+ * else {
98
+ * nvtxDomainSyncUserAcquireFailed(hSync);
99
+ * }
100
+ * return acquired;
101
+ * }
102
+
103
+ * void Unlock() {
104
+ * nvtxDomainSyncUserReleasing(hSync);
105
+ * bLocked = false;
106
+ * }
107
+ * };
108
+ * \endcode
109
+ *
110
+ * \version \NVTX_VERSION_2
111
+ */
112
+
113
+ /* ------------------------------------------------------------------------- */
114
+ /* \cond SHOW_HIDDEN
115
+ * \brief Used to build a non-colliding value for resource types separated class
116
+ * \version \NVTX_VERSION_2
117
+ */
118
+ #define NVTX_RESOURCE_CLASS_SYNC_OS 2 /**< Synchronization objects that are OS specific. */
119
+ #define NVTX_RESOURCE_CLASS_SYNC_PTHREAD 3 /**< Synchronization objects that are from the POSIX Threads API (pthread)*/
120
+ /** \endcond */
121
+
122
+
123
+ /* ------------------------------------------------------------------------- */
124
+ /** \defgroup SYNCHRONIZATION Synchronization
125
+ * See page \ref PAGE_SYNCHRONIZATION.
126
+ * @{
127
+ */
128
+
129
+ /** \brief Resource type values for OSs with POSIX Thread API support
130
+ */
131
+ typedef enum nvtxResourceSyncPosixThreadType_t
132
+ {
133
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 1), /* pthread_mutex_t */
134
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_CONDITION = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 2), /* pthread_cond_t */
135
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_RWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 3), /* pthread_rwlock_t */
136
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_BARRIER = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 4), /* pthread_barrier_t */
137
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 5), /* pthread_spinlock_t */
138
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_ONCE = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 6) /* pthread_once_t */
139
+ } nvtxResourceSyncPosixThreadType_t;
140
+
141
+ /** \brief Resource type values for Windows OSs
142
+ */
143
+ typedef enum nvtxResourceSyncWindowsType_t
144
+ {
145
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
146
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
147
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_EVENT = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
148
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_CRITICAL_SECTION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
149
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SRWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5)
150
+ } nvtxResourceSyncWindowsType_t;
151
+
152
+ /** \brief Resource type values for Linux and Linux derived OSs such as Android
153
+ * \sa
154
+ * ::nvtxResourceSyncPosixThreadType_t
155
+ */
156
+ typedef enum nvtxResourceSyncLinuxType_t
157
+ {
158
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
159
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_FUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
160
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
161
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_COMPLETION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
162
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5),
163
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SEQLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 6),
164
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_RCU = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 7)
165
+ } nvtxResourceSyncLinuxType_t;
166
+
167
+ /** \brief Resource type values for Android come from Linux.
168
+ * \sa
169
+ * ::nvtxResourceSyncLinuxType_t
170
+ * ::nvtxResourceSyncPosixThreadType_t
171
+ */
172
+ typedef enum nvtxResourceSyncLinuxType_t nvtxResourceSyncAndroidType_t;
173
+
174
+ /** \brief User Defined Synchronization Object Handle .
175
+ * \anchor SYNCUSER_HANDLE_STRUCTURE
176
+ *
177
+ * This structure is opaque to the user and is used as a handle to reference
178
+ * a user defined syncrhonization object. The tools will return a pointer through the API for the application
179
+ * to hold on it's behalf to reference the string in the future.
180
+ *
181
+ */
182
+ typedef struct nvtxSyncUser* nvtxSyncUser_t;
183
+
184
+ /** \brief User Defined Synchronization Object Attributes Structure.
185
+ * \anchor USERDEF_SYNC_ATTRIBUTES_STRUCTURE
186
+ *
187
+ * This structure is used to describe the attributes of a user defined synchronization
188
+ * object. The layout of the structure is defined by a specific version of the tools
189
+ * extension library and can change between different versions of the Tools Extension
190
+ * library.
191
+ *
192
+ * \par Initializing the Attributes
193
+ *
194
+ * The caller should always perform the following three tasks when using
195
+ * attributes:
196
+ * <ul>
197
+ * <li>Zero the structure
198
+ * <li>Set the version field
199
+ * <li>Set the size field
200
+ * </ul>
201
+ *
202
+ * Zeroing the structure sets all the event attributes types and values
203
+ * to the default value.
204
+ *
205
+ * The version and size field are used by the Tools Extension
206
+ * implementation to handle multiple versions of the attributes structure.
207
+ *
208
+ * It is recommended that the caller use one of the following to methods
209
+ * to initialize the event attributes structure:
210
+ *
211
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
212
+ * \code
213
+ * nvtxSyncUserAttributes_t attribs = {0};
214
+ * attribs.version = NVTX_VERSION;
215
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
216
+ * \endcode
217
+ *
218
+ * \par Method 2: Initializing nvtxSyncUserAttributes_t for a specific version
219
+ * \code
220
+ * nvtxSyncUserAttributes_t attribs = {0};
221
+ * attribs.version = 1;
222
+ * attribs.size = (uint16_t)(sizeof(nvtxSyncUserAttributes_t));
223
+ * \endcode
224
+ *
225
+ * If the caller uses Method 1 it is critical that the entire binary
226
+ * layout of the structure be configured to 0 so that all fields
227
+ * are initialized to the default value.
228
+ *
229
+ * The caller should either use both NVTX_VERSION and
230
+ * NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
231
+ * and a versioned type (Method 2). Using a mix of the two methods
232
+ * will likely cause either source level incompatibility or binary
233
+ * incompatibility in the future.
234
+ *
235
+ * \par Settings Attribute Types and Values
236
+ *
237
+ *
238
+ * \par Example:
239
+ * \code
240
+ * // Initialize
241
+ * nvtxSyncUserAttributes_t attribs = {0};
242
+ * attribs.version = NVTX_VERSION;
243
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
244
+ *
245
+ * // Configure the Attributes
246
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
247
+ * attribs.message.ascii = "Example";
248
+ * \endcode
249
+ *
250
+ * \sa
251
+ * ::nvtxDomainSyncUserCreate
252
+ */
253
+ typedef struct nvtxSyncUserAttributes_v0
254
+ {
255
+ /**
256
+ * \brief Version flag of the structure.
257
+ *
258
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
259
+ * supported in this header file. This can optionally be overridden to
260
+ * another version of the tools extension library.
261
+ */
262
+ uint16_t version;
263
+
264
+ /**
265
+ * \brief Size of the structure.
266
+ *
267
+ * Needs to be set to the size in bytes of the event attribute
268
+ * structure used to specify the event.
269
+ */
270
+ uint16_t size;
271
+
272
+ /** \brief Message type specified in this attribute structure.
273
+ *
274
+ * Defines the message format of the attribute structure's \ref nvtxSyncUserAttributes_v0::message
275
+ * "message" field.
276
+ *
277
+ * Default Value is NVTX_MESSAGE_UNKNOWN
278
+ */
279
+ int32_t messageType; /* nvtxMessageType_t */
280
+
281
+ /** \brief Message assigned to this attribute structure.
282
+ *
283
+ * The text message that is attached to an event.
284
+ */
285
+ nvtxMessageValue_t message;
286
+
287
+ } nvtxSyncUserAttributes_v0;
288
+
289
+ typedef struct nvtxSyncUserAttributes_v0 nvtxSyncUserAttributes_t;
290
+
291
+ /* ------------------------------------------------------------------------- */
292
+ /** \brief Create a user defined synchronization object
293
+ * This is used to track non-OS synchronization working with spinlocks and atomics
294
+ *
295
+ * \param domain - Domain to own the resource
296
+ * \param attribs - A structure to assign multiple attributes to the object.
297
+ *
298
+ * \return A handle that represents the newly created user defined synchronization object.
299
+ *
300
+ * \sa
301
+ * ::nvtxDomainSyncUserCreate
302
+ * ::nvtxDomainSyncUserDestroy
303
+ * ::nvtxDomainSyncUserAcquireStart
304
+ * ::nvtxDomainSyncUserAcquireFailed
305
+ * ::nvtxDomainSyncUserAcquireSuccess
306
+ * ::nvtxDomainSyncUserReleasing
307
+ *
308
+ * \version \NVTX_VERSION_2
309
+ */
310
+ NVTX_DECLSPEC nvtxSyncUser_t NVTX_API nvtxDomainSyncUserCreate(nvtxDomainHandle_t domain, const nvtxSyncUserAttributes_t* attribs);
311
+
312
+ /* ------------------------------------------------------------------------- */
313
+ /** \brief Destroy a user defined synchronization object
314
+ * This is used to track non-OS synchronization working with spinlocks and atomics
315
+ *
316
+ * \param handle - A handle to the object to operate on.
317
+ *
318
+ * \sa
319
+ * ::nvtxDomainSyncUserCreate
320
+ * ::nvtxDomainSyncUserDestroy
321
+ * ::nvtxDomainSyncUserAcquireStart
322
+ * ::nvtxDomainSyncUserAcquireFailed
323
+ * ::nvtxDomainSyncUserAcquireSuccess
324
+ * ::nvtxDomainSyncUserReleasing
325
+ *
326
+ * \version \NVTX_VERSION_2
327
+ */
328
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserDestroy(nvtxSyncUser_t handle);
329
+
330
+ /* ------------------------------------------------------------------------- */
331
+ /** \brief Signal to tools that an attempt to acquire a user defined synchronization object
332
+ *
333
+ * \param handle - A handle to the object to operate on.
334
+ *
335
+ * \sa
336
+ * ::nvtxDomainSyncUserCreate
337
+ * ::nvtxDomainSyncUserDestroy
338
+ * ::nvtxDomainSyncUserAcquireStart
339
+ * ::nvtxDomainSyncUserAcquireFailed
340
+ * ::nvtxDomainSyncUserAcquireSuccess
341
+ * ::nvtxDomainSyncUserReleasing
342
+ *
343
+ * \version \NVTX_VERSION_2
344
+ */
345
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireStart(nvtxSyncUser_t handle);
346
+
347
+ /* ------------------------------------------------------------------------- */
348
+ /** \brief Signal to tools of failure in acquiring a user defined synchronization object
349
+ * This should be called after \ref nvtxDomainSyncUserAcquireStart
350
+ *
351
+ * \param handle - A handle to the object to operate on.
352
+ *
353
+ * \sa
354
+ * ::nvtxDomainSyncUserCreate
355
+ * ::nvtxDomainSyncUserDestroy
356
+ * ::nvtxDomainSyncUserAcquireStart
357
+ * ::nvtxDomainSyncUserAcquireFailed
358
+ * ::nvtxDomainSyncUserAcquireSuccess
359
+ * ::nvtxDomainSyncUserReleasing
360
+ *
361
+ * \version \NVTX_VERSION_2
362
+ */NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireFailed(nvtxSyncUser_t handle);
363
+
364
+ /* ------------------------------------------------------------------------- */
365
+ /** \brief Signal to tools of success in acquiring a user defined synchronization object
366
+ * This should be called after \ref nvtxDomainSyncUserAcquireStart.
367
+ *
368
+ * \param handle - A handle to the object to operate on.
369
+ *
370
+ * \sa
371
+ * ::nvtxDomainSyncUserCreate
372
+ * ::nvtxDomainSyncUserDestroy
373
+ * ::nvtxDomainSyncUserAcquireStart
374
+ * ::nvtxDomainSyncUserAcquireFailed
375
+ * ::nvtxDomainSyncUserAcquireSuccess
376
+ * ::nvtxDomainSyncUserReleasing
377
+ *
378
+ * \version \NVTX_VERSION_2
379
+ */NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireSuccess(nvtxSyncUser_t handle);
380
+
381
+ /* ------------------------------------------------------------------------- */
382
+ /** \brief Signal to tools of releasing a reservation on user defined synchronization object
383
+ * This should be called after \ref nvtxDomainSyncUserAcquireSuccess.
384
+ *
385
+ * \param handle - A handle to the object to operate on.
386
+ *
387
+ * \sa
388
+ * ::nvtxDomainSyncUserCreate
389
+ * ::nvtxDomainSyncUserDestroy
390
+ * ::nvtxDomainSyncUserAcquireStart
391
+ * ::nvtxDomainSyncUserAcquireFailed
392
+ * ::nvtxDomainSyncUserAcquireSuccess
393
+ * ::nvtxDomainSyncUserReleasing
394
+ *
395
+ * \version \NVTX_VERSION_2
396
+ */
397
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserReleasing(nvtxSyncUser_t handle);
398
+
399
+
400
+ /** @} */ /*END defgroup*/
401
+
402
+ #ifdef __cplusplus
403
+ }
404
+ #endif /* __cplusplus */
405
+
406
+ #endif /* NVTOOLSEXT_SYNC_H_ */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExt.h ADDED
@@ -0,0 +1,1499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ /** \file nvToolsExt.h
39
+ */
40
+
41
+ /* ========================================================================= */
42
+ /** \mainpage
43
+ * \tableofcontents
44
+ * \section INTRODUCTION Introduction
45
+ *
46
+ * The NVIDIA Tools Extension library is a set of functions that a
47
+ * developer can use to provide additional information to tools.
48
+ * The additional information is used by the tool to improve
49
+ * analysis and visualization of data.
50
+ *
51
+ * The library introduces close to zero overhead if no tool is
52
+ * attached to the application. The overhead when a tool is
53
+ * attached is specific to the tool.
54
+ *
55
+ * \section INITIALIZATION_SECTION Initialization
56
+ *
57
+ * Typically the tool's library that plugs into NVTX is indirectly
58
+ * loaded via enviromental properties that are platform specific.
59
+ * For some platform or special cases, the user may be required
60
+ * to instead explicity initialize instead though. This can also
61
+ * be helpful to control when the API loads a tool's library instead
62
+ * of what would typically be the first function call to emit info.
63
+ * For these rare case, see \ref INITIALIZATION for additional information.
64
+ *
65
+ * \section MARKERS_AND_RANGES Markers and Ranges
66
+ *
67
+ * Markers and ranges are used to describe events at a specific time (markers)
68
+ * or over a time span (ranges) during the execution of the application
69
+ * respectively.
70
+ *
71
+ * \subsection MARKERS Markers
72
+ *
73
+ * Markers denote specific moments in time.
74
+ *
75
+ *
76
+ * See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
77
+ * how to specify the domain.
78
+ *
79
+ * \subsection THREAD_RANGES Thread Ranges
80
+ *
81
+ * Thread ranges denote nested time ranges. Nesting is maintained per thread
82
+ * per domain and does not require any additional correlation mechanism. The
83
+ * duration of a thread range is defined by the corresponding pair of
84
+ * nvtxRangePush* to nvtxRangePop API calls.
85
+ *
86
+ * See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
87
+ * how to specify the domain.
88
+ *
89
+ * \subsection PROCESS_RANGES Process Ranges
90
+ *
91
+ * Process ranges denote a time span that can expose arbitrary concurrency, as
92
+ * opposed to thread ranges that only support nesting. In addition the range
93
+ * start event can happen on a different thread than the end marker. For the
94
+ * correlation of a start/end pair an unique correlation ID is used that is
95
+ * returned from the start API call and needs to be passed into the end API
96
+ * call.
97
+ *
98
+ * \subsection EVENT_ATTRIBUTES Event Attributes
99
+ *
100
+ * \ref MARKERS_AND_RANGES can be annotated with various attributes to provide
101
+ * additional information for an event or to guide the tool's visualization of
102
+ * the data. Each of the attributes is optional and if left unused the
103
+ * attributes fall back to a default value. The attributes include:
104
+ * - color
105
+ * - category
106
+ *
107
+ * To specify any attribute other than the text message, the \ref
108
+ * EVENT_ATTRIBUTE_STRUCTURE "Event Attribute Structure" must be used.
109
+ *
110
+ * \section DOMAINS Domains
111
+ *
112
+ * Domains enable developers to scope annotations. By default all events and
113
+ * annotations are in the default domain. Additional domains can be registered.
114
+ * This allows developers to scope markers, ranges, and resources names to
115
+ * avoid conflicts.
116
+ *
117
+ * The function ::nvtxDomainCreateA or ::nvtxDomainCreateW is used to create
118
+ * a named domain.
119
+ *
120
+ * Each domain maintains its own
121
+ * - categories
122
+ * - thread range stacks
123
+ * - registered strings
124
+ *
125
+ * The function ::nvtxDomainDestroy marks the end of the domain. Destroying
126
+ * a domain unregisters and destroys all objects associated with it such as
127
+ * registered strings, resource objects, named categories, and started ranges.
128
+ *
129
+ * \section RESOURCE_NAMING Resource Naming
130
+ *
131
+ * This section covers calls that allow to annotate objects with user-provided
132
+ * names in order to allow for a better analysis of complex trace data. All of
133
+ * the functions take the handle or the ID of the object to name and the name.
134
+ * The functions can be called multiple times during the execution of an
135
+ * application, however, in that case it is implementation dependent which
136
+ * name will be reported by the tool.
137
+ *
138
+ * \subsection CATEGORY_NAMING Category Naming
139
+ *
140
+ * Some function in this library support associating an integer category
141
+ * to enable filtering and sorting. The category naming functions allow
142
+ * the application to associate a user friendly name with the integer
143
+ * category. Support for domains have been added in NVTX_VERSION_2 to
144
+ * avoid collisions when domains are developed independantly.
145
+ *
146
+ * \subsection RESOURCE_OBJECTS Resource Objects
147
+ *
148
+ * Resource objects are a generic mechanism for attaching data to an application
149
+ * resource. The identifier field makes the association to a pointer or handle,
150
+ * while the type field helps provide deeper understanding of the identifier as
151
+ * well as enabling differentiation in cases where handles generated by different
152
+ * APIs may collide. The resource object may also have an associated message to
153
+ * associate with the application resource, enabling further annotation of this
154
+ * object and how it is used.
155
+ *
156
+ * The resource object was introduced in NVTX_VERSION_2 to supersede existing naming
157
+ * functions and allow the application resource identified by those functions to be
158
+ * associated to a domain. The other naming functions are still supported for backward
159
+ * compatibility but will be associated only to the default domain.
160
+ *
161
+ * \subsection RESOURCE_NAMING_OS Resource Naming
162
+ *
163
+ * Some operating system resources creation APIs do not support providing a user friendly
164
+ * name, such as some OS thread creation APIs. This API support resource naming though
165
+ * both through resource objects and functions following the pattern
166
+ * nvtxName[RESOURCE_TYPE][A|W](identifier, name). Resource objects introduced in NVTX_VERSION 2
167
+ * supersede the other functions with a a more general method of assigning names to OS resources,
168
+ * along with associating them to domains too. The older nvtxName* functions are only associated
169
+ * with the default domain.
170
+ * \section EXTENSIONS Optional Extensions
171
+ * Optional extensions will either appear within the existing sections the extend or appear
172
+ * in the "Related Pages" when they introduce new concepts.
173
+ */
174
+
175
+ /**
176
+ * Tools Extension API version
177
+ */
178
+ #if defined(NVTX_VERSION) && NVTX_VERSION < 3
179
+ #error "Trying to #include NVTX version 3 in a source file where an older NVTX version has already been included. If you are not directly using NVTX (the NVIDIA Tools Extension library), you are getting this error because libraries you are using have included different versions of NVTX. Suggested solutions are: (1) reorder #includes so the newest NVTX version is included first, (2) avoid using the conflicting libraries in the same .c/.cpp file, or (3) update the library using the older NVTX version to use the newer version instead."
180
+ #endif
181
+
182
+ /* Header guard */
183
+ #if !defined(NVTX_VERSION)
184
+ #define NVTX_VERSION 3
185
+
186
+ #if defined(_MSC_VER)
187
+ #define NVTX_API __stdcall
188
+ #define NVTX_INLINE_STATIC __inline static
189
+ #else /*defined(__GNUC__)*/
190
+ #define NVTX_API
191
+ #define NVTX_INLINE_STATIC inline static
192
+ #endif /* Platform */
193
+
194
+ #if defined(NVTX_NO_IMPL)
195
+ /* When omitting implementation, avoid declaring functions inline */
196
+ /* without definitions, since this causes compiler warnings. */
197
+ #define NVTX_DECLSPEC
198
+ #elif defined(NVTX_EXPORT_API)
199
+ /* Allow overriding definition of NVTX_DECLSPEC when exporting API. */
200
+ /* Default is empty, meaning non-inline with external linkage. */
201
+ #if !defined(NVTX_DECLSPEC)
202
+ #define NVTX_DECLSPEC
203
+ #endif
204
+ #else
205
+ /* Normal NVTX usage defines the NVTX API inline with static */
206
+ /* (internal) linkage. */
207
+ #define NVTX_DECLSPEC NVTX_INLINE_STATIC
208
+ #endif
209
+
210
+ #include "nvtxDetail/nvtxLinkOnce.h"
211
+
212
+ #define NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION) NAME##_v##VERSION
213
+ #define NVTX_VERSIONED_IDENTIFIER_L2(NAME, VERSION) NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION)
214
+ #define NVTX_VERSIONED_IDENTIFIER(NAME) NVTX_VERSIONED_IDENTIFIER_L2(NAME, NVTX_VERSION)
215
+
216
+ /**
217
+ * The nvToolsExt library depends on stdint.h. If the build tool chain in use
218
+ * does not include stdint.h then define NVTX_STDINT_TYPES_ALREADY_DEFINED
219
+ * and define the following types:
220
+ * <ul>
221
+ * <li>uint8_t
222
+ * <li>int8_t
223
+ * <li>uint16_t
224
+ * <li>int16_t
225
+ * <li>uint32_t
226
+ * <li>int32_t
227
+ * <li>uint64_t
228
+ * <li>int64_t
229
+ * <li>uintptr_t
230
+ * <li>intptr_t
231
+ * </ul>
232
+ * #define NVTX_STDINT_TYPES_ALREADY_DEFINED if you are using your own header file.
233
+ */
234
+ #ifndef NVTX_STDINT_TYPES_ALREADY_DEFINED
235
+ #include <stdint.h>
236
+ #endif
237
+
238
+ #include <stddef.h>
239
+
240
+ #ifdef __cplusplus
241
+ extern "C" {
242
+ #endif /* __cplusplus */
243
+
244
+ /**
245
+ * Result Codes
246
+ */
247
+
248
+ #define NVTX_SUCCESS 0
249
+ #define NVTX_FAIL 1
250
+ #define NVTX_ERR_INIT_LOAD_PROPERTY 2
251
+ #define NVTX_ERR_INIT_ACCESS_LIBRARY 3
252
+ #define NVTX_ERR_INIT_LOAD_LIBRARY 4
253
+ #define NVTX_ERR_INIT_MISSING_LIBRARY_ENTRY_POINT 5
254
+ #define NVTX_ERR_INIT_FAILED_LIBRARY_ENTRY_POINT 6
255
+ #define NVTX_ERR_NO_INJECTION_LIBRARY_AVAILABLE 7
256
+
257
+ /**
258
+ * Size of the nvtxEventAttributes_t structure.
259
+ */
260
+ #define NVTX_EVENT_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxEventAttributes_t) ) )
261
+
262
+ #define NVTX_NO_PUSH_POP_TRACKING ((int)-2)
263
+
264
+ typedef uint64_t nvtxRangeId_t;
265
+
266
+ /* Forward declaration of opaque domain registration structure */
267
+ struct nvtxDomainRegistration_st;
268
+ typedef struct nvtxDomainRegistration_st nvtxDomainRegistration;
269
+
270
+ /* \brief Domain Handle Structure.
271
+ * \anchor DOMAIN_HANDLE_STRUCTURE
272
+ *
273
+ * This structure is opaque to the user and is used as a handle to reference
274
+ * a domain. This type is returned from tools when using the NVTX API to
275
+ * create a domain.
276
+ *
277
+ */
278
+ typedef nvtxDomainRegistration* nvtxDomainHandle_t;
279
+
280
+ /* Forward declaration of opaque string registration structure */
281
+ struct nvtxStringRegistration_st;
282
+ typedef struct nvtxStringRegistration_st nvtxStringRegistration;
283
+
284
+ /* \brief Registered String Handle Structure.
285
+ * \anchor REGISTERED_STRING_HANDLE_STRUCTURE
286
+ *
287
+ * This structure is opaque to the user and is used as a handle to reference
288
+ * a registered string. This type is returned from tools when using the NVTX
289
+ * API to create a registered string.
290
+ *
291
+ */
292
+ typedef nvtxStringRegistration* nvtxStringHandle_t;
293
+
294
+ /* ========================================================================= */
295
+ /** \defgroup GENERAL General
296
+ * @{
297
+ */
298
+
299
+ /** ---------------------------------------------------------------------------
300
+ * Color Types
301
+ * ------------------------------------------------------------------------- */
302
+ typedef enum nvtxColorType_t
303
+ {
304
+ NVTX_COLOR_UNKNOWN = 0, /**< Color attribute is unused. */
305
+ NVTX_COLOR_ARGB = 1 /**< An ARGB color is provided. */
306
+ } nvtxColorType_t;
307
+
308
+ /** ---------------------------------------------------------------------------
309
+ * Message Types
310
+ * ------------------------------------------------------------------------- */
311
+ typedef enum nvtxMessageType_t
312
+ {
313
+ NVTX_MESSAGE_UNKNOWN = 0, /**< Message payload is unused. */
314
+ NVTX_MESSAGE_TYPE_ASCII = 1, /**< A character sequence is used as payload. */
315
+ NVTX_MESSAGE_TYPE_UNICODE = 2, /**< A wide character sequence is used as payload. */
316
+ /* NVTX_VERSION_2 */
317
+ NVTX_MESSAGE_TYPE_REGISTERED = 3, /**< A unique string handle that was registered
318
+ with \ref nvtxDomainRegisterStringA() or
319
+ \ref nvtxDomainRegisterStringW(). */
320
+ } nvtxMessageType_t;
321
+
322
+ typedef union nvtxMessageValue_t
323
+ {
324
+ const char* ascii;
325
+ const wchar_t* unicode;
326
+ /* NVTX_VERSION_2 */
327
+ nvtxStringHandle_t registered;
328
+ } nvtxMessageValue_t;
329
+
330
+
331
+ /** @} */ /*END defgroup*/
332
+ /* ------------------------------------------------------------------------- */
333
+ /** \brief Force initialization (optional)
334
+ *
335
+ * Force NVTX library to initialize. The first call to any NVTX API function
336
+ * will automatically initialize the entire API. This can make the first call
337
+ * much slower than subsequent calls. In applications where the first call to
338
+ * NVTX may be in a performance-critical section, calling nvtxInitialize before
339
+ * any performance-critical sections will ensure NVTX initialization occurs at
340
+ * an acceptable time. Since nvtxInitialize takes no parameters and has no
341
+ * expected behavior besides initialization, it is convenient to add a call to
342
+ * nvtxInitialize in NVTX-instrumented applications that need to force earlier
343
+ * initialization without changing any other code. For example, if an app's
344
+ * first NVTX call is nvtxDomainCreate, and it is difficult to move that call
345
+ * earlier because the domain handle must be stored in an object only created
346
+ * at that point, adding a call to nvtxInitialize at the top of main() will
347
+ * ensure the later call to nvtxDomainCreate is as fast as possible.
348
+ *
349
+ * \version \NVTX_VERSION_3
350
+ *
351
+ * \param reserved - must be zero or NULL.
352
+ *
353
+ * @{ */
354
+ NVTX_DECLSPEC void NVTX_API nvtxInitialize(const void* reserved);
355
+ /** @} */
356
+
357
+
358
+ /** @} */ /*END defgroup*/
359
+
360
+ /* ========================================================================= */
361
+ /** \defgroup EVENT_ATTRIBUTES Event Attributes
362
+ * @{
363
+ */
364
+
365
+ /** ---------------------------------------------------------------------------
366
+ * Payload Types
367
+ * ------------------------------------------------------------------------- */
368
+ typedef enum nvtxPayloadType_t
369
+ {
370
+ NVTX_PAYLOAD_UNKNOWN = 0, /**< Color payload is unused. */
371
+ NVTX_PAYLOAD_TYPE_UNSIGNED_INT64 = 1, /**< A 64 bit unsigned integer value is used as payload. */
372
+ NVTX_PAYLOAD_TYPE_INT64 = 2, /**< A 64 bit signed integer value is used as payload. */
373
+ NVTX_PAYLOAD_TYPE_DOUBLE = 3, /**< A 64 bit floating point value is used as payload. */
374
+ /* NVTX_VERSION_2 */
375
+ NVTX_PAYLOAD_TYPE_UNSIGNED_INT32 = 4, /**< A 32 bit floating point value is used as payload. */
376
+ NVTX_PAYLOAD_TYPE_INT32 = 5, /**< A 32 bit floating point value is used as payload. */
377
+ NVTX_PAYLOAD_TYPE_FLOAT = 6 /**< A 32 bit floating point value is used as payload. */
378
+ } nvtxPayloadType_t;
379
+
380
+ /** \brief Event Attribute Structure.
381
+ * \anchor EVENT_ATTRIBUTE_STRUCTURE
382
+ *
383
+ * This structure is used to describe the attributes of an event. The layout of
384
+ * the structure is defined by a specific version of the tools extension
385
+ * library and can change between different versions of the Tools Extension
386
+ * library.
387
+ *
388
+ * \par Initializing the Attributes
389
+ *
390
+ * The caller should always perform the following three tasks when using
391
+ * attributes:
392
+ * <ul>
393
+ * <li>Zero the structure
394
+ * <li>Set the version field
395
+ * <li>Set the size field
396
+ * </ul>
397
+ *
398
+ * Zeroing the structure sets all the event attributes types and values
399
+ * to the default value.
400
+ *
401
+ * The version and size field are used by the Tools Extension
402
+ * implementation to handle multiple versions of the attributes structure.
403
+ *
404
+ * It is recommended that the caller use one of the following to methods
405
+ * to initialize the event attributes structure:
406
+ *
407
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
408
+ * \code
409
+ * nvtxEventAttributes_t eventAttrib = {0};
410
+ * eventAttrib.version = NVTX_VERSION;
411
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
412
+ * \endcode
413
+ *
414
+ * \par Method 2: Initializing nvtxEventAttributes for a specific version
415
+ * \code
416
+ * nvtxEventAttributes_t eventAttrib = {0};
417
+ * eventAttrib.version = 1;
418
+ * eventAttrib.size = (uint16_t)(sizeof(nvtxEventAttributes_v1));
419
+ * \endcode
420
+ *
421
+ * If the caller uses Method 1 it is critical that the entire binary
422
+ * layout of the structure be configured to 0 so that all fields
423
+ * are initialized to the default value.
424
+ *
425
+ * The caller should either use both NVTX_VERSION and
426
+ * NVTX_EVENT_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
427
+ * and a versioned type (Method 2). Using a mix of the two methods
428
+ * will likely cause either source level incompatibility or binary
429
+ * incompatibility in the future.
430
+ *
431
+ * \par Settings Attribute Types and Values
432
+ *
433
+ *
434
+ * \par Example:
435
+ * \code
436
+ * // Initialize
437
+ * nvtxEventAttributes_t eventAttrib = {0};
438
+ * eventAttrib.version = NVTX_VERSION;
439
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
440
+ *
441
+ * // Configure the Attributes
442
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
443
+ * eventAttrib.color = 0xFF880000;
444
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
445
+ * eventAttrib.message.ascii = "Example";
446
+ * \endcode
447
+ *
448
+ * In the example the caller does not have to set the value of
449
+ * \ref ::nvtxEventAttributes_v2::category or
450
+ * \ref ::nvtxEventAttributes_v2::payload as these fields were set to
451
+ * the default value by {0}.
452
+ * \sa
453
+ * ::nvtxDomainMarkEx
454
+ * ::nvtxDomainRangeStartEx
455
+ * ::nvtxDomainRangePushEx
456
+ */
457
+ typedef struct nvtxEventAttributes_v2
458
+ {
459
+ /**
460
+ * \brief Version flag of the structure.
461
+ *
462
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
463
+ * supported in this header file. This can optionally be overridden to
464
+ * another version of the tools extension library.
465
+ */
466
+ uint16_t version;
467
+
468
+ /**
469
+ * \brief Size of the structure.
470
+ *
471
+ * Needs to be set to the size in bytes of the event attribute
472
+ * structure used to specify the event.
473
+ */
474
+ uint16_t size;
475
+
476
+ /**
477
+ * \brief ID of the category the event is assigned to.
478
+ *
479
+ * A category is a user-controlled ID that can be used to group
480
+ * events. The tool may use category IDs to improve filtering or
481
+ * enable grouping of events in the same category. The functions
482
+ * \ref ::nvtxNameCategoryA or \ref ::nvtxNameCategoryW can be used
483
+ * to name a category.
484
+ *
485
+ * Default Value is 0
486
+ */
487
+ uint32_t category;
488
+
489
+ /** \brief Color type specified in this attribute structure.
490
+ *
491
+ * Defines the color format of the attribute structure's \ref COLOR_FIELD
492
+ * "color" field.
493
+ *
494
+ * Default Value is NVTX_COLOR_UNKNOWN
495
+ */
496
+ int32_t colorType; /* nvtxColorType_t */
497
+
498
+ /** \brief Color assigned to this event. \anchor COLOR_FIELD
499
+ *
500
+ * The color that the tool should use to visualize the event.
501
+ */
502
+ uint32_t color;
503
+
504
+ /**
505
+ * \brief Payload type specified in this attribute structure.
506
+ *
507
+ * Defines the payload format of the attribute structure's \ref PAYLOAD_FIELD
508
+ * "payload" field.
509
+ *
510
+ * Default Value is NVTX_PAYLOAD_UNKNOWN
511
+ */
512
+ int32_t payloadType; /* nvtxPayloadType_t */
513
+
514
+ int32_t reserved0;
515
+
516
+ /**
517
+ * \brief Payload assigned to this event. \anchor PAYLOAD_FIELD
518
+ *
519
+ * A numerical value that can be used to annotate an event. The tool could
520
+ * use the payload data to reconstruct graphs and diagrams.
521
+ */
522
+ union payload_t
523
+ {
524
+ uint64_t ullValue;
525
+ int64_t llValue;
526
+ double dValue;
527
+ /* NVTX_VERSION_2 */
528
+ uint32_t uiValue;
529
+ int32_t iValue;
530
+ float fValue;
531
+ } payload;
532
+
533
+ /** \brief Message type specified in this attribute structure.
534
+ *
535
+ * Defines the message format of the attribute structure's \ref MESSAGE_FIELD
536
+ * "message" field.
537
+ *
538
+ * Default Value is NVTX_MESSAGE_UNKNOWN
539
+ */
540
+ int32_t messageType; /* nvtxMessageType_t */
541
+
542
+ /** \brief Message assigned to this attribute structure. \anchor MESSAGE_FIELD
543
+ *
544
+ * The text message that is attached to an event.
545
+ */
546
+ nvtxMessageValue_t message;
547
+
548
+ } nvtxEventAttributes_v2;
549
+
550
+ typedef struct nvtxEventAttributes_v2 nvtxEventAttributes_t;
551
+
552
+ /** @} */ /*END defgroup*/
553
+ /* ========================================================================= */
554
+ /** \defgroup MARKERS_AND_RANGES Markers and Ranges
555
+ *
556
+ * See \ref MARKERS_AND_RANGES for more details
557
+ *
558
+ * @{
559
+ */
560
+
561
+ /** \name Marker */
562
+
563
+ /* ------------------------------------------------------------------------- */
564
+ /** \brief Marks an instantaneous event in the application.
565
+ *
566
+ * A marker can contain a text message or specify additional information
567
+ * using the event attributes structure. These attributes include a text
568
+ * message, color, category, and a payload. Each of the attributes is optional
569
+ * and can only be sent out using the \ref nvtxDomainMarkEx function.
570
+ *
571
+ * nvtxDomainMarkEx(NULL, event) is equivalent to calling
572
+ * nvtxMarkEx(event).
573
+ *
574
+ * \param domain - The domain of scoping the category.
575
+ * \param eventAttrib - The event attribute structure defining the marker's
576
+ * attribute types and attribute values.
577
+ *
578
+ * \sa
579
+ * ::nvtxMarkEx
580
+ *
581
+ * \version \NVTX_VERSION_2
582
+ * @{ */
583
+ NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
584
+ /** @} */
585
+
586
+ /* ------------------------------------------------------------------------- */
587
+ /** \brief Marks an instantaneous event in the application.
588
+ *
589
+ * A marker can contain a text message or specify additional information
590
+ * using the event attributes structure. These attributes include a text
591
+ * message, color, category, and a payload. Each of the attributes is optional
592
+ * and can only be sent out using the \ref nvtxMarkEx function.
593
+ * If \ref nvtxMarkA or \ref nvtxMarkW are used to specify the marker
594
+ * or if an attribute is unspecified then a default value will be used.
595
+ *
596
+ * \param eventAttrib - The event attribute structure defining the marker's
597
+ * attribute types and attribute values.
598
+ *
599
+ * \par Example:
600
+ * \code
601
+ * // zero the structure
602
+ * nvtxEventAttributes_t eventAttrib = {0};
603
+ * // set the version and the size information
604
+ * eventAttrib.version = NVTX_VERSION;
605
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
606
+ * // configure the attributes. 0 is the default for all attributes.
607
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
608
+ * eventAttrib.color = 0xFF880000;
609
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
610
+ * eventAttrib.message.ascii = "Example nvtxMarkEx";
611
+ * nvtxMarkEx(&eventAttrib);
612
+ * \endcode
613
+ *
614
+ * \sa
615
+ * ::nvtxDomainMarkEx
616
+ *
617
+ * \version \NVTX_VERSION_1
618
+ * @{ */
619
+ NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib);
620
+ /** @} */
621
+
622
+ /* ------------------------------------------------------------------------- */
623
+ /** \brief Marks an instantaneous event in the application.
624
+ *
625
+ * A marker created using \ref nvtxMarkA or \ref nvtxMarkW contains only a
626
+ * text message.
627
+ *
628
+ * \param message - The message associated to this marker event.
629
+ *
630
+ * \par Example:
631
+ * \code
632
+ * nvtxMarkA("Example nvtxMarkA");
633
+ * nvtxMarkW(L"Example nvtxMarkW");
634
+ * \endcode
635
+ *
636
+ * \sa
637
+ * ::nvtxDomainMarkEx
638
+ * ::nvtxMarkEx
639
+ *
640
+ * \version \NVTX_VERSION_0
641
+ * @{ */
642
+ NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message);
643
+ NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message);
644
+ /** @} */
645
+
646
+
647
+ /** \name Process Ranges */
648
+
649
+ /* ------------------------------------------------------------------------- */
650
+ /** \brief Starts a process range in a domain.
651
+ *
652
+ * \param domain - The domain of scoping the category.
653
+ * \param eventAttrib - The event attribute structure defining the range's
654
+ * attribute types and attribute values.
655
+ *
656
+ * \return The unique ID used to correlate a pair of Start and End events.
657
+ *
658
+ * \remarks Ranges defined by Start/End can overlap.
659
+ *
660
+ * \par Example:
661
+ * \code
662
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
663
+ * nvtxEventAttributes_t eventAttrib = {0};
664
+ * eventAttrib.version = NVTX_VERSION;
665
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
666
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
667
+ * eventAttrib.message.ascii = "my range";
668
+ * nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
669
+ * // ...
670
+ * nvtxDomainRangeEnd(rangeId);
671
+ * \endcode
672
+ *
673
+ * \sa
674
+ * ::nvtxDomainRangeEnd
675
+ *
676
+ * \version \NVTX_VERSION_2
677
+ * @{ */
678
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
679
+ /** @} */
680
+
681
+ /* ------------------------------------------------------------------------- */
682
+ /** \brief Starts a process range.
683
+ *
684
+ * \param eventAttrib - The event attribute structure defining the range's
685
+ * attribute types and attribute values.
686
+ *
687
+ * \return The unique ID used to correlate a pair of Start and End events.
688
+ *
689
+ * \remarks Ranges defined by Start/End can overlap.
690
+ *
691
+ * \par Example:
692
+ * \code
693
+ * nvtxEventAttributes_t eventAttrib = {0};
694
+ * eventAttrib.version = NVTX_VERSION;
695
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
696
+ * eventAttrib.category = 3;
697
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
698
+ * eventAttrib.color = 0xFF0088FF;
699
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
700
+ * eventAttrib.message.ascii = "Example Range";
701
+ * nvtxRangeId_t rangeId = nvtxRangeStartEx(&eventAttrib);
702
+ * // ...
703
+ * nvtxRangeEnd(rangeId);
704
+ * \endcode
705
+ *
706
+ * \sa
707
+ * ::nvtxRangeEnd
708
+ * ::nvtxDomainRangeStartEx
709
+ *
710
+ * \version \NVTX_VERSION_1
711
+ * @{ */
712
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib);
713
+ /** @} */
714
+
715
+ /* ------------------------------------------------------------------------- */
716
+ /** \brief Starts a process range.
717
+ *
718
+ * \param message - The event message associated to this range event.
719
+ *
720
+ * \return The unique ID used to correlate a pair of Start and End events.
721
+ *
722
+ * \remarks Ranges defined by Start/End can overlap.
723
+ *
724
+ * \par Example:
725
+ * \code
726
+ * nvtxRangeId_t r1 = nvtxRangeStartA("Range 1");
727
+ * nvtxRangeId_t r2 = nvtxRangeStartW(L"Range 2");
728
+ * nvtxRangeEnd(r1);
729
+ * nvtxRangeEnd(r2);
730
+ * \endcode
731
+ *
732
+ * \sa
733
+ * ::nvtxRangeEnd
734
+ * ::nvtxRangeStartEx
735
+ * ::nvtxDomainRangeStartEx
736
+ *
737
+ * \version \NVTX_VERSION_0
738
+ * @{ */
739
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message);
740
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message);
741
+ /** @} */
742
+
743
+ /* ------------------------------------------------------------------------- */
744
+ /** \brief Ends a process range.
745
+ *
746
+ * \param domain - The domain
747
+ * \param id - The correlation ID returned from a nvtxRangeStart call.
748
+ *
749
+ * \remarks This function is offered completeness but is an alias for ::nvtxRangeEnd.
750
+ * It does not need a domain param since that is associated iwth the range ID at ::nvtxDomainRangeStartEx
751
+ *
752
+ * \par Example:
753
+ * \code
754
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
755
+ * nvtxEventAttributes_t eventAttrib = {0};
756
+ * eventAttrib.version = NVTX_VERSION;
757
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
758
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
759
+ * eventAttrib.message.ascii = "my range";
760
+ * nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
761
+ * // ...
762
+ * nvtxDomainRangeEnd(rangeId);
763
+ * \endcode
764
+ *
765
+ * \sa
766
+ * ::nvtxDomainRangeStartEx
767
+ *
768
+ * \version \NVTX_VERSION_2
769
+ * @{ */
770
+ NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id);
771
+ /** @} */
772
+
773
+ /* ------------------------------------------------------------------------- */
774
+ /** \brief Ends a process range.
775
+ *
776
+ * \param id - The correlation ID returned from an nvtxRangeStart call.
777
+ *
778
+ * \sa
779
+ * ::nvtxDomainRangeStartEx
780
+ * ::nvtxRangeStartEx
781
+ * ::nvtxRangeStartA
782
+ * ::nvtxRangeStartW
783
+ *
784
+ * \version \NVTX_VERSION_0
785
+ * @{ */
786
+ NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id);
787
+ /** @} */
788
+
789
+ /** \name Thread Ranges */
790
+
791
+ /* ------------------------------------------------------------------------- */
792
+ /** \brief Starts a nested thread range.
793
+ *
794
+ * \param domain - The domain of scoping.
795
+ * \param eventAttrib - The event attribute structure defining the range's
796
+ * attribute types and attribute values.
797
+ *
798
+ * \return The 0 based level of range being started. This value is scoped to the domain.
799
+ * If an error occurs, a negative value is returned.
800
+ *
801
+ * \par Example:
802
+ * \code
803
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
804
+ * nvtxEventAttributes_t eventAttrib = {0};
805
+ * eventAttrib.version = NVTX_VERSION;
806
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
807
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
808
+ * eventAttrib.color = 0xFFFF0000;
809
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
810
+ * eventAttrib.message.ascii = "Level 0";
811
+ * nvtxDomainRangePushEx(domain, &eventAttrib);
812
+ *
813
+ * // Re-use eventAttrib
814
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
815
+ * eventAttrib.message.unicode = L"Level 1";
816
+ * nvtxDomainRangePushEx(domain, &eventAttrib);
817
+ *
818
+ * nvtxDomainRangePop(domain); //level 1
819
+ * nvtxDomainRangePop(domain); //level 0
820
+ * \endcode
821
+ *
822
+ * \sa
823
+ * ::nvtxDomainRangePop
824
+ *
825
+ * \version \NVTX_VERSION_2
826
+ * @{ */
827
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
828
+ /** @} */
829
+
830
+ /* ------------------------------------------------------------------------- */
831
+ /** \brief Starts a nested thread range.
832
+ *
833
+ * \param eventAttrib - The event attribute structure defining the range's
834
+ * attribute types and attribute values.
835
+ *
836
+ * \return The 0 based level of range being started. This level is per domain.
837
+ * If an error occurs a negative value is returned.
838
+ *
839
+ * \par Example:
840
+ * \code
841
+ * nvtxEventAttributes_t eventAttrib = {0};
842
+ * eventAttrib.version = NVTX_VERSION;
843
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
844
+ * eventAttrib.colorType = NVTX_COLOR_ARGB;
845
+ * eventAttrib.color = 0xFFFF0000;
846
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
847
+ * eventAttrib.message.ascii = "Level 0";
848
+ * nvtxRangePushEx(&eventAttrib);
849
+ *
850
+ * // Re-use eventAttrib
851
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
852
+ * eventAttrib.message.unicode = L"Level 1";
853
+ * nvtxRangePushEx(&eventAttrib);
854
+ *
855
+ * nvtxRangePop();
856
+ * nvtxRangePop();
857
+ * \endcode
858
+ *
859
+ * \sa
860
+ * ::nvtxDomainRangePushEx
861
+ * ::nvtxRangePop
862
+ *
863
+ * \version \NVTX_VERSION_1
864
+ * @{ */
865
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib);
866
+ /** @} */
867
+
868
+ /* ------------------------------------------------------------------------- */
869
+ /** \brief Starts a nested thread range.
870
+ *
871
+ * \param message - The event message associated to this range event.
872
+ *
873
+ * \return The 0 based level of range being started. If an error occurs a
874
+ * negative value is returned.
875
+ *
876
+ * \par Example:
877
+ * \code
878
+ * nvtxRangePushA("Level 0");
879
+ * nvtxRangePushW(L"Level 1");
880
+ * nvtxRangePop();
881
+ * nvtxRangePop();
882
+ * \endcode
883
+ *
884
+ * \sa
885
+ * ::nvtxDomainRangePushEx
886
+ * ::nvtxRangePop
887
+ *
888
+ * \version \NVTX_VERSION_0
889
+ * @{ */
890
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message);
891
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message);
892
+ /** @} */
893
+
894
+
895
+ /* ------------------------------------------------------------------------- */
896
+ /** \brief Ends a nested thread range.
897
+ *
898
+ * \return The level of the range being ended. If an error occurs a negative
899
+ * value is returned on the current thread.
900
+ *
901
+ * \par Example:
902
+ * \code
903
+ * nvtxDomainHandle_t domain = nvtxDomainCreate("example library");
904
+ * nvtxDomainRangePushA(domain, "Level 0");
905
+ * nvtxDomainRangePushW(domain, L"Level 1");
906
+ * nvtxDomainRangePop(domain);
907
+ * nvtxDomainRangePop(domain);
908
+ * \endcode
909
+ *
910
+ * \sa
911
+ * ::nvtxRangePushEx
912
+ * ::nvtxRangePushA
913
+ * ::nvtxRangePushW
914
+ *
915
+ * \version \NVTX_VERSION_2
916
+ * @{ */
917
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain);
918
+ /** @} */
919
+
920
+ /* ------------------------------------------------------------------------- */
921
+ /** \brief Ends a nested thread range.
922
+ *
923
+ * \return The level of the range being ended. If an error occurs a negative
924
+ * value is returned on the current thread.
925
+ *
926
+ * \par Example:
927
+ * \code
928
+ * nvtxRangePushA("Level 0");
929
+ * nvtxRangePushW(L"Level 1");
930
+ * nvtxRangePop();
931
+ * nvtxRangePop();
932
+ * \endcode
933
+ *
934
+ * \sa
935
+ * ::nvtxRangePushEx
936
+ * ::nvtxRangePushA
937
+ * ::nvtxRangePushW
938
+ *
939
+ * \version \NVTX_VERSION_0
940
+ * @{ */
941
+ NVTX_DECLSPEC int NVTX_API nvtxRangePop(void);
942
+ /** @} */
943
+
944
+
945
+ /** @} */ /*END defgroup*/
946
+ /* ========================================================================= */
947
+ /** \defgroup RESOURCE_NAMING Resource Naming
948
+ *
949
+ * See \ref RESOURCE_NAMING for more details
950
+ *
951
+ * @{
952
+ */
953
+
954
+
955
+ /* ------------------------------------------------------------------------- */
956
+ /** \name Functions for Generic Resource Naming*/
957
+ /* ------------------------------------------------------------------------- */
958
+
959
+ /* ------------------------------------------------------------------------- */
960
+ /** \cond SHOW_HIDDEN
961
+ * \brief Resource typing helpers.
962
+ *
963
+ * Classes are used to make it easy to create a series of resource types
964
+ * per API without collisions
965
+ */
966
+ #define NVTX_RESOURCE_MAKE_TYPE(CLASS, INDEX) ((((uint32_t)(NVTX_RESOURCE_CLASS_ ## CLASS))<<16)|((uint32_t)(INDEX)))
967
+ #define NVTX_RESOURCE_CLASS_GENERIC 1
968
+ /** \endcond */
969
+
970
+ /* ------------------------------------------------------------------------- */
971
+ /** \brief Generic resource type for when a resource class is not available.
972
+ *
973
+ * \sa
974
+ * ::nvtxDomainResourceCreate
975
+ *
976
+ * \version \NVTX_VERSION_2
977
+ */
978
+ typedef enum nvtxResourceGenericType_t
979
+ {
980
+ NVTX_RESOURCE_TYPE_UNKNOWN = 0,
981
+ NVTX_RESOURCE_TYPE_GENERIC_POINTER = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 1), /**< Generic pointer assumed to have no collisions with other pointers. */
982
+ NVTX_RESOURCE_TYPE_GENERIC_HANDLE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 2), /**< Generic handle assumed to have no collisions with other handles. */
983
+ NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 3), /**< OS native thread identifier. */
984
+ NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 4) /**< POSIX pthread identifier. */
985
+ } nvtxResourceGenericType_t;
986
+
987
+
988
+
989
+ /** \brief Resource Attribute Structure.
990
+ * \anchor RESOURCE_ATTRIBUTE_STRUCTURE
991
+ *
992
+ * This structure is used to describe the attributes of a resource. The layout of
993
+ * the structure is defined by a specific version of the tools extension
994
+ * library and can change between different versions of the Tools Extension
995
+ * library.
996
+ *
997
+ * \par Initializing the Attributes
998
+ *
999
+ * The caller should always perform the following three tasks when using
1000
+ * attributes:
1001
+ * <ul>
1002
+ * <li>Zero the structure
1003
+ * <li>Set the version field
1004
+ * <li>Set the size field
1005
+ * </ul>
1006
+ *
1007
+ * Zeroing the structure sets all the resource attributes types and values
1008
+ * to the default value.
1009
+ *
1010
+ * The version and size field are used by the Tools Extension
1011
+ * implementation to handle multiple versions of the attributes structure.
1012
+ *
1013
+ * It is recommended that the caller use one of the following to methods
1014
+ * to initialize the event attributes structure:
1015
+ *
1016
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
1017
+ * \code
1018
+ * nvtxResourceAttributes_t attribs = {0};
1019
+ * attribs.version = NVTX_VERSION;
1020
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1021
+ * \endcode
1022
+ *
1023
+ * \par Method 2: Initializing nvtxEventAttributes for a specific version
1024
+ * \code
1025
+ * nvtxResourceAttributes_v0 attribs = {0};
1026
+ * attribs.version = 2;
1027
+ * attribs.size = (uint16_t)(sizeof(nvtxResourceAttributes_v0));
1028
+ * \endcode
1029
+ *
1030
+ * If the caller uses Method 1 it is critical that the entire binary
1031
+ * layout of the structure be configured to 0 so that all fields
1032
+ * are initialized to the default value.
1033
+ *
1034
+ * The caller should either use both NVTX_VERSION and
1035
+ * NVTX_RESOURCE_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
1036
+ * and a versioned type (Method 2). Using a mix of the two methods
1037
+ * will likely cause either source level incompatibility or binary
1038
+ * incompatibility in the future.
1039
+ *
1040
+ * \par Settings Attribute Types and Values
1041
+ *
1042
+ *
1043
+ * \par Example:
1044
+ * \code
1045
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1046
+ *
1047
+ * // Initialize
1048
+ * nvtxResourceAttributes_t attribs = {0};
1049
+ * attribs.version = NVTX_VERSION;
1050
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1051
+ *
1052
+ * // Configure the Attributes
1053
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1054
+ * attribs.identifier.pValue = (const void*)pMutex;
1055
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1056
+ * attribs.message.ascii = "Single thread access to database.";
1057
+ *
1058
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1059
+ * \endcode
1060
+ *
1061
+ * \sa
1062
+ * ::nvtxDomainResourceCreate
1063
+ */
1064
+ typedef struct nvtxResourceAttributes_v0
1065
+ {
1066
+ /**
1067
+ * \brief Version flag of the structure.
1068
+ *
1069
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
1070
+ * supported in this header file. This can optionally be overridden to
1071
+ * another version of the tools extension library.
1072
+ */
1073
+ uint16_t version;
1074
+
1075
+ /**
1076
+ * \brief Size of the structure.
1077
+ *
1078
+ * Needs to be set to the size in bytes of this attribute
1079
+ * structure.
1080
+ */
1081
+ uint16_t size;
1082
+
1083
+ /**
1084
+ * \brief Identifier type specifies how to interpret the identifier field
1085
+ *
1086
+ * Defines the identifier format of the attribute structure's \ref RESOURCE_IDENTIFIER_FIELD
1087
+ * "identifier" field.
1088
+ *
1089
+ * Default Value is NVTX_RESOURCE_TYPE_UNKNOWN
1090
+ */
1091
+ int32_t identifierType; /* values from enums following the pattern nvtxResource[name]Type_t */
1092
+
1093
+ /**
1094
+ * \brief Identifier for the resource.
1095
+ * \anchor RESOURCE_IDENTIFIER_FIELD
1096
+ *
1097
+ * An identifier may be a pointer or a handle to an OS or middleware API object.
1098
+ * The resource type will assist in avoiding collisions where handles values may collide.
1099
+ */
1100
+ union identifier_t
1101
+ {
1102
+ const void* pValue;
1103
+ uint64_t ullValue;
1104
+ } identifier;
1105
+
1106
+ /** \brief Message type specified in this attribute structure.
1107
+ *
1108
+ * Defines the message format of the attribute structure's \ref RESOURCE_MESSAGE_FIELD
1109
+ * "message" field.
1110
+ *
1111
+ * Default Value is NVTX_MESSAGE_UNKNOWN
1112
+ */
1113
+ int32_t messageType; /* nvtxMessageType_t */
1114
+
1115
+ /** \brief Message assigned to this attribute structure. \anchor RESOURCE_MESSAGE_FIELD
1116
+ *
1117
+ * The text message that is attached to a resource.
1118
+ */
1119
+ nvtxMessageValue_t message;
1120
+
1121
+ } nvtxResourceAttributes_v0;
1122
+
1123
+ typedef struct nvtxResourceAttributes_v0 nvtxResourceAttributes_t;
1124
+
1125
+ /* \cond SHOW_HIDDEN
1126
+ * \version \NVTX_VERSION_2
1127
+ */
1128
+ #define NVTX_RESOURCE_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxResourceAttributes_v0) ) )
1129
+ typedef struct nvtxResourceHandle* nvtxResourceHandle_t;
1130
+ /** \endcond */
1131
+
1132
+
1133
+
1134
+ /* ------------------------------------------------------------------------- */
1135
+ /** \brief Create a resource object to track and associate data with OS and middleware objects
1136
+ *
1137
+ * Allows users to associate an API handle or pointer with a user-provided name.
1138
+ *
1139
+ *
1140
+ * \param domain - Domain to own the resource object
1141
+ * \param attribs - Attributes to be associated with the resource
1142
+ *
1143
+ * \return A handle that represents the newly created resource object.
1144
+ *
1145
+ * \par Example:
1146
+ * \code
1147
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1148
+ * nvtxResourceAttributes_t attribs = {0};
1149
+ * attribs.version = NVTX_VERSION;
1150
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1151
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1152
+ * attribs.identifier.pValue = (const void*)pMutex;
1153
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1154
+ * attribs.message.ascii = "Single thread access to database.";
1155
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1156
+ * \endcode
1157
+ *
1158
+ * \sa
1159
+ * ::nvtxResourceAttributes_t
1160
+ * ::nvtxDomainResourceDestroy
1161
+ *
1162
+ * \version \NVTX_VERSION_2
1163
+ * @{ */
1164
+ NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
1165
+ /** @} */
1166
+
1167
+ /* ------------------------------------------------------------------------- */
1168
+ /** \brief Destroy a resource object to track and associate data with OS and middleware objects
1169
+ *
1170
+ * Allows users to associate an API handle or pointer with a user-provided name.
1171
+ *
1172
+ * \param resource - Handle to the resource in which to operate.
1173
+ *
1174
+ * \par Example:
1175
+ * \code
1176
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
1177
+ * nvtxResourceAttributes_t attribs = {0};
1178
+ * attribs.version = NVTX_VERSION;
1179
+ * attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
1180
+ * attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
1181
+ * attribs.identifier.pValue = (const void*)pMutex;
1182
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
1183
+ * attribs.message.ascii = "Single thread access to database.";
1184
+ * nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
1185
+ * nvtxDomainResourceDestroy(handle);
1186
+ * \endcode
1187
+ *
1188
+ * \sa
1189
+ * ::nvtxDomainResourceCreate
1190
+ *
1191
+ * \version \NVTX_VERSION_2
1192
+ * @{ */
1193
+ NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource);
1194
+ /** @} */
1195
+
1196
+
1197
+ /** \name Functions for NVTX Category Naming*/
1198
+
1199
+ /* ------------------------------------------------------------------------- */
1200
+ /**
1201
+ * \brief Annotate an NVTX category used within a domain.
1202
+ *
1203
+ * Categories are used to group sets of events. Each category is identified
1204
+ * through a unique ID and that ID is passed into any of the marker/range
1205
+ * events to assign that event to a specific category. The nvtxDomainNameCategory
1206
+ * function calls allow the user to assign a name to a category ID that is
1207
+ * specific to the domain.
1208
+ *
1209
+ * nvtxDomainNameCategory(NULL, category, name) is equivalent to calling
1210
+ * nvtxNameCategory(category, name).
1211
+ *
1212
+ * \param domain - The domain of scoping the category.
1213
+ * \param category - The category ID to name.
1214
+ * \param name - The name of the category.
1215
+ *
1216
+ * \remarks The category names are tracked per domain.
1217
+ *
1218
+ * \par Example:
1219
+ * \code
1220
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("example");
1221
+ * nvtxDomainNameCategoryA(domain, 1, "Memory Allocation");
1222
+ * nvtxDomainNameCategoryW(domain, 2, L"Memory Transfer");
1223
+ * \endcode
1224
+ *
1225
+ * \version \NVTX_VERSION_2
1226
+ * @{ */
1227
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name);
1228
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
1229
+ /** @} */
1230
+
1231
+ /** \brief Annotate an NVTX category.
1232
+ *
1233
+ * Categories are used to group sets of events. Each category is identified
1234
+ * through a unique ID and that ID is passed into any of the marker/range
1235
+ * events to assign that event to a specific category. The nvtxNameCategory
1236
+ * function calls allow the user to assign a name to a category ID.
1237
+ *
1238
+ * \param category - The category ID to name.
1239
+ * \param name - The name of the category.
1240
+ *
1241
+ * \remarks The category names are tracked per process.
1242
+ *
1243
+ * \par Example:
1244
+ * \code
1245
+ * nvtxNameCategory(1, "Memory Allocation");
1246
+ * nvtxNameCategory(2, "Memory Transfer");
1247
+ * nvtxNameCategory(3, "Memory Object Lifetime");
1248
+ * \endcode
1249
+ *
1250
+ * \version \NVTX_VERSION_1
1251
+ * @{ */
1252
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name);
1253
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name);
1254
+ /** @} */
1255
+
1256
+ /** \name Functions for OS Threads Naming*/
1257
+
1258
+ /* ------------------------------------------------------------------------- */
1259
+ /** \brief Annotate an OS thread.
1260
+ *
1261
+ * Allows the user to name an active thread of the current process. If an
1262
+ * invalid thread ID is provided or a thread ID from a different process is
1263
+ * used the behavior of the tool is implementation dependent.
1264
+ *
1265
+ * Tools expect thread ID to be a number that uniquely identifies the thread
1266
+ * at the time of the call. Note that a thread's ID can be reused after
1267
+ * it is destroyed. Tools may choose how to handle aliasing of thread IDs.
1268
+ *
1269
+ * POSIX pthread_t type returned by pthread_self() may not comply with these
1270
+ * expectations. Please use OS-specific thread ID instead of pthread_t.
1271
+ *
1272
+ * The thread name is associated to the default domain. To support domains
1273
+ * use resource objects via ::nvtxDomainResourceCreate.
1274
+ *
1275
+ * \param threadId - The ID of the thread to name.
1276
+ * \param name - The name of the thread.
1277
+ *
1278
+ * \par Examples:
1279
+ * MS Windows:
1280
+ * \code
1281
+ * #include <windows.h>
1282
+ * nvtxNameOsThread(GetCurrentThreadId(), "Current thread");
1283
+ * nvtxNameOsThread(GetThreadId(SomeThreadHandle), "Other thread");
1284
+ * \endcode
1285
+ *
1286
+ * Android:
1287
+ * \code
1288
+ * #include <unistd.h>
1289
+ * nvtxNameOsThreadA(gettid(), "Current thread");
1290
+ * nvtxNameOsThreadA(getpid(), "Main thread");
1291
+ * \endcode
1292
+ *
1293
+ * Linux:
1294
+ * \code
1295
+ * #include <sys/syscall.h>
1296
+ * nvtxNameOsThreadA(syscall(SYS_gettid), "Current thread");
1297
+ * \endcode
1298
+ * \code
1299
+ * #include <unistd.h>
1300
+ * nvtxNameOsThreadA(getpid(), "Main thread");
1301
+ * \endcode
1302
+ *
1303
+ * OS X:
1304
+ * \code
1305
+ * #include <sys/syscall.h>
1306
+ * nvtxNameOsThreadA(syscall(SYS_thread_selfid), "Current thread");
1307
+ * \endcode
1308
+ * \code
1309
+ * #include <pthread.h>
1310
+ * __uint64_t id;
1311
+ * pthread_threadid_np(pthread_self(), &id);
1312
+ * nvtxNameOsThreadA(id, "Current thread");
1313
+ * pthread_threadid_np(somePThreadId, &id);
1314
+ * nvtxNameOsThreadA(id, "Other thread");
1315
+ * \endcode
1316
+ *
1317
+ * \version \NVTX_VERSION_1
1318
+ * @{ */
1319
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name);
1320
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name);
1321
+ /** @} */
1322
+
1323
+
1324
+ /** @} */ /*END defgroup*/
1325
+ /* ========================================================================= */
1326
+ /** \defgroup STRING_REGISTRATION String Registration
1327
+ *
1328
+ * Registered strings are intended to increase performance by lowering instrumentation
1329
+ * overhead. String may be registered once and the handle may be passed in place of
1330
+ * a string where an the APIs may allow.
1331
+ *
1332
+ * See \ref STRING_REGISTRATION for more details
1333
+ *
1334
+ * @{
1335
+ */
1336
+
1337
+ /* ------------------------------------------------------------------------- */
1338
+ /** \brief Register a string.
1339
+
1340
+ * Registers an immutable string with NVTX. Once registered the pointer used
1341
+ * to register the domain name can be used in nvtxEventAttributes_t
1342
+ * \ref MESSAGE_FIELD. This allows NVTX implementation to skip copying the
1343
+ * contents of the message on each event invocation.
1344
+ *
1345
+ * String registration is an optimization. It is recommended to use string
1346
+ * registration if the string will be passed to an event many times.
1347
+ *
1348
+ * String are not unregistered, except that by unregistering the entire domain
1349
+ *
1350
+ * \param domain - Domain handle. If NULL then the global domain is used.
1351
+ * \param string - A unique pointer to a sequence of characters.
1352
+ *
1353
+ * \return A handle representing the registered string.
1354
+ *
1355
+ * \par Example:
1356
+ * \code
1357
+ * nvtxDomainCreateA("com.nvidia.nvtx.example");
1358
+ * nvtxStringHandle_t message = nvtxDomainRegisterStringA(domain, "registered string");
1359
+ * nvtxEventAttributes_t eventAttrib = {0};
1360
+ * eventAttrib.version = NVTX_VERSION;
1361
+ * eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1362
+ * eventAttrib.messageType = NVTX_MESSAGE_TYPE_REGISTERED;
1363
+ * eventAttrib.message.registered = message;
1364
+ * \endcode
1365
+ *
1366
+ * \version \NVTX_VERSION_2
1367
+ * @{ */
1368
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string);
1369
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string);
1370
+ /** @} */
1371
+
1372
+ /** @} */ /*END defgroup*/
1373
+ /* ========================================================================= */
1374
+ /** \defgroup DOMAINS Domains
1375
+ *
1376
+ * Domains are used to group events to a developer defined scope. Middleware
1377
+ * vendors may also scope their own events to avoid collisions with the
1378
+ * the application developer's events, so that the application developer may
1379
+ * inspect both parts and easily differentiate or filter them. By default
1380
+ * all events are scoped to a global domain where NULL is provided or when
1381
+ * using APIs provided b versions of NVTX below v2
1382
+ *
1383
+ * Domains are intended to be typically long lived objects with the intention
1384
+ * of logically separating events of large modules from each other such as
1385
+ * middleware libraries from each other and the main application.
1386
+ *
1387
+ * See \ref DOMAINS for more details
1388
+ *
1389
+ * @{
1390
+ */
1391
+
1392
+ /* ------------------------------------------------------------------------- */
1393
+ /** \brief Register a NVTX domain.
1394
+ *
1395
+ * Domains are used to scope annotations. All NVTX_VERSION_0 and NVTX_VERSION_1
1396
+ * annotations are scoped to the global domain. The function nvtxDomainCreate
1397
+ * creates a new named domain.
1398
+ *
1399
+ * Each domain maintains its own nvtxRangePush and nvtxRangePop stack.
1400
+ *
1401
+ * \param name - A unique string representing the domain.
1402
+ *
1403
+ * \return A handle representing the domain.
1404
+ *
1405
+ * \par Example:
1406
+ * \code
1407
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
1408
+ *
1409
+ * nvtxMarkA("nvtxMarkA to global domain");
1410
+ *
1411
+ * nvtxEventAttributes_t eventAttrib1 = {0};
1412
+ * eventAttrib1.version = NVTX_VERSION;
1413
+ * eventAttrib1.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1414
+ * eventAttrib1.message.ascii = "nvtxDomainMarkEx to global domain";
1415
+ * nvtxDomainMarkEx(NULL, &eventAttrib1);
1416
+ *
1417
+ * nvtxEventAttributes_t eventAttrib2 = {0};
1418
+ * eventAttrib2.version = NVTX_VERSION;
1419
+ * eventAttrib2.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
1420
+ * eventAttrib2.message.ascii = "nvtxDomainMarkEx to com.nvidia.nvtx.example";
1421
+ * nvtxDomainMarkEx(domain, &eventAttrib2);
1422
+ * nvtxDomainDestroy(domain);
1423
+ * \endcode
1424
+ *
1425
+ * \sa
1426
+ * ::nvtxDomainDestroy
1427
+ *
1428
+ * \version \NVTX_VERSION_2
1429
+ * @{ */
1430
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* name);
1431
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* name);
1432
+ /** @} */
1433
+
1434
+ /* ------------------------------------------------------------------------- */
1435
+ /** \brief Unregister a NVTX domain.
1436
+ *
1437
+ * Unregisters the domain handle and frees all domain specific resources.
1438
+ *
1439
+ * \param domain - the domain handle
1440
+ *
1441
+ * \par Example:
1442
+ * \code
1443
+ * nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
1444
+ * nvtxDomainDestroy(domain);
1445
+ * \endcode
1446
+ *
1447
+ * \sa
1448
+ * ::nvtxDomainCreateA
1449
+ * ::nvtxDomainCreateW
1450
+ *
1451
+ * \version \NVTX_VERSION_2
1452
+ * @{ */
1453
+ NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain);
1454
+ /** @} */
1455
+
1456
+
1457
+ /** @} */ /*END defgroup*/
1458
+ /* ========================================================================= */
1459
+ /** \cond SHOW_HIDDEN */
1460
+
1461
+ #ifdef UNICODE
1462
+ #define nvtxMark nvtxMarkW
1463
+ #define nvtxRangeStart nvtxRangeStartW
1464
+ #define nvtxRangePush nvtxRangePushW
1465
+ #define nvtxNameCategory nvtxNameCategoryW
1466
+ #define nvtxNameOsThread nvtxNameOsThreadW
1467
+ /* NVTX_VERSION_2 */
1468
+ #define nvtxDomainCreate nvtxDomainCreateW
1469
+ #define nvtxDomainRegisterString nvtxDomainRegisterStringW
1470
+ #define nvtxDomainNameCategory nvtxDomainNameCategoryW
1471
+ #else
1472
+ #define nvtxMark nvtxMarkA
1473
+ #define nvtxRangeStart nvtxRangeStartA
1474
+ #define nvtxRangePush nvtxRangePushA
1475
+ #define nvtxNameCategory nvtxNameCategoryA
1476
+ #define nvtxNameOsThread nvtxNameOsThreadA
1477
+ /* NVTX_VERSION_2 */
1478
+ #define nvtxDomainCreate nvtxDomainCreateA
1479
+ #define nvtxDomainRegisterString nvtxDomainRegisterStringA
1480
+ #define nvtxDomainNameCategory nvtxDomainNameCategoryA
1481
+ #endif
1482
+
1483
+ /** \endcond */
1484
+
1485
+ #ifdef __cplusplus
1486
+ } /* extern "C" */
1487
+ #endif /* __cplusplus */
1488
+
1489
+ #define NVTX_IMPL_GUARD /* Ensure other headers cannot included directly */
1490
+
1491
+ #include "nvtxDetail/nvtxTypes.h"
1492
+
1493
+ #ifndef NVTX_NO_IMPL
1494
+ #include "nvtxDetail/nvtxImpl.h"
1495
+ #endif /*NVTX_NO_IMPL*/
1496
+
1497
+ #undef NVTX_IMPL_GUARD
1498
+
1499
+ #endif /* !defined(NVTX_VERSION) */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCuda.h ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #include "nvToolsExt.h"
39
+
40
+ #include "cuda.h"
41
+
42
+ #ifndef NVTOOLSEXT_CUDA_V3
43
+ #define NVTOOLSEXT_CUDA_V3
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif /* __cplusplus */
48
+
49
+ /* ========================================================================= */
50
+ /** \name Functions for CUDA Resource Naming
51
+ */
52
+ /** \addtogroup RESOURCE_NAMING
53
+ * \section RESOURCE_NAMING_CUDA CUDA Resource Naming
54
+ *
55
+ * This section covers the API functions that allow to annotate CUDA resources
56
+ * with user-provided names.
57
+ *
58
+ * @{
59
+ */
60
+
61
+ /* ------------------------------------------------------------------------- */
62
+ /* \cond SHOW_HIDDEN
63
+ * \brief Used to build a non-colliding value for resource types separated class
64
+ * \version \NVTX_VERSION_2
65
+ */
66
+ #define NVTX_RESOURCE_CLASS_CUDA 4
67
+ /** \endcond */
68
+
69
+ /* ------------------------------------------------------------------------- */
70
+ /** \brief Resource types for CUDA
71
+ */
72
+ typedef enum nvtxResourceCUDAType_t
73
+ {
74
+ NVTX_RESOURCE_TYPE_CUDA_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDA, 1), /* CUdevice */
75
+ NVTX_RESOURCE_TYPE_CUDA_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 2), /* CUcontext */
76
+ NVTX_RESOURCE_TYPE_CUDA_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDA, 3), /* CUstream */
77
+ NVTX_RESOURCE_TYPE_CUDA_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 4), /* CUevent */
78
+ } nvtxResourceCUDAType_t;
79
+
80
+
81
+ /* ------------------------------------------------------------------------- */
82
+ /** \brief Annotates a CUDA device.
83
+ *
84
+ * Allows the user to associate a CUDA device with a user-provided name.
85
+ *
86
+ * \param device - The handle of the CUDA device to name.
87
+ * \param name - The name of the CUDA device.
88
+ *
89
+ * \version \NVTX_VERSION_1
90
+ * @{ */
91
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceA(CUdevice device, const char* name);
92
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceW(CUdevice device, const wchar_t* name);
93
+ /** @} */
94
+
95
+ /* ------------------------------------------------------------------------- */
96
+ /** \brief Annotates a CUDA context.
97
+ *
98
+ * Allows the user to associate a CUDA context with a user-provided name.
99
+ *
100
+ * \param context - The handle of the CUDA context to name.
101
+ * \param name - The name of the CUDA context.
102
+ *
103
+ * \par Example:
104
+ * \code
105
+ * CUresult status = cuCtxCreate( &cuContext, 0, cuDevice );
106
+ * if ( CUDA_SUCCESS != status )
107
+ * goto Error;
108
+ * nvtxNameCuContext(cuContext, "CTX_NAME");
109
+ * \endcode
110
+ *
111
+ * \version \NVTX_VERSION_1
112
+ * @{ */
113
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextA(CUcontext context, const char* name);
114
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextW(CUcontext context, const wchar_t* name);
115
+ /** @} */
116
+
117
+ /* ------------------------------------------------------------------------- */
118
+ /** \brief Annotates a CUDA stream.
119
+ *
120
+ * Allows the user to associate a CUDA stream with a user-provided name.
121
+ *
122
+ * \param stream - The handle of the CUDA stream to name.
123
+ * \param name - The name of the CUDA stream.
124
+ *
125
+ * \version \NVTX_VERSION_1
126
+ * @{ */
127
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamA(CUstream stream, const char* name);
128
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamW(CUstream stream, const wchar_t* name);
129
+ /** @} */
130
+
131
+ /* ------------------------------------------------------------------------- */
132
+ /** \brief Annotates a CUDA event.
133
+ *
134
+ * Allows the user to associate a CUDA event with a user-provided name.
135
+ *
136
+ * \param event - The handle of the CUDA event to name.
137
+ * \param name - The name of the CUDA event.
138
+ *
139
+ * \version \NVTX_VERSION_1
140
+ * @{ */
141
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventA(CUevent event, const char* name);
142
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventW(CUevent event, const wchar_t* name);
143
+ /** @} */
144
+
145
+ /** @} */ /* END RESOURCE_NAMING */
146
+
147
+ /* ========================================================================= */
148
+ #ifdef UNICODE
149
+ #define nvtxNameCuDevice nvtxNameCuDeviceW
150
+ #define nvtxNameCuContext nvtxNameCuContextW
151
+ #define nvtxNameCuStream nvtxNameCuStreamW
152
+ #define nvtxNameCuEvent nvtxNameCuEventW
153
+ #else
154
+ #define nvtxNameCuDevice nvtxNameCuDeviceA
155
+ #define nvtxNameCuContext nvtxNameCuContextA
156
+ #define nvtxNameCuStream nvtxNameCuStreamA
157
+ #define nvtxNameCuEvent nvtxNameCuEventA
158
+ #endif
159
+
160
+ #ifdef __cplusplus
161
+ }
162
+ #endif /* __cplusplus */
163
+
164
+ #ifndef NVTX_NO_IMPL
165
+ #define NVTX_IMPL_GUARD_CUDA /* Ensure other headers cannot included directly */
166
+ #include "nvtxDetail/nvtxImplCuda_v3.h"
167
+ #undef NVTX_IMPL_GUARD_CUDA
168
+ #endif /*NVTX_NO_IMPL*/
169
+
170
+ #endif /* NVTOOLSEXT_CUDA_V3 */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCudaRt.h ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #include "nvToolsExt.h"
39
+
40
+ #include "cuda.h"
41
+ #include "driver_types.h"
42
+
43
+ #ifndef NVTOOLSEXT_CUDART_V3
44
+ #define NVTOOLSEXT_CUDART_V3
45
+
46
+ #ifdef __cplusplus
47
+ extern "C" {
48
+ #endif /* __cplusplus */
49
+
50
+ /* ========================================================================= */
51
+ /** \name Functions for CUDA Resource Naming
52
+ */
53
+ /** \addtogroup RESOURCE_NAMING
54
+ * \section RESOURCE_NAMING_CUDART CUDA Runtime Resource Naming
55
+ *
56
+ * This section covers the API functions that allow to annotate CUDA resources
57
+ * with user-provided names.
58
+ *
59
+ * @{
60
+ */
61
+
62
+ /* ------------------------------------------------------------------------- */
63
+ /* \cond SHOW_HIDDEN
64
+ * \brief Used to build a non-colliding value for resource types separated class
65
+ * \version \NVTX_VERSION_2
66
+ */
67
+ #define NVTX_RESOURCE_CLASS_CUDART 5
68
+ /** \endcond */
69
+
70
+ /* ------------------------------------------------------------------------- */
71
+ /** \brief Resource types for CUDART
72
+ */
73
+ typedef enum nvtxResourceCUDARTType_t
74
+ {
75
+ NVTX_RESOURCE_TYPE_CUDART_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDART, 0), /* int device */
76
+ NVTX_RESOURCE_TYPE_CUDART_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDART, 1), /* cudaStream_t */
77
+ NVTX_RESOURCE_TYPE_CUDART_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDART, 2), /* cudaEvent_t */
78
+ } nvtxResourceCUDARTType_t;
79
+
80
+
81
+ /* ------------------------------------------------------------------------- */
82
+ /** \brief Annotates a CUDA device.
83
+ *
84
+ * Allows the user to associate a CUDA device with a user-provided name.
85
+ *
86
+ * \param device - The id of the CUDA device to name.
87
+ * \param name - The name of the CUDA device.
88
+ *
89
+ * \version \NVTX_VERSION_1
90
+ * @{ */
91
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceA(int device, const char* name);
92
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceW(int device, const wchar_t* name);
93
+ /** @} */
94
+
95
+ /* ------------------------------------------------------------------------- */
96
+ /** \brief Annotates a CUDA stream.
97
+ *
98
+ * Allows the user to associate a CUDA stream with a user-provided name.
99
+ *
100
+ * \param stream - The handle of the CUDA stream to name.
101
+ * \param name - The name of the CUDA stream.
102
+ *
103
+ * \version \NVTX_VERSION_1
104
+ * @{ */
105
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamA(cudaStream_t stream, const char* name);
106
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamW(cudaStream_t stream, const wchar_t* name);
107
+ /** @} */
108
+
109
+ /* ------------------------------------------------------------------------- */
110
+ /** \brief Annotates a CUDA event.
111
+ *
112
+ * Allows the user to associate a CUDA event with a user-provided name.
113
+ *
114
+ * \param event - The handle of the CUDA event to name.
115
+ * \param name - The name of the CUDA event.
116
+ *
117
+ * \version \NVTX_VERSION_1
118
+ * @{ */
119
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventA(cudaEvent_t event, const char* name);
120
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventW(cudaEvent_t event, const wchar_t* name);
121
+ /** @} */
122
+
123
+ /** @} */ /* END RESOURCE_NAMING */
124
+
125
+ /* ========================================================================= */
126
+ #ifdef UNICODE
127
+ #define nvtxNameCudaDevice nvtxNameCudaDeviceW
128
+ #define nvtxNameCudaStream nvtxNameCudaStreamW
129
+ #define nvtxNameCudaEvent nvtxNameCudaEventW
130
+ #else
131
+ #define nvtxNameCudaDevice nvtxNameCudaDeviceA
132
+ #define nvtxNameCudaStream nvtxNameCudaStreamA
133
+ #define nvtxNameCudaEvent nvtxNameCudaEventA
134
+ #endif
135
+
136
+ #ifdef __cplusplus
137
+ }
138
+ #endif /* __cplusplus */
139
+
140
+ #ifndef NVTX_NO_IMPL
141
+ #define NVTX_IMPL_GUARD_CUDART /* Ensure other headers cannot included directly */
142
+ #include "nvtxDetail/nvtxImplCudaRt_v3.h"
143
+ #undef NVTX_IMPL_GUARD_CUDART
144
+ #endif /*NVTX_NO_IMPL*/
145
+
146
+ #endif /* NVTOOLSEXT_CUDART_V3 */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtOpenCL.h ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #include "nvToolsExt.h"
39
+
40
+ #include <CL/cl.h>
41
+
42
+ #ifndef NVTOOLSEXT_OPENCL_V3
43
+ #define NVTOOLSEXT_OPENCL_V3
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif /* __cplusplus */
48
+
49
+ /* ========================================================================= */
50
+ /** \name Functions for OpenCL Resource Naming
51
+ */
52
+ /** \addtogroup RESOURCE_NAMING
53
+ * \section RESOURCE_NAMING_OPENCL OpenCL Resource Naming
54
+ *
55
+ * This section covers the API functions that allow to annotate OpenCL resources
56
+ * with user-provided names.
57
+ *
58
+ * @{
59
+ */
60
+
61
+ /* ------------------------------------------------------------------------- */
62
+ /* \cond SHOW_HIDDEN
63
+ * \brief Used to build a non-colliding value for resource types separated class
64
+ * \version \NVTX_VERSION_2
65
+ */
66
+ #define NVTX_RESOURCE_CLASS_OPENCL 6
67
+ /** \endcond */
68
+
69
+ /* ------------------------------------------------------------------------- */
70
+ /** \brief Resource types for OpenCL
71
+ */
72
+ typedef enum nvtxResourceOpenCLType_t
73
+ {
74
+ NVTX_RESOURCE_TYPE_OPENCL_DEVICE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 1),
75
+ NVTX_RESOURCE_TYPE_OPENCL_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 2),
76
+ NVTX_RESOURCE_TYPE_OPENCL_COMMANDQUEUE = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 3),
77
+ NVTX_RESOURCE_TYPE_OPENCL_MEMOBJECT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 4),
78
+ NVTX_RESOURCE_TYPE_OPENCL_SAMPLER = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 5),
79
+ NVTX_RESOURCE_TYPE_OPENCL_PROGRAM = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 6),
80
+ NVTX_RESOURCE_TYPE_OPENCL_EVENT = NVTX_RESOURCE_MAKE_TYPE(OPENCL, 7),
81
+ } nvtxResourceOpenCLType_t;
82
+
83
+
84
+ /* ------------------------------------------------------------------------- */
85
+ /** \brief Annotates an OpenCL device.
86
+ *
87
+ * Allows to associate an OpenCL device with a user-provided name.
88
+ *
89
+ * \param device - The handle of the OpenCL device to name.
90
+ * \param name - The name of the OpenCL device.
91
+ *
92
+ * \version \NVTX_VERSION_1
93
+ * @{ */
94
+ NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceA(cl_device_id device, const char* name);
95
+ NVTX_DECLSPEC void NVTX_API nvtxNameClDeviceW(cl_device_id device, const wchar_t* name);
96
+ /** @} */
97
+
98
+ /* ------------------------------------------------------------------------- */
99
+ /** \brief Annotates an OpenCL context.
100
+ *
101
+ * Allows to associate an OpenCL context with a user-provided name.
102
+ *
103
+ * \param context - The handle of the OpenCL context to name.
104
+ * \param name - The name of the OpenCL context.
105
+ *
106
+ * \version \NVTX_VERSION_1
107
+ * @{ */
108
+ NVTX_DECLSPEC void NVTX_API nvtxNameClContextA(cl_context context, const char* name);
109
+ NVTX_DECLSPEC void NVTX_API nvtxNameClContextW(cl_context context, const wchar_t* name);
110
+ /** @} */
111
+
112
+ /* ------------------------------------------------------------------------- */
113
+ /** \brief Annotates an OpenCL command queue.
114
+ *
115
+ * Allows to associate an OpenCL command queue with a user-provided name.
116
+ *
117
+ * \param command_queue - The handle of the OpenCL command queue to name.
118
+ * \param name - The name of the OpenCL command queue.
119
+ *
120
+ * \version \NVTX_VERSION_1
121
+ * @{ */
122
+ NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueA(cl_command_queue command_queue, const char* name);
123
+ NVTX_DECLSPEC void NVTX_API nvtxNameClCommandQueueW(cl_command_queue command_queue, const wchar_t* name);
124
+ /** @} */
125
+
126
+ /* ------------------------------------------------------------------------- */
127
+ /** \brief Annotates an OpenCL memory object.
128
+ *
129
+ * Allows to associate an OpenCL memory object with a user-provided name.
130
+ *
131
+ * \param memobj - The handle of the OpenCL memory object to name.
132
+ * \param name - The name of the OpenCL memory object.
133
+ *
134
+ * \version \NVTX_VERSION_1
135
+ * @{ */
136
+ NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectA(cl_mem memobj, const char* name);
137
+ NVTX_DECLSPEC void NVTX_API nvtxNameClMemObjectW(cl_mem memobj, const wchar_t* name);
138
+ /** @} */
139
+
140
+ /* ------------------------------------------------------------------------- */
141
+ /** \brief Annotates an OpenCL sampler.
142
+ *
143
+ * Allows to associate an OpenCL sampler with a user-provided name.
144
+ *
145
+ * \param sampler - The handle of the OpenCL sampler to name.
146
+ * \param name - The name of the OpenCL sampler.
147
+ *
148
+ * \version \NVTX_VERSION_1
149
+ * @{ */
150
+ NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerA(cl_sampler sampler, const char* name);
151
+ NVTX_DECLSPEC void NVTX_API nvtxNameClSamplerW(cl_sampler sampler, const wchar_t* name);
152
+ /** @} */
153
+
154
+ /* ------------------------------------------------------------------------- */
155
+ /** \brief Annotates an OpenCL program.
156
+ *
157
+ * Allows to associate an OpenCL program with a user-provided name.
158
+ *
159
+ * \param program - The handle of the OpenCL program to name.
160
+ * \param name - The name of the OpenCL program.
161
+ *
162
+ * \code
163
+ * cpProgram = clCreateProgramWithSource(cxGPUContext, 1,
164
+ * (const char **) &cSourceCL, &program_length, &ciErrNum);
165
+ * shrCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
166
+ * nvtxNameClProgram(cpProgram, L"PROGRAM_NAME");
167
+ * \endcode
168
+ *
169
+ * \version \NVTX_VERSION_1
170
+ * @{ */
171
+ NVTX_DECLSPEC void NVTX_API nvtxNameClProgramA(cl_program program, const char* name);
172
+ NVTX_DECLSPEC void NVTX_API nvtxNameClProgramW(cl_program program, const wchar_t* name);
173
+ /** @} */
174
+
175
+ /* ------------------------------------------------------------------------- */
176
+ /** \brief Annotates an OpenCL event.
177
+ *
178
+ * Allows to associate an OpenCL event with a user-provided name.
179
+ *
180
+ * \param evnt - The handle of the OpenCL event to name.
181
+ * \param name - The name of the OpenCL event.
182
+ *
183
+ * \version \NVTX_VERSION_1
184
+ * @{ */
185
+ NVTX_DECLSPEC void NVTX_API nvtxNameClEventA(cl_event evnt, const char* name);
186
+ NVTX_DECLSPEC void NVTX_API nvtxNameClEventW(cl_event evnt, const wchar_t* name);
187
+ /** @} */
188
+
189
+ /** @} */ /* END RESOURCE_NAMING */
190
+
191
+ /* ========================================================================= */
192
+ #ifdef UNICODE
193
+ #define nvtxNameClDevice nvtxNameClDeviceW
194
+ #define nvtxNameClContext nvtxNameClContextW
195
+ #define nvtxNameClCommandQueue nvtxNameClCommandQueueW
196
+ #define nvtxNameClMemObject nvtxNameClMemObjectW
197
+ #define nvtxNameClSampler nvtxNameClSamplerW
198
+ #define nvtxNameClProgram nvtxNameClProgramW
199
+ #define nvtxNameClEvent nvtxNameClEventW
200
+ #else
201
+ #define nvtxNameClDevice nvtxNameClDeviceA
202
+ #define nvtxNameClContext nvtxNameClContextA
203
+ #define nvtxNameClCommandQueue nvtxNameClCommandQueueA
204
+ #define nvtxNameClMemObject nvtxNameClMemObjectA
205
+ #define nvtxNameClSampler nvtxNameClSamplerA
206
+ #define nvtxNameClProgram nvtxNameClProgramA
207
+ #define nvtxNameClEvent nvtxNameClEventA
208
+ #endif
209
+
210
+ #ifdef __cplusplus
211
+ }
212
+ #endif /* __cplusplus */
213
+
214
+ #ifndef NVTX_NO_IMPL
215
+ #define NVTX_IMPL_GUARD_OPENCL /* Ensure other headers cannot included directly */
216
+ #include "nvtxDetail/nvtxImplOpenCL_v3.h"
217
+ #undef NVTX_IMPL_GUARD_OPENCL
218
+ #endif /*NVTX_NO_IMPL*/
219
+
220
+ #endif /* NVTOOLSEXT_OPENCL_V3 */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtSync.h ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
3
+ *
4
+ * NOTICE TO USER:
5
+ *
6
+ * This source code is subject to NVIDIA ownership rights under U.S. and
7
+ * international Copyright laws.
8
+ *
9
+ * This software and the information contained herein is PROPRIETARY and
10
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
11
+ * of a form of NVIDIA software license agreement.
12
+ *
13
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
14
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
15
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
16
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
17
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
18
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
19
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
21
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
22
+ * OR PERFORMANCE OF THIS SOURCE CODE.
23
+ *
24
+ * U.S. Government End Users. This source code is a "commercial item" as
25
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
26
+ * "commercial computer software" and "commercial computer software
27
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
28
+ * and is provided to the U.S. Government only as a commercial end item.
29
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
30
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
31
+ * source code with only those rights set forth herein.
32
+ *
33
+ * Any use of this source code in individual and commercial software must
34
+ * include, in the user documentation and internal comments to the code,
35
+ * the above Disclaimer and U.S. Government End Users Notice.
36
+ */
37
+
38
+ #include "nvToolsExt.h"
39
+
40
+ #ifndef NVTOOLSEXT_SYNC_V3
41
+ #define NVTOOLSEXT_SYNC_V3
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif /* __cplusplus */
46
+
47
+ /* \cond SHOW_HIDDEN
48
+ * \version \NVTX_VERSION_2
49
+ */
50
+ #define NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxSyncUserAttributes_v0) ) )
51
+ /** \endcond */
52
+
53
+
54
+ /**
55
+ * \page PAGE_SYNCHRONIZATION Synchronization
56
+ *
57
+ * This section covers a subset of the API that allow users to track additional
58
+ * synchronization details of their application. Naming OS synchronization primitives
59
+ * may allow users to better understand the data collected by traced synchronization
60
+ * APIs. Additionally, a user defined synchronization object can allow the users to
61
+ * to tell the tools when the user is building their own synchronization system
62
+ * that do not rely on the OS to provide behaviors and instead use techniques like
63
+ * atomic operations and spinlocks.
64
+ *
65
+ * See module \ref SYNCHRONIZATION for details.
66
+ *
67
+ * \par Example:
68
+ * \code
69
+ * class MyMutex
70
+ * {
71
+ * volatile long bLocked;
72
+ * nvtxSyncUser_t hSync;
73
+ * public:
74
+ * MyMutex(const char* name, nvtxDomainHandle_t d){
75
+ * bLocked = 0;
76
+ *
77
+ * nvtxSyncUserAttributes_t attribs = { 0 };
78
+ * attribs.version = NVTX_VERSION;
79
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
80
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
81
+ * attribs.message.ascii = name;
82
+ * hSync = nvtxDomainSyncUserCreate(d, &attribs);
83
+ * }
84
+ *
85
+ * ~MyMutex() {
86
+ * nvtxDomainSyncUserDestroy(hSync);
87
+ * }
88
+ *
89
+ * bool Lock() {
90
+ * nvtxDomainSyncUserAcquireStart(hSync);
91
+ * bool acquired = __sync_bool_compare_and_swap(&bLocked, 0, 1);//atomic compiler intrinsic
92
+
93
+ * if (acquired) {
94
+ * nvtxDomainSyncUserAcquireSuccess(hSync);
95
+ * }
96
+ * else {
97
+ * nvtxDomainSyncUserAcquireFailed(hSync);
98
+ * }
99
+ * return acquired;
100
+ * }
101
+
102
+ * void Unlock() {
103
+ * nvtxDomainSyncUserReleasing(hSync);
104
+ * bLocked = false;
105
+ * }
106
+ * };
107
+ * \endcode
108
+ *
109
+ * \version \NVTX_VERSION_2
110
+ */
111
+
112
+ /* ------------------------------------------------------------------------- */
113
+ /* \cond SHOW_HIDDEN
114
+ * \brief Used to build a non-colliding value for resource types separated class
115
+ * \version \NVTX_VERSION_2
116
+ */
117
+ #define NVTX_RESOURCE_CLASS_SYNC_OS 2 /**< Synchronization objects that are OS specific. */
118
+ #define NVTX_RESOURCE_CLASS_SYNC_PTHREAD 3 /**< Synchronization objects that are from the POSIX Threads API (pthread)*/
119
+ /** \endcond */
120
+
121
+
122
+ /* ------------------------------------------------------------------------- */
123
+ /** \defgroup SYNCHRONIZATION Synchronization
124
+ * See page \ref PAGE_SYNCHRONIZATION.
125
+ * @{
126
+ */
127
+
128
+ /** \brief Resource type values for OSs with POSIX Thread API support
129
+ */
130
+ typedef enum nvtxResourceSyncPosixThreadType_t
131
+ {
132
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 1), /* pthread_mutex_t */
133
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_CONDITION = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 2), /* pthread_cond_t */
134
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_RWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 3), /* pthread_rwlock_t */
135
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_BARRIER = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 4), /* pthread_barrier_t */
136
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 5), /* pthread_spinlock_t */
137
+ NVTX_RESOURCE_TYPE_SYNC_PTHREAD_ONCE = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 6) /* pthread_once_t */
138
+ } nvtxResourceSyncPosixThreadType_t;
139
+
140
+ /** \brief Resource type values for Windows OSs
141
+ */
142
+ typedef enum nvtxResourceSyncWindowsType_t
143
+ {
144
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
145
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
146
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_EVENT = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
147
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_CRITICAL_SECTION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
148
+ NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SRWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5)
149
+ } nvtxResourceSyncWindowsType_t;
150
+
151
+ /** \brief Resource type values for Linux and Linux derived OSs such as Android
152
+ * \sa
153
+ * ::nvtxResourceSyncPosixThreadType_t
154
+ */
155
+ typedef enum nvtxResourceSyncLinuxType_t
156
+ {
157
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
158
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_FUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
159
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
160
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_COMPLETION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
161
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5),
162
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_SEQLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 6),
163
+ NVTX_RESOURCE_TYPE_SYNC_LINUX_RCU = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 7)
164
+ } nvtxResourceSyncLinuxType_t;
165
+
166
+ /** \brief Resource type values for Android come from Linux.
167
+ * \sa
168
+ * ::nvtxResourceSyncLinuxType_t
169
+ * ::nvtxResourceSyncPosixThreadType_t
170
+ */
171
+ typedef enum nvtxResourceSyncLinuxType_t nvtxResourceSyncAndroidType_t;
172
+
173
+ /** \brief User Defined Synchronization Object Handle .
174
+ * \anchor SYNCUSER_HANDLE_STRUCTURE
175
+ *
176
+ * This structure is opaque to the user and is used as a handle to reference
177
+ * a user defined syncrhonization object. The tools will return a pointer through the API for the application
178
+ * to hold on it's behalf to reference the string in the future.
179
+ *
180
+ */
181
+ typedef struct nvtxSyncUser* nvtxSyncUser_t;
182
+
183
+ /** \brief User Defined Synchronization Object Attributes Structure.
184
+ * \anchor USERDEF_SYNC_ATTRIBUTES_STRUCTURE
185
+ *
186
+ * This structure is used to describe the attributes of a user defined synchronization
187
+ * object. The layout of the structure is defined by a specific version of the tools
188
+ * extension library and can change between different versions of the Tools Extension
189
+ * library.
190
+ *
191
+ * \par Initializing the Attributes
192
+ *
193
+ * The caller should always perform the following three tasks when using
194
+ * attributes:
195
+ * <ul>
196
+ * <li>Zero the structure
197
+ * <li>Set the version field
198
+ * <li>Set the size field
199
+ * </ul>
200
+ *
201
+ * Zeroing the structure sets all the event attributes types and values
202
+ * to the default value.
203
+ *
204
+ * The version and size field are used by the Tools Extension
205
+ * implementation to handle multiple versions of the attributes structure.
206
+ *
207
+ * It is recommended that the caller use one of the following to methods
208
+ * to initialize the event attributes structure:
209
+ *
210
+ * \par Method 1: Initializing nvtxEventAttributes for future compatibility
211
+ * \code
212
+ * nvtxSyncUserAttributes_t attribs = {0};
213
+ * attribs.version = NVTX_VERSION;
214
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
215
+ * \endcode
216
+ *
217
+ * \par Method 2: Initializing nvtxSyncUserAttributes_t for a specific version
218
+ * \code
219
+ * nvtxSyncUserAttributes_t attribs = {0};
220
+ * attribs.version = 1;
221
+ * attribs.size = (uint16_t)(sizeof(nvtxSyncUserAttributes_t));
222
+ * \endcode
223
+ *
224
+ * If the caller uses Method 1 it is critical that the entire binary
225
+ * layout of the structure be configured to 0 so that all fields
226
+ * are initialized to the default value.
227
+ *
228
+ * The caller should either use both NVTX_VERSION and
229
+ * NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
230
+ * and a versioned type (Method 2). Using a mix of the two methods
231
+ * will likely cause either source level incompatibility or binary
232
+ * incompatibility in the future.
233
+ *
234
+ * \par Settings Attribute Types and Values
235
+ *
236
+ *
237
+ * \par Example:
238
+ * \code
239
+ * // Initialize
240
+ * nvtxSyncUserAttributes_t attribs = {0};
241
+ * attribs.version = NVTX_VERSION;
242
+ * attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
243
+ *
244
+ * // Configure the Attributes
245
+ * attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
246
+ * attribs.message.ascii = "Example";
247
+ * \endcode
248
+ *
249
+ * \sa
250
+ * ::nvtxDomainSyncUserCreate
251
+ */
252
+ typedef struct nvtxSyncUserAttributes_v0
253
+ {
254
+ /**
255
+ * \brief Version flag of the structure.
256
+ *
257
+ * Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
258
+ * supported in this header file. This can optionally be overridden to
259
+ * another version of the tools extension library.
260
+ */
261
+ uint16_t version;
262
+
263
+ /**
264
+ * \brief Size of the structure.
265
+ *
266
+ * Needs to be set to the size in bytes of the event attribute
267
+ * structure used to specify the event.
268
+ */
269
+ uint16_t size;
270
+
271
+ /** \brief Message type specified in this attribute structure.
272
+ *
273
+ * Defines the message format of the attribute structure's \ref nvtxSyncUserAttributes_v0::message
274
+ * "message" field.
275
+ *
276
+ * Default Value is NVTX_MESSAGE_UNKNOWN
277
+ */
278
+ int32_t messageType; /* nvtxMessageType_t */
279
+
280
+ /** \brief Message assigned to this attribute structure.
281
+ *
282
+ * The text message that is attached to an event.
283
+ */
284
+ nvtxMessageValue_t message;
285
+
286
+ } nvtxSyncUserAttributes_v0;
287
+
288
+ typedef struct nvtxSyncUserAttributes_v0 nvtxSyncUserAttributes_t;
289
+
290
+ /* ------------------------------------------------------------------------- */
291
+ /** \brief Create a user defined synchronization object
292
+ * This is used to track non-OS synchronization working with spinlocks and atomics
293
+ *
294
+ * \param domain - Domain to own the resource
295
+ * \param attribs - A structure to assign multiple attributes to the object.
296
+ *
297
+ * \return A handle that represents the newly created user defined synchronization object.
298
+ *
299
+ * \sa
300
+ * ::nvtxDomainSyncUserCreate
301
+ * ::nvtxDomainSyncUserDestroy
302
+ * ::nvtxDomainSyncUserAcquireStart
303
+ * ::nvtxDomainSyncUserAcquireFailed
304
+ * ::nvtxDomainSyncUserAcquireSuccess
305
+ * ::nvtxDomainSyncUserReleasing
306
+ *
307
+ * \version \NVTX_VERSION_2
308
+ */
309
+ NVTX_DECLSPEC nvtxSyncUser_t NVTX_API nvtxDomainSyncUserCreate(nvtxDomainHandle_t domain, const nvtxSyncUserAttributes_t* attribs);
310
+
311
+ /* ------------------------------------------------------------------------- */
312
+ /** \brief Destroy a user defined synchronization object
313
+ * This is used to track non-OS synchronization working with spinlocks and atomics
314
+ *
315
+ * \param handle - A handle to the object to operate on.
316
+ *
317
+ * \sa
318
+ * ::nvtxDomainSyncUserCreate
319
+ * ::nvtxDomainSyncUserDestroy
320
+ * ::nvtxDomainSyncUserAcquireStart
321
+ * ::nvtxDomainSyncUserAcquireFailed
322
+ * ::nvtxDomainSyncUserAcquireSuccess
323
+ * ::nvtxDomainSyncUserReleasing
324
+ *
325
+ * \version \NVTX_VERSION_2
326
+ */
327
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserDestroy(nvtxSyncUser_t handle);
328
+
329
+ /* ------------------------------------------------------------------------- */
330
+ /** \brief Signal to tools that an attempt to acquire a user defined synchronization object
331
+ *
332
+ * \param handle - A handle to the object to operate on.
333
+ *
334
+ * \sa
335
+ * ::nvtxDomainSyncUserCreate
336
+ * ::nvtxDomainSyncUserDestroy
337
+ * ::nvtxDomainSyncUserAcquireStart
338
+ * ::nvtxDomainSyncUserAcquireFailed
339
+ * ::nvtxDomainSyncUserAcquireSuccess
340
+ * ::nvtxDomainSyncUserReleasing
341
+ *
342
+ * \version \NVTX_VERSION_2
343
+ */
344
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireStart(nvtxSyncUser_t handle);
345
+
346
+ /* ------------------------------------------------------------------------- */
347
+ /** \brief Signal to tools of failure in acquiring a user defined synchronization object
348
+ * This should be called after \ref nvtxDomainSyncUserAcquireStart
349
+ *
350
+ * \param handle - A handle to the object to operate on.
351
+ *
352
+ * \sa
353
+ * ::nvtxDomainSyncUserCreate
354
+ * ::nvtxDomainSyncUserDestroy
355
+ * ::nvtxDomainSyncUserAcquireStart
356
+ * ::nvtxDomainSyncUserAcquireFailed
357
+ * ::nvtxDomainSyncUserAcquireSuccess
358
+ * ::nvtxDomainSyncUserReleasing
359
+ *
360
+ * \version \NVTX_VERSION_2
361
+ */NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireFailed(nvtxSyncUser_t handle);
362
+
363
+ /* ------------------------------------------------------------------------- */
364
+ /** \brief Signal to tools of success in acquiring a user defined synchronization object
365
+ * This should be called after \ref nvtxDomainSyncUserAcquireStart.
366
+ *
367
+ * \param handle - A handle to the object to operate on.
368
+ *
369
+ * \sa
370
+ * ::nvtxDomainSyncUserCreate
371
+ * ::nvtxDomainSyncUserDestroy
372
+ * ::nvtxDomainSyncUserAcquireStart
373
+ * ::nvtxDomainSyncUserAcquireFailed
374
+ * ::nvtxDomainSyncUserAcquireSuccess
375
+ * ::nvtxDomainSyncUserReleasing
376
+ *
377
+ * \version \NVTX_VERSION_2
378
+ */NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireSuccess(nvtxSyncUser_t handle);
379
+
380
+ /* ------------------------------------------------------------------------- */
381
+ /** \brief Signal to tools of releasing a reservation on user defined synchronization object
382
+ * This should be called after \ref nvtxDomainSyncUserAcquireSuccess.
383
+ *
384
+ * \param handle - A handle to the object to operate on.
385
+ *
386
+ * \sa
387
+ * ::nvtxDomainSyncUserCreate
388
+ * ::nvtxDomainSyncUserDestroy
389
+ * ::nvtxDomainSyncUserAcquireStart
390
+ * ::nvtxDomainSyncUserAcquireFailed
391
+ * ::nvtxDomainSyncUserAcquireSuccess
392
+ * ::nvtxDomainSyncUserReleasing
393
+ *
394
+ * \version \NVTX_VERSION_2
395
+ */
396
+ NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserReleasing(nvtxSyncUser_t handle);
397
+
398
+
399
+ /** @} */ /*END defgroup*/
400
+
401
+ #ifdef __cplusplus
402
+ }
403
+ #endif /* __cplusplus */
404
+
405
+ #ifndef NVTX_NO_IMPL
406
+ #define NVTX_IMPL_GUARD_SYNC /* Ensure other headers cannot included directly */
407
+ #include "nvtxDetail/nvtxImplSync_v3.h"
408
+ #undef NVTX_IMPL_GUARD_SYNC
409
+ #endif /*NVTX_NO_IMPL*/
410
+
411
+ #endif /* NVTOOLSEXT_SYNC_V3 */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImpl.h ADDED
@@ -0,0 +1,469 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* This file was procedurally generated! Do not modify this file by hand. */
2
+
3
+ /*
4
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
5
+ *
6
+ * NOTICE TO USER:
7
+ *
8
+ * This source code is subject to NVIDIA ownership rights under U.S. and
9
+ * international Copyright laws.
10
+ *
11
+ * This software and the information contained herein is PROPRIETARY and
12
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
13
+ * of a form of NVIDIA software license agreement.
14
+ *
15
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
16
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
17
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
18
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
19
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
20
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
21
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
22
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
23
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
24
+ * OR PERFORMANCE OF THIS SOURCE CODE.
25
+ *
26
+ * U.S. Government End Users. This source code is a "commercial item" as
27
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
28
+ * "commercial computer software" and "commercial computer software
29
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
30
+ * and is provided to the U.S. Government only as a commercial end item.
31
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
32
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
33
+ * source code with only those rights set forth herein.
34
+ *
35
+ * Any use of this source code in individual and commercial software must
36
+ * include, in the user documentation and internal comments to the code,
37
+ * the above Disclaimer and U.S. Government End Users Notice.
38
+ */
39
+
40
+ #ifndef NVTX_IMPL_GUARD
41
+ #error Never include this file directly -- it is automatically included by nvToolsExt.h (except when NVTX_NO_IMPL is defined).
42
+ #endif
43
+
44
+ /* ---- Include required platform headers ---- */
45
+
46
+ #if defined(_WIN32)
47
+
48
+ #include <Windows.h>
49
+
50
+ #else
51
+ #include <unistd.h>
52
+
53
+ #if defined(__ANDROID__)
54
+ #include <android/api-level.h>
55
+ #endif
56
+
57
+ #if defined(__linux__) || defined(__CYGWIN__)
58
+ #include <sched.h>
59
+ #endif
60
+
61
+ #include <limits.h>
62
+ #include <dlfcn.h>
63
+ #include <fcntl.h>
64
+ #include <stdlib.h>
65
+ #include <stdio.h>
66
+ #include <sys/types.h>
67
+ #include <unistd.h>
68
+ #include <errno.h>
69
+
70
+ #include <string.h>
71
+ #include <sys/types.h>
72
+ #include <pthread.h>
73
+ #include <stdlib.h>
74
+ #include <wchar.h>
75
+
76
+ #endif
77
+
78
+ /* ---- Define macros used in this file ---- */
79
+
80
+ #define NVTX_INIT_STATE_FRESH 0
81
+ #define NVTX_INIT_STATE_STARTED 1
82
+ #define NVTX_INIT_STATE_COMPLETE 2
83
+
84
+ #ifdef NVTX_DEBUG_PRINT
85
+ #ifdef __ANDROID__
86
+ #include <android/log.h>
87
+ #define NVTX_ERR(...) __android_log_print(ANDROID_LOG_ERROR, "NVTOOLSEXT", __VA_ARGS__);
88
+ #define NVTX_INFO(...) __android_log_print(ANDROID_LOG_INFO, "NVTOOLSEXT", __VA_ARGS__);
89
+ #else
90
+ #include <stdio.h>
91
+ #define NVTX_ERR(...) fprintf(stderr, "NVTX_ERROR: " __VA_ARGS__)
92
+ #define NVTX_INFO(...) fprintf(stderr, "NVTX_INFO: " __VA_ARGS__)
93
+ #endif
94
+ #else /* !defined(NVTX_DEBUG_PRINT) */
95
+ #define NVTX_ERR(...)
96
+ #define NVTX_INFO(...)
97
+ #endif
98
+
99
+ #ifdef __cplusplus
100
+ extern "C" {
101
+ #endif /* __cplusplus */
102
+
103
+ #ifdef __GNUC__
104
+ #pragma GCC visibility push(hidden)
105
+ #endif
106
+
107
+ /* ---- Forward declare all functions referenced in globals ---- */
108
+
109
+ NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_VERSIONED_IDENTIFIER(nvtxInitOnce)(void);
110
+ NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxEtiGetModuleFunctionTable)(
111
+ NvtxCallbackModule module,
112
+ NvtxFunctionTable* out_table,
113
+ unsigned int* out_size);
114
+ NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxEtiSetInjectionNvtxVersion)(
115
+ uint32_t version);
116
+ NVTX_LINKONCE_FWDDECL_FUNCTION const void* NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxGetExportTable)(
117
+ uint32_t exportTableId);
118
+
119
+ #include "nvtxInitDecls.h"
120
+
121
+ /* ---- Define all globals ---- */
122
+
123
+ typedef struct nvtxGlobals_t
124
+ {
125
+ volatile unsigned int initState;
126
+ NvtxExportTableCallbacks etblCallbacks;
127
+ NvtxExportTableVersionInfo etblVersionInfo;
128
+
129
+ /* Implementation function pointers */
130
+ nvtxMarkEx_impl_fntype nvtxMarkEx_impl_fnptr;
131
+ nvtxMarkA_impl_fntype nvtxMarkA_impl_fnptr;
132
+ nvtxMarkW_impl_fntype nvtxMarkW_impl_fnptr;
133
+ nvtxRangeStartEx_impl_fntype nvtxRangeStartEx_impl_fnptr;
134
+ nvtxRangeStartA_impl_fntype nvtxRangeStartA_impl_fnptr;
135
+ nvtxRangeStartW_impl_fntype nvtxRangeStartW_impl_fnptr;
136
+ nvtxRangeEnd_impl_fntype nvtxRangeEnd_impl_fnptr;
137
+ nvtxRangePushEx_impl_fntype nvtxRangePushEx_impl_fnptr;
138
+ nvtxRangePushA_impl_fntype nvtxRangePushA_impl_fnptr;
139
+ nvtxRangePushW_impl_fntype nvtxRangePushW_impl_fnptr;
140
+ nvtxRangePop_impl_fntype nvtxRangePop_impl_fnptr;
141
+ nvtxNameCategoryA_impl_fntype nvtxNameCategoryA_impl_fnptr;
142
+ nvtxNameCategoryW_impl_fntype nvtxNameCategoryW_impl_fnptr;
143
+ nvtxNameOsThreadA_impl_fntype nvtxNameOsThreadA_impl_fnptr;
144
+ nvtxNameOsThreadW_impl_fntype nvtxNameOsThreadW_impl_fnptr;
145
+
146
+ nvtxNameCuDeviceA_fakeimpl_fntype nvtxNameCuDeviceA_impl_fnptr;
147
+ nvtxNameCuDeviceW_fakeimpl_fntype nvtxNameCuDeviceW_impl_fnptr;
148
+ nvtxNameCuContextA_fakeimpl_fntype nvtxNameCuContextA_impl_fnptr;
149
+ nvtxNameCuContextW_fakeimpl_fntype nvtxNameCuContextW_impl_fnptr;
150
+ nvtxNameCuStreamA_fakeimpl_fntype nvtxNameCuStreamA_impl_fnptr;
151
+ nvtxNameCuStreamW_fakeimpl_fntype nvtxNameCuStreamW_impl_fnptr;
152
+ nvtxNameCuEventA_fakeimpl_fntype nvtxNameCuEventA_impl_fnptr;
153
+ nvtxNameCuEventW_fakeimpl_fntype nvtxNameCuEventW_impl_fnptr;
154
+
155
+ nvtxNameClDeviceA_fakeimpl_fntype nvtxNameClDeviceA_impl_fnptr;
156
+ nvtxNameClDeviceW_fakeimpl_fntype nvtxNameClDeviceW_impl_fnptr;
157
+ nvtxNameClContextA_fakeimpl_fntype nvtxNameClContextA_impl_fnptr;
158
+ nvtxNameClContextW_fakeimpl_fntype nvtxNameClContextW_impl_fnptr;
159
+ nvtxNameClCommandQueueA_fakeimpl_fntype nvtxNameClCommandQueueA_impl_fnptr;
160
+ nvtxNameClCommandQueueW_fakeimpl_fntype nvtxNameClCommandQueueW_impl_fnptr;
161
+ nvtxNameClMemObjectA_fakeimpl_fntype nvtxNameClMemObjectA_impl_fnptr;
162
+ nvtxNameClMemObjectW_fakeimpl_fntype nvtxNameClMemObjectW_impl_fnptr;
163
+ nvtxNameClSamplerA_fakeimpl_fntype nvtxNameClSamplerA_impl_fnptr;
164
+ nvtxNameClSamplerW_fakeimpl_fntype nvtxNameClSamplerW_impl_fnptr;
165
+ nvtxNameClProgramA_fakeimpl_fntype nvtxNameClProgramA_impl_fnptr;
166
+ nvtxNameClProgramW_fakeimpl_fntype nvtxNameClProgramW_impl_fnptr;
167
+ nvtxNameClEventA_fakeimpl_fntype nvtxNameClEventA_impl_fnptr;
168
+ nvtxNameClEventW_fakeimpl_fntype nvtxNameClEventW_impl_fnptr;
169
+
170
+ nvtxNameCudaDeviceA_impl_fntype nvtxNameCudaDeviceA_impl_fnptr;
171
+ nvtxNameCudaDeviceW_impl_fntype nvtxNameCudaDeviceW_impl_fnptr;
172
+ nvtxNameCudaStreamA_fakeimpl_fntype nvtxNameCudaStreamA_impl_fnptr;
173
+ nvtxNameCudaStreamW_fakeimpl_fntype nvtxNameCudaStreamW_impl_fnptr;
174
+ nvtxNameCudaEventA_fakeimpl_fntype nvtxNameCudaEventA_impl_fnptr;
175
+ nvtxNameCudaEventW_fakeimpl_fntype nvtxNameCudaEventW_impl_fnptr;
176
+
177
+ nvtxDomainMarkEx_impl_fntype nvtxDomainMarkEx_impl_fnptr;
178
+ nvtxDomainRangeStartEx_impl_fntype nvtxDomainRangeStartEx_impl_fnptr;
179
+ nvtxDomainRangeEnd_impl_fntype nvtxDomainRangeEnd_impl_fnptr;
180
+ nvtxDomainRangePushEx_impl_fntype nvtxDomainRangePushEx_impl_fnptr;
181
+ nvtxDomainRangePop_impl_fntype nvtxDomainRangePop_impl_fnptr;
182
+ nvtxDomainResourceCreate_impl_fntype nvtxDomainResourceCreate_impl_fnptr;
183
+ nvtxDomainResourceDestroy_impl_fntype nvtxDomainResourceDestroy_impl_fnptr;
184
+ nvtxDomainNameCategoryA_impl_fntype nvtxDomainNameCategoryA_impl_fnptr;
185
+ nvtxDomainNameCategoryW_impl_fntype nvtxDomainNameCategoryW_impl_fnptr;
186
+ nvtxDomainRegisterStringA_impl_fntype nvtxDomainRegisterStringA_impl_fnptr;
187
+ nvtxDomainRegisterStringW_impl_fntype nvtxDomainRegisterStringW_impl_fnptr;
188
+ nvtxDomainCreateA_impl_fntype nvtxDomainCreateA_impl_fnptr;
189
+ nvtxDomainCreateW_impl_fntype nvtxDomainCreateW_impl_fnptr;
190
+ nvtxDomainDestroy_impl_fntype nvtxDomainDestroy_impl_fnptr;
191
+ nvtxInitialize_impl_fntype nvtxInitialize_impl_fnptr;
192
+
193
+ nvtxDomainSyncUserCreate_impl_fntype nvtxDomainSyncUserCreate_impl_fnptr;
194
+ nvtxDomainSyncUserDestroy_impl_fntype nvtxDomainSyncUserDestroy_impl_fnptr;
195
+ nvtxDomainSyncUserAcquireStart_impl_fntype nvtxDomainSyncUserAcquireStart_impl_fnptr;
196
+ nvtxDomainSyncUserAcquireFailed_impl_fntype nvtxDomainSyncUserAcquireFailed_impl_fnptr;
197
+ nvtxDomainSyncUserAcquireSuccess_impl_fntype nvtxDomainSyncUserAcquireSuccess_impl_fnptr;
198
+ nvtxDomainSyncUserReleasing_impl_fntype nvtxDomainSyncUserReleasing_impl_fnptr;
199
+
200
+ /* Tables of function pointers -- Extra null added to the end to ensure
201
+ * a crash instead of silent corruption if a tool reads off the end. */
202
+ NvtxFunctionPointer* functionTable_CORE [NVTX_CBID_CORE_SIZE + 1];
203
+ NvtxFunctionPointer* functionTable_CUDA [NVTX_CBID_CUDA_SIZE + 1];
204
+ NvtxFunctionPointer* functionTable_OPENCL[NVTX_CBID_OPENCL_SIZE + 1];
205
+ NvtxFunctionPointer* functionTable_CUDART[NVTX_CBID_CUDART_SIZE + 1];
206
+ NvtxFunctionPointer* functionTable_CORE2 [NVTX_CBID_CORE2_SIZE + 1];
207
+ NvtxFunctionPointer* functionTable_SYNC [NVTX_CBID_SYNC_SIZE + 1];
208
+ } nvtxGlobals_t;
209
+
210
+ NVTX_LINKONCE_DEFINE_GLOBAL nvtxGlobals_t NVTX_VERSIONED_IDENTIFIER(nvtxGlobals) =
211
+ {
212
+ NVTX_INIT_STATE_FRESH,
213
+
214
+ {
215
+ sizeof(NvtxExportTableCallbacks),
216
+ NVTX_VERSIONED_IDENTIFIER(nvtxEtiGetModuleFunctionTable)
217
+ },
218
+ {
219
+ sizeof(NvtxExportTableVersionInfo),
220
+ NVTX_VERSION,
221
+ 0,
222
+ NVTX_VERSIONED_IDENTIFIER(nvtxEtiSetInjectionNvtxVersion)
223
+ },
224
+
225
+ /* Implementation function pointers */
226
+ NVTX_VERSIONED_IDENTIFIER(nvtxMarkEx_impl_init),
227
+ NVTX_VERSIONED_IDENTIFIER(nvtxMarkA_impl_init),
228
+ NVTX_VERSIONED_IDENTIFIER(nvtxMarkW_impl_init),
229
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartEx_impl_init),
230
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartA_impl_init),
231
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartW_impl_init),
232
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangeEnd_impl_init),
233
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangePushEx_impl_init),
234
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangePushA_impl_init),
235
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangePushW_impl_init),
236
+ NVTX_VERSIONED_IDENTIFIER(nvtxRangePop_impl_init),
237
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCategoryA_impl_init),
238
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCategoryW_impl_init),
239
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameOsThreadA_impl_init),
240
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameOsThreadW_impl_init),
241
+
242
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuDeviceA_impl_init),
243
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuDeviceW_impl_init),
244
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuContextA_impl_init),
245
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuContextW_impl_init),
246
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuStreamA_impl_init),
247
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuStreamW_impl_init),
248
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuEventA_impl_init),
249
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCuEventW_impl_init),
250
+
251
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClDeviceA_impl_init),
252
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClDeviceW_impl_init),
253
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClContextA_impl_init),
254
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClContextW_impl_init),
255
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClCommandQueueA_impl_init),
256
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClCommandQueueW_impl_init),
257
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClMemObjectA_impl_init),
258
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClMemObjectW_impl_init),
259
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClSamplerA_impl_init),
260
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClSamplerW_impl_init),
261
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClProgramA_impl_init),
262
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClProgramW_impl_init),
263
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClEventA_impl_init),
264
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameClEventW_impl_init),
265
+
266
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaDeviceA_impl_init),
267
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaDeviceW_impl_init),
268
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaStreamA_impl_init),
269
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaStreamW_impl_init),
270
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaEventA_impl_init),
271
+ NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaEventW_impl_init),
272
+
273
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainMarkEx_impl_init),
274
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangeStartEx_impl_init),
275
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangeEnd_impl_init),
276
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangePushEx_impl_init),
277
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangePop_impl_init),
278
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainResourceCreate_impl_init),
279
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainResourceDestroy_impl_init),
280
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainNameCategoryA_impl_init),
281
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainNameCategoryW_impl_init),
282
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRegisterStringA_impl_init),
283
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainRegisterStringW_impl_init),
284
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainCreateA_impl_init),
285
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainCreateW_impl_init),
286
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainDestroy_impl_init),
287
+ NVTX_VERSIONED_IDENTIFIER(nvtxInitialize_impl_init),
288
+
289
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserCreate_impl_init),
290
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserDestroy_impl_init),
291
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireStart_impl_init),
292
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireFailed_impl_init),
293
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireSuccess_impl_init),
294
+ NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserReleasing_impl_init),
295
+
296
+ /* Tables of function pointers */
297
+ {
298
+ 0,
299
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkEx_impl_fnptr,
300
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkA_impl_fnptr,
301
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkW_impl_fnptr,
302
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartEx_impl_fnptr,
303
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartA_impl_fnptr,
304
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartW_impl_fnptr,
305
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeEnd_impl_fnptr,
306
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushEx_impl_fnptr,
307
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushA_impl_fnptr,
308
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushW_impl_fnptr,
309
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePop_impl_fnptr,
310
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCategoryA_impl_fnptr,
311
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCategoryW_impl_fnptr,
312
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameOsThreadA_impl_fnptr,
313
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameOsThreadW_impl_fnptr,
314
+ 0
315
+ },
316
+ {
317
+ 0,
318
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuDeviceA_impl_fnptr,
319
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuDeviceW_impl_fnptr,
320
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuContextA_impl_fnptr,
321
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuContextW_impl_fnptr,
322
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuStreamA_impl_fnptr,
323
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuStreamW_impl_fnptr,
324
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuEventA_impl_fnptr,
325
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuEventW_impl_fnptr,
326
+ 0
327
+ },
328
+ {
329
+ 0,
330
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClDeviceA_impl_fnptr,
331
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClDeviceW_impl_fnptr,
332
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClContextA_impl_fnptr,
333
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClContextW_impl_fnptr,
334
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClCommandQueueA_impl_fnptr,
335
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClCommandQueueW_impl_fnptr,
336
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClMemObjectA_impl_fnptr,
337
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClMemObjectW_impl_fnptr,
338
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClSamplerA_impl_fnptr,
339
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClSamplerW_impl_fnptr,
340
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClProgramA_impl_fnptr,
341
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClProgramW_impl_fnptr,
342
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClEventA_impl_fnptr,
343
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameClEventW_impl_fnptr,
344
+ 0
345
+ },
346
+ {
347
+ 0,
348
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaDeviceA_impl_fnptr,
349
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaDeviceW_impl_fnptr,
350
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaStreamA_impl_fnptr,
351
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaStreamW_impl_fnptr,
352
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaEventA_impl_fnptr,
353
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaEventW_impl_fnptr,
354
+ 0
355
+ },
356
+ {
357
+ 0,
358
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainMarkEx_impl_fnptr,
359
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangeStartEx_impl_fnptr,
360
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangeEnd_impl_fnptr,
361
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangePushEx_impl_fnptr,
362
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangePop_impl_fnptr,
363
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainResourceCreate_impl_fnptr,
364
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainResourceDestroy_impl_fnptr,
365
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainNameCategoryA_impl_fnptr,
366
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainNameCategoryW_impl_fnptr,
367
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRegisterStringA_impl_fnptr,
368
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRegisterStringW_impl_fnptr,
369
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainCreateA_impl_fnptr,
370
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainCreateW_impl_fnptr,
371
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainDestroy_impl_fnptr,
372
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxInitialize_impl_fnptr,
373
+ 0
374
+ },
375
+ {
376
+ 0,
377
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserCreate_impl_fnptr,
378
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserDestroy_impl_fnptr,
379
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserAcquireStart_impl_fnptr,
380
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserAcquireFailed_impl_fnptr,
381
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserAcquireSuccess_impl_fnptr,
382
+ (NvtxFunctionPointer*)&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainSyncUserReleasing_impl_fnptr,
383
+ 0
384
+ }
385
+ };
386
+
387
+ /* ---- Define static inline implementations of core API functions ---- */
388
+
389
+ #include "nvtxImplCore.h"
390
+
391
+ /* ---- Define implementations of export table functions ---- */
392
+
393
+ NVTX_LINKONCE_DEFINE_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxEtiGetModuleFunctionTable)(
394
+ NvtxCallbackModule module,
395
+ NvtxFunctionTable* out_table,
396
+ unsigned int* out_size)
397
+ {
398
+ unsigned int bytes = 0;
399
+ NvtxFunctionTable table = (NvtxFunctionTable)0;
400
+
401
+ switch (module)
402
+ {
403
+ case NVTX_CB_MODULE_CORE:
404
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CORE;
405
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CORE);
406
+ break;
407
+ case NVTX_CB_MODULE_CUDA:
408
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CUDA;
409
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CUDA);
410
+ break;
411
+ case NVTX_CB_MODULE_OPENCL:
412
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_OPENCL;
413
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_OPENCL);
414
+ break;
415
+ case NVTX_CB_MODULE_CUDART:
416
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CUDART;
417
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CUDART);
418
+ break;
419
+ case NVTX_CB_MODULE_CORE2:
420
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CORE2;
421
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_CORE2);
422
+ break;
423
+ case NVTX_CB_MODULE_SYNC:
424
+ table = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_SYNC;
425
+ bytes = (unsigned int)sizeof(NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).functionTable_SYNC);
426
+ break;
427
+ default: return 0;
428
+ }
429
+
430
+ if (out_size)
431
+ *out_size = (bytes / (unsigned int)sizeof(NvtxFunctionPointer*)) - 1;
432
+
433
+ if (out_table)
434
+ *out_table = table;
435
+
436
+ return 1;
437
+ }
438
+
439
+ NVTX_LINKONCE_DEFINE_FUNCTION const void* NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxGetExportTable)(uint32_t exportTableId)
440
+ {
441
+ switch (exportTableId)
442
+ {
443
+ case NVTX_ETID_CALLBACKS: return &NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).etblCallbacks;
444
+ case NVTX_ETID_VERSIONINFO: return &NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).etblVersionInfo;
445
+ default: return 0;
446
+ }
447
+ }
448
+
449
+ NVTX_LINKONCE_DEFINE_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxEtiSetInjectionNvtxVersion)(uint32_t version)
450
+ {
451
+ /* Reserved for custom implementations to resolve problems with tools */
452
+ (void)version;
453
+ }
454
+
455
+ /* ---- Define implementations of init versions of all API functions ---- */
456
+
457
+ #include "nvtxInitDefs.h"
458
+
459
+ /* ---- Define implementations of initialization functions ---- */
460
+
461
+ #include "nvtxInit.h"
462
+
463
+ #ifdef __GNUC__
464
+ #pragma GCC visibility pop
465
+ #endif
466
+
467
+ #ifdef __cplusplus
468
+ } /* extern "C" */
469
+ #endif /* __cplusplus */
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCore.h ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib)
2
+ {
3
+ #ifndef NVTX_DISABLE
4
+ nvtxMarkEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkEx_impl_fnptr;
5
+ if(local!=0)
6
+ (*local)(eventAttrib);
7
+ #endif /*NVTX_DISABLE*/
8
+ }
9
+
10
+ NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message)
11
+ {
12
+ #ifndef NVTX_DISABLE
13
+ nvtxMarkA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkA_impl_fnptr;
14
+ if(local!=0)
15
+ (*local)(message);
16
+ #endif /*NVTX_DISABLE*/
17
+ }
18
+
19
+ NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message)
20
+ {
21
+ #ifndef NVTX_DISABLE
22
+ nvtxMarkW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxMarkW_impl_fnptr;
23
+ if(local!=0)
24
+ (*local)(message);
25
+ #endif /*NVTX_DISABLE*/
26
+ }
27
+
28
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib)
29
+ {
30
+ #ifndef NVTX_DISABLE
31
+ nvtxRangeStartEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartEx_impl_fnptr;
32
+ if(local!=0)
33
+ return (*local)(eventAttrib);
34
+ else
35
+ #endif /*NVTX_DISABLE*/
36
+ return (nvtxRangeId_t)0;
37
+ }
38
+
39
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message)
40
+ {
41
+ #ifndef NVTX_DISABLE
42
+ nvtxRangeStartA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartA_impl_fnptr;
43
+ if(local!=0)
44
+ return (*local)(message);
45
+ else
46
+ #endif /*NVTX_DISABLE*/
47
+ return (nvtxRangeId_t)0;
48
+ }
49
+
50
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message)
51
+ {
52
+ #ifndef NVTX_DISABLE
53
+ nvtxRangeStartW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeStartW_impl_fnptr;
54
+ if(local!=0)
55
+ return (*local)(message);
56
+ else
57
+ #endif /*NVTX_DISABLE*/
58
+ return (nvtxRangeId_t)0;
59
+ }
60
+
61
+ NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id)
62
+ {
63
+ #ifndef NVTX_DISABLE
64
+ nvtxRangeEnd_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangeEnd_impl_fnptr;
65
+ if(local!=0)
66
+ (*local)(id);
67
+ #endif /*NVTX_DISABLE*/
68
+ }
69
+
70
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib)
71
+ {
72
+ #ifndef NVTX_DISABLE
73
+ nvtxRangePushEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushEx_impl_fnptr;
74
+ if(local!=0)
75
+ return (*local)(eventAttrib);
76
+ else
77
+ #endif /*NVTX_DISABLE*/
78
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
79
+ }
80
+
81
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message)
82
+ {
83
+ #ifndef NVTX_DISABLE
84
+ nvtxRangePushA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushA_impl_fnptr;
85
+ if(local!=0)
86
+ return (*local)(message);
87
+ else
88
+ #endif /*NVTX_DISABLE*/
89
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
90
+ }
91
+
92
+ NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message)
93
+ {
94
+ #ifndef NVTX_DISABLE
95
+ nvtxRangePushW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePushW_impl_fnptr;
96
+ if(local!=0)
97
+ return (*local)(message);
98
+ else
99
+ #endif /*NVTX_DISABLE*/
100
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
101
+ }
102
+
103
+ NVTX_DECLSPEC int NVTX_API nvtxRangePop(void)
104
+ {
105
+ #ifndef NVTX_DISABLE
106
+ nvtxRangePop_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxRangePop_impl_fnptr;
107
+ if(local!=0)
108
+ return (*local)();
109
+ else
110
+ #endif /*NVTX_DISABLE*/
111
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
112
+ }
113
+
114
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name)
115
+ {
116
+ #ifndef NVTX_DISABLE
117
+ nvtxNameCategoryA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCategoryA_impl_fnptr;
118
+ if(local!=0)
119
+ (*local)(category, name);
120
+ #endif /*NVTX_DISABLE*/
121
+ }
122
+
123
+ NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name)
124
+ {
125
+ #ifndef NVTX_DISABLE
126
+ nvtxNameCategoryW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCategoryW_impl_fnptr;
127
+ if(local!=0)
128
+ (*local)(category, name);
129
+ #endif /*NVTX_DISABLE*/
130
+ }
131
+
132
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name)
133
+ {
134
+ #ifndef NVTX_DISABLE
135
+ nvtxNameOsThreadA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameOsThreadA_impl_fnptr;
136
+ if(local!=0)
137
+ (*local)(threadId, name);
138
+ #endif /*NVTX_DISABLE*/
139
+ }
140
+
141
+ NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name)
142
+ {
143
+ #ifndef NVTX_DISABLE
144
+ nvtxNameOsThreadW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameOsThreadW_impl_fnptr;
145
+ if(local!=0)
146
+ (*local)(threadId, name);
147
+ #endif /*NVTX_DISABLE*/
148
+ }
149
+
150
+ NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib)
151
+ {
152
+ #ifndef NVTX_DISABLE
153
+ nvtxDomainMarkEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainMarkEx_impl_fnptr;
154
+ if(local!=0)
155
+ (*local)(domain, eventAttrib);
156
+ #endif /*NVTX_DISABLE*/
157
+ }
158
+
159
+ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib)
160
+ {
161
+ #ifndef NVTX_DISABLE
162
+ nvtxDomainRangeStartEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangeStartEx_impl_fnptr;
163
+ if(local!=0)
164
+ return (*local)(domain, eventAttrib);
165
+ else
166
+ #endif /*NVTX_DISABLE*/
167
+ return (nvtxRangeId_t)0;
168
+ }
169
+
170
+ NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id)
171
+ {
172
+ #ifndef NVTX_DISABLE
173
+ nvtxDomainRangeEnd_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangeEnd_impl_fnptr;
174
+ if(local!=0)
175
+ (*local)(domain, id);
176
+ #endif /*NVTX_DISABLE*/
177
+ }
178
+
179
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib)
180
+ {
181
+ #ifndef NVTX_DISABLE
182
+ nvtxDomainRangePushEx_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangePushEx_impl_fnptr;
183
+ if(local!=0)
184
+ return (*local)(domain, eventAttrib);
185
+ else
186
+ #endif /*NVTX_DISABLE*/
187
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
188
+ }
189
+
190
+ NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain)
191
+ {
192
+ #ifndef NVTX_DISABLE
193
+ nvtxDomainRangePop_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRangePop_impl_fnptr;
194
+ if(local!=0)
195
+ return (*local)(domain);
196
+ else
197
+ #endif /*NVTX_DISABLE*/
198
+ return (int)NVTX_NO_PUSH_POP_TRACKING;
199
+ }
200
+
201
+ NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs)
202
+ {
203
+ #ifndef NVTX_DISABLE
204
+ nvtxDomainResourceCreate_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainResourceCreate_impl_fnptr;
205
+ if(local!=0)
206
+ return (*local)(domain, attribs);
207
+ else
208
+ #endif /*NVTX_DISABLE*/
209
+ return (nvtxResourceHandle_t)0;
210
+ }
211
+
212
+ NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource)
213
+ {
214
+ #ifndef NVTX_DISABLE
215
+ nvtxDomainResourceDestroy_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainResourceDestroy_impl_fnptr;
216
+ if(local!=0)
217
+ (*local)(resource);
218
+ #endif /*NVTX_DISABLE*/
219
+ }
220
+
221
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name)
222
+ {
223
+ #ifndef NVTX_DISABLE
224
+ nvtxDomainNameCategoryA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainNameCategoryA_impl_fnptr;
225
+ if(local!=0)
226
+ (*local)(domain, category, name);
227
+ #endif /*NVTX_DISABLE*/
228
+ }
229
+
230
+ NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name)
231
+ {
232
+ #ifndef NVTX_DISABLE
233
+ nvtxDomainNameCategoryW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainNameCategoryW_impl_fnptr;
234
+ if(local!=0)
235
+ (*local)(domain, category, name);
236
+ #endif /*NVTX_DISABLE*/
237
+ }
238
+
239
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string)
240
+ {
241
+ #ifndef NVTX_DISABLE
242
+ nvtxDomainRegisterStringA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRegisterStringA_impl_fnptr;
243
+ if(local!=0)
244
+ return (*local)(domain, string);
245
+ else
246
+ #endif /*NVTX_DISABLE*/
247
+ return (nvtxStringHandle_t)0;
248
+ }
249
+
250
+ NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string)
251
+ {
252
+ #ifndef NVTX_DISABLE
253
+ nvtxDomainRegisterStringW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainRegisterStringW_impl_fnptr;
254
+ if(local!=0)
255
+ return (*local)(domain, string);
256
+ else
257
+ #endif /*NVTX_DISABLE*/
258
+ return (nvtxStringHandle_t)0;
259
+ }
260
+
261
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* message)
262
+ {
263
+ #ifndef NVTX_DISABLE
264
+ nvtxDomainCreateA_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainCreateA_impl_fnptr;
265
+ if(local!=0)
266
+ return (*local)(message);
267
+ else
268
+ #endif /*NVTX_DISABLE*/
269
+ return (nvtxDomainHandle_t)0;
270
+ }
271
+
272
+ NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* message)
273
+ {
274
+ #ifndef NVTX_DISABLE
275
+ nvtxDomainCreateW_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainCreateW_impl_fnptr;
276
+ if(local!=0)
277
+ return (*local)(message);
278
+ else
279
+ #endif /*NVTX_DISABLE*/
280
+ return (nvtxDomainHandle_t)0;
281
+ }
282
+
283
+ NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain)
284
+ {
285
+ #ifndef NVTX_DISABLE
286
+ nvtxDomainDestroy_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxDomainDestroy_impl_fnptr;
287
+ if(local!=0)
288
+ (*local)(domain);
289
+ #endif /*NVTX_DISABLE*/
290
+ }
291
+
292
+ NVTX_DECLSPEC void NVTX_API nvtxInitialize(const void* reserved)
293
+ {
294
+ #ifndef NVTX_DISABLE
295
+ nvtxInitialize_impl_fntype local = NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxInitialize_impl_fnptr;
296
+ if(local!=0)
297
+ (*local)(reserved);
298
+ #endif /*NVTX_DISABLE*/
299
+ }
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCudaRt_v3.h ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* This file was procedurally generated! Do not modify this file by hand. */
2
+
3
+ /*
4
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
5
+ *
6
+ * NOTICE TO USER:
7
+ *
8
+ * This source code is subject to NVIDIA ownership rights under U.S. and
9
+ * international Copyright laws.
10
+ *
11
+ * This software and the information contained herein is PROPRIETARY and
12
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
13
+ * of a form of NVIDIA software license agreement.
14
+ *
15
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
16
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
17
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
18
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
19
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
20
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
21
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
22
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
23
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
24
+ * OR PERFORMANCE OF THIS SOURCE CODE.
25
+ *
26
+ * U.S. Government End Users. This source code is a "commercial item" as
27
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
28
+ * "commercial computer software" and "commercial computer software
29
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
30
+ * and is provided to the U.S. Government only as a commercial end item.
31
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
32
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
33
+ * source code with only those rights set forth herein.
34
+ *
35
+ * Any use of this source code in individual and commercial software must
36
+ * include, in the user documentation and internal comments to the code,
37
+ * the above Disclaimer and U.S. Government End Users Notice.
38
+ */
39
+
40
+ #ifndef NVTX_IMPL_GUARD_CUDART
41
+ #error Never include this file directly -- it is automatically included by nvToolsExtCudaRt.h (except when NVTX_NO_IMPL is defined).
42
+ #endif
43
+
44
+ #ifdef __cplusplus
45
+ extern "C" {
46
+ #endif /* __cplusplus */
47
+
48
+ //typedef void (NVTX_API * nvtxNameCudaDeviceA_impl_fntype)(int device, const char* name);
49
+ //typedef void (NVTX_API * nvtxNameCudaDeviceW_impl_fntype)(int device, const wchar_t* name);
50
+ typedef void (NVTX_API * nvtxNameCudaStreamA_impl_fntype)(cudaStream_t stream, const char* name);
51
+ typedef void (NVTX_API * nvtxNameCudaStreamW_impl_fntype)(cudaStream_t stream, const wchar_t* name);
52
+ typedef void (NVTX_API * nvtxNameCudaEventA_impl_fntype)(cudaEvent_t event, const char* name);
53
+ typedef void (NVTX_API * nvtxNameCudaEventW_impl_fntype)(cudaEvent_t event, const wchar_t* name);
54
+
55
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceA(int device, const char* name)
56
+ {
57
+ #ifndef NVTX_DISABLE
58
+ nvtxNameCudaDeviceA_impl_fntype local = (nvtxNameCudaDeviceA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaDeviceA_impl_fnptr;
59
+ if(local!=0)
60
+ (*local)(device, name);
61
+ #endif /*NVTX_DISABLE*/
62
+ }
63
+
64
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceW(int device, const wchar_t* name)
65
+ {
66
+ #ifndef NVTX_DISABLE
67
+ nvtxNameCudaDeviceW_impl_fntype local = (nvtxNameCudaDeviceW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaDeviceW_impl_fnptr;
68
+ if(local!=0)
69
+ (*local)(device, name);
70
+ #endif /*NVTX_DISABLE*/
71
+ }
72
+
73
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamA(cudaStream_t stream, const char* name)
74
+ {
75
+ #ifndef NVTX_DISABLE
76
+ nvtxNameCudaStreamA_impl_fntype local = (nvtxNameCudaStreamA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaStreamA_impl_fnptr;
77
+ if(local!=0)
78
+ (*local)(stream, name);
79
+ #endif /*NVTX_DISABLE*/
80
+ }
81
+
82
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamW(cudaStream_t stream, const wchar_t* name)
83
+ {
84
+ #ifndef NVTX_DISABLE
85
+ nvtxNameCudaStreamW_impl_fntype local = (nvtxNameCudaStreamW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaStreamW_impl_fnptr;
86
+ if(local!=0)
87
+ (*local)(stream, name);
88
+ #endif /*NVTX_DISABLE*/
89
+ }
90
+
91
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventA(cudaEvent_t event, const char* name)
92
+ {
93
+ #ifndef NVTX_DISABLE
94
+ nvtxNameCudaEventA_impl_fntype local = (nvtxNameCudaEventA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaEventA_impl_fnptr;
95
+ if(local!=0)
96
+ (*local)(event, name);
97
+ #endif /*NVTX_DISABLE*/
98
+ }
99
+
100
+ NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventW(cudaEvent_t event, const wchar_t* name)
101
+ {
102
+ #ifndef NVTX_DISABLE
103
+ nvtxNameCudaEventW_impl_fntype local = (nvtxNameCudaEventW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCudaEventW_impl_fnptr;
104
+ if(local!=0)
105
+ (*local)(event, name);
106
+ #endif /*NVTX_DISABLE*/
107
+ }
108
+
109
+ #ifdef __cplusplus
110
+ } /* extern "C" */
111
+ #endif /* __cplusplus */
112
+
miniconda3/envs/active_proaction/lib/python3.10/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxImplCuda_v3.h ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* This file was procedurally generated! Do not modify this file by hand. */
2
+
3
+ /*
4
+ * Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
5
+ *
6
+ * NOTICE TO USER:
7
+ *
8
+ * This source code is subject to NVIDIA ownership rights under U.S. and
9
+ * international Copyright laws.
10
+ *
11
+ * This software and the information contained herein is PROPRIETARY and
12
+ * CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
13
+ * of a form of NVIDIA software license agreement.
14
+ *
15
+ * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
16
+ * CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
17
+ * IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
18
+ * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
19
+ * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
20
+ * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
21
+ * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
22
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
23
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
24
+ * OR PERFORMANCE OF THIS SOURCE CODE.
25
+ *
26
+ * U.S. Government End Users. This source code is a "commercial item" as
27
+ * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
28
+ * "commercial computer software" and "commercial computer software
29
+ * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
30
+ * and is provided to the U.S. Government only as a commercial end item.
31
+ * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
32
+ * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
33
+ * source code with only those rights set forth herein.
34
+ *
35
+ * Any use of this source code in individual and commercial software must
36
+ * include, in the user documentation and internal comments to the code,
37
+ * the above Disclaimer and U.S. Government End Users Notice.
38
+ */
39
+
40
+ #ifndef NVTX_IMPL_GUARD_CUDA
41
+ #error Never include this file directly -- it is automatically included by nvToolsExtCuda.h (except when NVTX_NO_IMPL is defined).
42
+ #endif
43
+
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif /* __cplusplus */
48
+
49
+ typedef void (NVTX_API * nvtxNameCuDeviceA_impl_fntype)(CUdevice device, const char* name);
50
+ typedef void (NVTX_API * nvtxNameCuDeviceW_impl_fntype)(CUdevice device, const wchar_t* name);
51
+ typedef void (NVTX_API * nvtxNameCuContextA_impl_fntype)(CUcontext context, const char* name);
52
+ typedef void (NVTX_API * nvtxNameCuContextW_impl_fntype)(CUcontext context, const wchar_t* name);
53
+ typedef void (NVTX_API * nvtxNameCuStreamA_impl_fntype)(CUstream stream, const char* name);
54
+ typedef void (NVTX_API * nvtxNameCuStreamW_impl_fntype)(CUstream stream, const wchar_t* name);
55
+ typedef void (NVTX_API * nvtxNameCuEventA_impl_fntype)(CUevent event, const char* name);
56
+ typedef void (NVTX_API * nvtxNameCuEventW_impl_fntype)(CUevent event, const wchar_t* name);
57
+
58
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceA(CUdevice device, const char* name)
59
+ {
60
+ #ifndef NVTX_DISABLE
61
+ nvtxNameCuDeviceA_impl_fntype local = (nvtxNameCuDeviceA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuDeviceA_impl_fnptr;
62
+ if(local!=0)
63
+ (*local)(device, name);
64
+ #endif /*NVTX_DISABLE*/
65
+ }
66
+
67
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceW(CUdevice device, const wchar_t* name)
68
+ {
69
+ #ifndef NVTX_DISABLE
70
+ nvtxNameCuDeviceW_impl_fntype local = (nvtxNameCuDeviceW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuDeviceW_impl_fnptr;
71
+ if(local!=0)
72
+ (*local)(device, name);
73
+ #endif /*NVTX_DISABLE*/
74
+ }
75
+
76
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextA(CUcontext context, const char* name)
77
+ {
78
+ #ifndef NVTX_DISABLE
79
+ nvtxNameCuContextA_impl_fntype local = (nvtxNameCuContextA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuContextA_impl_fnptr;
80
+ if(local!=0)
81
+ (*local)(context, name);
82
+ #endif /*NVTX_DISABLE*/
83
+ }
84
+
85
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuContextW(CUcontext context, const wchar_t* name)
86
+ {
87
+ #ifndef NVTX_DISABLE
88
+ nvtxNameCuContextW_impl_fntype local = (nvtxNameCuContextW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuContextW_impl_fnptr;
89
+ if(local!=0)
90
+ (*local)(context, name);
91
+ #endif /*NVTX_DISABLE*/
92
+ }
93
+
94
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamA(CUstream stream, const char* name)
95
+ {
96
+ #ifndef NVTX_DISABLE
97
+ nvtxNameCuStreamA_impl_fntype local = (nvtxNameCuStreamA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuStreamA_impl_fnptr;
98
+ if(local!=0)
99
+ (*local)(stream, name);
100
+ #endif /*NVTX_DISABLE*/
101
+ }
102
+
103
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamW(CUstream stream, const wchar_t* name)
104
+ {
105
+ #ifndef NVTX_DISABLE
106
+ nvtxNameCuStreamW_impl_fntype local = (nvtxNameCuStreamW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuStreamW_impl_fnptr;
107
+ if(local!=0)
108
+ (*local)(stream, name);
109
+ #endif /*NVTX_DISABLE*/
110
+ }
111
+
112
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventA(CUevent event, const char* name)
113
+ {
114
+ #ifndef NVTX_DISABLE
115
+ nvtxNameCuEventA_impl_fntype local = (nvtxNameCuEventA_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuEventA_impl_fnptr;
116
+ if(local!=0)
117
+ (*local)(event, name);
118
+ #endif /*NVTX_DISABLE*/
119
+ }
120
+
121
+ NVTX_DECLSPEC void NVTX_API nvtxNameCuEventW(CUevent event, const wchar_t* name)
122
+ {
123
+ #ifndef NVTX_DISABLE
124
+ nvtxNameCuEventW_impl_fntype local = (nvtxNameCuEventW_impl_fntype)NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).nvtxNameCuEventW_impl_fnptr;
125
+ if(local!=0)
126
+ (*local)(event, name);
127
+ #endif /*NVTX_DISABLE*/
128
+ }
129
+
130
+ #ifdef __cplusplus
131
+ } /* extern "C" */
132
+ #endif /* __cplusplus */
133
+