From patchwork Tue Mar 17 20:59:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 45902 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0EC821547 for ; Tue, 17 Mar 2015 21:00:26 +0000 (UTC) Received: by labgq15 with SMTP id gq15sf3973591lab.0 for ; Tue, 17 Mar 2015 14:00:25 -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:in-reply-to :references: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=5UGfNugm780hBT/HjbBL9vVWWzf+qncqI81a0TXYFWU=; b=b9jr2rgtZIntGxEireWZZnwRvypCLidcy2iPrA+cDlS1l52MTWSqlPjZmQZkeXWF7D ogUFVdoOkoqwGLvi1WtwBk4UKcce3fvLrXWwC8lZdXMt1d0PJ9KBJIPRZW+OmRzaA6kw IeaAlsV7WXU9LBYLyOKbOTLJ2Svby16rhSAjbzndfkuF/eyW/3swbVKACb5DxzeyxoY3 vDgblqhlf/SXi3KDWnX6tKMbtK+Q9Mx0yPvJf6IRIF31x/OFFTJQ+QDLcsJlEm1Ls0rw NvX/zbKO99opU75vu2W8SU37RlV6Rty9Vr2LhqDXxIk3IoqCDXcz1W7anWtpa008tChD 68CQ== X-Gm-Message-State: ALoCoQkQFv4iN+uFTBZNNmG+vcbc3I7X4bPy0pmeqzvjBbXMA5AspXayWftlI0+f50EDnPTYC1lm X-Received: by 10.112.40.81 with SMTP id v17mr6472927lbk.5.1426626025761; Tue, 17 Mar 2015 14:00:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls95488lat.83.gmail; Tue, 17 Mar 2015 14:00:25 -0700 (PDT) X-Received: by 10.152.5.170 with SMTP id t10mr61235886lat.43.1426626025603; Tue, 17 Mar 2015 14:00:25 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id cy2si11391876lac.174.2015.03.17.14.00.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Mar 2015 14:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbsy1 with SMTP id sy1so16305498lbb.1 for ; Tue, 17 Mar 2015 14:00:25 -0700 (PDT) X-Received: by 10.152.22.67 with SMTP id b3mr60415812laf.117.1426626025435; Tue, 17 Mar 2015 14:00:25 -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 h5csp759590lbj; Tue, 17 Mar 2015 14:00:24 -0700 (PDT) X-Received: by 10.140.232.197 with SMTP id d188mr88075218qhc.80.1426626022430; Tue, 17 Mar 2015 14:00:22 -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 a1si14575400qco.31.2015.03.17.14.00.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Mar 2015 14:00:22 -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 1YXyb4-0002rp-UX; Tue, 17 Mar 2015 21:00:18 +0000 Received: from mail-qc0-f172.google.com ([209.85.216.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YXyav-0002rN-9F for lng-odp@lists.linaro.org; Tue, 17 Mar 2015 21:00:09 +0000 Received: by qcaz10 with SMTP id z10so21242768qca.1 for ; Tue, 17 Mar 2015 14:00:04 -0700 (PDT) X-Received: by 10.140.40.203 with SMTP id x69mr82936509qgx.15.1426626004110; Tue, 17 Mar 2015 14:00:04 -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 l38sm10406632qkh.17.2015.03.17.14.00.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2015 14:00:03 -0700 (PDT) From: Mike Holmes To: ola.liljedahl@linaro.org Date: Tue, 17 Mar 2015 16:59:56 -0400 Message-Id: <1426625996-8864-2-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1426625996-8864-1-git-send-email-mike.holmes@linaro.org> References: <1426625996-8864-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCH] 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.180 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 Signed-off-by: Mike Holmes --- 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 | 6 +- .../odp_atomic_test.c => performance/odp_atomic.c} | 136 ++++++++++++++++++++- 7 files changed, 139 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 3be3721..63e4e23 100644 --- a/test/performance/Makefile.am +++ b/test/performance/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/test/Makefile.inc -EXECUTABLES = +EXECUTABLES = odp_atomic COMPILE_ONLY = odp_scheduling @@ -15,7 +15,11 @@ bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY) odp_scheduling_LDFLAGS = $(AM_LDFLAGS) -static odp_scheduling_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test +odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static +odp_atomic_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test + noinst_HEADERS = \ $(top_srcdir)/test/test_debug.h dist_odp_scheduling_SOURCES = odp_scheduling.c +dist_odp_atomic_SOURCES = odp_atomic.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; } + +