NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_pcc_dev_utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED.
3  *
4  * This software product is a proprietary product of NVIDIA CORPORATION &
5  * AFFILIATES (the "Company") and all right, title, and interest in and to the
6  * software product, including all associated intellectual property rights, are
7  * and shall remain exclusively with the Company.
8  *
9  * This software product is governed by the End User License Agreement
10  * provided with the software product.
11  *
12  */
13 
23 #ifndef DOCA_PCC_DEV_UTILS_H_
24 #define DOCA_PCC_DEV_UTILS_H_
25 
31 #define DOCA_DPA_DEVICE
32 
33 #include <dpaintrin.h>
34 #include <doca_pcc_dev_common.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 #define doca_pcc_dev_fxp_recip(a_fp) __dpa_fxp_rcp(a_fp)
44 
48 #define doca_pcc_dev_fxp_power2(a_fp) __dpa_fxp_pow2(a_fp)
49 
53 #define doca_pcc_dev_fxp_log2(a_fp) __dpa_fxp_log2(a_fp)
54 
58 #define doca_pcc_dev_fls(a) (32 - __builtin_clz(a))
59 
63 #define doca_pcc_dev_mult(a, b) ((uint64_t)(a) * (uint64_t)(b))
64 
68 #define doca_pcc_dev_fxp_mult(a, b) ((uint32_t)((doca_pcc_dev_mult((a), (b)) >> 16) & 0xffffffff))
69 
73 #define doca_pcc_dev_fence_all() __dpa_thread_fence(__DPA_SYSTEM, __DPA_RW, __DPA_RW)
74 
78 #define doca_pcc_dev_fence_memory() __dpa_thread_fence(__DPA_MEMORY, __DPA_RW, __DPA_RW)
79 
83 #define doca_pcc_dev_fence_io() __dpa_thread_fence(__DPA_MMIO, __DPA_RW, __DPA_RW)
84 
88 #define doca_pcc_dev_fence_w_r() __dpa_thread_fence(__DPA_MEMORY, __DPA_W, __DPA_R)
89 
93 #define doca_pcc_dev_get_thread_time() __dpa_thread_time()
94 
102 {
103  return (uint32_t)(doca_pcc_dev_get_thread_time() & 0xffffffff);
104 }
105 
113 {
115 }
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* DOCA_PCC_DEV_UTILS_H_ */
122 
#define DOCA_STABLE
To set a Symbol (or specifically a function) as stable API, i.e. it won't be changed.
Definition: doca_compat.h:96
#define FORCE_INLINE
static inline wrapper
DOCA_STABLE FORCE_INLINE uint64_t doca_pcc_dev_get_timer(void)
Core timer access (elapsed time in uSec) function 64 bits.
#define doca_pcc_dev_get_thread_time()
return 1usec tick count
DOCA_STABLE FORCE_INLINE uint32_t doca_pcc_dev_get_timer_lo(void)
Core timer access (elapsed time in uSec) function 32 bits.