diff mbox

[API-NEXT,v4,03/10] linux-generic: sysinfo: move CPU HZ API to cpu.h

Message ID 1439278439-11386-4-git-send-email-hongbo.zhang@freescale.com
State New
Headers show

Commit Message

hongbo.zhang@freescale.com Aug. 11, 2015, 7:33 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

This patch moves odp_sys_cpu_hz() to cpu.h and accordingly rename
it to odp_cpu_hz(). All the calling functions are also updated.

New CPU HZ APIs for AMP system will be added into this cpu.h too.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 example/classifier/odp_classifier.c          | 2 +-
 example/generator/odp_generator.c            | 2 +-
 example/ipsec/odp_ipsec.c                    | 2 +-
 example/packet/odp_pktio.c                   | 2 +-
 example/timer/odp_timer_test.c               | 4 ++--
 include/odp/api/cpu.h                        | 7 +++++++
 include/odp/api/system_info.h                | 7 -------
 platform/linux-generic/arch/linux/odp_time.c | 3 ++-
 platform/linux-generic/odp_system_info.c     | 2 +-
 platform/linux-generic/odp_time.c            | 5 +++--
 test/api_test/odp_common.c                   | 2 +-
 test/performance/odp_atomic.c                | 2 +-
 test/performance/odp_l2fwd.c                 | 2 +-
 test/performance/odp_scheduling.c            | 2 +-
 test/validation/system/system.c              | 6 +++---
 test/validation/system/system.h              | 2 +-
 16 files changed, 27 insertions(+), 25 deletions(-)

Comments

Savolainen, Petri (Nokia - FI/Espoo) Sept. 3, 2015, 1:29 p.m. UTC | #1
> -----Original Message-----
> From: ext hongbo.zhang@freescale.com
> [mailto:hongbo.zhang@freescale.com]
> Sent: Tuesday, August 11, 2015 10:34 AM
> To: lng-odp@lists.linaro.org
> Cc: mike.holmes@linaro.org; stuart.haslam@arm.com; Savolainen, Petri
> (Nokia - FI/Espoo); petri.savolainen@linaro.org; Hongbo Zhang
> Subject: [API-NEXT PATCH v4 03/10] linux-generic: sysinfo: move CPU HZ
> API to cpu.h
> 
> From: Hongbo Zhang <hongbo.zhang@linaro.org>
> 
> This patch moves odp_sys_cpu_hz() to cpu.h and accordingly rename
> it to odp_cpu_hz(). All the calling functions are also updated.
> 
> New CPU HZ APIs for AMP system will be added into this cpu.h too.
> 
> Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
> ---
> 
>  /**
> + * CPU frequency in Hz
> + *
> + * @return CPU frequency in Hz
> + */
> +uint64_t odp_cpu_hz(void);
> +
> +/**
>   * @}
>   */

I'd change the documentation already in this patch to mention that it's "the current frequency of this CPU"


-Petri
Hongbo Zhang Sept. 7, 2015, 10:11 a.m. UTC | #2
On 3 September 2015 at 21:29, Savolainen, Petri (Nokia - FI/Espoo)
<petri.savolainen@nokia.com> wrote:
>
>
>> -----Original Message-----
>> From: ext hongbo.zhang@freescale.com
>> [mailto:hongbo.zhang@freescale.com]
>> Sent: Tuesday, August 11, 2015 10:34 AM
>> To: lng-odp@lists.linaro.org
>> Cc: mike.holmes@linaro.org; stuart.haslam@arm.com; Savolainen, Petri
>> (Nokia - FI/Espoo); petri.savolainen@linaro.org; Hongbo Zhang
>> Subject: [API-NEXT PATCH v4 03/10] linux-generic: sysinfo: move CPU HZ
>> API to cpu.h
>>
>> From: Hongbo Zhang <hongbo.zhang@linaro.org>
>>
>> This patch moves odp_sys_cpu_hz() to cpu.h and accordingly rename
>> it to odp_cpu_hz(). All the calling functions are also updated.
>>
>> New CPU HZ APIs for AMP system will be added into this cpu.h too.
>>
>> Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
>> ---
>>
>>  /**
>> + * CPU frequency in Hz
>> + *
>> + * @return CPU frequency in Hz
>> + */
>> +uint64_t odp_cpu_hz(void);
>> +
>> +/**
>>   * @}
>>   */
>
> I'd change the documentation already in this patch to mention that it's "the current frequency of this CPU"
>
Which documentation please? is that documentation generated from these
lines of comments? do you mean update these comments?

>
> -Petri
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index b55a6f9..267b6a5 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -733,7 +733,7 @@  static void print_info(char *progname, appl_args_t *appl_args)
 			"CPU count:       %i\n"
 			"\n",
 			odp_version_api_str(), odp_sys_cpu_model_str(),
