benchmarks/libcpucycles: Microlibrary for counting CPU cycles

libcpucycles is a microlibrary for counting CPU cycles.  Cycle counts
are not as detailed as Falk diagrams but are the most precise timers
available to typical software; they are central tools used in
understanding and improving software performance.

The libcpucycles API is simple: include <cpucycles.h>, call cpucycles()
to receive a long long whenever desired, and link with -lcpucycles.

Internally, libcpucycles understands machine-level cycle counters for
amd64 (both PMC and TSC), arm32, arm64 (both PMC and VCT), mips64,
ppc32, ppc64, riscv32, riscv64, s390x, sparc64, and x86. libcpucycles
also understands four OS-level mechanisms, which give varying levels of
accuracy: mach_absolute_time, perf_event, CLOCK_MONOTONIC, and, as a
fallback, microsecond-resolution gettimeofday.

When the program first calls cpucycles(), libcpucycles automatically
benchmarks the available mechanisms and selects the mechanism that does
the best job.  Subsequent cpucycles() calls are thread-safe and very
fast. An accompanying cpucycles-info program prints a summary of
cycle-counter accuracy.

WWW: https://cpucycles.cr.yp.to/

Tested by:	jhibbits
This commit is contained in:
Robert Clausecker 2024-10-29 19:26:54 +01:00
parent 83dd50b363
commit fb16871572
5 changed files with 70 additions and 0 deletions

View File

@ -39,6 +39,7 @@
SUBDIR += iperf3
SUBDIR += kdiskmark
SUBDIR += libcelero
SUBDIR += libcpucycles
SUBDIR += libmicro
SUBDIR += linux-gputest
SUBDIR += linux-unigine-heaven

View File

@ -0,0 +1,39 @@
PORTNAME= libcpucycles
DISTVERSION= 20240318
CATEGORIES= benchmarks devel
MASTER_SITES= https://cpucycles.cr.yp.to/
MAINTAINER= fuz@FreeBSD.org
COMMENT= Microlibrary for counting CPU cycles
WWW= https://cpucycles.cr.yp.to/
LICENSE= PD
USES= python:build shebangfix
USE_LDCONFIG= yes
SHEBANG_FILES= configure scripts-build/*
HAS_CONFIGURE= yes
CONFIGURE_ARGS= --host=${ARCH}
ALL_TARGET= default
CFLAGS+= -fPIC -fwrapv -fvisibility=hidden
_STAGE= ${WRKSRC}/build/0/package
pre-configure:
${ECHO} ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} >${WRKSRC}/compilers/default
# no staging support for some reason
do-install:
${INSTALL_MAN} ${_STAGE}/man/man1/cpucycles-info.1 ${STAGEDIR}${PREFIX}/share/man/man1/
${INSTALL_MAN} ${_STAGE}/man/man3/cpucycles.3 ${STAGEDIR}${PREFIX}/share/man/man3/
${INSTALL_DATA} ${_STAGE}/include/cpucycles.h ${STAGEDIR}${PREFIX}/include/
for lib in ${_STAGE}/lib/libcpucycles* ; \
do \
${INSTALL_LIB} $$lib ${STAGEDIR}${PREFIX}/lib/ ; \
done
${INSTALL_PROGRAM} ${_STAGE}/bin/cpucycles-info ${STAGEDIR}${PREFIX}/bin/
do-test:
${SETENVI} LD_LIBRARY_PATH=${STAGEDIR}${PREFIX}/lib ${STAGEDIR}${PREFIX}/bin/cpucycles-info
.include <bsd.port.mk>

View File

@ -0,0 +1,3 @@
TIMESTAMP = 1730224174
SHA256 (libcpucycles-20240318.tar.gz) = 19646a1b69d8f013647313fcedf15b6a89327a4b7ce553536d513f1f6e54d32d
SIZE (libcpucycles-20240318.tar.gz) = 42790

View File

@ -0,0 +1,20 @@
libcpucycles is a microlibrary for counting CPU cycles. Cycle counts
are not as detailed as Falk diagrams but are the most precise timers
available to typical software; they are central tools used in
understanding and improving software performance.
The libcpucycles API is simple: include <cpucycles.h>, call cpucycles()
to receive a long long whenever desired, and link with -lcpucycles.
Internally, libcpucycles understands machine-level cycle counters for
amd64 (both PMC and TSC), arm32, arm64 (both PMC and VCT), mips64,
ppc32, ppc64, riscv32, riscv64, s390x, sparc64, and x86. libcpucycles
also understands four OS-level mechanisms, which give varying levels of
accuracy: mach_absolute_time, perf_event, CLOCK_MONOTONIC, and, as a
fallback, microsecond-resolution gettimeofday.
When the program first calls cpucycles(), libcpucycles automatically
benchmarks the available mechanisms and selects the mechanism that does
the best job. Subsequent cpucycles() calls are thread-safe and very
fast. An accompanying cpucycles-info program prints a summary of
cycle-counter accuracy.

View File

@ -0,0 +1,7 @@
bin/cpucycles-info
include/cpucycles.h
lib/libcpucycles.a
lib/libcpucycles.so
lib/libcpucycles.so.1
share/man/man1/cpucycles-info.1.gz
share/man/man3/cpucycles.3.gz