diff mbox

validation:add atomic test in odp syncronizers

Message ID 1418181555-7970-1-git-send-email-yan.songming@linaro.org
State New
Headers show

Commit Message

yan.songming Dec. 10, 2014, 3:19 a.m. UTC
Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
to test/validation as one part of odp syncronizers test

Signed-off-by: Yan Songming <yan.songming@linaro.org>
---
 test/api_test/Makefile.am              |   5 +-
 test/api_test/odp_atomic_test.c        | 299 ---------------------------------
 test/api_test/odp_atomic_test.h        |  51 ------
 test/api_test/odp_common.c             |   1 -
 test/validation/.gitignore             |   1 +
 test/validation/Makefile.am            |   6 +-
 test/validation/odp_syne.c             |  15 ++
 test/validation/syne/odp_test_atomic.c | 258 ++++++++++++++++++++++++++++
 test/validation/syne/odp_test_atomic.h |  14 ++
 9 files changed, 294 insertions(+), 356 deletions(-)
 delete mode 100644 test/api_test/odp_atomic_test.c
 delete mode 100644 test/api_test/odp_atomic_test.h
 create mode 100644 test/validation/odp_syne.c
 create mode 100644 test/validation/syne/odp_test_atomic.c
 create mode 100644 test/validation/syne/odp_test_atomic.h

Comments

Mike Holmes Dec. 10, 2014, 7:42 p.m. UTC | #1
I think odp_syne would be better as odp_sync  throughout the patch

Does Barrys patch cover atomics in an overlapping way, or do we have both
as separate suites ? I think this one is much more sunny day as we had
originally planned.
Mario were you able to make the final changes to create a patch for tip
from Barrys files, do we need to wait until we can see that patch along
side this one ?

Mike


On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org> wrote:

> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
> to test/validation as one part of odp syncronizers test
>

syncronizers


>
> Signed-off-by: Yan Songming <yan.songming@linaro.org>
> ---
>  test/api_test/Makefile.am              |   5 +-
>  test/api_test/odp_atomic_test.c        | 299
> ---------------------------------
>  test/api_test/odp_atomic_test.h        |  51 ------
>  test/api_test/odp_common.c             |   1 -
>  test/validation/.gitignore             |   1 +
>  test/validation/Makefile.am            |   6 +-
>  test/validation/odp_syne.c             |  15 ++
>  test/validation/syne/odp_test_atomic.c | 258 ++++++++++++++++++++++++++++
>  test/validation/syne/odp_test_atomic.h |  14 ++
>  9 files changed, 294 insertions(+), 356 deletions(-)
>  delete mode 100644 test/api_test/odp_atomic_test.c
>  delete mode 100644 test/api_test/odp_atomic_test.h
>  create mode 100644 test/validation/odp_syne.c
>  create mode 100644 test/validation/syne/odp_test_atomic.c
>  create mode 100644 test/validation/syne/odp_test_atomic.h
>
> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
> index 74e8612..ce301ce 100644
> --- a/test/api_test/Makefile.am
> +++ b/test/api_test/Makefile.am
> @@ -1,18 +1,15 @@
>  include $(top_srcdir)/test/Makefile.inc
>
> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
>
> -odp_atomic_CFLAGS = $(AM_CFLAGS)
>  odp_shm_CFLAGS = $(AM_CFLAGS)
>  odp_ring_CFLAGS = $(AM_CFLAGS)
>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)
>
> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
>
> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
> diff --git a/test/api_test/odp_atomic_test.c
> b/test/api_test/odp_atomic_test.c
> deleted file mode 100644
> index 5563606..0000000
> --- a/test/api_test/odp_atomic_test.c
> +++ /dev/null
> @@ -1,299 +0,0 @@
> -/* Copyright (c) 2013, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -
> -#include <string.h>
> -#include <sys/time.h>
> -#include <odp_common.h>
> -#include <odp_atomic_test.h>
> -#include <test_debug.h>
> -
> -static odp_atomic_u32_t a32u;
> -static odp_atomic_u64_t a64u;
> -
> -static odp_barrier_t barrier;
> -
> -static const char * const test_name[] = {
> -       "dummy",
> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic ints",
> -       "test atomic inc/dec of 32-bit atomic int",
> -       "test atomic add/sub of 32-bit atomic int",
> -       "test atomic inc/dec of 64-bit atomic int",
> -       "test atomic add/sub of 64-bit atomic int"
> -};
> -
> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
> -
> -static void usage(void)
> -{
> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
> -              "\t<testcase> is\n"
> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
> ints)\n"
> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"
> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"
> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"
> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"
> -              "\t\t-n <1 - 31> - no of threads to start\n"
> -              "\t\tif user doesn't specify this option, then\n"
> -              "\t\tno of threads created is equivalent to no of cores\n"
> -              "\t\tavailable in the system\n"
> -              "\tExample usage:\n"
> -              "\t\t./odp_atomic -t 2\n"
> -              "\t\t./odp_atomic -t 3 -n 12\n");
> -}
> -
> -
> -void test_atomic_inc_u32(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < CNT; i++)
> -               odp_atomic_inc_u32(&a32u);
> -}
> -
> -void test_atomic_inc_64(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < CNT; i++)
> -               odp_atomic_inc_u64(&a64u);
> -}
> -
> -void test_atomic_dec_u32(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < CNT; i++)
> -               odp_atomic_dec_u32(&a32u);
> -}
> -
> -void test_atomic_dec_64(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < CNT; i++)
> -               odp_atomic_dec_u64(&a64u);
> -}
> -
> -void test_atomic_add_u32(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
> -}
> -
> -void test_atomic_add_64(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
> -}
> -
> -void test_atomic_sub_u32(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
> -}
> -
> -void test_atomic_sub_64(void)
> -{
> -       int i;
> -
> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
> -}
> -
> -void test_atomic_inc_dec_u32(void)
> -{
> -       test_atomic_inc_u32();
> -       test_atomic_dec_u32();
> -}
> -
> -void test_atomic_add_sub_u32(void)
> -{
> -       test_atomic_add_u32();
> -       test_atomic_sub_u32();
> -}
> -
> -void test_atomic_inc_dec_64(void)
> -{
> -       test_atomic_inc_64();
> -       test_atomic_dec_64();
> -}
> -
> -void test_atomic_add_sub_64(void)
> -{
> -       test_atomic_add_64();
> -       test_atomic_sub_64();
> -}
> -
> -/**
> - * Test basic atomic operation like
> - * add/sub/increment/decrement operation.
> - */
> -void test_atomic_basic(void)
> -{
> -       test_atomic_inc_u32();
> -       test_atomic_dec_u32();
> -       test_atomic_add_u32();
> -       test_atomic_sub_u32();
> -
> -       test_atomic_inc_64();
> -       test_atomic_dec_64();
> -       test_atomic_add_64();
> -       test_atomic_sub_64();
> -}
> -
> -void test_atomic_init(void)
> -{
> -       odp_atomic_init_u32(&a32u, 0);
> -       odp_atomic_init_u64(&a64u, 0);
> -}
> -
> -void test_atomic_store(void)
> -{
> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
> -}
> -
> -int test_atomic_validate(void)
> -{
> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
> -               LOG_ERR("Atomic u32 usual functions failed\n");
> -               return -1;
> -       }
> -
> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
> -               LOG_ERR("Atomic u64 usual functions failed\n");
> -               return -1;
> -       }
> -
> -       return 0;
> -}
> -
> -static void *run_thread(void *arg)
> -{
> -       pthrd_arg *parg = (pthrd_arg *)arg;
> -       int thr;
> -
> -       thr = odp_thread_id();
> -
> -       LOG_DBG("Thread %i starts\n", thr);
> -
> -       /* Wait here until all threads have arrived */
> -       /* Use multiple barriers to verify that it handles wrap around and
> -        * has no race conditions which could be exposed when invoked back-
> -        * to-back */
> -       odp_barrier_wait(&barrier);
> -       odp_barrier_wait(&barrier);
> -       odp_barrier_wait(&barrier);
> -       odp_barrier_wait(&barrier);
> -
> -       gettimeofday(&tv0[thr], NULL);
> -
> -       switch (parg->testcase) {
> -       case TEST_MIX:
> -               test_atomic_basic();
> -               break;
> -       case TEST_INC_DEC_U32:
> -               test_atomic_inc_dec_u32();
> -               break;
> -       case TEST_ADD_SUB_U32:
> -               test_atomic_add_sub_u32();
> -               break;
> -       case TEST_INC_DEC_64:
> -               test_atomic_inc_dec_64();
> -               break;
> -       case TEST_ADD_SUB_64:
> -               test_atomic_add_sub_64();
> -               break;
> -       }
> -       gettimeofday(&tv1[thr], NULL);
> -       fflush(NULL);
> -
> -       printf("Time taken in thread %02d to complete op is %lld usec\n",
> thr,
> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));
> -
> -       return parg;
> -}
> -
> -int main(int argc, char *argv[])
> -{
> -       pthrd_arg thrdarg;
> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
> -       char c;
> -       int result;
> -
> -       if (argc == 1 || argc % 2 == 0) {
> -               usage();
> -               goto err_exit;
> -       }
> -       if (odp_test_global_init() != 0)
> -               goto err_exit;
> -       odp_print_system_info();
> -
> -       while (cnt != 0) {
> -               sscanf(argv[++i], "-%c", &c);
> -               switch (c) {
> -               case 't':
> -                       sscanf(argv[++i], "%d", &test_type);
> -                       break;
> -               case 'n':
> -                       sscanf(argv[++i], "%d", &pthrdnum);
> -                       break;
> -               default:
> -                       LOG_ERR("Invalid option %c\n", c);
> -                       usage();
> -                       goto err_exit;
> -               }
> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||
> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
> -                       usage();
> -                       goto err_exit;
> -               }
> -               cnt -= 2;
> -       }
> -
> -       if (pthrdnum == 0)
> -               pthrdnum = odp_sys_core_count();
> -
> -       test_atomic_init();
> -       test_atomic_store();
> -
> -       memset(&thrdarg, 0, sizeof(pthrd_arg));
> -       thrdarg.testcase = test_type;
> -       thrdarg.numthrds = pthrdnum;
> -
> -       if ((test_type > 0) && (test_type < TEST_MAX)) {
> -               printf("%s\n", test_name[test_type]);
> -       } else {
> -               LOG_ERR("Invalid test case [%d]\n", test_type);
> -               usage();
> -               goto err_exit;
> -       }
> -       odp_barrier_init(&barrier, pthrdnum);
> -       odp_test_thread_create(run_thread, &thrdarg);
> -
> -       odp_test_thread_exit(&thrdarg);
> -
> -       result = test_atomic_validate();
> -
> -       if (result == 0) {
> -               printf("%s_%d_%d Result:pass\n",
> -                      test_name[test_type], test_type, pthrdnum);
> -       } else {
> -               printf("%s_%d_%d Result:fail\n",
> -                      test_name[test_type], test_type, pthrdnum);
> -       }
> -       return 0;
> -
> -err_exit:
> -       return -1;
> -}
> diff --git a/test/api_test/odp_atomic_test.h
> b/test/api_test/odp_atomic_test.h
> deleted file mode 100644
> index aaa9d34..0000000
> --- a/test/api_test/odp_atomic_test.h
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -/* Copyright (c) 2013, Linaro Limited
> - * All rights reserved.
> - *
> - * SPDX-License-Identifier:     BSD-3-Clause
> - */
> -
> -#ifndef ODP_ATOMIC_TEST_H_
> -#define ODP_ATOMIC_TEST_H_
> -
> -#include <odp.h>
> -#include <odph_linux.h>
> -
> -/**
> - * add_sub_cnt could be any valid value
> - * so to excercise explicit atomic_add/sub
> - * ops. For now using 5..
> - */
> -#define ADD_SUB_CNT    5
> -
> -#define        CNT 500000
> -#define        U32_INIT_VAL    (1UL << 10)
> -#define        U64_INIT_VAL    (1ULL << 33)
> -
> -typedef enum {
> -       TEST_MIX = 1, /* Must be first test case num */
> -       TEST_INC_DEC_U32,
> -       TEST_ADD_SUB_U32,
> -       TEST_INC_DEC_64,
> -       TEST_ADD_SUB_64,
> -       TEST_MAX,
> -} odp_test_atomic_t;
> -
> -
> -void test_atomic_inc_dec_u32(void);
> -void test_atomic_add_sub_u32(void);
> -void test_atomic_inc_dec_64(void);
> -void test_atomic_add_sub_64(void);
> -void test_atomic_inc_u32(void);
> -void test_atomic_dec_u32(void);
> -void test_atomic_add_u32(void);
> -void test_atomic_sub_u32(void);
> -void test_atomic_inc_64(void);
> -void test_atomic_dec_64(void);
> -void test_atomic_add_64(void);
> -void test_atomic_sub_64(void);
> -void test_atomic_init(void);
> -void test_atomic_basic(void);
> -void test_atomic_store(void);
> -int test_atomic_validate(void);
> -
> -#endif /* ODP_ATOMIC_TEST_H_ */
> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
> index 329d4d4..11afb1f 100644
> --- a/test/api_test/odp_common.c
> +++ b/test/api_test/odp_common.c
> @@ -14,7 +14,6 @@
>  #include <odp.h>
>  #include <odph_linux.h>
>  #include <odp_common.h>
> -#include <odp_atomic_test.h>
>  #include <odp_shm_test.h>
>  #include <test_debug.h>
>
> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> index 37e2594..22c867a 100644
> --- a/test/validation/.gitignore
> +++ b/test/validation/.gitignore
> @@ -4,3 +4,4 @@ odp_init
>  odp_queue
>  odp_crypto
>  odp_shm
> +odp_syne
> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> index 8547085..073e72b 100644
> --- a/test/validation/Makefile.am
> +++ b/test/validation/Makefile.am
> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static
>  if ODP_CUNIT_ENABLED
>  TESTS = ${bin_PROGRAMS}
>  check_PROGRAMS = ${bin_PROGRAMS}
> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
>  odp_init_LDFLAGS = $(AM_LDFLAGS)
>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
>  odp_shm_CFLAGS = $(AM_CFLAGS)
>  odp_shm_LDFLAGS = $(AM_LDFLAGS)
> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
> +odp_syne_LDFLAGS = $(AM_LDFLAGS)
>  endif
>
>  dist_odp_init_SOURCES = odp_init.c
> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =
> crypto/odp_crypto_test_async_inp.c \
>                           crypto/odp_crypto_test_rng.c \
>                           odp_crypto.c common/odp_cunit_common.c
>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
> +                     common/odp_cunit_common.c
> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
> new file mode 100644
> index 0000000..8e2d425
> --- /dev/null
> +++ b/test/validation/odp_syne.c
> @@ -0,0 +1,15 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include "odp.h"
>

This is from the system path

#include <odp.h>


> +#include "odp_cunit_common.h"
> +#include "odp_test_atomic.h"
> +
> +CU_SuiteInfo odp_testsuites[] = {
> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
> +       CU_SUITE_INFO_NULL,
> +};
> diff --git a/test/validation/syne/odp_test_atomic.c
> b/test/validation/syne/odp_test_atomic.c
> new file mode 100644
> index 0000000..68d23f4
> --- /dev/null
> +++ b/test/validation/syne/odp_test_atomic.c
> @@ -0,0 +1,258 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:     BSD-3-Clause
> + */
> +
> +#include <string.h>
> +#include "odp.h"
> +#include "odp_cunit_common.h"
> +
> +static odp_atomic_u32_t a32u;
> +static odp_atomic_u64_t a64u;
> +
> +
> +#define ADD_SUB_CNT    5
> +
> +#define        CNT 10
> +#define        U32_INIT_VAL    (1UL << 10)
> +#define        U64_INIT_VAL    (1ULL << 33)
> +
> +
> +static void test_atomic_inc_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_inc_u32(&a32u);
> +}
> +
> +static void test_atomic_inc_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_inc_u64(&a64u);
> +}
> +
> +static void test_atomic_dec_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_dec_u32(&a32u);
> +}
> +
> +static void test_atomic_dec_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_dec_u64(&a64u);
> +}
> +static void test_atomic_fetch_inc_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_inc_u32(&a32u);
> +}
> +
> +static void test_atomic_fetch_inc_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_inc_u64(&a64u);
> +}
> +
> +static void test_atomic_fetch_dec_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_dec_u32(&a32u);
> +}
> +
> +static void test_atomic_fetch_dec_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_dec_u64(&a64u);
> +}
> +
> +static void test_atomic_add_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
> +}
> +static void test_atomic_add_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_sub_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_sub_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_fetch_add_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_fetch_add_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
> +}
> +static void test_atomic_fetch_sub_u32(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_fetch_sub_64(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < CNT; i++)
> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
> +}
> +
> +static void test_atomic_inc_dec_u32(void)
> +{
> +       test_atomic_inc_u32();
> +       test_atomic_dec_u32();
> +}
> +
> +static void test_atomic_inc_dec_64(void)
> +{
> +       test_atomic_inc_64();
> +       test_atomic_dec_64();
> +}
> +
> +static void test_atomic_fetch_inc_dec_u32(void)
> +{
> +       test_atomic_fetch_inc_u32();
> +       test_atomic_fetch_dec_u32();
> +}
> +
> +static void test_atomic_fetch_inc_dec_64(void)
> +{
> +       test_atomic_fetch_inc_64();
> +       test_atomic_fetch_dec_64();
> +}
> +
> +
> +static void test_atomic_add_sub_u32(void)
> +{
> +       test_atomic_add_u32();
> +       test_atomic_sub_u32();
> +}
> +
> +
> +static void test_atomic_add_sub_64(void)
> +{
> +       test_atomic_add_64();
> +       test_atomic_sub_64();
> +}
> +
> +static void test_atomic_fetch_add_sub_u32(void)
> +{
> +       test_atomic_fetch_add_u32();
> +       test_atomic_fetch_sub_u32();
> +}
> +
> +static void test_atomic_fetch_add_sub_64(void)
> +{
> +       test_atomic_fetch_add_64();
> +       test_atomic_fetch_sub_64();
> +}
> +
> +static void test_atomic_init(void)
> +{
> +       odp_atomic_init_u32(&a32u, 0);
> +       odp_atomic_init_u64(&a64u, 0);
> +}
> +
> +static void test_atomic_store(void)
> +{
> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
> +}
> +
> +static void test_atomic_validate(void)
> +{
> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
> +}
> +static void test_atomic_basic(void)
> +{
> +       test_atomic_init();
> +       test_atomic_store();
> +       test_atomic_validate();
> +}
> +static void test_atomic_inc_dec(void)
> +{
> +       test_atomic_store();
> +       test_atomic_inc_dec_u32();
> +       test_atomic_inc_dec_64();
> +       test_atomic_validate();
> +}
> +
> +static void test_atomic_fetch_inc_dec(void)
> +{
> +       test_atomic_store();
> +       test_atomic_fetch_inc_dec_u32();
> +       test_atomic_fetch_inc_dec_64();
> +       test_atomic_validate();
> +}
> +
> +static void test_atomic_add_sub(void)
> +{
> +       test_atomic_store();
> +       test_atomic_add_sub_u32();
> +       test_atomic_add_sub_64();
> +       test_atomic_validate();
> +}
> +static void test_atomic_fetch_add_sub(void)
> +{
> +       test_atomic_store();
> +       test_atomic_fetch_add_sub_u32();
> +       test_atomic_fetch_add_sub_64();
> +       test_atomic_validate();
> +}
> +
> +CU_TestInfo test_odp_atomic[] = {
> +       {"test_odp_atomic_basic",    test_atomic_basic},
> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},
> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
> +       CU_TEST_INFO_NULL,
> +};
> diff --git a/test/validation/syne/odp_test_atomic.h
> b/test/validation/syne/odp_test_atomic.h
> new file mode 100644
> index 0000000..a51a26a
> --- /dev/null
> +++ b/test/validation/syne/odp_test_atomic.h
> @@ -0,0 +1,14 @@
> +/* Copyright (c) 2014, Linaro Limited
> + * All rights reserved.
> + *
> + * SPDX-License-Identifier:    BSD-3-Clause
> + */
> +#ifndef ODP_TEST_ATOMIC_
> +#define ODP_TEST_ATOMIC_
> +
> +#include "CUnit/TestDB.h"
> +
> +/* Suite test array */
> +extern CU_TestInfo test_odp_atomic[];
> +
> +#endif
> --
> 1.8.3.1
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Dec. 10, 2014, 10:31 p.m. UTC | #2
On 12/10/2014 10:42 PM, Mike Holmes wrote:
> +#include "CUnit/TestDB.h"
<CUnit/TestDB.h>
Ola Liljedahl Dec. 11, 2014, 9:36 a.m. UTC | #3
Are these cunit tests for odp_atomic.h only?
Are there any cunit tests for plain spin locks, ticket locks, rwlocks etc?

