aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Holmes <mike.holmes@linaro.org>2015-03-20 14:19:38 -0400
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-03-23 14:49:50 +0300
commit091463bc03c7b9572404c8d327deb34a0c0cd3ce (patch)
tree30c3a6ec3be216d620ff44a02ac2049c7b244480 /test
parent9c3e7f68c416fea0b820ff9644aa4195247f3e1d (diff)
performance: odp_atomic: move atomic test from api_test to performance
The api_test directory is being deleted, any test with value needs to migrate Moved this test to performance because it can be used to gauge the ability of the atomics to scale with core count. The move required that odp_atomic run all tests by default Signed-off-by: Mike Holmes <mike.holmes@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'test')
-rw-r--r--test/api_test/.gitignore1
-rw-r--r--test/api_test/Makefile.am6
-rw-r--r--test/api_test/odp_atomic_test.h51
-rw-r--r--test/api_test/odp_common.c2
-rw-r--r--test/performance/.gitignore1
-rw-r--r--test/performance/Makefile.am5
-rw-r--r--test/performance/odp_atomic.c (renamed from test/api_test/odp_atomic_test.c)136
7 files changed, 138 insertions, 64 deletions
diff --git a/test/api_test/.gitignore b/test/api_test/.gitignore
index 84159e13c..950f443f3 100644
--- a/test/api_test/.gitignore
+++ b/test/api_test/.gitignore
@@ -1,3 +1,2 @@
-odp_atomic
odp_ring
odp_shm
diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am
index 86e1bc250..f231fee05 100644
--- a/test/api_test/Makefile.am
+++ b/test/api_test/Makefile.am
@@ -1,21 +1,17 @@
include $(top_srcdir)/test/Makefile.inc
-bin_PROGRAMS = odp_atomic odp_shm odp_ring
+bin_PROGRAMS = odp_shm odp_ring
-odp_atomic_CFLAGS = $(AM_CFLAGS)
odp_shm_CFLAGS = $(AM_CFLAGS)
odp_ring_CFLAGS = $(AM_CFLAGS)
-odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
odp_shm_LDFLAGS = $(AM_LDFLAGS) -static
odp_ring_LDFLAGS = $(AM_LDFLAGS) -static
noinst_HEADERS = \
- $(top_srcdir)/test/api_test/odp_atomic_test.h \
$(top_srcdir)/test/api_test/odp_common.h \
$(top_srcdir)/test/api_test/odp_shm_test.h \
$(top_srcdir)/test/test_debug.h
-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
diff --git a/test/api_test/odp_atomic_test.h b/test/api_test/odp_atomic_test.h
deleted file mode 100644
index 89e774815..000000000
--- 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 <odp/helper/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 5158d8790..18b365ece 100644
--- a/test/api_test/odp_common.c
+++ b/test/api_test/odp_common.c
@@ -14,10 +14,10 @@
#include <odp.h>
#include <odp/helper/linux.h>
#include <odp_common.h>
-#include <odp_atomic_test.h>
#include <odp_shm_test.h>
#include <test_debug.h>
+#define MAX_WORKERS 32 /**< Max worker threads */
/* Globals */
static odph_linux_pthread_t thread_tbl[MAX_WORKERS]; /**< worker threads table*/
diff --git a/test/performance/.gitignore b/test/performance/.gitignore
index 9ccb102c5..1bdb90d2d 100644
--- a/test/performance/.gitignore
+++ b/test/performance/.gitignore
@@ -1,3 +1,4 @@
*.log
*.trs
odp_scheduling
+odp_atomic
diff --git a/test/performance/Makefile.am b/test/performance/Makefile.am
index 54cf5292e..b0f7457cc 100644
--- a/test/performance/Makefile.am
+++ b/test/performance/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/test/Makefile.inc
TESTS_ENVIRONMENT = TEST_DIR=${builddir}
-EXECUTABLES =
+EXECUTABLES = odp_atomic
COMPILE_ONLY = odp_scheduling
@@ -14,10 +14,13 @@ endif
bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY)
+odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static
+odp_atomic_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test
odp_scheduling_LDFLAGS = $(AM_LDFLAGS) -static
odp_scheduling_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test
noinst_HEADERS = \
$(top_srcdir)/test/test_debug.h
+dist_odp_atomic_SOURCES = odp_atomic.c
dist_odp_scheduling_SOURCES = odp_scheduling.c
diff --git a/test/api_test/odp_atomic_test.c b/test/performance/odp_atomic.c
index 6ccdc3558..241295c8d 100644
--- a/test/api_test/odp_atomic_test.c
+++ b/test/performance/odp_atomic.c
@@ -6,14 +6,68 @@
#include <string.h>
#include <sys/time.h>
-#include <odp_common.h>
-#include <odp_atomic_test.h>
#include <test_debug.h>
+#include <odp.h>
+#include <odp/helper/linux.h>
+
+static void test_atomic_inc_dec_u32(void);
+static void test_atomic_add_sub_u32(void);
+static void test_atomic_inc_dec_64(void);
+static void test_atomic_add_sub_64(void);
+static void test_atomic_inc_u32(void);
+static void test_atomic_dec_u32(void);
+static void test_atomic_add_u32(void);
+static void test_atomic_sub_u32(void);
+static void test_atomic_inc_64(void);
+static void test_atomic_dec_64(void);
+static void test_atomic_add_64(void);
+static void test_atomic_sub_64(void);
+static void test_atomic_init(void);
+static void test_atomic_basic(void);
+static void test_atomic_store(void);
+static int test_atomic_validate(void);
+static int odp_test_global_init(void);
+static void odp_print_system_info(void);
+
+/**
+ * Thread argument
+ */
+typedef struct {
+ int testcase; /**< specifies which set of API's to exercise */
+ int numthrds; /**< no of pthreads to create */
+} pthrd_arg;
+
+static int odp_test_thread_create(void *(*start_routine) (void *), pthrd_arg *);
+static int odp_test_thread_exit(pthrd_arg *);
+
+#define MAX_WORKERS 32 /**< Max worker threads */
+/**
+ * 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;
+
static odp_atomic_u32_t a32u;
static odp_atomic_u64_t a64u;
-
static odp_barrier_t barrier;
+static odph_linux_pthread_t thread_tbl[MAX_WORKERS]; /**< worker threads table*/
+static int num_workers; /**< number of workers >----*/
+
+
static const char * const test_name[] = {
"dummy",
@@ -224,17 +278,87 @@ static void *run_thread(void *arg)
return parg;
}
+/** create test thread */
+int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg)
+{
+ odp_cpumask_t cpumask;
+
+ /* Create and init additional threads */
+ odph_linux_cpumask_default(&cpumask, arg->numthrds);
+ odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr,
+ (void *)arg);
+
+ return 0;
+}
+
+/** exit from test thread */
+int odp_test_thread_exit(pthrd_arg *arg)
+{
+ /* Wait for other threads to exit */
+ odph_linux_pthread_join(thread_tbl, arg->numthrds);
+
+ return 0;
+}
+
+/** test init globals and call odp_init_global() */
+int odp_test_global_init(void)
+{
+ memset(thread_tbl, 0, sizeof(thread_tbl));
+
+ if (odp_init_global(NULL, NULL)) {
+ LOG_ERR("ODP global init failed.\n");
+ return -1;
+ }
+
+ num_workers = odp_cpu_count();
+ /* force to max CPU count */
+ if (num_workers > MAX_WORKERS)
+ num_workers = MAX_WORKERS;
+
+ return 0;
+}
+
+/**
+ * Print system information
+ */
+void odp_print_system_info(void)
+{
+ odp_cpumask_t cpumask;
+ char str[ODP_CPUMASK_STR_SIZE];
+
+ memset(str, 1, sizeof(str));
+
+ odp_cpumask_zero(&cpumask);
+
+ odp_cpumask_from_str(&cpumask, "0x1");
+ (void)odp_cpumask_to_str(&cpumask, str, sizeof(str));
+
+ printf("\n");
+ printf("ODP system info\n");
+ printf("---------------\n");
+ printf("ODP API version: %s\n", odp_version_api_str());
+ printf("CPU model: %s\n", odp_sys_cpu_model_str());
+ printf("CPU freq (hz): %"PRIu64"\n", odp_sys_cpu_hz());
+ printf("Cache line size: %i\n", odp_sys_cache_line_size());
+ printf("CPU count: %i\n", odp_cpu_count());
+ printf("CPU mask: %s\n", str);
+
+ printf("\n");
+}
+
+
int main(int argc, char *argv[])
{
pthrd_arg thrdarg;
- int test_type = 0, pthrdnum = 0, i = 0, cnt = argc - 1;
+ int test_type = 1, pthrdnum = 0, i = 0, cnt = argc - 1;
char c;
int result;
- if (argc == 1 || argc % 2 == 0) {
+ if (argc == 0 || argc % 2 == 0) {
usage();
goto err_exit;
}
+
if (odp_test_global_init() != 0)
goto err_exit;
odp_print_system_info();
@@ -297,3 +421,5 @@ int main(int argc, char *argv[])
err_exit:
return -1;
}
+
+