-/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
- *
+/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This file is part of Gromacs Copyright (c) 1991-2006
- * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
+ * Copyright (c) 1991-2006 David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
*
- * This program 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 2
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org
+ * GROMACS 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
*
- * And Hey:
- * Gnomes, ROck Monsters And Chili Sauce
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
-/*! \internal \file
+/*! \libinternal \file
* \brief
* High-resolution timestamp or CPU clock cycle counters.
*
* After reading the current value with gmx_cycles_read() you can add or
* subtract these numbers as normal integers of type gmx_cycles_t.
+ *
+ * \inlibraryapi
*/
#ifndef GMX_TIMING_CYCLECOUNTER_H
#define GMX_TIMING_CYCLECOUNTER_H
* define HAVE_RDTSCP to use the serializing rdtscp instruction instead of rdtsc.
* This is only supported on newer Intel/AMD hardware, but provides better accuracy.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#ifdef _MSC_VER
#include <intrin.h>
typedef unsigned long long
gmx_cycles_t;
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+/* 64-bit ARM cycle counters with GCC inline assembly */
+typedef unsigned long long
+ gmx_cycles_t;
+
#elif defined(_MSC_VER)
#include <windows.h>
typedef __int64
#elif defined(__xlC__) && defined (_AIX)
/* AIX compilers */
-#include <sys/time.h>
#include <sys/systemcfg.h>
+#include <sys/time.h>
typedef unsigned long long
gmx_cycles_t;
* one when later linking to the library it might happen that the
* library supports cyclecounters but not the headers, or vice versa.
*/
-#if ((defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)) && \
+#if ((defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__) || defined(_CRAYC)) && \
(defined(__i386__) || defined(__x86_64__)))
static __inline__ int gmx_cycles_have_counter(void)
{
/* x86 or x86-64 with GCC inline assembly - pentium TSC register */
return 1;
}
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+static __inline int gmx_cycles_have_counter(void)
+{
+ /* 64-bit ARM cycle counters with GCC inline assembly */
+ return 1;
+}
#elif (defined(_MSC_VER))
static __inline int gmx_cycles_have_counter(void)
{
* routine.
*/
#if ((defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)) && \
- (defined(__i386__) || defined(__x86_64__)))
+ (defined(__i386__) || defined(__x86_64__)) && !defined(_CRAYC))
static __inline__ gmx_cycles_t gmx_cycles_read(void)
{
/* x86 with GCC inline assembly - pentium TSC register */
return cycle;
}
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+static __inline__ gmx_cycles_t gmx_cycles_read(void)
+{
+ /* 64-bit ARM cycle counters with GCC inline assembly */
+ gmx_cycles_t cycle;
+ __asm__ __volatile__("mrs %0, cntvct_el0" : "=r" (cycle) );
+
+ return cycle;
+}
+
#elif defined(_MSC_VER)
static __inline gmx_cycles_t gmx_cycles_read(void)
{
-#ifdef HAVE_RDTSCP
+#ifdef _M_ARM
+ /* Windows on 64-bit ARM */
+ return __rdpmccntr64();
+#else
+ /* x86 */
+# ifdef HAVE_RDTSCP
unsigned int ui;
return __rdtscp(&ui);
-#else
+# else
return __rdtsc();
+# endif
#endif
}
#elif (defined(__hpux) || defined(__HP_cc)) && defined(__ia64)
return ret;
}
+#elif defined(_CRAYC)
+#include <intrinsics.h>
+
+static __inline gmx_cycles_t gmx_cycles_read(void)
+{
+ return _rtc();
+}
#else
static gmx_cycles_t gmx_cycles_read(void)
{