Skip to contentSkip to conversation

use stdatomic API

PATCH Superseded Tyler Retzlaff 11 participants 300 messages Mar 20, 2024 – May 17, 2024 Page 5 of 5

Subsystems (8)
lore
Share & tools
lore
#293 lore raw

PATCH v6 41/45 app/test: use rte stdatomic API

In reply to Tyler Retzlaff

Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API.

---
 app/test/test_bpf.c                    |  46 ++++++++-----
 app/test/test_distributor.c            | 114 ++++++++++++++++-----------------
 app/test/test_distributor_perf.c       |   4 +-
 app/test/test_func_reentrancy.c        |  28 ++++----
 app/test/test_hash_multiwriter.c       |  16 ++---
 app/test/test_hash_readwrite.c         |  74 ++++++++++-----------
 app/test/test_hash_readwrite_lf_perf.c |  88 ++++++++++++-------------
 app/test/test_lcores.c                 |  25 ++++----
 app/test/test_lpm_perf.c               |  14 ++--
 app/test/test_mcslock.c                |  12 ++--
 app/test/test_mempool_perf.c           |   9 +--
 app/test/test_pflock.c                 |  13 ++--
 app/test/test_pmd_perf.c               |  10 +--
 app/test/test_rcu_qsbr_perf.c          | 114 +++++++++++++++++----------------
 app/test/test_ring_perf.c              |  11 ++--
 app/test/test_ring_stress_impl.h       |  10 +--
 app/test/test_rwlock.c                 |   9 +--
 app/test/test_seqlock.c                |   6 +-
 app/test/test_service_cores.c          |  24 +++----
 app/test/test_spinlock.c               |   9 +--
 app/test/test_stack_perf.c             |  12 ++--
 app/test/test_threads.c                |  33 +++++-----
 app/test/test_ticketlock.c             |   9 +--
 app/test/test_timer.c                  |  31 +++++----
 24 files changed, 378 insertions(+), 343 deletions(-)
app/test/test_bpf.c +30 -16
index 53e3a31..2e43442 100644
@@ -39,8 +39,8 @@
  */
 
 struct dummy_offset {
-	uint64_t u64;
-	uint32_t u32;
+	RTE_ATOMIC(uint64_t) u64;
+	RTE_ATOMIC(uint32_t) u32;
 	uint16_t u16;
 	uint8_t  u8;
 };
@@ -1581,32 +1581,46 @@ struct bpf_test {
 	memset(&dfe, 0, sizeof(dfe));
 
 	rv = 1;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = -1;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = (int32_t)TEST_FILL_1;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = TEST_MUL_1;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = TEST_MUL_2;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = TEST_JCC_2;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	rv = TEST_JCC_3;
-	__atomic_fetch_add(&dfe.u32, rv, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&dfe.u64, rv, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit((uint32_t __rte_atomic *)&dfe.u32, rv,
+	    rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit((uint64_t __rte_atomic *)&dfe.u64, rv,
+	    rte_memory_order_relaxed);
 
 	return cmp_res(__func__, 1, rc, &dfe, dft, sizeof(dfe));
 }
app/test/test_distributor.c +57 -57

259 lines not on this page · raw message

app/test/test_distributor_perf.c +2 -2
index c0ad39d..e678aec 100644
@@ -31,7 +31,7 @@
 
 /* static vars - zero initialized by default */
 static volatile int quit;
-static volatile unsigned worker_idx;
+static volatile RTE_ATOMIC(unsigned int) worker_idx;
 
 struct __rte_cache_aligned worker_stats {
 	volatile unsigned handled_packets;
@@ -121,7 +121,7 @@ struct __rte_cache_aligned worker_stats {
 	struct rte_distributor *d = arg;
 	unsigned int num = 0;
 	int i;
-	unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED);
+	unsigned int id = rte_atomic_fetch_add_explicit(&worker_idx, 1, rte_memory_order_relaxed);
 	alignas(RTE_CACHE_LINE_SIZE) struct rte_mbuf *buf[8];
 
 	for (i = 0; i < 8; i++)
app/test/test_func_reentrancy.c +15 -13
index 9296de2..bae39af 100644
@@ -53,12 +53,13 @@
 
 #define MAX_LCORES	(rte_memzone_max_get() / (MAX_ITER_MULTI * 4U))
 
-static uint32_t obj_count;
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) obj_count;
+static RTE_ATOMIC(uint32_t) synchro;
 
 #define WAIT_SYNCHRO_FOR_WORKERS()   do { \
 	if (lcore_self != rte_get_main_lcore())                  \
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED); \
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1, \
+		    rte_memory_order_relaxed); \
 } while(0)
 
 /*
@@ -71,7 +72,8 @@
 
 	WAIT_SYNCHRO_FOR_WORKERS();
 
-	__atomic_store_n(&obj_count, 1, __ATOMIC_RELAXED); /* silent the check in the caller */
+	/* silent the check in the caller */
+	rte_atomic_store_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	if (rte_eal_init(0, NULL) != -1)
 		return -1;
 
@@ -113,7 +115,7 @@
 	for (i = 0; i < MAX_ITER_ONCE; i++) {
 		rp = rte_ring_create("fr_test_once", 4096, SOCKET_ID_ANY, 0);
 		if (rp != NULL)
-			__atomic_fetch_add(&obj_count, 1, __ATOMIC_RELAXED);
+			rte_atomic_fetch_add_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	}
 
 	/* create/lookup new ring several times */
@@ -178,7 +180,7 @@
 					my_obj_init, NULL,
 					SOCKET_ID_ANY, 0);
 		if (mp != NULL)
-			__atomic_fetch_add(&obj_count, 1, __ATOMIC_RELAXED);
+			rte_atomic_fetch_add_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	}
 
 	/* create/lookup new ring several times */
@@ -244,7 +246,7 @@
 	for (i = 0; i < MAX_ITER_ONCE; i++) {
 		handle = rte_hash_create(&hash_params);
 		if (handle != NULL)
-			__atomic_fetch_add(&obj_count, 1, __ATOMIC_RELAXED);
+			rte_atomic_fetch_add_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	}
 
 	/* create multiple times simultaneously */
@@ -311,7 +313,7 @@
 	for (i = 0; i < MAX_ITER_ONCE; i++) {
 		handle = rte_fbk_hash_create(&fbk_params);
 		if (handle != NULL)
-			__atomic_fetch_add(&obj_count, 1, __ATOMIC_RELAXED);
+			rte_atomic_fetch_add_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	}
 
 	/* create multiple fbk tables simultaneously */
@@ -376,7 +378,7 @@
 	for (i = 0; i < MAX_ITER_ONCE; i++) {
 		lpm = rte_lpm_create("fr_test_once",  SOCKET_ID_ANY, &config);
 		if (lpm != NULL)
-			__atomic_fetch_add(&obj_count, 1, __ATOMIC_RELAXED);
+			rte_atomic_fetch_add_explicit(&obj_count, 1, rte_memory_order_relaxed);
 	}
 
 	/* create multiple fbk tables simultaneously */