-- Ola


On 10 December 2014 at 20:42, Mike Holmes <mike.holmes@linaro.org> wrote:
> I think odp_syne would be better as odp_sync  throughout the patch
>
> Does Barrys patch cover atomics in an overlapping way, or do we have both as
> separate suites ? I think this one is much more sunny day as we had
> originally planned.
> Mario were you able to make the final changes to create a patch for tip from
> Barrys files, do we need to wait until we can see that patch along side this
> one ?
>
> Mike
>
>
> On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org> wrote:
>>
>> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
>> to test/validation as one part of odp syncronizers test
>
>
> syncronizers
>
>>
>>
>> Signed-off-by: Yan Songming <yan.songming@linaro.org>
>> ---
>>  test/api_test/Makefile.am              |   5 +-
>>  test/api_test/odp_atomic_test.c        | 299
>> ---------------------------------
>>  test/api_test/odp_atomic_test.h        |  51 ------
>>  test/api_test/odp_common.c             |   1 -
>>  test/validation/.gitignore             |   1 +
>>  test/validation/Makefile.am            |   6 +-
>>  test/validation/odp_syne.c             |  15 ++
>>  test/validation/syne/odp_test_atomic.c | 258 ++++++++++++++++++++++++++++
>>  test/validation/syne/odp_test_atomic.h |  14 ++
>>  9 files changed, 294 insertions(+), 356 deletions(-)
>>  delete mode 100644 test/api_test/odp_atomic_test.c
>>  delete mode 100644 test/api_test/odp_atomic_test.h
>>  create mode 100644 test/validation/odp_syne.c
>>  create mode 100644 test/validation/syne/odp_test_atomic.c
>>  create mode 100644 test/validation/syne/odp_test_atomic.h
>>
>> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
>> index 74e8612..ce301ce 100644
>> --- a/test/api_test/Makefile.am
>> +++ b/test/api_test/Makefile.am
>> @@ -1,18 +1,15 @@
>>  include $(top_srcdir)/test/Makefile.inc
>>
>> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
>> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
>>
>> -odp_atomic_CFLAGS = $(AM_CFLAGS)
>>  odp_shm_CFLAGS = $(AM_CFLAGS)
>>  odp_ring_CFLAGS = $(AM_CFLAGS)
>>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)
>>
>> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
>>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
>>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
>>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
>>
>> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
>>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
>>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
>>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
>> diff --git a/test/api_test/odp_atomic_test.c
>> b/test/api_test/odp_atomic_test.c
>> deleted file mode 100644
>> index 5563606..0000000
>> --- a/test/api_test/odp_atomic_test.c
>> +++ /dev/null
>> @@ -1,299 +0,0 @@
>> -/* Copyright (c) 2013, Linaro Limited
>> - * All rights reserved.
>> - *
>> - * SPDX-License-Identifier:     BSD-3-Clause
>> - */
>> -
>> -#include <string.h>
>> -#include <sys/time.h>
>> -#include <odp_common.h>
>> -#include <odp_atomic_test.h>
>> -#include <test_debug.h>
>> -
>> -static odp_atomic_u32_t a32u;
>> -static odp_atomic_u64_t a64u;
>> -
>> -static odp_barrier_t barrier;
>> -
>> -static const char * const test_name[] = {
>> -       "dummy",
>> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic ints",
>> -       "test atomic inc/dec of 32-bit atomic int",
>> -       "test atomic add/sub of 32-bit atomic int",
>> -       "test atomic inc/dec of 64-bit atomic int",
>> -       "test atomic add/sub of 64-bit atomic int"
>> -};
>> -
>> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
>> -
>> -static void usage(void)
>> -{
>> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
>> -              "\t<testcase> is\n"
>> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
>> ints)\n"
>> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"
>> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"
>> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"
>> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"
>> -              "\t\t-n <1 - 31> - no of threads to start\n"
>> -              "\t\tif user doesn't specify this option, then\n"
>> -              "\t\tno of threads created is equivalent to no of cores\n"
>> -              "\t\tavailable in the system\n"
>> -              "\tExample usage:\n"
>> -              "\t\t./odp_atomic -t 2\n"
>> -              "\t\t./odp_atomic -t 3 -n 12\n");
>> -}
>> -
>> -
>> -void test_atomic_inc_u32(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < CNT; i++)
>> -               odp_atomic_inc_u32(&a32u);
>> -}
>> -
>> -void test_atomic_inc_64(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < CNT; i++)
>> -               odp_atomic_inc_u64(&a64u);
>> -}
>> -
>> -void test_atomic_dec_u32(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < CNT; i++)
>> -               odp_atomic_dec_u32(&a32u);
>> -}
>> -
>> -void test_atomic_dec_64(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < CNT; i++)
>> -               odp_atomic_dec_u64(&a64u);
>> -}
>> -
>> -void test_atomic_add_u32(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>> -}
>> -
>> -void test_atomic_add_64(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>> -}
>> -
>> -void test_atomic_sub_u32(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>> -}
>> -
>> -void test_atomic_sub_64(void)
>> -{
>> -       int i;
>> -
>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>> -}
>> -
>> -void test_atomic_inc_dec_u32(void)
>> -{
>> -       test_atomic_inc_u32();
>> -       test_atomic_dec_u32();
>> -}
>> -
>> -void test_atomic_add_sub_u32(void)
>> -{
>> -       test_atomic_add_u32();
>> -       test_atomic_sub_u32();
>> -}
>> -
>> -void test_atomic_inc_dec_64(void)
>> -{
>> -       test_atomic_inc_64();
>> -       test_atomic_dec_64();
>> -}
>> -
>> -void test_atomic_add_sub_64(void)
>> -{
>> -       test_atomic_add_64();
>> -       test_atomic_sub_64();
>> -}
>> -
>> -/**
>> - * Test basic atomic operation like
>> - * add/sub/increment/decrement operation.
>> - */
>> -void test_atomic_basic(void)
>> -{
>> -       test_atomic_inc_u32();
>> -       test_atomic_dec_u32();
>> -       test_atomic_add_u32();
>> -       test_atomic_sub_u32();
>> -
>> -       test_atomic_inc_64();
>> -       test_atomic_dec_64();
>> -       test_atomic_add_64();
>> -       test_atomic_sub_64();
>> -}
>> -
>> -void test_atomic_init(void)
>> -{
>> -       odp_atomic_init_u32(&a32u, 0);
>> -       odp_atomic_init_u64(&a64u, 0);
>> -}
>> -
>> -void test_atomic_store(void)
>> -{
>> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>> -}
>> -
>> -int test_atomic_validate(void)
>> -{
>> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
>> -               LOG_ERR("Atomic u32 usual functions failed\n");
>> -               return -1;
>> -       }
>> -
>> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
>> -               LOG_ERR("Atomic u64 usual functions failed\n");
>> -               return -1;
>> -       }
>> -
>> -       return 0;
>> -}
>> -
>> -static void *run_thread(void *arg)
>> -{
>> -       pthrd_arg *parg = (pthrd_arg *)arg;
>> -       int thr;
>> -
>> -       thr = odp_thread_id();
>> -
>> -       LOG_DBG("Thread %i starts\n", thr);
>> -
>> -       /* Wait here until all threads have arrived */
>> -       /* Use multiple barriers to verify that it handles wrap around and
>> -        * has no race conditions which could be exposed when invoked
>> back-
>> -        * to-back */
>> -       odp_barrier_wait(&barrier);
>> -       odp_barrier_wait(&barrier);
>> -       odp_barrier_wait(&barrier);
>> -       odp_barrier_wait(&barrier);
>> -
>> -       gettimeofday(&tv0[thr], NULL);
>> -
>> -       switch (parg->testcase) {
>> -       case TEST_MIX:
>> -               test_atomic_basic();
>> -               break;
>> -       case TEST_INC_DEC_U32:
>> -               test_atomic_inc_dec_u32();
>> -               break;
>> -       case TEST_ADD_SUB_U32:
>> -               test_atomic_add_sub_u32();
>> -               break;
>> -       case TEST_INC_DEC_64:
>> -               test_atomic_inc_dec_64();
>> -               break;
>> -       case TEST_ADD_SUB_64:
>> -               test_atomic_add_sub_64();
>> -               break;
>> -       }
>> -       gettimeofday(&tv1[thr], NULL);
>> -       fflush(NULL);
>> -
>> -       printf("Time taken in thread %02d to complete op is %lld usec\n",
>> thr,
>> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
>> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));
>> -
>> -       return parg;
>> -}
>> -
>> -int main(int argc, char *argv[])
>> -{
>> -       pthrd_arg thrdarg;
>> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
>> -       char c;
>> -       int result;
>> -
>> -       if (argc == 1 || argc % 2 == 0) {
>> -               usage();
>> -               goto err_exit;
>> -       }
>> -       if (odp_test_global_init() != 0)
>> -               goto err_exit;
>> -       odp_print_system_info();
>> -
>> -       while (cnt != 0) {
>> -               sscanf(argv[++i], "-%c", &c);
>> -               switch (c) {
>> -               case 't':
>> -                       sscanf(argv[++i], "%d", &test_type);
>> -                       break;
>> -               case 'n':
>> -                       sscanf(argv[++i], "%d", &pthrdnum);
>> -                       break;
>> -               default:
>> -                       LOG_ERR("Invalid option %c\n", c);
>> -                       usage();
>> -                       goto err_exit;
>> -               }
>> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||
>> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
>> -                       usage();
>> -                       goto err_exit;
>> -               }
>> -               cnt -= 2;
>> -       }
>> -
>> -       if (pthrdnum == 0)
>> -               pthrdnum = odp_sys_core_count();
>> -
>> -       test_atomic_init();
>> -       test_atomic_store();
>> -
>> -       memset(&thrdarg, 0, sizeof(pthrd_arg));
>> -       thrdarg.testcase = test_type;
>> -       thrdarg.numthrds = pthrdnum;
>> -
>> -       if ((test_type > 0) && (test_type < TEST_MAX)) {
>> -               printf("%s\n", test_name[test_type]);
>> -       } else {
>> -               LOG_ERR("Invalid test case [%d]\n", test_type);
>> -               usage();
>> -               goto err_exit;
>> -       }
>> -       odp_barrier_init(&barrier, pthrdnum);
>> -       odp_test_thread_create(run_thread, &thrdarg);
>> -
>> -       odp_test_thread_exit(&thrdarg);
>> -
>> -       result = test_atomic_validate();
>> -
>> -       if (result == 0) {
>> -               printf("%s_%d_%d Result:pass\n",
>> -                      test_name[test_type], test_type, pthrdnum);
>> -       } else {
>> -               printf("%s_%d_%d Result:fail\n",
>> -                      test_name[test_type], test_type, pthrdnum);
>> -       }
>> -       return 0;
>> -
>> -err_exit:
>> -       return -1;
>> -}
>> diff --git a/test/api_test/odp_atomic_test.h
>> b/test/api_test/odp_atomic_test.h
>> deleted file mode 100644
>> index aaa9d34..0000000
>> --- a/test/api_test/odp_atomic_test.h
>> +++ /dev/null
>> @@ -1,51 +0,0 @@
>> -/* Copyright (c) 2013, Linaro Limited
>> - * All rights reserved.
>> - *
>> - * SPDX-License-Identifier:     BSD-3-Clause
>> - */
>> -
>> -#ifndef ODP_ATOMIC_TEST_H_
>> -#define ODP_ATOMIC_TEST_H_
>> -
>> -#include <odp.h>
>> -#include <odph_linux.h>
>> -
>> -/**
>> - * add_sub_cnt could be any valid value
>> - * so to excercise explicit atomic_add/sub
>> - * ops. For now using 5..
>> - */
>> -#define ADD_SUB_CNT    5
>> -
>> -#define        CNT 500000
>> -#define        U32_INIT_VAL    (1UL << 10)
>> -#define        U64_INIT_VAL    (1ULL << 33)
>> -
>> -typedef enum {
>> -       TEST_MIX = 1, /* Must be first test case num */
>> -       TEST_INC_DEC_U32,
>> -       TEST_ADD_SUB_U32,
>> -       TEST_INC_DEC_64,
>> -       TEST_ADD_SUB_64,
>> -       TEST_MAX,
>> -} odp_test_atomic_t;
>> -
>> -
>> -void test_atomic_inc_dec_u32(void);
>> -void test_atomic_add_sub_u32(void);
>> -void test_atomic_inc_dec_64(void);
>> -void test_atomic_add_sub_64(void);
>> -void test_atomic_inc_u32(void);
>> -void test_atomic_dec_u32(void);
>> -void test_atomic_add_u32(void);
>> -void test_atomic_sub_u32(void);
>> -void test_atomic_inc_64(void);
>> -void test_atomic_dec_64(void);
>> -void test_atomic_add_64(void);
>> -void test_atomic_sub_64(void);
>> -void test_atomic_init(void);
>> -void test_atomic_basic(void);
>> -void test_atomic_store(void);
>> -int test_atomic_validate(void);
>> -
>> -#endif /* ODP_ATOMIC_TEST_H_ */
>> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
>> index 329d4d4..11afb1f 100644
>> --- a/test/api_test/odp_common.c
>> +++ b/test/api_test/odp_common.c
>> @@ -14,7 +14,6 @@
>>  #include <odp.h>
>>  #include <odph_linux.h>
>>  #include <odp_common.h>
>> -#include <odp_atomic_test.h>
>>  #include <odp_shm_test.h>
>>  #include <test_debug.h>
>>
>> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
>> index 37e2594..22c867a 100644
>> --- a/test/validation/.gitignore
>> +++ b/test/validation/.gitignore
>> @@ -4,3 +4,4 @@ odp_init
>>  odp_queue
>>  odp_crypto
>>  odp_shm
>> +odp_syne
>> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
>> index 8547085..073e72b 100644
>> --- a/test/validation/Makefile.am
>> +++ b/test/validation/Makefile.am
>> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static
>>  if ODP_CUNIT_ENABLED
>>  TESTS = ${bin_PROGRAMS}
>>  check_PROGRAMS = ${bin_PROGRAMS}
>> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
>> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
>>  odp_init_LDFLAGS = $(AM_LDFLAGS)
>>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
>>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
>>  odp_shm_CFLAGS = $(AM_CFLAGS)
>>  odp_shm_LDFLAGS = $(AM_LDFLAGS)
>> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
>> +odp_syne_LDFLAGS = $(AM_LDFLAGS)
>>  endif
>>
>>  dist_odp_init_SOURCES = odp_init.c
>> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =
>> crypto/odp_crypto_test_async_inp.c \
>>                           crypto/odp_crypto_test_rng.c \
>>                           odp_crypto.c common/odp_cunit_common.c
>>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
>> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
>> +                     common/odp_cunit_common.c
>> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
>> new file mode 100644
>> index 0000000..8e2d425
>> --- /dev/null
>> +++ b/test/validation/odp_syne.c
>> @@ -0,0 +1,15 @@
>> +/* Copyright (c) 2014, Linaro Limited
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier:     BSD-3-Clause
>> + */
>> +
>> +#include "odp.h"
>
>
> This is from the system path
>
> #include <odp.h>
>
>>
>> +#include "odp_cunit_common.h"
>> +#include "odp_test_atomic.h"
>> +
>> +CU_SuiteInfo odp_testsuites[] = {
>> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
>> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
>> +       CU_SUITE_INFO_NULL,
>> +};
>> diff --git a/test/validation/syne/odp_test_atomic.c
>> b/test/validation/syne/odp_test_atomic.c
>> new file mode 100644
>> index 0000000..68d23f4
>> --- /dev/null
>> +++ b/test/validation/syne/odp_test_atomic.c
>> @@ -0,0 +1,258 @@
>> +/* Copyright (c) 2014, Linaro Limited
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier:     BSD-3-Clause
>> + */
>> +
>> +#include <string.h>
>> +#include "odp.h"
>> +#include "odp_cunit_common.h"
>> +
>> +static odp_atomic_u32_t a32u;
>> +static odp_atomic_u64_t a64u;
>> +
>> +
>> +#define ADD_SUB_CNT    5
>> +
>> +#define        CNT 10
>> +#define        U32_INIT_VAL    (1UL << 10)
>> +#define        U64_INIT_VAL    (1ULL << 33)
>> +
>> +
>> +static void test_atomic_inc_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_inc_u32(&a32u);
>> +}
>> +
>> +static void test_atomic_inc_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_inc_u64(&a64u);
>> +}
>> +
>> +static void test_atomic_dec_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_dec_u32(&a32u);
>> +}
>> +
>> +static void test_atomic_dec_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_dec_u64(&a64u);
>> +}
>> +static void test_atomic_fetch_inc_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_inc_u32(&a32u);
>> +}
>> +
>> +static void test_atomic_fetch_inc_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_inc_u64(&a64u);
>> +}
>> +
>> +static void test_atomic_fetch_dec_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_dec_u32(&a32u);
>> +}
>> +
>> +static void test_atomic_fetch_dec_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_dec_u64(&a64u);
>> +}
>> +
>> +static void test_atomic_add_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
>> +}
>> +static void test_atomic_add_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_sub_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_sub_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_fetch_add_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_fetch_add_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>> +}
>> +static void test_atomic_fetch_sub_u32(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_fetch_sub_64(void)
>> +{
>> +       int i;
>> +
>> +       for (i = 0; i < CNT; i++)
>> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>> +}
>> +
>> +static void test_atomic_inc_dec_u32(void)
>> +{
>> +       test_atomic_inc_u32();
>> +       test_atomic_dec_u32();
>> +}
>> +
>> +static void test_atomic_inc_dec_64(void)
>> +{
>> +       test_atomic_inc_64();
>> +       test_atomic_dec_64();
>> +}
>> +
>> +static void test_atomic_fetch_inc_dec_u32(void)
>> +{
>> +       test_atomic_fetch_inc_u32();
>> +       test_atomic_fetch_dec_u32();
>> +}
>> +
>> +static void test_atomic_fetch_inc_dec_64(void)
>> +{
>> +       test_atomic_fetch_inc_64();
>> +       test_atomic_fetch_dec_64();
>> +}
>> +
>> +
>> +static void test_atomic_add_sub_u32(void)
>> +{
>> +       test_atomic_add_u32();
>> +       test_atomic_sub_u32();
>> +}
>> +
>> +
>> +static void test_atomic_add_sub_64(void)
>> +{
>> +       test_atomic_add_64();
>> +       test_atomic_sub_64();
>> +}
>> +
>> +static void test_atomic_fetch_add_sub_u32(void)
>> +{
>> +       test_atomic_fetch_add_u32();
>> +       test_atomic_fetch_sub_u32();
>> +}
>> +
>> +static void test_atomic_fetch_add_sub_64(void)
>> +{
>> +       test_atomic_fetch_add_64();
>> +       test_atomic_fetch_sub_64();
>> +}
>> +
>> +static void test_atomic_init(void)
>> +{
>> +       odp_atomic_init_u32(&a32u, 0);
>> +       odp_atomic_init_u64(&a64u, 0);
>> +}
>> +
>> +static void test_atomic_store(void)
>> +{
>> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>> +}
>> +
>> +static void test_atomic_validate(void)
>> +{
>> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
>> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
>> +}
>> +static void test_atomic_basic(void)
>> +{
>> +       test_atomic_init();
>> +       test_atomic_store();
>> +       test_atomic_validate();
>> +}
>> +static void test_atomic_inc_dec(void)
>> +{
>> +       test_atomic_store();
>> +       test_atomic_inc_dec_u32();
>> +       test_atomic_inc_dec_64();
>> +       test_atomic_validate();
>> +}
>> +
>> +static void test_atomic_fetch_inc_dec(void)
>> +{
>> +       test_atomic_store();
>> +       test_atomic_fetch_inc_dec_u32();
>> +       test_atomic_fetch_inc_dec_64();
>> +       test_atomic_validate();
>> +}
>> +
>> +static void test_atomic_add_sub(void)
>> +{
>> +       test_atomic_store();
>> +       test_atomic_add_sub_u32();
>> +       test_atomic_add_sub_64();
>> +       test_atomic_validate();
>> +}
>> +static void test_atomic_fetch_add_sub(void)
>> +{
>> +       test_atomic_store();
>> +       test_atomic_fetch_add_sub_u32();
>> +       test_atomic_fetch_add_sub_64();
>> +       test_atomic_validate();
>> +}
>> +
>> +CU_TestInfo test_odp_atomic[] = {
>> +       {"test_odp_atomic_basic",    test_atomic_basic},
>> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
>> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},
>> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
>> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
>> +       CU_TEST_INFO_NULL,
>> +};
>> diff --git a/test/validation/syne/odp_test_atomic.h
>> b/test/validation/syne/odp_test_atomic.h
>> new file mode 100644
>> index 0000000..a51a26a
>> --- /dev/null
>> +++ b/test/validation/syne/odp_test_atomic.h
>> @@ -0,0 +1,14 @@
>> +/* Copyright (c) 2014, Linaro Limited
>> + * All rights reserved.
>> + *
>> + * SPDX-License-Identifier:    BSD-3-Clause
>> + */
>> +#ifndef ODP_TEST_ATOMIC_
>> +#define ODP_TEST_ATOMIC_
>> +
>> +#include "CUnit/TestDB.h"
>> +
>> +/* Suite test array */
>> +extern CU_TestInfo test_odp_atomic[];
>> +
>> +#endif
>> --
>> 1.8.3.1
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> --
> Mike Holmes
> Linaro  Sr Technical Manager
> LNG - ODP
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Mike Holmes Dec. 11, 2014, 7:09 p.m. UTC | #4
On 11 December 2014 at 04:36, Ola Liljedahl <ola.liljedahl@linaro.org>
wrote:

