From patchwork Wed Jan 20 17:27:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 570813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B9AD5140271 for ; Thu, 21 Jan 2016 04:29:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=f1H1594s; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=mj84GEphGe+Das7L/ANn76Cq05vR0+G57uCUeJAoq4FkzH2sCkJ19 pDMfFu+Q6bM8yK32/KDSXatzWI0/3T4Q2q0AmRcAS0060/Tqv0Si1Nn3uEvHUoXG G/lFcmDg86cJD4wpNx+U8/12VGIP51ujEYnGUUENmsL7QRlMMHDMfI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references; s=default; bh=Df69KWnPZ23csgWzIiy5XaGO28A=; b=f1H1594sFU+Jn8anAST/LNEeLZQP 9OFTdL8lQyArsDbCP2Aeg3C6ZJVqYXwagzdjWrO2S0nfW/pkX69tlRjTZ+jgFtOj +MjZbWWW7mabFeUWA5ETtKp1W1jgzLPoOvNZKyNO3UARE6H4gpf5EMFDu21545ZU nz5L3RUZyqbXERs= Received: (qmail 3199 invoked by alias); 20 Jan 2016 17:27:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3002 invoked by uid 89); 20 Jan 2016 17:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_20, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=timer, Processing, Hx-languages-length:2113, explicitely X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 20 Jan 2016 17:27:17 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLwXK-0004PR-4f for gcc-patches@gcc.gnu.org; Wed, 20 Jan 2016 12:27:15 -0500 Received: from smtp.ispras.ru ([83.149.199.79]:35583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLwXJ-0004PB-Tk for gcc-patches@gcc.gnu.org; Wed, 20 Jan 2016 12:27:14 -0500 Received: from condor.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 1AB7420412 for ; Wed, 20 Jan 2016 20:27:08 +0300 (MSK) Received: by condor.intra.ispras.ru (Postfix, from userid 23246) id F21541225E0D; Wed, 20 Jan 2016 20:27:07 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: [gomp-nvptx 06/13] libgomp: add nvptx time.c Date: Wed, 20 Jan 2016 20:27:00 +0300 Message-Id: <1453310827-23183-7-git-send-email-amonakov@ispras.ru> In-Reply-To: <1453310827-23183-1-git-send-email-amonakov@ispras.ru> References: <1453310827-23183-1-git-send-email-amonakov@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 X-IsSubscribed: yes This patch implements time.c on NVPTX with the %clock64 register. The PTX documentation describes %globaltimer as explicitely off-limits for us. * config/nvptx/time.c: New. --- libgomp/ChangeLog.gomp-nvptx | 4 ++++ libgomp/config/nvptx/time.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/libgomp/config/nvptx/time.c b/libgomp/config/nvptx/time.c index e69de29..08feafe 100644 --- a/libgomp/config/nvptx/time.c +++ b/libgomp/config/nvptx/time.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2015 Free Software Foundation, Inc. + Contributed by Dmitry Melnik + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This file implements timer routines for NVPTX. It uses the %clock64 cycle + counter. */ + +#include "libgomp.h" + +/* This is set from host in plugin-nvptx.c. */ +double __nvptx_clocktick = 0; + +double +omp_get_wtime (void) +{ + uint64_t clock; + asm ("mov.u64 %0, %%clock64;" : "=r" (clock)); + return clock * __nvptx_clocktick; +} + +double +omp_get_wtick (void) +{ + return __nvptx_clocktick; +} + +ialias (omp_get_wtime) +ialias (omp_get_wtick)