git: fb1687157216 - main - benchmarks/libcpucycles: Microlibrary for counting CPU cycles
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Oct 2024 09:02:44 UTC
The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/ports/commit/?id=fb1687157216017a3c33d5b1890c3b2b75621735 commit fb1687157216017a3c33d5b1890c3b2b75621735 Author: Robert Clausecker <fuz@FreeBSD.org> AuthorDate: 2024-10-29 18:26:54 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2024-10-30 09:00:37 +0000 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 --- benchmarks/Makefile | 1 + benchmarks/libcpucycles/Makefile | 39 +++++++++++++++++++++++++++++++++++++++ benchmarks/libcpucycles/distinfo | 3 +++ benchmarks/libcpucycles/pkg-descr | 20 ++++++++++++++++++++ benchmarks/libcpucycles/pkg-plist | 7 +++++++ 5 files changed, 70 insertions(+) diff --git a/benchmarks/Makefile b/benchmarks/Makefile index 8a7572e2a904..78b25950bdc5 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -39,6 +39,7 @@ SUBDIR += iperf3 SUBDIR += kdiskmark SUBDIR += libcelero + SUBDIR += libcpucycles SUBDIR += libmicro SUBDIR += linux-gputest SUBDIR += linux-unigine-heaven diff --git a/benchmarks/libcpucycles/Makefile b/benchmarks/libcpucycles/Makefile new file mode 100644 index 000000000000..d2180fd16f91 --- /dev/null +++ b/benchmarks/libcpucycles/Makefile @@ -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> diff --git a/benchmarks/libcpucycles/distinfo b/benchmarks/libcpucycles/distinfo new file mode 100644 index 000000000000..7d9974242ff7 --- /dev/null +++ b/benchmarks/libcpucycles/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1730224174 +SHA256 (libcpucycles-20240318.tar.gz) = 19646a1b69d8f013647313fcedf15b6a89327a4b7ce553536d513f1f6e54d32d +SIZE (libcpucycles-20240318.tar.gz) = 42790 diff --git a/benchmarks/libcpucycles/pkg-descr b/benchmarks/libcpucycles/pkg-descr new file mode 100644 index 000000000000..ec932913c336 --- /dev/null +++ b/benchmarks/libcpucycles/pkg-descr @@ -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. diff --git a/benchmarks/libcpucycles/pkg-plist b/benchmarks/libcpucycles/pkg-plist new file mode 100644 index 000000000000..8c9c0b661f23 --- /dev/null +++ b/benchmarks/libcpucycles/pkg-plist @@ -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