> Are these cunit tests for odp_atomic.h only?
> Are there any cunit tests for plain spin locks, ticket locks, rwlocks etc?
>

Yes, Mario has Barrys code as the basis.


>
> -- Ola
>
>
> On 10 December 2014 at 20:42, Mike Holmes <mike.holmes@linaro.org> wrote:
> > I think odp_syne would be better as odp_sync  throughout the patch
> >
> > Does Barrys patch cover atomics in an overlapping way, or do we have
> both as
> > separate suites ? I think this one is much more sunny day as we had
> > originally planned.
> > Mario were you able to make the final changes to create a patch for tip
> from
> > Barrys files, do we need to wait until we can see that patch along side
> this
> > one ?
> >
> > Mike
> >
> >
> > On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org>
> wrote:
> >>
> >> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
> >> to test/validation as one part of odp syncronizers test
> >
> >
> > syncronizers
> >
> >>
> >>
> >> Signed-off-by: Yan Songming <yan.songming@linaro.org>
> >> ---
> >>  test/api_test/Makefile.am              |   5 +-
> >>  test/api_test/odp_atomic_test.c        | 299
> >> ---------------------------------
> >>  test/api_test/odp_atomic_test.h        |  51 ------
> >>  test/api_test/odp_common.c             |   1 -
> >>  test/validation/.gitignore             |   1 +
> >>  test/validation/Makefile.am            |   6 +-
> >>  test/validation/odp_syne.c             |  15 ++
> >>  test/validation/syne/odp_test_atomic.c | 258
> ++++++++++++++++++++++++++++
> >>  test/validation/syne/odp_test_atomic.h |  14 ++
> >>  9 files changed, 294 insertions(+), 356 deletions(-)
> >>  delete mode 100644 test/api_test/odp_atomic_test.c
> >>  delete mode 100644 test/api_test/odp_atomic_test.h
> >>  create mode 100644 test/validation/odp_syne.c
> >>  create mode 100644 test/validation/syne/odp_test_atomic.c
> >>  create mode 100644 test/validation/syne/odp_test_atomic.h
> >>
> >> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
> >> index 74e8612..ce301ce 100644
> >> --- a/test/api_test/Makefile.am
> >> +++ b/test/api_test/Makefile.am
> >> @@ -1,18 +1,15 @@
> >>  include $(top_srcdir)/test/Makefile.inc
> >>
> >> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
> >> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
> >>
> >> -odp_atomic_CFLAGS = $(AM_CFLAGS)
> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
> >>  odp_ring_CFLAGS = $(AM_CFLAGS)
> >>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)
> >>
> >> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
> >>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
> >>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
> >>
> >> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
> >>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
> >>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
> >>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
> >> diff --git a/test/api_test/odp_atomic_test.c
> >> b/test/api_test/odp_atomic_test.c
> >> deleted file mode 100644
> >> index 5563606..0000000
> >> --- a/test/api_test/odp_atomic_test.c
> >> +++ /dev/null
> >> @@ -1,299 +0,0 @@
> >> -/* Copyright (c) 2013, Linaro Limited
> >> - * All rights reserved.
> >> - *
> >> - * SPDX-License-Identifier:     BSD-3-Clause
> >> - */
> >> -
> >> -#include <string.h>
> >> -#include <sys/time.h>
> >> -#include <odp_common.h>
> >> -#include <odp_atomic_test.h>
> >> -#include <test_debug.h>
> >> -
> >> -static odp_atomic_u32_t a32u;
> >> -static odp_atomic_u64_t a64u;
> >> -
> >> -static odp_barrier_t barrier;
> >> -
> >> -static const char * const test_name[] = {
> >> -       "dummy",
> >> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic
> ints",
> >> -       "test atomic inc/dec of 32-bit atomic int",
> >> -       "test atomic add/sub of 32-bit atomic int",
> >> -       "test atomic inc/dec of 64-bit atomic int",
> >> -       "test atomic add/sub of 64-bit atomic int"
> >> -};
> >> -
> >> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
> >> -
> >> -static void usage(void)
> >> -{
> >> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
> >> -              "\t<testcase> is\n"
> >> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
> >> ints)\n"
> >> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"
> >> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"
> >> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"
> >> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"
> >> -              "\t\t-n <1 - 31> - no of threads to start\n"
> >> -              "\t\tif user doesn't specify this option, then\n"
> >> -              "\t\tno of threads created is equivalent to no of
> cores\n"
> >> -              "\t\tavailable in the system\n"
> >> -              "\tExample usage:\n"
> >> -              "\t\t./odp_atomic -t 2\n"
> >> -              "\t\t./odp_atomic -t 3 -n 12\n");
> >> -}
> >> -
> >> -
> >> -void test_atomic_inc_u32(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < CNT; i++)
> >> -               odp_atomic_inc_u32(&a32u);
> >> -}
> >> -
> >> -void test_atomic_inc_64(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < CNT; i++)
> >> -               odp_atomic_inc_u64(&a64u);
> >> -}
> >> -
> >> -void test_atomic_dec_u32(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < CNT; i++)
> >> -               odp_atomic_dec_u32(&a32u);
> >> -}
> >> -
> >> -void test_atomic_dec_64(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < CNT; i++)
> >> -               odp_atomic_dec_u64(&a64u);
> >> -}
> >> -
> >> -void test_atomic_add_u32(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> >> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
> >> -}
> >> -
> >> -void test_atomic_add_64(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> >> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
> >> -}
> >> -
> >> -void test_atomic_sub_u32(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> >> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
> >> -}
> >> -
> >> -void test_atomic_sub_64(void)
> >> -{
> >> -       int i;
> >> -
> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
> >> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
> >> -}
> >> -
> >> -void test_atomic_inc_dec_u32(void)
> >> -{
> >> -       test_atomic_inc_u32();
> >> -       test_atomic_dec_u32();
> >> -}
> >> -
> >> -void test_atomic_add_sub_u32(void)
> >> -{
> >> -       test_atomic_add_u32();
> >> -       test_atomic_sub_u32();
> >> -}
> >> -
> >> -void test_atomic_inc_dec_64(void)
> >> -{
> >> -       test_atomic_inc_64();
> >> -       test_atomic_dec_64();
> >> -}
> >> -
> >> -void test_atomic_add_sub_64(void)
> >> -{
> >> -       test_atomic_add_64();
> >> -       test_atomic_sub_64();
> >> -}
> >> -
> >> -/**
> >> - * Test basic atomic operation like
> >> - * add/sub/increment/decrement operation.
> >> - */
> >> -void test_atomic_basic(void)
> >> -{
> >> -       test_atomic_inc_u32();
> >> -       test_atomic_dec_u32();
> >> -       test_atomic_add_u32();
> >> -       test_atomic_sub_u32();
> >> -
> >> -       test_atomic_inc_64();
> >> -       test_atomic_dec_64();
> >> -       test_atomic_add_64();
> >> -       test_atomic_sub_64();
> >> -}
> >> -
> >> -void test_atomic_init(void)
> >> -{
> >> -       odp_atomic_init_u32(&a32u, 0);
> >> -       odp_atomic_init_u64(&a64u, 0);
> >> -}
> >> -
> >> -void test_atomic_store(void)
> >> -{
> >> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
> >> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
> >> -}
> >> -
> >> -int test_atomic_validate(void)
> >> -{
> >> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
> >> -               LOG_ERR("Atomic u32 usual functions failed\n");
> >> -               return -1;
> >> -       }
> >> -
> >> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
> >> -               LOG_ERR("Atomic u64 usual functions failed\n");
> >> -               return -1;
> >> -       }
> >> -
> >> -       return 0;
> >> -}
> >> -
> >> -static void *run_thread(void *arg)
> >> -{
> >> -       pthrd_arg *parg = (pthrd_arg *)arg;
> >> -       int thr;
> >> -
> >> -       thr = odp_thread_id();
> >> -
> >> -       LOG_DBG("Thread %i starts\n", thr);
> >> -
> >> -       /* Wait here until all threads have arrived */
> >> -       /* Use multiple barriers to verify that it handles wrap around
> and
> >> -        * has no race conditions which could be exposed when invoked
> >> back-
> >> -        * to-back */
> >> -       odp_barrier_wait(&barrier);
> >> -       odp_barrier_wait(&barrier);
> >> -       odp_barrier_wait(&barrier);
> >> -       odp_barrier_wait(&barrier);
> >> -
> >> -       gettimeofday(&tv0[thr], NULL);
> >> -
> >> -       switch (parg->testcase) {
> >> -       case TEST_MIX:
> >> -               test_atomic_basic();
> >> -               break;
> >> -       case TEST_INC_DEC_U32:
> >> -               test_atomic_inc_dec_u32();
> >> -               break;
> >> -       case TEST_ADD_SUB_U32:
> >> -               test_atomic_add_sub_u32();
> >> -               break;
> >> -       case TEST_INC_DEC_64:
> >> -               test_atomic_inc_dec_64();
> >> -               break;
> >> -       case TEST_ADD_SUB_64:
> >> -               test_atomic_add_sub_64();
> >> -               break;
> >> -       }
> >> -       gettimeofday(&tv1[thr], NULL);
> >> -       fflush(NULL);
> >> -
> >> -       printf("Time taken in thread %02d to complete op is %lld
> usec\n",
> >> thr,
> >> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
> >> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));
> >> -
> >> -       return parg;
> >> -}
> >> -
> >> -int main(int argc, char *argv[])
> >> -{
> >> -       pthrd_arg thrdarg;
> >> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
> >> -       char c;
> >> -       int result;
> >> -
> >> -       if (argc == 1 || argc % 2 == 0) {
> >> -               usage();
> >> -               goto err_exit;
> >> -       }
> >> -       if (odp_test_global_init() != 0)
> >> -               goto err_exit;
> >> -       odp_print_system_info();
> >> -
> >> -       while (cnt != 0) {
> >> -               sscanf(argv[++i], "-%c", &c);
> >> -               switch (c) {
> >> -               case 't':
> >> -                       sscanf(argv[++i], "%d", &test_type);
> >> -                       break;
> >> -               case 'n':
> >> -                       sscanf(argv[++i], "%d", &pthrdnum);
> >> -                       break;
> >> -               default:
> >> -                       LOG_ERR("Invalid option %c\n", c);
> >> -                       usage();
> >> -                       goto err_exit;
> >> -               }
> >> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||
> >> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
> >> -                       usage();
> >> -                       goto err_exit;
> >> -               }
> >> -               cnt -= 2;
> >> -       }
> >> -
> >> -       if (pthrdnum == 0)
> >> -               pthrdnum = odp_sys_core_count();
> >> -
> >> -       test_atomic_init();
> >> -       test_atomic_store();
> >> -
> >> -       memset(&thrdarg, 0, sizeof(pthrd_arg));
> >> -       thrdarg.testcase = test_type;
> >> -       thrdarg.numthrds = pthrdnum;
> >> -
> >> -       if ((test_type > 0) && (test_type < TEST_MAX)) {
> >> -               printf("%s\n", test_name[test_type]);
> >> -       } else {
> >> -               LOG_ERR("Invalid test case [%d]\n", test_type);
> >> -               usage();
> >> -               goto err_exit;
> >> -       }
> >> -       odp_barrier_init(&barrier, pthrdnum);
> >> -       odp_test_thread_create(run_thread, &thrdarg);
> >> -
> >> -       odp_test_thread_exit(&thrdarg);
> >> -
> >> -       result = test_atomic_validate();
> >> -
> >> -       if (result == 0) {
> >> -               printf("%s_%d_%d Result:pass\n",
> >> -                      test_name[test_type], test_type, pthrdnum);
> >> -       } else {
> >> -               printf("%s_%d_%d Result:fail\n",
> >> -                      test_name[test_type], test_type, pthrdnum);
> >> -       }
> >> -       return 0;
> >> -
> >> -err_exit:
> >> -       return -1;
> >> -}
> >> diff --git a/test/api_test/odp_atomic_test.h
> >> b/test/api_test/odp_atomic_test.h
> >> deleted file mode 100644
> >> index aaa9d34..0000000
> >> --- a/test/api_test/odp_atomic_test.h
> >> +++ /dev/null
> >> @@ -1,51 +0,0 @@
> >> -/* Copyright (c) 2013, Linaro Limited
> >> - * All rights reserved.
> >> - *
> >> - * SPDX-License-Identifier:     BSD-3-Clause
> >> - */
> >> -
> >> -#ifndef ODP_ATOMIC_TEST_H_
> >> -#define ODP_ATOMIC_TEST_H_
> >> -
> >> -#include <odp.h>
> >> -#include <odph_linux.h>
> >> -
> >> -/**
> >> - * add_sub_cnt could be any valid value
> >> - * so to excercise explicit atomic_add/sub
> >> - * ops. For now using 5..
> >> - */
> >> -#define ADD_SUB_CNT    5
> >> -
> >> -#define        CNT 500000
> >> -#define        U32_INIT_VAL    (1UL << 10)
> >> -#define        U64_INIT_VAL    (1ULL << 33)
> >> -
> >> -typedef enum {
> >> -       TEST_MIX = 1, /* Must be first test case num */
> >> -       TEST_INC_DEC_U32,
> >> -       TEST_ADD_SUB_U32,
> >> -       TEST_INC_DEC_64,
> >> -       TEST_ADD_SUB_64,
> >> -       TEST_MAX,
> >> -} odp_test_atomic_t;
> >> -
> >> -
> >> -void test_atomic_inc_dec_u32(void);
> >> -void test_atomic_add_sub_u32(void);
> >> -void test_atomic_inc_dec_64(void);
> >> -void test_atomic_add_sub_64(void);
> >> -void test_atomic_inc_u32(void);
> >> -void test_atomic_dec_u32(void);
> >> -void test_atomic_add_u32(void);
> >> -void test_atomic_sub_u32(void);
> >> -void test_atomic_inc_64(void);
> >> -void test_atomic_dec_64(void);
> >> -void test_atomic_add_64(void);
> >> -void test_atomic_sub_64(void);
> >> -void test_atomic_init(void);
> >> -void test_atomic_basic(void);
> >> -void test_atomic_store(void);
> >> -int test_atomic_validate(void);
> >> -
> >> -#endif /* ODP_ATOMIC_TEST_H_ */
> >> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
> >> index 329d4d4..11afb1f 100644
> >> --- a/test/api_test/odp_common.c
> >> +++ b/test/api_test/odp_common.c
> >> @@ -14,7 +14,6 @@
> >>  #include <odp.h>
> >>  #include <odph_linux.h>
> >>  #include <odp_common.h>
> >> -#include <odp_atomic_test.h>
> >>  #include <odp_shm_test.h>
> >>  #include <test_debug.h>
> >>
> >> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
> >> index 37e2594..22c867a 100644
> >> --- a/test/validation/.gitignore
> >> +++ b/test/validation/.gitignore
> >> @@ -4,3 +4,4 @@ odp_init
> >>  odp_queue
> >>  odp_crypto
> >>  odp_shm
> >> +odp_syne
> >> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
> >> index 8547085..073e72b 100644
> >> --- a/test/validation/Makefile.am
> >> +++ b/test/validation/Makefile.am
> >> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static
> >>  if ODP_CUNIT_ENABLED
> >>  TESTS = ${bin_PROGRAMS}
> >>  check_PROGRAMS = ${bin_PROGRAMS}
> >> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
> >> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
> >>  odp_init_LDFLAGS = $(AM_LDFLAGS)
> >>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
> >>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
> >>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS)
> >> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
> >> +odp_syne_LDFLAGS = $(AM_LDFLAGS)
> >>  endif
> >>
> >>  dist_odp_init_SOURCES = odp_init.c
> >> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =
> >> crypto/odp_crypto_test_async_inp.c \
> >>                           crypto/odp_crypto_test_rng.c \
> >>                           odp_crypto.c common/odp_cunit_common.c
> >>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
> >> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
> >> +                     common/odp_cunit_common.c
> >> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
> >> new file mode 100644
> >> index 0000000..8e2d425
> >> --- /dev/null
> >> +++ b/test/validation/odp_syne.c
> >> @@ -0,0 +1,15 @@
> >> +/* Copyright (c) 2014, Linaro Limited
> >> + * All rights reserved.
> >> + *
> >> + * SPDX-License-Identifier:     BSD-3-Clause
> >> + */
> >> +
> >> +#include "odp.h"
> >
> >
> > This is from the system path
> >
> > #include <odp.h>
> >
> >>
> >> +#include "odp_cunit_common.h"
> >> +#include "odp_test_atomic.h"
> >> +
> >> +CU_SuiteInfo odp_testsuites[] = {
> >> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
> >> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
> >> +       CU_SUITE_INFO_NULL,
> >> +};
> >> diff --git a/test/validation/syne/odp_test_atomic.c
> >> b/test/validation/syne/odp_test_atomic.c
> >> new file mode 100644
> >> index 0000000..68d23f4
> >> --- /dev/null
> >> +++ b/test/validation/syne/odp_test_atomic.c
> >> @@ -0,0 +1,258 @@
> >> +/* Copyright (c) 2014, Linaro Limited
> >> + * All rights reserved.
> >> + *
> >> + * SPDX-License-Identifier:     BSD-3-Clause
> >> + */
> >> +
> >> +#include <string.h>
> >> +#include "odp.h"
> >> +#include "odp_cunit_common.h"
> >> +
> >> +static odp_atomic_u32_t a32u;
> >> +static odp_atomic_u64_t a64u;
> >> +
> >> +
> >> +#define ADD_SUB_CNT    5
> >> +
> >> +#define        CNT 10
> >> +#define        U32_INIT_VAL    (1UL << 10)
> >> +#define        U64_INIT_VAL    (1ULL << 33)
> >> +
> >> +
> >> +static void test_atomic_inc_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_inc_u32(&a32u);
> >> +}
> >> +
> >> +static void test_atomic_inc_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_inc_u64(&a64u);
> >> +}
> >> +
> >> +static void test_atomic_dec_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_dec_u32(&a32u);
> >> +}
> >> +
> >> +static void test_atomic_dec_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_dec_u64(&a64u);
> >> +}
> >> +static void test_atomic_fetch_inc_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_inc_u32(&a32u);
> >> +}
> >> +
> >> +static void test_atomic_fetch_inc_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_inc_u64(&a64u);
> >> +}
> >> +
> >> +static void test_atomic_fetch_dec_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_dec_u32(&a32u);
> >> +}
> >> +
> >> +static void test_atomic_fetch_dec_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_dec_u64(&a64u);
> >> +}
> >> +
> >> +static void test_atomic_add_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
> >> +}
> >> +static void test_atomic_add_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_sub_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_sub_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_fetch_add_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_fetch_add_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
> >> +}
> >> +static void test_atomic_fetch_sub_u32(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_fetch_sub_64(void)
> >> +{
> >> +       int i;
> >> +
> >> +       for (i = 0; i < CNT; i++)
> >> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
> >> +}
> >> +
> >> +static void test_atomic_inc_dec_u32(void)
> >> +{
> >> +       test_atomic_inc_u32();
> >> +       test_atomic_dec_u32();
> >> +}
> >> +
> >> +static void test_atomic_inc_dec_64(void)
> >> +{
> >> +       test_atomic_inc_64();
> >> +       test_atomic_dec_64();
> >> +}
> >> +
> >> +static void test_atomic_fetch_inc_dec_u32(void)
> >> +{
> >> +       test_atomic_fetch_inc_u32();
> >> +       test_atomic_fetch_dec_u32();
> >> +}
> >> +
> >> +static void test_atomic_fetch_inc_dec_64(void)
> >> +{
> >> +       test_atomic_fetch_inc_64();
> >> +       test_atomic_fetch_dec_64();
> >> +}
> >> +
> >> +
> >> +static void test_atomic_add_sub_u32(void)
> >> +{
> >> +       test_atomic_add_u32();
> >> +       test_atomic_sub_u32();
> >> +}
> >> +
> >> +
> >> +static void test_atomic_add_sub_64(void)
> >> +{
> >> +       test_atomic_add_64();
> >> +       test_atomic_sub_64();
> >> +}
> >> +
> >> +static void test_atomic_fetch_add_sub_u32(void)
> >> +{
> >> +       test_atomic_fetch_add_u32();
> >> +       test_atomic_fetch_sub_u32();
> >> +}
> >> +
> >> +static void test_atomic_fetch_add_sub_64(void)
> >> +{
> >> +       test_atomic_fetch_add_64();
> >> +       test_atomic_fetch_sub_64();
> >> +}
> >> +
> >> +static void test_atomic_init(void)
> >> +{
> >> +       odp_atomic_init_u32(&a32u, 0);
> >> +       odp_atomic_init_u64(&a64u, 0);
> >> +}
> >> +
> >> +static void test_atomic_store(void)
> >> +{
> >> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
> >> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
> >> +}
> >> +
> >> +static void test_atomic_validate(void)
> >> +{
> >> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
> >> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
> >> +}
> >> +static void test_atomic_basic(void)
> >> +{
> >> +       test_atomic_init();
> >> +       test_atomic_store();
> >> +       test_atomic_validate();
> >> +}
> >> +static void test_atomic_inc_dec(void)
> >> +{
> >> +       test_atomic_store();
> >> +       test_atomic_inc_dec_u32();
> >> +       test_atomic_inc_dec_64();
> >> +       test_atomic_validate();
> >> +}
> >> +
> >> +static void test_atomic_fetch_inc_dec(void)
> >> +{
> >> +       test_atomic_store();
> >> +       test_atomic_fetch_inc_dec_u32();
> >> +       test_atomic_fetch_inc_dec_64();
> >> +       test_atomic_validate();
> >> +}
> >> +
> >> +static void test_atomic_add_sub(void)
> >> +{
> >> +       test_atomic_store();
> >> +       test_atomic_add_sub_u32();
> >> +       test_atomic_add_sub_64();
> >> +       test_atomic_validate();
> >> +}
> >> +static void test_atomic_fetch_add_sub(void)
> >> +{
> >> +       test_atomic_store();
> >> +       test_atomic_fetch_add_sub_u32();
> >> +       test_atomic_fetch_add_sub_64();
> >> +       test_atomic_validate();
> >> +}
> >> +
> >> +CU_TestInfo test_odp_atomic[] = {
> >> +       {"test_odp_atomic_basic",    test_atomic_basic},
> >> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
> >> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},
> >> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
> >> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
> >> +       CU_TEST_INFO_NULL,
> >> +};
> >> diff --git a/test/validation/syne/odp_test_atomic.h
> >> b/test/validation/syne/odp_test_atomic.h
> >> new file mode 100644
> >> index 0000000..a51a26a
> >> --- /dev/null
> >> +++ b/test/validation/syne/odp_test_atomic.h
> >> @@ -0,0 +1,14 @@
> >> +/* Copyright (c) 2014, Linaro Limited
> >> + * All rights reserved.
> >> + *
> >> + * SPDX-License-Identifier:    BSD-3-Clause
> >> + */
> >> +#ifndef ODP_TEST_ATOMIC_
> >> +#define ODP_TEST_ATOMIC_
> >> +
> >> +#include "CUnit/TestDB.h"
> >> +
> >> +/* Suite test array */
> >> +extern CU_TestInfo test_odp_atomic[];
> >> +
> >> +#endif
> >> --
> >> 1.8.3.1
> >>
> >>
> >> _______________________________________________
> >> lng-odp mailing list
> >> lng-odp@lists.linaro.org
> >> http://lists.linaro.org/mailman/listinfo/lng-odp
> >
> >
> >
> >
> > --
> > Mike Holmes
> > Linaro  Sr Technical Manager
> > LNG - ODP
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
> >
>
yan.songming Dec. 12, 2014, 8:43 a.m. UTC | #5
Mike,
I think Barry's patch is cover the lock, and my patch cover the atomic.

