From patchwork Mon Nov 24 22:38:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 41442 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 2AE8225E18 for ; Mon, 24 Nov 2014 22:39:54 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf5981345lam.10 for ; Mon, 24 Nov 2014 14:39:53 -0800 (PST) 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: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=SqAKAVUjUx9WA+H4u81+6o7Xi+Tm3oU9DioMrMFdmVU=; b=ArychXPFKFvsiimd7p9Y4umaNKnsVXCauW5ZxIGK37De4R/0Bprk7igJU0DAAVKW4d DHqcfeVceJtthw86XDfEw1u7a4avcIy247hk4CtenhVr+GqJFWJ2nE6l9L9K0lkvH7uH XQbkADjsw2+9qCrQgLw2Zkt0JZMxbwwuraaUQu2vw9vgyqcfXqbbskAFV4A3aq/RL10Y wYRiN31YaqKswIuJcBaD9n6gbqCFhowl/wNfC5YQrCC1T2w3dsYI/KCveWCSWmpERc2E pgud+vnYDc9L2zeUb5wasAo7ZFPbR5myBkNkyqOH6uxZRYjfPRiv+4P7k0lULdm7+p1F uyxg== X-Gm-Message-State: ALoCoQl77n8dI8eUT9Jb7XteZaWIxna/DqTtMW/eP5vRikeTEG68AKnglo9d4sbaiI+NCxeggeHY X-Received: by 10.112.166.102 with SMTP id zf6mr1236782lbb.12.1416868793143; Mon, 24 Nov 2014 14:39:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.134 with SMTP id s6ls408793las.27.gmail; Mon, 24 Nov 2014 14:39:52 -0800 (PST) X-Received: by 10.152.2.41 with SMTP id 9mr22326318lar.47.1416868792777; Mon, 24 Nov 2014 14:39:52 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id n4si16616584lan.14.2014.11.24.14.39.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 14:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id ge10so8454630lab.17 for ; Mon, 24 Nov 2014 14:39:52 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr22574015lbc.23.1416868792693; Mon, 24 Nov 2014 14:39:52 -0800 (PST) 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.184.201 with SMTP id ew9csp348204lbc; Mon, 24 Nov 2014 14:39:51 -0800 (PST) X-Received: by 10.52.81.129 with SMTP id a1mr11410683vdy.53.1416868791412; Mon, 24 Nov 2014 14:39:51 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y15si6928450vct.59.2014.11.24.14.39.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Nov 2014 14:39:51 -0800 (PST) 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 1Xt2IO-0007sa-Lo; Mon, 24 Nov 2014 22:39:48 +0000 Received: from mail-la0-f52.google.com ([209.85.215.52]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xt2Hm-0007mC-Dl for lng-odp@lists.linaro.org; Mon, 24 Nov 2014 22:39:10 +0000 Received: by mail-la0-f52.google.com with SMTP id q1so8343307lam.25 for ; Mon, 24 Nov 2014 14:39:04 -0800 (PST) X-Received: by 10.152.120.167 with SMTP id ld7mr22484340lab.77.1416868744872; Mon, 24 Nov 2014 14:39:04 -0800 (PST) Received: from macmini.lan (84-217-193-77.tn.glocalnet.net. [84.217.193.77]) by mx.google.com with ESMTPSA id pr9sm2952957lbc.12.2014.11.24.14.39.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Nov 2014 14:39:04 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 24 Nov 2014 23:38:48 +0100 Message-Id: <1416868730-26140-8-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1416868730-26140-1-git-send-email-ola.liljedahl@linaro.org> References: <1416868730-26140-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 7/9] test: odp_atomic_test.c: use odp_barrier, fix descriptions 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: ola.liljedahl@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.215.44 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: Ola Liljedahl --- Updated help texts and descriptions. Updated to use odp_barrier_t instead of homegrown thread barrier. test/api_test/odp_atomic_test.c | 44 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/test/api_test/odp_atomic_test.c b/test/api_test/odp_atomic_test.c index f07c962..553c447 100644 --- a/test/api_test/odp_atomic_test.c +++ b/test/api_test/odp_atomic_test.c @@ -13,32 +13,31 @@ static odp_atomic_u32_t a32u; static odp_atomic_u64_t a64u; -static odp_atomic_u32_t numthrds; +static odp_barrier_t barrier; static const char * const test_name[] = { "dummy", - "test atomic basic ops add/sub/inc/dec", - "test atomic inc/dec of unsigned word", - "test atomic add/sub of unsigned word", - "test atomic inc/dec of unsigned double word", - "test atomic add/sub of unsigned double word" + "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 -n ,\n\n" + printf("\n./odp_atomic -t [-n ]\n\n" "\t is\n" - "\t\t1 - Test mix(does inc,dec,add,sub on 32/64 bit)\n" - "\t\t2 - Test inc dec of unsigned word\n" - "\t\t3 - Test add sub of unsigned word\n" - "\t\t4 - Test inc dec of double word\n" - "\t\t5 - Test add sub of double word\n" - "\t is optional\n" - "\t\t<1 - 31> - no of pthreads to start\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 pthreads created is equivalent to no of cores\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" @@ -187,11 +186,14 @@ static void *run_thread(void *arg) ODP_DBG("Thread %i starts\n", thr); - odp_atomic_inc_u32(&numthrds); - - /* Wait here until all pthreads are created */ - while (*(volatile int *)&numthrds < parg->numthrds) - ; + /* 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); @@ -262,7 +264,6 @@ int main(int argc, char *argv[]) if (pthrdnum == 0) pthrdnum = odp_sys_core_count(); - odp_atomic_init_u32(&numthrds); test_atomic_init(); test_atomic_store(); @@ -277,6 +278,7 @@ int main(int argc, char *argv[]) usage(); goto err_exit; } + odp_barrier_init(&barrier, pthrdnum); odp_test_thread_create(run_thread, &thrdarg); odp_test_thread_exit(&thrdarg);