-			odp_sys_cpu_hz(), odp_sys_cache_line_size(),
+			odp_cpu_hz(), odp_sys_cache_line_size(),
 			odp_cpu_count());
 
 	printf("Running ODP appl: \"%s\"\n"
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index bdee222..ffe462d 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -988,7 +988,7 @@  static void print_info(char *progname, appl_args_t *appl_args)
 	       "Cache line size: %i\n"
 	       "CPU count:       %i\n"
 	       "\n",
-	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(),
+	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_cpu_hz(),
 	       odp_sys_cache_line_size(), odp_cpu_count());
 
 	printf("Running ODP appl: \"%s\"\n"
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 91c7fad..54e3c98 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1516,7 +1516,7 @@  static void print_info(char *progname, appl_args_t *appl_args)
 	       "Cache line size: %i\n"
 	       "CPU count:       %i\n"
 	       "\n",
-	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(),
+	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_cpu_hz(),
 	       odp_sys_cache_line_size(), odp_cpu_count());
 
 	printf("Running ODP appl: \"%s\"\n"
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 0db5a60..a583302 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -628,7 +628,7 @@  static void print_info(char *progname, appl_args_t *appl_args)
 	       "Cache line size: %i\n"
 	       "CPU count:       %i\n"
 	       "\n",
-	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(),
+	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_cpu_hz(),
 	       odp_sys_cache_line_size(), odp_cpu_count());
 
 	printf("Running ODP appl: \"%s\"\n"
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 933dc3b..1528715 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -350,7 +350,7 @@  int main(int argc, char *argv[])
 	printf("---------------\n");
 	printf("ODP API version: %s\n",        odp_version_api_str());
 	printf("CPU model:       %s\n",        odp_sys_cpu_model_str());
-	printf("CPU freq (hz):   %"PRIu64"\n", odp_sys_cpu_hz());
+	printf("CPU freq (hz):   %"PRIu64"\n", odp_cpu_hz());
 	printf("Cache line size: %i\n",        odp_sys_cache_line_size());
 	printf("Max CPU count:   %i\n",        odp_cpu_count());
 
@@ -445,7 +445,7 @@  int main(int argc, char *argv[])
 		return -1;
 	}
 
-	printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz());
+	printf("CPU freq %"PRIu64" Hz\n", odp_cpu_hz());
 	printf("Cycles vs nanoseconds:\n");
 	ns = 0;
 	cycles = odp_time_ns_to_cycles(ns);
diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index c389093..8ba9c26 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -44,6 +44,13 @@  int odp_cpu_id(void);
 int odp_cpu_count(void);
 
 /**
+ * CPU frequency in Hz
+ *
+ * @return CPU frequency in Hz
+ */
+uint64_t odp_cpu_hz(void);
+
+/**
  * @}
  */
 
