aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/cpu.h
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2015-09-08 11:31:31 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-10-22 15:44:29 +0300
commitd6f6e9ea0a4d6dd1bba3059da7fc3151c1e25e5b (patch)
treed6e4ea8db48c8fbc533a72b42da3e308cd238269 /include/odp/api/cpu.h
parent01005f0eae61a0aee3fa39f304de876ea6a4a786 (diff)
api: cpu: added cpu cycle count API
Raw CPU cycle counts can be used to measure performance in CPU cycles. These functions will replace some usage of odp_time_cycles() of odp_time_diff_cycles(). Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'include/odp/api/cpu.h')
-rw-r--r--include/odp/api/cpu.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index c38909321..50a7e3da5 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -18,6 +18,8 @@
extern "C" {
#endif
+#include <odp/std_types.h>
+
/** @defgroup odp_cpu ODP CPU
* @{
*/
@@ -44,6 +46,56 @@ int odp_cpu_id(void);
int odp_cpu_count(void);
/**
+ * Current CPU cycle count
+ *
+ * Return current CPU cycle count. Cycle count may not be reset at ODP init
+ * and thus may wrap back to zero between two calls. Use odp_cpu_cycles_max()
+ * to read the maximum count value after which it wraps. Cycle count frequency
+ * follows the CPU frequency and thus may change at any time. The count may
+ * advance in steps larger than one. Use odp_cpu_cycles_resolution() to read
+ * the step size.
+ *
+ * @note Do not use CPU count for time measurements since the frequency may
+ * vary.
+ *
+ * @return Current CPU cycle count
+ */
+uint64_t odp_cpu_cycles(void);
+
+/**
+ * CPU cycle count difference
+ *
+ * Calculate difference between cycle counts c1 and c2. Parameter c1 must be the
+ * first cycle count sample and c2 the second. The function handles correctly
+ * single cycle count wrap between c1 and c2.
+ *
+ * @param c1 First cycle count
+ * @param c2 Second cycle count
+ *
+ * @return CPU cycles from c1 to c2
+ */
+uint64_t odp_cpu_cycles_diff(uint64_t c1, uint64_t c2);
+
+/**
+ * Maximum CPU cycle count
+ *
+ * Maximum CPU cycle count value before it wraps back to zero.
+ *
+ * @return Maximum CPU cycle count value
+ */
+uint64_t odp_cpu_cycles_max(void);
+
+/**
+ * Resolution of CPU cycle count
+ *
+ * CPU cycle count may advance in steps larger than one. This function returns
+ * resolution of odp_cpu_cycles() in CPU cycles.
+ *
+ * @return CPU cycle count resolution in CPU cycles
+ */
+uint64_t odp_cpu_cycles_resolution(void);
+
+/**
* @}
*/