Commit e3607fd9 authored by Julien Puydt's avatar Julien Puydt

Merge tag 'upstream/20150908'

Upstream version 20150908
parents 1b1b764d 7a6cde28
......@@ -49,43 +49,6 @@ pkgincludesub_HEADERS = m4rie/gf2x.h \
libm4rie_la_LDFLAGS = -release 0.0.$(RELEASE) -no-undefined ${M4RIE_M4RI_LDFLAGS}
libm4rie_la_LIBADD = -lm4ri
#testing
TESTCFLAGS = ${AM_CFLAGS} @CFLAGS@ ${M4RIE_M4RI_CFLAGS} ${M4RI_CFLAGS} -I./tests
TESTLIBADD = -lm4ri -lm4rie -lm
TESTLDADD =
TESTLDFLAGS = ${M4RIE_M4RI_LDFLAGS}
SUBDIRS = . tests
DIST_SUBDIRS = $(SUBDIRS) bench
check_PROGRAMS = test_trsm test_elimination test_multiplication test_smallops test_ple
test_elimination_SOURCES = tests/test_elimination.c tests/testing.h
test_elimination_LDADD = ${TESTLDADD} ${TESTLIBADD}
test_elimination_LDFLAGS = ${TESTLDFLAGS}
test_elimination_CFLAGS = ${TESTCFLAGS}
test_multiplication_SOURCES = tests/test_multiplication.c tests/testing.h
test_multiplication_LDADD = ${TESTLDADD} ${TESTLIBADD}
test_multiplication_LDFLAGS = ${TESTLDFLAGS}
test_multiplication_CFLAGS = ${TESTCFLAGS}
test_smallops_SOURCES = tests/test_smallops.c tests/testing.h
test_smallops_LDADD = ${TESTLDADD} ${TESTLIBADD}
test_smallops_LDFLAGS = ${TESTLDFLAGS}
test_smallops_CFLAGS = ${TESTCFLAGS}
test_trsm_SOURCES = tests/test_trsm.c tests/testing.h
test_trsm_LDADD = ${TESTLDADD} ${TESTLIBADD}
test_trsm_LDFLAGS = ${TESTLDFLAGS}
test_trsm_CFLAGS = ${TESTCFLAGS}
test_ple_SOURCES = tests/test_ple.c tests/testing.h
test_ple_LDADD = ${TESTLDADD} ${TESTLIBADD}
test_ple_LDFLAGS = ${TESTLDFLAGS}
test_ple_CFLAGS = ${TESTCFLAGS}
TESTS = test_trsm test_elimination test_multiplication test_smallops test_ple
# benchmarketing
SUBDIRS = . bench
clean-local:
(cd tests; make clean; cd ..)
This diff is collapsed.
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
m4_if([$1], [1.15], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
......@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
[AM_AUTOMAKE_VERSION([1.15])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
# Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd "$ac_aux_dir" && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -142,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -333,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -409,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -499,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
......@@ -574,6 +573,9 @@ END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi
dnl The trailing newline in this macro's definition is deliberate, for
dnl backward compatibility and to allow trailing 'dnl'-style comments
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
......@@ -603,7 +605,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -614,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
if test x"${install_sh+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
......@@ -624,7 +626,7 @@ if test x"${install_sh}" != xset; then
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -645,7 +647,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -695,7 +697,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -734,7 +736,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -763,7 +765,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -810,7 +812,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -829,7 +831,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -910,7 +912,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -970,7 +972,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -998,7 +1000,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -1017,7 +1019,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2013 Free Software Foundation, Inc.
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......
CPUCYCLES_DIR=./cpucycles-20060326
# TOPSRCDIR allows to compile this testsuite for a clone (and different revision) of this
# repository. If the environment variable topsrcdir is the top source directory of the clone,
# compile this testsuite as:
#
# make TOPSRCDIR="$topsrcdir"
#
# Finally, if you also leave out TOPSRCDIR and just run 'make' then the testsuite
# is compiled against the current source tree.
BENCHCFLAGS = $(AM_CFLAGS) -I.. -I${CPUCYCLES_DIR} @CXXFLAGS@ -DNDEBUG ${M4RIE_M4RI_CFLAGS}
BENCHLIBADD = -lm4ri -lm cpucycles.o
BENCHLDFLAGS = -Wl,-rpath,../.libs/ ../.libs/libm4rie.so -L${CPUCYCLES_DIR} ${M4RIE_M4RI_LDFLAGS} -Wl,-rpath,${M4RIE_M4RI_PREFIX}/lib
AUTOMAKE_OPTIONS = foreign
TOPSRCDIR = $(srcdir)/..
TOPBUILDDIR = $(builddir)/..
DEFINES =
# include TOPBUILDIR for m4ri_config.h
AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -D_XOPEN_SOURCE=600 @CFLAGS@ $(DEFINES) @OPENMP_CFLAGS@ ${M4RIE_M4RI_CFLAGS}
EXTRA_PROGRAMS = bench_multiplication bench_elimination bench_smallops bench_trsm bench_ple
STAGEDIR := $(realpath -s $(TOPBUILDDIR)/.libs)
AM_LDFLAGS = -L$(STAGEDIR) -Wl,-rpath,$(STAGEDIR) cpucycles.o -lm4ri -lm4rie -lm ${M4RIE_M4RI_LDFLAGS} -Wl,-rpath,${M4RIE_M4RI_PREFIX}/lib
.PHONY: clean dist-clean
BENCH = bench_multiplication \
bench_elimination \
bench_smallops \
bench_trsm \
bench_ple
cpucycles.o:
(cd $(CPUCYCLES_DIR); sh do; mv cpucycles.o ..; mv cpucycles.h ..; cd ../..)
cpucycles.h: cpucycles.o
CPUCYCLES_DIR = cpucycles-20060326
clean-local:
-rm -f cpucycles.h
-rm -f $(EXTRA_PROGRAMS)
CPUCYCLES_EXTRA_DIST = $(srcdir)/cpucycles-20060326/*.c \
$(srcdir)/cpucycles-20060326/*.h \
$(srcdir)/cpucycles-20060326/compile \
$(srcdir)/cpucycles-20060326/do
bench_elimination_SOURCES=bench_elimination.c cpucycles.h benchmarking.c
bench_elimination_CFLAGS=${BENCHCFLAGS}
bench_elimination_LDFLAGS=${BENCHLDFLAGS} ${BENCHLIBADD}
EXTRA_DIST = $(CPUCYCLES_EXTRA_DIST)
bench_multiplication_SOURCES=bench_multiplication.c cpucycles.h benchmarking.c
bench_multiplication_CFLAGS=${BENCHCFLAGS}
bench_multiplication_LDFLAGS=${BENCHLDFLAGS} ${BENCHLIBADD}
bin_PROGRAMS = $(BENCH)
bench_smallops_SOURCES=bench_smallops.c cpucycles.h benchmarking.c
bench_smallops_CFLAGS=${BENCHCFLAGS}
bench_smallops_LDFLAGS=${BENCHLDFLAGS} ${BENCHLIBADD}
bench_elimination_SOURCES = bench_elimination.c benchmarking.c benchmarking.h
bench_multiplication_SOURCES = bench_multiplication.c benchmarking.c benchmarking.h
bench_ple_SOURCES = bench_ple.c benchmarking.c benchmarking.h
bench_smallops_SOURCES = bench_smallops.c benchmarking.c benchmarking.h
bench_trsm_SOURCES = bench_trsm.c benchmarking.c benchmarking.h
bench_trsm_SOURCES=bench_trsm.c cpucycles.h benchmarking.c
bench_trsm_CFLAGS=${BENCHCFLAGS}
bench_trsm_LDFLAGS=${BENCHLDFLAGS} ${BENCHLIBADD}
BUILT_SOURCES = cpucycles.h
bench_ple_SOURCES=bench_ple.c cpucycles.h benchmarking.c
bench_ple_CFLAGS=${BENCHCFLAGS}
bench_ple_LDFLAGS=${BENCHLDFLAGS} ${BENCHLIBADD}
cpucycles.h: cpucycles.o
bench: cpucycles.o ${EXTRA_PROGRAMS}
cpucycles.o:
(if [ $(srcdir) != $(builddir) ]; then \
cp -r $(srcdir)/$(CPUCYCLES_DIR) $(builddir); \
chmod +w -R $(CPUCYCLES_DIR)/; \
fi; \
cd $(CPUCYCLES_DIR); \
sh do; \
cp cpucycles.o ..; \
cp cpucycles.h ..; \
cd ..; \
if [ $(srcdir) != $(builddir) ]; then \
rm -r $(CPUCYCLES_DIR); \
fi)
distclean-local:
-rm -f cpucycles.h
This diff is collapsed.
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "cpucycles.h"
#include "benchmarking.h"
struct elim_params {
......
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "cpucycles.h"
#include "benchmarking.h"
struct mul_params {
......
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "cpucycles.h"
#include "benchmarking.h"
struct ple_params {
......
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "cpucycles.h"
#include "benchmarking.h"
struct smallops_params {
......
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "cpucycles.h"
#include "benchmarking.h"
struct elim_params {
......
#ifndef BENCHMARKETING_H
#define BENCHMARKETING_H
#include <stdint.h>
/*
* Command line options. See benchmarking.h for documentation.
*/
extern int bench_quiet;
extern int bench_dump;
extern int bench_minimum;
extern int bench_maximum;
extern unsigned long long bench_maxtime;
extern double bench_accuracy;
extern int bench_confidence_index;
extern char const* progname;
extern uint64_t bench_count;
unsigned long long walltime(unsigned long long t0);
int global_options(int* argcp, char*** argvp);
void bench_print_global_options(FILE*);
int run_bench(
int (*f)(void* params, unsigned long long* data, int *data_len),
void* params,
unsigned long long* data,
int data_len);
#ifdef HAVE_LIBPAPI
extern int papi_events[];
extern int papi_array_len;
char* papi_event_name(int event);
#endif
#define __M4RIE_OMEGA 2.80735492205760
#endif //BENCHMARKETING_H
/*
cpucycles/alpha.c version 20060316
D. J. Bernstein
Public domain.
*/
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
static long long tod(void)
{
struct timeval t;
gettimeofday(&t,(struct timezone *) 0);
return t.tv_sec * (long long) 1000000 + t.tv_usec;
}
static long long rpcc(void)
{
unsigned long long t;
asm volatile("rpcc %0" : "=r"(t));
return t & 0xffffffff;
}
static long long firstrpcc;
static long long firsttod;
static long long lastrpcc;
static long long lasttod;
static double mhz = 0;
static void init(void)
{
firstrpcc = rpcc();
firsttod = tod();
do {
lastrpcc = rpcc();
lasttod = tod();
} while (lasttod - firsttod < 10000);
lastrpcc -= firstrpcc; lastrpcc &= 0xffffffff;
lasttod -= firsttod;
mhz = (double) lastrpcc / (double) lasttod;
}
long long cpucycles_alpha(void)
{
double x;
long long y;
if (!mhz) init();
lastrpcc = rpcc();
lasttod = tod();
lastrpcc -= firstrpcc; lastrpcc &= 0xffffffff;
lasttod -= firsttod;
/* Number of cycles since firstrpcc is lastrpcc + 2^32 y for unknown y. */
/* Number of microseconds since firsttod is lasttod. */
x = (lasttod * mhz - lastrpcc) * 0.00000000023283064365386962890625;
y = x;
while (x > y + 0.5) y += 1;
while (x < y - 0.5) y -= 1;
y *= 4294967296ULL;
lastrpcc += y;
mhz = (double) lastrpcc / (double) lasttod;
return firstrpcc + lastrpcc;
}
long long cpucycles_alpha_persecond(void)
{
if (!mhz) init();
return 1000000.0 * mhz;
}
/*
cpucycles alpha.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_alpha_h
#define CPUCYCLES_alpha_h
#ifdef __cplusplus
extern "C" {
#endif
extern long long cpucycles_alpha(void);
extern long long cpucycles_alpha_persecond(void);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "alpha"
#define cpucycles cpucycles_alpha
#define cpucycles_persecond cpucycles_alpha_persecond
#endif
#endif
#include <stdio.h>
#include <sys/types.h>
long long cpucycles_amd64cpuinfo(void)
{
unsigned long long result;
asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax"
: "=a" (result) :: "%rdx");
return result;
}
long long cpucycles_amd64cpuinfo_persecond(void)
{
FILE *f;
double result;
int s;
f = fopen("/proc/cpuinfo","r");
if (!f) return 0;
for (;;) {
s = fscanf(f,"cpu MHz : %lf",&result);
if (s > 0) break;
if (s == 0) s = fscanf(f,"%*[^\n]\n");
if (s < 0) { result = 0; break; }
}
fclose(f);
return 1000000.0 * result;
}
#include <stdio.h>
#include <sys/types.h>
long long cpucycles_amd64tscfreq(void)
{
unsigned long long result;
asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax"
: "=a" (result) :: "%rdx");
return result;
}
long long cpucycles_amd64tscfreq_persecond(void)
{
long result = 0;
size_t resultlen = sizeof(long);
sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0);
return result;
}
/*
cpucycles amd64tscfreq.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_amd64tscfreq_h
#define CPUCYCLES_amd64tscfreq_h
#ifdef __cplusplus
extern "C" {
#endif
extern long long cpucycles_amd64tscfreq(void);
extern long long cpucycles_amd64tscfreq_persecond(void);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "amd64tscfreq"
#define cpucycles cpucycles_amd64tscfreq
#define cpucycles_persecond cpucycles_amd64tscfreq_persecond
#endif
#endif
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/sysctl.h>
static double cpufrequency = 0;
static void init(void)
{
long result = 0; size_t resultlen = sizeof(long);
sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0);
cpufrequency = result;
}
long long cpucycles_clockmonotonic(void)
{
double result;
struct timespec t;
if (!cpufrequency) init();
clock_gettime(CLOCK_MONOTONIC,&t);
result = t.tv_nsec;
result *= 0.000000001;
result += (double) t.tv_sec;
result *= cpufrequency;
return result;
}
long long cpucycles_clockmonotonic_persecond(void)
{
if (!cpufrequency) init();
return cpufrequency;
}
/*
cpucycles clockmonotonic.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_clockmonotonic_h
#define CPUCYCLES_clockmonotonic_h
#ifdef __cplusplus
extern "C" {
#endif
extern long long cpucycles_clockmonotonic(void);
extern long long cpucycles_clockmonotonic_persecond(void);
#ifdef __cplusplus
}
#endif
#ifndef cpucycles_implementation
#define cpucycles_implementation "clockmonotonic"
#define cpucycles cpucycles_clockmonotonic
#define cpucycles_persecond cpucycles_clockmonotonic_persecond
#endif
#endif
#!/bin/sh
case "$COMPILER" in
suncc)
case "$ARCHITECTURE" in
64) /opt/SUNWspro/bin/cc -xarch=v9 -O2 "$@" ;;
32) /opt/SUNWspro/bin/cc -xarch=v8 -O2 "$@" ;;
*) /opt/SUNWspro/bin/cc -O2 "$@" ;;
esac
;;
ibmcc)
case "$ARCHITECTURE" in
64) xlc -q64 -O2 "$@" ;;
32) xlc -q32 -O2 "$@" ;;
*) xlc -O2 "$@" ;;
esac
;;
hpcc)
case "$ARCHITECTURE" in
64) /opt/ansic/bin/cc +DD64 -O2 "$@" ;;
32) /opt/ansic/bin/cc +DD32 -O2 "$@" ;;
*) /opt/ansic/bin/cc -O2 "$@" ;;
esac
;;
*)
case "$ARCHITECTURE" in
64) gcc -m64 -O2 "$@" ;;
32) gcc -m32 -O2 "$@" ;;
*) gcc -O2 "$@" ;;
esac
;;
esac
/*
cpucycles amd64cpuinfo.h version 20060318
D. J. Bernstein
Public domain.
*/
#ifndef CPUCYCLES_amd64cpuinfo_h
#define CPUCYCLES_amd64cpuinfo_h
#ifdef __cplusplus
extern "C" {
#endif
extern long long cpucycles_amd64cpuinfo(void);
extern long long cpucycles_amd64cpuinfo_persecond(void);
#ifdef __cplusplus
}
#endif