diff --git a/include/odp/api/system_info.h b/include/odp/api/system_info.h
index e55ff6d..f188b54 100644
--- a/include/odp/api/system_info.h
+++ b/include/odp/api/system_info.h
@@ -24,13 +24,6 @@  extern "C" {
  */
 
 /**
- * CPU frequency in Hz
- *
- * @return CPU frequency in Hz
- */
-uint64_t odp_sys_cpu_hz(void);
-
-/**
  * Huge page size in bytes
  *
  * @return Huge page size in bytes
diff --git a/platform/linux-generic/arch/linux/odp_time.c b/platform/linux-generic/arch/linux/odp_time.c
index 4dc0764..3309da0 100644
--- a/platform/linux-generic/arch/linux/odp_time.c
+++ b/platform/linux-generic/arch/linux/odp_time.c
@@ -11,6 +11,7 @@ 
 
 #include <odp/time.h>
 #include <odp/hints.h>
+#include <odp/cpu.h>
 #include <odp/system_info.h>
 #include <odp_debug_internal.h>
 
@@ -27,7 +28,7 @@  uint64_t odp_time_cycles(void)
 	if (ret != 0)
 		ODP_ABORT("clock_gettime failed\n");
 
-	hz  = odp_sys_cpu_hz();
+	hz  = odp_cpu_hz();
 	sec = (uint64_t) time.tv_sec;
 	ns  = (uint64_t) time.tv_nsec;
 
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 83226f8..3284ae1 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -374,7 +374,7 @@  int odp_system_info_init(void)
  * Public access functions
  *************************
  */
-uint64_t odp_sys_cpu_hz(void)
+uint64_t odp_cpu_hz(void)
 {
 	return odp_global_data.system_info.cpu_hz[0];
 }
diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c
index a08833d..a137a36 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -8,6 +8,7 @@ 
 
 #include <odp/time.h>
 #include <odp/hints.h>
+#include <odp/cpu.h>
 #include <odp/system_info.h>
 
 #define GIGA 1000000000
@@ -22,7 +23,7 @@  uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2)
 
 uint64_t odp_time_cycles_to_ns(uint64_t cycles)
 {
-	uint64_t hz = odp_sys_cpu_hz();
+	uint64_t hz = odp_cpu_hz();
 
 	if (cycles > (UINT64_MAX / GIGA))
 		return (cycles/hz)*GIGA;
@@ -33,7 +34,7 @@  uint64_t odp_time_cycles_to_ns(uint64_t cycles)
 
 uint64_t odp_time_ns_to_cycles(uint64_t ns)
 {
-	uint64_t hz = odp_sys_cpu_hz();
+	uint64_t hz = odp_cpu_hz();
 
 	if (ns > (UINT64_MAX / hz))
 		return (ns/GIGA)*hz;
diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
index 0dbefa5..80ae581 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -42,7 +42,7 @@  void odp_print_system_info(void)
 	printf("---------------\n");
 	printf("ODP API version: %s\n",        odp_version_api_str());
 	printf("CPU model:       %s\n",        odp_sys_cpu_model_str());
-	printf("CPU freq (hz):   %"PRIu64"\n", odp_sys_cpu_hz());
+	printf("CPU freq (hz):   %"PRIu64"\n", odp_cpu_hz());
 	printf("Cache line size: %i\n",        odp_sys_cache_line_size());
 	printf("CPU count:       %i\n",        odp_cpu_count());
 	printf("CPU mask:        %s\n",        str);
diff --git a/test/performance/odp_atomic.c b/test/performance/odp_atomic.c
index eefce06..c2fdc8b 100644
--- a/test/performance/odp_atomic.c
+++ b/test/performance/odp_atomic.c
@@ -338,7 +338,7 @@  void odp_print_system_info(void)
 	printf("---------------\n");
 	printf("ODP API version: %s\n",        odp_version_api_str());
 	printf("CPU model:       %s\n",        odp_sys_cpu_model_str());
-	printf("CPU freq (hz):   %"PRIu64"\n", odp_sys_cpu_hz());
+	printf("CPU freq (hz):   %"PRIu64"\n", odp_cpu_hz());
 	printf("Cache line size: %i\n",        odp_sys_cache_line_size());
 	printf("CPU count:       %i\n",        odp_cpu_count());
 	printf("CPU mask:        %s\n",        str);
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 157df3b..0336dc0 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -641,7 +641,7 @@  static void print_info(char *progname, appl_args_t *appl_args)
 	       "Cache line size: %i\n"
 	       "CPU count:       %i\n"
 	       "\n",
-	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(),
+	       odp_version_api_str(), odp_sys_cpu_model_str(), odp_cpu_hz(),
 	       odp_sys_cache_line_size(), odp_cpu_count());
 
 	printf("Running ODP appl: \"%s\"\n"
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 8d388ff..9f8535c 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -881,7 +881,7 @@  int main(int argc, char *argv[])
 	printf("---------------\n");
 	printf("ODP API version: %s\n",        odp_version_api_str());
 	printf("CPU model:       %s\n",        odp_sys_cpu_model_str());
-	printf("CPU freq (hz):   %"PRIu64"\n", odp_sys_cpu_hz());
+	printf("CPU freq (hz):   %"PRIu64"\n", odp_cpu_hz());
 	printf("Cache line size: %i\n",        odp_sys_cache_line_size());
 	printf("Max CPU count:   %i\n",        odp_cpu_count());
 
diff --git a/test/validation/system/system.c b/test/validation/system/system.c
index 7687f20..f29e310 100644
--- a/test/validation/system/system.c
+++ b/test/validation/system/system.c
@@ -75,11 +75,11 @@  void system_test_odp_sys_huge_page_size(void)
 	CU_ASSERT(0 < page);
 }
 
-void system_test_odp_sys_cpu_hz(void)
+void system_test_odp_cpu_hz(void)
 {
 	uint64_t hz;
 
-	hz = odp_sys_cpu_hz();
+	hz = odp_cpu_hz();
 	CU_ASSERT(0 < hz);
 }
 
@@ -90,7 +90,7 @@  CU_TestInfo system_suite[] = {
 	{"odp_sys_cpu_model_str",  system_test_odp_sys_cpu_model_str},
 	{"odp_sys_page_size",  system_test_odp_sys_page_size},
 	{"odp_sys_huge_page_size",  system_test_odp_sys_huge_page_size},
-	{"odp_sys_cpu_hz",  system_test_odp_sys_cpu_hz},
+	{"odp_cpu_hz",  system_test_odp_cpu_hz},
 	CU_TEST_INFO_NULL,
 };
 
diff --git a/test/validation/system/system.h b/test/validation/system/system.h
index c8bd2d4..9790181 100644
--- a/test/validation/system/system.h
+++ b/test/validation/system/system.h
@@ -16,7 +16,7 @@  void system_test_odp_sys_cache_line_size(void);
 void system_test_odp_sys_cpu_model_str(void);
 void system_test_odp_sys_page_size(void);
 void system_test_odp_sys_huge_page_size(void);
-void system_test_odp_sys_cpu_hz(void);
+void system_test_odp_cpu_hz(void);
 
 /* test arrays: */
 extern CU_TestInfo system_suite[];