Added implementation for CPU cycle diff, max and resolution.

Signed-off-by: Petri Savolainen <petri.savolai...@nokia.com>
---
 platform/linux-generic/Makefile.am                  |  1 +
 platform/linux-generic/arch/linux/odp_cpu_cycles.c  | 10 ++++++++++
 platform/linux-generic/arch/mips64/odp_cpu_cycles.c | 10 ++++++++++
 platform/linux-generic/arch/x86/odp_cpu_cycles.c    | 10 ++++++++++
 platform/linux-generic/odp_cpu.c                    | 16 ++++++++++++++++
 5 files changed, 47 insertions(+)
 create mode 100644 platform/linux-generic/odp_cpu.c

diff --git a/platform/linux-generic/Makefile.am 
b/platform/linux-generic/Makefile.am
index c2a4778..43f8de8 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -139,6 +139,7 @@ __LIB__libodp_la_SOURCES = \
                           odp_barrier.c \
                           odp_buffer.c \
                           odp_classification.c \
+                          odp_cpu.c \
                           odp_cpumask.c \
                           odp_cpumask_task.c \
                           odp_crypto.c \
diff --git a/platform/linux-generic/arch/linux/odp_cpu_cycles.c 
b/platform/linux-generic/arch/linux/odp_cpu_cycles.c
index c312f3d..37a4d94 100644
--- a/platform/linux-generic/arch/linux/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/linux/odp_cpu_cycles.c
@@ -36,3 +36,13 @@ uint64_t odp_cpu_cycles(void)
 
        return cycles;
 }
+
+uint64_t odp_cpu_cycles_max(void)
+{
+       return UINT64_MAX;
+}
+
+uint64_t odp_cpu_cycles_resolution(void)
+{
+       return 1;
+}
diff --git a/platform/linux-generic/arch/mips64/odp_cpu_cycles.c 
b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c
index acd7058..a20a313 100644
--- a/platform/linux-generic/arch/mips64/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c
@@ -19,3 +19,13 @@ uint64_t odp_cpu_cycles(void)
 
        return cycle;
 }
+
+uint64_t odp_cpu_cycles_max(void)
+{
+       return UINT64_MAX;
+}
+
+uint64_t odp_cpu_cycles_resolution(void)
+{
+       return 1;
+}
diff --git a/platform/linux-generic/arch/x86/odp_cpu_cycles.c 
b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
index 20ad44a..1c5c0ec 100644
--- a/platform/linux-generic/arch/x86/odp_cpu_cycles.c
+++ b/platform/linux-generic/arch/x86/odp_cpu_cycles.c
@@ -21,3 +21,13 @@ uint64_t odp_cpu_cycles(void)
 
        return tsc.tsc_64;
 }
+
+uint64_t odp_cpu_cycles_max(void)
+{
+       return UINT64_MAX;
+}
+
+uint64_t odp_cpu_cycles_resolution(void)
+{
+       return 1;
+}
diff --git a/platform/linux-generic/odp_cpu.c b/platform/linux-generic/odp_cpu.c
new file mode 100644
index 0000000..bcda466
--- /dev/null
+++ b/platform/linux-generic/odp_cpu.c
@@ -0,0 +1,16 @@
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/cpu.h>
+#include <odp/hints.h>
+
+uint64_t odp_cpu_cycles_diff(uint64_t c1, uint64_t c2)
+{
+       if (odp_likely(c2 > c1))
+               return c2 - c1;
+
+       return c2 + (odp_cpu_cycles_max() - c1);
+}
-- 
2.5.1

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to