[v4,44/45] app/test-compress-perf: use rte stdatomic API

Message ID 1713568003-30453-45-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series use stdatomic API |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff April 19, 2024, 11:06 p.m. UTC
  Replace the use of gcc builtin __atomic_xxx intrinsics with
corresponding rte_atomic_xxx optional rte stdatomic API.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-compress-perf/comp_perf_test_common.h     |  2 +-
 app/test-compress-perf/comp_perf_test_cyclecount.c |  4 ++--
 app/test-compress-perf/comp_perf_test_throughput.c | 10 +++++-----
 app/test-compress-perf/comp_perf_test_verify.c     |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)
  

Patch

diff --git a/app/test-compress-perf/comp_perf_test_common.h b/app/test-compress-perf/comp_perf_test_common.h
index d039e5a..085e269 100644
--- a/app/test-compress-perf/comp_perf_test_common.h
+++ b/app/test-compress-perf/comp_perf_test_common.h
@@ -14,7 +14,7 @@  struct cperf_mem_resources {
 	uint16_t qp_id;
 	uint8_t lcore_id;
 
-	uint16_t print_info_once;
+	RTE_ATOMIC(uint16_t) print_info_once;
 
 	uint32_t total_bufs;
 	uint8_t *compressed_data;
diff --git a/app/test-compress-perf/comp_perf_test_cyclecount.c b/app/test-compress-perf/comp_perf_test_cyclecount.c
index 4d336ec..64e8faa 100644
--- a/app/test-compress-perf/comp_perf_test_cyclecount.c
+++ b/app/test-compress-perf/comp_perf_test_cyclecount.c
@@ -498,8 +498,8 @@  struct cperf_cyclecount_ctx {
 	/*
 	 * printing information about current compression thread
 	 */
-	if (__atomic_compare_exchange_n(&ctx->ver.mem.print_info_once, &exp,
-				1, 0, __ATOMIC_RELAXED,  __ATOMIC_RELAXED))
+	if (rte_atomic_compare_exchange_strong_explicit(&ctx->ver.mem.print_info_once, &exp,
+				1, rte_memory_order_relaxed,  rte_memory_order_relaxed))
 		printf("    lcore: %u,"
 				" driver name: %s,"
 				" device name: %s,"
diff --git a/app/test-compress-perf/comp_perf_test_throughput.c b/app/test-compress-perf/comp_perf_test_throughput.c
index 1f7072d..089d19c 100644
--- a/app/test-compress-perf/comp_perf_test_throughput.c
+++ b/app/test-compress-perf/comp_perf_test_throughput.c
@@ -336,7 +336,7 @@ 
 	struct cperf_benchmark_ctx *ctx = test_ctx;
 	struct comp_test_data *test_data = ctx->ver.options;
 	uint32_t lcore = rte_lcore_id();
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 	int i, ret = EXIT_SUCCESS;
 
 	ctx->ver.mem.lcore_id = lcore;
@@ -345,8 +345,8 @@ 
 	/*
 	 * printing information about current compression thread
 	 */
-	if (__atomic_compare_exchange_n(&ctx->ver.mem.print_info_once, &exp,
-				1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
+	if (rte_atomic_compare_exchange_strong_explicit(&ctx->ver.mem.print_info_once, &exp,
+				1, rte_memory_order_relaxed, rte_memory_order_relaxed))
 		printf("    lcore: %u,"
 				" driver name: %s,"
 				" device name: %s,"
@@ -413,8 +413,8 @@ 
 	}
 
 	exp = 0;
-	if (__atomic_compare_exchange_n(&display_once, &exp, 1, 0,
-			__ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
+	if (rte_atomic_compare_exchange_strong_explicit(&display_once, &exp, 1,
+			rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		printf("\n%12s%6s%12s%17s%15s%16s\n",
 			"lcore id", "Level", "Comp size", "Comp ratio [%]",
 			"Comp [Gbps]", "Decomp [Gbps]");
diff --git a/app/test-compress-perf/comp_perf_test_verify.c b/app/test-compress-perf/comp_perf_test_verify.c
index 7bd1807..09d97c5 100644
--- a/app/test-compress-perf/comp_perf_test_verify.c
+++ b/app/test-compress-perf/comp_perf_test_verify.c
@@ -396,7 +396,7 @@ 
 	struct cperf_verify_ctx *ctx = test_ctx;
 	struct comp_test_data *test_data = ctx->options;
 	int ret = EXIT_SUCCESS;
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 	uint32_t lcore = rte_lcore_id();
 	uint16_t exp = 0;
 
@@ -452,8 +452,8 @@ 
 			test_data->input_data_sz * 100;
 
 	if (!ctx->silent) {
-		if (__atomic_compare_exchange_n(&display_once, &exp, 1, 0,
-				__ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
+		if (rte_atomic_compare_exchange_strong_explicit(&display_once, &exp, 1,
+				rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 			printf("%12s%6s%12s%17s\n",
 			    "lcore id", "Level", "Comp size", "Comp ratio [%]");
 		}