But I still have some cards about the rwlock, spin lock and ticket lock.

So ,should  I write a new one accord Barry's patch or just use his code and change it suitable for our  sunny day test if necessary  ?
I prefer the second.

Thanks,
Yan


yan.songming@linaro.org
 
From: Mike Holmes

Date: 2014-12-12 03:09
To: Ola Liljedahl
CC: Yan Sonming; Barry Spinney; lng-odp
Subject: Re: [lng-odp] [PATCH] validation:add atomic test in odp syncronizers


On 11 December 2014 at 04:36, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:
Are these cunit tests for odp_atomic.h only?
Are there any cunit tests for plain spin locks, ticket locks, rwlocks etc?

Yes, Mario has Barrys code as the basis.
 

-- Ola


On 10 December 2014 at 20:42, Mike Holmes <mike.holmes@linaro.org> wrote:
> I think odp_syne would be better as odp_sync  throughout the patch

>

> Does Barrys patch cover atomics in an overlapping way, or do we have both as

> separate suites ? I think this one is much more sunny day as we had

> originally planned.

> Mario were you able to make the final changes to create a patch for tip from

> Barrys files, do we need to wait until we can see that patch along side this

> one ?

>

> Mike

>

>

> On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org> wrote:

>>

>> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test

>> to test/validation as one part of odp syncronizers test

>

>

> syncronizers

>

>>

>>

>> Signed-off-by: Yan Songming <yan.songming@linaro.org>

>> ---

>>  test/api_test/Makefile.am              |   5 +-

>>  test/api_test/odp_atomic_test.c        | 299

>> ---------------------------------

>>  test/api_test/odp_atomic_test.h        |  51 ------

>>  test/api_test/odp_common.c             |   1 -

>>  test/validation/.gitignore             |   1 +

>>  test/validation/Makefile.am            |   6 +-

>>  test/validation/odp_syne.c             |  15 ++

>>  test/validation/syne/odp_test_atomic.c | 258 ++++++++++++++++++++++++++++

>>  test/validation/syne/odp_test_atomic.h |  14 ++

>>  9 files changed, 294 insertions(+), 356 deletions(-)

>>  delete mode 100644 test/api_test/odp_atomic_test.c

>>  delete mode 100644 test/api_test/odp_atomic_test.h

>>  create mode 100644 test/validation/odp_syne.c

>>  create mode 100644 test/validation/syne/odp_test_atomic.c

>>  create mode 100644 test/validation/syne/odp_test_atomic.h

>>

>> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am

>> index 74e8612..ce301ce 100644

>> --- a/test/api_test/Makefile.am

>> +++ b/test/api_test/Makefile.am

>> @@ -1,18 +1,15 @@

>>  include $(top_srcdir)/test/Makefile.inc

>>

>> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping

>> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping

>>

>> -odp_atomic_CFLAGS = $(AM_CFLAGS)

>>  odp_shm_CFLAGS = $(AM_CFLAGS)

>>  odp_ring_CFLAGS = $(AM_CFLAGS)

>>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)

>>

>> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static

>>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static

>>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static

>>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static

>>

>> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c

>>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c

>>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c

>>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c

>> diff --git a/test/api_test/odp_atomic_test.c

>> b/test/api_test/odp_atomic_test.c

>> deleted file mode 100644

>> index 5563606..0000000

>> --- a/test/api_test/odp_atomic_test.c

>> +++ /dev/null

>> @@ -1,299 +0,0 @@

>> -/* Copyright (c) 2013, Linaro Limited

>> - * All rights reserved.

>> - *

>> - * SPDX-License-Identifier:     BSD-3-Clause

>> - */

>> -

>> -#include <string.h>

>> -#include <sys/time.h>

>> -#include <odp_common.h>

>> -#include <odp_atomic_test.h>

>> -#include <test_debug.h>

>> -

>> -static odp_atomic_u32_t a32u;

>> -static odp_atomic_u64_t a64u;

>> -

>> -static odp_barrier_t barrier;

>> -

>> -static const char * const test_name[] = {

>> -       "dummy",

>> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic ints",

>> -       "test atomic inc/dec of 32-bit atomic int",

>> -       "test atomic add/sub of 32-bit atomic int",

>> -       "test atomic inc/dec of 64-bit atomic int",

>> -       "test atomic add/sub of 64-bit atomic int"

>> -};

>> -

>> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];

>> -

>> -static void usage(void)

>> -{

>> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"

>> -              "\t<testcase> is\n"

>> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic

>> ints)\n"

>> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"

>> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"

>> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"

>> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"

>> -              "\t\t-n <1 - 31> - no of threads to start\n"

>> -              "\t\tif user doesn't specify this option, then\n"

>> -              "\t\tno of threads created is equivalent to no of cores\n"

>> -              "\t\tavailable in the system\n"

>> -              "\tExample usage:\n"

>> -              "\t\t./odp_atomic -t 2\n"

>> -              "\t\t./odp_atomic -t 3 -n 12\n");

>> -}

>> -

>> -

>> -void test_atomic_inc_u32(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < CNT; i++)

>> -               odp_atomic_inc_u32(&a32u);

>> -}

>> -

>> -void test_atomic_inc_64(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < CNT; i++)

>> -               odp_atomic_inc_u64(&a64u);

>> -}

>> -

>> -void test_atomic_dec_u32(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < CNT; i++)

>> -               odp_atomic_dec_u32(&a32u);

>> -}

>> -

>> -void test_atomic_dec_64(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < CNT; i++)

>> -               odp_atomic_dec_u64(&a64u);

>> -}

>> -

>> -void test_atomic_add_u32(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)

>> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);

>> -}

>> -

>> -void test_atomic_add_64(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)

>> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);

>> -}

>> -

>> -void test_atomic_sub_u32(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)

>> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);

>> -}

>> -

>> -void test_atomic_sub_64(void)

>> -{

>> -       int i;

>> -

>> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)

>> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);

>> -}

>> -

>> -void test_atomic_inc_dec_u32(void)

>> -{

>> -       test_atomic_inc_u32();

>> -       test_atomic_dec_u32();

>> -}

>> -

>> -void test_atomic_add_sub_u32(void)

>> -{

>> -       test_atomic_add_u32();

>> -       test_atomic_sub_u32();

>> -}

>> -

>> -void test_atomic_inc_dec_64(void)

>> -{

>> -       test_atomic_inc_64();

>> -       test_atomic_dec_64();

>> -}

>> -

>> -void test_atomic_add_sub_64(void)

>> -{

>> -       test_atomic_add_64();

>> -       test_atomic_sub_64();

>> -}

>> -

>> -/**

>> - * Test basic atomic operation like

>> - * add/sub/increment/decrement operation.

>> - */

>> -void test_atomic_basic(void)

>> -{

>> -       test_atomic_inc_u32();

>> -       test_atomic_dec_u32();

>> -       test_atomic_add_u32();

>> -       test_atomic_sub_u32();

>> -

>> -       test_atomic_inc_64();

>> -       test_atomic_dec_64();

>> -       test_atomic_add_64();

>> -       test_atomic_sub_64();

>> -}

>> -

>> -void test_atomic_init(void)

>> -{

>> -       odp_atomic_init_u32(&a32u, 0);

>> -       odp_atomic_init_u64(&a64u, 0);

>> -}

>> -

>> -void test_atomic_store(void)

>> -{

>> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);

>> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);

>> -}

>> -

>> -int test_atomic_validate(void)

>> -{

>> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {

>> -               LOG_ERR("Atomic u32 usual functions failed\n");

>> -               return -1;

>> -       }

>> -

>> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {

>> -               LOG_ERR("Atomic u64 usual functions failed\n");

>> -               return -1;

>> -       }

>> -

>> -       return 0;

>> -}

>> -

>> -static void *run_thread(void *arg)

>> -{

>> -       pthrd_arg *parg = (pthrd_arg *)arg;

>> -       int thr;

>> -

>> -       thr = odp_thread_id();

>> -

>> -       LOG_DBG("Thread %i starts\n", thr);

>> -

>> -       /* Wait here until all threads have arrived */

>> -       /* Use multiple barriers to verify that it handles wrap around and

>> -        * has no race conditions which could be exposed when invoked

>> back-

>> -        * to-back */

>> -       odp_barrier_wait(&barrier);

>> -       odp_barrier_wait(&barrier);

>> -       odp_barrier_wait(&barrier);

>> -       odp_barrier_wait(&barrier);

>> -

>> -       gettimeofday(&tv0[thr], NULL);

>> -

>> -       switch (parg->testcase) {

>> -       case TEST_MIX:

>> -               test_atomic_basic();

>> -               break;

>> -       case TEST_INC_DEC_U32:

>> -               test_atomic_inc_dec_u32();

>> -               break;

>> -       case TEST_ADD_SUB_U32:

>> -               test_atomic_add_sub_u32();

>> -               break;

>> -       case TEST_INC_DEC_64:

>> -               test_atomic_inc_dec_64();

>> -               break;

>> -       case TEST_ADD_SUB_64:

>> -               test_atomic_add_sub_64();

>> -               break;

>> -       }

>> -       gettimeofday(&tv1[thr], NULL);

>> -       fflush(NULL);

>> -

>> -       printf("Time taken in thread %02d to complete op is %lld usec\n",

>> thr,

>> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +

>> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));

>> -

>> -       return parg;

>> -}

>> -

>> -int main(int argc, char *argv[])

>> -{

>> -       pthrd_arg thrdarg;

>> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;

>> -       char c;

>> -       int result;

>> -

>> -       if (argc == 1 || argc % 2 == 0) {

>> -               usage();

>> -               goto err_exit;

>> -       }

>> -       if (odp_test_global_init() != 0)

>> -               goto err_exit;

>> -       odp_print_system_info();

>> -

>> -       while (cnt != 0) {

>> -               sscanf(argv[++i], "-%c", &c);

>> -               switch (c) {

>> -               case 't':

>> -                       sscanf(argv[++i], "%d", &test_type);

>> -                       break;

>> -               case 'n':

>> -                       sscanf(argv[++i], "%d", &pthrdnum);

>> -                       break;

>> -               default:

>> -                       LOG_ERR("Invalid option %c\n", c);

>> -                       usage();

>> -                       goto err_exit;

>> -               }

>> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||

>> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {

>> -                       usage();

>> -                       goto err_exit;

>> -               }

>> -               cnt -= 2;

>> -       }

>> -

>> -       if (pthrdnum == 0)

>> -               pthrdnum = odp_sys_core_count();

>> -

>> -       test_atomic_init();

>> -       test_atomic_store();

>> -

>> -       memset(&thrdarg, 0, sizeof(pthrd_arg));

>> -       thrdarg.testcase = test_type;

>> -       thrdarg.numthrds = pthrdnum;

>> -

>> -       if ((test_type > 0) && (test_type < TEST_MAX)) {

>> -               printf("%s\n", test_name[test_type]);

>> -       } else {

>> -               LOG_ERR("Invalid test case [%d]\n", test_type);

>> -               usage();

>> -               goto err_exit;

>> -       }

>> -       odp_barrier_init(&barrier, pthrdnum);

>> -       odp_test_thread_create(run_thread, &thrdarg);

>> -

>> -       odp_test_thread_exit(&thrdarg);

>> -

>> -       result = test_atomic_validate();

>> -

>> -       if (result == 0) {

>> -               printf("%s_%d_%d Result:pass\n",

>> -                      test_name[test_type], test_type, pthrdnum);

>> -       } else {

>> -               printf("%s_%d_%d Result:fail\n",

>> -                      test_name[test_type], test_type, pthrdnum);

>> -       }

>> -       return 0;

>> -

>> -err_exit:

>> -       return -1;

>> -}

>> diff --git a/test/api_test/odp_atomic_test.h

>> b/test/api_test/odp_atomic_test.h

>> deleted file mode 100644

>> index aaa9d34..0000000

>> --- a/test/api_test/odp_atomic_test.h

>> +++ /dev/null

>> @@ -1,51 +0,0 @@

>> -/* Copyright (c) 2013, Linaro Limited

>> - * All rights reserved.

>> - *

>> - * SPDX-License-Identifier:     BSD-3-Clause

>> - */

>> -

>> -#ifndef ODP_ATOMIC_TEST_H_

>> -#define ODP_ATOMIC_TEST_H_

>> -

>> -#include <odp.h>

>> -#include <odph_linux.h>

>> -

>> -/**

>> - * add_sub_cnt could be any valid value

>> - * so to excercise explicit atomic_add/sub

>> - * ops. For now using 5..

>> - */

>> -#define ADD_SUB_CNT    5

>> -

>> -#define        CNT 500000

>> -#define        U32_INIT_VAL    (1UL << 10)

>> -#define        U64_INIT_VAL    (1ULL << 33)

>> -

>> -typedef enum {

>> -       TEST_MIX = 1, /* Must be first test case num */

>> -       TEST_INC_DEC_U32,

>> -       TEST_ADD_SUB_U32,

>> -       TEST_INC_DEC_64,

>> -       TEST_ADD_SUB_64,

>> -       TEST_MAX,

>> -} odp_test_atomic_t;

>> -

>> -

>> -void test_atomic_inc_dec_u32(void);

>> -void test_atomic_add_sub_u32(void);

>> -void test_atomic_inc_dec_64(void);

>> -void test_atomic_add_sub_64(void);

>> -void test_atomic_inc_u32(void);

>> -void test_atomic_dec_u32(void);

>> -void test_atomic_add_u32(void);

>> -void test_atomic_sub_u32(void);

>> -void test_atomic_inc_64(void);

>> -void test_atomic_dec_64(void);

>> -void test_atomic_add_64(void);

>> -void test_atomic_sub_64(void);

>> -void test_atomic_init(void);

>> -void test_atomic_basic(void);

>> -void test_atomic_store(void);

>> -int test_atomic_validate(void);

>> -

>> -#endif /* ODP_ATOMIC_TEST_H_ */

>> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c

>> index 329d4d4..11afb1f 100644

>> --- a/test/api_test/odp_common.c

>> +++ b/test/api_test/odp_common.c

>> @@ -14,7 +14,6 @@

>>  #include <odp.h>

>>  #include <odph_linux.h>

>>  #include <odp_common.h>

>> -#include <odp_atomic_test.h>

>>  #include <odp_shm_test.h>

>>  #include <test_debug.h>

>>

>> diff --git a/test/validation/.gitignore b/test/validation/.gitignore

>> index 37e2594..22c867a 100644

>> --- a/test/validation/.gitignore

>> +++ b/test/validation/.gitignore

>> @@ -4,3 +4,4 @@ odp_init

>>  odp_queue

>>  odp_crypto

>>  odp_shm

>> +odp_syne

>> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am

>> index 8547085..073e72b 100644

>> --- a/test/validation/Makefile.am

>> +++ b/test/validation/Makefile.am

>> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static

>>  if ODP_CUNIT_ENABLED

>>  TESTS = ${bin_PROGRAMS}

>>  check_PROGRAMS = ${bin_PROGRAMS}

>> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm

>> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne

>>  odp_init_LDFLAGS = $(AM_LDFLAGS)

>>  odp_queue_LDFLAGS = $(AM_LDFLAGS)

>>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto

>>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)

>>  odp_shm_CFLAGS = $(AM_CFLAGS)

>>  odp_shm_LDFLAGS = $(AM_LDFLAGS)

>> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne

>> +odp_syne_LDFLAGS = $(AM_LDFLAGS)

>>  endif

>>

>>  dist_odp_init_SOURCES = odp_init.c

>> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =

>> crypto/odp_crypto_test_async_inp.c \

>>                           crypto/odp_crypto_test_rng.c \

>>                           odp_crypto.c common/odp_cunit_common.c

>>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c

>> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\

>> +                     common/odp_cunit_common.c

>> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c

>> new file mode 100644

>> index 0000000..8e2d425

>> --- /dev/null

>> +++ b/test/validation/odp_syne.c

>> @@ -0,0 +1,15 @@

>> +/* Copyright (c) 2014, Linaro Limited

>> + * All rights reserved.

>> + *

>> + * SPDX-License-Identifier:     BSD-3-Clause

>> + */

>> +

>> +#include "odp.h"

>

>

> This is from the system path