@@ -437,8 +439,8 @@ struct test_case test_cases[] = {
 	if (pt_case->func == NULL)
 		return -1;
 
-	__atomic_store_n(&obj_count, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&obj_count, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 
 	cores = RTE_MIN(rte_lcore_count(), MAX_LCORES);
 	RTE_LCORE_FOREACH_WORKER(lcore_id) {
@@ -448,7 +450,7 @@ struct test_case test_cases[] = {
 		rte_eal_remote_launch(pt_case->func, pt_case->arg, lcore_id);
 	}
 
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 
 	if (pt_case->func(pt_case->arg) < 0)
 		ret = -1;
@@ -463,7 +465,7 @@ struct test_case test_cases[] = {
 			pt_case->clean(lcore_id);
 	}
 
-	count = __atomic_load_n(&obj_count, __ATOMIC_RELAXED);
+	count = rte_atomic_load_explicit(&obj_count, rte_memory_order_relaxed);
 	if (count != 1) {
 		printf("%s: common object allocated %d times (should be 1)\n",
 			pt_case->name, count);
app/test/test_hash_multiwriter.c +8 -8
index ed9dd41..33d3147 100644
@@ -43,8 +43,8 @@ struct {
 const uint32_t nb_total_tsx_insertion = 4.5*1024*1024;
 uint32_t rounded_nb_total_tsx_insertion;
 
-static uint64_t gcycles;
-static uint64_t ginsertions;
+static RTE_ATOMIC(uint64_t) gcycles;
+static RTE_ATOMIC(uint64_t) ginsertions;
 
 static int use_htm;
 
@@ -84,8 +84,8 @@ struct {
 	}
 
 	cycles = rte_rdtsc_precise() - begin;
-	__atomic_fetch_add(&gcycles, cycles, __ATOMIC_RELAXED);
-	__atomic_fetch_add(&ginsertions, i - offset, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit(&gcycles, cycles, rte_memory_order_relaxed);
+	rte_atomic_fetch_add_explicit(&ginsertions, i - offset, rte_memory_order_relaxed);
 
 	for (; i < offset + tbl_multiwriter_test_params.nb_tsx_insertion; i++)
 		tbl_multiwriter_test_params.keys[i]
@@ -166,8 +166,8 @@ struct {
 
 	tbl_multiwriter_test_params.found = found;
 
-	__atomic_store_n(&gcycles, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&ginsertions, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&gcycles, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&ginsertions, 0, rte_memory_order_relaxed);
 
 	/* Get list of enabled cores */
 	i = 0;
@@ -233,8 +233,8 @@ struct {
 	printf("No key corrupted during multiwriter insertion.\n");
 
 	unsigned long long int cycles_per_insertion =
-		__atomic_load_n(&gcycles, __ATOMIC_RELAXED)/
-		__atomic_load_n(&ginsertions, __ATOMIC_RELAXED);
+		rte_atomic_load_explicit(&gcycles, rte_memory_order_relaxed)/
+		rte_atomic_load_explicit(&ginsertions, rte_memory_order_relaxed);
 
 	printf(" cycles per insertion: %llu\n", cycles_per_insertion);
 
app/test/test_hash_readwrite.c +37 -37

154 lines not on this page · raw message

app/test/test_hash_readwrite_lf_perf.c +44 -44

202 lines not on this page · raw message

app/test/test_lcores.c +13 -12
index 3434a0d..bd5c0dd 100644
@@ -10,6 +10,7 @@
 #include <rte_errno.h>
 #include <rte_lcore.h>
 #include <rte_thread.h>
+#include <rte_stdatomic.h>
 
 #include "test.h"
 
@@ -25,7 +26,7 @@ struct thread_context {
 	enum { Thread_INIT, Thread_ERROR, Thread_DONE } state;
 	bool lcore_id_any;
 	rte_thread_t id;
-	unsigned int *registered_count;
+	RTE_ATOMIC(unsigned int) *registered_count;
 };
 
 static uint32_t thread_loop(void *arg)
@@ -49,10 +50,10 @@ static uint32_t thread_loop(void *arg)
 		t->state = Thread_ERROR;
 	}
 	/* Report register happened to the control thread. */
-	__atomic_fetch_add(t->registered_count, 1, __ATOMIC_RELEASE);
+	rte_atomic_fetch_add_explicit(t->registered_count, 1, rte_memory_order_release);
 
 	/* Wait for release from the control thread. */
-	while (__atomic_load_n(t->registered_count, __ATOMIC_ACQUIRE) != 0)
+	while (rte_atomic_load_explicit(t->registered_count, rte_memory_order_acquire) != 0)
 		sched_yield();
 	rte_thread_unregister();
 	lcore_id = rte_lcore_id();
@@ -73,7 +74,7 @@ static uint32_t thread_loop(void *arg)
 {
 	struct thread_context thread_contexts[RTE_MAX_LCORE];
 	unsigned int non_eal_threads_count;
-	unsigned int registered_count;
+	RTE_ATOMIC(unsigned int) registered_count;
 	struct thread_context *t;
 	unsigned int i;
 	int ret;
@@ -93,7 +94,7 @@ static uint32_t thread_loop(void *arg)
 	}
 	printf("non-EAL threads count: %u\n", non_eal_threads_count);
 	/* Wait all non-EAL threads to register. */
-	while (__atomic_load_n(&registered_count, __ATOMIC_ACQUIRE) !=
+	while (rte_atomic_load_explicit(&registered_count, rte_memory_order_acquire) !=
 			non_eal_threads_count)
 		sched_yield();
 
@@ -109,14 +110,14 @@ static uint32_t thread_loop(void *arg)
 	if (rte_thread_create(&t->id, NULL, thread_loop, t) == 0) {
 		non_eal_threads_count++;
 		printf("non-EAL threads count: %u\n", non_eal_threads_count);
-		while (__atomic_load_n(&registered_count, __ATOMIC_ACQUIRE) !=
+		while (rte_atomic_load_explicit(&registered_count, rte_memory_order_acquire) !=
 				non_eal_threads_count)
 			sched_yield();
 	}
 
 skip_lcore_any:
 	/* Release all threads, and check their states. */
-	__atomic_store_n(&registered_count, 0, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&registered_count, 0, rte_memory_order_release);
 	ret = 0;
 	for (i = 0; i < non_eal_threads_count; i++) {
 		t = &thread_contexts[i];
@@ -225,7 +226,7 @@ struct limit_lcore_context {
 	struct thread_context thread_contexts[2];
 	unsigned int non_eal_threads_count = 0;
 	struct limit_lcore_context l[2] = {};
-	unsigned int registered_count = 0;
+	RTE_ATOMIC(unsigned int) registered_count = 0;
 	struct thread_context *t;
 	void *handle[2] = {};
 	unsigned int i;
@@ -275,7 +276,7 @@ struct limit_lcore_context {
 	if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
 		goto cleanup_threads;
 	non_eal_threads_count++;
-	while (__atomic_load_n(&registered_count, __ATOMIC_ACQUIRE) !=
+	while (rte_atomic_load_explicit(&registered_count, rte_memory_order_acquire) !=
 			non_eal_threads_count)
 		sched_yield();
 	if (l[0].init != eal_threads_count + 1 ||
@@ -298,7 +299,7 @@ struct limit_lcore_context {
 	if (rte_thread_create(&t->id, NULL, thread_loop, t) != 0)
 		goto cleanup_threads;
 	non_eal_threads_count++;
-	while (__atomic_load_n(&registered_count, __ATOMIC_ACQUIRE) !=
+	while (rte_atomic_load_explicit(&registered_count, rte_memory_order_acquire) !=
 			non_eal_threads_count)
 		sched_yield();
 	if (l[0].init != eal_threads_count + 2 ||
@@ -315,7 +316,7 @@ struct limit_lcore_context {
 	}
 	rte_lcore_dump(stdout);
 	/* Release all threads, and check their states. */
-	__atomic_store_n(&registered_count, 0, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&registered_count, 0, rte_memory_order_release);
 	ret = 0;
 	for (i = 0; i < non_eal_threads_count; i++) {
 		t = &thread_contexts[i];
@@ -337,7 +338,7 @@ struct limit_lcore_context {
 
 cleanup_threads:
 	/* Release all threads */
-	__atomic_store_n(&registered_count, 0, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&registered_count, 0, rte_memory_order_release);
 	for (i = 0; i < non_eal_threads_count; i++) {
 		t = &thread_contexts[i];
 		rte_thread_join(t->id, NULL);
app/test/test_lpm_perf.c +7 -7
index 82daf9e..bc4bdde 100644
@@ -22,8 +22,8 @@
 struct rte_lpm *lpm;
 static struct rte_rcu_qsbr *rv;
 static volatile uint8_t writer_done;
-static volatile uint32_t thr_id;
-static uint64_t gwrite_cycles;
+static volatile RTE_ATOMIC(uint32_t) thr_id;
+static RTE_ATOMIC(uint64_t) gwrite_cycles;
 static uint32_t num_writers;
 
 /* LPM APIs are not thread safe, use spinlock */
@@ -362,7 +362,7 @@ static void generate_large_route_rule_table(void)
 {
 	uint32_t tmp_thr_id;
 
-	tmp_thr_id = __atomic_fetch_add(&thr_id, 1, __ATOMIC_RELAXED);
+	tmp_thr_id = rte_atomic_fetch_add_explicit(&thr_id, 1, rte_memory_order_relaxed);
 	if (tmp_thr_id >= RTE_MAX_LCORE)
 		printf("Invalid thread id %u\n", tmp_thr_id);
 
@@ -470,7 +470,7 @@ static void generate_large_route_rule_table(void)
 
 	total_cycles = rte_rdtsc_precise() - begin;
 
-	__atomic_fetch_add(&gwrite_cycles, total_cycles, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit(&gwrite_cycles, total_cycles, rte_memory_order_relaxed);
 
 	return 0;
 
@@ -540,9 +540,9 @@ static void generate_large_route_rule_table(void)
 			reader_f = test_lpm_reader;
 
 		writer_done = 0;
-		__atomic_store_n(&gwrite_cycles, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&gwrite_cycles, 0, rte_memory_order_relaxed);
 
-		__atomic_store_n(&thr_id, 0, __ATOMIC_SEQ_CST);
+		rte_atomic_store_explicit(&thr_id, 0, rte_memory_order_seq_cst);
 
 		/* Launch reader threads */
 		for (i = j; i < num_cores; i++)
@@ -563,7 +563,7 @@ static void generate_large_route_rule_table(void)
 		printf("Total LPM Adds: %d\n", TOTAL_WRITES);
 		printf("Total LPM Deletes: %d\n", TOTAL_WRITES);
 		printf("Average LPM Add/Del: %"PRIu64" cycles\n",
-			__atomic_load_n(&gwrite_cycles, __ATOMIC_RELAXED)
+			rte_atomic_load_explicit(&gwrite_cycles, rte_memory_order_relaxed)
 			/ TOTAL_WRITES);
 
 		writer_done = 1;
app/test/test_mcslock.c +6 -6
index 46ff13c..8fcbc11 100644
@@ -42,7 +42,7 @@
 
 static unsigned int count;
 
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 static int
 test_mcslock_per_core(__rte_unused void *arg)
@@ -75,7 +75,7 @@
 	rte_mcslock_t ml_perf_me;
 
 	/* wait synchro */
-	rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+	rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1, rte_memory_order_relaxed);
 
 	begin = rte_get_timer_cycles();
 	while (lcount < MAX_LOOP) {
@@ -100,14 +100,14 @@
 	const unsigned int lcore = rte_lcore_id();
 
 	printf("\nTest with no lock on single core...\n");
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 	printf("Core [%u] Cost Time = %"PRIu64" us\n",
 			lcore, time_count[lcore]);
 	memset(time_count, 0, sizeof(time_count));
 
 	printf("\nTest with lock on single core...\n");
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	lock = 1;
 	load_loop_fn(&lock);
 	printf("Core [%u] Cost Time = %"PRIu64" us\n",
@@ -116,11 +116,11 @@
 
 	printf("\nTest with lock on %u cores...\n", (rte_lcore_count()));
 
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 	rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN);
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 
 	rte_eal_mp_wait_lcore();
app/test/test_mempool_perf.c +5 -4
index a42a772..130d598 100644
@@ -88,7 +88,7 @@
 static int use_external_cache;
 static unsigned external_cache_size = RTE_MEMPOOL_CACHE_MAX_SIZE;
 
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 /* number of objects in one bulk operation (get or put) */
 static unsigned n_get_bulk;
@@ -188,7 +188,8 @@ struct __rte_cache_aligned mempool_test_stats {
 
 	/* wait synchro for workers */
 	if (lcore_id != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	start_cycles = rte_get_timer_cycles();
 
@@ -233,7 +234,7 @@ struct __rte_cache_aligned mempool_test_stats {
 	int ret;
 	unsigned cores_save = cores;
 
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 
 	/* reset stats */
 	memset(stats, 0, sizeof(stats));
@@ -258,7 +259,7 @@ struct __rte_cache_aligned mempool_test_stats {
 	}
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 
 	ret = per_lcore_mempool_test(mp);
 
app/test/test_pflock.c +7 -6
index 5f77b15..d989a68 100644
@@ -31,7 +31,7 @@
 
 static rte_pflock_t sl;
 static rte_pflock_t sl_tab[RTE_MAX_LCORE];
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 static int
 test_pflock_per_core(__rte_unused void *arg)
@@ -69,7 +69,8 @@
 
 	/* wait synchro for workers */
 	if (lcore != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	begin = rte_rdtsc_precise();
 	while (lcount < MAX_LOOP) {
@@ -99,7 +100,7 @@
 	const unsigned int lcore = rte_lcore_id();
 
 	printf("\nTest with no lock on single core...\n");
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 	printf("Core [%u] Cost Time = %"PRIu64" us\n",
 			lcore, time_count[lcore]);
@@ -107,7 +108,7 @@
 
 	printf("\nTest with phase-fair lock on single core...\n");
 	lock = 1;
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 	printf("Core [%u] Cost Time = %"PRIu64" us\n",
 			lcore, time_count[lcore]);
@@ -116,12 +117,12 @@
 	printf("\nPhase-fair test on %u cores...\n", rte_lcore_count());
 
 	/* clear synchro and start workers */
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 	if (rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN) < 0)
 		return -1;
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 
 	rte_eal_mp_wait_lcore();
app/test/test_pmd_perf.c +5 -5
index 35fa068..995b0a6 100644
@@ -537,7 +537,7 @@ enum {
 	return 0;
 }
 
-static uint64_t start;
+static RTE_ATOMIC(uint64_t) start;
 
 static inline int
 poll_burst(void *args)
@@ -575,7 +575,7 @@ enum {
 		num[portid] = pkt_per_port;
 	}
 
-	rte_wait_until_equal_64(&start, 1, __ATOMIC_ACQUIRE);
+	rte_wait_until_equal_64((uint64_t *)(uintptr_t)&start, 1, rte_memory_order_acquire);
 
 	cur_tsc = rte_rdtsc();
 	while (total) {
@@ -629,9 +629,9 @@ enum {
 
 	/* only when polling first */
 	if (flags == SC_BURST_POLL_FIRST)
-		__atomic_store_n(&start, 1, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&start, 1, rte_memory_order_relaxed);
 	else
-		__atomic_store_n(&start, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&start, 0, rte_memory_order_relaxed);
 
 	/* start polling thread
 	 * if in POLL_FIRST mode, poll once launched;
@@ -655,7 +655,7 @@ enum {
 
 	/* only when polling second  */
 	if (flags == SC_BURST_XMIT_FIRST)
-		__atomic_store_n(&start, 1, __ATOMIC_RELEASE);
+		rte_atomic_store_explicit(&start, 1, rte_memory_order_release);
 
 	/* wait for polling finished */
 	diff_tsc = rte_eal_wait_lcore(lcore);
app/test/test_rcu_qsbr_perf.c +59 -55

243 lines not on this page · raw message

app/test/test_ring_perf.c +6 -5
index d7c5a4c..6d7a0a8 100644
@@ -186,7 +186,7 @@ struct thread_params {
 	void *burst = NULL;
 
 #ifdef RTE_USE_C11_MEM_MODEL
-	if (__atomic_fetch_add(&lcore_count, 1, __ATOMIC_RELAXED) + 1 != 2)
+	if (rte_atomic_fetch_add_explicit(&lcore_count, 1, rte_memory_order_relaxed) + 1 != 2)
 #else
 	if (__sync_add_and_fetch(&lcore_count, 1) != 2)
 #endif
@@ -320,7 +320,7 @@ struct thread_params {
 	return 0;
 }
 
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 static uint64_t queue_count[RTE_MAX_LCORE];
 
 #define TIME_MS 100
@@ -342,7 +342,8 @@ struct thread_params {
 
 	/* wait synchro for workers */
 	if (lcore != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	begin = rte_get_timer_cycles();
 	while (time_diff < hz * TIME_MS / 1000) {
@@ -397,12 +398,12 @@ struct thread_params {
 		param.r = r;
 
 		/* clear synchro and start workers */
-		__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 		if (rte_eal_mp_remote_launch(lcore_f, &param, SKIP_MAIN) < 0)
 			return -1;
 
 		/* start synchro and launch test on main */
-		__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 		lcore_f(&param);
 
 		rte_eal_mp_wait_lcore();
app/test/test_ring_stress_impl.h +5 -5
index 202d47d..8b0bfb1 100644
@@ -24,7 +24,7 @@ enum {
 	WRK_CMD_RUN,
 };
 
-static alignas(RTE_CACHE_LINE_SIZE) uint32_t wrk_cmd = WRK_CMD_STOP;
+static alignas(RTE_CACHE_LINE_SIZE) RTE_ATOMIC(uint32_t) wrk_cmd = WRK_CMD_STOP;
 
 /* test run-time in seconds */
 static const uint32_t run_time = 60;
@@ -203,7 +203,7 @@ struct __rte_cache_aligned ring_elem {
 	 * really releasing any data through 'wrk_cmd' to
 	 * the worker.
 	 */
-	while (__atomic_load_n(&wrk_cmd, __ATOMIC_RELAXED) != WRK_CMD_RUN)
+	while (rte_atomic_load_explicit(&wrk_cmd, rte_memory_order_relaxed) != WRK_CMD_RUN)
 		rte_pause();
 
 	cl = rte_rdtsc_precise();
@@ -246,7 +246,7 @@ struct __rte_cache_aligned ring_elem {
 
 		lcore_stat_update(&la->stats, 1, num, tm0 + tm1, prcs);
 
-	} while (__atomic_load_n(&wrk_cmd, __ATOMIC_RELAXED) == WRK_CMD_RUN);
+	} while (rte_atomic_load_explicit(&wrk_cmd, rte_memory_order_relaxed) == WRK_CMD_RUN);
 
 	cl = rte_rdtsc_precise() - cl;
 	if (prcs == 0)
@@ -360,12 +360,12 @@ struct __rte_cache_aligned ring_elem {
 	}
 
 	/* signal worker to start test */
-	__atomic_store_n(&wrk_cmd, WRK_CMD_RUN, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&wrk_cmd, WRK_CMD_RUN, rte_memory_order_release);
 
 	rte_delay_us(run_time * US_PER_S);
 
 	/* signal worker to start test */
-	__atomic_store_n(&wrk_cmd, WRK_CMD_STOP, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&wrk_cmd, WRK_CMD_STOP, rte_memory_order_release);
 
 	/* wait for workers and collect stats. */
 	mc = rte_lcore_id();
app/test/test_rwlock.c +5 -4
index e8767da..6777b91 100644
@@ -35,7 +35,7 @@
 
 static rte_rwlock_t sl;
 static rte_rwlock_t sl_tab[RTE_MAX_LCORE];
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 enum {
 	LC_TYPE_RDLOCK,
@@ -101,7 +101,8 @@ struct __rte_cache_aligned try_rwlock_lcore {
 
 	/* wait synchro for workers */
 	if (lcore != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	begin = rte_rdtsc_precise();
 	while (lcount < MAX_LOOP) {
@@ -134,12 +135,12 @@ struct __rte_cache_aligned try_rwlock_lcore {
 	printf("\nRwlock Perf Test on %u cores...\n", rte_lcore_count());
 
 	/* clear synchro and start workers */
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 	if (rte_eal_mp_remote_launch(load_loop_fn, NULL, SKIP_MAIN) < 0)
 		return -1;
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(NULL);
 
 	rte_eal_mp_wait_lcore();
app/test/test_seqlock.c +3 -3
index bab8b0f..c5e5e64 100644
@@ -22,7 +22,7 @@ struct __rte_cache_aligned data {
 
 struct reader {
 	struct data *data;
-	uint8_t stop;
+	RTE_ATOMIC(uint8_t) stop;
 };
 
 #define WRITER_RUNTIME 2.0 /* s */
@@ -79,7 +79,7 @@ struct reader {
 	struct reader *r = arg;
 	int rc = TEST_SUCCESS;
 
-	while (__atomic_load_n(&r->stop, __ATOMIC_RELAXED) == 0 &&
+	while (rte_atomic_load_explicit(&r->stop, rte_memory_order_relaxed) == 0 &&
 			rc == TEST_SUCCESS) {
 		struct data *data = r->data;
 		bool interrupted;
@@ -115,7 +115,7 @@ struct reader {
 static void
 reader_stop(struct reader *reader)
 {
-	__atomic_store_n(&reader->stop, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&reader->stop, 1, rte_memory_order_relaxed);
 }
 
 #define NUM_WRITERS 2 /* main lcore + one worker */
app/test/test_service_cores.c +12 -12
index c12d52d..010ab82 100644
@@ -59,15 +59,15 @@ static int32_t dummy_mt_unsafe_cb(void *args)
 	 * test, because two threads are concurrently in a non-MT safe callback.
 	 */
 	uint32_t *test_params = args;
-	uint32_t *lock = &test_params[0];
+	RTE_ATOMIC(uint32_t) *lock = (uint32_t __rte_atomic *)&test_params[0];
 	uint32_t *pass_test = &test_params[1];
 	uint32_t exp = 0;
-	int lock_taken = __atomic_compare_exchange_n(lock, &exp, 1, 0,
-					__ATOMIC_RELAXED, __ATOMIC_RELAXED);
+	int lock_taken = rte_atomic_compare_exchange_strong_explicit(lock, &exp, 1,
+					rte_memory_order_relaxed, rte_memory_order_relaxed);
 	if (lock_taken) {
 		/* delay with the lock held */
 		rte_delay_ms(250);
-		__atomic_store_n(lock, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(lock, 0, rte_memory_order_relaxed);
 	} else {
 		/* 2nd thread will fail to take lock, so clear pass flag */
 		*pass_test = 0;
@@ -86,15 +86,15 @@ static int32_t dummy_mt_safe_cb(void *args)
 	 *    that 2 threads are running the callback at the same time: MT safe
 	 */
 	uint32_t *test_params = args;
-	uint32_t *lock = &test_params[0];
+	RTE_ATOMIC(uint32_t) *lock = (uint32_t __rte_atomic *)&test_params[0];
 	uint32_t *pass_test = &test_params[1];
 	uint32_t exp = 0;
-	int lock_taken = __atomic_compare_exchange_n(lock, &exp, 1, 0,
-					__ATOMIC_RELAXED, __ATOMIC_RELAXED);
+	int lock_taken = rte_atomic_compare_exchange_strong_explicit(lock, &exp, 1,
+					rte_memory_order_relaxed, rte_memory_order_relaxed);
 	if (lock_taken) {
 		/* delay with the lock held */
 		rte_delay_ms(250);
-		__atomic_store_n(lock, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(lock, 0, rte_memory_order_relaxed);
 	} else {
 		/* 2nd thread will fail to take lock, so set pass flag */
 		*pass_test = 1;
@@ -748,15 +748,15 @@ static int32_t dummy_mt_safe_cb(void *args)
 
 	/* retrieve done flag and lock to add/sub */
 	uint32_t *done = &params[0];
-	uint32_t *lock = &params[1];
+	RTE_ATOMIC(uint32_t) *lock = (uint32_t __rte_atomic *)&params[1];
 
 	while (!*done) {
-		__atomic_fetch_add(lock, 1, __ATOMIC_RELAXED);
+		rte_atomic_fetch_add_explicit(lock, 1, rte_memory_order_relaxed);
 		rte_delay_us(500);
-		if (__atomic_load_n(lock, __ATOMIC_RELAXED) > 1)
+		if (rte_atomic_load_explicit(lock, rte_memory_order_relaxed) > 1)
 			/* pass: second core has simultaneously incremented */
 			*done = 1;
-		__atomic_fetch_sub(lock, 1, __ATOMIC_RELAXED);
+		rte_atomic_fetch_sub_explicit(lock, 1, rte_memory_order_relaxed);
 	}
 
 	return 0;
app/test/test_spinlock.c +5 -4
index 9a481f2..a29405a 100644
@@ -48,7 +48,7 @@
 static rte_spinlock_recursive_t slr;
 static unsigned count = 0;
 
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 static int
 test_spinlock_per_core(__rte_unused void *arg)
@@ -110,7 +110,8 @@
 
 	/* wait synchro for workers */
 	if (lcore != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	begin = rte_get_timer_cycles();
 	while (lcount < MAX_LOOP) {
@@ -149,11 +150,11 @@
 	printf("\nTest with lock on %u cores...\n", rte_lcore_count());
 
 	/* Clear synchro and start workers */
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 	rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN);
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 
 	rte_eal_mp_wait_lcore();
app/test/test_stack_perf.c +6 -6
index c5e1caa..3f17a26 100644
@@ -23,7 +23,7 @@
  */
 static volatile unsigned int bulk_sizes[] = {8, MAX_BURST};
 
-static uint32_t lcore_barrier;
+static RTE_ATOMIC(uint32_t) lcore_barrier;
 
 struct lcore_pair {
 	unsigned int c1;
@@ -143,8 +143,8 @@ struct thread_args {
 	s = args->s;
 	size = args->sz;
 
-	__atomic_fetch_sub(&lcore_barrier, 1, __ATOMIC_RELAXED);
-	rte_wait_until_equal_32(&lcore_barrier, 0, __ATOMIC_RELAXED);
+	rte_atomic_fetch_sub_explicit(&lcore_barrier, 1, rte_memory_order_relaxed);
+	rte_wait_until_equal_32((uint32_t *)(uintptr_t)&lcore_barrier, 0, rte_memory_order_relaxed);
 
 	uint64_t start = rte_rdtsc();
 
@@ -173,7 +173,7 @@ struct thread_args {
 	unsigned int i;
 
 	for (i = 0; i < RTE_DIM(bulk_sizes); i++) {
-		__atomic_store_n(&lcore_barrier, 2, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&lcore_barrier, 2, rte_memory_order_relaxed);
 
 		args[0].sz = args[1].sz = bulk_sizes[i];
 		args[0].s = args[1].s = s;
@@ -206,7 +206,7 @@ struct thread_args {
 		int cnt = 0;
 		double avg;
 
-		__atomic_store_n(&lcore_barrier, n, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&lcore_barrier, n, rte_memory_order_relaxed);
 
 		RTE_LCORE_FOREACH_WORKER(lcore_id) {
 			if (++cnt >= n)
@@ -300,7 +300,7 @@ struct thread_args {
 	struct lcore_pair cores;
 	struct rte_stack *s;
 
-	__atomic_store_n(&lcore_barrier, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&lcore_barrier, 0, rte_memory_order_relaxed);
 
 	s = rte_stack_create(STACK_NAME, STACK_SIZE, rte_socket_id(), flags);
 	if (s == NULL) {
app/test/test_threads.c +17 -16
index 4ac3f26..6d6881a 100644
@@ -6,12 +6,13 @@
 
 #include <rte_thread.h>
 #include <rte_debug.h>
+#include <rte_stdatomic.h>
 
 #include "test.h"
 
 RTE_LOG_REGISTER(threads_logtype_test, test.threads, INFO);
 
-static uint32_t thread_id_ready;
+static RTE_ATOMIC(uint32_t) thread_id_ready;
 
 static uint32_t
 thread_main(void *arg)
@@ -19,9 +20,9 @@
 	if (arg != NULL)
 		*(rte_thread_t *)arg = rte_thread_self();
 
-	__atomic_store_n(&thread_id_ready, 1, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 1, rte_memory_order_release);
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 1)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 1)
 		;
 
 	return 0;
@@ -37,13 +38,13 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, &thread_main_id) == 0,
 		"Failed to create thread.");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
 		"Unexpected thread id.");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	RTE_TEST_ASSERT(rte_thread_join(thread_id, NULL) == 0,
 		"Failed to join thread.");
@@ -61,13 +62,13 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main,
 		&thread_main_id) == 0, "Failed to create thread.");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
 		"Unexpected thread id.");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	RTE_TEST_ASSERT(rte_thread_detach(thread_id) == 0,
 		"Failed to detach thread.");
@@ -85,7 +86,7 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0,
 		"Failed to create thread");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	priority = RTE_THREAD_PRIORITY_NORMAL;
@@ -121,7 +122,7 @@
 	RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL,
 		"Priority set mismatches priority get");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	return 0;
 }
@@ -137,7 +138,7 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0,
 		"Failed to create thread");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset0) == 0,
@@ -190,7 +191,7 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, &attr, thread_main, NULL) == 0,
 		"Failed to create attributes affinity thread.");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_get_affinity_by_id(thread_id, &cpuset1) == 0,
@@ -198,7 +199,7 @@
 	RTE_TEST_ASSERT(memcmp(&cpuset0, &cpuset1, sizeof(rte_cpuset_t)) == 0,
 		"Failed to apply affinity attributes");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	return 0;
 }
@@ -219,7 +220,7 @@
 	RTE_TEST_ASSERT(rte_thread_create(&thread_id, &attr, thread_main, NULL) == 0,
 		"Failed to create attributes priority thread.");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0,
@@ -227,7 +228,7 @@
 	RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL,
 		"Failed to apply priority attributes");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	return 0;
 }
@@ -243,13 +244,13 @@
 		thread_main, &thread_main_id) == 0,
 		"Failed to create thread.");
 
-	while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0)
+	while (rte_atomic_load_explicit(&thread_id_ready, rte_memory_order_acquire) == 0)
 		;
 
 	RTE_TEST_ASSERT(rte_thread_equal(thread_id, thread_main_id) != 0,
 		"Unexpected thread id.");
 
-	__atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&thread_id_ready, 2, rte_memory_order_release);
 
 	RTE_TEST_ASSERT(rte_thread_join(thread_id, NULL) == 0,
 		"Failed to join thread.");
app/test/test_ticketlock.c +5 -4
index 7a6cb4c..ad4a2d8 100644
@@ -48,7 +48,7 @@
 static rte_ticketlock_recursive_t tlr;
 static unsigned int count;
 
-static uint32_t synchro;
+static RTE_ATOMIC(uint32_t) synchro;
 
 static int
 test_ticketlock_per_core(__rte_unused void *arg)
@@ -111,7 +111,8 @@
 
 	/* wait synchro for workers */
 	if (lcore != rte_get_main_lcore())
-		rte_wait_until_equal_32(&synchro, 1, __ATOMIC_RELAXED);
+		rte_wait_until_equal_32((uint32_t *)(uintptr_t)&synchro, 1,
+		    rte_memory_order_relaxed);
 
 	begin = rte_rdtsc_precise();
 	while (lcore_count[lcore] < MAX_LOOP) {
@@ -153,11 +154,11 @@
 	printf("\nTest with lock on %u cores...\n", rte_lcore_count());
 
 	/* Clear synchro and start workers */
-	__atomic_store_n(&synchro, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 0, rte_memory_order_relaxed);
 	rte_eal_mp_remote_launch(load_loop_fn, &lock, SKIP_MAIN);
 
 	/* start synchro and launch test on main */
-	__atomic_store_n(&synchro, 1, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&synchro, 1, rte_memory_order_relaxed);
 	load_loop_fn(&lock);
 
 	rte_eal_mp_wait_lcore();
app/test/test_timer.c +19 -12
index cac8fc0..dc15a80 100644
@@ -202,7 +202,7 @@ struct mytimerinfo {
 
 /* Need to synchronize worker lcores through multiple steps. */
 enum { WORKER_WAITING = 1, WORKER_RUN_SIGNAL, WORKER_RUNNING, WORKER_FINISHED };
-static uint16_t lcore_state[RTE_MAX_LCORE];
+static RTE_ATOMIC(uint16_t) lcore_state[RTE_MAX_LCORE];
 
 static void
 main_init_workers(void)
@@ -210,7 +210,8 @@ struct mytimerinfo {
 	unsigned i;
 
 	RTE_LCORE_FOREACH_WORKER(i) {
-		__atomic_store_n(&lcore_state[i], WORKER_WAITING, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&lcore_state[i], WORKER_WAITING,
+		    rte_memory_order_relaxed);
 	}
 }
 
@@ -220,10 +221,12 @@ struct mytimerinfo {
 	unsigned i;
 
 	RTE_LCORE_FOREACH_WORKER(i) {
-		__atomic_store_n(&lcore_state[i], WORKER_RUN_SIGNAL, __ATOMIC_RELEASE);
+		rte_atomic_store_explicit(&lcore_state[i], WORKER_RUN_SIGNAL,
+		    rte_memory_order_release);
 	}
 	RTE_LCORE_FOREACH_WORKER(i) {
-		rte_wait_until_equal_16(&lcore_state[i], WORKER_RUNNING, __ATOMIC_ACQUIRE);
+		rte_wait_until_equal_16((uint16_t *)(uintptr_t)&lcore_state[i], WORKER_RUNNING,
+		    rte_memory_order_acquire);
 	}
 }
 
@@ -233,7 +236,8 @@ struct mytimerinfo {
 	unsigned i;
 
 	RTE_LCORE_FOREACH_WORKER(i) {
-		rte_wait_until_equal_16(&lcore_state[i], WORKER_FINISHED, __ATOMIC_ACQUIRE);
+		rte_wait_until_equal_16((uint16_t *)(uintptr_t)&lcore_state[i], WORKER_FINISHED,
+		    rte_memory_order_acquire);
 	}
 }
 
@@ -242,8 +246,10 @@ struct mytimerinfo {
 {
 	unsigned lcore_id = rte_lcore_id();
 
-	rte_wait_until_equal_16(&lcore_state[lcore_id], WORKER_RUN_SIGNAL, __ATOMIC_ACQUIRE);
-	__atomic_store_n(&lcore_state[lcore_id], WORKER_RUNNING, __ATOMIC_RELEASE);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&lcore_state[lcore_id], WORKER_RUN_SIGNAL,
+	    rte_memory_order_acquire);
+	rte_atomic_store_explicit(&lcore_state[lcore_id], WORKER_RUNNING,
+	    rte_memory_order_release);
 }
 
 static void
@@ -251,7 +257,8 @@ struct mytimerinfo {
 {
 	unsigned lcore_id = rte_lcore_id();
 
-	__atomic_store_n(&lcore_state[lcore_id], WORKER_FINISHED, __ATOMIC_RELEASE);
+	rte_atomic_store_explicit(&lcore_state[lcore_id], WORKER_FINISHED,
+	    rte_memory_order_release);
 }
 
 
@@ -277,12 +284,12 @@ struct mytimerinfo {
 	unsigned int lcore_id = rte_lcore_id();
 	unsigned int main_lcore = rte_get_main_lcore();
 	int32_t my_collisions = 0;
-	static uint32_t collisions;
+	static RTE_ATOMIC(uint32_t) collisions;
 
 	if (lcore_id == main_lcore) {
 		cb_count = 0;
 		test_failed = 0;
-		__atomic_store_n(&collisions, 0, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&collisions, 0, rte_memory_order_relaxed);
 		timers = rte_malloc(NULL, sizeof(*timers) * NB_STRESS2_TIMERS, 0);
 		if (timers == NULL) {
 			printf("Test Failed\n");
@@ -310,7 +317,7 @@ struct mytimerinfo {
 			my_collisions++;
 	}
 	if (my_collisions != 0)
-		__atomic_fetch_add(&collisions, my_collisions, __ATOMIC_RELAXED);
+		rte_atomic_fetch_add_explicit(&collisions, my_collisions, rte_memory_order_relaxed);
 
 	/* wait long enough for timers to expire */
 	rte_delay_ms(100);
@@ -324,7 +331,7 @@ struct mytimerinfo {
 
 	/* now check that we get the right number of callbacks */
 	if (lcore_id == main_lcore) {
-		my_collisions = __atomic_load_n(&collisions, __ATOMIC_RELAXED);
+		my_collisions = rte_atomic_load_explicit(&collisions, rte_memory_order_relaxed);
 		if (my_collisions != 0)
 			printf("- %d timer reset collisions (OK)\n", my_collisions);
 		rte_timer_manage();
Signature · 1 line
1.8.3.1
#294 lore raw

PATCH v6 42/45 app/test-eventdev: use rte stdatomic API

In reply to Tyler Retzlaff

Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API.

---
 app/test-eventdev/test_order_atq.c    | 4 ++--
 app/test-eventdev/test_order_common.c | 5 +++--
 app/test-eventdev/test_order_common.h | 8 ++++----
 app/test-eventdev/test_order_queue.c  | 4 ++--
 app/test-eventdev/test_perf_common.h  | 6 +++---
 5 files changed, 14 insertions(+), 13 deletions(-)
app/test-eventdev/test_order_atq.c +2 -2
index 2fee4b4..128d3f2 100644
@@ -28,7 +28,7 @@
 		uint16_t event = rte_event_dequeue_burst(dev_id, port,
 					&ev, 1, 0);
 		if (!event) {
-			if (__atomic_load_n(outstand_pkts, __ATOMIC_RELAXED) <= 0)
+			if (rte_atomic_load_explicit(outstand_pkts, rte_memory_order_relaxed) <= 0)
 				break;
 			rte_pause();
 			continue;
@@ -64,7 +64,7 @@
 				BURST_SIZE, 0);
 
 		if (nb_rx == 0) {
-			if (__atomic_load_n(outstand_pkts, __ATOMIC_RELAXED) <= 0)
+			if (rte_atomic_load_explicit(outstand_pkts, rte_memory_order_relaxed) <= 0)
 				break;
 			rte_pause();
 			continue;
app/test-eventdev/test_order_common.c +3 -2
index a9894c6..0fceace 100644
@@ -189,7 +189,7 @@
 		evt_err("failed to allocate t->expected_flow_seq memory");
 		goto exp_nomem;
 	}
-	__atomic_store_n(&t->outstand_pkts, opt->nb_pkts, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&t->outstand_pkts, opt->nb_pkts, rte_memory_order_relaxed);
 	t->err = false;
 	t->nb_pkts = opt->nb_pkts;
 	t->nb_flows = opt->nb_flows;
@@ -296,7 +296,8 @@
 
 	while (t->err == false) {
 		uint64_t new_cycles = rte_get_timer_cycles();
-		int64_t remaining = __atomic_load_n(&t->outstand_pkts, __ATOMIC_RELAXED);
+		int64_t remaining = rte_atomic_load_explicit(&t->outstand_pkts,
+		    rte_memory_order_relaxed);
 
 		if (remaining <= 0) {
 			t->result = EVT_TEST_SUCCESS;
app/test-eventdev/test_order_common.h +4 -4
index d4cbc5c..7177fd8 100644
@@ -48,7 +48,7 @@ struct __rte_cache_aligned test_order {
 	 * The atomic_* is an expensive operation,Since it is a functional test,
 	 * We are using the atomic_ operation to reduce the code complexity.
 	 */
-	uint64_t outstand_pkts;
+	RTE_ATOMIC(uint64_t) outstand_pkts;
 	enum evt_test_result result;
 	uint32_t nb_flows;
 	uint64_t nb_pkts;
@@ -95,7 +95,7 @@ struct __rte_cache_aligned test_order {
 order_process_stage_1(struct test_order *const t,
 		struct rte_event *const ev, const uint32_t nb_flows,
 		uint32_t *const expected_flow_seq,
-		uint64_t *const outstand_pkts)
+		RTE_ATOMIC(uint64_t) *const outstand_pkts)
 {
 	const uint32_t flow = (uintptr_t)ev->mbuf % nb_flows;
 	/* compare the seqn against expected value */
@@ -113,7 +113,7 @@ struct __rte_cache_aligned test_order {
 	 */
 	expected_flow_seq[flow]++;
 	rte_pktmbuf_free(ev->mbuf);
-	__atomic_fetch_sub(outstand_pkts, 1, __ATOMIC_RELAXED);
+	rte_atomic_fetch_sub_explicit(outstand_pkts, 1, rte_memory_order_relaxed);
 }
 
 static __rte_always_inline void
@@ -132,7 +132,7 @@ struct __rte_cache_aligned test_order {
 	const uint8_t port = w->port_id;\
 	const uint32_t nb_flows = t->nb_flows;\
 	uint32_t *expected_flow_seq = t->expected_flow_seq;\
-	uint64_t *outstand_pkts = &t->outstand_pkts;\
+	RTE_ATOMIC(uint64_t) *outstand_pkts = &t->outstand_pkts;\
 	if (opt->verbose_level > 1)\
 		printf("%s(): lcore %d dev_id %d port=%d\n",\
 			__func__, rte_lcore_id(), dev_id, port)
app/test-eventdev/test_order_queue.c +2 -2
index 80eaea5..a282ab2 100644
@@ -28,7 +28,7 @@
 		uint16_t event = rte_event_dequeue_burst(dev_id, port,
 					&ev, 1, 0);
 		if (!event) {
-			if (__atomic_load_n(outstand_pkts, __ATOMIC_RELAXED) <= 0)
+			if (rte_atomic_load_explicit(outstand_pkts, rte_memory_order_relaxed) <= 0)
 				break;
 			rte_pause();
 			continue;
@@ -64,7 +64,7 @@
 				BURST_SIZE, 0);
 
 		if (nb_rx == 0) {
-			if (__atomic_load_n(outstand_pkts, __ATOMIC_RELAXED) <= 0)
+			if (rte_atomic_load_explicit(outstand_pkts, rte_memory_order_relaxed) <= 0)
 				break;
 			rte_pause();
 			continue;
app/test-eventdev/test_perf_common.h +3 -3
index bc627de..d60b873 100644
@@ -225,7 +225,7 @@ struct __rte_cache_aligned perf_elt {
 	 * stored before updating the number of
 	 * processed packets for worker lcores
 	 */
-	rte_atomic_thread_fence(__ATOMIC_RELEASE);
+	rte_atomic_thread_fence(rte_memory_order_release);
 	w->processed_pkts++;
 
 	if (prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
@@ -270,7 +270,7 @@ struct __rte_cache_aligned perf_elt {
 	/* Release fence here ensures event_prt is stored before updating the number of processed
 	 * packets for worker lcores.
 	 */
-	rte_atomic_thread_fence(__ATOMIC_RELEASE);
+	rte_atomic_thread_fence(rte_memory_order_release);
 	w->processed_pkts++;
 
 	if (prod_type == EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR) {
@@ -325,7 +325,7 @@ struct __rte_cache_aligned perf_elt {
 	/* Release fence here ensures event_prt is stored before updating the number of processed
 	 * packets for worker lcores.
 	 */
-	rte_atomic_thread_fence(__ATOMIC_RELEASE);
+	rte_atomic_thread_fence(rte_memory_order_release);
 	w->processed_pkts += vec->nb_elem;
 
 	if (enable_fwd_latency) {
Signature · 1 line
1.8.3.1
#295 lore raw

PATCH v6 43/45 app/test-crypto-perf: use rte stdatomic API

In reply to Tyler Retzlaff

Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API.

---
 app/test-crypto-perf/cperf_test_latency.c        |  6 +++---
 app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 10 +++++-----
 app/test-crypto-perf/cperf_test_throughput.c     | 10 +++++-----
 app/test-crypto-perf/cperf_test_verify.c         | 10 +++++-----
 4 files changed, 18 insertions(+), 18 deletions(-)
app/test-crypto-perf/cperf_test_latency.c +3 -3
index 99b7d7c..b8ad6bf 100644
@@ -136,7 +136,7 @@ struct priv_op_data {
 	uint32_t imix_idx = 0;
 	int ret = 0;
 
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 
 	if (ctx == NULL)
 		return 0;
@@ -341,8 +341,8 @@ struct priv_op_data {
 
 		uint16_t exp = 0;
 		if (ctx->options->csv) {
-			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# lcore, Buffer Size, Burst Size, Pakt Seq #, "
 						"cycles, time (us)");
 
app/test-crypto-perf/cperf_test_pmd_cyclecount.c +5 -5
index 4a60f6d..7191d99 100644
@@ -396,7 +396,7 @@ struct pmd_cyclecount_state {
 	state.lcore = rte_lcore_id();
 	state.linearize = 0;
 
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 	static bool warmup = true;
 
 	/*
@@ -443,8 +443,8 @@ struct pmd_cyclecount_state {
 
 		uint16_t exp = 0;
 		if (!opts->csv) {
-			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(PRETTY_HDR_FMT, "lcore id", "Buf Size",
 						"Burst Size", "Enqueued",
 						"Dequeued", "Enq Retries",
@@ -460,8 +460,8 @@ struct pmd_cyclecount_state {
 					state.cycles_per_enq,
 					state.cycles_per_deq);
 		} else {
-			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(CSV_HDR_FMT, "# lcore id", "Buf Size",
 						"Burst Size", "Enqueued",
 						"Dequeued", "Enq Retries",
app/test-crypto-perf/cperf_test_throughput.c +5 -5
index e3d266d..c0891e7 100644
@@ -107,7 +107,7 @@ struct cperf_throughput_ctx {
 	uint8_t burst_size_idx = 0;
 	uint32_t imix_idx = 0;
 
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 
 	struct rte_crypto_op *ops[ctx->options->max_burst_size];
 	struct rte_crypto_op *ops_processed[ctx->options->max_burst_size];
@@ -277,8 +277,8 @@ struct cperf_throughput_ctx {
 
 		uint16_t exp = 0;
 		if (!ctx->options->csv) {
-			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%12s%12s%12s%12s%12s%12s%12s%12s%12s\n\n",
 					"lcore id", "Buf Size", "Burst Size",
 					"Enqueued", "Dequeued", "Failed Enq",
@@ -298,8 +298,8 @@ struct cperf_throughput_ctx {
 					throughput_gbps,
 					cycles_per_packet);
 		} else {
-			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("#lcore id,Buffer Size(B),"
 					"Burst Size,Enqueued,Dequeued,Failed Enq,"
 					"Failed Deq,Ops(Millions),Throughput(Gbps),"
app/test-crypto-perf/cperf_test_verify.c +5 -5
index 3548509..222c7a1 100644
@@ -216,7 +216,7 @@ struct cperf_op_result {
 	uint64_t ops_deqd = 0, ops_deqd_total = 0, ops_deqd_failed = 0;
 	uint64_t ops_failed = 0;
 
-	static uint16_t display_once;
+	static RTE_ATOMIC(uint16_t) display_once;
 
 	uint64_t i;
 	uint16_t ops_unused = 0;
@@ -370,8 +370,8 @@ struct cperf_op_result {
 
 	uint16_t exp = 0;
 	if (!ctx->options->csv) {
-		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%12s%12s%12s%12s%12s%12s%12s\n\n",
 				"lcore id", "Buf Size", "Burst size",
 				"Enqueued", "Dequeued", "Failed Enq",
@@ -388,8 +388,8 @@ struct cperf_op_result {
 				ops_deqd_failed,
 				ops_failed);
 	} else {
-		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# lcore id, Buffer Size(B), "
 				"Burst Size,Enqueued,Dequeued,Failed Enq,"
 				"Failed Deq,Failed Ops\n");
Signature · 1 line
1.8.3.1
#296 lore raw

PATCH v6 44/45 app/test-compress-perf: use rte stdatomic API

In reply to Tyler Retzlaff

Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API.

---
 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(-)
app/test-compress-perf/comp_perf_test_common.h +1 -1
index d039e5a..085e269 100644
@@ -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;
app/test-compress-perf/comp_perf_test_cyclecount.c +2 -2
index 4d336ec..64e8faa 100644
@@ -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,"
app/test-compress-perf/comp_perf_test_throughput.c +5 -5
index 1f7072d..089d19c 100644
@@ -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]");
app/test-compress-perf/comp_perf_test_verify.c +3 -3
index 7bd1807..09d97c5 100644
@@ -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 [%]");
 		}
Signature · 1 line
1.8.3.1
#297 lore raw

PATCH v6 45/45 app/test-bbdev: use rte stdatomic API

In reply to Tyler Retzlaff

Replace the use of gcc builtin __atomic_xxx intrinsics with corresponding rte_atomic_xxx optional rte stdatomic API.

---
 app/test-bbdev/test_bbdev_perf.c | 183 +++++++++++++++++++++++----------------
 1 file changed, 110 insertions(+), 73 deletions(-)
app/test-bbdev/test_bbdev_perf.c +110 -73
index dcce00a..9694ed3 100644
@@ -144,7 +144,7 @@ struct test_op_params {
 	uint16_t num_to_process;
 	uint16_t num_lcores;
 	int vector_mask;
-	uint16_t sync;
+	RTE_ATOMIC(uint16_t) sync;
 	struct test_buffers q_bufs[RTE_MAX_NUMA_NODES][MAX_QUEUES];
 };
 
@@ -159,9 +159,9 @@ struct thread_params {
 	uint8_t iter_count;
 	double iter_average;
 	double bler;
-	uint16_t nb_dequeued;
-	int16_t processing_status;
-	uint16_t burst_sz;
+	RTE_ATOMIC(uint16_t) nb_dequeued;
+	RTE_ATOMIC(int16_t) processing_status;
+	RTE_ATOMIC(uint16_t) burst_sz;
 	struct test_op_params *op_params;
 	struct rte_bbdev_dec_op *dec_ops[MAX_BURST];
 	struct rte_bbdev_enc_op *enc_ops[MAX_BURST];
@@ -3195,56 +3195,64 @@ typedef int (test_case_function)(struct active_device *ad,
 	}
 
 	if (unlikely(event != RTE_BBDEV_EVENT_DEQUEUE)) {
-		__atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
+		    rte_memory_order_relaxed);
 		printf(
 			"Dequeue interrupt handler called for incorrect event!\n");
 		return;
 	}
 
-	burst_sz = __atomic_load_n(&tp->burst_sz, __ATOMIC_RELAXED);
+	burst_sz = rte_atomic_load_explicit(&tp->burst_sz, rte_memory_order_relaxed);
 	num_ops = tp->op_params->num_to_process;
 
 	if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
 		deq = rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
 				&tp->dec_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 	else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
 		deq = rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
 				&tp->dec_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 	else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
 		deq = rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
 				&tp->enc_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 	else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
 		deq = rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
 				&tp->fft_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 	else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
 		deq = rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
 				&tp->mldts_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 	else /*RTE_BBDEV_OP_TURBO_ENC*/
 		deq = rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
 				&tp->enc_ops[
-					__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED)],
+					rte_atomic_load_explicit(&tp->nb_dequeued,
+					    rte_memory_order_relaxed)],
 				burst_sz);
 
 	if (deq < burst_sz) {
 		printf(
 			"After receiving the interrupt all operations should be dequeued. Expected: %u, got: %u\n",
 			burst_sz, deq);
-		__atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
+		    rte_memory_order_relaxed);
 		return;
 	}
 
-	if (__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) + deq < num_ops) {
-		__atomic_fetch_add(&tp->nb_dequeued, deq, __ATOMIC_RELAXED);
+	if (rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) + deq < num_ops) {
+		rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
 		return;
 	}
 
@@ -3288,7 +3296,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	if (ret) {
 		printf("Buffers validation failed\n");
-		__atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
+		    rte_memory_order_relaxed);
 	}
 
 	switch (test_vector.op_type) {
@@ -3315,7 +3324,8 @@ typedef int (test_case_function)(struct active_device *ad,
 		break;
 	default:
 		printf("Unknown op type: %d\n", test_vector.op_type);
-		__atomic_store_n(&tp->processing_status, TEST_FAILED, __ATOMIC_RELAXED);
+		rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
+		    rte_memory_order_relaxed);
 		return;
 	}
 
@@ -3324,7 +3334,7 @@ typedef int (test_case_function)(struct active_device *ad,
 	tp->mbps += (((double)(num_ops * tb_len_bits)) / 1000000.0) /
 			((double)total_time / (double)rte_get_tsc_hz());
 
-	__atomic_fetch_add(&tp->nb_dequeued, deq, __ATOMIC_RELAXED);
+	rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
 }
 
 static int
@@ -3362,10 +3372,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
 				num_to_process);
@@ -3415,15 +3426,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3459,10 +3472,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
 				num_to_process);
@@ -3506,15 +3520,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3549,10 +3565,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
 			num_to_process);
@@ -3592,15 +3609,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3636,10 +3655,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
 			num_to_process);
@@ -3681,15 +3701,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3725,10 +3747,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops,
 			num_to_process);
@@ -3769,15 +3792,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3811,10 +3836,11 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	__atomic_store_n(&tp->processing_status, 0, __ATOMIC_RELAXED);
-	__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
+	rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops, num_to_process);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_to_process);
@@ -3851,15 +3877,17 @@ typedef int (test_case_function)(struct active_device *ad,
 			 * the number of operations is not a multiple of
 			 * burst size.
 			 */
-			__atomic_store_n(&tp->burst_sz, num_to_enq, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
+			    rte_memory_order_relaxed);
 
 			/* Wait until processing of previous batch is
 			 * completed
 			 */
-			rte_wait_until_equal_16(&tp->nb_dequeued, enqueued, __ATOMIC_RELAXED);
+			rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
+			    rte_memory_order_relaxed);
 		}
 		if (j != TEST_REPETITIONS - 1)
-			__atomic_store_n(&tp->nb_dequeued, 0, __ATOMIC_RELAXED);
+			rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
 	}
 
 	return TEST_SUCCESS;
@@ -3894,7 +3922,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4013,7 +4042,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4148,7 +4178,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4271,7 +4302,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4402,7 +4434,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
 			num_ops);
@@ -4503,7 +4536,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
 			num_ops);
@@ -4604,7 +4638,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4702,7 +4737,8 @@ typedef int (test_case_function)(struct active_device *ad,
 
 	bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
 
-	rte_wait_until_equal_16(&tp->op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
+	    rte_memory_order_relaxed);
 
 	ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
 	TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
@@ -4898,7 +4934,7 @@ typedef int (test_case_function)(struct active_device *ad,
 	else
 		return TEST_SKIPPED;
 
-	__atomic_store_n(&op_params->sync, SYNC_WAIT, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
 
 	/* Main core is set at first entry */
 	t_params[0].dev_id = ad->dev_id;
@@ -4921,7 +4957,7 @@ typedef int (test_case_function)(struct active_device *ad,
 				&t_params[used_cores++], lcore_id);
 	}
 
-	__atomic_store_n(&op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
 	ret = bler_function(&t_params[0]);
 
 	/* Main core is always used */
@@ -5024,7 +5060,7 @@ typedef int (test_case_function)(struct active_device *ad,
 			throughput_function = throughput_pmd_lcore_enc;
 	}
 
-	__atomic_store_n(&op_params->sync, SYNC_WAIT, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
 
 	/* Main core is set at first entry */
 	t_params[0].dev_id = ad->dev_id;
@@ -5047,7 +5083,7 @@ typedef int (test_case_function)(struct active_device *ad,
 				&t_params[used_cores++], lcore_id);
 	}
 
-	__atomic_store_n(&op_params->sync, SYNC_START, __ATOMIC_RELAXED);
+	rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
 	ret = throughput_function(&t_params[0]);
 
 	/* Main core is always used */
@@ -5077,29 +5113,30 @@ typedef int (test_case_function)(struct active_device *ad,
 	 * Wait for main lcore operations.
 	 */
 	tp = &t_params[0];
-	while ((__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) <
+	while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
 		op_params->num_to_process) &&
-		(__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED) !=
+		(rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed) !=
 		TEST_FAILED))
 		rte_pause();
 
 	tp->ops_per_sec /= TEST_REPETITIONS;
 	tp->mbps /= TEST_REPETITIONS;
-	ret |= (int)__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED);
+	ret |= (int)rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed);
 
 	/* Wait for worker lcores operations */
 	for (used_cores = 1; used_cores < num_lcores; used_cores++) {
 		tp = &t_params[used_cores];
 
-		while ((__atomic_load_n(&tp->nb_dequeued, __ATOMIC_RELAXED) <
+		while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
 			op_params->num_to_process) &&
-			(__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED) !=
-			TEST_FAILED))
+			(rte_atomic_load_explicit(&tp->processing_status,
+			    rte_memory_order_relaxed) != TEST_FAILED))
 			rte_pause();
 
 		tp->ops_per_sec /= TEST_REPETITIONS;
 		tp->mbps /= TEST_REPETITIONS;
-		ret |= (int)__atomic_load_n(&tp->processing_status, __ATOMIC_RELAXED);
+		ret |= (int)rte_atomic_load_explicit(&tp->processing_status,
+		    rte_memory_order_relaxed);
 	}
 
 	/* Print throughput if test passed */
Signature · 1 line
1.8.3.1
#298 lore raw
In reply to Tyler Retzlaff
Quoted 8 lines · Tyler Retzlaff

This series converts all non-generic built atomics to use the rte_atomic macros that allow optional enablement of standard C11 atomics.

Use of generic atomics for non-scalar types are not converted in this change and will be evaluated as a part of a separate series. Specifically conversion of lib/lpm and drivers/x/cnxk will be addressed in a separate series to address use of generics.

I adjusted some more 4 space indents (trying to preserve the beauty of the pre-existing indent when possible), and applied this series. Thanks Tyler.

Signature · 1 line
David Marchand
#299 lore raw
Quoted 6 lines · David Marchand
Quoted 4 lines · Tyler Retzlaff

This series converts all non-generic built atomics to use the rte_atomic macros that allow optional enablement of standard C11 atomics.

Quoted 8 lines
Quoted 4 lines

Use of generic atomics for non-scalar types are not converted in this change and will be evaluated as a part of a separate series. Specifically conversion of lib/lpm and drivers/x/cnxk will be addressed in a separate series to address use of generics.

I adjusted some more 4 space indents (trying to preserve the beauty of the pre-existing indent when possible), and applied this series. Thanks Tyler.

Appreciate it David!

Quoted 4 lines
Signature · 2 lines
-- 
David Marchand