From patchwork Fri Mar 20 18:19:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 46154 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 029DB21418 for ; Fri, 20 Mar 2015 18:20:01 +0000 (UTC) Received: by wggy19 with SMTP id y19sf18608481wgg.2 for ; Fri, 20 Mar 2015 11:20:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=EyDg5JmH4LJvH63sajPVJGo+37DEXe8UHegs6TTlJRE=; b=aDOMIHVbzO9J7b64jkZIBaPr74ONSKK3BfE1a3ZfsnbZrk1d5BFj8PwP/YGKZiqhoS ppdl35/ymX9EIGSdRgmngMkEA3ZspVeMw2M1O7ZsdZ6nCI8iIgesyWsy0H1UdZzQMbRG wl2FI9SV+y/i0ahL3O+HuBZnDIRjVGshRB6BIn3ERNhKsuKB0LZNWVAm80qCvEfrMcr9 8UWnWT9ucJqfU2ot42ctxZLOOxcYt9OVV/X06w0830nysjyk1vviIVMNR8QFjjVwoWnW BGI+fcW5HELIf9lxw4TXfRdTviUTpQEVRUso7xk82qTSy6cjxhw8Eo0I2w/tIbam8atx s3Hw== X-Gm-Message-State: ALoCoQlNLL3qR9r+jM4RBLzEPIHPcs7WJV8EmQKu5aEhFp4bYl/LJxCSB3PuJLFyYvbo2szBT57k X-Received: by 10.180.11.34 with SMTP id n2mr929837wib.2.1426875601319; Fri, 20 Mar 2015 11:20:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.2 with SMTP id ci2ls437173lad.38.gmail; Fri, 20 Mar 2015 11:20:01 -0700 (PDT) X-Received: by 10.152.120.134 with SMTP id lc6mr72881259lab.72.1426875601122; Fri, 20 Mar 2015 11:20:01 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id k3si3685804lak.38.2015.03.20.11.20.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2015 11:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbsy1 with SMTP id sy1so81310788lbb.1 for ; Fri, 20 Mar 2015 11:20:01 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr54090556lbc.35.1426875600942; Fri, 20 Mar 2015 11:20:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp212222lbj; Fri, 20 Mar 2015 11:20:00 -0700 (PDT) X-Received: by 10.55.31.89 with SMTP id f86mr92398524qkf.26.1426875599292; Fri, 20 Mar 2015 11:19:59 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 91si4989443qky.84.2015.03.20.11.19.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 20 Mar 2015 11:19:59 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YZ1WV-000264-NA; Fri, 20 Mar 2015 18:19:55 +0000 Received: from mail-qc0-f178.google.com ([209.85.216.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YZ1WQ-00025e-C0 for lng-odp@lists.linaro.org; Fri, 20 Mar 2015 18:19:50 +0000 Received: by qcbjx9 with SMTP id jx9so61610290qcb.0 for ; Fri, 20 Mar 2015 11:19:45 -0700 (PDT) X-Received: by 10.140.92.234 with SMTP id b97mr21732012qge.69.1426875585150; Fri, 20 Mar 2015 11:19:45 -0700 (PDT) Received: from mike-desktop.?.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id b66sm3511778qkb.38.2015.03.20.11.19.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Mar 2015 11:19:44 -0700 (PDT) From: Mike Holmes To: maxim.uvraov@linaro.org Date: Fri, 20 Mar 2015 14:19:38 -0400 Message-Id: <1426875578-6724-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCH v3] performance: odp_atomic: move atomic test from api_test to performance X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Reviewed-by: Bill Fischofer --- test/api_test/.gitignore | 1 - test/api_test/Makefile.am | 6 +- test/api_test/odp_atomic_test.h | 51 -------- test/api_test/odp_common.c | 2 +- test/performance/.gitignore | 1 + test/performance/Makefile.am | 5 +- .../odp_atomic_test.c => performance/odp_atomic.c} | 136 ++++++++++++++++++++- 7 files changed, 138 insertions(+), 64 deletions(-) delete mode 100644 test/api_test/odp_atomic_test.h rename test/{api_test/odp_atomic_test.c => performance/odp_atomic.c} (63%) diff --git a/test/api_test/.gitignore b/test/api_test/.gitignore index 84159e1..950f443 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 86e1bc2..f231fee 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 89e7748..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 -#include - -/** - * 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 5158d87..18b365e 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -14,10 +14,10 @@ #include #include #include -#include #include #include +#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 9ccb102..1bdb90d 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 54cf529..b0f7457 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 similarity index 63% rename from test/api_test/odp_atomic_test.c rename to test/performance/odp_atomic.c index 6ccdc35..241295c 100644 --- a/test/api_test/odp_atomic_test.c +++ b/test/performance/odp_atomic.c @@ -6,14 +6,68 @@ #include #include -#include -#include #include +#include +#include + +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; } + +