>

> #include <odp.h>

>

>>

>> +#include "odp_cunit_common.h"

>> +#include "odp_test_atomic.h"

>> +

>> +CU_SuiteInfo odp_testsuites[] = {

>> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},

>> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/

>> +       CU_SUITE_INFO_NULL,

>> +};

>> diff --git a/test/validation/syne/odp_test_atomic.c

>> b/test/validation/syne/odp_test_atomic.c

>> new file mode 100644

>> index 0000000..68d23f4

>> --- /dev/null

>> +++ b/test/validation/syne/odp_test_atomic.c

>> @@ -0,0 +1,258 @@

>> +/* Copyright (c) 2014, Linaro Limited

>> + * All rights reserved.

>> + *

>> + * SPDX-License-Identifier:     BSD-3-Clause

>> + */

>> +

>> +#include <string.h>

>> +#include "odp.h"

>> +#include "odp_cunit_common.h"

>> +

>> +static odp_atomic_u32_t a32u;

>> +static odp_atomic_u64_t a64u;

>> +

>> +

>> +#define ADD_SUB_CNT    5

>> +

>> +#define        CNT 10

>> +#define        U32_INIT_VAL    (1UL << 10)

>> +#define        U64_INIT_VAL    (1ULL << 33)

>> +

>> +

>> +static void test_atomic_inc_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_inc_u32(&a32u);

>> +}

>> +

>> +static void test_atomic_inc_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_inc_u64(&a64u);

>> +}

>> +

>> +static void test_atomic_dec_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_dec_u32(&a32u);

>> +}

>> +

>> +static void test_atomic_dec_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_dec_u64(&a64u);

>> +}

>> +static void test_atomic_fetch_inc_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_inc_u32(&a32u);

>> +}

>> +

>> +static void test_atomic_fetch_inc_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_inc_u64(&a64u);

>> +}

>> +

>> +static void test_atomic_fetch_dec_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_dec_u32(&a32u);

>> +}

>> +

>> +static void test_atomic_fetch_dec_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_dec_u64(&a64u);

>> +}

>> +

>> +static void test_atomic_add_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);

>> +}

>> +static void test_atomic_add_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_sub_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_sub_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_fetch_add_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_fetch_add_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);

>> +}

>> +static void test_atomic_fetch_sub_u32(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_fetch_sub_64(void)

>> +{

>> +       int i;

>> +

>> +       for (i = 0; i < CNT; i++)

>> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);

>> +}

>> +

>> +static void test_atomic_inc_dec_u32(void)

>> +{

>> +       test_atomic_inc_u32();

>> +       test_atomic_dec_u32();

>> +}

>> +

>> +static void test_atomic_inc_dec_64(void)

>> +{

>> +       test_atomic_inc_64();

>> +       test_atomic_dec_64();

>> +}

>> +

>> +static void test_atomic_fetch_inc_dec_u32(void)

>> +{

>> +       test_atomic_fetch_inc_u32();

>> +       test_atomic_fetch_dec_u32();

>> +}

>> +

>> +static void test_atomic_fetch_inc_dec_64(void)

>> +{

>> +       test_atomic_fetch_inc_64();

>> +       test_atomic_fetch_dec_64();

>> +}

>> +

>> +

>> +static void test_atomic_add_sub_u32(void)

>> +{

>> +       test_atomic_add_u32();

>> +       test_atomic_sub_u32();

>> +}

>> +

>> +

>> +static void test_atomic_add_sub_64(void)

>> +{

>> +       test_atomic_add_64();

>> +       test_atomic_sub_64();

>> +}

>> +

>> +static void test_atomic_fetch_add_sub_u32(void)

>> +{

>> +       test_atomic_fetch_add_u32();

>> +       test_atomic_fetch_sub_u32();

>> +}

>> +

>> +static void test_atomic_fetch_add_sub_64(void)

>> +{

>> +       test_atomic_fetch_add_64();

>> +       test_atomic_fetch_sub_64();

>> +}

>> +

>> +static void test_atomic_init(void)

>> +{

>> +       odp_atomic_init_u32(&a32u, 0);

>> +       odp_atomic_init_u64(&a64u, 0);

>> +}

>> +

>> +static void test_atomic_store(void)

>> +{

>> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);

>> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);

>> +}

>> +

>> +static void test_atomic_validate(void)

>> +{

>> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));

>> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));

>> +}

>> +static void test_atomic_basic(void)

>> +{

>> +       test_atomic_init();

>> +       test_atomic_store();

>> +       test_atomic_validate();

>> +}

>> +static void test_atomic_inc_dec(void)

>> +{

>> +       test_atomic_store();

>> +       test_atomic_inc_dec_u32();

>> +       test_atomic_inc_dec_64();

>> +       test_atomic_validate();

>> +}

>> +

>> +static void test_atomic_fetch_inc_dec(void)

>> +{

>> +       test_atomic_store();

>> +       test_atomic_fetch_inc_dec_u32();

>> +       test_atomic_fetch_inc_dec_64();

>> +       test_atomic_validate();

>> +}

>> +

>> +static void test_atomic_add_sub(void)

>> +{

>> +       test_atomic_store();

>> +       test_atomic_add_sub_u32();

>> +       test_atomic_add_sub_64();

>> +       test_atomic_validate();

>> +}

>> +static void test_atomic_fetch_add_sub(void)

>> +{

>> +       test_atomic_store();

>> +       test_atomic_fetch_add_sub_u32();

>> +       test_atomic_fetch_add_sub_64();

>> +       test_atomic_validate();

>> +}

>> +

>> +CU_TestInfo test_odp_atomic[] = {

>> +       {"test_odp_atomic_basic",    test_atomic_basic},

>> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},

>> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},

>> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},

>> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},

>> +       CU_TEST_INFO_NULL,

>> +};

>> diff --git a/test/validation/syne/odp_test_atomic.h

>> b/test/validation/syne/odp_test_atomic.h

>> new file mode 100644

>> index 0000000..a51a26a

>> --- /dev/null

>> +++ b/test/validation/syne/odp_test_atomic.h

>> @@ -0,0 +1,14 @@

>> +/* Copyright (c) 2014, Linaro Limited

>> + * All rights reserved.

>> + *

>> + * SPDX-License-Identifier:    BSD-3-Clause

>> + */

>> +#ifndef ODP_TEST_ATOMIC_

>> +#define ODP_TEST_ATOMIC_

>> +

>> +#include "CUnit/TestDB.h"

>> +

>> +/* Suite test array */

>> +extern CU_TestInfo test_odp_atomic[];

>> +

>> +#endif

>> --

>> 1.8.3.1

>>

>>

>> _______________________________________________

>> lng-odp mailing list

>> lng-odp@lists.linaro.org

>> http://lists.linaro.org/mailman/listinfo/lng-odp

>

>

>

>

> --

> Mike Holmes

> Linaro  Sr Technical Manager

> LNG - ODP

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> http://lists.linaro.org/mailman/listinfo/lng-odp

>




-- 
Mike Holmes 
Linaro  Sr Technical Manager
LNG - ODP
Mike Holmes Dec. 12, 2014, 6:41 p.m. UTC | #6
Synchronize with Mario, but we don't want to lose any extra functionality
in combining all the work.

I assume that test/validation/sync  (synchronizers)  will contain one test
suite each for for atomics, rwlock, spin lock and ticket lock and all of
those test suites will be called from a top level test/validation/odp_sync
test.

Mike

