From patchwork Thu Mar 19 18:32:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 46074 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 070A02153C for ; Thu, 19 Mar 2015 18:33:12 +0000 (UTC) Received: by lbdu10 with SMTP id u10sf9563512lbd.3 for ; Thu, 19 Mar 2015 11:33:10 -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=YteD0n5/Z22t2iO+V1DuXZbuDXQPZcCH8x2yKoeAOFo=; b=h5Mi+S+LHNIWysdf0WyvHh3B1p66MwtYcNQObVNoThmGO0JwRIyj8OQJMraFjEsYWe AtZSY53enLDNNAe7zC2hmfmbAWF1WIJ3YBM6606JuSa6D87dchMG8Q6dtnMn2/SItmdL aLjXGM1kMeO3ZsQ4JNDUr2KTQIpFph4y0fCZH3btmwCfxE7le6MiKFd71lAn6xeR/iIJ 1zP3+Sm+p6eD7esqFC9WG1xLvhBUSJ+/I+ueIEqpvQbIMgCNVH8VkBJp0qhAyaAL6cXZ tnwLpUEheZVUokr0DKI0wfsL16VFu/2GukhKCcgrVJeNVYOdr7SZHHryXvSQeMHSAONP cIYg== X-Gm-Message-State: ALoCoQnnWzTqsLCUVZXGqq4rjoEf6y+CzLJYaEiEAcsuypiassq2EKySsvOLXvMbuzBogixQZNP5 X-Received: by 10.180.101.39 with SMTP id fd7mr1011489wib.0.1426789990941; Thu, 19 Mar 2015 11:33:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.211 with SMTP id jq19ls364564lab.32.gmail; Thu, 19 Mar 2015 11:33:10 -0700 (PDT) X-Received: by 10.152.37.164 with SMTP id z4mr25257850laj.5.1426789990632; Thu, 19 Mar 2015 11:33:10 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id uq10si1558373lbb.86.2015.03.19.11.33.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Mar 2015 11:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbblx11 with SMTP id lx11so37185135lbb.3 for ; Thu, 19 Mar 2015 11:33:10 -0700 (PDT) X-Received: by 10.152.26.201 with SMTP id n9mr69110551lag.29.1426789990463; Thu, 19 Mar 2015 11:33:10 -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 h5csp568511lbj; Thu, 19 Mar 2015 11:33:09 -0700 (PDT) X-Received: by 10.55.31.203 with SMTP id n72mr122466370qkh.30.1426789988628; Thu, 19 Mar 2015 11:33:08 -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 h198si1975421qhc.127.2015.03.19.11.33.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 19 Mar 2015 11:33:08 -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 1YYfFg-0007pd-7t; Thu, 19 Mar 2015 18:33:04 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YYfFa-0007pR-Iz for lng-odp@lists.linaro.org; Thu, 19 Mar 2015 18:32:58 +0000 Received: by qcto4 with SMTP id o4so74143940qct.3 for ; Thu, 19 Mar 2015 11:32:53 -0700 (PDT) X-Received: by 10.140.145.76 with SMTP id 73mr48910617qhr.19.1426789973386; Thu, 19 Mar 2015 11:32:53 -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 g34sm1374409qgd.0.2015.03.19.11.32.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2015 11:32:52 -0700 (PDT) From: Mike Holmes To: bill.fischofer@linaro.org Date: Thu, 19 Mar 2015 14:32:46 -0400 Message-Id: <1426789966-18939-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 v2] 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.173 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 | 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; } + +