From patchwork Wed Apr 1 20:02:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 47088 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A957F21416 for ; Sat, 11 Apr 2015 10:04:18 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8819140lbc.1 for ; Sat, 11 Apr 2015 03:04:17 -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: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=Ch7wTVzYMVNtciIrb+uO11R2h1QtDp1/ArGpZmM9ogw=; b=YFLTkWSSXA4/VKr9bVKph39IPX9KVfaGJ2kARWCyLbEpi8Vk7N4nT080p2AhAgGL9O HeUGZ4XXTlWqNNWizpaoszKETiQdfnxNzEjhvJdqbcpEM2sxtXfKvqX/HYafcJ9j5bQf 1l1hpsos6r0UUDtp5oSbEvPHTecsxsHobdWOjzoYk/9EvHhsbUvR5c2d1KMI3VsLpAqx 4VuyiSYrFyG9K2sVoafTtycCmZv9472pORSMnHZN/XLHnub9hbK4dPJEwISk990QFoR0 ld+jAJOWwGkD8+E8/BRPmVU/DXEJiDUnSx35oSbjjyj7D3poyabKTIO8FBBVFbGZ5xlh KoFQ== X-Gm-Message-State: ALoCoQlBO9KSB935ADxpm/+YTU7inniwtgZXOlztJ7tXRZNPDqfMm5YseFKe0ozCZSBQaDTyXP2z X-Received: by 10.112.203.168 with SMTP id kr8mr899085lbc.10.1428746657362; Sat, 11 Apr 2015 03:04:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.9 with SMTP id 9ls563422laq.89.gmail; Sat, 11 Apr 2015 03:04:17 -0700 (PDT) X-Received: by 10.112.170.132 with SMTP id am4mr4973702lbc.89.1428746657088; Sat, 11 Apr 2015 03:04:17 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id qt5si3504811lbb.78.2015.04.11.03.04.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Apr 2015 03:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagv1 with SMTP id v1so28340276lag.3 for ; Sat, 11 Apr 2015 03:04:16 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr4916701lbc.117.1428746656639; Sat, 11 Apr 2015 03:04:16 -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.67.65 with SMTP id l1csp234174lbt; Sat, 11 Apr 2015 03:04:16 -0700 (PDT) X-Received: by 10.141.28.70 with SMTP id f67mr7076692qhe.0.1428746655305; Sat, 11 Apr 2015 03:04:15 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l92si4370291qgf.83.2015.04.11.03.04.14; Sat, 11 Apr 2015 03:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 927E461C82; Sat, 11 Apr 2015 10:04:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 919DD65169; Sat, 11 Apr 2015 09:52:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: from mail-qg0-f54.google.com (mail-qg0-f54.google.com [209.85.192.54]) by lists.linaro.org (Postfix) with ESMTPS id AA33064FF3 for ; Wed, 1 Apr 2015 20:03:03 +0000 (UTC) Received: by qgep97 with SMTP id p97so52753929qge.1 for ; Wed, 01 Apr 2015 13:03:03 -0700 (PDT) X-Received: by 10.229.61.134 with SMTP id t6mr58546096qch.7.1427918583522; Wed, 01 Apr 2015 13:03:03 -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 186sm1974503qhd.11.2015.04.01.13.03.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 13:03:02 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Apr 2015 16:02:53 -0400 Message-Id: <1427918573-30596-3-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427918573-30596-1-git-send-email-mike.holmes@linaro.org> References: <1427918573-30596-1-git-send-email-mike.holmes@linaro.org> X-Topics: Architecture patch Subject: [lng-odp] [PATCH 3/3] linux-generic: use arch optimisations for time X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" 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.215.49 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 Switch to using configure time optimizations from compile time Signed-off-by: Mike Holmes --- platform/linux-generic/Makefile.am | 3 +- platform/linux-generic/odp_time.c | 64 -------------------------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index e5558ac..06d5998 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -167,4 +167,5 @@ __LIB__libodp_la_SOURCES = \ odp_time.c \ odp_timer.c \ odp_version.c \ - odp_weak.c + odp_weak.c \ + arch/@ARCH@/odp_time.c diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index 31d6656..a08833d 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -12,70 +12,6 @@ #define GIGA 1000000000 -#if defined __x86_64__ || defined __i386__ - -uint64_t odp_time_cycles(void) -{ - union { - uint64_t tsc_64; - struct { - uint32_t lo_32; - uint32_t hi_32; - }; - } tsc; - - __asm__ __volatile__ ("rdtsc" : - "=a" (tsc.lo_32), - "=d" (tsc.hi_32) : : "memory"); - - return tsc.tsc_64; -} - - -#elif defined __OCTEON__ - -uint64_t odp_time_cycles(void) -{ - #define CVMX_TMP_STR(x) CVMX_TMP_STR2(x) - #define CVMX_TMP_STR2(x) #x - uint64_t cycle; - - __asm__ __volatile__ ("rdhwr %[rt],$" CVMX_TMP_STR(31) : - [rt] "=d" (cycle) : : "memory"); - - return cycle; -} - -#else - -#include -#include -#include - -uint64_t odp_time_cycles(void) -{ - struct timespec time; - uint64_t sec, ns, hz, cycles; - int ret; - - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); - - if (ret != 0) { - ODP_ABORT("clock_gettime failed\n"); - } - - hz = odp_sys_cpu_hz(); - sec = (uint64_t) time.tv_sec; - ns = (uint64_t) time.tv_nsec; - - cycles = sec * hz; - cycles += (ns * hz) / GIGA; - - return cycles; -} - -#endif - uint64_t odp_time_diff_cycles(uint64_t t1, uint64_t t2) { if (odp_likely(t2 > t1))