On 12 December 2014 at 03:43, yan.songming@linaro.org <
yan.songming@linaro.org> wrote:
>
> Mike,
> I think Barry's patch is cover the lock, and my patch cover the atomic.
>
> But I still have some cards about the rwlock, spin lock and ticket lock.
>
> So ,should  I write a new one accord Barry's patch or just use his code
> and change it suitable for our  sunny day test if necessary  ?
> I prefer the second.
>
> Thanks,
> Yan
> ------------------------------
> yan.songming@linaro.org
>
>
> *From:* Mike Holmes <mike.holmes@linaro.org>
> *Date:* 2014-12-12 03:09
> *To:* Ola Liljedahl <ola.liljedahl@linaro.org>
> *CC:* Yan Sonming <yan.songming@linaro.org>; Barry Spinney
> <spinney@ezchip.com>; lng-odp <lng-odp@lists.linaro.org>
> *Subject:* Re: [lng-odp] [PATCH] validation:add atomic test in odp
> syncronizers
>
>
> On 11 December 2014 at 04:36, Ola Liljedahl <ola.liljedahl@linaro.org>
> wrote:
>
>> Are these cunit tests for odp_atomic.h only?
>> Are there any cunit tests for plain spin locks, ticket locks, rwlocks etc?
>>
>
> Yes, Mario has Barrys code as the basis.
>
>
>>
>> -- Ola
>>
>>
>> On 10 December 2014 at 20:42, Mike Holmes <mike.holmes@linaro.org> wrote:
>> > I think odp_syne would be better as odp_sync  throughout the patch
>> >
>> > Does Barrys patch cover atomics in an overlapping way, or do we have
>> both as
>> > separate suites ? I think this one is much more sunny day as we had
>> > originally planned.
>> > Mario were you able to make the final changes to create a patch for tip
>> from
>> > Barrys files, do we need to wait until we can see that patch along side
>> this
>> > one ?
>> >
>> > Mike
>> >
>> >
>> > On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org>
>> wrote:
>> >>
>> >> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
>> >> to test/validation as one part of odp syncronizers test
>> >
>> >
>> > syncronizers
>> >
>> >>
>> >>
>> >> Signed-off-by: Yan Songming <yan.songming@linaro.org>
>> >> ---
>> >>  test/api_test/Makefile.am              |   5 +-
>> >>  test/api_test/odp_atomic_test.c        | 299
>> >> ---------------------------------
>> >>  test/api_test/odp_atomic_test.h        |  51 ------
>> >>  test/api_test/odp_common.c             |   1 -
>> >>  test/validation/.gitignore             |   1 +
>> >>  test/validation/Makefile.am            |   6 +-
>> >>  test/validation/odp_syne.c             |  15 ++
>> >>  test/validation/syne/odp_test_atomic.c | 258
>> ++++++++++++++++++++++++++++
>> >>  test/validation/syne/odp_test_atomic.h |  14 ++
>> >>  9 files changed, 294 insertions(+), 356 deletions(-)
>> >>  delete mode 100644 test/api_test/odp_atomic_test.c
>> >>  delete mode 100644 test/api_test/odp_atomic_test.h
>> >>  create mode 100644 test/validation/odp_syne.c
>> >>  create mode 100644 test/validation/syne/odp_test_atomic.c
>> >>  create mode 100644 test/validation/syne/odp_test_atomic.h
>> >>
>> >> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
>> >> index 74e8612..ce301ce 100644
>> >> --- a/test/api_test/Makefile.am
>> >> +++ b/test/api_test/Makefile.am
>> >> @@ -1,18 +1,15 @@
>> >>  include $(top_srcdir)/test/Makefile.inc
>> >>
>> >> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
>> >> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
>> >>
>> >> -odp_atomic_CFLAGS = $(AM_CFLAGS)
>> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
>> >>  odp_ring_CFLAGS = $(AM_CFLAGS)
>> >>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)
>> >>
>> >> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
>> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
>> >>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
>> >>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
>> >>
>> >> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
>> >>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
>> >>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
>> >>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
>> >> diff --git a/test/api_test/odp_atomic_test.c
>> >> b/test/api_test/odp_atomic_test.c
>> >> deleted file mode 100644
>> >> index 5563606..0000000
>> >> --- a/test/api_test/odp_atomic_test.c
>> >> +++ /dev/null
>> >> @@ -1,299 +0,0 @@
>> >> -/* Copyright (c) 2013, Linaro Limited
>> >> - * All rights reserved.
>> >> - *
>> >> - * SPDX-License-Identifier:     BSD-3-Clause
>> >> - */
>> >> -
>> >> -#include <string.h>
>> >> -#include <sys/time.h>
>> >> -#include <odp_common.h>
>> >> -#include <odp_atomic_test.h>
>> >> -#include <test_debug.h>
>> >> -
>> >> -static odp_atomic_u32_t a32u;
>> >> -static odp_atomic_u64_t a64u;
>> >> -
>> >> -static odp_barrier_t barrier;
>> >> -
>> >> -static const char * const test_name[] = {
>> >> -       "dummy",
>> >> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic
>> ints",
>> >> -       "test atomic inc/dec of 32-bit atomic int",
>> >> -       "test atomic add/sub of 32-bit atomic int",
>> >> -       "test atomic inc/dec of 64-bit atomic int",
>> >> -       "test atomic add/sub of 64-bit atomic int"
>> >> -};
>> >> -
>> >> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
>> >> -
>> >> -static void usage(void)
>> >> -{
>> >> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
>> >> -              "\t<testcase> is\n"
>> >> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
>> >> ints)\n"
>> >> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"
>> >> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"
>> >> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"
>> >> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"
>> >> -              "\t\t-n <1 - 31> - no of threads to start\n"
>> >> -              "\t\tif user doesn't specify this option, then\n"
>> >> -              "\t\tno of threads created is equivalent to no of
>> cores\n"
>> >> -              "\t\tavailable in the system\n"
>> >> -              "\tExample usage:\n"
>> >> -              "\t\t./odp_atomic -t 2\n"
>> >> -              "\t\t./odp_atomic -t 3 -n 12\n");
>> >> -}
>> >> -
>> >> -
>> >> -void test_atomic_inc_u32(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < CNT; i++)
>> >> -               odp_atomic_inc_u32(&a32u);
>> >> -}
>> >> -
>> >> -void test_atomic_inc_64(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < CNT; i++)
>> >> -               odp_atomic_inc_u64(&a64u);
>> >> -}
>> >> -
>> >> -void test_atomic_dec_u32(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < CNT; i++)
>> >> -               odp_atomic_dec_u32(&a32u);
>> >> -}
>> >> -
>> >> -void test_atomic_dec_64(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < CNT; i++)
>> >> -               odp_atomic_dec_u64(&a64u);
>> >> -}
>> >> -
>> >> -void test_atomic_add_u32(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> >> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>> >> -}
>> >> -
>> >> -void test_atomic_add_64(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> >> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>> >> -}
>> >> -
>> >> -void test_atomic_sub_u32(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> >> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>> >> -}
>> >> -
>> >> -void test_atomic_sub_64(void)
>> >> -{
>> >> -       int i;
>> >> -
>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>> >> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>> >> -}
>> >> -
>> >> -void test_atomic_inc_dec_u32(void)
>> >> -{
>> >> -       test_atomic_inc_u32();
>> >> -       test_atomic_dec_u32();
>> >> -}
>> >> -
>> >> -void test_atomic_add_sub_u32(void)
>> >> -{
>> >> -       test_atomic_add_u32();
>> >> -       test_atomic_sub_u32();
>> >> -}
>> >> -
>> >> -void test_atomic_inc_dec_64(void)
>> >> -{
>> >> -       test_atomic_inc_64();
>> >> -       test_atomic_dec_64();
>> >> -}
>> >> -
>> >> -void test_atomic_add_sub_64(void)
>> >> -{
>> >> -       test_atomic_add_64();
>> >> -       test_atomic_sub_64();
>> >> -}
>> >> -
>> >> -/**
>> >> - * Test basic atomic operation like
>> >> - * add/sub/increment/decrement operation.
>> >> - */
>> >> -void test_atomic_basic(void)
>> >> -{
>> >> -       test_atomic_inc_u32();
>> >> -       test_atomic_dec_u32();
>> >> -       test_atomic_add_u32();
>> >> -       test_atomic_sub_u32();
>> >> -
>> >> -       test_atomic_inc_64();
>> >> -       test_atomic_dec_64();
>> >> -       test_atomic_add_64();
>> >> -       test_atomic_sub_64();
>> >> -}
>> >> -
>> >> -void test_atomic_init(void)
>> >> -{
>> >> -       odp_atomic_init_u32(&a32u, 0);
>> >> -       odp_atomic_init_u64(&a64u, 0);
>> >> -}
>> >> -
>> >> -void test_atomic_store(void)
>> >> -{
>> >> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>> >> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>> >> -}
>> >> -
>> >> -int test_atomic_validate(void)
>> >> -{
>> >> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
>> >> -               LOG_ERR("Atomic u32 usual functions failed\n");
>> >> -               return -1;
>> >> -       }
>> >> -
>> >> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
>> >> -               LOG_ERR("Atomic u64 usual functions failed\n");
>> >> -               return -1;
>> >> -       }
>> >> -
>> >> -       return 0;
>> >> -}
>> >> -
>> >> -static void *run_thread(void *arg)
>> >> -{
>> >> -       pthrd_arg *parg = (pthrd_arg *)arg;
>> >> -       int thr;
>> >> -
>> >> -       thr = odp_thread_id();
>> >> -
>> >> -       LOG_DBG("Thread %i starts\n", thr);
>> >> -
>> >> -       /* Wait here until all threads have arrived */
>> >> -       /* Use multiple barriers to verify that it handles wrap around
>> and
>> >> -        * has no race conditions which could be exposed when invoked
>> >> back-
>> >> -        * to-back */
>> >> -       odp_barrier_wait(&barrier);
>> >> -       odp_barrier_wait(&barrier);
>> >> -       odp_barrier_wait(&barrier);
>> >> -       odp_barrier_wait(&barrier);
>> >> -
>> >> -       gettimeofday(&tv0[thr], NULL);
>> >> -
>> >> -       switch (parg->testcase) {
>> >> -       case TEST_MIX:
>> >> -               test_atomic_basic();
>> >> -               break;
>> >> -       case TEST_INC_DEC_U32:
>> >> -               test_atomic_inc_dec_u32();
>> >> -               break;
>> >> -       case TEST_ADD_SUB_U32:
>> >> -               test_atomic_add_sub_u32();
>> >> -               break;
>> >> -       case TEST_INC_DEC_64:
>> >> -               test_atomic_inc_dec_64();
>> >> -               break;
>> >> -       case TEST_ADD_SUB_64:
>> >> -               test_atomic_add_sub_64();
>> >> -               break;
>> >> -       }
>> >> -       gettimeofday(&tv1[thr], NULL);
>> >> -       fflush(NULL);
>> >> -
>> >> -       printf("Time taken in thread %02d to complete op is %lld
>> usec\n",
>> >> thr,
>> >> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
>> >> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));
>> >> -
>> >> -       return parg;
>> >> -}
>> >> -
>> >> -int main(int argc, char *argv[])
>> >> -{
>> >> -       pthrd_arg thrdarg;
>> >> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
>> >> -       char c;
>> >> -       int result;
>> >> -
>> >> -       if (argc == 1 || argc % 2 == 0) {
>> >> -               usage();
>> >> -               goto err_exit;
>> >> -       }
>> >> -       if (odp_test_global_init() != 0)
>> >> -               goto err_exit;
>> >> -       odp_print_system_info();
>> >> -
>> >> -       while (cnt != 0) {
>> >> -               sscanf(argv[++i], "-%c", &c);
>> >> -               switch (c) {
>> >> -               case 't':
>> >> -                       sscanf(argv[++i], "%d", &test_type);
>> >> -                       break;
>> >> -               case 'n':
>> >> -                       sscanf(argv[++i], "%d", &pthrdnum);
>> >> -                       break;
>> >> -               default:
>> >> -                       LOG_ERR("Invalid option %c\n", c);
>> >> -                       usage();
>> >> -                       goto err_exit;
>> >> -               }
>> >> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||
>> >> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
>> >> -                       usage();
>> >> -                       goto err_exit;
>> >> -               }
>> >> -               cnt -= 2;
>> >> -       }
>> >> -
>> >> -       if (pthrdnum == 0)
>> >> -               pthrdnum = odp_sys_core_count();
>> >> -
>> >> -       test_atomic_init();
>> >> -       test_atomic_store();
>> >> -
>> >> -       memset(&thrdarg, 0, sizeof(pthrd_arg));
>> >> -       thrdarg.testcase = test_type;
>> >> -       thrdarg.numthrds = pthrdnum;
>> >> -
>> >> -       if ((test_type > 0) && (test_type < TEST_MAX)) {
>> >> -               printf("%s\n", test_name[test_type]);
>> >> -       } else {
>> >> -               LOG_ERR("Invalid test case [%d]\n", test_type);
>> >> -               usage();
>> >> -               goto err_exit;
>> >> -       }
>> >> -       odp_barrier_init(&barrier, pthrdnum);
>> >> -       odp_test_thread_create(run_thread, &thrdarg);
>> >> -
>> >> -       odp_test_thread_exit(&thrdarg);
>> >> -
>> >> -       result = test_atomic_validate();
>> >> -
>> >> -       if (result == 0) {
>> >> -               printf("%s_%d_%d Result:pass\n",
>> >> -                      test_name[test_type], test_type, pthrdnum);
>> >> -       } else {
>> >> -               printf("%s_%d_%d Result:fail\n",
>> >> -                      test_name[test_type], test_type, pthrdnum);
>> >> -       }
>> >> -       return 0;
>> >> -
>> >> -err_exit:
>> >> -       return -1;
>> >> -}
>> >> diff --git a/test/api_test/odp_atomic_test.h
>> >> b/test/api_test/odp_atomic_test.h
>> >> deleted file mode 100644
>> >> index aaa9d34..0000000
>> >> --- a/test/api_test/odp_atomic_test.h
>> >> +++ /dev/null
>> >> @@ -1,51 +0,0 @@
>> >> -/* Copyright (c) 2013, Linaro Limited
>> >> - * All rights reserved.
>> >> - *
>> >> - * SPDX-License-Identifier:     BSD-3-Clause
>> >> - */
>> >> -
>> >> -#ifndef ODP_ATOMIC_TEST_H_
>> >> -#define ODP_ATOMIC_TEST_H_
>> >> -
>> >> -#include <odp.h>
>> >> -#include <odph_linux.h>
>> >> -
>> >> -/**
>> >> - * add_sub_cnt could be any valid value
>> >> - * so to excercise explicit atomic_add/sub
>> >> - * ops. For now using 5..
>> >> - */
>> >> -#define ADD_SUB_CNT    5
>> >> -
>> >> -#define        CNT 500000
>> >> -#define        U32_INIT_VAL    (1UL << 10)
>> >> -#define        U64_INIT_VAL    (1ULL << 33)
>> >> -
>> >> -typedef enum {
>> >> -       TEST_MIX = 1, /* Must be first test case num */
>> >> -       TEST_INC_DEC_U32,
>> >> -       TEST_ADD_SUB_U32,
>> >> -       TEST_INC_DEC_64,
>> >> -       TEST_ADD_SUB_64,
>> >> -       TEST_MAX,
>> >> -} odp_test_atomic_t;
>> >> -
>> >> -
>> >> -void test_atomic_inc_dec_u32(void);
>> >> -void test_atomic_add_sub_u32(void);
>> >> -void test_atomic_inc_dec_64(void);
>> >> -void test_atomic_add_sub_64(void);
>> >> -void test_atomic_inc_u32(void);
>> >> -void test_atomic_dec_u32(void);
>> >> -void test_atomic_add_u32(void);
>> >> -void test_atomic_sub_u32(void);
>> >> -void test_atomic_inc_64(void);
>> >> -void test_atomic_dec_64(void);
>> >> -void test_atomic_add_64(void);
>> >> -void test_atomic_sub_64(void);
>> >> -void test_atomic_init(void);
>> >> -void test_atomic_basic(void);
>> >> -void test_atomic_store(void);
>> >> -int test_atomic_validate(void);
>> >> -
>> >> -#endif /* ODP_ATOMIC_TEST_H_ */
>> >> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
>> >> index 329d4d4..11afb1f 100644
>> >> --- a/test/api_test/odp_common.c
>> >> +++ b/test/api_test/odp_common.c
>> >> @@ -14,7 +14,6 @@
>> >>  #include <odp.h>
>> >>  #include <odph_linux.h>
>> >>  #include <odp_common.h>
>> >> -#include <odp_atomic_test.h>
>> >>  #include <odp_shm_test.h>
>> >>  #include <test_debug.h>
>> >>
>> >> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
>> >> index 37e2594..22c867a 100644
>> >> --- a/test/validation/.gitignore
>> >> +++ b/test/validation/.gitignore
>> >> @@ -4,3 +4,4 @@ odp_init
>> >>  odp_queue
>> >>  odp_crypto
>> >>  odp_shm
>> >> +odp_syne
>> >> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
>> >> index 8547085..073e72b 100644
>> >> --- a/test/validation/Makefile.am
>> >> +++ b/test/validation/Makefile.am
>> >> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static
>> >>  if ODP_CUNIT_ENABLED
>> >>  TESTS = ${bin_PROGRAMS}
>> >>  check_PROGRAMS = ${bin_PROGRAMS}
>> >> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
>> >> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
>> >>  odp_init_LDFLAGS = $(AM_LDFLAGS)
>> >>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
>> >>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>> >>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
>> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
>> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS)
>> >> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
>> >> +odp_syne_LDFLAGS = $(AM_LDFLAGS)
>> >>  endif
>> >>
>> >>  dist_odp_init_SOURCES = odp_init.c
>> >> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =
>> >> crypto/odp_crypto_test_async_inp.c \
>> >>                           crypto/odp_crypto_test_rng.c \
>> >>                           odp_crypto.c common/odp_cunit_common.c
>> >>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
>> >> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
>> >> +                     common/odp_cunit_common.c
>> >> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
>> >> new file mode 100644
>> >> index 0000000..8e2d425
>> >> --- /dev/null
>> >> +++ b/test/validation/odp_syne.c
>> >> @@ -0,0 +1,15 @@
>> >> +/* Copyright (c) 2014, Linaro Limited
>> >> + * All rights reserved.
>> >> + *
>> >> + * SPDX-License-Identifier:     BSD-3-Clause
>> >> + */
>> >> +
>> >> +#include "odp.h"
>> >
>> >
>> > This is from the system path
>> >
>> > #include <odp.h>
>> >
>> >>
>> >> +#include "odp_cunit_common.h"
>> >> +#include "odp_test_atomic.h"
>> >> +
>> >> +CU_SuiteInfo odp_testsuites[] = {
>> >> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
>> >> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
>> >> +       CU_SUITE_INFO_NULL,
>> >> +};
>> >> diff --git a/test/validation/syne/odp_test_atomic.c
>> >> b/test/validation/syne/odp_test_atomic.c
>> >> new file mode 100644
>> >> index 0000000..68d23f4
>> >> --- /dev/null
>> >> +++ b/test/validation/syne/odp_test_atomic.c
>> >> @@ -0,0 +1,258 @@
>> >> +/* Copyright (c) 2014, Linaro Limited
>> >> + * All rights reserved.
>> >> + *
>> >> + * SPDX-License-Identifier:     BSD-3-Clause
>> >> + */
>> >> +
>> >> +#include <string.h>
>> >> +#include "odp.h"
>> >> +#include "odp_cunit_common.h"
>> >> +
>> >> +static odp_atomic_u32_t a32u;
>> >> +static odp_atomic_u64_t a64u;
>> >> +
>> >> +
>> >> +#define ADD_SUB_CNT    5
>> >> +
>> >> +#define        CNT 10
>> >> +#define        U32_INIT_VAL    (1UL << 10)
>> >> +#define        U64_INIT_VAL    (1ULL << 33)
>> >> +
>> >> +
>> >> +static void test_atomic_inc_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_inc_u32(&a32u);
>> >> +}
>> >> +
>> >> +static void test_atomic_inc_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_inc_u64(&a64u);
>> >> +}
>> >> +
>> >> +static void test_atomic_dec_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_dec_u32(&a32u);
>> >> +}
>> >> +
>> >> +static void test_atomic_dec_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_dec_u64(&a64u);
>> >> +}
>> >> +static void test_atomic_fetch_inc_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_inc_u32(&a32u);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_inc_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_inc_u64(&a64u);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_dec_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_dec_u32(&a32u);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_dec_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_dec_u64(&a64u);
>> >> +}
>> >> +
>> >> +static void test_atomic_add_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
>> >> +}
>> >> +static void test_atomic_add_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_sub_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_sub_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_add_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_add_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>> >> +}
>> >> +static void test_atomic_fetch_sub_u32(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_sub_64(void)
>> >> +{
>> >> +       int i;
>> >> +
>> >> +       for (i = 0; i < CNT; i++)
>> >> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>> >> +}
>> >> +
>> >> +static void test_atomic_inc_dec_u32(void)
>> >> +{
>> >> +       test_atomic_inc_u32();
>> >> +       test_atomic_dec_u32();
>> >> +}
>> >> +
>> >> +static void test_atomic_inc_dec_64(void)
>> >> +{
>> >> +       test_atomic_inc_64();
>> >> +       test_atomic_dec_64();
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_inc_dec_u32(void)
>> >> +{
>> >> +       test_atomic_fetch_inc_u32();
>> >> +       test_atomic_fetch_dec_u32();
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_inc_dec_64(void)
>> >> +{
>> >> +       test_atomic_fetch_inc_64();
>> >> +       test_atomic_fetch_dec_64();
>> >> +}
>> >> +
>> >> +
>> >> +static void test_atomic_add_sub_u32(void)
>> >> +{
>> >> +       test_atomic_add_u32();
>> >> +       test_atomic_sub_u32();
>> >> +}
>> >> +
>> >> +
>> >> +static void test_atomic_add_sub_64(void)
>> >> +{
>> >> +       test_atomic_add_64();
>> >> +       test_atomic_sub_64();
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_add_sub_u32(void)
>> >> +{
>> >> +       test_atomic_fetch_add_u32();
>> >> +       test_atomic_fetch_sub_u32();
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_add_sub_64(void)
>> >> +{
>> >> +       test_atomic_fetch_add_64();
>> >> +       test_atomic_fetch_sub_64();
>> >> +}
>> >> +
>> >> +static void test_atomic_init(void)
>> >> +{
>> >> +       odp_atomic_init_u32(&a32u, 0);
>> >> +       odp_atomic_init_u64(&a64u, 0);
>> >> +}
>> >> +
>> >> +static void test_atomic_store(void)
>> >> +{
>> >> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>> >> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>> >> +}
>> >> +
>> >> +static void test_atomic_validate(void)
>> >> +{
>> >> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
>> >> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
>> >> +}
>> >> +static void test_atomic_basic(void)
>> >> +{
>> >> +       test_atomic_init();
>> >> +       test_atomic_store();
>> >> +       test_atomic_validate();
>> >> +}
>> >> +static void test_atomic_inc_dec(void)
>> >> +{
>> >> +       test_atomic_store();
>> >> +       test_atomic_inc_dec_u32();
>> >> +       test_atomic_inc_dec_64();
>> >> +       test_atomic_validate();
>> >> +}
>> >> +
>> >> +static void test_atomic_fetch_inc_dec(void)
>> >> +{
>> >> +       test_atomic_store();
>> >> +       test_atomic_fetch_inc_dec_u32();
>> >> +       test_atomic_fetch_inc_dec_64();
>> >> +       test_atomic_validate();
>> >> +}
>> >> +
>> >> +static void test_atomic_add_sub(void)
>> >> +{
>> >> +       test_atomic_store();
>> >> +       test_atomic_add_sub_u32();
>> >> +       test_atomic_add_sub_64();
>> >> +       test_atomic_validate();
>> >> +}
>> >> +static void test_atomic_fetch_add_sub(void)
>> >> +{
>> >> +       test_atomic_store();
>> >> +       test_atomic_fetch_add_sub_u32();
>> >> +       test_atomic_fetch_add_sub_64();
>> >> +       test_atomic_validate();
>> >> +}
>> >> +
>> >> +CU_TestInfo test_odp_atomic[] = {
>> >> +       {"test_odp_atomic_basic",    test_atomic_basic},
>> >> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
>> >> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},
>> >> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
>> >> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
>> >> +       CU_TEST_INFO_NULL,
>> >> +};
>> >> diff --git a/test/validation/syne/odp_test_atomic.h
>> >> b/test/validation/syne/odp_test_atomic.h
>> >> new file mode 100644
>> >> index 0000000..a51a26a
>> >> --- /dev/null
>> >> +++ b/test/validation/syne/odp_test_atomic.h
>> >> @@ -0,0 +1,14 @@
>> >> +/* Copyright (c) 2014, Linaro Limited
>> >> + * All rights reserved.
>> >> + *
>> >> + * SPDX-License-Identifier:    BSD-3-Clause
>> >> + */
>> >> +#ifndef ODP_TEST_ATOMIC_
>> >> +#define ODP_TEST_ATOMIC_
>> >> +
>> >> +#include "CUnit/TestDB.h"
>> >> +
>> >> +/* Suite test array */
>> >> +extern CU_TestInfo test_odp_atomic[];
>> >> +
>> >> +#endif
>> >> --
>> >> 1.8.3.1
>> >>
>> >>
>> >> _______________________________________________
>> >> lng-odp mailing list
>> >> lng-odp@lists.linaro.org
>> >> http://lists.linaro.org/mailman/listinfo/lng-odp
>> >
>> >
>> >
>> >
>> > --
>> > Mike Holmes
>> > Linaro  Sr Technical Manager
>> > LNG - ODP
>> >
>> > _______________________________________________
>> > lng-odp mailing list
>> > lng-odp@lists.linaro.org
>> > http://lists.linaro.org/mailman/listinfo/lng-odp
>> >
>>
>
>
>
> --
> *Mike Holmes*
> Linaro  Sr Technical Manager
> LNG - ODP
>
>
Ola Liljedahl Dec. 15, 2014, 10:42 a.m. UTC | #7
On 14 December 2014 at 12:12, Mario Torrecillas Rodriguez
<Mario.TorrecillasRodriguez@arm.com> wrote:
> I have combined both patches into a single one using Barry’s as the
> baseline. I need to fix a couple of minor issues that I have and do some
> cleanup but I’ll most likely send the patch tomorrow so that we can continue
> working on this unified set of synchroniser tests from now on.
> Like Mike said, there’s basically one test set per lock, one for barrier,
> and one for atomics, and they are all executed from a single application.
>
> We also need tests that exercise the atomic primitives using more than one
> thread so that race conditions can actually exist (in the presence of bugs
> in the library).
It would be useful if the lock tests actually protected something that
was read and written so we could verify that all barriers are in
place. The original implementations had some bugs...

-- Ola


>
> Mario.
>
> From: Mike Holmes <mike.holmes@linaro.org>
> Date: Friday, 12 December 2014 18:41
> To: "yan.songming@linaro.org" <yan.songming@linaro.org>
> Cc: spinney <spinney@ezchip.com>, lng-odp <lng-odp@lists.linaro.org>
> Subject: Re: [lng-odp] [PATCH] validation:add atomic test in odp
> syncronizers
>
> Synchronize with Mario, but we don't want to lose any extra functionality in
> combining all the work.
>
> I assume that test/validation/sync  (synchronizers)  will contain one test
> suite each for for atomics, rwlock, spin lock and ticket lock and all of
> those test suites will be called from a top level test/validation/odp_sync
> test.
>
> Mike
>
> On 12 December 2014 at 03:43, yan.songming@linaro.org
> <yan.songming@linaro.org> wrote:
>>
>> Mike,
>> I think Barry's patch is cover the lock, and my patch cover the atomic.
>>
>> But I still have some cards about the rwlock, spin lock and ticket lock.
>>
>> So ,should  I write a new one accord Barry's patch or just use his code
>> and change it suitable for our  sunny day test if necessary  ?
>> I prefer the second.
>>
>> Thanks,
>> Yan
>> ________________________________
>> yan.songming@linaro.org
>>
>>
>> From: Mike Holmes
>> Date: 2014-12-12 03:09
>> To: Ola Liljedahl
>> CC: Yan Sonming; Barry Spinney; lng-odp
>> Subject: Re: [lng-odp] [PATCH] validation:add atomic test in odp
>> syncronizers
>>
>>
>> On 11 December 2014 at 04:36, Ola Liljedahl <ola.liljedahl@linaro.org>
>> wrote:
>>>
>>> Are these cunit tests for odp_atomic.h only?
>>> Are there any cunit tests for plain spin locks, ticket locks, rwlocks
>>> etc?
>>
>>
>> Yes, Mario has Barrys code as the basis.
>>
>>>
>>>
>>> -- Ola
>>>
>>>
>>> On 10 December 2014 at 20:42, Mike Holmes <mike.holmes@linaro.org> wrote:
>>> > I think odp_syne would be better as odp_sync  throughout the patch
>>> >
>>> > Does Barrys patch cover atomics in an overlapping way, or do we have
>>> > both as
>>> > separate suites ? I think this one is much more sunny day as we had
>>> > originally planned.
>>> > Mario were you able to make the final changes to create a patch for tip
>>> > from
>>> > Barrys files, do we need to wait until we can see that patch along side
>>> > this
>>> > one ?
>>> >
>>> > Mike
>>> >
>>> >
>>> > On 9 December 2014 at 22:19, Yan Sonming <yan.songming@linaro.org>
>>> > wrote:
>>> >>
>>> >> Remove odp_atomic_test in test/api_test and  add the odp_atomic_test
>>> >> to test/validation as one part of odp syncronizers test
>>> >
>>> >
>>> > syncronizers
>>> >
>>> >>
>>> >>
>>> >> Signed-off-by: Yan Songming <yan.songming@linaro.org>
>>> >> ---
>>> >>  test/api_test/Makefile.am              |   5 +-
>>> >>  test/api_test/odp_atomic_test.c        | 299
>>> >> ---------------------------------
>>> >>  test/api_test/odp_atomic_test.h        |  51 ------
>>> >>  test/api_test/odp_common.c             |   1 -
>>> >>  test/validation/.gitignore             |   1 +
>>> >>  test/validation/Makefile.am            |   6 +-
>>> >>  test/validation/odp_syne.c             |  15 ++
>>> >>  test/validation/syne/odp_test_atomic.c | 258
>>> >> ++++++++++++++++++++++++++++
>>> >>  test/validation/syne/odp_test_atomic.h |  14 ++
>>> >>  9 files changed, 294 insertions(+), 356 deletions(-)
>>> >>  delete mode 100644 test/api_test/odp_atomic_test.c
>>> >>  delete mode 100644 test/api_test/odp_atomic_test.h
>>> >>  create mode 100644 test/validation/odp_syne.c
>>> >>  create mode 100644 test/validation/syne/odp_test_atomic.c
>>> >>  create mode 100644 test/validation/syne/odp_test_atomic.h
>>> >>
>>> >> diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
>>> >> index 74e8612..ce301ce 100644
>>> >> --- a/test/api_test/Makefile.am
>>> >> +++ b/test/api_test/Makefile.am
>>> >> @@ -1,18 +1,15 @@
>>> >>  include $(top_srcdir)/test/Makefile.inc
>>> >>
>>> >> -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
>>> >> +bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
>>> >>
>>> >> -odp_atomic_CFLAGS = $(AM_CFLAGS)
>>> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
>>> >>  odp_ring_CFLAGS = $(AM_CFLAGS)
>>> >>  odp_timer_ping_CFLAGS = $(AM_CFLAGS)
>>> >>
>>> >> -odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
>>> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
>>> >>  odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
>>> >>  odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
>>> >>
>>> >> -dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
>>> >>  dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
>>> >>  dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
>>> >>  dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
>>> >> diff --git a/test/api_test/odp_atomic_test.c
>>> >> b/test/api_test/odp_atomic_test.c
>>> >> deleted file mode 100644
>>> >> index 5563606..0000000
>>> >> --- a/test/api_test/odp_atomic_test.c
>>> >> +++ /dev/null
>>> >> @@ -1,299 +0,0 @@
>>> >> -/* Copyright (c) 2013, Linaro Limited
>>> >> - * All rights reserved.
>>> >> - *
>>> >> - * SPDX-License-Identifier:     BSD-3-Clause
>>> >> - */
>>> >> -
>>> >> -#include <string.h>
>>> >> -#include <sys/time.h>
>>> >> -#include <odp_common.h>
>>> >> -#include <odp_atomic_test.h>
>>> >> -#include <test_debug.h>
>>> >> -
>>> >> -static odp_atomic_u32_t a32u;
>>> >> -static odp_atomic_u64_t a64u;
>>> >> -
>>> >> -static odp_barrier_t barrier;
>>> >> -
>>> >> -static const char * const test_name[] = {
>>> >> -       "dummy",
>>> >> -       "test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic
>>> >> ints",
>>> >> -       "test atomic inc/dec of 32-bit atomic int",
>>> >> -       "test atomic add/sub of 32-bit atomic int",
>>> >> -       "test atomic inc/dec of 64-bit atomic int",
>>> >> -       "test atomic add/sub of 64-bit atomic int"
>>> >> -};
>>> >> -
>>> >> -static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
>>> >> -
>>> >> -static void usage(void)
>>> >> -{
>>> >> -       printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
>>> >> -              "\t<testcase> is\n"
>>> >> -              "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic
>>> >> ints)\n"
>>> >> -              "\t\t2 - Test inc/dec of 32-bit atomic int\n"
>>> >> -              "\t\t3 - Test add/sub of 32-bit atomic int\n"
>>> >> -              "\t\t4 - Test inc/dec of 64-bit atomic int\n"
>>> >> -              "\t\t5 - Test add/sub of 64-bit atomic int\n"
>>> >> -              "\t\t-n <1 - 31> - no of threads to start\n"
>>> >> -              "\t\tif user doesn't specify this option, then\n"
>>> >> -              "\t\tno of threads created is equivalent to no of
>>> >> cores\n"
>>> >> -              "\t\tavailable in the system\n"
>>> >> -              "\tExample usage:\n"
>>> >> -              "\t\t./odp_atomic -t 2\n"
>>> >> -              "\t\t./odp_atomic -t 3 -n 12\n");
>>> >> -}
>>> >> -
>>> >> -
>>> >> -void test_atomic_inc_u32(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < CNT; i++)
>>> >> -               odp_atomic_inc_u32(&a32u);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_inc_64(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < CNT; i++)
>>> >> -               odp_atomic_inc_u64(&a64u);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_dec_u32(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < CNT; i++)
>>> >> -               odp_atomic_dec_u32(&a32u);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_dec_64(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < CNT; i++)
>>> >> -               odp_atomic_dec_u64(&a64u);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_add_u32(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>>> >> -               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_add_64(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>>> >> -               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_sub_u32(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>>> >> -               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_sub_64(void)
>>> >> -{
>>> >> -       int i;
>>> >> -
>>> >> -       for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
>>> >> -               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_inc_dec_u32(void)
>>> >> -{
>>> >> -       test_atomic_inc_u32();
>>> >> -       test_atomic_dec_u32();
>>> >> -}
>>> >> -
>>> >> -void test_atomic_add_sub_u32(void)
>>> >> -{
>>> >> -       test_atomic_add_u32();
>>> >> -       test_atomic_sub_u32();
>>> >> -}
>>> >> -
>>> >> -void test_atomic_inc_dec_64(void)
>>> >> -{
>>> >> -       test_atomic_inc_64();
>>> >> -       test_atomic_dec_64();
>>> >> -}
>>> >> -
>>> >> -void test_atomic_add_sub_64(void)
>>> >> -{
>>> >> -       test_atomic_add_64();
>>> >> -       test_atomic_sub_64();
>>> >> -}
>>> >> -
>>> >> -/**
>>> >> - * Test basic atomic operation like
>>> >> - * add/sub/increment/decrement operation.
>>> >> - */
>>> >> -void test_atomic_basic(void)
>>> >> -{
>>> >> -       test_atomic_inc_u32();
>>> >> -       test_atomic_dec_u32();
>>> >> -       test_atomic_add_u32();
>>> >> -       test_atomic_sub_u32();
>>> >> -
>>> >> -       test_atomic_inc_64();
>>> >> -       test_atomic_dec_64();
>>> >> -       test_atomic_add_64();
>>> >> -       test_atomic_sub_64();
>>> >> -}
>>> >> -
>>> >> -void test_atomic_init(void)
>>> >> -{
>>> >> -       odp_atomic_init_u32(&a32u, 0);
>>> >> -       odp_atomic_init_u64(&a64u, 0);
>>> >> -}
>>> >> -
>>> >> -void test_atomic_store(void)
>>> >> -{
>>> >> -       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>>> >> -       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>>> >> -}
>>> >> -
>>> >> -int test_atomic_validate(void)
>>> >> -{
>>> >> -       if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
>>> >> -               LOG_ERR("Atomic u32 usual functions failed\n");
>>> >> -               return -1;
>>> >> -       }
>>> >> -
>>> >> -       if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
>>> >> -               LOG_ERR("Atomic u64 usual functions failed\n");
>>> >> -               return -1;
>>> >> -       }
>>> >> -
>>> >> -       return 0;
>>> >> -}
>>> >> -
>>> >> -static void *run_thread(void *arg)
>>> >> -{
>>> >> -       pthrd_arg *parg = (pthrd_arg *)arg;
>>> >> -       int thr;
>>> >> -
>>> >> -       thr = odp_thread_id();
>>> >> -
>>> >> -       LOG_DBG("Thread %i starts\n", thr);
>>> >> -
>>> >> -       /* Wait here until all threads have arrived */
>>> >> -       /* Use multiple barriers to verify that it handles wrap around
>>> >> and
>>> >> -        * has no race conditions which could be exposed when invoked
>>> >> back-
>>> >> -        * to-back */
>>> >> -       odp_barrier_wait(&barrier);
>>> >> -       odp_barrier_wait(&barrier);
>>> >> -       odp_barrier_wait(&barrier);
>>> >> -       odp_barrier_wait(&barrier);
>>> >> -
>>> >> -       gettimeofday(&tv0[thr], NULL);
>>> >> -
>>> >> -       switch (parg->testcase) {
>>> >> -       case TEST_MIX:
>>> >> -               test_atomic_basic();
>>> >> -               break;
>>> >> -       case TEST_INC_DEC_U32:
>>> >> -               test_atomic_inc_dec_u32();
>>> >> -               break;
>>> >> -       case TEST_ADD_SUB_U32:
>>> >> -               test_atomic_add_sub_u32();
>>> >> -               break;
>>> >> -       case TEST_INC_DEC_64:
>>> >> -               test_atomic_inc_dec_64();
>>> >> -               break;
>>> >> -       case TEST_ADD_SUB_64:
>>> >> -               test_atomic_add_sub_64();
>>> >> -               break;
>>> >> -       }
>>> >> -       gettimeofday(&tv1[thr], NULL);
>>> >> -       fflush(NULL);
>>> >> -
>>> >> -       printf("Time taken in thread %02d to complete op is %lld
>>> >> usec\n",
>>> >> thr,
>>> >> -              (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
>>> >> -              (tv1[thr].tv_usec - tv0[thr].tv_usec));
>>> >> -
>>> >> -       return parg;
>>> >> -}
>>> >> -
>>> >> -int main(int argc, char *argv[])
>>> >> -{
>>> >> -       pthrd_arg thrdarg;
>>> >> -       int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
>>> >> -       char c;
>>> >> -       int result;
>>> >> -
>>> >> -       if (argc == 1 || argc % 2 == 0) {
>>> >> -               usage();
>>> >> -               goto err_exit;
>>> >> -       }
>>> >> -       if (odp_test_global_init() != 0)
>>> >> -               goto err_exit;
>>> >> -       odp_print_system_info();
>>> >> -
>>> >> -       while (cnt != 0) {
>>> >> -               sscanf(argv[++i], "-%c", &c);
>>> >> -               switch (c) {
>>> >> -               case 't':
>>> >> -                       sscanf(argv[++i], "%d", &test_type);
>>> >> -                       break;
>>> >> -               case 'n':
>>> >> -                       sscanf(argv[++i], "%d", &pthrdnum);
>>> >> -                       break;
>>> >> -               default:
>>> >> -                       LOG_ERR("Invalid option %c\n", c);
>>> >> -                       usage();
>>> >> -                       goto err_exit;
>>> >> -               }
>>> >> -               if (test_type < TEST_MIX || test_type > TEST_MAX ||
>>> >> -                   pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
>>> >> -                       usage();
>>> >> -                       goto err_exit;
>>> >> -               }
>>> >> -               cnt -= 2;
>>> >> -       }
>>> >> -
>>> >> -       if (pthrdnum == 0)
>>> >> -               pthrdnum = odp_sys_core_count();
>>> >> -
>>> >> -       test_atomic_init();
>>> >> -       test_atomic_store();
>>> >> -
>>> >> -       memset(&thrdarg, 0, sizeof(pthrd_arg));
>>> >> -       thrdarg.testcase = test_type;
>>> >> -       thrdarg.numthrds = pthrdnum;
>>> >> -
>>> >> -       if ((test_type > 0) && (test_type < TEST_MAX)) {
>>> >> -               printf("%s\n", test_name[test_type]);
>>> >> -       } else {
>>> >> -               LOG_ERR("Invalid test case [%d]\n", test_type);
>>> >> -               usage();
>>> >> -               goto err_exit;
>>> >> -       }
>>> >> -       odp_barrier_init(&barrier, pthrdnum);
>>> >> -       odp_test_thread_create(run_thread, &thrdarg);
>>> >> -
>>> >> -       odp_test_thread_exit(&thrdarg);
>>> >> -
>>> >> -       result = test_atomic_validate();
>>> >> -
>>> >> -       if (result == 0) {
>>> >> -               printf("%s_%d_%d Result:pass\n",
>>> >> -                      test_name[test_type], test_type, pthrdnum);
>>> >> -       } else {
>>> >> -               printf("%s_%d_%d Result:fail\n",
>>> >> -                      test_name[test_type], test_type, pthrdnum);
>>> >> -       }
>>> >> -       return 0;
>>> >> -
>>> >> -err_exit:
>>> >> -       return -1;
>>> >> -}
>>> >> diff --git a/test/api_test/odp_atomic_test.h
>>> >> b/test/api_test/odp_atomic_test.h
>>> >> deleted file mode 100644
>>> >> index aaa9d34..0000000
>>> >> --- a/test/api_test/odp_atomic_test.h
>>> >> +++ /dev/null
>>> >> @@ -1,51 +0,0 @@
>>> >> -/* Copyright (c) 2013, Linaro Limited
>>> >> - * All rights reserved.
>>> >> - *
>>> >> - * SPDX-License-Identifier:     BSD-3-Clause
>>> >> - */
>>> >> -
>>> >> -#ifndef ODP_ATOMIC_TEST_H_
>>> >> -#define ODP_ATOMIC_TEST_H_
>>> >> -
>>> >> -#include <odp.h>
>>> >> -#include <odph_linux.h>
>>> >> -
>>> >> -/**
>>> >> - * add_sub_cnt could be any valid value
>>> >> - * so to excercise explicit atomic_add/sub
>>> >> - * ops. For now using 5..
>>> >> - */
>>> >> -#define ADD_SUB_CNT    5
>>> >> -
>>> >> -#define        CNT 500000
>>> >> -#define        U32_INIT_VAL    (1UL << 10)
>>> >> -#define        U64_INIT_VAL    (1ULL << 33)
>>> >> -
>>> >> -typedef enum {
>>> >> -       TEST_MIX = 1, /* Must be first test case num */
>>> >> -       TEST_INC_DEC_U32,
>>> >> -       TEST_ADD_SUB_U32,
>>> >> -       TEST_INC_DEC_64,
>>> >> -       TEST_ADD_SUB_64,
>>> >> -       TEST_MAX,
>>> >> -} odp_test_atomic_t;
>>> >> -
>>> >> -
>>> >> -void test_atomic_inc_dec_u32(void);
>>> >> -void test_atomic_add_sub_u32(void);
>>> >> -void test_atomic_inc_dec_64(void);
>>> >> -void test_atomic_add_sub_64(void);
>>> >> -void test_atomic_inc_u32(void);
>>> >> -void test_atomic_dec_u32(void);
>>> >> -void test_atomic_add_u32(void);
>>> >> -void test_atomic_sub_u32(void);
>>> >> -void test_atomic_inc_64(void);
>>> >> -void test_atomic_dec_64(void);
>>> >> -void test_atomic_add_64(void);
>>> >> -void test_atomic_sub_64(void);
>>> >> -void test_atomic_init(void);
>>> >> -void test_atomic_basic(void);
>>> >> -void test_atomic_store(void);
>>> >> -int test_atomic_validate(void);
>>> >> -
>>> >> -#endif /* ODP_ATOMIC_TEST_H_ */
>>> >> diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
>>> >> index 329d4d4..11afb1f 100644
>>> >> --- a/test/api_test/odp_common.c
>>> >> +++ b/test/api_test/odp_common.c
>>> >> @@ -14,7 +14,6 @@
>>> >>  #include <odp.h>
>>> >>  #include <odph_linux.h>
>>> >>  #include <odp_common.h>
>>> >> -#include <odp_atomic_test.h>
>>> >>  #include <odp_shm_test.h>
>>> >>  #include <test_debug.h>
>>> >>
>>> >> diff --git a/test/validation/.gitignore b/test/validation/.gitignore
>>> >> index 37e2594..22c867a 100644
>>> >> --- a/test/validation/.gitignore
>>> >> +++ b/test/validation/.gitignore
>>> >> @@ -4,3 +4,4 @@ odp_init
>>> >>  odp_queue
>>> >>  odp_crypto
>>> >>  odp_shm
>>> >> +odp_syne
>>> >> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
>>> >> index 8547085..073e72b 100644
>>> >> --- a/test/validation/Makefile.am
>>> >> +++ b/test/validation/Makefile.am
>>> >> @@ -6,13 +6,15 @@ AM_LDFLAGS += -static
>>> >>  if ODP_CUNIT_ENABLED
>>> >>  TESTS = ${bin_PROGRAMS}
>>> >>  check_PROGRAMS = ${bin_PROGRAMS}
>>> >> -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
>>> >> +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
>>> >>  odp_init_LDFLAGS = $(AM_LDFLAGS)
>>> >>  odp_queue_LDFLAGS = $(AM_LDFLAGS)
>>> >>  odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
>>> >>  odp_crypto_LDFLAGS = $(AM_LDFLAGS)
>>> >>  odp_shm_CFLAGS = $(AM_CFLAGS)
>>> >>  odp_shm_LDFLAGS = $(AM_LDFLAGS)
>>> >> +odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
>>> >> +odp_syne_LDFLAGS = $(AM_LDFLAGS)
>>> >>  endif
>>> >>
>>> >>  dist_odp_init_SOURCES = odp_init.c
>>> >> @@ -22,3 +24,5 @@ dist_odp_crypto_SOURCES =
>>> >> crypto/odp_crypto_test_async_inp.c \
>>> >>                           crypto/odp_crypto_test_rng.c \
>>> >>                           odp_crypto.c common/odp_cunit_common.c
>>> >>  dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
>>> >> +dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
>>> >> +                     common/odp_cunit_common.c
>>> >> diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
>>> >> new file mode 100644
>>> >> index 0000000..8e2d425
>>> >> --- /dev/null
>>> >> +++ b/test/validation/odp_syne.c
>>> >> @@ -0,0 +1,15 @@
>>> >> +/* Copyright (c) 2014, Linaro Limited
>>> >> + * All rights reserved.
>>> >> + *
>>> >> + * SPDX-License-Identifier:     BSD-3-Clause
>>> >> + */
>>> >> +
>>> >> +#include "odp.h"
>>> >
>>> >
>>> > This is from the system path
>>> >
>>> > #include <odp.h>
>>> >
>>> >>
>>> >> +#include "odp_cunit_common.h"
>>> >> +#include "odp_test_atomic.h"
>>> >> +
>>> >> +CU_SuiteInfo odp_testsuites[] = {
>>> >> +       {"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
>>> >> +       /* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
>>> >> +       CU_SUITE_INFO_NULL,
>>> >> +};
>>> >> diff --git a/test/validation/syne/odp_test_atomic.c
>>> >> b/test/validation/syne/odp_test_atomic.c
>>> >> new file mode 100644
>>> >> index 0000000..68d23f4
>>> >> --- /dev/null
>>> >> +++ b/test/validation/syne/odp_test_atomic.c
>>> >> @@ -0,0 +1,258 @@
>>> >> +/* Copyright (c) 2014, Linaro Limited
>>> >> + * All rights reserved.
>>> >> + *
>>> >> + * SPDX-License-Identifier:     BSD-3-Clause
>>> >> + */
>>> >> +
>>> >> +#include <string.h>
>>> >> +#include "odp.h"
>>> >> +#include "odp_cunit_common.h"
>>> >> +
>>> >> +static odp_atomic_u32_t a32u;
>>> >> +static odp_atomic_u64_t a64u;
>>> >> +
>>> >> +
>>> >> +#define ADD_SUB_CNT    5
>>> >> +
>>> >> +#define        CNT 10
>>> >> +#define        U32_INIT_VAL    (1UL << 10)
>>> >> +#define        U64_INIT_VAL    (1ULL << 33)
>>> >> +
>>> >> +
>>> >> +static void test_atomic_inc_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_inc_u32(&a32u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_inc_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_inc_u64(&a64u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_dec_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_dec_u32(&a32u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_dec_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_dec_u64(&a64u);
>>> >> +}
>>> >> +static void test_atomic_fetch_inc_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_inc_u32(&a32u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_inc_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_inc_u64(&a64u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_dec_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_dec_u32(&a32u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_dec_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_dec_u64(&a64u);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_add_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
>>> >> +}
>>> >> +static void test_atomic_add_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_sub_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_sub_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_add_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_add_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
>>> >> +}
>>> >> +static void test_atomic_fetch_sub_u32(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_sub_64(void)
>>> >> +{
>>> >> +       int i;
>>> >> +
>>> >> +       for (i = 0; i < CNT; i++)
>>> >> +               odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_inc_dec_u32(void)
>>> >> +{
>>> >> +       test_atomic_inc_u32();
>>> >> +       test_atomic_dec_u32();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_inc_dec_64(void)
>>> >> +{
>>> >> +       test_atomic_inc_64();
>>> >> +       test_atomic_dec_64();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_inc_dec_u32(void)
>>> >> +{
>>> >> +       test_atomic_fetch_inc_u32();
>>> >> +       test_atomic_fetch_dec_u32();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_inc_dec_64(void)
>>> >> +{
>>> >> +       test_atomic_fetch_inc_64();
>>> >> +       test_atomic_fetch_dec_64();
>>> >> +}
>>> >> +
>>> >> +
>>> >> +static void test_atomic_add_sub_u32(void)
>>> >> +{
>>> >> +       test_atomic_add_u32();
>>> >> +       test_atomic_sub_u32();
>>> >> +}
>>> >> +
>>> >> +
>>> >> +static void test_atomic_add_sub_64(void)
>>> >> +{
>>> >> +       test_atomic_add_64();
>>> >> +       test_atomic_sub_64();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_add_sub_u32(void)
>>> >> +{
>>> >> +       test_atomic_fetch_add_u32();
>>> >> +       test_atomic_fetch_sub_u32();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_add_sub_64(void)
>>> >> +{
>>> >> +       test_atomic_fetch_add_64();
>>> >> +       test_atomic_fetch_sub_64();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_init(void)
>>> >> +{
>>> >> +       odp_atomic_init_u32(&a32u, 0);
>>> >> +       odp_atomic_init_u64(&a64u, 0);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_store(void)
>>> >> +{
>>> >> +       odp_atomic_store_u32(&a32u, U32_INIT_VAL);
>>> >> +       odp_atomic_store_u64(&a64u, U64_INIT_VAL);
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_validate(void)
>>> >> +{
>>> >> +       CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
>>> >> +       CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
>>> >> +}
>>> >> +static void test_atomic_basic(void)
>>> >> +{
>>> >> +       test_atomic_init();
>>> >> +       test_atomic_store();
>>> >> +       test_atomic_validate();
>>> >> +}
>>> >> +static void test_atomic_inc_dec(void)
>>> >> +{
>>> >> +       test_atomic_store();
>>> >> +       test_atomic_inc_dec_u32();
>>> >> +       test_atomic_inc_dec_64();
>>> >> +       test_atomic_validate();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_fetch_inc_dec(void)
>>> >> +{
>>> >> +       test_atomic_store();
>>> >> +       test_atomic_fetch_inc_dec_u32();
>>> >> +       test_atomic_fetch_inc_dec_64();
>>> >> +       test_atomic_validate();
>>> >> +}
>>> >> +
>>> >> +static void test_atomic_add_sub(void)
>>> >> +{
>>> >> +       test_atomic_store();
>>> >> +       test_atomic_add_sub_u32();
>>> >> +       test_atomic_add_sub_64();
>>> >> +       test_atomic_validate();
>>> >> +}
>>> >> +static void test_atomic_fetch_add_sub(void)
>>> >> +{
>>> >> +       test_atomic_store();
>>> >> +       test_atomic_fetch_add_sub_u32();
>>> >> +       test_atomic_fetch_add_sub_64();
>>> >> +       test_atomic_validate();
>>> >> +}
>>> >> +
>>> >> +CU_TestInfo test_odp_atomic[] = {
>>> >> +       {"test_odp_atomic_basic",    test_atomic_basic},
>>> >> +       {"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
>>> >> +       {"test_odp_atomic_add_sub",  test_atomic_add_sub},
>>> >> +       {"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
>>> >> +       {"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
>>> >> +       CU_TEST_INFO_NULL,
>>> >> +};
>>> >> diff --git a/test/validation/syne/odp_test_atomic.h
>>> >> b/test/validation/syne/odp_test_atomic.h
>>> >> new file mode 100644
>>> >> index 0000000..a51a26a
>>> >> --- /dev/null
>>> >> +++ b/test/validation/syne/odp_test_atomic.h
>>> >> @@ -0,0 +1,14 @@
>>> >> +/* Copyright (c) 2014, Linaro Limited
>>> >> + * All rights reserved.
>>> >> + *
>>> >> + * SPDX-License-Identifier:    BSD-3-Clause
>>> >> + */
>>> >> +#ifndef ODP_TEST_ATOMIC_
>>> >> +#define ODP_TEST_ATOMIC_
>>> >> +
>>> >> +#include "CUnit/TestDB.h"
>>> >> +
>>> >> +/* Suite test array */
>>> >> +extern CU_TestInfo test_odp_atomic[];
>>> >> +
>>> >> +#endif
>>> >> --
>>> >> 1.8.3.1
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> lng-odp mailing list
>>> >> lng-odp@lists.linaro.org
>>> >> http://lists.linaro.org/mailman/listinfo/lng-odp
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> > Mike Holmes
>>> > Linaro  Sr Technical Manager
>>> > LNG - ODP
>>> >
>>> > _______________________________________________
>>> > lng-odp mailing list
>>> > lng-odp@lists.linaro.org
>>> > http://lists.linaro.org/mailman/listinfo/lng-odp
>>> >
>>
>>
>>
>>
>> --
>> Mike Holmes
>> Linaro  Sr Technical Manager
>> LNG - ODP
>
>
>
> --
> Mike Holmes
> Linaro  Sr Technical Manager
> LNG - ODP
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
index 74e8612..ce301ce 100644
--- a/test/api_test/Makefile.am
+++ b/test/api_test/Makefile.am
@@ -1,18 +1,15 @@ 
 include $(top_srcdir)/test/Makefile.inc
 
-bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping
+bin_PROGRAMS = odp_shm odp_ring odp_timer_ping
 
-odp_atomic_CFLAGS = $(AM_CFLAGS)
 odp_shm_CFLAGS = $(AM_CFLAGS)
 odp_ring_CFLAGS = $(AM_CFLAGS)
 odp_timer_ping_CFLAGS = $(AM_CFLAGS)
 
-odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
 odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
 odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
 odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static
 
-dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c
 dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c
 dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c
 dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c
diff --git a/test/api_test/odp_atomic_test.c b/test/api_test/odp_atomic_test.c
deleted file mode 100644
index 5563606..0000000
--- a/test/api_test/odp_atomic_test.c
+++ /dev/null
@@ -1,299 +0,0 @@ 
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#include <string.h>
-#include <sys/time.h>
-#include <odp_common.h>
-#include <odp_atomic_test.h>
-#include <test_debug.h>
-
-static odp_atomic_u32_t a32u;
-static odp_atomic_u64_t a64u;
-
-static odp_barrier_t barrier;
-
-static const char * const test_name[] = {
-	"dummy",
-	"test atomic all (add/sub/inc/dec) on 32- and 64-bit atomic ints",
-	"test atomic inc/dec of 32-bit atomic int",
-	"test atomic add/sub of 32-bit atomic int",
-	"test atomic inc/dec of 64-bit atomic int",
-	"test atomic add/sub of 64-bit atomic int"
-};
-
-static struct timeval tv0[MAX_WORKERS], tv1[MAX_WORKERS];
-
-static void usage(void)
-{
-	printf("\n./odp_atomic -t <testcase> [-n <numthreads>]\n\n"
-	       "\t<testcase> is\n"
-	       "\t\t1 - Test all (inc/dec/add/sub on 32/64-bit atomic ints)\n"
-	       "\t\t2 - Test inc/dec of 32-bit atomic int\n"
-	       "\t\t3 - Test add/sub of 32-bit atomic int\n"
-	       "\t\t4 - Test inc/dec of 64-bit atomic int\n"
-	       "\t\t5 - Test add/sub of 64-bit atomic int\n"
-	       "\t\t-n <1 - 31> - no of threads to start\n"
-	       "\t\tif user doesn't specify this option, then\n"
-	       "\t\tno of threads created is equivalent to no of cores\n"
-	       "\t\tavailable in the system\n"
-	       "\tExample usage:\n"
-	       "\t\t./odp_atomic -t 2\n"
-	       "\t\t./odp_atomic -t 3 -n 12\n");
-}
-
-
-void test_atomic_inc_u32(void)
-{
-	int i;
-
-	for (i = 0; i < CNT; i++)
-		odp_atomic_inc_u32(&a32u);
-}
-
-void test_atomic_inc_64(void)
-{
-	int i;
-
-	for (i = 0; i < CNT; i++)
-		odp_atomic_inc_u64(&a64u);
-}
-
-void test_atomic_dec_u32(void)
-{
-	int i;
-
-	for (i = 0; i < CNT; i++)
-		odp_atomic_dec_u32(&a32u);
-}
-
-void test_atomic_dec_64(void)
-{
-	int i;
-
-	for (i = 0; i < CNT; i++)
-		odp_atomic_dec_u64(&a64u);
-}
-
-void test_atomic_add_u32(void)
-{
-	int i;
-
-	for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
-		odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
-}
-
-void test_atomic_add_64(void)
-{
-	int i;
-
-	for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
-		odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
-}
-
-void test_atomic_sub_u32(void)
-{
-	int i;
-
-	for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
-		odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
-}
-
-void test_atomic_sub_64(void)
-{
-	int i;
-
-	for (i = 0; i < (CNT / ADD_SUB_CNT); i++)
-		odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
-}
-
-void test_atomic_inc_dec_u32(void)
-{
-	test_atomic_inc_u32();
-	test_atomic_dec_u32();
-}
-
-void test_atomic_add_sub_u32(void)
-{
-	test_atomic_add_u32();
-	test_atomic_sub_u32();
-}
-
-void test_atomic_inc_dec_64(void)
-{
-	test_atomic_inc_64();
-	test_atomic_dec_64();
-}
-
-void test_atomic_add_sub_64(void)
-{
-	test_atomic_add_64();
-	test_atomic_sub_64();
-}
-
-/**
- * Test basic atomic operation like
- * add/sub/increment/decrement operation.
- */
-void test_atomic_basic(void)
-{
-	test_atomic_inc_u32();
-	test_atomic_dec_u32();
-	test_atomic_add_u32();
-	test_atomic_sub_u32();
-
-	test_atomic_inc_64();
-	test_atomic_dec_64();
-	test_atomic_add_64();
-	test_atomic_sub_64();
-}
-
-void test_atomic_init(void)
-{
-	odp_atomic_init_u32(&a32u, 0);
-	odp_atomic_init_u64(&a64u, 0);
-}
-
-void test_atomic_store(void)
-{
-	odp_atomic_store_u32(&a32u, U32_INIT_VAL);
-	odp_atomic_store_u64(&a64u, U64_INIT_VAL);
-}
-
-int test_atomic_validate(void)
-{
-	if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) {
-		LOG_ERR("Atomic u32 usual functions failed\n");
-		return -1;
-	}
-
-	if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) {
-		LOG_ERR("Atomic u64 usual functions failed\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-static void *run_thread(void *arg)
-{
-	pthrd_arg *parg = (pthrd_arg *)arg;
-	int thr;
-
-	thr = odp_thread_id();
-
-	LOG_DBG("Thread %i starts\n", thr);
-
-	/* Wait here until all threads have arrived */
-	/* Use multiple barriers to verify that it handles wrap around and
-	 * has no race conditions which could be exposed when invoked back-
-	 * to-back */
-	odp_barrier_wait(&barrier);
-	odp_barrier_wait(&barrier);
-	odp_barrier_wait(&barrier);
-	odp_barrier_wait(&barrier);
-
-	gettimeofday(&tv0[thr], NULL);
-
-	switch (parg->testcase) {
-	case TEST_MIX:
-		test_atomic_basic();
-		break;
-	case TEST_INC_DEC_U32:
-		test_atomic_inc_dec_u32();
-		break;
-	case TEST_ADD_SUB_U32:
-		test_atomic_add_sub_u32();
-		break;
-	case TEST_INC_DEC_64:
-		test_atomic_inc_dec_64();
-		break;
-	case TEST_ADD_SUB_64:
-		test_atomic_add_sub_64();
-		break;
-	}
-	gettimeofday(&tv1[thr], NULL);
-	fflush(NULL);
-
-	printf("Time taken in thread %02d to complete op is %lld usec\n", thr,
-	       (tv1[thr].tv_sec - tv0[thr].tv_sec) * 1000000ULL +
-	       (tv1[thr].tv_usec - tv0[thr].tv_usec));
-
-	return parg;
-}
-
-int main(int argc, char *argv[])
-{
-	pthrd_arg thrdarg;
-	int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
-	char c;
-	int result;
-
-	if (argc == 1 || argc % 2 == 0) {
-		usage();
-		goto err_exit;
-	}
-	if (odp_test_global_init() != 0)
-		goto err_exit;
-	odp_print_system_info();
-
-	while (cnt != 0) {
-		sscanf(argv[++i], "-%c", &c);
-		switch (c) {
-		case 't':
-			sscanf(argv[++i], "%d", &test_type);
-			break;
-		case 'n':
-			sscanf(argv[++i], "%d", &pthrdnum);
-			break;
-		default:
-			LOG_ERR("Invalid option %c\n", c);
-			usage();
-			goto err_exit;
-		}
-		if (test_type < TEST_MIX || test_type > TEST_MAX ||
-		    pthrdnum > odp_sys_core_count() || pthrdnum < 0) {
-			usage();
-			goto err_exit;
-		}
-		cnt -= 2;
-	}
-
-	if (pthrdnum == 0)
-		pthrdnum = odp_sys_core_count();
-
-	test_atomic_init();
-	test_atomic_store();
-
-	memset(&thrdarg, 0, sizeof(pthrd_arg));
-	thrdarg.testcase = test_type;
-	thrdarg.numthrds = pthrdnum;
-
-	if ((test_type > 0) && (test_type < TEST_MAX)) {
-		printf("%s\n", test_name[test_type]);
-	} else {
-		LOG_ERR("Invalid test case [%d]\n", test_type);
-		usage();
-		goto err_exit;
-	}
-	odp_barrier_init(&barrier, pthrdnum);
-	odp_test_thread_create(run_thread, &thrdarg);
-
-	odp_test_thread_exit(&thrdarg);
-
-	result = test_atomic_validate();
-
-	if (result == 0) {
-		printf("%s_%d_%d Result:pass\n",
-		       test_name[test_type], test_type, pthrdnum);
-	} else {
-		printf("%s_%d_%d Result:fail\n",
-		       test_name[test_type], test_type, pthrdnum);
-	}
-	return 0;
-
-err_exit:
-	return -1;
-}
diff --git a/test/api_test/odp_atomic_test.h b/test/api_test/odp_atomic_test.h
deleted file mode 100644
index aaa9d34..0000000
--- a/test/api_test/odp_atomic_test.h
+++ /dev/null
@@ -1,51 +0,0 @@ 
-/* Copyright (c) 2013, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#ifndef ODP_ATOMIC_TEST_H_
-#define ODP_ATOMIC_TEST_H_
-
-#include <odp.h>
-#include <odph_linux.h>
-
-/**
- * add_sub_cnt could be any valid value
- * so to excercise explicit atomic_add/sub
- * ops. For now using 5..
- */
-#define ADD_SUB_CNT	5
-
-#define	CNT 500000
-#define	U32_INIT_VAL	(1UL << 10)
-#define	U64_INIT_VAL	(1ULL << 33)
-
-typedef enum {
-	TEST_MIX = 1, /* Must be first test case num */
-	TEST_INC_DEC_U32,
-	TEST_ADD_SUB_U32,
-	TEST_INC_DEC_64,
-	TEST_ADD_SUB_64,
-	TEST_MAX,
-} odp_test_atomic_t;
-
-
-void test_atomic_inc_dec_u32(void);
-void test_atomic_add_sub_u32(void);
-void test_atomic_inc_dec_64(void);
-void test_atomic_add_sub_64(void);
-void test_atomic_inc_u32(void);
-void test_atomic_dec_u32(void);
-void test_atomic_add_u32(void);
-void test_atomic_sub_u32(void);
-void test_atomic_inc_64(void);
-void test_atomic_dec_64(void);
-void test_atomic_add_64(void);
-void test_atomic_sub_64(void);
-void test_atomic_init(void);
-void test_atomic_basic(void);
-void test_atomic_store(void);
-int test_atomic_validate(void);
-
-#endif /* ODP_ATOMIC_TEST_H_ */
diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c
index 329d4d4..11afb1f 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -14,7 +14,6 @@ 
 #include <odp.h>
 #include <odph_linux.h>
 #include <odp_common.h>
-#include <odp_atomic_test.h>
 #include <odp_shm_test.h>
 #include <test_debug.h>
 
diff --git a/test/validation/.gitignore b/test/validation/.gitignore
index 37e2594..22c867a 100644
--- a/test/validation/.gitignore
+++ b/test/validation/.gitignore
@@ -4,3 +4,4 @@  odp_init
 odp_queue
 odp_crypto
 odp_shm
+odp_syne
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 8547085..073e72b 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -6,13 +6,15 @@  AM_LDFLAGS += -static
 if ODP_CUNIT_ENABLED
 TESTS = ${bin_PROGRAMS}
 check_PROGRAMS = ${bin_PROGRAMS}
-bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm
+bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_syne
 odp_init_LDFLAGS = $(AM_LDFLAGS)
 odp_queue_LDFLAGS = $(AM_LDFLAGS)
 odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto
 odp_crypto_LDFLAGS = $(AM_LDFLAGS)
 odp_shm_CFLAGS = $(AM_CFLAGS)
 odp_shm_LDFLAGS = $(AM_LDFLAGS)
+odp_syne_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/syne
+odp_syne_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
@@ -22,3 +24,5 @@  dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 			  crypto/odp_crypto_test_rng.c \
 			  odp_crypto.c common/odp_cunit_common.c
 dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c
+dist_odp_syne_SOURCES = odp_syne.c   syne/odp_test_atomic.c\
+                     common/odp_cunit_common.c
diff --git a/test/validation/odp_syne.c b/test/validation/odp_syne.c
new file mode 100644
index 0000000..8e2d425
--- /dev/null
+++ b/test/validation/odp_syne.c
@@ -0,0 +1,15 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "odp.h"
+#include "odp_cunit_common.h"
+#include "odp_test_atomic.h"
+
+CU_SuiteInfo odp_testsuites[] = {
+	{"ODP_ATOMIC", NULL, NULL, NULL, NULL, test_odp_atomic},
+	/* {"ODP_LOCK", NULL, NULL, NULL, NULL, test_odp_lock},*/
+	CU_SUITE_INFO_NULL,
+};
diff --git a/test/validation/syne/odp_test_atomic.c b/test/validation/syne/odp_test_atomic.c
new file mode 100644
index 0000000..68d23f4
--- /dev/null
+++ b/test/validation/syne/odp_test_atomic.c
@@ -0,0 +1,258 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <string.h>
+#include "odp.h"
+#include "odp_cunit_common.h"
+
+static odp_atomic_u32_t a32u;
+static odp_atomic_u64_t a64u;
+
+
+#define ADD_SUB_CNT	5
+
+#define	CNT 10
+#define	U32_INIT_VAL	(1UL << 10)
+#define	U64_INIT_VAL	(1ULL << 33)
+
+
+static void test_atomic_inc_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_inc_u32(&a32u);
+}
+
+static void test_atomic_inc_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_inc_u64(&a64u);
+}
+
+static void test_atomic_dec_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_dec_u32(&a32u);
+}
+
+static void test_atomic_dec_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_dec_u64(&a64u);
+}
+static void test_atomic_fetch_inc_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_inc_u32(&a32u);
+}
+
+static void test_atomic_fetch_inc_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_inc_u64(&a64u);
+}
+
+static void test_atomic_fetch_dec_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_dec_u32(&a32u);
+}
+
+static void test_atomic_fetch_dec_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_dec_u64(&a64u);
+}
+
+static void test_atomic_add_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_add_u32(&a32u, ADD_SUB_CNT);
+}
+static void test_atomic_add_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_add_u64(&a64u, ADD_SUB_CNT);
+}
+
+static void test_atomic_sub_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_sub_u32(&a32u, ADD_SUB_CNT);
+}
+
+static void test_atomic_sub_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_sub_u64(&a64u, ADD_SUB_CNT);
+}
+
+static void test_atomic_fetch_add_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT);
+}
+
+static void test_atomic_fetch_add_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT);
+}
+static void test_atomic_fetch_sub_u32(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT);
+}
+
+static void test_atomic_fetch_sub_64(void)
+{
+	int i;
+
+	for (i = 0; i < CNT; i++)
+		odp_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT);
+}
+
+static void test_atomic_inc_dec_u32(void)
+{
+	test_atomic_inc_u32();
+	test_atomic_dec_u32();
+}
+
+static void test_atomic_inc_dec_64(void)
+{
+	test_atomic_inc_64();
+	test_atomic_dec_64();
+}
+
+static void test_atomic_fetch_inc_dec_u32(void)
+{
+	test_atomic_fetch_inc_u32();
+	test_atomic_fetch_dec_u32();
+}
+
+static void test_atomic_fetch_inc_dec_64(void)
+{
+	test_atomic_fetch_inc_64();
+	test_atomic_fetch_dec_64();
+}
+
+
+static void test_atomic_add_sub_u32(void)
+{
+	test_atomic_add_u32();
+	test_atomic_sub_u32();
+}
+
+
+static void test_atomic_add_sub_64(void)
+{
+	test_atomic_add_64();
+	test_atomic_sub_64();
+}
+
+static void test_atomic_fetch_add_sub_u32(void)
+{
+	test_atomic_fetch_add_u32();
+	test_atomic_fetch_sub_u32();
+}
+
+static void test_atomic_fetch_add_sub_64(void)
+{
+	test_atomic_fetch_add_64();
+	test_atomic_fetch_sub_64();
+}
+
+static void test_atomic_init(void)
+{
+	odp_atomic_init_u32(&a32u, 0);
+	odp_atomic_init_u64(&a64u, 0);
+}
+
+static void test_atomic_store(void)
+{
+	odp_atomic_store_u32(&a32u, U32_INIT_VAL);
+	odp_atomic_store_u64(&a64u, U64_INIT_VAL);
+}
+
+static void test_atomic_validate(void)
+{
+	CU_ASSERT(U32_INIT_VAL == odp_atomic_load_u32(&a32u));
+	CU_ASSERT(U64_INIT_VAL == odp_atomic_load_u64(&a64u));
+}
+static void test_atomic_basic(void)
+{
+	test_atomic_init();
+	test_atomic_store();
+	test_atomic_validate();
+}
+static void test_atomic_inc_dec(void)
+{
+	test_atomic_store();
+	test_atomic_inc_dec_u32();
+	test_atomic_inc_dec_64();
+	test_atomic_validate();
+}
+
+static void test_atomic_fetch_inc_dec(void)
+{
+	test_atomic_store();
+	test_atomic_fetch_inc_dec_u32();
+	test_atomic_fetch_inc_dec_64();
+	test_atomic_validate();
+}
+
+static void test_atomic_add_sub(void)
+{
+	test_atomic_store();
+	test_atomic_add_sub_u32();
+	test_atomic_add_sub_64();
+	test_atomic_validate();
+}
+static void test_atomic_fetch_add_sub(void)
+{
+	test_atomic_store();
+	test_atomic_fetch_add_sub_u32();
+	test_atomic_fetch_add_sub_64();
+	test_atomic_validate();
+}
+
+CU_TestInfo test_odp_atomic[] = {
+	{"test_odp_atomic_basic",    test_atomic_basic},
+	{"test_odp_atomic_inc_dec",  test_atomic_inc_dec},
+	{"test_odp_atomic_add_sub",  test_atomic_add_sub},
+	{"test_odp_atomic_fetch_inc_dec",  test_atomic_fetch_inc_dec},
+	{"test_odp_atomic_fetch_add_sub",  test_atomic_fetch_add_sub},
+	CU_TEST_INFO_NULL,
+};
diff --git a/test/validation/syne/odp_test_atomic.h b/test/validation/syne/odp_test_atomic.h
new file mode 100644
index 0000000..a51a26a
--- /dev/null
+++ b/test/validation/syne/odp_test_atomic.h
@@ -0,0 +1,14 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:	BSD-3-Clause
+ */
+#ifndef ODP_TEST_ATOMIC_
+#define ODP_TEST_ATOMIC_
+
+#include "CUnit/TestDB.h"
+
+/* Suite test array */
+extern CU_TestInfo test_odp_atomic[];
+
+#endif