diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 73b0eeb10a5a..000000000000 --- a/LICENSE +++ /dev/null @@ -1,54 +0,0 @@ -Copyright 2010-2014 Samy Al Bahra. -Copyright 2011-2013 AppNexus, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -Hazard Pointers (src/ck_hp.c) also includes this license: - -(c) Copyright 2008, IBM Corporation. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -ck_pr_rtm leverages work from Andi Kleen: -Copyright (c) 2012,2013 Intel Corporation - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that: (1) source code distributions -retain the above copyright notice and this paragraph in its entirety, (2) -distributions including binary code include the above copyright notice and -this paragraph in its entirety in the documentation or other materials -provided with the distribution - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index 7e73f709e184..000000000000 --- a/Makefile.in +++ /dev/null @@ -1,103 +0,0 @@ -.PHONY: all check clean dist distclean doc install install-headers regressions uninstall - -BUILD_DIR=@BUILD_DIR@ -SRC_DIR=@SRC_DIR@ -CFLAGS=@CFLAGS@ -VERSION=@VERSION@ -VERSION_MAJOR=@VERSION_MAJOR@ -PREFIX=@PREFIX@ -LIBRARY=@LIBRARY@ -HEADERS=@HEADERS@ -PKGCONFIG_DATA=@LIBRARY@/pkgconfig -LDNAME=@LDNAME@ -LDNAME_VERSION=@LDNAME_VERSION@ -LDNAME_MAJOR=@LDNAME_MAJOR@ - -all: doc - $(MAKE) -C src all || exit - @echo - @echo - @echo ---[ Concurrency Kit has built successfully. You may now \"make install\". - -doc: - $(MAKE) -C doc all || exit - @echo ---[ Manual pages are ready for installation. - -regressions: - $(MAKE) -C regressions all || exit - @echo ---[ Regressions have built successfully. - -check: regressions - @echo ---[ Executing unit tests... - $(MAKE) -C regressions check - @echo ---[ Unit tests have completed successfully. - -install-headers: - mkdir -p $(DESTDIR)/$(HEADERS) || exit - cp $(SRC_DIR)/include/*.h $(DESTDIR)/$(HEADERS) || exit - chmod 644 $(DESTDIR)/$(HEADERS)/ck_*.h || exit - mkdir -p $(DESTDIR)$(HEADERS)/gcc || exit - cp -r $(SRC_DIR)/include/gcc/* $(DESTDIR)/$(HEADERS)/gcc || exit - cp include/ck_md.h $(DESTDIR)/$(HEADERS)/ck_md.h || exit - chmod 755 $(DESTDIR)/$(HEADERS)/gcc - chmod 644 $(DESTDIR)/$(HEADERS)/gcc/ck_*.h $(DESTDIR)/$(HEADERS)/gcc/*/ck_*.h || exit - mkdir -p $(DESTDIR)$(HEADERS)/spinlock || exit - cp -r $(SRC_DIR)/include/spinlock/* $(DESTDIR)/$(HEADERS)/spinlock || exit - chmod 755 $(DESTDIR)/$(HEADERS)/spinlock - chmod 644 $(DESTDIR)/$(HEADERS)/spinlock/*.h || exit - -install-so: - mkdir -p $(DESTDIR)/$(LIBRARY) - cp src/libck.so $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION) - ln -sf $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME) - ln -sf $(LDNAME_VERSION) $(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR) - chmod 744 $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION) \ - $(DESTDIR)/$(LIBRARY)/$(LDNAME) \ - $(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR) - -install-lib: - mkdir -p $(DESTDIR)/$(LIBRARY) - cp src/libck.a $(DESTDIR)/$(LIBRARY)/libck.a - chmod 644 $(DESTDIR)/$(LIBRARY)/libck.a - -install: all install-headers @INSTALL_LIBS@ - $(MAKE) -C doc install - mkdir -p $(DESTDIR)/$(LIBRARY) || exit - mkdir -p $(DESTDIR)/$(PKGCONFIG_DATA) || exit - chmod 755 $(DESTDIR)/$(PKGCONFIG_DATA) - cp build/ck.pc $(DESTDIR)/$(PKGCONFIG_DATA)/ck.pc || exit - @echo - @echo - @echo ---[ Concurrency Kit has installed successfully. - -uninstall: - $(MAKE) -C doc uninstall - rm -f $(DESTDIR)/$(LIBRARY)/$(LDNAME_VERSION) \ - $(DESTDIR)/$(LIBRARY)/$(LDNAME) \ - $(DESTDIR)/$(LIBRARY)/$(LDNAME_MAJOR) - rm -f $(DESTDIR)/$(LIBRARY)/libck.so* - rm -f $(DESTDIR)/$(LIBRARY)/libck.a - rm -f $(DESTDIR)/$(HEADERS)/ck_*.h - rm -f $(DESTDIR)/$(HEADERS)/spinlock/*.h - rm -f $(DESTDIR)/$(HEADERS)/gcc/ck_*.h - rm -f $(DESTDIR)/$(HEADERS)/gcc/*/ck_*.h - rm -f $(DESTDIR)/$(PKGCONFIG_DATA)/ck.pc - -clean: - $(MAKE) -C doc clean - $(MAKE) -C src clean - $(MAKE) -C regressions clean - rm -f $(BUILD_DIR)/*~ $(BUILD_DIR)/*.o $(BUILD_DIR)/*.tar.gz - -dist: - git archive --remote=$(SRC_DIR) --format=tar --prefix=ck-$(VERSION)/ HEAD \ - | gzip > $(BUILD_DIR)/ck-$(VERSION).tar.gz - -distclean: clean - rm -f $(BUILD_DIR)/include/ck_md.h - rm -f $(BUILD_DIR)/build/regressions.build - rm -f $(BUILD_DIR)/build/ck.build - rm -f $(BUILD_DIR)/build/ck.pc - rm -f $(BUILD_DIR)/Makefile - rm -f $(BUILD_DIR)/doc/Makefile - diff --git a/README b/README deleted file mode 100644 index 81fb5ac87ca8..000000000000 --- a/README +++ /dev/null @@ -1,21 +0,0 @@ - ____ _ ___ _ - / ___|___ _ __ ___ _ _ _ __ _ __ ___ _ __ ___ _ _ | |/ (_) |_ -| | / _ \| '_ \ / __| | | | '__| '__/ _ \ '_ \ / __| | | | | ' /| | __| -| |__| (_) | | | | (__| |_| | | | | | __/ | | | (__| |_| | | . \| | |_ - \____\___/|_| |_|\___|\__,_|_| |_| \___|_| |_|\___|\__, | |_|\_\_|\__| - |___/ - -Step 1. - ./configure - For additional options try ./configure --help - -Step 2. - In order to compile regressions (requires POSIX threads) use - "make regressions". In order to compile libck use "make all" or "make". - -Step 3. - In order to install use "make install" - To uninstall use "make uninstall". - -See http://concurrencykit.org/ for more information. - diff --git a/build/ck.build.aarch64 b/build/ck.build.aarch64 deleted file mode 100644 index 8b137891791f..000000000000 --- a/build/ck.build.aarch64 +++ /dev/null @@ -1 +0,0 @@ - diff --git a/build/ck.build.arm b/build/ck.build.arm deleted file mode 100644 index 3fa739cb6d08..000000000000 --- a/build/ck.build.arm +++ /dev/null @@ -1 +0,0 @@ -CFLAGS+=-D__arm__ diff --git a/build/ck.build.in b/build/ck.build.in deleted file mode 100644 index 1d6bfe32bb4a..000000000000 --- a/build/ck.build.in +++ /dev/null @@ -1,10 +0,0 @@ -CC=@CC@ -MAKE=make -SRC_DIR=@SRC_DIR@ -BUILD_DIR=@BUILD_DIR@ -CFLAGS+=@CFLAGS@ -I$(SRC_DIR)/include -I$(BUILD_DIR)/include -LDFLAGS+=@LDFLAGS@ -ALL_LIBS=@ALL_LIBS@ -LD=@LD@ - -include $(BUILD_DIR)/build/ck.build.@PROFILE@ diff --git a/build/ck.build.ppc b/build/ck.build.ppc deleted file mode 100644 index bd0c2fdf7e23..000000000000 --- a/build/ck.build.ppc +++ /dev/null @@ -1 +0,0 @@ -CFLAGS+=-m32 -D__ppc__ diff --git a/build/ck.build.ppc64 b/build/ck.build.ppc64 deleted file mode 100644 index 51003f4e4c83..000000000000 --- a/build/ck.build.ppc64 +++ /dev/null @@ -1,2 +0,0 @@ -CFLAGS+=-m64 -D__ppc64__ -LDFLAGS+=-m64 diff --git a/build/ck.build.sparcv9 b/build/ck.build.sparcv9 deleted file mode 100644 index d866841ba721..000000000000 --- a/build/ck.build.sparcv9 +++ /dev/null @@ -1 +0,0 @@ -CFLAGS+=-m64 -D__sparcv9__ diff --git a/build/ck.build.x86 b/build/ck.build.x86 deleted file mode 100644 index 6e127839a11a..000000000000 --- a/build/ck.build.x86 +++ /dev/null @@ -1,2 +0,0 @@ -CFLAGS+=-m32 -D__x86__ -msse -msse2 -LDFLAGS+=-m32 diff --git a/build/ck.build.x86_64 b/build/ck.build.x86_64 deleted file mode 100644 index 81b378a1bad0..000000000000 --- a/build/ck.build.x86_64 +++ /dev/null @@ -1,2 +0,0 @@ -CFLAGS+=-m64 -D__x86_64__ -LDFLAGS+=-m64 diff --git a/build/ck.pc.in b/build/ck.pc.in deleted file mode 100644 index 0f1e93b9e26b..000000000000 --- a/build/ck.pc.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@PREFIX@ -includedir=@HEADERS@ -libdir=@LIBRARY@ - -Name: Concurrency Kit -Description: Toolkit for well-specified design and implementation of concurrent systems -URL: http://concurrencykit.org/ -Version: @VERSION@ -Libs: -L${libdir} -lck -Cflags: -D__@PROFILE@__ -I${includedir} @PC_CFLAGS@ diff --git a/build/ck.spec.in b/build/ck.spec.in deleted file mode 100644 index e486d53ff7d7..000000000000 --- a/build/ck.spec.in +++ /dev/null @@ -1,74 +0,0 @@ -Name: ck -Version: @VERSION@ -Release: 1%{?dist} -Group: Development/Libraries -Summary: Concurrency Kit -License: Simplified BSD License -URL: http://concurrencykit.org -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -Source: http://concurrencykit.org/releases/ck-%{version}.tar.gz - -%description -Concurrency Kit provides a plethora of concurrency primitives, safe memory -reclamation mechanisms and lock-less and lock-free data structures designed to -aid in the design and implementation of high performance concurrent systems. It -is designed to minimize dependencies on operating system-specific interfaces -and most of the interface relies only on a strict subset of the standard -library and more popular compiler extensions. - -%package devel -Group: Development/Libraries -Summary: Header files and libraries for CK development -Requires: %{name} = %{version}-%{release} - -%description devel -Concurrency Kit provides a plethora of concurrency primitives, safe memory -reclamation mechanisms and lock-less and lock-free data structures designed to -aid in the design and implementation of high performance concurrent systems. It -is designed to minimize dependencies on operating system-specific interfaces -and most of the interface relies only on a strict subset of the standard -library and more popular compiler extensions. - -This package provides the libraries, include files, and other -resources needed for developing Concurrency Kit applications. - -%prep -%setup -q - -%build -CFLAGS=$RPM_OPT_FLAGS ./configure \ - --libdir=%{_libdir} \ - --includedir=%{_includedir}/%{name} \ - --mandir=%{_mandir} \ - --prefix=%{_prefix} -make %{?_smp_mflags} - -%install -rm -rf $RPM_BUILD_ROOT -make DESTDIR=$RPM_BUILD_ROOT install - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root,-) -%{_libdir}/libck.so.@VERSION@ -%{_libdir}/libck.so.@VERSION_MAJOR@ - -%files devel -%defattr(-,root,root) -%{_libdir}/libck.so -%{_includedir}/%{name}/*.h -%{_includedir}/%{name}/*/*.h -%{_includedir}/%{name}/*/*/*.h -%{_libdir}/libck.a -%{_libdir}/pkgconfig/%{name}.pc -%{_mandir}/man3/*.3.gz - -%post -/sbin/ldconfig - -%postun -/sbin/ldconfig - diff --git a/build/regressions.build.in b/build/regressions.build.in deleted file mode 100644 index 6d79a8b678a1..000000000000 --- a/build/regressions.build.in +++ /dev/null @@ -1,10 +0,0 @@ -CC=@CC@ -MAKE=make -CORES=@CORES@ -CFLAGS=@CFLAGS@ -I../../../include -DCORES=@CORES@ -LD=@LD@ -LDFLAGS=@LDFLAGS@ -PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ -BUILD_DIR=@BUILD_DIR@ - -include $(BUILD_DIR)/build/ck.build.@PROFILE@ diff --git a/configure b/configure deleted file mode 100755 index a9c931ddcd53..000000000000 --- a/configure +++ /dev/null @@ -1,775 +0,0 @@ -#!/bin/sh -# -# Copyright © 2009-2013 Samy Al Bahra. -# Copyright © 2011 Devon H. O'Dell -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -REQUIRE_HEADER="stdbool.h stddef.h stdint.h string.h" - -EXIT_SUCCESS=0 -EXIT_FAILURE=1 -WANT_PIC=yes - -P_PWD=`pwd` -MAINTAINER='sbahra@repnop.org' -VERSION=${VERSION:-'0.5.2'} -VERSION_MAJOR='0' -BUILD="$PWD/build/ck.build" -PREFIX=${PREFIX:-"/usr/local"} -LDNAME="libck.so" -LDNAME_VERSION="libck.so.$VERSION" -LDNAME_MAJOR="libck.so.$VERSION_MAJOR" - -OPTION_CHECKING=1 - -export CFLAGS -export PREFIX -LC_ALL=C -export LC_ALL - -if test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi - -trap epilog 1 2 3 6 - -epilog() -{ - rm -f .1.c .1 -} - -assert() -{ - - if test "$#" -eq 2; then - fail=$2 - print=true - elif test "$#" -eq 3; then - fail=$3 - print=echo - else - echo "Usage: assert or assert " 1>&2 - exit $EXIT_FAILURE - fi - - if test -z "$1"; then - echo "failed [$fail]" - exit $EXIT_FAILURE - else - ${print} "success [$1]" - fi -} - -get_git_sha() -{ - # return a short SHA for the current HEAD - GIT_SHA="" - GIT_MSG="success" - gitcmd=`which git` - if test -n "$gitcmd"; then - GIT_SHA=`git rev-parse --short HEAD 2>/dev/null` - if ! test -n "$GIT_SHA"; then - GIT_MSG="not within a git repo" - fi - else - GIT_MSG="git not installed or executable" - fi -} - -generate() -{ - sed -e "s#@PROFILE@#$PROFILE#g" \ - -e "s#@VERSION@#$VERSION#g" \ - -e "s#@VERSION_MAJOR@#$VERSION_MAJOR#g" \ - -e "s#@CC@#$CC#g" \ - -e "s#@CFLAGS@#$CFLAGS#g" \ - -e "s#@HEADERS@#$HEADERS#g" \ - -e "s#@LIBRARY@#$LIBRARY#g" \ - -e "s#@PREFIX@#$PREFIX#g" \ - -e "s#@CORES@#$CORES#g" \ - -e "s#@ALL_LIBS@#$ALL_LIBS#g" \ - -e "s#@INSTALL_LIBS@#$INSTALL_LIBS#g" \ - -e "s#@LD@#$LD#g" \ - -e "s#@LDFLAGS@#$LDFLAGS#g" \ - -e "s#@PTHREAD_CFLAGS@#$PTHREAD_CFLAGS#g" \ - -e "s#@MANDIR@#$MANDIR#g" \ - -e "s#@GZIP@#$GZIP#g" \ - -e "s#@GZIP_SUFFIX@#$GZIP_SUFFIX#g" \ - -e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \ - -e "s#@RTM_ENABLE@#$RTM_ENABLE#g" \ - -e "s#@VMA_BITS@#$VMA_BITS_R#g" \ - -e "s#@VMA_BITS_VALUE@#$VMA_BITS_VALUE_R#g" \ - -e "s#@MM@#$MM#g" \ - -e "s#@BUILD_DIR@#$P_PWD#g" \ - -e "s#@SRC_DIR@#$BUILD_DIR#g" \ - -e "s#@LDNAME@#$LDNAME#g" \ - -e "s#@LDNAME_MAJOR@#$LDNAME_MAJOR#g" \ - -e "s#@LDNAME_VERSION@#$LDNAME_VERSION#g" \ - -e "s#@PC_CFLAGS@#$PC_CFLAGS#g" \ - -e "s#@GIT_SHA@#$GIT_SHA#g" \ - $1 > $2 -} - -generate_stdout() -{ - - echo - echo " VERSION = $VERSION" - echo " GIT_SHA = $GIT_SHA" - echo " BUILD_DIR = $P_PWD" - echo " SRC_DIR = $BUILD_DIR" - echo " SYSTEM = $SYSTEM" - echo " PROFILE = $PROFILE" - echo " CC = $CC" - echo " COMPILER = $COMPILER" - echo " CFLAGS = $CFLAGS" - echo " PTHREAD_CFLAGS = $PTHREAD_CFLAGS" - echo " LD = $LD" - echo " LDNAME = $LDNAME" - echo " LDNAME_VERSION = $LDNAME_VERSION" - echo " LDNAME_MAJOR = $LDNAME_MAJOR" - echo " LDFLAGS = $LDFLAGS" - echo " GZIP = $GZIP" - echo " CORES = $CORES" - echo " POINTER_PACK = $POINTER_PACK_ENABLE" - echo " VMA_BITS = $VMA_BITS" - echo " MEMORY_MODEL = $MM" - echo " RTM = $RTM_ENABLE" - echo - echo "Headers will be installed in $HEADERS" - echo "Libraries will be installed in $LIBRARY" - echo "Documentation will be installed in $MANDIR" -} - -for option; do - case "$option" in - *=?*) - value=`expr -- "$option" : '[^=]*=\(.*\)'` - ;; - *=) - value= - ;; - *) - value=yes - ;; - esac - - case "$option" in - --help) - echo "Usage: $0 [OPTIONS]" - echo - echo "The following options may be used for cross-building." - echo " --profile=N Use custom build profile (use in conjunction with \$CC)" - echo - echo "The following options may be used to modify installation behavior." - echo " --includedir=N Headers directory (default is ${PREFIX}/include)" - echo " --libdir=N Libraries directory (default is ${PREFIX}/lib)" - echo " --mandir=N Manual pages directory (default is ${PREFIX}/man)" - echo " --prefix=N Installs library files in N (default is $PREFIX)" - echo - echo "The following options will affect generated code." - echo " --enable-pointer-packing Assumes address encoding is subset of pointer range" - echo " --enable-rtm Enable restricted transactional memory (power, x86_64)" - echo " --memory-model=N Specify memory model (currently tso, pso or rmo)" - echo " --vma-bits=N Specify valid number of VMA bits" - echo " --platform=N Force the platform type, instead of relying on autodetection" - echo " --use-cc-builtins Use the compiler atomic bultin functions, instead of the CK implementation" - echo - echo "The following options affect regression testing." - echo " --cores=N Specify number of cores available on target machine" - echo - echo "The following environment variables may be used:" - echo " CC C compiler command" - echo " CFLAGS C compiler flags" - echo " LDFLAGS Linker flags" - echo " GZIP GZIP compression tool" - echo - echo "Report bugs to ${MAINTAINER}." - exit $EXIT_SUCCESS - ;; - --memory-model=*) - case "$value" in - "tso") - MM="CK_MD_TSO" - ;; - "rmo") - MM="CK_MD_RMO" - ;; - "pso") - MM="CK_MD_PSO" - ;; - *) - echo "./configure [--help]" - exit $EXIT_FAILURE - ;; - esac - ;; - --vma-bits=*) - VMA_BITS=$value - ;; - --enable-pointer-packing) - POINTER_PACK_ENABLE="CK_MD_POINTER_PACK_ENABLE" - ;; - --enable-rtm) - RTM_ENABLE_SET="CK_MD_RTM_ENABLE" - ;; - --cores=*) - CORES=$value - ;; - --profile=*) - PROFILE=$value - ;; - --prefix=*) - PREFIX=$value - ;; - --includedir=*) - HEADERS=$value - ;; - --libdir=*) - LIBRARY=$value - ;; - --mandir=*) - MANDIR=$value - ;; - --with-pic) - WANT_PIC=yes - ;; - --without-pic) - WANT_PIC=no - ;; - --disable-option-checking) - OPTION_CHECKING=0 - ;; - --use-cc-builtins) - USE_CC_BUILTINS=1 - ;; - --platform=*) - PLATFORM=$value - ;; - --build=*|--host=*|--target=*|--exec-prefix=*|--bindir=*|--sbindir=*|\ - --sysconfdir=*|--datadir=*|--libexecdir=*|--localstatedir=*|\ - --enable-static|\ - --sharedstatedir=*|--infodir=*|--enable-shared|--disable-shared|\ - --cache-file=*|--srcdir=*) - # ignore for compat with regular configure - ;; - --*) - if test "$OPTION_CHECKING" -eq 1; then - echo "$0 [--help]" - echo "Unknown option $option" - exit $EXIT_FAILURE - fi - ;; - *=*) - NAME=`expr -- "$option" : '\([^=]*\)='` - eval "$NAME='$value'" - export $NAME - ;; - *) - echo "$0 [--help]" - echo "Unknown option $option" - exit $EXIT_FAILURE - ;; - esac -done - -HEADERS=${HEADERS:-"${PREFIX}/include"} -LIBRARY=${LIBRARY:-"${PREFIX}/lib"} -MANDIR=${MANDIR:-"${PREFIX}/share/man"} -GZIP=${GZIP:-"gzip -c"} -POINTER_PACK_ENABLE=${POINTER_PACK_ENABLE:-"CK_MD_POINTER_PACK_DISABLE"} -RTM_ENABLE=${RTM_ENABLE_SET:-"CK_MD_RTM_DISABLE"} -VMA_BITS=${VMA_BITS:-"unknown"} - -DCORES=2 -printf "Detecting operating system......." -SYSTEM=`uname -s 2> /dev/null` -case "$SYSTEM" in - "SunOS") - SYSTEM=solaris - ;; - "Linux"|"uClinux") - DCORES=`egrep '(^CPU[0-9]+|^processor.*:.*)' /proc/cpuinfo|wc -l` - SYSTEM=linux - ;; - "FreeBSD"|"GNU/kFreeBSD") - DCORES=`sysctl -n hw.ncpu` - SYSTEM=freebsd - ;; - "NetBSD") - DCORES=`sysctl -n hw.ncpu` - SYSTEM=netbsd - ;; - "OpenBSD") - DCORES=`sysctl -n hw.ncpu` - SYSTEM=openbsd - ;; - "DragonFly") - DCORES=`sysctl -n hw.ncpu` - SYSTEM=dragonflybsd - ;; - "Darwin") - DCORES=`sysctl -n hw.ncpu` - SYSTEM=darwin - ;; - MINGW32*) - SYSTEM=mingw32 - LDFLAGS="-mthreads $LDFLAGS" - ;; - CYGWIN_NT*) - SYSTEM=cygwin - LDFLAGS="-mthreads $LDFLAGS" - ;; - *) - SYSTEM= - ;; -esac - -assert "$SYSTEM" "$SYSTEM" "unsupported" - -CORES=${CORES:-${DCORES}} -printf "Detecting machine architecture..." -if test "x$PLATFORM" = "x"; then - PLATFORM=`uname -m 2> /dev/null` -fi - -case $PLATFORM in - "macppc"|"Power Macintosh"|"powerpc") - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_RMO"}" - PLATFORM=ppc - ENVIRONMENT=32 - LDFLAGS="-m32 $LDFLAGS" - ;; - "sun4u"|"sun4v"|"sparc64") - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_TSO"}" - PLATFORM=sparcv9 - ENVIRONMENT=64 - LDFLAGS="-m64 $LDFLAGS" - ;; - i386|i486|i586|i686|i586_i686|pentium*|athlon*|k5|k6|k6_2|k6_3) - MM="${MM:-"CK_MD_TSO"}" - case $SYSTEM in - darwin) - ENVIRONMENT=64 - PLATFORM=x86_64 - ;; - freebsd) - PLATFORM=x86 - ENVIRONMENT=32 - - # FreeBSD doesn't give us a nice way to determine the CPU - # class of the running system, reporting any 32-bit x86 - # architecture as i386. 486 is its minimum supported CPU - # class and cmpxchg8b was implemented first in i586. - dmesg | grep -q "486-class" - if test "$?" -eq 0; then - assert "" "" "Must have an i586 class or higher CPU" - fi - - # FreeBSD still generates code for 486-class CPUs as its - # default 32-bit target, but we need 586 at the least. - echo "$CFLAGS" | grep -q 'march=' - if test "$?" -ne 0; then - # Needed for cmpxchg8b - CFLAGS="$CFLAGS -march=i586" - fi - ;; - linux) - case $PLATFORM in - i386|i486) - assert "" "" "Must have an i586 class or higher CPU" - ;; - esac - - PLATFORM=x86 - ENVIRONMENT=32 - ;; - - *) - PLATFORM=x86 - ENVIRONMENT=32 - assert "$PLATFORM $ENVIRONMENT" "$PLATFORM $ENVIRONMENT" "unsupported" - ;; - esac - ;; - "amd64"|"x86_64") - PLATFORM=x86_64 - ENVIRONMENT=64 - LDFLAGS="-m64 $LDFLAGS" - MM="${MM:-"CK_MD_TSO"}" - ;; - "i86pc") - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_TSO"}" - if test -z "$ISA"; then ISA=`isainfo -n 2> /dev/null || echo i386` ; fi - case "$ISA" in - "amd64") - RTM_ENABLE=${RTM_ENABLE_SET:-"CK_MD_RTM_DISABLE"} - PLATFORM=x86_64 - ENVIRONMENT=64 - ;; - *) - PLATFORM=x86 - ENVIRONMENT=32 - assert "$PLATFORM $ENVIRONMENT" "$PLATFORM $ENVIRONMENT" "unsupported" - ;; - esac - ;; - "ppc64"|"ppc64le") - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_RMO"}" - PLATFORM=ppc64 - ENVIRONMENT=64 - ;; - arm|armv6l|armv7l) - if test "$PLATFORM" = "armv6l"; then - CFLAGS="$CFLAGS -march=armv6k"; - elif test "$PLATFORM" = "armv7l"; then - CFLAGS="$CFLAGS -march=armv7-a"; - fi - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_RMO"}" - PLATFORM=arm - ENVIRONMENT=32 - ;; - "arm64"|"aarch64") - RTM_ENABLE="CK_MD_RTM_DISABLE" - MM="${MM:-"CK_MD_RMO"}" - PLATFORM=aarch64 - ENVIRONMENT=64 - ;; - *) - RTM_ENABLE="CK_MD_RTM_DISABLE" - PLATFORM= - MM="${MM:-"CK_MD_RMO"}" - ;; -esac - -assert "$PLATFORM" "$PLATFORM" "unsupported" - -if test "$VMA" = "unknown"; then - VMA_BITS_R="CK_MD_VMA_BITS_UNKNOWN" - VMA_BITS_VALUE_R="" - POINTER_PACK_ENABLE="CK_MD_POINTER_PACK_DISABLE" -else - VMA_BITS_R="CK_MD_VMA_BITS" - VMA_BITS_VALUE_R="${VMA_BITS}ULL" -fi - -if test "$USE_CC_BUILTINS"; then - CFLAGS="$CFLAGS -DCK_CC_BUILTINS" - PC_CFLAGS="-DCK_CC_BULITINS" -fi - -# `which` on Solaris sucks -pathsearch() -{ - what=$1 - oldFS="$IFS" - IFS=":" - for d in $PATH ; do - if test -x "$d/$what" ; then - echo "$d/$what"; - IFS="$oldFS" - return - fi - done - IFS="$oldFS" -} - -printf "Finding dirname command.........." -DIRNAME=`pathsearch "${DIRNAME:-dirname}"` -if test -z "$DIRNAME" -o ! -x "$DIRNAME"; then - DIRNAME=`pathsearch "${DIRNAME:-dirname}"` - DIRNAME="$DIRNAME" -else - echo "success [$DIRNAME]" -fi - -if test -z "$DIRNAME"; then - echo "not found (out of source build unsupported)" -else - printf "Determining build directory......" - - BUILD_DIR=`$DIRNAME $0` - cd `$DIRNAME $0` - BUILD_DIR=`pwd` - - echo "success [$BUILD_DIR]" -fi - -printf "Finding gzip tool................" -GZIP=`pathsearch "${GZIP:-gzip}"` -if test -z "$GZIP" -o ! -x "$GZIP"; then - GZIP=`pathsearch "${GZIP:-gzip}"` - GZIP="$GZIP" -fi - -if test -z "$GZIP"; then - echo "not found" - GZIP=cat - GZIP_SUFFIX="" -else - echo "success [$GZIP]" - GZIP="$GZIP -c" - GZIP_SUFFIX=".gz" -fi - -printf "Finding suitable compiler........" -CC=`pathsearch "${CC:-cc}"` -if test -z "$CC" -o ! -x "$CC"; then - CC=`pathsearch "${CC:-gcc}"` -fi -assert "$CC" "not found" - -cat << EOF > .1.c -#include -int main(void) { -#if defined(_WIN32) -#if defined(__MINGW64__) - puts("mingw64"); - return (0); -#elif defined(__MINGW32__) && (__MINGW32_MAJOR_VERSION >= 3) - puts("mingw32"); - return (0); -#else - return (1); -#endif /* __MINGW32__ && __MINGW32_MAJOR_VERSION >= 3 */ -#elif defined(__clang__) && (__clang_major__ >= 3) - puts("clang"); - return (0); -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5110) - puts("suncc"); - return (0); -#elif defined(__GNUC__) && (__GNUC__ >= 4) - puts("gcc"); - return (0); -#else - return (1); -#endif -} -EOF - -$CC -o .1 .1.c -COMPILER=`./.1` -r=$? -rm -f .1.c .1 - -if test "$r" -ne 0; then - assert "" "update compiler" -else - echo "success [$CC]" -fi - -if test "$COMPILER" = "suncc"; then - LD=/bin/ld - LDFLAGS="-G -z text -h libck.so.$VERSION_MAJOR $LDFLAGS" - CFLAGS="-xO5 $CFLAGS" - PTHREAD_CFLAGS="-mt -lpthread" -elif test "$COMPILER" = "gcc" || test "$COMPILER" = "clang" || test "$COMPILER" = "mingw32" || test "$COMPILER" = "mingw64"; then - LD=$CC - SONAME="$LDNAME_MAJOR" - if test "$SYSTEM" = "darwin"; then - CC_WL_OPT="-install_name" - LDNAME="libck.dylib" - LDNAME_VERSION="libck.$VERSION.dylib" - LDNAME_MAJOR="libck.$VERSION_MAJOR.dylib" - SONAME="$LIBRARY/$LDNAME_MAJOR" - else - CC_WL_OPT="-soname" - fi - - LDFLAGS="-Wl,$CC_WL_OPT,$SONAME $LDFLAGS" - if test "$WANT_PIC" = "yes"; then - LDFLAGS="$LDFLAGS -shared -fPIC" - CFLAGS="$CFLAGS -fPIC" - ALL_LIBS="libck.so libck.a" - INSTALL_LIBS="install-so install-lib" - else - LDFLAGS="$LDFLAGS -fno-PIC" - CFLAGS="$CFLAGS -fno-PIC" - ALL_LIBS="libck.a" - INSTALL_LIBS="install-lib" - fi - - CFLAGS="-D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=gnu99 -pedantic -Wall -W -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -fstrict-aliasing -O2 -pipe -Wno-parentheses $CFLAGS" - PTHREAD_CFLAGS="-pthread" - if test "$COMPILER" = "mingw64"; then - ENVIRONMENT=64 - PLATFORM=x86_64 - fi -else - assert "" "unknown compiler" -fi - -printf "Detecting VMA bits..............." -VMA="unknown" -if test "$VMA_BITS" = "unknown"; then - if test "$PLATFORM" = "x86" || test $PLATFORM = "x86_64"; then - case $SYSTEM in - darwin) - VMA=`sysctl -n machdep.cpu.address_bits.virtual` - ;; - linux) - VMA=`awk '/address sizes/ {print $7;exit}' /proc/cpuinfo` - ;; - *) - if test "$PLATFORM" = "x86"; then - VMA="32" - else - cat << EOF > .1.c - #include - - int main(int argc, char *argv[]) - { - unsigned long ret = 0x80000000; - - __asm __volatile("cpuid\n" - : "+a" (ret)); - if (ret >= 0x80000008) { - ret = 0x80000008; - __asm __volatile("cpuid\n" - : "+a" (ret)); - printf("%lu\n", (ret >> 8) & 0xff); - } else { - return (1); - } - return (0); - } -EOF - - $CC -o .1 .1.c 2>/dev/null - VMA=`./.1 2>/dev/null` - if test $? -ne 0; then - VMA="unknown" - fi - rm -f .1.c .1 - fi - esac - fi - - VMA_BITS=$VMA -else - VMA=$VMA_BITS -fi - -if test "$VMA" = "unknown"; then - echo "unknown" - VMA_BITS_R="CK_MD_VMA_BITS_UNKNOWN" - VMA_BITS_VALUE_R="" - POINTER_PACK_ENABLE="CK_MD_POINTER_PACK_DISABLE" -else - echo "success [$VMA]" - VMA_BITS_R="CK_MD_VMA_BITS" - VMA_BITS_VALUE_R="${VMA_BITS}ULL" -fi - -for i in $REQUIRE_HEADER; do - printf "Checking header file usability..." - - cat << EOF > .1.c -#include <$i> -int main(void){return(0);} -EOF - $CC -o .1 .1.c 2> /dev/null - hf_s=$? - - rm -f .1 .1.c - if test $hf_s -eq 0; then - echo "success [$i]" - else - echo "failed [$i]" - exit $EXIT_FAILURE - fi -done - -printf "Detecting git SHA................" -get_git_sha -echo "$GIT_MSG [$GIT_SHA]" - -if test "$PROFILE"; then - printf "Using user-specified profile....." - - if test -z "$CC"; then - echo "failed [specify compiler]" - exit $EXIT_FAILURE - fi - - if test ! -f build/ck.build.$PROFILE; then - echo "failed [$PROFILE]" - exit $EXIT_FAILURE - fi - - echo "success [$PROFILE]" - printf "Generating header files.........." - generate include/ck_md.h.in include/ck_md.h - echo "success" - printf "Generating build files..........." - generate src/Makefile.in src/Makefile - generate doc/Makefile.in doc/Makefile - generate build/ck.build.in build/ck.build - generate build/regressions.build.in build/regressions.build - generate build/ck.pc.in build/ck.pc - generate build/ck.spec.in build/ck.spec - generate Makefile.in Makefile - echo "success" - generate_stdout - exit $EXIT_SUCCESS -fi - -# Platform will be used as a macro. -PROFILE="${PROFILE:-$PLATFORM}" -PLATFORM="__${PLATFORM}__" - -printf "Generating header files.........." -generate include/ck_md.h.in include/ck_md.h -echo "success" - -printf "Generating build files..........." - -mkdir -p $P_PWD/doc -mkdir -p $P_PWD/build -mkdir -p $P_PWD/include -mkdir -p $P_PWD/src - -if test "$P_PWD" '!=' "$BUILD_DIR"; then - mkdir -p $P_PWD/regressions - cp $BUILD_DIR/regressions/Makefile.unsupported $P_PWD/regressions/Makefile &> /dev/null - cp $BUILD_DIR/build/ck.build.$PROFILE $P_PWD/build/ck.build.$PROFILE &> /dev/null - cp $BUILD_DIR/include/ck_md.h $P_PWD/include/ck_md.h &> /dev/null -fi - -generate src/Makefile.in $P_PWD/src/Makefile -generate doc/Makefile.in $P_PWD/doc/Makefile -generate build/ck.build.in $P_PWD/build/ck.build -generate build/regressions.build.in $P_PWD/build/regressions.build -generate build/ck.pc.in $P_PWD/build/ck.pc -generate build/ck.spec.in $P_PWD/build/ck.spec -generate Makefile.in $P_PWD/Makefile -touch src/*.c -echo "success" -generate_stdout diff --git a/doc/CK_ARRAY_FOREACH b/doc/CK_ARRAY_FOREACH deleted file mode 100644 index d85b767c34ea..000000000000 --- a/doc/CK_ARRAY_FOREACH +++ /dev/null @@ -1,79 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_FOREACH 3 -.Sh NAME -.Nm CK_ARRAY_FOREACH -.Nd iterate through an array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn CK_ARRAY_FOREACH "ck_array_t *array" "ck_array_iterator_t *iterator" "void **b" -.Sh DESCRIPTION -The -.Fn CK_ARRAY_FOREACH 3 -macro iterates through the array pointed to by -.Fa array . -A pointer to an iterator object must be specified by -.Fa iterator -and -.Fa b -must point to a void pointer. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* Assume this was already previously initialized. */ -ck_array_t array; - -void -example(void) -{ - ck_array_iterator_t iterator; - void *pointer; - - CK_ARRAY_FOREACH(&array, &iterator, &pointer) { - do_something(pointer); - } -} -.Ed -.Sh RETURN VALUES -This macro has no return value. -.Sh SEE ALSO -.Xr ck_array_init 3 , -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_INIT b/doc/CK_COHORT_INIT deleted file mode 100644 index 94454d9f07e8..000000000000 --- a/doc/CK_COHORT_INIT +++ /dev/null @@ -1,66 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_COHORT_INIT 3 -.Sh NAME -.Nm CK_COHORT_INIT -.Nd initialize instance of a cohort type -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_INIT "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_lock" \ -"void *local_lock" "unsigned int pass_limit" -.Sh DESCRIPTION -Until a cohort instance is initialized using the CK_COHORT_INIT macro, any operations -involving it will have undefined behavior. After this macro has been called, the cohort -pointed to by the -.Fa cohort -argument will use the lock pointed to by -.Fa global_lock -as its global lock and the lock pointed to by -.Fa local_lock -as its local lock. -.Pp -The cohort will relinquish its global lock after -.Fa pass_limit -consecutive acquisitions of its local lock, even if there are other threads waiting. -If you are unsure of a value to use for the -.Fa pass_limit -argument, you should use CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_INSTANCE b/doc/CK_COHORT_INSTANCE deleted file mode 100644 index cec16171a869..000000000000 --- a/doc/CK_COHORT_INSTANCE +++ /dev/null @@ -1,59 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_COHORT_INSTANCE 3 -.Sh NAME -.Nm CK_COHORT_INSTANCE -.Nd declare an instance of a cohort type -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_INSTANCE "COHORT_NAME cohort_name" -.Sh DESCRIPTION -The user must use this macro to declare instances of cohort types that they have -defined. For instance, if they have used the CK_COHORT_PROTOTYPE macro to define -a cohort type with name foo, they would create an instance of this type as follows: -.br -CK_COHORT_INSTANCE(foo) cohort; -.Pp -This macro should also be used when allocating memory for cohorts. For instance, -to allocate a block of 4 cohorts: -.br -CK_COHORT_INSTANCE(foo) *cohorts = malloc(4 * sizeof(CK_COHORT_INSTANCE(foo))); -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_LOCK b/doc/CK_COHORT_LOCK deleted file mode 100644 index 22475f81b2be..000000000000 --- a/doc/CK_COHORT_LOCK +++ /dev/null @@ -1,61 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_COHORT_LOCK 3 -.Sh NAME -.Nm CK_COHORT_LOCK -.Nd acquire cohort lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_LOCK "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_context" \ -"void *local_context" -.Sh DESCRIPTION -This call attempts to acquire both the local and global (if necessary) locks from -.Fa cohort . -The call will block until both locks have been acquired. -.Fa global_context -will be passed as the second argument to the function that was provided as the -.Fa global_lock_method -argument to CK_COHORT_PROTOTYPE if that method is called, and -.Fa local_context -will be passed to the function specified by -.Fa local_lock_method -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_PROTOTYPE b/doc/CK_COHORT_PROTOTYPE deleted file mode 100644 index 7a7b1a717f6e..000000000000 --- a/doc/CK_COHORT_PROTOTYPE +++ /dev/null @@ -1,76 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_COHORT_PROTOTYPE 3 -.Sh NAME -.Nm CK_COHORT_PROTOTYPE -.Nd define cohort type with specified lock types -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_PROTOTYPE "COHORT_NAME cohort_name" "TYPE global_lock_method" \ -"LOCK_FXN global_unlock_method" "LOCK_FXN local_lock_method" "LOCK_FXN local_unlock_method" -.Sh DESCRIPTION -The ck_cohort.h header file does not define any cohort types. Instead, the user must use -the CK_COHORT_PROTOTYPE or -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macros to define any types they want to use. They must use CK_COHORT_TRYLOCK_PROTOTYPE -if they want their cohort type to support trylock operations. -The CK_COHORT_PROTOTYPE macro takes the following arguments: -.Pp -.Fa cohort_name -: An identifier used for this cohort type. This will have to be passed to each -of the other CK_COHORT macros. -.br -.Fa global_lock_method -: The method that should be called to acquire the global lock -.br -.Fa global_unlock_method -: The method that should be called to relinquish the global lock -.br -.Fa local_lock_method -: The method that should be called to acquire the local lock -.br -.Fa local_unlock_method -: The method that should be called to relinquish the local lock -.Pp -Instances of the defined cohort type can be declared as: -.br - CK_COHORT_INSTANCE(cohort_name) cohort; -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_TRYLOCK b/doc/CK_COHORT_TRYLOCK deleted file mode 100644 index 22bb4b52f856..000000000000 --- a/doc/CK_COHORT_TRYLOCK +++ /dev/null @@ -1,69 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 9, 2013. -.Dt CK_COHORT_TRYLOCK 3 -.Sh NAME -.Nm CK_COHORT_TRYLOCK -.Nd try to acquire cohort lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_TRYLOCK "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_trylock_context" \ -"void *local_trylock_context" "void *lock_unlock_context" -.Sh DESCRIPTION -This call attempts to acquire both the local and global (if necessary) locks from -.Fa cohort . -It can only be used with cohort types that were defined using the -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macro. The call will not block and will return a bool that will evaluate to true iff -the cohort was successfully acquired. -.Fa global_trylock_context -will be passed as the second argument to the function that was provided as the -.Fa global_trylock_method -argument to CK_COHORT_TRYLOCK_PROTOTYPE if that method is called, and -.Fa local_trylock_context -will be passed to the function specified by -.Fa local_trylock_method . -If the global lock acquisition fails, then the cohort will immediately release its -local lock as well, and -.Fa local_unlock_context -will be passed to the function specified by -.Fa local_unlock_method -when this call is made. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_TRYLOCK_PROTOTYPE b/doc/CK_COHORT_TRYLOCK_PROTOTYPE deleted file mode 100644 index dd97ad47b94e..000000000000 --- a/doc/CK_COHORT_TRYLOCK_PROTOTYPE +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 9, 2013. -.Dt CK_COHORT_TRYLOCK_PROTOTYPE 3 -.Sh NAME -.Nm CK_COHORT_TRYLOCK_PROTOTYPE -.Nd define cohort type with specified lock types -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_TRYLOCK_PROTOTYPE "COHORT_NAME cohort_name" "LOCK_FXN global_lock_method" \ -"LOCK_FXN global_unlock_method" "BOOL_LOCK_FXN global_locked_method" \ -"BOOL_LOCK_FXN global_trylock_method" "LOCK_FXN local_lock_method" \ -"LOCK_FXN local_unlock_method" "BOOL_LOCK_FXN local_locked_method" "BOOL_LOCK_FXN local_trylock_method" -.Sh DESCRIPTION -The ck_cohort.h header file does not define any cohort types. Instead, the user must use -the CK_COHORT_PROTOTYPE or CK_COHORT_TRYLOCK_PROTOTYPE macros to define any types -they want to use. They must use CK_COHORT_TRYLOCK_PROTOTYPE if they want their cohort type to have support -for trylock operations. The CK_COHORT_TRYLOCK_PROTOTYPE macro takes the following arguments: -.Pp -.Fa cohort_name -: An identifier used for this cohort type. This will have to be passed to each -of the other CK_COHORT macros. -.br -.Fa global_lock_method -: The method that should be called to acquire the global lock -.br -.Fa global_unlock_method -: The method that should be called to relinquish the global lock -.br -.Fa global_locked_method -: This method should return true iff the global lock is acquired by a thread. -.br -.Fa global_trylock_method -: The method that should be called to try to acquire the global lock. -It should not block and return true iff the lock was successfully acquired. -.br -.Fa local_lock_method -: The method that should be called to acquire the local lock -.br -.Fa local_unlock_method -: The method that should be called to relinquish the local lock -.br -.Fa global_locked_method -: This method should return true iff the global lock is acquired by a thread. -.br -.Fa local_trylock_method -: The method that should be called to try to acquire the local lock. -It should not block and return true iff the lock was successfully acquired. -.Pp -Instances of the defined cohort type can be declared as: -.br - CK_COHORT_INSTANCE(cohort_name) cohort; -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_COHORT_UNLOCK b/doc/CK_COHORT_UNLOCK deleted file mode 100644 index a9f302fb68ef..000000000000 --- a/doc/CK_COHORT_UNLOCK +++ /dev/null @@ -1,61 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_COHORT_UNLOCK 3 -.Sh NAME -.Nm CK_COHORT_UNLOCK -.Nd release cohort lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_UNLOCK "COHORT_NAME cohort_name" "COHORT *cohort" "void *global_context" \ -"void *local_context" -.Sh DESCRIPTION -This call instructs -.Fa cohort -to relinquish its local lock and potentially its global lock as well. -.Fa global_context -will be passed as the second argument to the function that was provided as the -.Fa global_lock_method -argument to CK_COHORT_PROTOTYPE if that method is called, and -.Fa local_context -will be passed to the function specified by -.Fa local_lock_method -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_HS_HASH b/doc/CK_HS_HASH deleted file mode 100644 index 6d8dc753faec..000000000000 --- a/doc/CK_HS_HASH +++ /dev/null @@ -1,71 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 28, 2012 -.Dt CK_HS_HASH 3 -.Sh NAME -.Nm CK_HS_HASH -.Nd invoke hash function with hash set seed -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft unsigned long -.Fn CK_HS_HASH "ck_hs_t *hs" "ck_hs_hash_cb_t *hf" "const void *key" -.Sh DESCRIPTION -The -.Fn CK_HS_HASH 3 -macro will invoke the hash function pointed to by the -.Fa hf -argument with the seed value associated with -.Fa hs -and the key pointer specified by the -.Fa key -argument. -.Sh RETURN VALUES -This function will return the value returned by the -.Fa hf -function. -.Sh ERRORS -It is expected -.Fa hs -was previously initialized via -.Fn ck_hs_init 3 . -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_destroy 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RHS_HASH b/doc/CK_RHS_HASH deleted file mode 100644 index 43b88593e11d..000000000000 --- a/doc/CK_RHS_HASH +++ /dev/null @@ -1,71 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 28, 2012 -.Dt CK_RHS_HASH 3 -.Sh NAME -.Nm CK_RHS_HASH -.Nd invoke hash function with hash set seed -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft unsigned long -.Fn CK_RHS_HASH "ck_rhs_t *hs" "ck_rhs_hash_cb_t *hf" "const void *key" -.Sh DESCRIPTION -The -.Fn CK_RHS_HASH 3 -macro will invoke the hash function pointed to by the -.Fa hf -argument with the seed value associated with -.Fa hs -and the key pointer specified by the -.Fa key -argument. -.Sh RETURN VALUES -This function will return the value returned by the -.Fa hf -function. -.Sh ERRORS -It is expected -.Fa hs -was previously initialized via -.Fn ck_rhs_init 3 . -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_destroy 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_INIT b/doc/CK_RWCOHORT_INIT deleted file mode 100644 index 18d1b33508cc..000000000000 --- a/doc/CK_RWCOHORT_INIT +++ /dev/null @@ -1,61 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_INIT 3 -.Sh NAME -.Nm CK_RWCOHORT_INIT -.Nd initialize instance of a cohort-based reader-writer lock type -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rwcohort.h -.Fn CK_RWCOHORT_NEUTRAL_INIT "COHORT_NAME cohort_name" "LOCK *lock" -.Fn CK_RWCOHORT_RP_INIT "COHORT_NAME cohort_name" "LOCK *lock" "unsigned int wait_limit" -.Fn CK_RWCOHORT_WP_INIT "COHORT_NAME cohort_name" "LOCK *lock" "unsigned int wait_limit" -.Sh DESCRIPTION -This macro initializes the lock instance pointed to by the -.Fa lock -argument. Until a lock instance is initialized using the CK_RWCOHORT_INIT macro, any operations -involving it will have undefined behavior. Note that the -.Fa wait_limit -argument should only be used with reader-preference or writer-preference locks. For neutral -locks, this argument should be excluded. -If you are unsure of a value to use for the -.Fa wait_limit -argument, you should use CK_RWCOHORT_STRATEGY_DEFAULT_LOCAL_WAIT_LIMIT. -.Sh SEE ALSO -.Xr ck_rwcohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_LOCK 3 , -.Xr CK_RWCOHORT_UNLOCK 3 , -.Xr CK_RWCOHORT_LOCKED 3 , -.Xr CK_RWCOHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_INSTANCE b/doc/CK_RWCOHORT_INSTANCE deleted file mode 100644 index 10251a3f56d3..000000000000 --- a/doc/CK_RWCOHORT_INSTANCE +++ /dev/null @@ -1,64 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_INSTANCE 3 -.Sh NAME -.Nm CK_RWCOHORT_INSTANCE -.Nd declare an instance of a cohort-based reader-writer lock type -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_INSTANCE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_RP_INSTANCE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_WP_INSTANCE "COHORT_NAME cohort_name" -.Sh DESCRIPTION -The user must use this macro to declare instances of lock types that they have -defined using the -.Xr CK_RWCOHORT_PROTOTYPE 3 -macro. The cohort_name must be the same as the one used in the prototype macro. -For instance, if CK_RWCOHORT_PROTOTYPE was called with the name "foo", the -CK_RWCOHORT_INSTANCE macro should be called as -.br -CK_RWCOHORT_INSTANCE(foo) cohort; -.Pp -This macro should also be used when allocating memory for cohorts. For instance, -to allocate a block of 4 cohorts: -.br -CK_RWCOHORT_WP_INSTANCE(foo) *cohorts = malloc(4 * sizeof(CK_RWCOHORT_WP_INSTANCE(foo))); -.Sh SEE ALSO -.Xr ck_rwcohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_LOCK 3 , -.Xr CK_RWCOHORT_UNLOCK 3 , -.Xr CK_RWCOHORT_LOCKED 3 , -.Xr CK_RWCOHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_PROTOTYPE b/doc/CK_RWCOHORT_PROTOTYPE deleted file mode 100644 index a2705b63403b..000000000000 --- a/doc/CK_RWCOHORT_PROTOTYPE +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_PROTOTYPE 3 -.Sh NAME -.Nm CK_RWCOHORT_PROTOTYPE -.Nd define reader-writer cohort-based lock using the specified cohort type -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rwcohort.h -.Fn CK_RWCOHORT_NEUTRAL_PROTOTYPE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_RP_PROTOTYPE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_WP_PROTOTYPE "COHORT_NAME cohort_name" -.Sh DESCRIPTION -The ck_rwcohort.h header file does not define any cohort types. Instead, the user must use -the CK_RWCOHORT_PROTOTYPE macro to define any types they want to use. -This macro takes a single argument which corresponds to the type of the cohort lock that -the reader-writer lock should use. A cohort type must have already been defined with that name -using the -.Xr CK_COHORT_PROTOTYPE 3 -or -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macros. -.Pp -Instances of the defined lock type can be declared as: -.br - CK_RWCOHORT_INSTANCE(cohort_name) lock; -.Sh SEE ALSO -.Xr ck_rwcohort 3 , -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_INIT 3 , -.Xr CK_RWCOHORT_READ_LOCK 3 , -.Xr CK_RWCOHORT_READ_UNLOCK 3 , -.Xr CK_RWCOHORT_WRITE_LOCK 3 , -.Xr CK_RWCOHORT_WRITE_UNLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_READ_LOCK b/doc/CK_RWCOHORT_READ_LOCK deleted file mode 100644 index 62831ea36a53..000000000000 --- a/doc/CK_RWCOHORT_READ_LOCK +++ /dev/null @@ -1,66 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_READ_LOCK 3 -.Sh NAME -.Nm CK_RWCOHORT_READ_LOCK -.Nd acquire read-only permission for cohort-based reader-writer lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_READ_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Sh DESCRIPTION -This call will acquire read-only permission from -.Fa lock . -The call will block until this permission has been acquired. -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with -.Fa lock . -The -.Fa global_context -and -.Fa local_context -arguments will be passed along as the context arguments to any calls to -.Fa cohort . -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_INIT 3 , -.Xr CK_RWCOHORT_READ_UNLOCK 3 , -.Xr CK_RWCOHORT_WRITE_LOCK 3 , -.Xr CK_RWCOHORT_WRITE_UNLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_READ_UNLOCK b/doc/CK_RWCOHORT_READ_UNLOCK deleted file mode 100644 index 1c818014ca04..000000000000 --- a/doc/CK_RWCOHORT_READ_UNLOCK +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_READ_UNLOCK 3 -.Sh NAME -.Nm CK_RWCOHORT_READ_UNLOCK -.Nd relinquish read-only access to cohort-based reader-writer lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_READ_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Sh DESCRIPTION -This call will relinquish read-only permission to -.Fa lock . -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with -.Fa lock . -The -.Fa global_context -and -.Fa local_context -arguments will be passed along as the context arguments to any calls to -.Fa cohort . -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_INIT 3 , -.Xr CK_RWCOHORT_READ_LOCK 3 , -.Xr CK_RWCOHORT_WRITE_LOCK 3 , -.Xr CK_RWCOHORT_WRITE_UNLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_WRITE_LOCK b/doc/CK_RWCOHORT_WRITE_LOCK deleted file mode 100644 index 161c7bb3dce3..000000000000 --- a/doc/CK_RWCOHORT_WRITE_LOCK +++ /dev/null @@ -1,66 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_WRITE_LOCK 3 -.Sh NAME -.Nm CK_RWCOHORT_WRITE_LOCK -.Nd acquite write access for a cohort-based reader-writer lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_WRITE_LOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Sh DESCRIPTION -This call will acquire write permission for -.Fa lock . -The call will block until this permission has been acquired. -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with -.Fa lock . -The -.Fa global_context -and -.Fa local_context -arguments will be passed along as the context arguments to any calls to -.Fa cohort . -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_INIT 3 , -.Xr CK_RWCOHORT_READ_LOCK 3 , -.Xr CK_RWCOHORT_READ_UNLOCK 3 , -.Xr CK_RWCOHORT_WRITE_UNLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/CK_RWCOHORT_WRITE_UNLOCK b/doc/CK_RWCOHORT_WRITE_UNLOCK deleted file mode 100644 index 5772a9faf6bb..000000000000 --- a/doc/CK_RWCOHORT_WRITE_UNLOCK +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt CK_RWCOHORT_WRITE_UNLOCK 3 -.Sh NAME -.Nm CK_RWCOHORT_WRITE_UNLOCK -.Nd relinquish write access for cohort-based reader-writer lock -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_RWCOHORT_NEUTRAL_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_RP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_WP_WRITE_UNLOCK "COHORT_NAME cohort_name" "LOCK *lock" "COHORT *cohort"\ -"void *global_context" "void *local_context" -.Sh DESCRIPTION -This call will relinquish write permission for -.Fa lock . -.Fa cohort -must point to a cohort whose global lock is the same as all other cohorts used with -.Fa lock . -The -.Fa global_context -and -.Fa local_context -arguments will be passed along as the context arguments to any calls to -.Fa cohort . -. -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr CK_RWCOHORT_PROTOTYPE 3 , -.Xr CK_RWCOHORT_INSTANCE 3 , -.Xr CK_RWCOHORT_INITIALIZER 3 , -.Xr CK_RWCOHORT_INIT 3 , -.Xr CK_RWCOHORT_READ_LOCK 3 , -.Xr CK_RWCOHORT_READ_UNLOCK 3 , -.Xr CK_RWCOHORT_WRITE_LOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/Makefile.in b/doc/Makefile.in deleted file mode 100644 index cbad704b709f..000000000000 --- a/doc/Makefile.in +++ /dev/null @@ -1,218 +0,0 @@ -.PHONY: clean install uninstall - -MANDIR=@MANDIR@ -GZIP=@GZIP@ -GZIP_SUFFIX=.3@GZIP_SUFFIX@ -BUILD_DIR=@BUILD_DIR@ -SRC_DIR=@SRC_DIR@ -HTML_SUFFIX=.html - -OBJECTS=CK_ARRAY_FOREACH \ - ck_array_buffer \ - ck_array_commit \ - ck_array_deinit \ - ck_array_init \ - ck_array_initialized \ - ck_array_length \ - ck_array_put \ - ck_array_put_unique \ - ck_array_remove \ - ck_array_deinit \ - ck_brlock \ - ck_ht_count \ - ck_ht_destroy \ - ck_ht_gc \ - ck_ht_get_spmc \ - ck_ht_grow_spmc \ - ck_ht_hash \ - ck_ht_hash_direct \ - ck_ht_init \ - ck_ht_put_spmc \ - ck_ht_remove_spmc \ - ck_ht_reset_spmc \ - ck_ht_reset_size_spmc \ - ck_ht_set_spmc \ - ck_ht_entry_empty \ - ck_ht_entry_key \ - ck_ht_entry_key_direct \ - ck_ht_entry_key_length \ - ck_ht_entry_key_set \ - ck_ht_entry_key_set_direct \ - ck_ht_entry_set \ - ck_ht_entry_set_direct \ - ck_ht_entry_value_direct \ - ck_ht_entry_value \ - ck_ht_iterator_init \ - ck_ht_next \ - ck_ht_stat \ - ck_bitmap_init \ - ck_bitmap_reset \ - ck_bitmap_set \ - ck_bitmap_bts \ - ck_bitmap_test \ - ck_bitmap_base \ - ck_bitmap_union \ - ck_bitmap_size \ - ck_bitmap_clear \ - ck_bitmap_bits \ - ck_bitmap_buffer \ - ck_bitmap_next \ - ck_bitmap_iterator_init \ - ck_elide \ - ck_epoch_barrier \ - ck_epoch_begin \ - ck_epoch_call \ - ck_epoch_end \ - ck_epoch_init \ - ck_epoch_poll \ - ck_epoch_recycle \ - ck_epoch_register \ - ck_epoch_reclaim \ - ck_epoch_synchronize \ - ck_epoch_unregister \ - ck_hs_gc \ - ck_hs_init \ - ck_hs_destroy \ - CK_HS_HASH \ - ck_hs_apply \ - ck_hs_iterator_init \ - ck_hs_next \ - ck_hs_get \ - ck_hs_put \ - ck_hs_put_unique \ - ck_hs_set \ - ck_hs_fas \ - ck_hs_remove \ - ck_hs_move \ - ck_hs_grow \ - ck_hs_rebuild \ - ck_hs_count \ - ck_hs_reset \ - ck_hs_reset_size \ - ck_hs_stat \ - ck_rhs_gc \ - ck_rhs_init \ - ck_rhs_destroy \ - CK_RHS_HASH \ - ck_rhs_apply \ - ck_rhs_iterator_init \ - ck_rhs_next \ - ck_rhs_get \ - ck_rhs_put \ - ck_rhs_put_unique \ - ck_rhs_set \ - ck_rhs_fas \ - ck_rhs_remove \ - ck_rhs_move \ - ck_rhs_grow \ - ck_rhs_rebuild \ - ck_rhs_count \ - ck_rhs_reset \ - ck_rhs_reset_size \ - ck_rhs_stat \ - ck_rwcohort \ - CK_RWCOHORT_INIT \ - CK_RWCOHORT_INSTANCE \ - CK_RWCOHORT_PROTOTYPE \ - CK_RWCOHORT_READ_LOCK \ - CK_RWCOHORT_READ_UNLOCK \ - CK_RWCOHORT_WRITE_LOCK \ - CK_RWCOHORT_WRITE_UNLOCK \ - ck_cohort \ - CK_COHORT_PROTOTYPE \ - CK_COHORT_TRYLOCK_PROTOTYPE \ - CK_COHORT_INSTANCE \ - CK_COHORT_INIT \ - CK_COHORT_LOCK \ - CK_COHORT_UNLOCK \ - CK_COHORT_TRYLOCK \ - ck_pr \ - ck_pr_fence_acquire \ - ck_pr_fence_release \ - ck_pr_barrier \ - ck_pr_fas \ - ck_pr_fence_atomic \ - ck_pr_fence_atomic_load \ - ck_pr_fence_atomic_store \ - ck_pr_fence_load \ - ck_pr_fence_load_atomic \ - ck_pr_fence_load_store \ - ck_pr_fence_load_depends \ - ck_pr_fence_memory \ - ck_pr_fence_store \ - ck_pr_fence_store_atomic \ - ck_pr_fence_store_load \ - ck_pr_stall \ - ck_pr_faa \ - ck_pr_inc \ - ck_pr_dec \ - ck_pr_not \ - ck_pr_neg \ - ck_pr_add \ - ck_pr_sub \ - ck_pr_and \ - ck_pr_xor \ - ck_pr_or \ - ck_pr_cas \ - ck_pr_bts \ - ck_pr_btc \ - ck_pr_btr \ - ck_pr_store \ - ck_pr_load \ - ck_pr_rtm \ - ck_queue \ - ck_ring_init \ - ck_ring_dequeue_spmc \ - ck_ring_enqueue_spmc \ - ck_ring_enqueue_spmc_size \ - ck_ring_trydequeue_spmc \ - ck_ring_dequeue_spsc \ - ck_ring_enqueue_spsc \ - ck_ring_enqueue_spsc_size \ - ck_ring_size \ - ck_ring_capacity \ - ck_tflock \ - ck_rwlock \ - ck_pflock \ - ck_swlock \ - ck_sequence \ - ck_spinlock - -all: - for target in $(OBJECTS); do \ - $(GZIP) $(SRC_DIR)/doc/$$target > $(BUILD_DIR)/doc/$$target$(GZIP_SUFFIX); \ - done - -html: - for target in $(OBJECTS); do \ - echo $$target; \ - groff -man -Tascii $(SRC_DIR)/doc/$$target | col -bx > \ - $(BUILD_DIR)/doc/$$target$(HTML_SUFFIX); \ - sed -i.bk 's/\&/\&\;/g;s/>/\>\;/g;s/&2; \ - fi; \ - done - -# check for stale references -refcheck: - @./refcheck.pl $(OBJECTS) - -install: - mkdir -p $(DESTDIR)/$(MANDIR)/man3 || exit - cp *$(GZIP_SUFFIX) $(DESTDIR)/$(MANDIR)/man3 || exit - -uninstall: - for target in $(OBJECTS); do \ - rm -f $(DESTDIR)/$(MANDIR)/man3/$$target$(GZIP_SUFFIX); \ - done - -clean: - rm -f $(BUILD_DIR)/doc/*~ $(BUILD_DIR)/doc/*$(GZIP_SUFFIX) $(BUILD_DIR)/doc/*$(HTML_SUFFIX) - diff --git a/doc/ck_array_buffer b/doc/ck_array_buffer deleted file mode 100644 index 7a8ded33a358..000000000000 --- a/doc/ck_array_buffer +++ /dev/null @@ -1,60 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_BUFFER 3 -.Sh NAME -.Nm ck_array_buffer -.Nd return length and pointer to array of reader-visible pointers -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft void * -.Fn ck_array_buffer "ck_array_t *array" "unsigned int *length" -.Sh DESCRIPTION -The -.Fn ck_array_buffer 3 -returns a pointer to the array of pointers currently visible -to readers after the last commit operation in -.Fa array . -The unsigned integer pointed to by -.Fa length -is updated to reflect the length of the array. -.Sh RETURN VALUES -This function returns a pointer to an array of pointers. -.Sh SEE ALSO -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_init 3 -.Xr ck_array_deinit 3 , -.Xr ck_array_length 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_commit b/doc/ck_array_commit deleted file mode 100644 index 0fc1192e8f5e..000000000000 --- a/doc/ck_array_commit +++ /dev/null @@ -1,58 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_COMMIT 3 -.Sh NAME -.Nm ck_array_commit -.Nd linearization point for mutations before commit call -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn ck_array_commit "ck_array_t *array" -.Sh DESCRIPTION -The -.Fn ck_array_commit 3 -function will commit any pending put or remove operations associated -with the array. The function may end up requesting the safe reclamation -of memory actively being iterated upon by other threads. -.Sh RETURN VALUES -This function returns true if the commit operation succeeded. It will -return false otherwise, and pending operations will not be applied. -.Sh SEE ALSO -.Xr ck_array_init 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_deinit b/doc/ck_array_deinit deleted file mode 100644 index 3a5e5ab90bbb..000000000000 --- a/doc/ck_array_deinit +++ /dev/null @@ -1,62 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_DEINIT 3 -.Sh NAME -.Nm ck_array_deinit -.Nd destroy and deinitialize a pointer array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft void -.Fn ck_array_deinit "ck_array_t *array" "bool defer" -.Sh DESCRIPTION -The -.Fn ck_array_deinit 3 -destroys the memory associated with the array pointed -to by -.Fa array . -The -.Fa defer -argument is true if the allocator must destroy -the memory using safe memory reclamation or false -if the allocator can destroy this memory immediately. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_init 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_init b/doc/ck_array_init deleted file mode 100644 index ad8a9fe57b72..000000000000 --- a/doc/ck_array_init +++ /dev/null @@ -1,69 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_INIT 3 -.Sh NAME -.Nm ck_array_init -.Nd initialize a pointer array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn ck_array_init "ck_array_t *array" "unsigned int mode" "struct ck_malloc *allocator" "unsigned int initial_length" -.Sh DESCRIPTION -The -.Fn ck_array_init 3 -function initializes the array pointed to by the argument -.Fa array . -The mode value must be -.Dv CK_ARRAY_MODE_SPMC . -The -.Fa allocator -argument must point to a ck_malloc data structure with valid non-NULL function pointers -initialized for malloc, free and realloc. The -.Fa initial_length -specifies the initial length of the array. The value of -.Fa initial_length -must be greater than or equal to 2. An array allows for one concurrent put or remove operations -in the presence of any number of concurrent CK_ARRAY_FOREACH operations. -.Sh RETURN VALUES -This function returns true if the array was successfully created. It returns -false if the creation failed. Failure may occur due to internal memory allocation -failures or invalid arguments. -.Sh SEE ALSO -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_initialized b/doc/ck_array_initialized deleted file mode 100644 index 3a064139e0ed..000000000000 --- a/doc/ck_array_initialized +++ /dev/null @@ -1,62 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_INITIALIZED 3 -.Sh NAME -.Nm ck_array_initialized -.Nd indicates whether an array was recently initialized or deinitialized -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn ck_array_initialized "ck_array_t *array" -.Sh DESCRIPTION -The -.Fn ck_array_initialized 3 -can be used to determine whether an array was recently initialized -with -.Fn ck_array_init 3 -or deinitialized with -.Fn ck_array_deinit 3 . -Behavior is undefined if a user allocates internal allocator data -in through other means. -.Sh RETURN VALUES -This function returns true if the array is initialized, and false -otherwise. -.Sh SEE ALSO -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_init 3 -.Xr ck_array_deinit 3 , -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_length b/doc/ck_array_length deleted file mode 100644 index e60c6c3bc00f..000000000000 --- a/doc/ck_array_length +++ /dev/null @@ -1,57 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_LENGTH 3 -.Sh NAME -.Nm ck_array_length -.Nd returns the number of pointers committed to an array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft unsigned int -.Fn ck_array_length "ck_array_t *array" -.Sh DESCRIPTION -The -.Fn ck_array_length 3 -function returns the number of items a concurrent -traversal operation would encounter at completion -time. -.Sh RETURN VALUES -The number of traversal-visible pointers is returned. -.Sh SEE ALSO -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_init 3 -.Xr ck_array_deinit 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_put b/doc/ck_array_put deleted file mode 100644 index 0f74eb06b80d..000000000000 --- a/doc/ck_array_put +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_PUT 3 -.Sh NAME -.Nm ck_array_put -.Nd attempt immediate or deferred insertion of a pointer into array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn ck_array_put "ck_array_t *array" "void *pointer" -.Sh DESCRIPTION -The -.Fn ck_array_put 3 -function will attempt to insert the value of -.Fa pointer -into the array pointed to by -.Fa array . -This function may incur additional memory allocations -if not enough memory has been allocated in the array -for a new entry. The operation is also free to apply -the operation immediately if there is an opportunity -for elimination with a pending (uncommitted) remove -operation. -.Sh RETURN VALUES -This function returns true if the put operation succeeded. It will -return false otherwise due to internal allocation failures. -.Sh SEE ALSO -.Xr ck_array_init 3 , -.Xr ck_array_commit 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_put_unique b/doc/ck_array_put_unique deleted file mode 100644 index bb355febce7e..000000000000 --- a/doc/ck_array_put_unique +++ /dev/null @@ -1,67 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_PUT_UNIQUE 3 -.Sh NAME -.Nm ck_array_put_unique -.Nd attempt immediate or deferred insertion of a unique pointer into array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft int -.Fn ck_array_put_unique "ck_array_t *array" "void *pointer" -.Sh DESCRIPTION -The -.Fn ck_array_put_unique 3 -function will attempt to insert the value of -.Fa pointer -into the array pointed to by -.Fa array . -This function may incur additional memory allocations -if not enough memory has been allocated in the array -for a new entry. The operation is also free to apply -the operation immediately if there is an opportunity -for elimination with a pending (uncommitted) remove -operation. The function will not make any modifications -if the pointer already exists in the array. -.Sh RETURN VALUES -This function returns 1 if the pointer already exists in the array. -It returns 0 if the put operation succeeded. It returns -1 on -error due to internal memory allocation failures. -.Sh SEE ALSO -.Xr ck_array_init 3 , -.Xr ck_array_commit 3 , -.Xr ck_array_put 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_array_remove b/doc/ck_array_remove deleted file mode 100644 index 8df454d8f1d5..000000000000 --- a/doc/ck_array_remove +++ /dev/null @@ -1,64 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd October 18, 2013 -.Dt CK_ARRAY_REMOVE 3 -.Sh NAME -.Nm ck_array_remove -.Nd attempt immediate or deferred removal of a pointer from an array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_array.h -.Ft bool -.Fn ck_array_remove "ck_array_t *array" "void *pointer" -.Sh DESCRIPTION -The -.Fn ck_array_remove 3 -function will attempt to remove the value of -.Fa pointer -into the array pointed to by -.Fa array . The operation is also free to apply -the operation immediately if there is an opportunity -for elimination with a pending (uncommitted) put -operation. If no elimination was possible, the function -may require to allocate more memory. -.Sh RETURN VALUES -This function returns true if the remove operation succeeded. It will -return false otherwise due to internal allocation failures or because -the value did not exist. -.Sh SEE ALSO -.Xr ck_array_init 3 , -.Xr ck_array_commit 3 , -.Xr ck_array_remove 3 , -.Xr ck_array_put_unique 3 , -.Xr ck_array_deinit 3 -.Xr ck_array_length 3 , -.Xr ck_array_buffer 3 , -.Xr ck_array_initialized 3 , -.Xr CK_ARRAY_FOREACH 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_base b/doc/ck_bitmap_base deleted file mode 100644 index e9342bfa375c..000000000000 --- a/doc/ck_bitmap_base +++ /dev/null @@ -1,58 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_BASE 3 -.Sh NAME -.Nm ck_bitmap_base -.Nd determine the size of a bit array in bytes -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft unsigned int -.Fn ck_bitmap_base "unsigned int n_bits" -.Sh DESCRIPTION -The -.Fn ck_bitmap_base -function returns the number of bytes that would be used -to store the number of bits specified by -.Fa n_bits . -.Sh RETURN VALUES -This function returns a non-zero value that is guaranteed to -be a multiple of -.Dv sizeof(CK_BITMAP_WORD) . -.Sh SEE ALSO -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_bits b/doc/ck_bitmap_bits deleted file mode 100644 index efd5eb2ea33d..000000000000 --- a/doc/ck_bitmap_bits +++ /dev/null @@ -1,56 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_BITS 3 -.Sh NAME -.Nm ck_bitmap_bits -.Nd return number of addressable bits in bitmap -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft unsigned int -.Fn ck_bitmap_bits "ck_bitmap_t *bitmap" -.Sh DESCRIPTION -The -.Fn ck_bitmap_bits -function returns the maximum number of addressable bits in -the object pointed to by -.Fa bitmap . -.Sh RETURN VALUES -This function returns a non-zero value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_bts b/doc/ck_bitmap_bts deleted file mode 100644 index 872284c16c51..000000000000 --- a/doc/ck_bitmap_bts +++ /dev/null @@ -1,61 +0,0 @@ -.\" -.\" Copyright 2014 David Joseph. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd August 22, 2014 -.Dt CK_BITMAP_BTS 3 -.Sh NAME -.Nm ck_bitmap_bts -.Nd set the bit at the specified index and fetch its original value -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft bool -.Fn ck_bitmap_bts "ck_bitmap_t *bitmap" "unsigned int n" -.Sh DESCRIPTION -.Fn ck_bitmap_bts -sets the bit at the offset specified by the argument -.Fa n -to -.Dv 1 -and fetches its original value. -.Sh RETURN VALUES -This function returns the original value of the bit at offset -.Fa n -in -.Fa bitmap . -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_buffer b/doc/ck_bitmap_buffer deleted file mode 100644 index 206df0338df1..000000000000 --- a/doc/ck_bitmap_buffer +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_BUFFER 3 -.Sh NAME -.Nm ck_bitmap_buffer -.Nd returns pointer to bit array -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void * -.Fn ck_bitmap_buffer "ck_bitmap_t *bitmap" -.Sh DESCRIPTION -The -.Fn ck_bitmap_buffer -functions returns a pointer to the actual bit array. -For ck_bitmap pointers, the bit array is of type -CK_BITMAP_WORD[] and consists of -ck_bitmap_base(bitmap) / sizeof(CK_BITMAP_WORD) elements. -On currently supported 64-bit platforms -.Dv CK_BITMAP_WORD -is -.Dv uint64_t . -On currently supported 32-bit platforms -.Dv CK_BITMAP_WORD -is -.Dv uint32_t . -.Sh RETURN VALUES -This function returns a non-NULL value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_clear b/doc/ck_bitmap_clear deleted file mode 100644 index f94dca22cd6a..000000000000 --- a/doc/ck_bitmap_clear +++ /dev/null @@ -1,56 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_CLEAR 3 -.Sh NAME -.Nm ck_bitmap_clear -.Nd reset all bits -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void -.Fn ck_bitmap_clear "ck_bitmap_t *bitmap" -.Sh DESCRIPTION -The -.Fn ck_bitmap_clear -function sets all bits in the bitmap pointed to by -.Fa bitmap -to 0. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_init b/doc/ck_bitmap_init deleted file mode 100644 index a238374862a0..000000000000 --- a/doc/ck_bitmap_init +++ /dev/null @@ -1,84 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_INIT 3 -.Sh NAME -.Nm ck_bitmap_init -.Nd initialize a bitmap -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void -.Fn ck_bitmap_init "ck_bitmap_t *bitmap" "unsigned int n_bits" "bool set" -.Sh DESCRIPTION -The -.Fn ck_bitmap_init -function initializes the bitmap pointed to by the -.Fa bitmap -pointer. The argument -.Fa n_bits -specifies the number of bits that are to be stored in the bitmap. -The argument -.Fa set -determines whether the values of the bits in -.Fa bitmap -are to be initialized to -.Dv 1 -or -.Dv 0 . -.Pp -It is expected that -.Fa bitmap -points to a contiguous region of memory containing at least -the number of bytes specified by -.Xr ck_bitmap_size 3 . -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -.Bl -tag -width Er -.Pp -The behavior of -.Fn ck_bitmap_init -is undefined if -.Fa bitmap -is not a pointer to a region of bytes -of at least -.Xr ck_bitmap_size 3 -length. -.El -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_iterator_init b/doc/ck_bitmap_iterator_init deleted file mode 100644 index d67c6595ed77..000000000000 --- a/doc/ck_bitmap_iterator_init +++ /dev/null @@ -1,70 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" Copyright 2012-2013 Shreyas Prasad. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 27, 2012 -.Dt CK_BITMAP_ITERATOR_INIT 3 -.Sh NAME -.Nm ck_bitmap_iterator_init -.Nd initialize bitmap iterator -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Pp -.Ft void -.Fn ck_bitmap_iterator_init "ck_bitmap_iterator_t *iterator" "ck_bitmap_t *bitmap" -.Sh DESCRIPTION -The -.Fn ck_bitmap_iterator_init -function will initialize the object pointed to by -the -.Fa iterator -argument for use with -.Fa bitmap . -.Pp -An iterator is used to iterate through set bitmap bits -with the -.Xr ck_bitmap_next 3 -function. -.Sh RETURN VALUES -The -.Fn ck_bitmap_iterator_init -function does not return a value. -.Sh ERRORS -This function will not fail. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 , -.Xr ck_bitmap_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_next b/doc/ck_bitmap_next deleted file mode 100644 index 3e93c4326652..000000000000 --- a/doc/ck_bitmap_next +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" Copyright 2012-2013 Shreyas Prasad. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 27, 2012 -.Dt CK_BITMAP_TEST 3 -.Sh NAME -.Nm ck_bitmap_next -.Nd iterate to the next set bit in bitmap -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft bool -.Fn ck_bitmap_next "ck_bitmap_t *bitmap" "ck_bitmap_iterator_t iterator" "unsigned int *bit" -.Sh DESCRIPTION -The -.Fn ck_bitmap_next -function will increment the iterator object pointed to by -.Fa iterator -to point to the next set bit in the bitmap. If -.Fn ck_bitmap_next -returns -.Dv true -then the pointer pointed to by -.Fa bit -is initialized to the number of the current set bit pointed to by the -.Fa iterator -object. -.Pp -It is expected that -.Fa iterator -has been initialized using the -.Xr ck_bitmap_iterator_init 3 -function. -.Sh RETURN VALUES -If -.Fn ck_bitmap_next -returns -.Dv true -then the object pointed to by -.Fa bit -contains a set bit. If -.Fn ck_bitmap_next -returns -.Dv false -then value of the object pointed to by -.Fa bit -is undefined. -.Sh ERRORS -Behavior is undefined if -.Fa iterator -or -.Fa bitmap -are uninitialized. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 , -.Xr ck_bitmap_iterator_init 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_reset b/doc/ck_bitmap_reset deleted file mode 100644 index c6b8ee531a33..000000000000 --- a/doc/ck_bitmap_reset +++ /dev/null @@ -1,57 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_RESET 3 -.Sh NAME -.Nm ck_bitmap_reset -.Nd resets the bit at the specified index -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void -.Fn ck_bitmap_reset "ck_bitmap_t *bitmap" "unsigned int n" -.Sh DESCRIPTION -The -.Fn ck_bitmap_reset -resets the bit at offset specified by the argument -.Fa n -to -.Dv 0 . -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_set b/doc/ck_bitmap_set deleted file mode 100644 index e92ba243f83b..000000000000 --- a/doc/ck_bitmap_set +++ /dev/null @@ -1,57 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_SET 3 -.Sh NAME -.Nm ck_bitmap_set -.Nd set the bit at the specified index -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void -.Fn ck_bitmap_set "ck_bitmap_t *bitmap" "unsigned int n" -.Sh DESCRIPTION -The -.Fn ck_bitmap_set -sets the bit at offset specified by the argument -.Fa n -to -.Dv 1 . -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_size b/doc/ck_bitmap_size deleted file mode 100644 index 03e5892fb7f7..000000000000 --- a/doc/ck_bitmap_size +++ /dev/null @@ -1,62 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_SIZE 3 -.Sh NAME -.Nm ck_bitmap_size -.Nd returns necessary number of bytes for bitmap -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft unsigned int -.Fn ck_bitmap_size "unsigned int n_bits" -.Sh DESCRIPTION -The -.Fn ck_bitmap_size -function returns the number of bytes that are necessary -to allocate for a bitmap that will contain the number -of bits specified by -.Fa n_bits . -.Pp -This function is used to determine how many bytes to -allocate for dynamically created bitmap objects. The -allocated object must still be initialized using -.Xr ck_bitmap_init 3 . -.Sh RETURN VALUES -This function returns a non-zero value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set_mpmc 3 , -.Xr ck_bitmap_reset_mpmc 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_test b/doc/ck_bitmap_test deleted file mode 100644 index 9eb8936dac22..000000000000 --- a/doc/ck_bitmap_test +++ /dev/null @@ -1,62 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2012 -.Dt CK_BITMAP_TEST 3 -.Sh NAME -.Nm ck_bitmap_test -.Nd determine if the bit at the specified index is set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft bool -.Fn ck_bitmap_test "ck_bitmap_t *bitmap" "unsigned int n" -.Sh DESCRIPTION -The -.Fn ck_bitmap_test -determines if the bit at the offset specified by the argument -.Fa n -is set to -.Dv 1 . -.Sh RETURN VALUES -This function returns -.Dv true -if the bit at the specified offset is set to -.Dv 1 -and otherwise returns -.Dv false . -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_set_mpmc 3 , -.Xr ck_bitmap_reset_mpmc 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_bitmap_union b/doc/ck_bitmap_union deleted file mode 100644 index b0ab8e8f7e3b..000000000000 --- a/doc/ck_bitmap_union +++ /dev/null @@ -1,58 +0,0 @@ -.\" -.\" Copyright 2012-2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 23, 2013 -.Dt CK_BITMAP_UNION 3 -.Sh NAME -.Nm ck_bitmap_union -.Nd generates union of two bitmaps -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_bitmap.h -.Ft void -.Fn ck_bitmap_union "ck_bitmap_t *dst" "ck_bitmap_t *src" -.Sh DESCRIPTION -The -.Fn ck_bitmap_union -function sets all bits in the bitmap pointed to by -.Fa src -in the bitmap pointed to by -.Fa dst . -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_bitmap_base 3 , -.Xr ck_bitmap_size 3 , -.Xr ck_bitmap_init 3 , -.Xr ck_bitmap_reset 3 , -.Xr ck_bitmap_set 3 , -.Xr ck_bitmap_clear 3 , -.Xr ck_bitmap_test 3 , -.Xr ck_bitmap_bits 3 , -.Xr ck_bitmap_buffer 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_brlock b/doc/ck_brlock deleted file mode 100644 index 7972ee43ef65..000000000000 --- a/doc/ck_brlock +++ /dev/null @@ -1,121 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 26, 2013. -.Dt ck_brlock 3 -.Sh NAME -.Nm ck_brlock_init , -.Nm ck_brlock_write_lock , -.Nm ck_brlock_write_unlock , -.Nm ck_brlock_write_trylock , -.Nm ck_brlock_read_register , -.Nm ck_brlock_read_unregister , -.Nm ck_brlock_read_lock , -.Nm ck_brlock_read_trylock , -.Nm ck_brlock_read_unlock -.Nd big-reader locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_brlock.h -.Pp -.Dv ck_brlock_t brlock = CK_BRLOCK_INITIALIZER; -.Pp -.Dv ck_brlock_reader_t reader = CK_BRLOCK_READER_INITIALIZER; -.Pp -.Ft void -.Fn ck_brlock_init "ck_brlock_t *br" -.Ft void -.Fn ck_brlock_write_lock "ck_brlock_t *br" -.Ft void -.Fn ck_brlock_write_unlock "ck_brlock_t *br" -.Ft bool -.Fn ck_brlock_write_trylock "ck_brlock_t *br" "unsigned int factor" -.Ft void -.Fn ck_brlock_read_register "ck_brlock_t *br" "ck_brlock_reader_t *reader" -.Ft void -.Fn ck_brlock_read_unregister "ck_brlock_t *br" "ck_brlock_reader_t *reader" -.Ft void -.Fn ck_brlock_read_lock "ck_brlock_t *br" "ck_brlock_reader_t *reader" -.Ft bool -.Fn ck_brlock_read_trylock "ck_brlock_t *br" "ck_brlock_reader_t *reader" \ -"unsigned int factor" -.Ft void -.Fn ck_brlock_read_unlock "ck_brlock_reader_t *reader" -.Sh DESCRIPTION -Big reader locks are distributed reader-writer locks with low latency constant time -reader acquisition (with respect to number of concurrent readers). On the other -hand, writer acquisitions are a relatively expensive O(n) operation. This is a write-biased -lock. -.Sh EXAMPLE -.Bd -literal -offset indent -static ck_brlock_t lock = CK_BRLOCK_INITIALIZER; -static __thread ck_brlock_reader_t reader; - -static void -reader(void) -{ - - /* Add our thread as a lock participant. */ - ck_brlock_read_register(&lock, &reader); - - for (;;) { - ck_brlock_read_lock(&lock, &reader); - /* Read-side critical section. */ - ck_brlock_read_unlock(&reader); - - if (ck_brlock_read_trylock(&lock, &reader, 1) == true) { - /* Read-side critical section. */ - ck_brlock_read_unlock(&reader); - } - } - - return; -} - -static void -writer(void) -{ - - for (;;) { - ck_brlock_write_lock(&lock); - /* Write-side critical section. */ - ck_brlock_write_unlock(&lock); - - if (ck_brlock_write_trylock(&lock, 1) == true) { - /* Write-side critical section. */ - ck_brlock_write_unlock(&lock); - } - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_bytelock 3 , -.Xr ck_rwlock 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_cohort b/doc/ck_cohort deleted file mode 100644 index 490541848db0..000000000000 --- a/doc/ck_cohort +++ /dev/null @@ -1,211 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd February 24, 2013. -.Dt ck_cohort 3 -.Sh NAME -.Nm ck_cohort -.Nd generalized interface for lock cohorts -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_cohort.h -.Fn CK_COHORT_PROTOTYPE "COHORT_NAME cohort_name" "LOCK_FXN global_lock_method" \ -"LOCK_FXN global_unlock_method" "LOCK_FXN local_lock_method" "LOCK_FXN local_unlock_method" -.Fn CK_COHORT_TRYLOCK_PROTOTYPE "COHORT_NAME cohort_name" \ -"LOCK_FXN global_lock_method" "LOCK_FXN global_unlock_method" \ -"BOOL_LOCK_FXN global_locked_method" "BOOL_LOCK_FXN global_trylock_method" \ -"LOCK_FXN local_lock_method" "LOCK_FXN local_unlock_method" \ -"BOOL_LOCK_FXN local_locked_method" "BOOL_LOCK_FXN local_trylock_method" -.Fn CK_COHORT_INSTANCE "COHORT_NAME cohort_name" -.Fn CK_COHORT_INIT "COHORT_NAME cohort_name" "ck_cohort *cohort" \ -"void *global_lock" "void *local_lock" "unsigned int pass_limit" -.Fn CK_COHORT_LOCK "COHORT_NAME cohort_name" "ck_cohort *cohort" \ -"void *global_context" "void *local_context" -.Fn CK_COHORT_UNLOCK "COHORT_NAME cohort_name" "ck_cohort *cohort" \ -"void *global_context" "void *local_context" -.Pp -Where LOCK_FXN refers to a method with the signature -.br -void(void *lock, void *context) -.br -BOOL_LOCK_FXN refers to a method with the signature -.br -bool(void *lock, void *context) -.Pp -The -.Fa context -argument in each signature is used to pass along any additional information that -the lock might need for its lock, unlock and trylock methods. The values for this -argument are provided to each call to -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -and -.Xr CK_COHORT_TRYLOCK 3 -. -.Sh DESCRIPTION -ck_cohort.h provides an interface for defining lock cohorts with -arbitrary lock types. Cohorts are a mechanism for coordinating -threads on NUMA architectures in order to reduce the frequency -with which a lock is passed between threads on different clusters. -.Pp -Before using a cohort, the user must define a cohort type using -either the -.Fn CK_COHORT_PROTOTYPE -or the -.Fn CK_COHORT_TRYLOCK_PROTOTYPE -macros. These macros allow the user to specify the lock methods that -they would like the cohort to use. See the -.Xr CK_COHORT_PROTOTYPE 3 -and -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -man pages for more details. -.Pp -.Sh EXAMPLE -.Bd -literal -offset indent -#include -#include - -#include -#include -#include - -/* - * Create cohort methods with signatures that match - * the required signature - */ -static void -ck_spinlock_lock_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - ck_spinlock_lock(lock); - return; -} - -static void -ck_spinlock_unlock_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - ck_spinlock_unlock(lock); - return; -} - -static bool -ck_spinlock_locked_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - return ck_spinlock_locked(lock); -} - -/* - * define a cohort type named "test_cohort" that will use - * the above methods for both its global and local locks - */ -CK_COHORT_PROTOTYPE(test_cohort, - ck_spinlock_lock_with_context, ck_spinlock_unlock_with_context, ck_spinlock_locked_with_context, - ck_spinlock_lock_with_context, ck_spinlock_unlock_with_context, ck_spinlock_locked_with_context) - -static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; -static unsigned int ready; - -static void * -function(void *context) -{ - CK_COHORT_INSTANCE(test_cohort) *cohort = context; - - while (ready == 0); - - while (ready > 0) { - /* - * acquire the cohort lock before performing critical section. - * note that we pass NULL for both the global and local context - * arguments because neither the lock nor unlock functions - * will use them. - */ - CK_COHORT_LOCK(test_cohort, cohort, NULL, NULL); - - /* perform critical section */ - - /* relinquish cohort lock */ - CK_COHORT_UNLOCK(test_cohort, cohort, NULL, NULL); - } - - return NULL; -} - -int -main(void) -{ - unsigned int nthr = 4; - unsigned int n_cohorts = 2; - unsigned int i; - - /* allocate 2 cohorts of the defined type */ - CK_COHORT_INSTANCE(test_cohort) *cohorts = - calloc(n_cohorts, sizeof(CK_COHORT_INSTANCE(test_cohort))); - - /* create local locks to use with each cohort */ - ck_spinlock_t *local_locks = - calloc(n_cohorts, sizeof(ck_spinlock_t)); - - pthread_t *threads = - calloc(nthr, sizeof(pthread_t)); - - /* initialize each of the cohorts before using them */ - for (i = 0 ; i < n_cohorts ; ++i) { - CK_COHORT_INIT(test_cohort, cohorts + i, &global_lock, local_locks + i, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - } - - /* start each thread and assign cohorts equally */ - for (i = 0 ; i < nthr ; ++i) { - pthread_create(threads + i, NULL, function, cohorts + (i % n_cohorts)); - } - - ck_pr_store_uint(&ready, 1); - sleep(10); - ck_pr_store_uint(&ready, 0); - - for (i = 0 ; i < nthr ; ++i) { - pthread_join(threads[i], NULL); - } - - return 0; -} -.Ed -.Sh SEE ALSO -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_elide b/doc/ck_elide deleted file mode 100644 index c0685677a059..000000000000 --- a/doc/ck_elide +++ /dev/null @@ -1,252 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 13, 2013. -.Dt ck_elide 3 -.Sh NAME -.Nm CK_ELIDE_PROTOTYPE , -.Nm CK_ELIDE_LOCK_ADAPTIVE , -.Nm CK_ELIDE_UNLOCK_ADAPTIVE , -.Nm CK_ELIDE_LOCK , -.Nm CK_ELIDE_UNLOCK , -.Nm CK_ELIDE_TRYLOCK_PROTOTYPE , -.Nm CK_ELIDE_TRYLOCK -.Nd lock elision wrappers -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_elide.h -.Pp -.Dv ck_elide_stat_t stat = CK_ELIDE_STAT_INITIALIZER; -.Pp -.Ft void -.Fn ck_elide_stat_init "ck_elide_stat_t *" -.Pp -.Dv struct ck_elide_config config = CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; -.Pp -.Bd -literal -offset -struct ck_elide_config { - unsigned short skip_busy; - short retry_busy; - unsigned short skip_other; - short retry_other; - unsigned short skip_conflict; - short retry_conflict; -}; -.Ed -.Pp -.Fn CK_ELIDE_PROTOTYPE "NAME" "TYPE" "LOCK_PREDICATE" "LOCK_FUNCTION" "UNLOCK_PREDICATE" "UNLOCK_FUNCTION" -.Fn CK_ELIDE_LOCK_ADAPTIVE "NAME" "ck_elide_stat_t *" "struct ck_elide_config *" "TYPE *" -.Fn CK_ELIDE_UNLOCK_ADAPTIVE "NAME" "ck_elide_stat_t *" "TYPE *" -.Fn CK_ELIDE_LOCK "NAME" "TYPE *" -.Fn CK_ELIDE_UNLOCK "NAME" "TYPE *" -.Fn CK_ELIDE_TRYLOCK_PROTOTYPE "NAME" "TYPE" "LOCK_PREDICATE" "TRYLOCK_FUNCTION" -.Sh DESCRIPTION -These macros implement lock elision wrappers for a user-specified single-argument -lock interface. The wrappers will attempt to elide lock acquisition, allowing -concurrent execution of critical sections that do not issue conflicting memory -operations. If any threads have successfully elided a lock acquisition, -conflicting memory operations will roll-back any side-effects of the critical -section and force every thread to retry the lock acquisition regularly. -.Pp -.Fn CK_ELIDE_LOCK , -.Fn CK_ELIDE_UNLOCK , -.Fn CK_ELIDE_LOCK_ADAPTIVE , -and -.Fn CK_ELIDE_UNLOCK_ADAPTIVE -macros require -a previous -.Fn CK_ELIDE_PROTOTYPE -with the same -.Fa NAME . -Elision is attempted if the -.Fa LOCK_PREDICATE -function returns false. If -.Fa LOCK_PREDICATE -returns true then elision is aborted and -.Fa LOCK_FUNCTION -is executed instead. If any threads are in an elided critical section, -.Fa LOCK_FUNCTION -must force them to rollback through a conflicting memory operation. -The -.Fa UNLOCK_PREDICATE -function must return true if the lock is acquired by the caller, meaning -that the lock was not successfully elided. If -.Fa UNLOCK_PREDICATE -returns true, then the -.Fa UNLOCK_FUNCTION -is executed. If RTM is unsupported (no CK_F_PR_RTM macro) then -.Fn CK_ELIDE_LOCK -and -.Fn CK_ELIDE_LOCK_ADAPTIVE -will immediately call -.Fn LOCK_FUNCTION . -.Fn CK_ELIDE_UNLOCK -and -.Fn CK_ELIDE_UNLOCK_ADAPTIVE -will immediately call -.Fn UNLOCK_FUNCTION . -.Pp -.Fn CK_ELIDE_TRYLOCK -requires a previous -.Fn CK_ELIDE_TRYLOCK_PROTOTYPE -with the same name. -Elision is attempted if the -.Fa LOCK_PREDICATE -function returns false. If -.Fa LOCK_PREDICATE -returns true or if elision fails then the -operation is aborted. If RTM is unsupported -(no CK_F_PR_RTM macro) then -.Fn CK_ELIDE_TRYLOCK -will immediately call -.Fn TRYLOCK_FUNCTION . -.Pp -.Fn CK_ELIDE_LOCK_ADAPTIVE -and -.Fn CK_ELIDE_UNLOCK_ADAPTIVE -will adapt the elision behavior associated with lock operations -according to the run-time behavior of the program. This behavior -is defined by the ck_elide_config structure pointer passed to -.Fn CK_ELIDE_LOCK_ADAPTIVE . -A thread-local ck_elide_stat structure must be passed to both -.Fn CK_ELIDE_LOCK_ADAPTIVE -and -.Fn CK_ELIDE_UNLOCK_ADAPTIVE . -This structure is expected to be unique for different workloads, -may not be re-used in recursive acquisitions and must match the -lifetime of the lock it is associated with. It is safe to mix -adaptive calls with best-effort calls. -.Pp -Both ck_spinlock.h and ck_rwlock.h define ck_elide wrappers under -the ck_spinlock and ck_rwlock namespace, respectively. -.Sh EXAMPLES -This example utilizes built-in lock elision facilities in ck_rwlock and ck_spinlock. -.Bd -literal -offset indent -#include -#include - -static ck_rwlock_t rw = CK_RWLOCK_INITIALIZER; -static struct ck_elide_config rw_config = - CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; -static __thread ck_elide_stat_t rw_stat = - CK_ELIDE_STAT_INITIALIZER; - -static ck_spinlock_t spinlock = CK_SPINLOCK_INITIALIZER; -static struct ck_elide_config spinlock_config = - CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; -static __thread ck_elide_stat_t spinlock_stat = - CK_ELIDE_STAT_INITIALIZER; - -void -function(void) -{ - - /* Lock-unlock write-side lock in weak best-effort manner. */ - CK_ELIDE_LOCK(ck_rwlock_write, &rw); - CK_ELIDE_UNLOCK(ck_rwlock_write, &rw); - - /* Attempt to acquire the write-side lock. */ - if (CK_ELIDE_TRYLOCK(ck_rwlock_write, &rw) == true) - CK_ELIDE_UNLOCK(ck_rwlock_write, &rw); - - /* Lock-unlock read-side lock in weak best-effort manner. */ - CK_ELIDE_LOCK(ck_rwlock_read, &rw); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw); - - /* Attempt to acquire the read-side lock. */ - if (CK_ELIDE_TRYLOCK(ck_rwlock_read, &rw) == true) - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw); - - /* Lock-unlock write-side lock in an adaptive manner. */ - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_write, &rw_stat, - &rw_config, &rw); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_write, &rw_stat, - &rw_config, &rw); - - /* Lock-unlock read-side lock in an adaptive manner. */ - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_read, &rw_stat, - &rw_config, &rw); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_read, &rw_stat, - &rw_config, &rw); - - /* Lock-unlock spinlock in weak best-effort manner. */ - CK_ELIDE_LOCK(ck_spinlock, &spinlock); - CK_ELIDE_UNLOCK(ck_spinlock, &spinlock); - - /* Attempt to acquire the lock. */ - if (CK_ELIDE_TRYLOCK(ck_spinlock, &lock) == true) - CK_ELIDE_UNLOCK(ck_spinlock, &spinlock); - - /* Lock-unlock spinlock in an adaptive manner. */ - CK_ELIDE_LOCK_ADAPTIVE(ck_spinlock, &spinlock_stat, - &spinlock_config, &spinlock); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_spinlock, &spinlock_stat, - &spinlock_config, &spinlock); -} -.Ed -.Pp -In this example, user-defined locking functions are provided an elision -implementation. -.Bd -literal -offset indent -/* Assume lock_t has been previously defined. */ -#include - -/* - * This function returns true if the lock is unavailable at the time - * it was called or false if the lock is available. - */ -bool is_locked(lock_t *); - -/* - * This function acquires the supplied lock. - */ -void lock(lock_t *); - -/* - * This function releases the lock. - */ -void unlock(lock_t *); - -CK_ELIDE_PROTOTYPE(my_lock, lock_t, is_locked, lock, is_locked, unlock) - -static lock_t lock; - -void -function(void) -{ - - CK_ELIDE_LOCK(my_lock, &lock); - CK_ELIDE_UNLOCK(my_lock, &lock); -} -.Ed -.Sh SEE ALSO -.Xr ck_rwlock 3 , -.Xr ck_spinlock 3 -.Pp -Ravi Rajwar and James R. Goodman. 2001. Speculative lock elision: enabling highly concurrent multithreaded execution. In Proceedings of the 34th annual ACM/IEEE international symposium on Microarchitecture (MICRO 34). IEEE Computer Society, Washington, DC, USA, 294-305. -.Pp -Additional information available at http://en.wikipedia.org/wiki/Transactional_Synchronization_Extensions and http://concurrencykit.org/ diff --git a/doc/ck_epoch_barrier b/doc/ck_epoch_barrier deleted file mode 100644 index a5861456831f..000000000000 --- a/doc/ck_epoch_barrier +++ /dev/null @@ -1,120 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_BARRIER 3 -.Sh NAME -.Nm ck_epoch_barrier -.Nd block until a grace period and all callbacks have been dispatched -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_barrier "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_barrier 3 -function will block the caller until a grace period has been -detected, according to the semantics of epoch reclamation. -Any objects requiring safe memory reclamation which are logically -deleted are safe for physical deletion following a call to -.Fn ck_epoch_barrier 3 . This function will also dispatch all callbacks -associated with -.Fa epoch -that were previously scheduled via -.Fn ck_epoch_call 3 . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include -#include -#include - -/* - * epoch was previously initialized with ck_epoch_init. - * stack was previously initialized with ck_stack_init. - */ -ck_epoch_t *epoch; -ck_stack_t *stack; - -void -function(void) -{ - ck_epoch_record_t *record; - ck_stack_entry_t *s; - - record = malloc(sizeof *record); - ck_epoch_register(&epoch, record); - - /* - * We are using an epoch section here to guarantee no - * nodes in the stack are deleted while we are dereferencing - * them. This is needed here because there are multiple writers. - * If there was only one thread popping from the this stack, - * then there is no need to ck_epoch_begin/ck_epoch_end. - */ - ck_epoch_begin(record); - - /* Logically delete an object. */ - s = ck_stack_pop_upmc(stack); - - ck_epoch_end(record); - - /* - * Wait until no threads could possibly have a reference to the - * object we just popped (assume all threads are simply executing - * ck_stack_pop_upmc). - */ - ck_epoch_barrier(record); - - /* It is now safe to physically delete the object. */ - free(s); - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -Behavior is undefined if the object pointed to by -.Fa epoch -is not a valid epoch object. The object pointed to by -.Fa record -must have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_begin b/doc/ck_epoch_begin deleted file mode 100644 index a44ecf878991..000000000000 --- a/doc/ck_epoch_begin +++ /dev/null @@ -1,73 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_BEGIN 3 -.Sh NAME -.Nm ck_epoch_begin -.Nd begin epoch-protected segment of execution -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_begin "ck_epoch_record_t *record" "ck_epoch_section_t *section" -.Sh DESCRIPTION -The -.Fn ck_epoch_begin 3 -function will mark the beginning of an epoch-protected code section. -An epoch-protected code section is delimited by a call to the -.Fn ck_epoch_end 3 -function. Though recursion is allowed for epoch-protected sections, -recursive calls will be associated with the -.Fn ck_epoch_begin 3 -that is at the top of the call stack. If a section is passed, then -recursion on a record will cause the epoch to be refreshed on entry -of every protected section. -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -The object pointed to by -.Fa epoch -must have been previously initiated via -.Fn ck_epoch_init 3 . -The object pointed to by -.Fa record -must have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_call b/doc/ck_epoch_call deleted file mode 100644 index 73906424ffb9..000000000000 --- a/doc/ck_epoch_call +++ /dev/null @@ -1,136 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_CALL 3 -.Sh NAME -.Nm ck_epoch_call -.Nd defer function execution until a grace period -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -typedef struct ck_epoch_entry ck_epoch_entry_t; -.br -typedef void ck_epoch_cb_t(ck_epoch_entry_t *); -.Ft void -.Fn ck_epoch_call "ck_epoch_record_t *record" "ck_epoch_entry_t *entry" "ck_epoch_cb_t *function" -.Sh DESCRIPTION -The -.Fn ck_epoch_call 3 -function will defer the execution of the function pointed to by -.Fa function -until a grace-period has been detected in -.Fa epoch . -The function will be provided -the pointer specified by -.Fa entry . -The function will execute at some time in the future via calls to -.Fn ck_epoch_reclaim 3 , -.Fn ck_epoch_barrier 3 -or -.Fn ck_epoch_poll 3 . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include -#include -#include - -/* - * epoch was previously initialized with ck_epoch_init. - */ -ck_epoch_t *epoch; - -struct object { - int value; - ck_epoch_entry_t epoch_entry; -}; -static struct object *global; - -CK_EPOCH_CONTAINER(struct object, epoch_entry, object_container) - -void -destroy_object(ck_epoch_entry_t *e) -{ - struct object *o = object_container(e); - - free(o); - return; -} - -void -function(void) -{ - ck_epoch_record_t *record; - struct object *n; - - record = malloc(sizeof *record); - ck_epoch_register(&epoch, record); - - n = malloc(sizeof *n); - if (n == NULL) - return; - - n->value = 1; - - /* - * We are using an epoch section here because there are multiple - * writers. It is also an option to use other forms of blocking - * write-side synchronization such as mutexes. - */ - ck_epoch_begin(record); - n = ck_pr_fas_ptr(&global, n); - ck_epoch_end(record); - - /* Defer destruction of previous object. */ - ck_epoch_call(record, &n->epoch_entry, destroy_object); - - /* Poll epoch sub-system in non-blocking manner. */ - ck_epoch_poll(record); - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -The object pointed to by -.Fa record -must have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_end b/doc/ck_epoch_end deleted file mode 100644 index a36afbd52c30..000000000000 --- a/doc/ck_epoch_end +++ /dev/null @@ -1,64 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_END 3 -.Sh NAME -.Nm ck_epoch_end -.Nd end epoch-protected segment of execution -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_end "ck_epoch_record_t *record" "ck_epoch_section_t *section" -.Sh DESCRIPTION -The -.Fn ck_epoch_end 3 -function will mark the end of an epoch-protected code section. -.Fa section -must point to a section object initialized previously with -.Fn ck_epoch_begin 3 . -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -The object pointed to by -.Fa record -must have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_init b/doc/ck_epoch_init deleted file mode 100644 index 51a3e2abb46d..000000000000 --- a/doc/ck_epoch_init +++ /dev/null @@ -1,69 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_INIT 3 -.Sh NAME -.Nm ck_epoch_init -.Nd initialize epoch reclamation object -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_init "ck_epoch_t *epoch" -.Sh DESCRIPTION -The -.Fn ck_epoch_init -function initializes the epoch object pointed to by the -.Fa epoch -pointer. -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -.Bl -tag -width Er -.Pp -The behavior of -.Fn ck_epoch_init -is undefined if -.Fa epoch -is not a pointer to a -.Tn ck_epoch_t -object. -.El -.Sh SEE ALSO -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_poll b/doc/ck_epoch_poll deleted file mode 100644 index 68c4a4e80766..000000000000 --- a/doc/ck_epoch_poll +++ /dev/null @@ -1,71 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_POLL 3 -.Sh NAME -.Nm ck_epoch_poll -.Nd non-blocking poll of epoch object for dispatch cycles -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft bool -.Fn ck_epoch_poll "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_poll 3 -function will attempt to dispatch any functions associated with the -object pointed to by -.Fa epoch -via -.Fn ck_epoch_call 3 -if deemed safe. This function is meant to be used in cases epoch -reclamation cost must be amortized over time in a manner that does -not affect caller progress. -.Sh RETURN VALUES -This function will return true if at least one function was dispatched. -This function will return false if it has determined not all threads have -observed the latest generation of epoch-protected objects. Neither value -indicates an error. -.Sh ERRORS -Behavior is undefined if the object pointed to by -.Fa record -has not have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_reclaim b/doc/ck_epoch_reclaim deleted file mode 100644 index ffe3bac5716c..000000000000 --- a/doc/ck_epoch_reclaim +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 2, 2013 -.Dt CK_EPOCH_RECLAIM 3 -.Sh NAME -.Nm ck_epoch_reclaim -.Nd immediately execute all deferred callbacks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_reclaim "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_reclaim 3 -function will unconditionally execute all callbacks -that have been deferred with -.Fn ck_epoch_call 3 . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include -#include -#include - -/* - * epoch was previously initialized with ck_epoch_init. - */ -ck_epoch_t *epoch; - -void -function(void) -{ - ck_epoch_record_t *record; - - logically_delete(object); - ck_epoch_call(epoch, record, &object->epoch_entry, destructor); - - /* - * Wait until no threads could possibly have a reference to the - * object we just deleted. - */ - ck_epoch_synchronize(epoch, record); - - /* - * Execute all deferred callbacks. - */ - ck_epoch_reclaim(record); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_recycle b/doc/ck_epoch_recycle deleted file mode 100644 index 530079c3e925..000000000000 --- a/doc/ck_epoch_recycle +++ /dev/null @@ -1,102 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_RECYCLE 3 -.Sh NAME -.Nm ck_epoch_recycle -.Nd return an epoch record that may be used by caller -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft ck_epoch_record_t * -.Fn ck_epoch_recycle "ck_epoch_t *epoch" -.Sh DESCRIPTION -The -.Fn ck_epoch_recycle 3 -function attempts to return an unused epoch record object for use by -the caller. These epoch records were associated with previous calls -to the -.Fn ck_epoch_unregister 3 -function. -.Sh EXAMPLE -.Bd -literal -offset indent -#include -#include - -/* - * epoch was previously initialized with ck_epoch_init. - */ -ck_epoch_t *epoch; - -void -function(void) -{ - ck_epoch_record_t *record; - - record = ck_epoch_recycle(&epoch); - if (record == NULL) { - record = malloc(sizeof *record); - if (record == NULL) - return; - - ck_epoch_register(&epoch, record); - } - - /* - * After we are done, we will unregister the record so it - * can be used by other new participants in the epoch system - * provided by the object pointed to by "epoch". - */ - ck_epoch_unregister(&epoch, record); - return; -} -.Ed -.Sh RETURN VALUES -This function returns a pointer to a -.Dv ck_epoch_record_t -object. If no unused record was found to be associated with the -object pointed to by -.Fa epoch , -then the function will return NULL. -.Sh ERRORS -Behavior is undefined if the object pointed to by -.Fa epoch -is not a valid epoch object. -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_register b/doc/ck_epoch_register deleted file mode 100644 index 85ea4610a682..000000000000 --- a/doc/ck_epoch_register +++ /dev/null @@ -1,67 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_REGISTER 3 -.Sh NAME -.Nm ck_epoch_register -.Nd register a thread for epoch reclamation -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_register "ck_epoch_t *epoch" "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_register 3 -function associates a record object specified by the -.Fa record -pointer with the epoch object pointed to by -.Fa epoch . -Any thread or processor that will require safe memory reclamation -guarantees must register a unique record object. After registration, the -object pointed to by the -.Fa record -argument will have lifetime managed by the underlying epoch sub-system. -The record object must not be destroyed after it is associated with a -.Fn ck_epoch_register 3 -call. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_synchronize b/doc/ck_epoch_synchronize deleted file mode 100644 index 6c9a69843c7a..000000000000 --- a/doc/ck_epoch_synchronize +++ /dev/null @@ -1,119 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_SYNCHRONIZE 3 -.Sh NAME -.Nm ck_epoch_synchronize -.Nd block until a grace period has been detected -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_synchronize "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_synchronize 3 -function will block the caller until a grace period has been -detected, according to the semantics of epoch reclamation. -Any objects requiring safe memory reclamation which are logically -deleted are safe for physical deletion following a call to -.Fn ck_epoch_synchronize 3 . -If you require that all callbacks be dispatched, then it is suggested -that you use -.Fn ck_epoch_barrier 3 -instead or follow a call of -.Fn ck_epoch_synchronize 3 -with -.Fn ck_epoch_reclaim 3 . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include -#include -#include - -/* - * epoch was previously initialized with ck_epoch_init. - * stack was previously initialized with ck_stack_init. - */ -ck_epoch_t *epoch; -ck_stack_t *stack; - -void -function(void) -{ - ck_epoch_record_t *record; - ck_stack_entry_t *s; - - record = malloc(sizeof *record); - ck_epoch_register(&epoch, record); - - /* - * We are using an epoch section here to guarantee no - * nodes in the stack are deleted while we are dereferencing - * them. This is needed here because there are multiple writers. - * If there was only one thread popping from the this stack, - * then there is no need to ck_epoch_begin/ck_epoch_end. - */ - ck_epoch_begin(record); - - /* Logically delete an object. */ - s = ck_stack_pop_upmc(stack); - - ck_epoch_end(record); - - /* - * Wait until no threads could possibly have a reference to the - * object we just popped (assume all threads are simply executing - * ck_stack_pop_upmc). - */ - ck_epoch_synchronize(record); - - /* It is now safe to physically delete the object. */ - free(s); - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh ERRORS -The object pointed to by .Fa record must have been previously registered via -.Fn ck_epoch_register 3 . -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_unregister 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_epoch_unregister b/doc/ck_epoch_unregister deleted file mode 100644 index 3be537f45614..000000000000 --- a/doc/ck_epoch_unregister +++ /dev/null @@ -1,65 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 2, 2012 -.Dt CK_EPOCH_UNREGISTER 3 -.Sh NAME -.Nm ck_epoch_unregister -.Nd unregister a thread for epoch reclamation -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_epoch.h -.Ft void -.Fn ck_epoch_unregister "ck_epoch_record_t *record" -.Sh DESCRIPTION -The -.Fn ck_epoch_unregister 3 -function allows for the record pointed by the -.Fa record -pointer to be used as a return value by the -.Fn ck_epoch_recycle 3 -function. This record can now be used by another thread -of execution. Behavior is undefined if the object pointed by -.Fa record -is modified in any way, even after a call is made to the -.Fn ck_epoch_unregister 3 -function. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_epoch_init 3 , -.Xr ck_epoch_register 3 , -.Xr ck_epoch_recycle 3 , -.Xr ck_epoch_poll 3 , -.Xr ck_epoch_synchronize 3 , -.Xr ck_epoch_reclaim 3 , -.Xr ck_epoch_barrier 3 , -.Xr ck_epoch_call 3 , -.Xr ck_epoch_begin 3 , -.Xr ck_epoch_end 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_apply b/doc/ck_hs_apply deleted file mode 100644 index 5664f73b90a0..000000000000 --- a/doc/ck_hs_apply +++ /dev/null @@ -1,86 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" Copyright 2014 Backtrace I/O, Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 1, 2014 -.Dt CK_HS_APPLY 3 -.Sh NAME -.Nm ck_hs_apply -.Nd apply a function to hash set value -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft void * -.Fn ck_hs_apply_fn_t "void *key" "void *closure" -.Ft bool -.Fn ck_hs_apply "ck_hs_t *hs" "unsigned long hash" "const void *key" "ck_hs_apply_fn_t *function" "void *argument" -.Sh DESCRIPTION -The -.Fn ck_hs_apply 3 -function will lookup the hash set slot associated with -.Fa key -and pass it to function pointed to by -.Fa function -for further action. This callback may remove or replace -the value by respectively returning NULL or a pointer to -another object with an identical key. The first argument -passed to -.Fa function -is a pointer to the object found in the hash set and -the second argument is the -.Fa argument -pointer passed to -.Fn ck_hs_apply 3 . -If the pointer returned by -.Fa function -is equivalent to the first argument then no modification -is made to the hash set. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_apply 3 -returns true and otherwise returns false on failure. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr ck_hs_fas 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_count b/doc/ck_hs_count deleted file mode 100644 index c12d8f76289f..000000000000 --- a/doc/ck_hs_count +++ /dev/null @@ -1,70 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_COUNT 3 -.Sh NAME -.Nm ck_hs_count -.Nd returns number of entries in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft unsigned long -.Fn ck_hs_count "ck_hs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_hs_count 3 -function returns the number of keys currently -stored in -.Fa hs . -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_destroy b/doc/ck_hs_destroy deleted file mode 100644 index 952502ba7144..000000000000 --- a/doc/ck_hs_destroy +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_DESTROY 3 -.Sh NAME -.Nm ck_hs_destroy -.Nd destroy hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft void -.Fn ck_hs_destroy "ck_hs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_hs_destroy 3 -function will request that the underlying allocator, as specified by the -.Xr ck_hs_init 3 -function, immediately destroy the object pointed to by the -.Fa hs -argument. -The user must guarantee that no threads are accessing the object pointed to -by -.Fa hs -when -.Fn ck_hs_destroy 3 -is called. -.Sh RETURN VALUES -.Fn ck_hs_destroy 3 -has no return value. -.Sh ERRORS -This function is guaranteed not to fail. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_fas b/doc/ck_hs_fas deleted file mode 100644 index 69760b56c980..000000000000 --- a/doc/ck_hs_fas +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd June 20, 2013 -.Dt CK_HS_FAS 3 -.Sh NAME -.Nm ck_hs_fas -.Nd fetch and store key in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_fas "ck_hs_t *hs" "unsigned long hash" "const void *key" "void **previous" -.Sh DESCRIPTION -The -.Fn ck_hs_fas 3 -function will fetch and store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_hs_fas 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The key must already exist in the hash set, and is -replaced by -.Fa key -and the previous value is stored into the void pointer -pointed to by the -.Fa previous -argument. If the key does not exist in the hash set -then the function will return false and the hash set -is unchanged. This function -is guaranteed to be stable with respect to memory usage. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_fas 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_gc b/doc/ck_hs_gc deleted file mode 100644 index 85abba2e3e6c..000000000000 --- a/doc/ck_hs_gc +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 17, 2013 -.Dt CK_HS_GC 3 -.Sh NAME -.Nm ck_hs_gc -.Nd perform maintenance on a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_gc "ck_hs_t *hs" "unsigned long cycles" "unsigned long seed" -.Sh DESCRIPTION -The -.Fn ck_hs_gc 3 -function will perform various maintenance routines on the hash set -pointed to by -.Fa hs , -including defragmentation of probe sequences with respect to tombstones -and in the case that the delete workload hint has been passed, recalculation -of probe sequence bounds. The -.Fa cycles -argument is used to indicate how many hash set entries should be subject -to attempted maintenance. If -.Fa cycles -is 0, then maintenance is performed on the complete hash set. The -.Fa seed -argument determines the start location of the maintenance process. If -.Fa cycles -is non-zero, it is recommended that -.Fa seed -is some random value. If the delete hint has been passed, the function -will require an additional 12% of memory (with respect to existing -memory usage of the set), until operation completion. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_gc 3 -returns true and otherwise returns false on failure due to memory allocation -failure. -.Sh ERRORS -This function will only return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_get b/doc/ck_hs_get deleted file mode 100644 index 9c1600d6a9bc..000000000000 --- a/doc/ck_hs_get +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_GET 3 -.Sh NAME -.Nm ck_hs_get -.Nd load a key from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft void * -.Fn ck_hs_get "ck_hs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_hs_get 3 -function will return a pointer to a key in the hash set -.Fa hs -that is of equivalent value to the object pointed to by -.Fa key . -The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which is to have been previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Sh RETURN VALUES -If the provided key is a member of -.Fa hs -then a pointer to the key as stored in -.Fa hs -is returned. If the key was not found in -.Fa hs -then a value of -.Dv NULL -is returned. -.Sh ERRORS -Behavior is undefined if -.Fa entry -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_grow b/doc/ck_hs_grow deleted file mode 100644 index ed35cd041564..000000000000 --- a/doc/ck_hs_grow +++ /dev/null @@ -1,81 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_GROW 3 -.Sh NAME -.Nm ck_hs_grow -.Nd enlarge hash set capacity -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_grow "ck_hs_t *hs" "unsigned long capacity" -.Sh DESCRIPTION -The -.Fn ck_hs_grow 3 -function will resize the hash set in order to be -able to store at least the number of entries specified by -.Fa capacity -at a load factor of one. The default hash set load factor -is 0.5. If you wish to minimize the likelihood of memory allocations -for a hash set meant to store n entries, then specify a -.Fa capacity -of 2n. The default behavior of ck_hs is to round -.Fa capacity -to the next power of two if it is not already a power of two. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_grow 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. This function will only -return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_init b/doc/ck_hs_init deleted file mode 100644 index cfcbf635d52b..000000000000 --- a/doc/ck_hs_init +++ /dev/null @@ -1,169 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_INIT 3 -.Sh NAME -.Nm ck_hs_init -.Nd initialize a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft typedef unsigned long -.Fn ck_hs_hash_cb_t "const void *key" "unsigned long seed" -.Ft typedef bool -.Fn ck_hs_compare_cb_t "const void *c1" "const void *c2" -.Ft bool -.Fn ck_hs_init "ck_hs_t *hs" "unsigned int mode" "ck_hs_hash_cb_t *hash_function" "ck_hs_compare_cb_t *compare" "struct ck_malloc *allocator" "unsigned long capacity" "unsigned long seed" -.Sh DESCRIPTION -The -.Fn ck_hs_init -function initializes the hash set pointed to by the -.Fa hs -pointer. -.Pp -The argument -.Fa mode -specifies the type of key-value pairs to be stored in the -hash set as well as the expected concurrent access model. -The value of -.Fa mode -consists of a bitfield of one of the following: -.Bl -tag -width indent -.It CK_HS_MODE_OBJECT -The hash set is meant to store pointers to objects. This provides -a hint that only CK_MD_VMA_BITS are necessary to encode the key -argument. Any unused pointer bits are leveraged for internal -optimizations. -.It CK_HS_MODE_DIRECT -The hash set is meant to directly store key values and that all -bits of the key are used to encode values. -.El -.Pp -The concurrent access model is specified by: -.Bl -tag -width indent -.It CK_HS_MODE_SPMC -The hash set should allow for concurrent readers in the -presence of a single writer. -.It CK_HS_MODE_MPMC -The hash set should allow for concurrent readers in the -presence of concurrent writers. This is currently unsupported. -.El -.Pp -The developer is free to specify additional workload hints. -These hints are one of: -.Bl -tag -width indent -.It CK_HS_MODE_DELETE -The hash set is expected to have a delete-heavy workload. -At the cost of approximately 13% increased memory usage, -allow for stronger per-slot probe bounds to combat the -effects of tombstone accumulation. -.El -.Pp -The argument -.Fa hash_function -is a mandatory pointer to a user-specified hash function. -A user-specified hash function takes two arguments. The -.Fa key -argument is a pointer to a key. The -.Fa seed -argument is the initial seed associated with the hash set. -This initial seed is specified by the user in -.Xr ck_hs_init 3 . -.Pp -The -.Fa compare -argument is an optional pointer to a user-specified -key comparison function. If NULL is specified in this -argument, then pointer equality will be used to determine -key equality. A user-specified comparison function takes -two arguments representing pointers to the objects being -compared for equality. It is expected to return true -if the keys are of equal value and false otherwise. -.Pp -The -.Fa allocator -argument is a pointer to a structure containing -.Fa malloc -and -.Fa free -function pointers which respectively define the memory allocation and -destruction functions to be used by the hash set being initialized. -.Pp -The argument -.Fa capacity -represents the initial number of keys the hash -set is expected to contain. This argument is simply a hint -and the underlying implementation is free to allocate more -or less memory than necessary to contain the number of entries -.Fa capacity -specifies. -.Pp -The argument -.Fa seed -specifies the initial seed used by the underlying hash function. -The user is free to choose a value of their choice. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_hs_init -returns a value of -.Dv true -and otherwise returns a value of -.Dv false -to indicate an error. -.Sh ERRORS -.Bl -tag -width Er -.Pp -The behavior of -.Fn ck_hs_init -is undefined if -.Fa hs -is not a pointer to a -.Tn ck_hs_t -object. -.El -.Sh SEE ALSO -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_iterator_init b/doc/ck_hs_iterator_init deleted file mode 100644 index d2c25ccdb060..000000000000 --- a/doc/ck_hs_iterator_init +++ /dev/null @@ -1,78 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_ITERATOR_INIT 3 -.Sh NAME -.Nm ck_hs_iterator_init -.Nd initialize hash set iterator -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Pp -.Dv ck_hs_iterator_t iterator = CK_HS_ITERATOR_INITIALIZER -.Pp -.Ft void -.Fn ck_hs_iterator_init "ck_hs_iterator_t *iterator" -.Sh DESCRIPTION -The -.Fn ck_hs_iterator_init 3 -function will initialize the object pointed to -by the -.Fa iterator -argument. Alternatively, an iterator may be statically -initialized by assigning it to the CK_HS_ITERATOR_INITIALIZER value. -.Pp -An iterator is used to iterate through hash set entries with the -.Xr ck_hs_next 3 -function. -.Sh RETURN VALUES -.Fn ck_hs_iterator_init 3 -has no return value. -.Sh ERRORS -This function will not fail. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_move b/doc/ck_hs_move deleted file mode 100644 index 1d3019574176..000000000000 --- a/doc/ck_hs_move +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 18, 2013 -.Dt CK_HS_MOVE 3 -.Sh NAME -.Nm ck_hs_move -.Nd move one from hash set to another -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_move "ck_hs_t *destination" "ck_hs_t *source" "ck_hs_hash_cb_t *hash_cb" "ck_hs_compare_cb_t *compare_cb" "struct ck_malloc *m" -.Sh DESCRIPTION -The -.Fn ck_hs_move 3 -function will initialize -.Fa source -from -.Fa destination . -The hash function is set to -.Fa hash_cb , -comparison function to -.Fa compare_cb -and the allocator callbacks to -.Fa m . -Further modifications to -.Fa source -will result in undefined behavior. Concurrent -.Xr ck_hs_get 3 -and -.Xr ck_hs_fas 3 -operations to -.Fa source -are legal until the next write operation to -.Fa destination . -.Pp -This operation moves ownership from one hash set object -to another and re-assigns callback functions to developer-specified -values. This allows for dynamic configuration of allocation -callbacks and is necessary for use-cases involving executable code -which may be unmapped underneath the hash set. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_hs_move 3 -returns true and otherwise returns false to indicate an error. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_next b/doc/ck_hs_next deleted file mode 100644 index 67e083e57080..000000000000 --- a/doc/ck_hs_next +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_NEXT 3 -.Sh NAME -.Nm ck_hs_next -.Nd iterate to next entry in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_next "ck_hs_t *hs" "ck_hs_iterator_t *iterator" "void **entry" -.Sh DESCRIPTION -The -.Fn ck_hs_next 3 -function will increment the iterator object pointed to by -.Fa iterator -to point to the next non-empty hash set entry. If -.Fn ck_hs_next 3 -returns true then the pointer pointed to by -.Fa entry -is initialized to the current hash set key pointed to by the -.Fa iterator -object. -.Pp -It is expected that -.Fa iterator -has been initialized using the -.Xr ck_hs_iterator_init 3 -function or statically initialized using CK_HS_ITERATOR_INITIALIZER. -.Sh RETURN VALUES -If -.Fn ck_hs_next 3 -returns true then the object pointed to by -.Fa entry -points to a valid hash set key. If -.Fn ck_hs_next 3 -returns false then the value of the object pointed to by -.Fa entry -is undefined. -.Sh ERRORS -Behavior is undefined if -.Fa iterator -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_put b/doc/ck_hs_put deleted file mode 100644 index 8f8f55f18b1a..000000000000 --- a/doc/ck_hs_put +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_PUT 3 -.Sh NAME -.Nm ck_hs_put -.Nd store unique key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_put "ck_hs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_hs_put 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_hs_put 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The function will fail if a key with an -equivalent value to -.Fa key -is already present in the hash set. For replacement -semantics, please see the -.Xr ck_hs_set 3 -function. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_put 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_put_unique b/doc/ck_hs_put_unique deleted file mode 100644 index f60c5436332b..000000000000 --- a/doc/ck_hs_put_unique +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 7, 2013 -.Dt CK_HS_PUT_UNIQUE 3 -.Sh NAME -.Nm ck_hs_put_unique -.Nd unconditionally store unique key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_put_unique "ck_hs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_hs_put_unique 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_hs_put 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The function will cause undefined behavior if a key with an -equivalent value is already present in the hash set. For replacement -semantics, please see the -.Xr ck_hs_set 3 -function. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_put_unique 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. The function will -result in undefined behavior if called for an -already inserted key value. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_rebuild b/doc/ck_hs_rebuild deleted file mode 100644 index a49bb28f4560..000000000000 --- a/doc/ck_hs_rebuild +++ /dev/null @@ -1,76 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 7, 2013 -.Dt CK_HS_REBUILD 3 -.Sh NAME -.Nm ck_hs_rebuild -.Nd rebuild a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_rebuild "ck_hs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_hs_rebuild 3 -function will regenerate the hash set pointed to by -.Fa hs . -This has the side-effect of pruning degradatory side-effects -of workloads that are delete heavy. The regenerated hash -set should have shorter probe sequences on average. This -operation will require a significant amount of memory -and is free to allocate a duplicate hash set in the -rebuild process. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_rebuild 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -This function will only return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_remove b/doc/ck_hs_remove deleted file mode 100644 index 10ccfb6f3a57..000000000000 --- a/doc/ck_hs_remove +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_REMOVE 3 -.Sh NAME -.Nm ck_hs_remove -.Nd remove key from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft void * -.Fn ck_hs_remove "ck_hs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_hs_remove 3 -function will attempt to remove the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_hs_remove 3 -was successful then the key contained in the hash -set is returned. If the key was not a member of the hash -set then -.Dv NULL -is returned. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_remove 3 -returns a pointer to a key and otherwise returns -.Dv NULL -on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_reset b/doc/ck_hs_reset deleted file mode 100644 index e6ce72e8c20d..000000000000 --- a/doc/ck_hs_reset +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_RESET 3 -.Sh NAME -.Nm ck_hs_reset -.Nd remove all keys from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_reset "ck_hs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_hs_reset 3 -function will remove all keys stored in the hash -set pointed to by the -.Fa hs -argument. -.Sh RETURN VALUES -If successful, -.Fn ck_hs_reset 3 -will return true and will otherwise return false on failure. This -function will only fail if a replacement hash set could not be -allocated internally. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_reset_size b/doc/ck_hs_reset_size deleted file mode 100644 index 801c0638ec19..000000000000 --- a/doc/ck_hs_reset_size +++ /dev/null @@ -1,80 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 5, 2013 -.Dt CK_HS_RESET_SIZE 3 -.Sh NAME -.Nm ck_hs_reset_size -.Nd remove all keys from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_reset_size "ck_hs_t *hs" "unsigned long size" -.Sh DESCRIPTION -The -.Fn ck_hs_reset_size 3 -function will remove all keys stored in the hash -set pointed to by the -.Fa hs -argument and create a new generation of the hash set that -is preallocated for -.Fa size -entries. -.Sh RETURN VALUES -If successful, -.Fn ck_hs_reset_size 3 -will return true and will otherwise return false on failure. This -function will only fail if a replacement hash set could not be -allocated internally. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_set b/doc/ck_hs_set deleted file mode 100644 index e9ba9f1035d8..000000000000 --- a/doc/ck_hs_set +++ /dev/null @@ -1,102 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_SET 3 -.Sh NAME -.Nm ck_hs_set -.Nd store key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft bool -.Fn ck_hs_set "ck_hs_t *hs" "unsigned long hash" "const void *key" "void **previous" -.Sh DESCRIPTION -The -.Fn ck_hs_set 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_HS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_hs_set 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -If the key already exists in the hash set, then it is -replaced by -.Fa key -and the previous value is stored into the void pointer -pointed to by the -.Fa previous -argument. If previous is set to -.Dv NULL -then -.Fa key -was not a replacement for an existing entry in the hash set. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_hs_set 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 , -.Xr ck_hs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_hs_stat b/doc/ck_hs_stat deleted file mode 100644 index 796a89446b66..000000000000 --- a/doc/ck_hs_stat +++ /dev/null @@ -1,81 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HS_STAT 3 -.Sh NAME -.Nm ck_hs_stat -.Nd get hash set status -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_hs.h -.Ft void -.Fn ck_hs_stat "ck_hs_t *hs" "struct ck_hs_stat *st" -.Sh DESCRIPTION -The -.Fn ck_hs_stat 3 -function will store various hash set statistics in -the object pointed to by -.Fa st . -The ck_hs_stat structure is defined as follows: -.Bd -literal -offset indent -struct ck_hs_stat { - unsigned long tombstones; /* Current number of tombstones in hash set. */ - unsigned long n_entries; /* Current number of keys in hash set. */ - unsigned int probe_maximum; /* Longest read-side probe sequence. */ -}; -.Ed -.Sh RETURN VALUES -.Fn ck_hs_stat 3 -has no return value. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_hs_init 3 , -.Xr ck_hs_move 3 , -.Xr ck_hs_destroy 3 , -.Xr CK_HS_HASH 3 , -.Xr ck_hs_iterator_init 3 , -.Xr ck_hs_next 3 , -.Xr ck_hs_get 3 , -.Xr ck_hs_put 3 , -.Xr ck_hs_put_unique 3 , -.Xr ck_hs_set 3 , -.Xr ck_hs_fas 3 , -.Xr ck_hs_remove 3 , -.Xr ck_hs_grow 3 , -.Xr ck_hs_gc 3 , -.Xr ck_hs_rebuild 3 , -.Xr ck_hs_count 3 , -.Xr ck_hs_reset 3 , -.Xr ck_hs_reset_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_count b/doc/ck_ht_count deleted file mode 100644 index ba10835fa208..000000000000 --- a/doc/ck_ht_count +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_COUNT 3 -.Sh NAME -.Nm ck_ht_count -.Nd return count of key-value pairs in hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft uint64_t -.Fn ck_ht_count "ck_ht_t *ht" -.Sh DESCRIPTION -The -.Fn ck_ht_count -function will return the number of entries in the hash table -pointed to be the -.Fa ht -argument. The function may only be called without the presence -of concurrent write operations. -.Sh ERRORS -Behavior is undefined if -.Fa ht -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_destroy b/doc/ck_ht_destroy deleted file mode 100644 index 95e4acb2fe6e..000000000000 --- a/doc/ck_ht_destroy +++ /dev/null @@ -1,87 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_DESTROY 3 -.Sh NAME -.Nm ck_ht_destroy -.Nd immediately destroy a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_destroy "ck_ht_t *ht" -.Sh DESCRIPTION -The -.Fn ck_ht_destroy -function will request that the underlying allocator, as specified by the -.Xr ck_ht_init 3 -function, immediately destroy the object pointed to by the -.Fa ht -argument. -.Pp -The user must guarantee that no threads are accessing the object pointed to -by -.Fa ht -when -.Fn ck_ht_destroy -is called. -.Sh RETURN VALUES -.Fn ck_ht_destroy -has no return value. -.Sh ERRORS -.Bl -tag -width Er -This function is guaranteed not to fail. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_empty b/doc/ck_ht_entry_empty deleted file mode 100644 index 92333442763b..000000000000 --- a/doc/ck_ht_entry_empty +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_ENTRY_EMPTY 3 -.Sh NAME -.Nm ck_ht_entry_empty -.Nd determine whether entry contains a key-value pair -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_entry_empty "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_empty -function will return -.Dv false -if -.Fa entry -points to a valid key-value pair. If -.Fa entry -does not point to a valid key-value pair it -returns -.Dv true. -It is expected that the object pointed to by -.Fa entry -was initialized by a preceding call to the -.Xr ck_ht_entry_set -family of functions, the -.Xr ck_ht_get_spmc 3 -function or the -.Xr ck_ht_set_spmc 3 -function. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_key b/doc/ck_ht_entry_key deleted file mode 100644 index 5003a1a38df6..000000000000 --- a/doc/ck_ht_entry_key +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_KEY 3 -.Sh NAME -.Nm ck_ht_entry_key -.Nd return pointer to key as specified in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void * -.Fn ck_ht_entry_key "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_key -function will return the key pointer as specified in the -object pointed to by the -.Fa entry -argument. -.Pp -It is expected that the entry is -associated with a hash table initialized with -.Dv CK_HT_MODE_BYTESTRING -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_key -returns -.Dv NULL -if the entry is empty. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_key_direct b/doc/ck_ht_entry_key_direct deleted file mode 100644 index e0a75a2bb1b4..000000000000 --- a/doc/ck_ht_entry_key_direct +++ /dev/null @@ -1,91 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_KEY_DIRECT 3 -.Sh NAME -.Nm ck_ht_entry_key_direct -.Nd return key value as specified in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft uintptr_t -.Fn ck_ht_entry_key_direct "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_key_direct -function will return the key value as specified in the -object pointed to by the -.Fa entry -argument. -.Pp -It is expected that the entry is -associated with a hash table initialized with -.Dv CK_HT_MODE_DIRECT -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_key_direct -returns -.Dv 0 -if the entry is empty. Otherwise, it returns the -key value stored in the object pointed to by the -.Fa entry -argument. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_key_length b/doc/ck_ht_entry_key_length deleted file mode 100644 index 6ac3ded08f47..000000000000 --- a/doc/ck_ht_entry_key_length +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_KEY_LENGTH 3 -.Sh NAME -.Nm ck_ht_entry_key_length -.Nd returns the length of the key specified in the argument -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft uint16_t -.Fn ck_ht_entry_key_length "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_key_length -function will return the length of the key associated with the -object pointed to by the -.Fa entry -argument. -.Pp -It is expected that the entry is -associated with a hash table initialized with -.Dv CK_HT_MODE_BYTESTRING -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_key_length -returns -.Dv 0 -if the entry is empty. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_key_set b/doc/ck_ht_entry_key_set deleted file mode 100644 index 03e53bb32e9e..000000000000 --- a/doc/ck_ht_entry_key_set +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_KEY_SET 3 -.Sh NAME -.Nm ck_ht_entry_key_set -.Nd initialize pointer to key in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_entry_key_set "ck_ht_entry_t *entry" "const void *key" "uint16_t key_length" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_key_set -function will initialize the object pointed to by -.Fa entry -with a key pointed to by the -.Fa key -argument. The length of the key is specified by -.Fa key_length. -The maximum value of -.Fa key_length -is defined by the CK_HT_KEY_LENGTH macro. -This function is typically used to initialize an -entry for -.Xr ck_ht_get_spmc 3 -and -.Xr ck_ht_remove_spmc 3 -operations. It is expected that the entry will -be associated with a hash table initialized with -.Dv CK_HT_MODE_BYTESTRING -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_key_set -has no return value. -.Sh ERRORS -This function will never fail. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_key_set_direct b/doc/ck_ht_entry_key_set_direct deleted file mode 100644 index 1cd2d6c2aa87..000000000000 --- a/doc/ck_ht_entry_key_set_direct +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_KEY_SET_DIRECT 3 -.Sh NAME -.Nm ck_ht_entry_key_set_direct -.Nd initialize key value in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_entry_key_set_direct "ck_ht_entry_t *entry" "uintptr_t key" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_key_set_direct -function will initialize the object pointed to by -.Fa entry -with the key value specified in the -.Fa key -argument. This function is typically used to initialize an -entry for -.Xr ck_ht_get_spmc 3 -and -.Xr ck_ht_remove_spmc 3 -operations. It is expected that the entry will -be associated with a hash table initialized with -.Dv CK_HT_MODE_DIRECT -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_key_set_direct -has no return value. -.Sh ERRORS -This function will never fail. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_set b/doc/ck_ht_entry_set deleted file mode 100644 index b0174308a441..000000000000 --- a/doc/ck_ht_entry_set +++ /dev/null @@ -1,95 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_SET 3 -.Sh NAME -.Nm ck_ht_entry_set -.Nd initialize a key-value pair -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_entry_set "ck_ht_entry_t *entry" "ck_ht_hash_t h" "const void *key" "uint16_t key_length" "const void *value" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_set -function will initialize the object pointed to by -.Fa entry -with a key pointed to by the -.Fa key -argument and a value pointed to by the -.Fa value -argument. The length of the key is specified by -.Fa key_length. -The maximum value of -.Fa key_length -is defined by the CK_HT_KEY_LENGTH macro. -This function is typically used to initialize an -entry for -.Xr ck_ht_set_spmc 3 -and -.Xr ck_ht_put_spmc 3 -operations. It is expected that the entry will -be associated with a hash table initialized with -.Dv CK_HT_MODE_BYTESTRING -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_set -has no return value. -.Sh ERRORS -This function will never fail. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_set_direct b/doc/ck_ht_entry_set_direct deleted file mode 100644 index 9c9bf0873ea5..000000000000 --- a/doc/ck_ht_entry_set_direct +++ /dev/null @@ -1,94 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_SET_DIRECT 3 -.Sh NAME -.Nm ck_ht_entry_set_direct -.Nd initialize a key-value pair -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_entry_set_direct "ck_ht_entry_t *entry" "ck_ht_hash_t h" "uintptr_t key" "uintptr_t value" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_set -function will initialize the object pointed to by -.Fa entry -with the hash value specified by the -.Fa h -argument, the key value specified in the -.Fa key -argument and the value specified by the -.Fa value -argument. -.Pp -This function is typically used to initialize an -entry for -.Xr ck_ht_set_spmc 3 -and -.Xr ck_ht_put_spmc 3 -operations. It is expected that the entry will -be associated with a hash table initialized with -.Dv CK_HT_MODE_DIRECT -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -.Fn ck_ht_entry_set_direct -has no return value. -.Sh ERRORS -This function will never fail. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_value b/doc/ck_ht_entry_value deleted file mode 100644 index 2e712e3b7bcc..000000000000 --- a/doc/ck_ht_entry_value +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_VALUE 3 -.Sh NAME -.Nm ck_ht_entry_value -.Nd return pointer to value as specified in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void * -.Fn ck_ht_entry_value "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_value -function will return the value pointer as specified in the -object pointed to by the -.Fa entry -argument. -.Pp -It is expected that the entry is -associated with a hash table initialized with -.Dv CK_HT_MODE_BYTESTRING -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -The -.Fn ck_ht_entry_value -function returns the value pointed to by -.Dv entry. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized or if the key is empty. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_entry_value_direct b/doc/ck_ht_entry_value_direct deleted file mode 100644 index 1a7c28e69104..000000000000 --- a/doc/ck_ht_entry_value_direct +++ /dev/null @@ -1,89 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ENTRY_VALUE_DIRECT 3 -.Sh NAME -.Nm ck_ht_entry_value_direct -.Nd return value as specified in hash table entry -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft uintptr_t -.Fn ck_ht_entry_value_direct "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_entry_value_direct -function will return the value of the key-value pair as specified in the -object pointed to by the -.Fa entry -argument. -.Pp -It is expected that the entry is -associated with a hash table initialized with -.Dv CK_HT_MODE_DIRECT -(see -.Xr ck_ht_init 3 -for more information). -.Sh RETURN VALUES -The -.Fn ck_ht_entry_value_direct -function returns the value stored in the object pointed to by the -.Fa entry -argument. -.Sh ERRORS -Behavior is undefined if -.Fa entry -has not been initialized or if the key is empty. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_gc b/doc/ck_ht_gc deleted file mode 100644 index 8bbad56a86fc..000000000000 --- a/doc/ck_ht_gc +++ /dev/null @@ -1,96 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 18, 2013 -.Dt CK_HT_GC 3 -.Sh NAME -.Nm ck_ht_gc -.Nd perform maintenance on a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_gc "ck_ht_t *ht" "unsigned long cycles" "unsigned long seed" -.Sh DESCRIPTION -The -.Fn ck_ht_gc -function will perform various maintenance routines on the hash table -pointed to by -.Fa ht , -including defragmentation of probe sequences with respect to tombstones -and in the case that the delete workload hint has been passed, recalculation -of probe sequence bounds. The -.Fa cycles -argument is used to indicate how many hash table entries should be subject -to attempted maintenance. -If -.Fa cycles -is 0, then maintenance is performed on the complete hash table. The -.Fa seed -argument determines the start location of the maintenance process. If -.Fa cycles -is non-zero, it is recommended that -.Fa seed -is some random value. If the delete hint has been passed, the function -will require an additional 12% of memory (with respect to existing -memory usage of the set), until operation completion. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_ht_gc 3 -returns true and otherwise returns false on failure due to memory allocation -failure. -.Sh ERRORS -This function will only return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_ht_count 3 , -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_get_spmc b/doc/ck_ht_get_spmc deleted file mode 100644 index 91b95340ecc7..000000000000 --- a/doc/ck_ht_get_spmc +++ /dev/null @@ -1,177 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_GET_SPMC 3 -.Sh NAME -.Nm ck_ht_get_spmc -.Nd load a key-value pair from a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_get_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_get_spmc -function will return the value associated with the key specified in the -.Fa entry -argument in the hash table pointed to by the -.Fa ht -argument. The key specified in -.Fa entry -is expected to have the hash value specified by the -.Fa h -argument. -.Pp -If -.Fa ht -was created with CK_HT_MODE_BYTESTRING then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set_key 3 -or -.Xr ck_ht_entry_set 3 -functions. If -.Fa ht -was created with CK_HT_MODE_DIRECT then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_key_set_direct 3 -or -.Xr ck_ht_entry_set_direct 3 -functions. -.Pp -It is expected that -.Fa h -was initialized with -.Xr ck_ht_hash 3 -if -.Fa ht -was created with CK_HT_MODE_BYTESTRING. If -.Fa ht -was initialized with CK_HT_MODE_DIRECT then it is -expected that -.Fa h -was initialized with the -.Xr ck_ht_hash_direct 3 -function. -.Pp -If the call to -.Fn ck_ht_get_spmc -was successful then the key-value pair in -.Fa entry -was successfully found in the hash table pointed -to by -.Fa h -and will fail if the key specified in -.Fa entry -does not exist in the hash table. If successful -.Fa entry -will contain the key-value pair found in the hash table -pointed to by the -.Fa ht -argument. -.Pp -If -.Fa ht -was initialized with CK_HT_MODE_BYTESTRING then -the key/value pair in -.Fa entry -may be extracted using the -.Xr ck_ht_entry_key 3 -and -.Xr ck_ht_entry_value 3 -functions. The length of the key may be extracted -using the -.Xr ck_ht_entry_key_length 3 -function. -.Pp -If -.Fa ht -was initialized with CK_HT_MODE_DIRECT then the -key/value pair in -.Fa entry -may be extracted using the -.Xr ck_ht_entry_key_direct 3 -and -.Xr ck_ht_entry_value_direct 3 -functions. -.Pp -This function is safe to call in the presence of a concurrent writer. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_ht_get_spmc -returns -.Dv true. -If successful, -.Fa entry -will contain the key/value pair as found -in the hash table. -Otherwise the function returns -.Dv false -on failure. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa entry -or -.Fa ht -are uninitialized. The function will return -.Dv false -if the key as specified in -.Fa entry -was not found in the hash table. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_grow_spmc b/doc/ck_ht_grow_spmc deleted file mode 100644 index 70e6055fde2c..000000000000 --- a/doc/ck_ht_grow_spmc +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_GROW_SPMC 3 -.Sh NAME -.Nm ck_ht_grow_spmc -.Nd resize a hash table if necessary -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_grow_spmc "ck_ht_t *ht" "uint64_t capacity" -.Sh DESCRIPTION -The -.Fn ck_ht_grow_spmc -function will resize the hash table in order to be able to -at least store the number of entries specified by -.Fa capacity -at a load factor of one. The default load hash table load factor is -0.5. If you wish to minimize the likelihood of memory allocations -for a hash table meant to store n entries then specify a capacity -of 2n. The default behavior of ck_ht is to round -.Fa capacity -to the next available power of two if it is not already a power -of two. -.Pp -This function is safe to call in the presence of concurrent -.Xr ck_ht_get_spmc 3 -operations. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_ht_grow_spmc -returns -.Dv true -and otherwise returns a -.Dv false -value. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa ht -is uninitialized. The function will only return -.Dv false -if there are internal memory allocation failures. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_hash b/doc/ck_ht_hash deleted file mode 100644 index 0ac5db9a8b08..000000000000 --- a/doc/ck_ht_hash +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_HASH 3 -.Sh NAME -.Nm ck_ht_hash -.Nd generate a hash value for a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_hash "ck_ht_hash_t *h" "ck_ht_t *ht" "const void *key" "uint16_t key_length" -.Sh DESCRIPTION -The -.Fn ck_ht_hash -function will generate a hash value in the object pointed to by the -.Fa h -argument. The hash value is valid for use in the hash table pointed to by the -.Fa ht -argument for the key (of bytestring type) specified by the -.Fa key -argument. The length of the key is specified by the -.Fa key_length -argument. -.Sh RETURN VALUES -.Fn ck_ht_hash -has no return value. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa key -is -.Dv NULL -or if -.Fa ht -is uninitialized. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_hash_direct b/doc/ck_ht_hash_direct deleted file mode 100644 index 564099c12281..000000000000 --- a/doc/ck_ht_hash_direct +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_HASH_DIRECT 3 -.Sh NAME -.Nm ck_ht_hash_direct -.Nd generate a hash value for a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_hash_direct "ck_ht_hash_t *h" "ck_ht_t *ht" "uintptr_t key" -.Sh DESCRIPTION -The -.Fn ck_ht_hash_direct -function will generate a hash value in the object pointed to by the -.Fa h -argument. The hash value is valid for use in the hash table pointed to by the -.Fa ht -argument for the key (of direct type) specified by the -.Fa key -argument. -.Sh RETURN VALUES -.Fn ck_ht_hash_direct -has no return value. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa key -is a -.Dv 0 -or -.Dv UINTPTR_MAX -value or if -.Fa ht -is uninitialized. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_init b/doc/ck_ht_init deleted file mode 100644 index 757a39ad0313..000000000000 --- a/doc/ck_ht_init +++ /dev/null @@ -1,188 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 28, 2012 -.Dt CK_HT_INIT 3 -.Sh NAME -.Nm ck_ht_init -.Nd initialize a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft typedef void -.Fn ck_ht_hash_cb_t "ck_ht_hash_t *h" "const void *key" "size_t key_length" "uint64_t seed" -.Ft bool -.Fn ck_ht_init "ck_ht_t *ht" "enum ck_ht_mode mode" "ck_ht_hash_cb_t *hash_function" "struct ck_malloc *allocator" "uint64_t capacity" "uint64_t seed" -.Sh DESCRIPTION -The -.Fn ck_ht_init -function initializes the hash table pointed to by the -.Fa ht -pointer. -.Pp -The argument -.Fa mode -specifies the type of key-value pairs to be stored in the -hash table. The value of -.Fa mode -may be one of: -.Bl -tag -width indent -.It CK_HT_MODE_BYTESTRING -The hash table is meant to store key-value pointers where -key is a region of memory that is up to 65536 bytes long. -This pointer will be dereferenced during hash table operations -for key comparison. Entries of this hash table are expected -to be interacted with using the -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -and -.Xr ck_ht_entry_set 3 -functions. Attempting a hash table operation with a key of value -NULL or (void *)UINTPTR_MAX will result in undefined behavior. -.It CK_HT_MODE_DIRECT -The hash table is meant to store key-value pointers where -the key is of fixed width field compatible with the -.Tn uintptr_t -type. The key will be directly compared with other keys for -equality. Entries of this hash table are expected to be interacted -with using the -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 -and -.Xr ck_ht_entry_set_direct 3 -functions. Attempting a hash table operation with a key of value of 0 or -UINTPTR_MAX will result in undefined behavior. -.El -.Pp -In addition to this, the user may bitwise OR the mode flag with -CK_HT_WORKLOAD_DELETE to indicate that the hash table will -have to handle a delete heavy workload, in which case stronger -bounds on latency can be provided at the cost of approximately -13% higher memory usage. -The argument -.Fa hash_function -is a pointer to a user-specified hash function. It is optional, -if -.Dv NULL -is specified, then the default hash function implementation will be -used ( -.Xr ck_ht_hash 3 ). -A user-specified hash function takes four arguments. The -.Fa h -argument is a pointer to a hash value object. The hash function -is expected to update the -.Fa value -object of type -.Fa uint64_t -contained with-in the object pointed to by -.Fa h . -The -.Fa key -argument is a pointer to a key, the -.Fa key_length -argument is the length of the key and the -.Fa seed -argument is the initial seed associated with the hash table. -This initial seed is specified by the user in -.Xr ck_ht_init 3 . -.Pp -The -.Fa allocator -argument is a pointer to a structure containing -.Fa malloc -and -.Fa free -function pointers which respectively define the memory allocation and -destruction functions to be used by the hash table being initialized. -.Pp -The argument -.Fa capacity -represents the initial number of key-value pairs the hash -table is expected to contain. This argument is simply a hint -and the underlying implementation is free to allocate more -or less memory than necessary to contain the number of entries -.Fa capacity -specifies. -.Pp -The argument -.Fa seed -specifies the initial seed used by the underlying hash function. -The user is free to choose a value of their choice. -.Pp -The hash table is safe to access by multiple readers in the presence -of one concurrent writer. Behavior is undefined in the presence of -concurrent writers. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_ht_init -returns a value of -.Dv true -and otherwise returns a value of -.Dv false -to indicate an error. -.Sh ERRORS -.Bl -tag -width Er -.Pp -The behavior of -.Fn ck_ht_init -is undefined if -.Fa ht -is not a pointer to a -.Tn ck_ht_t -object. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_iterator_init b/doc/ck_ht_iterator_init deleted file mode 100644 index 14f10c6ec450..000000000000 --- a/doc/ck_ht_iterator_init +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_ITERATOR_INIT 3 -.Sh NAME -.Nm ck_ht_iterator_init -.Nd initialize hash table iterator -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Pp -.Dv ck_ht_iterator_t iterator = CK_HT_ITERATOR_INITIALIZER -.Pp -.Ft void -.Fn ck_ht_iterator_init "ck_ht_iterator_t *iterator" -.Sh DESCRIPTION -The -.Fn ck_ht_iterator_init -function will initialize the object pointed to by -the -.Fa iterator -argument. Alternatively, an iterator may be statically initialized -by assigning it the -.Dv CK_HT_ITERATOR_INITIALIZER -value. -.Pp -An iterator is used to iterate through hash table entries -with the -.Xr ck_ht_next 3 -function. -.Sh RETURN VALUES -The -.Fn ck_ht_iterator_init -function does not return a value. -.Sh ERRORS -This function will not fail. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_next b/doc/ck_ht_next deleted file mode 100644 index d0365a16ca0f..000000000000 --- a/doc/ck_ht_next +++ /dev/null @@ -1,107 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 30, 2012 -.Dt CK_HT_NEXT 3 -.Sh NAME -.Nm ck_ht_next -.Nd iterate to next entry in hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_next "ck_ht_t *ht" "ck_ht_iterator_t *iterator" "ck_ht_entry_t **entry" -.Sh DESCRIPTION -The -.Fn ck_ht_next -function will increment the iterator object pointed to by -.Fa iterator -to point to the next non-empty hash table entry. If -.Fn ck_ht_next -returns -.Dv true -then the pointer pointed to by -.Fa entry -is initialized to the current hash table entry pointed to by -the -.Fa iterator -object. -.Pp -It is expected that -.Fa iterator -has been initialized using the -.Xr ck_ht_iterator_init 3 -function or statically initialized using -.Dv CK_HT_ITERATOR_INITIALIZER. -.Sh RETURN VALUES -If -.Fn ck_ht_next -returns -.Dv true -then the object pointed to by -.Fa entry -points to a valid hash table entry. If -.Fn ck_ht_next -returns -.Dv false -then value of the object pointed to by -.Fa entry -is undefined. -.Sh ERRORS -Behavior is undefined if -.Fa iterator -or -.Fa ht -are uninitialized. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_put_spmc b/doc/ck_ht_put_spmc deleted file mode 100644 index f5a638999cf9..000000000000 --- a/doc/ck_ht_put_spmc +++ /dev/null @@ -1,146 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_PUT_SPMC 3 -.Sh NAME -.Nm ck_ht_put_spmc -.Nd store unique key-value pair into hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_put_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_put_spmc -function will store the key-value pair specified in the -.Fa entry -argument in the hash table pointed to by the -.Fa ht -argument. The key specified in -.Fa entry -is expected to have the hash value specified by the -.Fa h -argument. -.Pp -If -.Fa ht -was created with CK_HT_MODE_BYTESTRING then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set 3 -function. If -.Fa ht -was created with CK_HT_MODE_DIRECT then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set_direct 3 -function. -.Pp -It is expected that -.Fa h -was initialized with -.Xr ck_ht_hash 3 -if -.Fa ht -was created with CK_HT_MODE_BYTESTRING. If -.Fa ht -was initialized with CK_HT_MODE_DIRECT then it is -expected that -.Fa h -was initialized with the -.Xr ck_ht_hash_direct 3 -function. -.Pp -If the call to -.Fn ck_ht_put_spmc -was successful then the key-value pair in -.Fa entry -was successfully stored in the hash table pointed -to by -.Fa ht -and will fail if the key specified in -.Fa entry -already exists with-in the hash table. Replacement semantics -are provided by the -.Xr ck_ht_set_spmc 3 -function. -.Pp -This function is safe to call in the presence of concurrent -.Xr ck_ht_get_spmc 3 -operations. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_ht_put_spmc -returns -.Dv true -and otherwise returns -.Dv false -on failure. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa entry -or -.Fa ht -are uninitialized. The function will return -.Dv false -if the hash table required to be grown but failed -while attempting to grow or if the key specified -in -.Fa entry -was already present in the hash table. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_remove_spmc b/doc/ck_ht_remove_spmc deleted file mode 100644 index a263866a6c14..000000000000 --- a/doc/ck_ht_remove_spmc +++ /dev/null @@ -1,117 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_GROW_SPMC 3 -.Sh NAME -.Nm ck_ht_remove_spmc -.Nd resize a hash table if necessary -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_remove_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_remove_spmc -function will remove the key-value pair associated with the -key specified by the -.Fa entry -argument. -.Pp -If -.Fa ht -was created with CK_HT_MODE_BYTESTRING then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set_key 3 -or -.Xr ck_ht_entry_set 3 -functions. If -.Fa ht -was created with CK_HT_MODE_DIRECT then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_key_set_direct 3 -or -.Xr ck_ht_entry_set_direct 3 -functions. -.Pp -It is expected that -.Fa h -was initialized with -.Xr ck_ht_hash 3 -if -.Fa ht -was created with CK_HT_MODE_BYTESTRING. If -.Fa ht -was initialized with CK_HT_MODE_DIRECT then it is -expected that -.Fa h -was initialized with the -.Xr ck_ht_hash_direct 3 -function. -.Sh RETURN VALUES -If successful, -.Fa entry -will contain the key-value pair that was found in the hash table -and -.Fn ck_ht_remove_spmc -will return -.Dv true. -If the entry could not be found then -.Fn ck_ht_remove_spmc -will return -.Dv false. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_reset_size_spmc b/doc/ck_ht_reset_size_spmc deleted file mode 100644 index 43083809e645..000000000000 --- a/doc/ck_ht_reset_size_spmc +++ /dev/null @@ -1,84 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 5, 2013 -.Dt CK_HT_RESET_SPMC 3 -.Sh NAME -.Nm ck_ht_reset_size_spmc -.Nd remove all entries from a hash table and reset size -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_reset_size_spmc "ck_ht_t *ht" "uint64_t capacity" -.Sh DESCRIPTION -The -.Fn ck_ht_reset_size_spmc -function will remove all key-value pairs stored in the hash -table pointed to by the -.Fa ht -argument and create a new generation of the hash table that -is preallocated for -.Fa capacity -entries. -.Sh RETURN VALUES -If successful, -.Fn ck_ht_reset_size_spmc -will return -.Dv true -and will otherwise return -.Dv false. -This function will only fail if a replacement hash table -could not be allocated internally. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_reset_spmc b/doc/ck_ht_reset_spmc deleted file mode 100644 index dc2e60168b09..000000000000 --- a/doc/ck_ht_reset_spmc +++ /dev/null @@ -1,81 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_RESET_SPMC 3 -.Sh NAME -.Nm ck_ht_reset_spmc -.Nd remove all entries from a hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_reset_spmc "ck_ht_t *ht" -.Sh DESCRIPTION -The -.Fn ck_ht_reset_spmc -function will remove all key-value pairs stored in the hash -table pointed to by the -.Fa ht -argument. -.Sh RETURN VALUES -If successful, -.Fn ck_ht_reset_spmc -will return -.Dv true -and will otherwise return -.Dv false. -This function will only fail if a replacement hash table -could not be allocated internally. -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_set_spmc b/doc/ck_ht_set_spmc deleted file mode 100644 index e0fe1ae386aa..000000000000 --- a/doc/ck_ht_set_spmc +++ /dev/null @@ -1,140 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd March 29, 2012 -.Dt CK_HT_SET_SPMC 3 -.Sh NAME -.Nm ck_ht_set_spmc -.Nd store key-value pair into hash table -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft bool -.Fn ck_ht_set_spmc "ck_ht_t *ht" "ck_ht_hash_t h" "ck_ht_entry_t *entry" -.Sh DESCRIPTION -The -.Fn ck_ht_set_spmc -function will store the key-value pair specified in the -.Fa entry -argument in the hash table pointed to by the -.Fa ht -argument. The key specified in -.Fa entry -is expected to have the hash value specified by the -.Fa h -argument. -.Pp -If -.Fa ht -was created with CK_HT_MODE_BYTESTRING then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set 3 -function. If -.Fa ht -was created with CK_HT_MODE_DIRECT then -.Fa entry -must have been initialized with the -.Xr ck_ht_entry_set_direct 3 -function. -.Pp -It is expected that -.Fa h -was initialized with -.Xr ck_ht_hash 3 -if -.Fa ht -was created with CK_HT_MODE_BYTESTRING. If -.Fa ht -was initialized with CK_HT_MODE_DIRECT then it is -expected that -.Fa h -was initialized with the -.Xr ck_ht_hash_direct 3 -function. -.Pp -If the call to -.Fn ck_ht_set_spmc -was successful then the key-value pair in -.Fa entry -will contain the previous key-value pair associated -with the key originally contained in the -.Fa entry -argument. If the operation was unsuccessful then -.Fa entry -is unmodified. -.Pp -This function is safe to call in the presence of concurrent -.Xr ck_ht_get_spmc -operations. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_ht_set_spmc -returns -.Dv true -and otherwise returns -.Dv false -on failure. -.Sh ERRORS -.Bl -tag -width Er -Behavior is undefined if -.Fa entry -or -.Fa ht -are uninitialized. The function will return -.Dv false -if the hash table required to be grown but failed -while attempting to grow. -.El -.Sh SEE ALSO -.Xr ck_ht_stat 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_count 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ht_stat b/doc/ck_ht_stat deleted file mode 100644 index 6d2f1cde5717..000000000000 --- a/doc/ck_ht_stat +++ /dev/null @@ -1,85 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_HT_STAT 3 -.Sh NAME -.Nm ck_ht_stat -.Nd get hash table status -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ht.h -.Ft void -.Fn ck_ht_stat "ck_ht_t *ht" "struct ck_ht_stat *st" -.Sh DESCRIPTION -The -.Fn ck_ht_stat 3 -function will store various hash set statistics in the object -pointed to by -.Fa st . -The ck_ht_stat structure is defined as follows: -.Bd -literal -offset indent -struct ck_ht_stat { - uint64_t probe_maximum; /* Longest read-side probe sequence. */ - uint64_t n_entries; /* Current number of keys in hash set. */ -}; -.Ed -.Sh RETURN VALUES -.Fn ck_ht_stat 3 -has no return value. -.Sh ERRORS -Behavior is undefined if -.Fa ht -has not been initialized. -.Sh SEE ALSO -.Xr ck_ht_count 3 , -.Xr ck_ht_init 3 , -.Xr ck_ht_destroy 3 , -.Xr ck_ht_hash 3 , -.Xr ck_ht_hash_direct 3 , -.Xr ck_ht_set_spmc 3 , -.Xr ck_ht_put_spmc 3 , -.Xr ck_ht_gc 3 , -.Xr ck_ht_get_spmc 3 , -.Xr ck_ht_grow_spmc 3 , -.Xr ck_ht_remove_spmc 3 , -.Xr ck_ht_reset_spmc 3 , -.Xr ck_ht_reset_size_spmc 3 , -.Xr ck_ht_entry_empty 3 , -.Xr ck_ht_entry_key_set 3 , -.Xr ck_ht_entry_key_set_direct 3 , -.Xr ck_ht_entry_key 3 , -.Xr ck_ht_entry_key_length 3 , -.Xr ck_ht_entry_value 3 , -.Xr ck_ht_entry_set 3 , -.Xr ck_ht_entry_set_direct 3 , -.Xr ck_ht_entry_key_direct 3 , -.Xr ck_ht_entry_value_direct 3 , -.Xr ck_ht_iterator_init 3 , -.Xr ck_ht_next 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pflock b/doc/ck_pflock deleted file mode 100644 index 6fea7017c530..000000000000 --- a/doc/ck_pflock +++ /dev/null @@ -1,95 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2014. -.Dt ck_pflock 3 -.Sh NAME -.Nm ck_pflock_init , -.Nm ck_pflock_write_lock , -.Nm ck_pflock_write_unlock , -.Nm ck_pflock_read_lock , -.Nm ck_pflock_read_unlock , -.Nd centralized phase-fair reader-writer locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pflock.h -.Pp -.Dv ck_pflock_t lock = CK_PFLOCK_INITIALIZER; -.Pp -.Ft void -.Fn ck_pflock_init "ck_pflock_t *lock" -.Ft void -.Fn ck_pflock_write_lock "ck_pflock_t *lock" -.Ft void -.Fn ck_pflock_write_unlock "ck_pflock_t *lock" -.Ft void -.Fn ck_pflock_read_lock "ck_pflock_t *lock" -.Ft void -.Fn ck_pflock_read_unlock "ck_pflock_t *lock" -.Sh DESCRIPTION -This is a centralized phase-fair reader-writer lock. It -requires little space overhead and has a low latency -fast path. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -static ck_pflock_t lock = CK_TFLOCK_INITIALIZER; - -static void -reader(void) -{ - - for (;;) { - ck_pflock_read_lock(&lock); - /* Read-side critical section. */ - ck_pflock_read_unlock(&lock); - } - - return; -} - -static void -writer(void) -{ - - for (;;) { - ck_pflock_write_lock(&lock); - /* Write-side critical section. */ - ck_pflock_write_unlock(&lock); - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_brlock 3 , -.Xr ck_rwlock 3 , -.Xr ck_tflock 3 , -.Xr ck_swlock 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr b/doc/ck_pr deleted file mode 100644 index 67c726feca3f..000000000000 --- a/doc/ck_pr +++ /dev/null @@ -1,71 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr 3 -.Sh NAME -.Nm ck_pr -.Nd concurrency primitives interface -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Sh DESCRIPTION -ck_pr.h provides an interface to volatile atomic instructions, -memory barriers and busy-wait facilities as provided by the -underlying processor. The presence of an atomic operation -is detected by the presence of a corresponding CK_F_PR macro. -For example, the availability of -.Xr ck_pr_add_16 3 -would be determined by the presence of CK_F_PR_ADD_16. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_acquire 3 , -.Xr ck_pr_fence_release 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_add b/doc/ck_pr_add deleted file mode 100644 index b4d394a63f3d..000000000000 --- a/doc/ck_pr_add +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_add 3 -.Sh NAME -.Nm ck_pr_add_ptr , -.Nm ck_pr_add_double , -.Nm ck_pr_add_char , -.Nm ck_pr_add_uint , -.Nm ck_pr_add_int , -.Nm ck_pr_add_64 , -.Nm ck_pr_add_32 , -.Nm ck_pr_add_16 , -.Nm ck_pr_add_8 -.Nd atomic addition operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_add_ptr "void *target" "uintptr_t delta" -.Ft void -.Fn ck_pr_add_double "double *target" "double delta" -.Ft void -.Fn ck_pr_add_char "char *target" "char delta" -.Ft void -.Fn ck_pr_add_uint "unsigned int *target" "unsigned int delta" -.Ft void -.Fn ck_pr_add_int "int *target" "int delta" -.Ft void -.Fn ck_pr_add_64 "uint64_t *target" "uint64_t delta" -.Ft void -.Fn ck_pr_add_32 "uint32_t *target" "uint32_t delta" -.Ft void -.Fn ck_pr_add_16 "uint16_t *target" "uint16_t delta" -.Ft void -.Fn ck_pr_add_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_add 3 -family of functions atomically add the value specified by -.Fa delta -to the value pointed to by -.Fa target . -.Sh RETURN VALUES -This family of functions does not have a return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_and b/doc/ck_pr_and deleted file mode 100644 index 56ce5af13542..000000000000 --- a/doc/ck_pr_and +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_and 3 -.Sh NAME -.Nm ck_pr_and_ptr , -.Nm ck_pr_and_char , -.Nm ck_pr_and_uint , -.Nm ck_pr_and_int , -.Nm ck_pr_and_64 , -.Nm ck_pr_and_32 , -.Nm ck_pr_and_16 , -.Nm ck_pr_and_8 -.Nd atomic bitwise-and operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_and_ptr "void *target" "uintptr_t delta" -.Ft void -.Fn ck_pr_and_char "char *target" "char delta" -.Ft void -.Fn ck_pr_and_uint "unsigned int *target" "unsigned int delta" -.Ft void -.Fn ck_pr_and_int "int *target" "int delta" -.Ft void -.Fn ck_pr_and_64 "uint64_t *target" "uint64_t delta" -.Ft void -.Fn ck_pr_and_32 "uint32_t *target" "uint32_t delta" -.Ft void -.Fn ck_pr_and_16 "uint16_t *target" "uint16_t delta" -.Ft void -.Fn ck_pr_and_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_and 3 -family of functions atomically compute and store the -result of a bitwise-and of the value pointed to by -.Fa target -and -.Fa delta -into the value pointed to by -.Fa target . -.Sh RETURN VALUES -This family of functions does not have a return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_barrier b/doc/ck_pr_barrier deleted file mode 100644 index 38867291dbbc..000000000000 --- a/doc/ck_pr_barrier +++ /dev/null @@ -1,66 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_barrier 3 -.Sh NAME -.Nm ck_pr_barrier -.Nd compiler optimization barrier -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_barrier void -.Sh DESCRIPTION -The -.Fn ck_pr_barrier 3 -function is used to disable code movement optimizations -across the invocation of the function. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_btc b/doc/ck_pr_btc deleted file mode 100644 index 5956221e3f19..000000000000 --- a/doc/ck_pr_btc +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_btc 3 -.Sh NAME -.Nm ck_pr_btc_ptr , -.Nm ck_pr_btc_uint , -.Nm ck_pr_btc_int , -.Nm ck_pr_btc_64 , -.Nm ck_pr_btc_32 , -.Nm ck_pr_btc_16 -.Nd atomic bit test-and-complement operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft bool -.Fn ck_pr_btc_ptr "void *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btc_uint "uint *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btc_int "int *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btc_64 "uint64_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btc_32 "uint32_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btc_16 "uint16_t *target" "unsigned int bit_index" -.Sh DESCRIPTION -The -.Fn ck_pr_btc 3 -family of functions atomically fetch the value -of the bit in -.Fa target -at index -.Fa bit_index -and set that bit to its complement. -.Sh RETURN VALUES -These family of functions return the original value of -the bit at offset -.Fa bit_index -that is in the value pointed to by -.Fa target . -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_btr 3 , -.Xr ck_pr_cas 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_btr b/doc/ck_pr_btr deleted file mode 100644 index d5e03fd64c75..000000000000 --- a/doc/ck_pr_btr +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_btr 3 -.Sh NAME -.Nm ck_pr_btr_ptr , -.Nm ck_pr_btr_uint , -.Nm ck_pr_btr_int , -.Nm ck_pr_btr_64 , -.Nm ck_pr_btr_32 , -.Nm ck_pr_btr_16 -.Nd atomic bit test-and-reset operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft bool -.Fn ck_pr_btr_ptr "void *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btr_uint "uint *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btr_int "int *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btr_64 "uint64_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btr_32 "uint32_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_btr_16 "uint16_t *target" "unsigned int bit_index" -.Sh DESCRIPTION -The -.Fn ck_pr_btr 3 -family of functions atomically fetch the value -of the bit in -.Fa target -at index -.Fa bit_index -and set that bit to 0. -.Sh RETURN VALUES -This family of functions returns the original value of -the bit at offset -.Fa bit_index -that is in the value pointed to by -.Fa target . -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_cas 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_bts b/doc/ck_pr_bts deleted file mode 100644 index 955855d71657..000000000000 --- a/doc/ck_pr_bts +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_bts 3 -.Sh NAME -.Nm ck_pr_bts_ptr , -.Nm ck_pr_bts_uint , -.Nm ck_pr_bts_int , -.Nm ck_pr_bts_64 , -.Nm ck_pr_bts_32 , -.Nm ck_pr_bts_16 -.Nd atomic bit test-and-set operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft bool -.Fn ck_pr_bts_ptr "void *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_bts_uint "uint *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_bts_int "int *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_bts_64 "uint64_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_bts_32 "uint32_t *target" "unsigned int bit_index" -.Ft bool -.Fn ck_pr_bts_16 "uint16_t *target" "unsigned int bit_index" -.Sh DESCRIPTION -The -.Fn ck_pr_bts 3 -family of functions atomically fetch the value -of the bit in -.Fa target -at index -.Fa bit_index -and set that bit to 1. -.Sh RETURN VALUES -This family of functions returns the original value of -the bit at offset -.Fa bit_index -that is in the value pointed to by -.Fa target . -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_btr 3 , -.Xr ck_pr_cas 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_cas b/doc/ck_pr_cas deleted file mode 100644 index 9d1d39b22aed..000000000000 --- a/doc/ck_pr_cas +++ /dev/null @@ -1,147 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_cas 3 -.Sh NAME -.Nm ck_pr_cas_ptr , -.Nm ck_pr_cas_ptr_value , -.Nm ck_pr_cas_ptr_2 , -.Nm ck_pr_cas_ptr_2_value , -.Nm ck_pr_cas_double , -.Nm ck_pr_cas_double_value , -.Nm ck_pr_cas_char , -.Nm ck_pr_cas_char_value , -.Nm ck_pr_cas_uint , -.Nm ck_pr_cas_uint_value , -.Nm ck_pr_cas_int , -.Nm ck_pr_cas_int_value , -.Nm ck_pr_cas_64_2 , -.Nm ck_pr_cas_64_2_value , -.Nm ck_pr_cas_64 , -.Nm ck_pr_cas_64_value , -.Nm ck_pr_cas_32 , -.Nm ck_pr_cas_32_value , -.Nm ck_pr_cas_16 , -.Nm ck_pr_cas_16_value , -.Nm ck_pr_cas_8 , -.Nm ck_pr_cas_8_value -.Nd atomic compare-and-swap operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft bool -.Fn ck_pr_cas_ptr "void *target" "void *old_value" "void *new_value" -.Ft bool -.Fn ck_pr_cas_ptr_value "void *target" "void *old_value" "void *new_value" "void *original_value" -.Ft bool -.Fn ck_pr_cas_ptr_2 "void *target" "void *old_value" "void *new_value" -.Ft bool -.Fn ck_pr_cas_ptr_2_value "void *target" "void *old_value" "void *new_value" "void *original_value" -.Ft bool -.Fn ck_pr_cas_double "double *target" "double old_value" "double new_value" -.Ft bool -.Fn ck_pr_cas_double_value "double *target" "double old_value" "double new_value" "double *original_value" -.Ft bool -.Fn ck_pr_cas_char "char *target" "char old_value" "char new_value" -.Ft bool -.Fn ck_pr_cas_char_value "char *target" "char old_value" "char new_value" "char *original_value" -.Ft bool -.Fn ck_pr_cas_uint "unsigned int *target" "unsigned int old_value" "unsigned int new_value" -.Ft bool -.Fn ck_pr_cas_uint_value "unsigned int *target" "unsigned int old_value" "unsigned int new_value" "unsigned int *original_value" -.Ft bool -.Fn ck_pr_cas_int "int *target" "int old_value" "int new_value" -.Ft bool -.Fn ck_pr_cas_int_value "int *target" "int old_value" "int new_value" "int *original_value" -.Ft bool -.Fn ck_pr_cas_64_2 "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" -.Ft bool -.Fn ck_pr_cas_64_2_value "uint64_t target[static 2]" "uint64_t old_value[static 2]" "uint64_t new_value[static 2]" "uint64_t original_value[static 2]" -.Ft bool -.Fn ck_pr_cas_64 "uint64_t *target" "uint64_t old_value" "uint64_t new_value" -.Ft bool -.Fn ck_pr_cas_64_value "uint64_t *target" "uint64_t old_value" "uint64_t new_value" "uint64_t *original_value" -.Ft bool -.Fn ck_pr_cas_32 "uint32_t *target" "uint32_t old_value" "uint32_t new_value" -.Ft bool -.Fn ck_pr_cas_32_value "uint32_t *target" "uint32_t old_value" "uint32_t new_value" "uint32_t *original_value" -.Ft bool -.Fn ck_pr_cas_16 "uint16_t *target" "uint16_t old_value" "uint16_t new_value" -.Ft bool -.Fn ck_pr_cas_16_value "uint16_t *target" "uint16_t old_value" "uint16_t new_value" "uint16_t *original_value" -.Ft bool -.Fn ck_pr_cas_8 "uint8_t *target" "uint8_t old_value" "uint8_t new_value" -.Ft bool -.Fn ck_pr_cas_8_value "uint8_t *target" "uint8_t old_value" "uint8_t new_value" "uint8_t *original_value" -.Sh DESCRIPTION -The -.Fn ck_pr_cas 3 -family of functions atomically compare the value in -.Fa target -for equality with -.Fa old_value -and if so, replace the value pointed to by -.Fa target -with the value specified by -.Fa new_value . -If the value in -.Fa target -was not equal to the value specified by -.Fa old_value -then no modifications occur to the value in -.Fa target . -The *_value form of these functions unconditionally update -.Fa original_value . -.Sh RETURN VALUES -This family of functions return true if the value in -.Fa target -was modified as a result of the operation. Otherwise, they -return false. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_dec b/doc/ck_pr_dec deleted file mode 100644 index f3d34dd7aadb..000000000000 --- a/doc/ck_pr_dec +++ /dev/null @@ -1,124 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_dec 3 -.Sh NAME -.Nm ck_pr_dec_ptr , -.Nm ck_pr_dec_ptr_zero , -.Nm ck_pr_dec_double , -.Nm ck_pr_dec_double_zero , -.Nm ck_pr_dec_char , -.Nm ck_pr_dec_char_zero , -.Nm ck_pr_dec_uint , -.Nm ck_pr_dec_uint_zero , -.Nm ck_pr_dec_int , -.Nm ck_pr_dec_int_zero , -.Nm ck_pr_dec_64 , -.Nm ck_pr_dec_64_zero , -.Nm ck_pr_dec_32 , -.Nm ck_pr_dec_32_zero , -.Nm ck_pr_dec_16 , -.Nm ck_pr_dec_16_zero , -.Nm ck_pr_dec_8 , -.Nm ck_pr_dec_8_zero -.Nd atomic decrement operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_dec_ptr "void *target" -.Ft void -.Fn ck_pr_dec_ptr_zero "void *target" "bool *z" -.Ft void -.Fn ck_pr_dec_double "double *target" -.Ft void -.Fn ck_pr_dec_double_zero "double *target" "bool *z" -.Ft void -.Fn ck_pr_dec_char "char *target" -.Ft void -.Fn ck_pr_dec_char_zero "char *target" "bool *z" -.Ft void -.Fn ck_pr_dec_uint "unsigned int *target" -.Ft void -.Fn ck_pr_dec_uint_zero "unsigned int *target" "bool *z" -.Ft void -.Fn ck_pr_dec_int "int *target" -.Ft void -.Fn ck_pr_dec_int_zero "int *target" "bool *z" -.Ft void -.Fn ck_pr_dec_64 "uint64_t *target" -.Ft void -.Fn ck_pr_dec_64_zero "uint64_t *target" "bool *z" -.Ft void -.Fn ck_pr_dec_32 "uint32_t *target" -.Ft void -.Fn ck_pr_dec_32_zero "uint32_t *target" "bool *z" -.Ft void -.Fn ck_pr_dec_16 "uint16_t *target" -.Ft void -.Fn ck_pr_dec_16_zero "uint16_t *target" "bool *z" -.Ft void -.Fn ck_pr_dec_8 "uint8_t *target" -.Ft void -.Fn ck_pr_dec_8_zero "uint8_t *target" "bool *z" -.Sh DESCRIPTION -The -.Fn ck_pr_dec 3 -family of functions atomically decrement the value pointed to -by -.Fa target . -.Sh RETURN VALUES -The ck_pr_dec_zero family of functions set the value pointed to by -.Fa z -to true if the result -of the decrement operation was 0. They set the value pointed to by -.Fa z -to false otherwise. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_faa b/doc/ck_pr_faa deleted file mode 100644 index fbeff01af128..000000000000 --- a/doc/ck_pr_faa +++ /dev/null @@ -1,99 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_faa 3 -.Sh NAME -.Nm ck_pr_faa_ptr , -.Nm ck_pr_faa_double , -.Nm ck_pr_faa_char , -.Nm ck_pr_faa_uint , -.Nm ck_pr_faa_int , -.Nm ck_pr_faa_64 , -.Nm ck_pr_faa_32 , -.Nm ck_pr_faa_16 , -.Nm ck_pr_faa_8 -.Nd atomic fetch-and-add operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft uintptr_t -.Fn ck_pr_faa_ptr "void *target" "uintptr_t delta" -.Ft double -.Fn ck_pr_faa_double "double *target" "double delta" -.Ft char -.Fn ck_pr_faa_char "char *target" "char delta" -.Ft unsigned int -.Fn ck_pr_faa_uint "unsigned int *target" "unsigned int delta" -.Ft int -.Fn ck_pr_faa_int "int *target" "int delta" -.Ft uint64_t -.Fn ck_pr_faa_64 "uint64_t *target" "uint64_t delta" -.Ft uint32_t -.Fn ck_pr_faa_32 "uint32_t *target" "uint32_t delta" -.Ft uint16_t -.Fn ck_pr_faa_16 "uint16_t *target" "uint16_t delta" -.Ft uint8_t -.Fn ck_pr_faa_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_faa 3 -family of functions atomically fetch the value pointed to -by -.Fa target -and add the value specified by -.Fa delta -to the value pointed to by -.Fa target . -.Sh RETURN VALUES -This function returns the value pointed to by -.Fa target -at the time of operation invocation before the -addition operation is applied. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fas b/doc/ck_pr_fas deleted file mode 100644 index 037b1044df35..000000000000 --- a/doc/ck_pr_fas +++ /dev/null @@ -1,100 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_fas 3 -.Sh NAME -.Nm ck_pr_fas_ptr , -.Nm ck_pr_fas_double , -.Nm ck_pr_fas_char , -.Nm ck_pr_fas_uint , -.Nm ck_pr_fas_int , -.Nm ck_pr_fas_64 , -.Nm ck_pr_fas_32 , -.Nm ck_pr_fas_16 , -.Nm ck_pr_fas_8 -.Nd atomic swap operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void * -.Fn ck_pr_fas_ptr "void *target" "void *new_value" -.Ft double -.Fn ck_pr_fas_double "double *target" "double new_value" -.Ft char -.Fn ck_pr_fas_char "char *target" "char new_value" -.Ft unsigned int -.Fn ck_pr_fas_uint "unsigned int *target" "unsigned int new_value" -.Ft int -.Fn ck_pr_fas_int "int *target" "int new_value" -.Ft uint64_t -.Fn ck_pr_fas_64 "uint64_t *target" "uint64_t new_value" -.Ft uint32_t -.Fn ck_pr_fas_32 "uint32_t *target" "uint32_t new_value" -.Ft uint16_t -.Fn ck_pr_fas_16 "uint16_t *target" "uint16_t new_value" -.Ft uint8_t -.Fn ck_pr_fas_8 "uint8_t *target" "uint8_t new_value" -.Sh DESCRIPTION -The -.Fn ck_pr_fas 3 -family of functions atomically fetch the value pointed to -by -.Fa target -and replace the value pointed to by -.Fa target -with the value specified by -.Fa new_value . -.Sh RETURN VALUES -This function returns the value pointed to by -.Fa target -at the time of operation invocation before it was -atomically replaced with -.Fa new_value . -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_acquire b/doc/ck_pr_fence_acquire deleted file mode 100644 index 2d6b9973c6b1..000000000000 --- a/doc/ck_pr_fence_acquire +++ /dev/null @@ -1,72 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd January 2, 2014 -.Dt CK_PR_FENCE_ACQUIRE 3 -.Sh NAME -.Nm ck_pr_fence_acquire -.Nd enforce acquire semantics -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_acquire void -.Sh DESCRIPTION -This function enforces the partial ordering of any loads prior -to invocation with respect to any following stores, loads and -atomic operations. It is typically used to implement critical -sections. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_release 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_atomic b/doc/ck_pr_fence_atomic deleted file mode 100644 index 06803283e561..000000000000 --- a/doc/ck_pr_fence_atomic +++ /dev/null @@ -1,111 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC 3 -.Sh NAME -.Nm ck_pr_fence_atomic -.Nd enforce partial ordering of atomic read-modify-write operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_atomic void -.Ft void -.Fn ck_pr_fence_strict_atomic void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_atomic -function enforces the ordering of any -atomic read-modify-write operations relative to -the invocation of the function. This function -always serve as an implicit compiler barrier. On -architectures implementing CK_MD_TSO, this operation -only serves as a compiler barrier and no fences -are emitted. On architectures implementing -CK_MD_PSO and CK_MD_RMO, a store fence is -emitted. To force the unconditional emission of -a fence, use -.Fn ck_pr_fence_strict_atomic . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; -static int c = 0; - -void -function(void) -{ - - ck_pr_fas_int(&a, 1); - - /* - * Guarantee that the update to a is completed - * with respect to the updates of b and c. - */ - ck_pr_fence_atomic(); - ck_pr_fas_int(&b, 2); - ck_pr_fas_int(&c, 2); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_atomic_load b/doc/ck_pr_fence_atomic_load deleted file mode 100644 index 77675cebc2e7..000000000000 --- a/doc/ck_pr_fence_atomic_load +++ /dev/null @@ -1,108 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC_LOAD 3 -.Sh NAME -.Nm ck_pr_fence_atomic_load -.Nd enforce ordering of atomic read-modify-write operations to load operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_atomic_load void -.Ft void -.Fn ck_pr_fence_strict_atomic_load void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_atomic_load -function enforces the ordering of any -atomic read-modify-write operations relative to -any load operations following the function invocation. This function -always serve as an implicit compiler barrier. On -architectures implementing CK_MD_TSO, this operation -only serves as a compiler barrier and no fences -are emitted. To force the unconditional emission of -a fence, use -.Fn ck_pr_fence_strict_atomic_load . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; - -void -function(void) -{ - int c; - - ck_pr_fas_int(&a, 1); - - /* - * Guarantee that the update to a is completed - * with respect to the load of *b. - */ - ck_pr_fence_atomic_load(); - c = ck_pr_load_int(&b); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_atomic_store b/doc/ck_pr_fence_atomic_store deleted file mode 100644 index fd02122ea6f7..000000000000 --- a/doc/ck_pr_fence_atomic_store +++ /dev/null @@ -1,109 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 16, 2013 -.Dt CK_PR_FENCE_ATOMIC_STORE 3 -.Sh NAME -.Nm ck_pr_fence_atomic_store -.Nd enforce ordering of atomic read-modify-write operations to store operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_atomic_store void -.Ft void -.Fn ck_pr_fence_strict_atomic_store void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_atomic_store -function enforces the ordering of any -atomic read-modify-write operations relative to -any load operations following the function invocation. This function -always serve as an implicit compiler barrier. On -architectures implementing CK_MD_TSO, this operation -only serves as a compiler barrier and no fences -are emitted. To force the unconditional emission of -a fence, use -.Fn ck_pr_fence_strict_atomic_store . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; - -void -function(void) -{ - int c; - - ck_pr_fas_int(&a, 1); - - /* - * Guarantee that the update to a is completed - * with respect to the store into the value pointed - * to by b. - */ - ck_pr_fence_atomic_store(); - c = ck_pr_store_int(&b, 2); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load b/doc/ck_pr_fence_load deleted file mode 100644 index b6e778df94bd..000000000000 --- a/doc/ck_pr_fence_load +++ /dev/null @@ -1,113 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_fence_load 3 -.Sh NAME -.Nm ck_pr_fence_load -.Nd enforce partial ordering of load operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_load void -.Ft void -.Fn ck_pr_fence_strict_load void -.Sh DESCRIPTION -This function enforces the ordering of any memory load -and -.Fn ck_pr_load 3 -operations relative to the invocation of the function. Any -store operations that were committed on remote processors -and received by the calling processor before the invocation of -.Fn ck_pr_fence_load -is also be made visible only after a call to -.Fn ck_pr_fence_load . -This function always serves as an implicit compiler barrier. -On architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering -and partial store ordering respectively), this operation only serves -as a compiler barrier and no fence instructions will be emitted. To -force the unconditional emission of a load fence, use -.Fn ck_pr_fence_strict_load . -Architectures implementing CK_MD_RMO always emit a load fence. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static unsigned int a; -static unsigned int b; - -void -function(void) -{ - unsigned int snapshot_a, snapshot_b; - - snapshot_a = ck_pr_load_uint(&a); - - /* - * Guarantee that the load from "a" completes - * before the load from "b". - */ - ck_pr_fence_load(); - snapshot_b = ck_pr_load_uint(&b); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load_atomic b/doc/ck_pr_fence_load_atomic deleted file mode 100644 index c935491055e6..000000000000 --- a/doc/ck_pr_fence_load_atomic +++ /dev/null @@ -1,113 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 18, 2013 -.Dt CK_PR_FENCE_LOAD_ATOMIC 3 -.Sh NAME -.Nm ck_pr_fence_load_atomic -.Nd enforce ordering of load operations to atomic read-modify-write operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_load_atomic void -.Ft void -.Fn ck_pr_fence_strict_load_atomic void -.Sh DESCRIPTION -This function enforces the ordering of any memory load -and -.Fn ck_pr_load 3 -operations with respect to store operations relative to -the invocation of the function. Any store operations that -were committed on remote processors -and received by the calling processor before the invocation of -.Fn ck_pr_fence_load_atomic -is also be made visible only after a call to -the ck_pr_fence_load family of functions. -This function always serves as an implicit compiler barrier. -On architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering -and partial store ordering respectively), this operation only serves -as a compiler barrier and no fence instructions will be emitted. To -force the unconditional emission of a load fence, use -.Fn ck_pr_fence_strict_load_atomic . -Architectures implementing CK_MD_RMO always emit a fence. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static unsigned int a; -static unsigned int b; - -void -function(void) -{ - unsigned int snapshot_a, snapshot_b; - - snapshot_a = ck_pr_load_uint(&a); - - /* - * Guarantee that the load from "a" completes - * before the update to "b". - */ - ck_pr_fence_load_atomic(); - ck_pr_fas_uint(&b, 1); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load_depends b/doc/ck_pr_fence_load_depends deleted file mode 100644 index 0c0ecfa4ab90..000000000000 --- a/doc/ck_pr_fence_load_depends +++ /dev/null @@ -1,75 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_fence_load_depends 3 -.Sh NAME -.Nm ck_pr_fence_load_depends -.Nd data dependency barrier -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_load_depends void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_load_depends 3 -emits necessary fences for pure data-dependent loads. It currently only serves as a compiler -barrier for Concurrency Kit's supported platforms. Unless you're on architecture -which re-orders data-dependent loads (such as the defunct Alpha), this function is unnecessary. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_load_store b/doc/ck_pr_fence_load_store deleted file mode 100644 index 4abce996ecbf..000000000000 --- a/doc/ck_pr_fence_load_store +++ /dev/null @@ -1,113 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 18, 2013 -.Dt CK_PR_FENCE_LOAD_STORE 3 -.Sh NAME -.Nm ck_pr_fence_load_store -.Nd enforce ordering of load operations to store operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_load_store void -.Ft void -.Fn ck_pr_fence_strict_load_store void -.Sh DESCRIPTION -This function enforces the ordering of any memory load -and -.Fn ck_pr_load 3 -operations with respect to store operations relative to -the invocation of the function. Any store operations that -were committed on remote processors -and received by the calling processor before the invocation of -.Fn ck_pr_fence_load_store -is also be made visible only after a call to -the ck_pr_fence_load family of functions. -This function always serves as an implicit compiler barrier. -On architectures with CK_MD_TSO or CK_MD_PSO specified (total store ordering -and partial store ordering respectively), this operation only serves -as a compiler barrier and no fence instructions will be emitted. To -force the unconditional emission of a load fence, use -.Fn ck_pr_fence_strict_load_store . -Architectures implementing CK_MD_RMO always emit a fence. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static unsigned int a; -static unsigned int b; - -void -function(void) -{ - unsigned int snapshot_a; - - snapshot_a = ck_pr_load_uint(&a); - - /* - * Guarantee that the load from "a" completes - * before the store to "b". - */ - ck_pr_fence_load_store(); - ck_pr_store_uint(&b, 1); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_memory b/doc/ck_pr_fence_memory deleted file mode 100644 index 0dfc81b84ec5..000000000000 --- a/doc/ck_pr_fence_memory +++ /dev/null @@ -1,113 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_fence_memory 3 -.Sh NAME -.Nm ck_pr_fence_memory -.Nd enforce partial ordering of all memory operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_memory -.Ft void -.Fn ck_pr_fence_strict_memory -.Sh DESCRIPTION -The -.Fn ck_pr_fence_memory 3 -function enforces the ordering of any memory operations -with respect to the invocation of the function. This function -always serves as an implicit compiler barrier. -Achitectures implementing CK_MD_TSO do not emit -a barrier, but compiler barrier semantics remain. -Architectures implementing CK_MD_PSO and CK_MD_RMO always emit -an instructions which provides the specified ordering -guarantees. To force the unconditional emission of a memory -fence, use -.Fn ck_pr_fence_strict_memory . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b; -static int c; -static int d; - -void -function(void) -{ - int snapshot_a; - - ck_pr_store_int(&b, 1); - snapshot_a = ck_pr_load_int(&a); - - /* - * Make sure previous memory operations are - * ordered with respect to memory operations - * following the ck_pr_fence_memory. - */ - ck_pr_fence_memory(); - - ck_pr_store_int(&d, 3); - ck_pr_store_int(&c, 2); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_release b/doc/ck_pr_fence_release deleted file mode 100644 index 214917cc559f..000000000000 --- a/doc/ck_pr_fence_release +++ /dev/null @@ -1,71 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd January 2, 2014 -.Dt CK_PR_FENCE_RELEASE 3 -.Sh NAME -.Nm ck_pr_fence_release -.Nd enforce release semantics -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_release void -.Sh DESCRIPTION -This function enforces the partial ordering of any loads prior -to invocation with respect to any following stores and any stores -prior to invocation with respect to any following stores. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_acquire 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_store b/doc/ck_pr_fence_store deleted file mode 100644 index d94e9f1d6f9f..000000000000 --- a/doc/ck_pr_fence_store +++ /dev/null @@ -1,112 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_fence_store 3 -.Sh NAME -.Nm ck_pr_fence_store -.Nd enforce partial ordering of store operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_store void -.Ft void -.Fn ck_pr_fence_strict_store void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_store -function enforces the ordering of any memory store, -.Fn ck_pr_store -and atomic read-modify-write operations relative to -the invocation of the function. This function -always serve as an implicit compiler barrier. On -architectures implementing CK_MD_TSO, this operation -only serves as a compiler barrier and no fences -are emitted. On architectures implementing -CK_MD_PSO and CK_MD_RMO, a store fence is -emitted. To force the unconditional emission of -a store fence, use -.Fn ck_pr_fence_strict_store . -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; -static int c = 0; - -void -function(void) -{ - - ck_pr_store_int(&a, 1); - - /* - * Guarantee that the store to a is completed - * with respect to the stores of b and c. - */ - ck_pr_fence_store(); - ck_pr_store_int(&b, 2); - ck_pr_store_int(&c, 2); - - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_store_atomic b/doc/ck_pr_fence_store_atomic deleted file mode 100644 index 309c80438ab0..000000000000 --- a/doc/ck_pr_fence_store_atomic +++ /dev/null @@ -1,108 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 18, 2013 -.Dt CK_PR_FENCE_STORE_ATOMIC 3 -.Sh NAME -.Nm ck_pr_fence_store_atomic -.Nd enforce ordering of store operations to load operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_store_atomic void -.Ft void -.Fn ck_pr_fence_strict_store_atomic void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_store_atomic -function enforces the ordering of any memory store, -.Fn ck_pr_store -and atomic read-modify-write operations to atomic read-modify-write -operations relative to the invocation of the function. This function -always serve as an implicit compiler barrier. -This functions will emit a fence for PSO and RMO -targets. In order to force the emission of a fence use the -.Fn ck_pr_fence_strict_store_atomic -function. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; - -void -function(void) -{ - - ck_pr_store_int(&a, 1); - - /* - * Guarantee that the store to a is completed - * with respect to the update of b. - */ - ck_pr_fence_store_atomic(); - ck_pr_add_int(&b, 2); - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_store_load 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_fence_store_load b/doc/ck_pr_fence_store_load deleted file mode 100644 index b595739a57fd..000000000000 --- a/doc/ck_pr_fence_store_load +++ /dev/null @@ -1,107 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 18, 2013 -.Dt CK_PR_FENCE_STORE_LOAD 3 -.Sh NAME -.Nm ck_pr_fence_store_load -.Nd enforce ordering of store operations to load operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_fence_store_load void -.Ft void -.Fn ck_pr_fence_strict_store_load void -.Sh DESCRIPTION -The -.Fn ck_pr_fence_store_load -function enforces the ordering of any memory store, -.Fn ck_pr_store -and atomic read-modify-write operations to load -operations relative to the invocation of the function. This function -always serve as an implicit compiler barrier. -A fence will currently always be emitted for this -operation, including for TSO memory model targets. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int a = 0; -static int b = 0; - -void -function(void) -{ - unsigned int snapshot_b; - - ck_pr_store_int(&a, 1); - - /* - * Guarantee that the store to a is completed - * with respect to load from b. - */ - ck_pr_fence_store_load(); - snapshot_b = ck_pr_load_int(&b, 2); - return; -} -.Ed -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_pr_stall 3 , -.Xr ck_pr_fence_atomic 3 , -.Xr ck_pr_fence_atomic_store 3 , -.Xr ck_pr_fence_atomic_load 3 , -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_atomic 3 , -.Xr ck_pr_fence_load_store 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_store_atomic 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_inc b/doc/ck_pr_inc deleted file mode 100644 index 72a3e7054912..000000000000 --- a/doc/ck_pr_inc +++ /dev/null @@ -1,124 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_inc 3 -.Sh NAME -.Nm ck_pr_inc_ptr , -.Nm ck_pr_inc_ptr_zero , -.Nm ck_pr_inc_double , -.Nm ck_pr_inc_double_zero , -.Nm ck_pr_inc_char , -.Nm ck_pr_inc_char_zero , -.Nm ck_pr_inc_uint , -.Nm ck_pr_inc_uint_zero , -.Nm ck_pr_inc_int , -.Nm ck_pr_inc_int_zero , -.Nm ck_pr_inc_64 , -.Nm ck_pr_inc_64_zero , -.Nm ck_pr_inc_32 , -.Nm ck_pr_inc_32_zero , -.Nm ck_pr_inc_16 , -.Nm ck_pr_inc_16_zero , -.Nm ck_pr_inc_8 , -.Nm ck_pr_inc_8_zero -.Nd atomic increment operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_inc_ptr "void *target" -.Ft void -.Fn ck_pr_inc_ptr_zero "void *target" "bool *z" -.Ft void -.Fn ck_pr_inc_double "double *target" -.Ft void -.Fn ck_pr_inc_double_zero "double *target" "bool *z" -.Ft void -.Fn ck_pr_inc_char "char *target" -.Ft void -.Fn ck_pr_inc_char_zero "char *target" "bool *z" -.Ft void -.Fn ck_pr_inc_uint "unsigned int *target" -.Ft void -.Fn ck_pr_inc_uint_zero "unsigned int *target" "bool *z" -.Ft void -.Fn ck_pr_inc_int "int *target" -.Ft void -.Fn ck_pr_inc_int_zero "int *target" "bool *z" -.Ft void -.Fn ck_pr_inc_64 "uint64_t *target" -.Ft void -.Fn ck_pr_inc_64_zero "uint64_t *target" "bool *z" -.Ft void -.Fn ck_pr_inc_32 "uint32_t *target" -.Ft void -.Fn ck_pr_inc_32_zero "uint32_t *target" "bool *z" -.Ft void -.Fn ck_pr_inc_16 "uint16_t *target" -.Ft void -.Fn ck_pr_inc_16_zero "uint16_t *target" "bool *z" -.Ft void -.Fn ck_pr_inc_8 "uint8_t *target" -.Ft void -.Fn ck_pr_inc_8_zero "uint8_t *target" "bool *z" -.Sh DESCRIPTION -The -.Fn ck_pr_inc 3 -family of functions atomically increment the value pointed to -by -.Fa target . -.Sh RETURN VALUES -The ck_pr_inc_zero family of functions set the value pointed to by -.Fa z -to true if the result of the increment operation was 0. The functions set -the value pointed to by -.Fa z -false otherwise. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_load b/doc/ck_pr_load deleted file mode 100644 index ed615d3523da..000000000000 --- a/doc/ck_pr_load +++ /dev/null @@ -1,96 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 15, 2013 -.Dt ck_pr_load 3 -.Sh NAME -.Nm ck_pr_load_ptr , -.Nm ck_pr_load_double , -.Nm ck_pr_load_uint , -.Nm ck_pr_load_int , -.Nm ck_pr_load_char , -.Nm ck_pr_load_64 , -.Nm ck_pr_load_32 , -.Nm ck_pr_load_16 , -.Nm ck_pr_load_8 -.Nd atomic volatile load operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void * -.Fn ck_pr_load_ptr "const void *target" -.Ft double -.Fn ck_pr_load_double "const double *target" -.Ft unsigned int -.Fn ck_pr_load_uint "const unsigned int *target" -.Ft int -.Fn ck_pr_load_int "const int *target" -.Ft char -.Fn ck_pr_load_char "const char *target" -.Ft uint64_t -.Fn ck_pr_load_64 "const uint64_t *target" -.Ft uint32_t -.Fn ck_pr_load_32 "const uint32_t *target" -.Ft uint16_t -.Fn ck_pr_load_16 "const uint16_t *target" -.Ft uint8_t -.Fn ck_pr_load_8 "const uint8_t *target" -.Sh DESCRIPTION -The -.Fn ck_pr_load 3 -family of functions atomically loads the value -pointed to by -.Fa target -and returns it. This family of functions always -serves as an implicit compiler barrier and is not -susceptible to re-ordering by the compiler. -.Sh RETURN VALUES -This family of functions returns the value contained -in the location pointed to by the first argument. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_neg b/doc/ck_pr_neg deleted file mode 100644 index 38f9a0a10df7..000000000000 --- a/doc/ck_pr_neg +++ /dev/null @@ -1,122 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_neg 3 -.Sh NAME -.Nm ck_pr_neg_ptr , -.Nm ck_pr_neg_ptr_zero , -.Nm ck_pr_neg_double , -.Nm ck_pr_neg_double_zero , -.Nm ck_pr_neg_char , -.Nm ck_pr_neg_char_zero , -.Nm ck_pr_neg_uint , -.Nm ck_pr_neg_uint_zero , -.Nm ck_pr_neg_int , -.Nm ck_pr_neg_int_zero , -.Nm ck_pr_neg_64 , -.Nm ck_pr_neg_64_zero , -.Nm ck_pr_neg_32 , -.Nm ck_pr_neg_32_zero , -.Nm ck_pr_neg_16 , -.Nm ck_pr_neg_16_zero , -.Nm ck_pr_neg_8 , -.Nm ck_pr_neg_8_zero -.Nd atomic negation operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_neg_ptr "void *target" -.Ft void -.Fn ck_pr_neg_ptr_zero "void *target" "bool *z" -.Ft void -.Fn ck_pr_neg_double "double *target" -.Ft void -.Fn ck_pr_neg_double_zero "double *target" "bool *z" -.Ft void -.Fn ck_pr_neg_char "char *target" -.Ft void -.Fn ck_pr_neg_char_zero "char *target" "bool *z" -.Ft void -.Fn ck_pr_neg_uint "unsigned int *target" -.Ft void -.Fn ck_pr_neg_uint_zero "unsigned int *target" "bool *z" -.Ft void -.Fn ck_pr_neg_int "int *target" -.Ft void -.Fn ck_pr_neg_int_zero "int *target" "bool *z" -.Ft void -.Fn ck_pr_neg_64 "uint64_t *target" -.Ft void -.Fn ck_pr_neg_64_zero "uint64_t *target" "bool *z" -.Ft void -.Fn ck_pr_neg_32 "uint32_t *target" -.Ft void -.Fn ck_pr_neg_32_zero "uint32_t *target" "bool *z" -.Ft void -.Fn ck_pr_neg_16 "uint16_t *target" -.Ft void -.Fn ck_pr_neg_16_zero "uint16_t *target" "bool *z" -.Ft void -.Fn ck_pr_neg_8 "uint8_t *target" -.Ft void -.Fn ck_pr_neg_8_zero "uint8_t *target" "bool *z" -.Sh DESCRIPTION -The -.Fn ck_pr_neg 3 -family of functions atomically negate the value pointed to -by -.Fa target . -.Sh RETURN VALUES -The ck_pr_neg_zero functions set the value pointed to by -.Fa z -if the result of the negation operation was 0. They set the -pointed to value to false otherwise. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_not b/doc/ck_pr_not deleted file mode 100644 index b0a38b254277..000000000000 --- a/doc/ck_pr_not +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_not 3 -.Sh NAME -.Nm ck_pr_not_ptr , -.Nm ck_pr_not_double , -.Nm ck_pr_not_char , -.Nm ck_pr_not_uint , -.Nm ck_pr_not_int , -.Nm ck_pr_not_64 , -.Nm ck_pr_not_32 , -.Nm ck_pr_not_16 , -.Nm ck_pr_not_8 -.Nd atomic complement operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_not_ptr "void *target" -.Ft void -.Fn ck_pr_not_double "double *target" -.Ft void -.Fn ck_pr_not_char "char *target" -.Ft void -.Fn ck_pr_not_uint "unsigned int *target" -.Ft void -.Fn ck_pr_not_int "int *target" -.Ft void -.Fn ck_pr_not_64 "uint64_t *target" -.Ft void -.Fn ck_pr_not_32 "uint32_t *target" -.Ft void -.Fn ck_pr_not_16 "uint16_t *target" -.Ft void -.Fn ck_pr_not_8 "uint8_t *target" -.Sh DESCRIPTION -The -.Fn ck_pr_not 3 -family of functions atomically complement the value pointed to -by -.Fa target . -.Sh RETURN VALUES -These functions have no return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_or b/doc/ck_pr_or deleted file mode 100644 index 2a68330a99fe..000000000000 --- a/doc/ck_pr_or +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_or 3 -.Sh NAME -.Nm ck_pr_or_ptr , -.Nm ck_pr_or_char , -.Nm ck_pr_or_uint , -.Nm ck_pr_or_int , -.Nm ck_pr_or_64 , -.Nm ck_pr_or_32 , -.Nm ck_pr_or_16 , -.Nm ck_pr_or_8 -.Nd atomic bitwise-or operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_or_ptr "void *target" "uintptr_t delta" -.Ft void -.Fn ck_pr_or_char "char *target" "char delta" -.Ft void -.Fn ck_pr_or_uint "unsigned int *target" "unsigned int delta" -.Ft void -.Fn ck_pr_or_int "int *target" "int delta" -.Ft void -.Fn ck_pr_or_64 "uint64_t *target" "uint64_t delta" -.Ft void -.Fn ck_pr_or_32 "uint32_t *target" "uint32_t delta" -.Ft void -.Fn ck_pr_or_16 "uint16_t *target" "uint16_t delta" -.Ft void -.Fn ck_pr_or_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_or 3 -family of functions atomically compute and store the -result of a bitwise-or of the value pointed to by -.Fa target -and -.Fa delta -into the value pointed to by -.Fa target . -.Sh RETURN VALUES -This family of functions does not have a return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_rtm b/doc/ck_pr_rtm deleted file mode 100644 index 53c31b60f41e..000000000000 --- a/doc/ck_pr_rtm +++ /dev/null @@ -1,112 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 17, 2013 -.Dt ck_pr_rtm 3 -.Sh NAME -.Nm ck_pr_rtm_begin , -.Nm ck_pr_rtm_end , -.Nm ck_pr_rtm_abort , -.Nm ck_pr_rtm_test -.Nd restricted transactional memory -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft unsigned int -.Fn ck_pr_rtm_begin "void" -.Ft void -.Fn ck_pr_rtm_end "void" -.Ft void -.Fn ck_pr_rtm_abort "const unsigned int status" -.Ft bool -.Fn ck_pr_rtm_test "void" -.Sh DESCRIPTION -These family of functions implement support for restricted -transactional memory, if available on the underlying platform. -Currently, support is only provided for Intel Haswell and -newer x86 microarchitectures that have the TSX-NI feature. -.Pp -The -.Fn ck_pr_rtm_begin -function returns CK_PR_RTM_STARTED if a transaction was successfully -started. In case of an abort, either internal (through a ck_pr_rtm_abort) -or external, program flow will return to the point which the function -was called except the return value will consist of a bitmap with one or -more of the following bits set: -.Bl -tag -width indent -.It CK_PR_RTM_EXPLICIT -Set if the transactionally was explicitly aborted through -.Fn ck_pr_rtm_abort . -.It CK_PR_RTM_RETRY -Set if the transaction failed but can still succeed if -retried. -.It CK_PR_RTM_CONFLICT -The transaction failed due to a conflict in one of the memory -addresses that are part of the working set of the transaction. -.It CK_PR_RTM_CAPACITY -Set if the architecture-defined transaction size limit was exceeded. -.It CK_PR_RTM_DEBUG -Set if a hardware breakpoint was triggered. -.It CK_PR_RTM_NESTED -Set if a nested transaction failed. -.El -.Pp -The user is also able to specify a one byte abort status -by calling -.Fn ck_pr_rtm_abort . -This status byte can be extracted by calling the -.Fn CK_PR_RTM_CODE -function with the return value of -.Fn ck_pr_rtm_begin -as an argument. The return value of -.Fn CK_PR_RTM_CODE -will be the value of this status byte. -For additional information, please see the Intel instruction -set manuals. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_stall b/doc/ck_pr_stall deleted file mode 100644 index bc46647c483b..000000000000 --- a/doc/ck_pr_stall +++ /dev/null @@ -1,86 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 7, 2013 -.Dt ck_pr_stall 3 -.Sh NAME -.Nm ck_pr_stall -.Nd busy-wait primitive -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_stall void -.Sh DESCRIPTION -The -.Fn ck_pr_stall 3 -function should be used inside retry paths of busy-wait loops. -It not only serves as a compiler barrier, but on some architectures -it emits cycle-saving instructions. -.Sh EXAMPLE -.Bd -literal -offset indent - -#include - -static int ready = 0; - -void -function(void) -{ - - /* Busy-wait until ready is non-zero. */ - while (ck_pr_load_int(&ready) == 0) - ck_pr_stall(); - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_barrier 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_store b/doc/ck_pr_store deleted file mode 100644 index 462cf7b7c250..000000000000 --- a/doc/ck_pr_store +++ /dev/null @@ -1,96 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 15, 2013 -.Dt ck_pr_store 3 -.Sh NAME -.Nm ck_pr_store_ptr , -.Nm ck_pr_store_double , -.Nm ck_pr_store_uint , -.Nm ck_pr_store_int , -.Nm ck_pr_store_char , -.Nm ck_pr_store_64 , -.Nm ck_pr_store_32 , -.Nm ck_pr_store_16 , -.Nm ck_pr_store_8 -.Nd atomic volatile store operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_store_ptr "void *target" "void *value" -.Ft void -.Fn ck_pr_store_double "double *target" "double value" -.Ft void -.Fn ck_pr_store_uint "unsigned int *target" "unsigned int value" -.Ft void -.Fn ck_pr_store_int "int *target" "int value" -.Ft void -.Fn ck_pr_store_char "char *target" "char value" -.Ft void -.Fn ck_pr_store_64 "uint64_t *target" "uint64_t value" -.Ft void -.Fn ck_pr_store_32 "uint32_t *target" "uint32_t value" -.Ft void -.Fn ck_pr_store_16 "uint16_t *target" "uint16_t value" -.Ft void -.Fn ck_pr_store_8 "uint8_t *target" "uint8_t value" -.Sh DESCRIPTION -The -.Fn ck_pr_store 3 -family of functions atomically stores the value specified -by -.Fa value -into the location pointed to by -.Fa target . -This family of functions always serves as an implicit compiler -barrier and is not susceptible to compiler re-ordering. -.Sh RETURN VALUES -This family of functions has no return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_sub b/doc/ck_pr_sub deleted file mode 100644 index 5eee17040353..000000000000 --- a/doc/ck_pr_sub +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_sub 3 -.Sh NAME -.Nm ck_pr_sub_ptr , -.Nm ck_pr_sub_double , -.Nm ck_pr_sub_char , -.Nm ck_pr_sub_uint , -.Nm ck_pr_sub_int , -.Nm ck_pr_sub_64 , -.Nm ck_pr_sub_32 , -.Nm ck_pr_sub_16 , -.Nm ck_pr_sub_8 -.Nd atomic subtraction operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_sub_ptr "void *target" "uintptr_t delta" -.Ft void -.Fn ck_pr_sub_double "double *target" "double delta" -.Ft void -.Fn ck_pr_sub_char "char *target" "char delta" -.Ft void -.Fn ck_pr_sub_uint "unsigned int *target" "unsigned int delta" -.Ft void -.Fn ck_pr_sub_int "int *target" "int delta" -.Ft void -.Fn ck_pr_sub_64 "uint64_t *target" "uint64_t delta" -.Ft void -.Fn ck_pr_sub_32 "uint32_t *target" "uint32_t delta" -.Ft void -.Fn ck_pr_sub_16 "uint16_t *target" "uint16_t delta" -.Ft void -.Fn ck_pr_sub_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_sub 3 -family of functions atomically subtract the value specified by -.Fa delta -from the value pointed to by -.Fa target . -.Sh RETURN VALUES -This family of functions does not have a return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_xor 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_pr_xor b/doc/ck_pr_xor deleted file mode 100644 index 509f60dd22ce..000000000000 --- a/doc/ck_pr_xor +++ /dev/null @@ -1,93 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 11, 2013 -.Dt ck_pr_xor 3 -.Sh NAME -.Nm ck_pr_xor_ptr , -.Nm ck_pr_xor_char , -.Nm ck_pr_xor_uint , -.Nm ck_pr_xor_int , -.Nm ck_pr_xor_64 , -.Nm ck_pr_xor_32 , -.Nm ck_pr_xor_16 , -.Nm ck_pr_xor_8 -.Nd atomic bitwise-xor operations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_pr.h -.Ft void -.Fn ck_pr_xor_ptr "void *target" "uintptr_t delta" -.Ft void -.Fn ck_pr_xor_char "char *target" "char delta" -.Ft void -.Fn ck_pr_xor_uint "unsigned int *target" "unsigned int delta" -.Ft void -.Fn ck_pr_xor_int "int *target" "int delta" -.Ft void -.Fn ck_pr_xor_64 "uint64_t *target" "uint64_t delta" -.Ft void -.Fn ck_pr_xor_32 "uint32_t *target" "uint32_t delta" -.Ft void -.Fn ck_pr_xor_16 "uint16_t *target" "uint16_t delta" -.Ft void -.Fn ck_pr_xor_8 "uint8_t *target" "uint8_t delta" -.Sh DESCRIPTION -The -.Fn ck_pr_xor 3 -family of functions atomically compute and store the -result of a bitwise-xor of the value pointed to by -.Fa target -and -.Fa delta -into the value pointed to by -.Fa target . -.Sh RETURN VALUES -This family of functions does not have a return value. -.Sh SEE ALSO -.Xr ck_pr_fence_load 3 , -.Xr ck_pr_fence_load_depends 3 , -.Xr ck_pr_fence_store 3 , -.Xr ck_pr_fence_memory 3 , -.Xr ck_pr_load 3 , -.Xr ck_pr_store 3 , -.Xr ck_pr_fas 3 , -.Xr ck_pr_faa 3 , -.Xr ck_pr_inc 3 , -.Xr ck_pr_dec 3 , -.Xr ck_pr_neg 3 , -.Xr ck_pr_not 3 , -.Xr ck_pr_add 3 , -.Xr ck_pr_sub 3 , -.Xr ck_pr_or 3 , -.Xr ck_pr_and 3 , -.Xr ck_pr_cas 3 , -.Xr ck_pr_btc 3 , -.Xr ck_pr_bts 3 , -.Xr ck_pr_btr 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_queue b/doc/ck_queue deleted file mode 100644 index a27ec15c582a..000000000000 --- a/doc/ck_queue +++ /dev/null @@ -1,147 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 28, 2013. -.Dt ck_queue 3 -.Sh NAME -.Nm CK_LIST_EMPTY , -.Nm CK_LIST_ENTRY , -.Nm CK_LIST_FIRST , -.Nm CK_LIST_FOREACH , -.Nm CK_LIST_FOREACH_SAFE , -.Nm CK_LIST_HEAD , -.Nm CK_LIST_HEAD_INITIALIZER , -.Nm CK_LIST_INIT , -.Nm CK_LIST_INSERT_AFTER , -.Nm CK_LIST_INSERT_BEFORE , -.Nm CK_LIST_INSERT_HEAD , -.Nm CK_LIST_MOVE , -.Nm CK_LIST_NEXT , -.Nm CK_LIST_REMOVE , -.Nm CK_LIST_SWAP , -.Nm CK_SLIST_EMPTY , -.Nm CK_SLIST_ENTRY , -.Nm CK_SLIST_FIRST , -.Nm CK_SLIST_FOREACH , -.Nm CK_SLIST_FOREACH_PREVPTR , -.Nm CK_SLIST_FOREACH_SAFE , -.Nm CK_SLIST_HEAD , -.Nm CK_SLIST_HEAD_INITIALIZER , -.Nm CK_SLIST_INIT , -.Nm CK_SLIST_INSERT_AFTER , -.Nm CK_SLIST_INSERT_HEAD , -.Nm CK_SLIST_MOVE , -.Nm CK_SLIST_NEXT , -.Nm CK_SLIST_REMOVE , -.Nm CK_SLIST_REMOVE_AFTER , -.Nm CK_SLIST_REMOVE_HEAD , -.Nm CK_SLIST_SWAP , -.Nm CK_STAILQ_CONCAT , -.Nm CK_STAILQ_EMPTY , -.Nm CK_STAILQ_ENTRY , -.Nm CK_STAILQ_FIRST , -.Nm CK_STAILQ_FOREACH , -.Nm CK_STAILQ_FOREACH_SAFE , -.Nm CK_STAILQ_HEAD , -.Nm CK_STAILQ_HEAD_INITIALIZER , -.Nm CK_STAILQ_INIT , -.Nm CK_STAILQ_INSERT_AFTER , -.Nm CK_STAILQ_INSERT_HEAD , -.Nm CK_STAILQ_INSERT_TAIL , -.Nm CK_STAILQ_MOVE , -.Nm CK_STAILQ_NEXT , -.Nm CK_STAILQ_REMOVE , -.Nm CK_STAILQ_REMOVE_AFTER , -.Nm CK_STAILQ_REMOVE_HEAD , -.Nm CK_STAILQ_SWAP -.Nd multi-reader single-writer singly-linked lists, singly-linked tail queues and lists -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_queue.h -.Fn CK_LIST_EMPTY -.Fn CK_LIST_ENTRY -.Fn CK_LIST_FIRST -.Fn CK_LIST_FOREACH -.Fn CK_LIST_FOREACH_SAFE -.Fn CK_LIST_HEAD -.Fn CK_LIST_HEAD_INITIALIZER -.Fn CK_LIST_INIT -.Fn CK_LIST_INSERT_AFTER -.Fn CK_LIST_INSERT_BEFORE -.Fn CK_LIST_INSERT_HEAD -.Fn CK_LIST_MOVE -.Fn CK_LIST_NEXT -.Fn CK_LIST_REMOVE -.Fn CK_LIST_SWAP -.Fn CK_SLIST_EMPTY -.Fn CK_SLIST_ENTRY -.Fn CK_SLIST_FIRST -.Fn CK_SLIST_FOREACH -.Fn CK_SLIST_FOREACH_PREVPTR -.Fn CK_SLIST_FOREACH_SAFE -.Fn CK_SLIST_HEAD -.Fn CK_SLIST_HEAD_INITIALIZER -.Fn CK_SLIST_INIT -.Fn CK_SLIST_INSERT_AFTER -.Fn CK_SLIST_INSERT_HEAD -.Fn CK_SLIST_MOVE -.Fn CK_SLIST_NEXT -.Fn CK_SLIST_REMOVE -.Fn CK_SLIST_REMOVE_AFTER -.Fn CK_SLIST_REMOVE_HEAD -.Fn CK_SLIST_SWAP -.Fn CK_STAILQ_CONCAT -.Fn CK_STAILQ_EMPTY -.Fn CK_STAILQ_ENTRY -.Fn CK_STAILQ_FIRST -.Fn CK_STAILQ_FOREACH -.Fn CK_STAILQ_FOREACH_SAFE -.Fn CK_STAILQ_HEAD -.Fn CK_STAILQ_HEAD_INITIALIZER -.Fn CK_STAILQ_INIT -.Fn CK_STAILQ_INSERT_AFTER -.Fn CK_STAILQ_INSERT_HEAD -.Fn CK_STAILQ_INSERT_TAIL -.Fn CK_STAILQ_MOVE -.Fn CK_STAILQ_NEXT -.Fn CK_STAILQ_REMOVE -.Fn CK_STAILQ_REMOVE_AFTER -.Fn CK_STAILQ_REMOVE_HEAD -.Fn CK_STAILQ_SWAP -.Sh DESCRIPTION -See your system's manual page for -.Xr queue -for additional information. ck_queue is a queue.h-compatible -implementation of many-reader-single-writer queues. It allows -for safe concurrent iteration, peeking and read-side access -in the presence of a single concurrent writer without any -usage of locks. In many cases, adoption of ck_queue will -simply require prefixing all queue operations with CK_. -.Sh SEE ALSO -.Xr queue -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_apply b/doc/ck_rhs_apply deleted file mode 100644 index 80b1da7bd696..000000000000 --- a/doc/ck_rhs_apply +++ /dev/null @@ -1,86 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" Copyright 2014 Backtrace I/O, Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 1, 2014 -.Dt CK_RHS_APPLY 3 -.Sh NAME -.Nm ck_rhs_apply -.Nd apply a function to hash set value -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft void * -.Fn ck_rhs_apply_fn_t "void *key" "void *closure" -.Ft bool -.Fn ck_rhs_apply "ck_rhs_t *hs" "unsigned long hash" "const void *key" "ck_rhs_apply_fn_t *function" "void *argument" -.Sh DESCRIPTION -The -.Fn ck_rhs_apply 3 -function will lookup the hash set slot associated with -.Fa key -and pass it to function pointed to by -.Fa function -for further action. This callback may remove or replace -the value by respectively returning NULL or a pointer to -another object with an identical key. The first argument -passed to -.Fa function -is a pointer to the object found in the hash set and -the second argument is the -.Fa argument -pointer passed to -.Fn ck_rhs_apply 3 . -If the pointer returned by -.Fa function -is equivalent to the first argument then no modification -is made to the hash set. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_apply 3 -returns true and otherwise returns false on failure. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr ck_rhs_fas 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_count b/doc/ck_rhs_count deleted file mode 100644 index 3a42b1200bcf..000000000000 --- a/doc/ck_rhs_count +++ /dev/null @@ -1,70 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_COUNT 3 -.Sh NAME -.Nm ck_rhs_count -.Nd returns number of entries in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft unsigned long -.Fn ck_rhs_count "ck_rhs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_rhs_count 3 -function returns the number of keys currently -stored in -.Fa hs . -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_destroy b/doc/ck_rhs_destroy deleted file mode 100644 index 68de27e2417e..000000000000 --- a/doc/ck_rhs_destroy +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_DESTROY 3 -.Sh NAME -.Nm ck_rhs_destroy -.Nd destroy hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft void -.Fn ck_rhs_destroy "ck_rhs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_rhs_destroy 3 -function will request that the underlying allocator, as specified by the -.Xr ck_rhs_init 3 -function, immediately destroy the object pointed to by the -.Fa hs -argument. -The user must guarantee that no threads are accessing the object pointed to -by -.Fa hs -when -.Fn ck_rhs_destroy 3 -is called. -.Sh RETURN VALUES -.Fn ck_rhs_destroy 3 -has no return value. -.Sh ERRORS -This function is guaranteed not to fail. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_fas b/doc/ck_rhs_fas deleted file mode 100644 index 453c40ba283f..000000000000 --- a/doc/ck_rhs_fas +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd June 20, 2013 -.Dt CK_RHS_FAS 3 -.Sh NAME -.Nm ck_rhs_fas -.Nd fetch and store key in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_fas "ck_rhs_t *hs" "unsigned long hash" "const void *key" "void **previous" -.Sh DESCRIPTION -The -.Fn ck_rhs_fas 3 -function will fetch and store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_rhs_fas 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The key must already exist in the hash set, and is -replaced by -.Fa key -and the previous value is stored into the void pointer -pointed to by the -.Fa previous -argument. If the key does not exist in the hash set -then the function will return false and the hash set -is unchanged. This function -is guaranteed to be stable with respect to memory usage. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_fas 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_gc b/doc/ck_rhs_gc deleted file mode 100644 index 0ad532463f07..000000000000 --- a/doc/ck_rhs_gc +++ /dev/null @@ -1,73 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 17, 2013 -.Dt CK_RHS_GC 3 -.Sh NAME -.Nm ck_rhs_gc -.Nd perform maintenance on a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_gc "ck_rhs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_rhs_gc 3 -function will perform various maintenance routines on the hash set -pointed to by -.Fa hs , -including recalculating the maximum number of probes. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_gc 3 -returns true and otherwise returns false on failure due to memory allocation -failure. -.Sh ERRORS -This function will only return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_get b/doc/ck_rhs_get deleted file mode 100644 index 51c6e2f439ac..000000000000 --- a/doc/ck_rhs_get +++ /dev/null @@ -1,88 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_GET 3 -.Sh NAME -.Nm ck_rhs_get -.Nd load a key from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft void * -.Fn ck_rhs_get "ck_rhs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_rhs_get 3 -function will return a pointer to a key in the hash set -.Fa hs -that is of equivalent value to the object pointed to by -.Fa key . -The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which is to have been previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Sh RETURN VALUES -If the provided key is a member of -.Fa hs -then a pointer to the key as stored in -.Fa hs -is returned. If the key was not found in -.Fa hs -then a value of -.Dv NULL -is returned. -.Sh ERRORS -Behavior is undefined if -.Fa entry -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_grow b/doc/ck_rhs_grow deleted file mode 100644 index f1cac2649543..000000000000 --- a/doc/ck_rhs_grow +++ /dev/null @@ -1,81 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_GROW 3 -.Sh NAME -.Nm ck_rhs_grow -.Nd enlarge hash set capacity -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_grow "ck_rhs_t *hs" "unsigned long capacity" -.Sh DESCRIPTION -The -.Fn ck_rhs_grow 3 -function will resize the hash set in order to be -able to store at least the number of entries specified by -.Fa capacity -at a load factor of one. The default hash set load factor -is 0.5. If you wish to minimize the likelihood of memory allocations -for a hash set meant to store n entries, then specify a -.Fa capacity -of 2n. The default behavior of ck_rhs is to round -.Fa capacity -to the next power of two if it is not already a power of two. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_grow 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. This function will only -return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_init b/doc/ck_rhs_init deleted file mode 100644 index 17c5097be21c..000000000000 --- a/doc/ck_rhs_init +++ /dev/null @@ -1,166 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_INIT 3 -.Sh NAME -.Nm ck_rhs_init -.Nd initialize a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft typedef unsigned long -.Fn ck_rhs_hash_cb_t "const void *key" "unsigned long seed" -.Ft typedef bool -.Fn ck_rhs_compare_cb_t "const void *c1" "const void *c2" -.Ft bool -.Fn ck_rhs_init "ck_rhs_t *hs" "unsigned int mode" "ck_rhs_hash_cb_t *hash_function" "ck_rhs_compare_cb_t *compare" "struct ck_malloc *allocator" "unsigned long capacity" "unsigned long seed" -.Sh DESCRIPTION -The -.Fn ck_rhs_init -function initializes the hash set pointed to by the -.Fa hs -pointer. -.Pp -The argument -.Fa mode -specifies the type of key-value pairs to be stored in the -hash set as well as the expected concurrent access model. -The value of -.Fa mode -consists of a bitfield of one of the following: -.Bl -tag -width indent -.It CK_RHS_MODE_OBJECT -The hash set is meant to store pointers to objects. This provides -a hint that only CK_MD_VMA_BITS are necessary to encode the key -argument. Any unused pointer bits are leveraged for internal -optimizations. -.It CK_RHS_MODE_DIRECT -The hash set is meant to directly store key values and that all -bits of the key are used to encode values. -.It CK_RHS_MODE_READ_MOSTLY -Optimize read operations over put/delete. -.El -.Pp -The concurrent access model is specified by: -.Bl -tag -width indent -.It CK_RHS_MODE_SPMC -The hash set should allow for concurrent readers in the -presence of a single writer. -.It CK_RHS_MODE_MPMC -The hash set should allow for concurrent readers in the -presence of concurrent writers. This is currently unsupported. -.El -.Pp -The developer is free to specify additional workload hints. -These hints are one of: -.Bl -tag -width indent -.El -.Pp -The argument -.Fa hash_function -is a mandatory pointer to a user-specified hash function. -A user-specified hash function takes two arguments. The -.Fa key -argument is a pointer to a key. The -.Fa seed -argument is the initial seed associated with the hash set. -This initial seed is specified by the user in -.Xr ck_rhs_init 3 . -.Pp -The -.Fa compare -argument is an optional pointer to a user-specified -key comparison function. If NULL is specified in this -argument, then pointer equality will be used to determine -key equality. A user-specified comparison function takes -two arguments representing pointers to the objects being -compared for equality. It is expected to return true -if the keys are of equal value and false otherwise. -.Pp -The -.Fa allocator -argument is a pointer to a structure containing -.Fa malloc -and -.Fa free -function pointers which respectively define the memory allocation and -destruction functions to be used by the hash set being initialized. -.Pp -The argument -.Fa capacity -represents the initial number of keys the hash -set is expected to contain. This argument is simply a hint -and the underlying implementation is free to allocate more -or less memory than necessary to contain the number of entries -.Fa capacity -specifies. -.Pp -The argument -.Fa seed -specifies the initial seed used by the underlying hash function. -The user is free to choose a value of their choice. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_rhs_init -returns a value of -.Dv true -and otherwise returns a value of -.Dv false -to indicate an error. -.Sh ERRORS -.Bl -tag -width Er -.Pp -The behavior of -.Fn ck_rhs_init -is undefined if -.Fa hs -is not a pointer to a -.Tn ck_rhs_t -object. -.El -.Sh SEE ALSO -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_iterator_init b/doc/ck_rhs_iterator_init deleted file mode 100644 index 4cfd0839eb47..000000000000 --- a/doc/ck_rhs_iterator_init +++ /dev/null @@ -1,78 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_ITERATOR_INIT 3 -.Sh NAME -.Nm ck_rhs_iterator_init -.Nd initialize hash set iterator -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Pp -.Dv ck_rhs_iterator_t iterator = CK_RHS_ITERATOR_INITIALIZER -.Pp -.Ft void -.Fn ck_rhs_iterator_init "ck_rhs_iterator_t *iterator" -.Sh DESCRIPTION -The -.Fn ck_rhs_iterator_init 3 -function will initialize the object pointed to -by the -.Fa iterator -argument. Alternatively, an iterator may be statically -initialized by assigning it to the CK_RHS_ITERATOR_INITIALIZER value. -.Pp -An iterator is used to iterate through hash set entries with the -.Xr ck_rhs_next 3 -function. -.Sh RETURN VALUES -.Fn ck_rhs_iterator_init 3 -has no return value. -.Sh ERRORS -This function will not fail. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_move b/doc/ck_rhs_move deleted file mode 100644 index 45e38e76843a..000000000000 --- a/doc/ck_rhs_move +++ /dev/null @@ -1,90 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 18, 2013 -.Dt CK_RHS_MOVE 3 -.Sh NAME -.Nm ck_rhs_move -.Nd move one from hash set to another -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_move "ck_rhs_t *destination" "ck_rhs_t *source" "ck_rhs_hash_cb_t *hash_cb" "ck_rhs_compare_cb_t *compare_cb" "struct ck_malloc *m" -.Sh DESCRIPTION -The -.Fn ck_rhs_move 3 -function will initialize -.Fa source -from -.Fa destination . -The hash function is set to -.Fa hash_cb , -comparison function to -.Fa compare_cb -and the allocator callbacks to -.Fa m . -Further modifications to -.Fa source -will result in undefined behavior. Concurrent -.Xr ck_rhs_get 3 -and -.Xr ck_rhs_fas 3 -operations to -.Fa source -are legal until the next write operation to -.Fa destination . -.Pp -This operation moves ownership from one hash set object -to another and re-assigns callback functions to developer-specified -values. This allows for dynamic configuration of allocation -callbacks and is necessary for use-cases involving executable code -which may be unmapped underneath the hash set. -.Sh RETURN VALUES -Upon successful completion -.Fn ck_rhs_move 3 -returns true and otherwise returns false to indicate an error. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_next b/doc/ck_rhs_next deleted file mode 100644 index c90a7d6454cf..000000000000 --- a/doc/ck_rhs_next +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_NEXT 3 -.Sh NAME -.Nm ck_rhs_next -.Nd iterate to next entry in hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_next "ck_rhs_t *hs" "ck_rhs_iterator_t *iterator" "void **entry" -.Sh DESCRIPTION -The -.Fn ck_rhs_next 3 -function will increment the iterator object pointed to by -.Fa iterator -to point to the next non-empty hash set entry. If -.Fn ck_rhs_next 3 -returns true then the pointer pointed to by -.Fa entry -is initialized to the current hash set key pointed to by the -.Fa iterator -object. -.Pp -It is expected that -.Fa iterator -has been initialized using the -.Xr ck_rhs_iterator_init 3 -function or statically initialized using CK_RHS_ITERATOR_INITIALIZER. -.Sh RETURN VALUES -If -.Fn ck_rhs_next 3 -returns true then the object pointed to by -.Fa entry -points to a valid hash set key. If -.Fn ck_rhs_next 3 -returns false then the value of the object pointed to by -.Fa entry -is undefined. -.Sh ERRORS -Behavior is undefined if -.Fa iterator -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_put b/doc/ck_rhs_put deleted file mode 100644 index 8df9b65188f0..000000000000 --- a/doc/ck_rhs_put +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_PUT 3 -.Sh NAME -.Nm ck_rhs_put -.Nd store unique key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_put "ck_rhs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_rhs_put 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_rhs_put 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The function will fail if a key with an -equivalent value to -.Fa key -is already present in the hash set. For replacement -semantics, please see the -.Xr ck_rhs_set 3 -function. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_put 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_put_unique b/doc/ck_rhs_put_unique deleted file mode 100644 index 4f941abd6ee4..000000000000 --- a/doc/ck_rhs_put_unique +++ /dev/null @@ -1,98 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 7, 2013 -.Dt CK_RHS_PUT_UNIQUE 3 -.Sh NAME -.Nm ck_rhs_put_unique -.Nd unconditionally store unique key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_put_unique "ck_rhs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_rhs_put_unique 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_rhs_put 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -The function will cause undefined behavior if a key with an -equivalent value is already present in the hash set. For replacement -semantics, please see the -.Xr ck_rhs_set 3 -function. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_put_unique 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. The function will -result in undefined behavior if called for an -already inserted key value. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_rebuild b/doc/ck_rhs_rebuild deleted file mode 100644 index 8ab9b50e1013..000000000000 --- a/doc/ck_rhs_rebuild +++ /dev/null @@ -1,76 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd December 7, 2013 -.Dt CK_RHS_REBUILD 3 -.Sh NAME -.Nm ck_rhs_rebuild -.Nd rebuild a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_rebuild "ck_rhs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_rhs_rebuild 3 -function will regenerate the hash set pointed to by -.Fa hs . -This has the side-effect of pruning degradatory side-effects -of workloads that are delete heavy. The regenerated hash -set should have shorter probe sequences on average. This -operation will require a significant amount of memory -and is free to allocate a duplicate hash set in the -rebuild process. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_rebuild 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -This function will only return false if there are internal memory allocation -failures. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_remove b/doc/ck_rhs_remove deleted file mode 100644 index c83bf3861b15..000000000000 --- a/doc/ck_rhs_remove +++ /dev/null @@ -1,92 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_REMOVE 3 -.Sh NAME -.Nm ck_rhs_remove -.Nd remove key from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft void * -.Fn ck_rhs_remove "ck_rhs_t *hs" "unsigned long hash" "const void *key" -.Sh DESCRIPTION -The -.Fn ck_rhs_remove 3 -function will attempt to remove the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_rhs_remove 3 -was successful then the key contained in the hash -set is returned. If the key was not a member of the hash -set then -.Dv NULL -is returned. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_remove 3 -returns a pointer to a key and otherwise returns -.Dv NULL -on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_reset b/doc/ck_rhs_reset deleted file mode 100644 index a750d85ff77f..000000000000 --- a/doc/ck_rhs_reset +++ /dev/null @@ -1,77 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_RESET 3 -.Sh NAME -.Nm ck_rhs_reset -.Nd remove all keys from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_reset "ck_rhs_t *hs" -.Sh DESCRIPTION -The -.Fn ck_rhs_reset 3 -function will remove all keys stored in the hash -set pointed to by the -.Fa hs -argument. -.Sh RETURN VALUES -If successful, -.Fn ck_rhs_reset 3 -will return true and will otherwise return false on failure. This -function will only fail if a replacement hash set could not be -allocated internally. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_reset_size b/doc/ck_rhs_reset_size deleted file mode 100644 index 6e9913e82105..000000000000 --- a/doc/ck_rhs_reset_size +++ /dev/null @@ -1,80 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 5, 2013 -.Dt CK_RHS_RESET_SIZE 3 -.Sh NAME -.Nm ck_rhs_reset_size -.Nd remove all keys from a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_reset_size "ck_rhs_t *hs" "unsigned long size" -.Sh DESCRIPTION -The -.Fn ck_rhs_reset_size 3 -function will remove all keys stored in the hash -set pointed to by the -.Fa hs -argument and create a new generation of the hash set that -is preallocated for -.Fa size -entries. -.Sh RETURN VALUES -If successful, -.Fn ck_rhs_reset_size 3 -will return true and will otherwise return false on failure. This -function will only fail if a replacement hash set could not be -allocated internally. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_set b/doc/ck_rhs_set deleted file mode 100644 index 6f3e28051029..000000000000 --- a/doc/ck_rhs_set +++ /dev/null @@ -1,102 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_SET 3 -.Sh NAME -.Nm ck_rhs_set -.Nd store key into a hash set -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_set "ck_rhs_t *hs" "unsigned long hash" "const void *key" "void **previous" -.Sh DESCRIPTION -The -.Fn ck_rhs_set 3 -function will store the key specified by the -.Fa key -argument in the hash set pointed to by the -.Fa hs -argument. The key specified by -.Fa key -is expected to have the hash value specified by the -.Fa hash -argument (which was previously generated using the -.Xr CK_RHS_HASH 3 -macro). -.Pp -If the call to -.Fn ck_rhs_set 3 -was successful then the key specified by -.Fa key -was successfully stored in the hash set pointed to by -.Fa hs . -If the key already exists in the hash set, then it is -replaced by -.Fa key -and the previous value is stored into the void pointer -pointed to by the -.Fa previous -argument. If previous is set to -.Dv NULL -then -.Fa key -was not a replacement for an existing entry in the hash set. -.Sh RETURN VALUES -Upon successful completion, -.Fn ck_rhs_set 3 -returns true and otherwise returns false on failure. -.Sh ERRORS -Behavior is undefined if -.Fa key -or -.Fa hs -are uninitialized. The function will also -return false if the hash set could not be enlarged -to accomodate key insertion. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 , -.Xr ck_rhs_stat 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_set_load_factor b/doc/ck_rhs_set_load_factor deleted file mode 100644 index 4ecb847e831e..000000000000 --- a/doc/ck_rhs_set_load_factor +++ /dev/null @@ -1,72 +0,0 @@ -.\" -.\" Copyright 2015 Olivier Houchard. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd May 16, 2015 -.Dt CK_RHS_SET_LOAD_FACTOR 3 -.Sh NAME -.Nm ck_rhs_set_load_factor -.Nd change the hash set load factor -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft bool -.Fn ck_rhs_set_load_factor "ck_rhs_t *hs" "unsigned int load_factor" -.Sh DESCRIPTION -The -.Fn ck_rhs_set_load_factor 3 -function will change the load factor of the hash set. The hash set will grow if it is load_factor% filled. -.Ed -.Sh RETURN VALUES -.Fn ck_rhs_set_load_factor 3 -returns true on success, or false if either the load factor is invalid (0 or > 100), or if growing was required, but failed. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rhs_stat b/doc/ck_rhs_stat deleted file mode 100644 index df45672b9183..000000000000 --- a/doc/ck_rhs_stat +++ /dev/null @@ -1,80 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd September 17, 2012 -.Dt CK_RHS_STAT 3 -.Sh NAME -.Nm ck_rhs_stat -.Nd get hash set status -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rhs.h -.Ft void -.Fn ck_rhs_stat "ck_rhs_t *hs" "struct ck_rhs_stat *st" -.Sh DESCRIPTION -The -.Fn ck_rhs_stat 3 -function will store various hash set statistics in -the object pointed to by -.Fa st . -The ck_rhs_stat structure is defined as follows: -.Bd -literal -offset indent -struct ck_rhs_stat { - unsigned long n_entries; /* Current number of keys in hash set. */ - unsigned int probe_maximum; /* Longest read-side probe sequence. */ -}; -.Ed -.Sh RETURN VALUES -.Fn ck_rhs_stat 3 -has no return value. -.Sh ERRORS -Behavior is undefined if -.Fa hs -is uninitialized. Behavior is -undefined if this function is called by a non-writer -thread. -.Sh SEE ALSO -.Xr ck_rhs_init 3 , -.Xr ck_rhs_move 3 , -.Xr ck_rhs_destroy 3 , -.Xr CK_RHS_HASH 3 , -.Xr ck_rhs_iterator_init 3 , -.Xr ck_rhs_next 3 , -.Xr ck_rhs_get 3 , -.Xr ck_rhs_put 3 , -.Xr ck_rhs_put_unique 3 , -.Xr ck_rhs_set 3 , -.Xr ck_rhs_fas 3 , -.Xr ck_rhs_remove 3 , -.Xr ck_rhs_grow 3 , -.Xr ck_rhs_gc 3 , -.Xr ck_rhs_rebuild 3 , -.Xr ck_rhs_count 3 , -.Xr ck_rhs_reset 3 , -.Xr ck_rhs_reset_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_capacity b/doc/ck_ring_capacity deleted file mode 100644 index 645b54baea69..000000000000 --- a/doc/ck_ring_capacity +++ /dev/null @@ -1,58 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_CAPACITY 3 -.Sh NAME -.Nm ck_ring_capacity -.Nd returns number of pointer slots in bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft unsigned int -.Fn ck_ring_capacity "ck_ring_t *ring" -.Sh DESCRIPTION -The -.Fn ck_ring_capacity 3 -function returns the number of pointers that can be -held in the buffer pointed to by -.Fa ring . -Note that a ring can only hold -.Fn ck_ring_capacity 3 -minus one entries at a time. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_dequeue_spmc b/doc/ck_ring_dequeue_spmc deleted file mode 100644 index 7fd7d9b64c15..000000000000 --- a/doc/ck_ring_dequeue_spmc +++ /dev/null @@ -1,117 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_DEQUEUE_SPMC 3 -.Sh NAME -.Nm ck_ring_dequeue_spmc -.Nd dequeue pointer from bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_dequeue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result" -.Sh DESCRIPTION -The -.Fn ck_ring_dequeue_spmc 3 -function dequeues a pointer from the bounded buffer -pointed to by -.Fa ring -in FIFO fashion. The pointer is stored in the pointer -pointed to by -.Fa result . -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring . -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa result . -This function is safe to call without locking for UINT_MAX -concurrent invocations of -.Fn ck_ring_dequeue_spmc 3 -or -.Fn ck_ring_trydequeue_spmc 3 -and up to one concurrent -.Fn ck_ring_enqueue_spmc 3 -or -.Fn ck_ring_tryenqueue_spmc 3 -invocation. This function provides lock-free progress -guarantees. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -dequeue(void) -{ - void *result; - - /* Dequeue from ring until it is empty. */ - while (ck_ring_dequeue_spmc(&ring, &buffer, &result) == true) { - /* - * Results contains the oldest pointer in ring - * since the dequeue operation returned true. - */ - operation(result); - } - - /* An empty ring was encountered, leave. */ - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the buffer was non-empty. -The result of the dequeue operation is stored in the -value pointed to by -.Fa result . -The function will return false if the buffer was empty -and the value in -.Fa result -will be undefined. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_dequeue_spsc b/doc/ck_ring_dequeue_spsc deleted file mode 100644 index 069dc7f6412e..000000000000 --- a/doc/ck_ring_dequeue_spsc +++ /dev/null @@ -1,115 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_DEQUEUE_SPSC 3 -.Sh NAME -.Nm ck_ring_dequeue_spsc -.Nd dequeue pointer from bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_dequeue_spsc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result" -.Sh DESCRIPTION -The -.Fn ck_ring_dequeue_spsc 3 -function dequeues a pointer from the bounded buffer -pointed to by -.Fa ring -in FIFO fashion. The pointer is stored in the pointer -pointed to by -.Fa result . -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa result . -This function is safe to call without locking for one -concurrent invocation of -.Fn ck_ring_dequeue_spsc 3 -and up to one concurrent -.Fn ck_ring_enqueue_spsc 3 -invocation. This function provides wait-free progress -guarantees. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -dequeue(void) -{ - void *result; - - /* Dequeue from ring until it is empty. */ - while (ck_ring_dequeue_spsc(&ring, &buffer, &result) == true) { - /* - * Results contains the oldest pointer in ring - * since the dequeue operation returned true. - */ - operation(result); - } - - /* An empty ring was encountered, leave. */ - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the buffer was non-empty. -The result of the dequeue operation is stored in the -value pointed to by -.Fa result . -The function will return false if the buffer was empty -and the value in -.Fa result -will be undefined. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spmc b/doc/ck_ring_enqueue_spmc deleted file mode 100644 index ba99199a08a4..000000000000 --- a/doc/ck_ring_enqueue_spmc +++ /dev/null @@ -1,115 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_ENQUEUE_SPMC 3 -.Sh NAME -.Nm ck_ring_enqueue_spmc -.Nd enqueue pointer into bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_enqueue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" -.Sh DESCRIPTION -The -.Fn ck_ring_enqueue_spmc 3 -function enqueues the pointer -.Fa entry -into the bounded buffer pointed to by -.Fa ring -in FIFO fashion. -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa entry . -This function is safe to call without locking for UINT_MAX -concurrent invocations of -.Fn ck_ring_dequeue_spmc 3 -or -.Fn ck_ring_trydequeue_spmc 3 . -This function provides wait-free progress -guarantees for one active invocation. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -enqueue(void) -{ - void *entry = some_object; - - /* Attempt to enqueue pointer to some_object into buffer. */ - if (ck_ring_enqueue_spmc(&ring, &buffer, &entry) == false) { - /* - * The buffer was full and the enqueue operation - * has failed. - */ - return; - } - - /* Enqueue operation completed successfully. */ - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the value of -.Fa entry -was successfully enqueued into -.Fa ring . -The function will return false if the value of -.Fa entry -could not be enqueued which only occurs if -.Fa ring -was full. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spmc_size b/doc/ck_ring_enqueue_spmc_size deleted file mode 100644 index eb30cab99ad4..000000000000 --- a/doc/ck_ring_enqueue_spmc_size +++ /dev/null @@ -1,127 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_ENQUEUE_SPMC_SIZE 3 -.Sh NAME -.Nm ck_ring_enqueue_spmc_size -.Nd enqueue pointer into bounded FIFO and return size of buffer -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_enqueue_spmc_size "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" "unsigned int *length" -.Sh DESCRIPTION -The -.Fn ck_ring_enqueue_spmc 3 -function enqueues the pointer -.Fa entry -into the bounded buffer pointed to by -.Fa ring -in FIFO fashion. -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa entry . -This function is safe to call without locking for UINT_MAX -concurrent invocations of -.Fn ck_ring_dequeue_spmc 3 -or -.Fn ck_ring_trydequeue_spmc 3 . -This function provides wait-free progress -guarantees for one active invocation. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -enqueue(void) -{ - void *entry = some_object; - unsigned int length; - - /* Attempt to enqueue pointer to some_object into buffer. */ - if (ck_ring_enqueue_spmc_size(&ring, &buffer, &entry, &length) == false) { - /* - * The buffer was full and the enqueue operation - * has failed. - */ - return; - } - - /* - * If entry was the 101st or greater pointer in the buffer, - * do something. - */ - if (length > 100) { - do_something; - } - - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the value of -.Fa entry -was successfully enqueued into -.Fa ring . -The function will return false if the value of -.Fa entry -could not be enqueued which only occurs if -.Fa ring -was full. The number of entries in the buffer -with respect to the point in time that -.Fa entry -is enqueued is stored in the integer pointed to by -.Fa length . -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spsc b/doc/ck_ring_enqueue_spsc deleted file mode 100644 index 2493059fb9a5..000000000000 --- a/doc/ck_ring_enqueue_spsc +++ /dev/null @@ -1,113 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_ENQUEUE_SPSC 3 -.Sh NAME -.Nm ck_ring_enqueue_spsc -.Nd enqueue pointer into bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_enqueue_spsc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" -.Sh DESCRIPTION -The -.Fn ck_ring_enqueue_spsc 3 -function enqueues the pointer -.Fa entry -into the bounded buffer pointed to by -.Fa ring -in FIFO fashion. -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa entry . -This function is safe to call without locking for up to -one concurrent invocation of -.Fn ck_ring_dequeue_spsc 3 . -This function provides wait-free progress -guarantees. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -enqueue(void) -{ - void *entry = some_object; - - /* Attempt to enqueue pointer to some_object into buffer. */ - if (ck_ring_enqueue_spsc(&ring, &buffer, &entry) == false) { - /* - * The buffer was full and the enqueue operation - * has failed. - */ - return; - } - - /* Enqueue operation completed successfully. */ - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the value of -.Fa entry -was successfully enqueued into -.Fa ring . -The function will return false if the value of -.Fa entry -could not be enqueued which only occurs if -.Fa ring -was full. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_enqueue_spsc_size b/doc/ck_ring_enqueue_spsc_size deleted file mode 100644 index 7048ea181f7f..000000000000 --- a/doc/ck_ring_enqueue_spsc_size +++ /dev/null @@ -1,128 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_ENQUEUE_SPSC_SIZE 3 -.Sh NAME -.Nm ck_ring_enqueue_spsc_size -.Nd enqueue pointer into bounded FIFO and return size of buffer -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_enqueue_spsc_size "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *entry" "unsigned int *size" -.Sh DESCRIPTION -The -.Fn ck_ring_enqueue_spsc_size 3 -function enqueues the pointer -.Fa entry -into the bounded buffer pointed to by -.Fa ring -in FIFO fashion. -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa entry . -This function is safe to call without locking for up to -one concurrent invocation of -.Fn ck_ring_dequeue_spsc 3 . -This function provides wait-free progress -guarantees. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -enqueue(void) -{ - void *entry = some_object; - unsigned int length; - - /* Attempt to enqueue pointer to some_object into buffer. */ - if (ck_ring_enqueue_spsc(&ring, &buffer, &entry, &length) == false) { - /* - * The buffer was full and the enqueue operation - * has failed. - */ - return; - } - - /* - * If buffer length was 100 items or more at the time entry was - * enqueued, do something. - */ - if (length > 100) { - do_something; - } - - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the value of -.Fa entry -was successfully enqueued into -.Fa ring . -This function will return the number of items -in -.Fa ring -with respect to the linearization point (the -point in item that -.Fa entry -is enqueued). -The function will return false if the value of -.Fa entry -could not be enqueued which only occurs if -.Fa ring -was full. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_init b/doc/ck_ring_init deleted file mode 100644 index 914d1bb139a0..000000000000 --- a/doc/ck_ring_init +++ /dev/null @@ -1,62 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_INIT 3 -.Sh NAME -.Nm ck_ring_init -.Nd initialize bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft void -.Fn ck_ring_init "ck_ring_t *ring" "unsigned int size" -.Sh DESCRIPTION -The -.Fn ck_ring_init -function initializes a bounded FIFO buffer pointed to by -.Fa ring -for the storage of up to -.Fa size -number of pointers. -The -.Fa size -argument must be a power-of-two greater than or equal to 4. -.Sh RETURN VALUES -This function has no return value. -.Sh SEE ALSO -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_size b/doc/ck_ring_size deleted file mode 100644 index 7ec69f486666..000000000000 --- a/doc/ck_ring_size +++ /dev/null @@ -1,55 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_SIZE 3 -.Sh NAME -.Nm ck_ring_size -.Nd return number of pointers enqueued in bounded FIFO -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft unsigned int -.Fn ck_ring_size "ck_ring_t *ring" -.Sh DESCRIPTION -The -.Fn ck_ring_size 3 -function returns the number of pointers currently -enqueued in the buffer pointed to by -.Fa ring . -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_trydequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_ring_trydequeue_spmc b/doc/ck_ring_trydequeue_spmc deleted file mode 100644 index 16f83eee4b9d..000000000000 --- a/doc/ck_ring_trydequeue_spmc +++ /dev/null @@ -1,126 +0,0 @@ -.\" -.\" Copyright 2012-2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 20, 2013 -.Dt CK_RING_TRYDEQUEUE_SPMC 3 -.Sh NAME -.Nm ck_ring_trydequeue_spmc -.Nd dequeue from bounded FIFO and allow for spurious failure -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_ring.h -.Ft bool -.Fn ck_ring_trydequeue_spmc "ck_ring_t *ring" "ck_ring_buffer_t *buffer" "void *result" -.Sh DESCRIPTION -The -.Fn ck_ring_trydequeue_spmc 3 -function attempts to dequeue a pointer from the bounded buffer -pointed to by -.Fa ring -in FIFO fashion. The pointer is stored in the pointer -pointed to by -.Fa result . -The buffer pointed to by -.Fa buffer -must be unique to -.Fa ring -and point to an array of ck_ring_buffer_t of sufficient -length (according to the power-of-2 elements in the buffer). -The decoupling of the ring from the buffer serves -to address use-cases involving multiple address spaces -and DMA, among others. -If you are on non-POSIX platforms or wish for strict -compliance with C, then it is recommended to pass a -pointer of type void ** for -.Fa result . -This function is safe to call without locking for UINT_MAX -concurrent -.Fn ck_ring_dequeue_spmc 3 -or -.Fn ck_ring_trydequeue_spmc 3 -invocations and up to one concurrent -.Fn ck_ring_enqueue_spmc 3 -or -.Fn ck_ring_tryenqueue_spmc 3 -invocation. This operation will always complete -in a bounded number of steps. It is -possible for the function to return false even -if -.Fa ring -is non-empty. This -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -/* This ring was previously initialized with ck_ring_init. */ -ck_ring_t ring; - -/* The ring was initialized for 1023 elements. */ -ck_ring_buffer_t buffer[1024]; - -void -dequeue(void) -{ - void *result; - - /* Dequeue from ring until contention is actively observed. */ - while (ck_ring_trydequeue_spmc(&ring, &buffer, &result) == true) { - /* - * Results contains the oldest pointer in ring - * since the dequeue operation returned true. - */ - operation(result); - } - - /* An empty ring was encountered, leave. */ - return; -} -.Ed -.Sh RETURN VALUES -The function returns true if the dequeue operation -completely successfully in a bounded number of steps. -The result of the dequeue operation is stored in the -value pointed to by -.Fa result . -Otherwise, the function will return false if the buffer was empty -or if the operation could not be completed in a bounded -number of steps. If the function returns false, then the contents -of -.Fa result -are undefined. -.Sh SEE ALSO -.Xr ck_ring_init 3 , -.Xr ck_ring_dequeue_spmc 3 , -.Xr ck_ring_enqueue_spmc 3 , -.Xr ck_ring_enqueue_spmc_size 3 , -.Xr ck_ring_dequeue_spsc 3 , -.Xr ck_ring_enqueue_spsc 3 , -.Xr ck_ring_enqueue_spsc_size 3 , -.Xr ck_ring_capacity 3 , -.Xr ck_ring_size 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rwcohort b/doc/ck_rwcohort deleted file mode 100644 index ba2b5f9f5702..000000000000 --- a/doc/ck_rwcohort +++ /dev/null @@ -1,203 +0,0 @@ -.\" -.\" Copyright 2013 Brendon Scheinman. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 23, 2013. -.Dt ck_rwcohort 3 -.Sh NAME -.Nm ck_rwcohort -.Nd generalized interface for reader-writer locks using cohort locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rwcohort.h -In each of the following macros, "STRATEGY" should be replaced with either "NEUTRAL", "RP", or "WP" -depending on which locking strategy the user prefers. RP and WP represent reader preference and -writer preference, respectively, while NEUTRAL represents a strategy neutral to reads vs. writes. -.Fn CK_RWCOHORT_STRATEGY_PROTOTYPE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_STRATEGY_NAME "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_STRATEGY_INSTANCE "COHORT_NAME cohort_name" -.Fn CK_RWCOHORT_STRATEGY_INIT "COHORT_NAME cohort_name" "RWCOHORT lock" "unsigned int wait_limit" -Note: the wait_limit argument should be omitted for locks using the neutral strategy -.Fn CK_RWCOHORT_STRATEGY_READ_LOCK "COHORT_NAME cohort_name" "RWCOHORT lock" "COHORT cohort" \ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_STRATEGY_READ_UNLOCK "COHORT_NAME cohort_name" "RWCOHORT lock" "COHORT cohort" \ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_STRATEGY_WRITE_LOCK "COHORT_NAME cohort_name" "RWCOHORT lock" "COHORT cohort" \ -"void *global_context" "void *local_context" -.Fn CK_RWCOHORT_STRATEGY_WRITE_UNLOCK "COHORT_NAME cohort_name" "RWCOHORT lock" "COHORT cohort" \ -"void *global_context" "void *local_context" -.Pp -Arguments of type RWCOHORT must be pointers to structs defined using the -.Xr CK_RWCOHORT_STRATEGY_PROTOTYPE 3 -macro with the same strategy and cohort name as the current call. -.Pp -Arguments of type COHORT must be pointers to structs defined using the -.Xr CK_COHORT_PROTOTYPE 3 -macro. -.Sh DESCRIPTION -ck_rwcohort.h provides an interface for defining reader-writer locks -that use cohort locks internally to increase performance on NUMA -architectures. See -.Xr ck_cohort 3 -for more information about cohort locks. -.Pp -Before using a reader-writer cohort lock, the user must define a cohort type using -either the -.Xr CK_COHORT_PROTOTYPE 3 -or the -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 -macros, and define a reader-writer lock type using the -.Xr CK_RWCOHORT_PROTOTYPE 3 -macro. -.Pp -.Sh EXAMPLE -.Bd -literal -offset indent -#include -#include - -#include -#include -#include -#include - -/* Create cohort methods with signatures that match the required signature */ - -static void -ck_spinlock_lock_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - ck_spinlock_lock(lock); - return; -} - -static void -ck_spinlock_unlock_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - ck_spinlock_unlock(lock); - return; -} - -static bool -ck_spinlock_locked_with_context(ck_spinlock_t *lock, void *context) -{ - (void)context; - return ck_spinlock_locked(lock); -} - -/* - * define a cohort type named "test_cohort" that will use - * the above methods for both its global and local locks - */ -CK_COHORT_PROTOTYPE(test_cohort, - ck_spinlock_lock_with_context, ck_spinlock_unlock_with_context, ck_spinlock_locked_with_context, - ck_spinlock_lock_with_context, ck_spinlock_unlock_with_context, ck_spinlock_locked_with_context) - -/* define a reader-writer type using the same cohort type */ -CK_RWCOHORT_WP_PROTOTYPE(test_cohort) - -static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; -static CK_COHORT_INSTANCE(test_cohort) *cohorts; -static CK_RWCOHORT_WP_INSTANCE(test_cohort) rw_cohort = CK_RWCOHORT_WP_INITIALIZER; -static unsigned int ready; - -static void * -function(void *context) -{ - CK_COHORT_INSTANCE(test_cohort) *cohort = context; - - while (ck_pr_load_uint(&ready) == 0); - - while (ck_pr_load_uint(&ready) > 0) { - /* - * acquire the cohort lock before performing critical section. - * note that we pass NULL for both the global and local context - * arguments because neither the lock nor unlock functions - * will use them. - */ - CK_COHORT_LOCK(test_cohort, cohort, NULL, NULL); - - /* perform critical section */ - - /* relinquish cohort lock */ - CK_COHORT_UNLOCK(test_cohort, cohort, NULL, NULL); - } - - return NULL; -} - -int -main(void) -{ - unsigned int nthr = 4; - unsigned int n_cohorts = 2; - unsigned int i; - - /* allocate 2 cohorts of the defined type */ - CK_COHORT_INSTANCE(test_cohort) *cohorts = - calloc(n_cohorts, sizeof(CK_COHORT_INSTANCE(test_cohort))); - - /* create local locks to use with each cohort */ - ck_spinlock_t *local_locks = - calloc(n_cohorts, sizeof(ck_spinlock_t)); - - pthread_t *threads = - calloc(nthr, sizeof(pthread_t)); - - /* initialize each of the cohorts before using them */ - for (i = 0 ; i < n_cohorts ; ++i) { - CK_COHORT_INIT(test_cohort, cohorts + i, &global_lock, local_locks + i, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - } - - /* start each thread and assign cohorts equally */ - for (i = 0 ; i < nthr ; ++i) { - pthread_create(threads + i, NULL, function, cohorts + (i % n_cohorts)); - } - - ck_pr_store_uint(&ready, 1); - sleep(10); - ck_pr_store_uint(&ready, 0); - - for (i = 0 ; i < nthr ; ++i) { - pthread_join(threads[i], NULL); - } - - return 0; -} -.Ed -.Sh SEE ALSO -.Xr CK_COHORT_PROTOTYPE 3 , -.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , -.Xr CK_COHORT_INSTANCE 3 , -.Xr CK_COHORT_INITIALIZER 3 , -.Xr CK_COHORT_INIT 3 , -.Xr CK_COHORT_LOCK 3 , -.Xr CK_COHORT_UNLOCK 3 , -.Xr CK_COHORT_LOCKED 3 , -.Xr CK_COHORT_TRYLOCK 3 , -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_rwlock b/doc/ck_rwlock deleted file mode 100644 index 60a18ab83544..000000000000 --- a/doc/ck_rwlock +++ /dev/null @@ -1,143 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 26, 2013. -.Dt ck_rwlock 3 -.Sh NAME -.Nm ck_rwlock_init , -.Nm ck_rwlock_write_lock , -.Nm ck_rwlock_write_unlock , -.Nm ck_rwlock_write_trylock , -.Nm ck_rwlock_write_downgrade , -.Nm ck_rwlock_locked_writer , -.Nm ck_rwlock_read_lock , -.Nm ck_rwlock_read_trylock , -.Nm ck_rwlock_read_unlock , -.Nm ck_rwlock_locked_reader , -.Nm ck_rwlock_recursive_write_lock , -.Nm ck_rwlock_recursive_write_trylock , -.Nm ck_rwlock_recurisve_write_unlock , -.Nm ck_rwlock_recursive_read_lock , -.Nm ck_rwlock_recursive_read_trylock , -.Nm ck_rwlock_recursive_read_unlock -.Nd centralized write-biased reader-writer locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_rwlock.h -.Pp -.Dv ck_rwlock_t lock = CK_RWLOCK_INITIALIZER; -.Pp -.Ft void -.Fn ck_rwlock_init "ck_rwlock_t *lock" -.Ft void -.Fn ck_rwlock_write_lock "ck_rwlock_t *lock" -.Ft void -.Fn ck_rwlock_write_unlock "ck_rwlock_t *lock" -.Ft bool -.Fn ck_rwlock_write_trylock "ck_rwlock_t *lock" -.Ft bool -.Fn ck_rwlock_write_downgrade "ck_rwlock_t *lock" -.Ft bool -.Fn ck_rwlock_locked_writer "ck_rwlock_t *lock" -.Ft void -.Fn ck_rwlock_read_lock "ck_rwlock_t *lock" -.Ft bool -.Fn ck_rwlock_read_trylock "ck_rwlock_t *lock" -.Ft void -.Fn ck_rwlock_read_unlock "ck_rwlock_t *lock" -.Ft bool -.Fn ck_rwlock_locked_reader "ck_rwlock_t *lock" -.Pp -.Dv ck_rwlock_recursive_t lock = CK_RWLOCK_RECURSIVE_INITIALIZER; -.Pp -.Ft void -.Fn ck_rwlock_recursive_write_lock "ck_rwlock_recursive_t *lock" "unsigned int tid" -.Ft bool -.Fn ck_rwlock_recursive_write_trylock "ck_rwlock_recursive_t *lock" "unsigned int tid" -.Ft void -.Fn ck_rwlock_recurisve_write_unlock "ck_rwlock_recursive_t *lock" -.Ft void -.Fn ck_rwlock_recursive_read_lock "ck_rwlock_recursive_t *lock" -.Ft bool -.Fn ck_rwlock_recursive_read_trylock "ck_rwlock_recursive_t *lock" -.Ft void -.Fn ck_rwlock_recursive_read_unlock "ck_rwlock_recursive_t *lock" -.Sh DESCRIPTION -This is a centralized write-biased reader-writer lock. It -requires very little space overhead and has a low latency -fast path. Write-side recursion requires usage of ck_rwlock_recursive. -Read-side recursion is disallowed. The -.Fn ck_rwlock_write_downgrade -function degrades the caller's write-side acquisition to a read-side -acquisition without forfeit of current critical section. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -static ck_rwlock_t lock = CK_RWLOCK_INITIALIZER; - -static void -reader(void) -{ - - for (;;) { - ck_rwlock_read_lock(&lock); - /* Read-side critical section. */ - ck_rwlock_read_unlock(&lock); - - if (ck_rwlock_read_trylock(&lock) == true) { - /* Read-side critical section. */ - ck_rwlock_read_unlock(&lock); - } - } - - return; -} - -static void -writer(void) -{ - - for (;;) { - ck_rwlock_write_lock(&lock); - /* Write-side critical section. */ - ck_rwlock_write_unlock(&lock); - - if (ck_rwlock_write_trylock(&lock, 1) == true) { - /* Write-side critical section. */ - ck_rwlock_write_unlock(&lock); - } - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_brlock 3 , -.Xr ck_elide 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_sequence b/doc/ck_sequence deleted file mode 100644 index faa1631e9e00..000000000000 --- a/doc/ck_sequence +++ /dev/null @@ -1,144 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 26, 2013. -.Dt ck_sequence 3 -.Sh NAME -.Nm ck_sequence_init , -.Nm ck_sequence_read_begin , -.Nm ck_sequence_read_retry , -.Nm ck_sequence_write_begin , -.Nm ck_sequence_write_end -.Nd sequence locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_sequence.h -.Pp -.Dv ck_sequence_t seqlock = CK_SEQUENCE_INITIALIZER; -.Pp -.Ft void -.Fn ck_sequence_init "ck_sequence_t *sq" -.Ft unsigned int -.Fn ck_sequence_read_begin "const ck_sequence_t *sq" -.Ft bool -.Fn ck_sequence_read_retry "const ck_sequence_t *sq" "unsigned int version" -.Ft void -.Fn ck_sequence_write_begin "ck_sequence_t *sq" -.Ft void -.Fn ck_sequence_write_end "ck_sequence_t *sq" -.Sh DESCRIPTION -It is recommended to use ck_sequence when a small amount of data that cannot be -accessed atomically has to be synchronized with readers in a fashion that does -not block any writer. Readers are able to execute their read-side critical -sections without any atomic operations. A ck_sequence_t must be initialized -before use. It may be initialized using either a static initializer -(CK_SEQUENCE_INITIALIZER) or using -.Fn ck_sequence_init . -Before readers attempt to -read data that may be concurrently modified they must first save the return -value of -.Fn ck_sequence_read_begin . -While or after a reader has completed copying -the data associated with a ck_sequence_t it must pass the earlier return value -of -.Fn ck_sequence_read_begin -to -.Fn "ck_sequence_read_retry". If -.Fn ck_sequence_read_retry -returns true then the copy of data may be inconsistent and the read process -must be retried. Writers must rely on their own synchronization primitives. -Once a writer has entered its respective critical section, it must call -.Fn ck_sequence_write_begin -to signal intent to update the data protected -by the ck_sequence_t. Before the writer leaves its critical section it must -execute -.Fn ck_sequence_write_end -to indicate that the updates have left respective objects in a consistent state. -.Sh EXAMPLE -.Bd -literal -offset indent -#include -#include - -static struct example { - int a; - int b; - int c; -} global; - -static ck_sequence_t seqlock = CK_SEQUENCE_INITIALIZER; - -void -reader(void) -{ - struct example copy; - unsigned int version; - - /* - * Attempt a read of the data structure. If the structure - * has been modified between ck_sequence_read_begin and - * ck_sequence_read_retry then attempt another read since - * the data may be in an inconsistent state. - */ - do { - version = ck_sequence_read_begin(&seqlock); - copy = global; - } while (ck_sequence_read_retry(&seqlock, version)); - - /* - * The previous may also be expressed using CK_SEQUENCE_READ. - * Generally recommend to only use ck_sequence_read_retry - * if you would like to detect a conflicting write at some - * higher granularity. - */ - CK_SEQUENCE_READ(&seqlock, &version) { - copy = global; - } - - return; -} - -void -writer(void) -{ - - for (;;) { - ck_sequence_write_begin(&seqlock); - global.a = rand(); - global.b = global.a + global.b; - global.c = global.b + global.c; - ck_sequence_write_end(&seqlock); - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_brlock 3 , -.Xr ck_bytelock 3 , -.Xr ck_rwlock 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_spinlock b/doc/ck_spinlock deleted file mode 100644 index 564d1857d8c6..000000000000 --- a/doc/ck_spinlock +++ /dev/null @@ -1,259 +0,0 @@ -.\" -.\" Copyright 2013 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd July 26, 2013. -.Dt ck_spinlock 3 -.Sh NAME -.Nm ck_spinlock_init , -.Nm ck_spinlock_lock , -.Nm ck_spinlock_unlock , -.Nm ck_spinlock_locked , -.Nm ck_spinlock_trylock , -.Nm ck_spinlock_anderson_init , -.Nm ck_spinlock_anderson_locked , -.Nm ck_spinlock_anderson_lock , -.Nm ck_spinlock_anderson_unlock , -.Nm ck_spinlock_cas_init , -.Nm ck_spinlock_cas_locked , -.Nm ck_spinlock_cas_lock , -.Nm ck_spinlock_cas_lock_eb , -.Nm ck_spinlock_cas_trylock , -.Nm ck_spinlock_cas_unlock , -.Nm ck_spinlock_clh_init , -.Nm ck_spinlock_clh_locked , -.Nm ck_spinlock_clh_lock , -.Nm ck_spinlock_clh_unlock , -.Nm ck_spinlock_dec_init , -.Nm ck_spinlock_dec_locked , -.Nm ck_spinlock_dec_lock , -.Nm ck_spinlock_dec_lock_eb , -.Nm ck_spinlock_dec_trylock , -.Nm ck_spinlock_dec_unlock , -.Nm ck_spinlock_fas_init , -.Nm ck_spinlock_fas_lock , -.Nm ck_spinlock_fas_lock_eb , -.Nm ck_spinlock_fas_locked , -.Nm ck_spinlock_fas_trylock , -.Nm ck_spinlock_fas_unlock , -.Nm ck_spinlock_hclh_init , -.Nm ck_spinlock_hclh_locked , -.Nm ck_spinlock_hclh_lock , -.Nm ck_spinlock_hclh_unlock , -.Nm ck_spinlock_mcs_init , -.Nm ck_spinlock_mcs_locked , -.Nm ck_spinlock_mcs_lock , -.Nm ck_spinlock_mcs_trylock , -.Nm ck_spinlock_mcs_unlock , -.Nm ck_spinlock_ticket_init , -.Nm ck_spinlock_ticket_locked , -.Nm ck_spinlock_ticket_lock , -.Nm ck_spinlock_ticket_lock_pb , -.Nm ck_spinlock_ticket_trylock , -.Nm ck_spinlock_ticket_unlock -.Nd spinlock implementations -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_spinlock.h -.Pp -.Dv ck_spinlock_t spinlock = CK_SPINLOCK_INITIALIZER; -.Ft void -.Fn ck_spinlock_init "ck_spinlock_t *lock" -.Ft void -.Fn ck_spinlock_lock "ck_spinlock_t *lock" -.Ft void -.Fn ck_spinlock_unlock "ck_spinlock_t *lock" -.Ft bool -.Fn ck_spinlock_locked "ck_spinlock_t *lock" -.Ft bool -.Fn ck_spinlock_trylock "ck_spinlock_t *lock" -.Ft void -.Fn ck_spinlock_anderson_init "ck_spinlock_anderson_t *lock" "ck_spinlock_anderson_thread_t *slots" "unsigned int count" -.Ft bool -.Fn ck_spinlock_anderson_locked "ck_spinlock_anderson_t *lock" -.Ft void -.Fn ck_spinlock_anderson_lock "ck_spinlock_anderson_t *lock" "ck_spinlock_anderson_thread_t **slot" -.Ft void -.Fn ck_spinlock_anderson_unlock "ck_spinlock_anderson_t *lock" "ck_spinlock_anderson_thread_t *slot" -.Pp -.Dv ck_spinlock_cas_t spinlock = CK_SPINLOCK_CAS_INITIALIZER; -.Ft void -.Fn ck_spinlock_cas_init "ck_spinlock_cas_t *lock" -.Ft bool -.Fn ck_spinlock_cas_locked "ck_spinlock_cas_t *lock" -.Ft void -.Fn ck_spinlock_cas_lock "ck_spinlock_cas_t *lock" -.Ft void -.Fn ck_spinlock_cas_lock_eb "ck_spinlock_cas_t *lock" -.Ft bool -.Fn ck_spinlock_cas_trylock "ck_spinlock_cas_t *lock" -.Ft void -.Fn ck_spinlock_cas_unlock "ck_spinlock_cas_t *lock" -.Ft void -.Fn ck_spinlock_clh_init "ck_spinlock_clh_t **lock" "ck_spinlock_clh_t *unowned" -.Ft bool -.Fn ck_spinlock_clh_locked "ck_spinlock_clh_t **lock" -.Ft void -.Fn ck_spinlock_clh_lock "ck_spinlock_clh_t **lock" "ck_spinlock_clh_t *node" -.Ft void -.Fn ck_spinlock_clh_unlock "ck_spinlock_clh_t **node" -.Pp -.Dv ck_spinlock_dec_t spinlock = CK_SPINLOCK_DEC_INITIALIZER; -.Ft void -.Fn ck_spinlock_dec_init "ck_spinlock_dec_t *lock" -.Ft bool -.Fn ck_spinlock_dec_locked "ck_spinlock_dec_t *lock" -.Ft void -.Fn ck_spinlock_dec_lock "ck_spinlock_dec_t *lock" -.Ft void -.Fn ck_spinlock_dec_lock_eb "ck_spinlock_dec_t *lock" -.Ft bool -.Fn ck_spinlock_dec_trylock "ck_spinlock_dec_t *lock" -.Ft void -.Fn ck_spinlock_dec_unlock "ck_spinlock_dec_t *lock" -.Pp -.Dv ck_spinlock_fas_t spinlock = CK_SPINLOCK_FAS_INITIALIZER; -.Ft void -.Fn ck_spinlock_fas_init "ck_spinlock_fas_t *lock" -.Ft void -.Fn ck_spinlock_fas_lock "ck_spinlock_fas_t *lock" -.Ft void -.Fn ck_spinlock_fas_lock_eb "ck_spinlock_fas_t *lock" -.Ft bool -.Fn ck_spinlock_fas_locked "ck_spinlock_fas_t *lock" -.Ft bool -.Fn ck_spinlock_fas_trylock "ck_spinlock_fas_t *lock" -.Ft void -.Fn ck_spinlock_fas_unlock "ck_spinlock_fas_t *lock" -.Pp -.Ft void -.Fn ck_spinlock_hclh_init "ck_spinlock_hclh_t **lock" "ck_spinlock_hclh_t *unowned" -.Ft bool -.Fn ck_spinlock_hclh_locked "ck_spinlock_hclh_t **lock" -.Ft void -.Fn ck_spinlock_hclh_lock "ck_spinlock_hclh_t **lock" "ck_spinlock_hclh_t *node" -.Ft void -.Fn ck_spinlock_hclh_unlock "ck_spinlock_hclh_t **node" -.Pp -.Dv ck_spinlock_mcs_t spinlock = CK_SPINLOCK_MCS_INITIALIZER; -.Ft void -.Fn ck_spinlock_mcs_init "ck_spinlock_mcs_t **lock" -.Ft bool -.Fn ck_spinlock_mcs_locked "ck_spinlock_mcs_t **lock" -.Ft void -.Fn ck_spinlock_mcs_lock "ck_spinlock_mcs_t **lock" "ck_spinlock_mcs_t *node" -.Ft bool -.Fn ck_spinlock_mcs_trylock "ck_spinlock_mcs_t **lock" "ck_spinlock_mcs_t *node" -.Ft void -.Fn ck_spinlock_mcs_unlock "ck_spinlock_mcs_t **lock" "ck_spinlock_mcs_t *node" -.Pp -.Dv ck_spinlock_ticket_t spinlock = CK_SPINLOCK_TICKET_INITIALIZER; -.Ft void -.Fn ck_spinlock_ticket_init "ck_spinlock_ticket_t *lock" -.Ft bool -.Fn ck_spinlock_ticket_locked "ck_spinlock_ticket_t *lock" -.Ft void -.Fn ck_spinlock_ticket_lock "ck_spinlock_ticket_t *lock" -.Ft void -.Fn ck_spinlock_ticket_lock_pb "ck_spinlock_ticket_t *lock" "unsigned int period" -.Ft bool -.Fn ck_spinlock_ticket_trylock "ck_spinlock_ticket_t *lock" -.Ft void -.Fn ck_spinlock_ticket_unlock "ck_spinlock_ticket_t *lock" -.Sh DESCRIPTION -A family of busy-wait spinlock implementations. The ck_spinlock_t implementation is simply -a wrapper around the fetch-and-swap (ck_spinlock_fas_t) implementation. The table below -provides a summary of the current implementations. -.Bd -literal -| Namespace | Algorithm | Type | Restrictions | Fair | -\'----------------------|-----------------------------|---------------|-------------------------|--------' - ck_spinlock_anderson Anderson Array Fixed number of threads Yes - ck_spinlock_cas Compare-and-Swap Centralized None No - ck_spinlock_clh Craig, Landin and Hagersten Queue Lifetime requirements Yes - ck_spinlock_dec Decrement (Linux kernel) Centralized UINT_MAX concurrency No - ck_spinlock_fas Fetch-and-store Centralized None No - ck_spinlock_hclh Hierarchical CLH Queue Lifetime requirements Yes * - ck_spinlock_mcs Mellor-Crummey and Scott Queue None Yes - ck_spinlock_ticket Ticket Centralized None Yes -.Ed -.Pp -* Hierarchical CLH only offers weak fairness for threads accross cluster -nodes. -.Pp -If contention is low and there is no hard requirement for starvation-freedom -then a centralized greedy (unfair) spinlock is recommended. If contention is -high and there is no requirement for starvation-freedom then a centralized -greedy spinlock is recommended to be used with an exponential backoff -mechanism. If contention is generally low and there is a hard requirement for -starvation-freedom then the ticket lock is recommended. If contention is high -and there is a hard requirement for starvation-freedom then the Craig and -Landin and Hagersten queue spinlock is recommended unless stack allocation is -necessary or NUMA factor is high, in which case the Mellor-Crummey and Scott -spinlock is recommended. If you cannot afford O(n) space-usage from array -or queue spinlocks but still require fairness under high contention then -the ticket lock with proportional back-off is recommended. -If NUMA factor is high but prefer a greedy lock, then please see -.Xr ck_cohort 3 . -.Sh EXAMPLE -.Bd -literal -offset indent -#include -#include - -/* - * Alternatively, the mutex may be initialized at run-time with - * ck_spinlock_init(&mutex). - */ -ck_spinlock_t mutex = CK_SPINLOCK_INITIALIZER; - -void -example(void) -{ - - ck_spinlock_lock(&mutex); - /* - * Critical section. - */ - ck_spinlock_unlock(&mutex); - - ck_spinlock_lock_eb(&mutex); - /* - * Critical section. - */ - ck_spinlock_unlock(&mutex); - - if (ck_spinlock_trylock(&mutex) == true) { - /* - * Critical section. - */ - ck_spinlock_unlock(&mutex); - } -} -.Ed -.Sh SEE ALSO -.Xr ck_cohort 3 , -.Xr ck_elide 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_swlock b/doc/ck_swlock deleted file mode 100644 index e101334814f3..000000000000 --- a/doc/ck_swlock +++ /dev/null @@ -1,138 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2014. -.Dt ck_swlock 3 -.Sh NAME -.Nm ck_swlock_init , -.Nm ck_swlock_write_latch , -.Nm ck_swlock_write_unlatch , -.Nm ck_swlock_write_lock , -.Nm ck_swlock_write_unlock , -.Nm ck_swlock_write_trylock , -.Nm ck_swlock_write_downgrade , -.Nm ck_swlock_locked_writer , -.Nm ck_swlock_read_lock , -.Nm ck_swlock_read_trylock , -.Nm ck_swlock_read_unlock , -.Nm ck_swlock_locked_reader -.Nd centralized copy-safe write-biased single-writer read-write locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_swlock.h -.Pp -.Dv ck_swlock_t lock = CK_SWLOCK_INITIALIZER; -.Pp -.Ft void -.Fn ck_swlock_init "ck_swlock_t *lock" -.Ft void -.Fn ck_swlock_write_lock "ck_swlock_t *lock" -.Ft void -.Fn ck_swlock_write_unlock "ck_swlock_t *lock" -.Ft void -.Fn ck_swlatch_write_latch "ck_swlatch_t *latch" -.Ft void -.Fn ck_swlatch_write_unlatch "ck_swlatch_t *latch" -.Ft bool -.Fn ck_swlock_write_trylock "ck_swlock_t *lock" -.Ft bool -.Fn ck_swlock_write_downgrade "ck_swlock_t *lock" -.Ft bool -.Fn ck_swlock_locked_writer "ck_swlock_t *lock" -.Ft void -.Fn ck_swlock_read_lock "ck_swlock_t *lock" -.Ft bool -.Fn ck_swlock_read_trylock "ck_swlock_t *lock" -.Ft void -.Fn ck_swlock_read_unlock "ck_swlock_t *lock" -.Ft bool -.Fn ck_swlock_locked_reader "ck_swlock_t *lock" -.Sh DESCRIPTION -This is a centralized write-biased single-writer reader-writer lock. It -requires half the space that ck_rwlock does and has a low latency -fast path. The lock supports latch and unlatch operations that -allow it to be used in a copy-safe manner (reader-bits may be -over-written safely). -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -static ck_swlock_t lock = CK_SWLOCK_INITIALIZER; - -static void -reader(void) -{ - - for (;;) { - ck_swlock_read_lock(&lock); - /* Read-side critical section. */ - ck_swlock_read_unlock(&lock); - - if (ck_swlock_read_trylock(&lock) == true) { - /* Read-side critical section. */ - ck_swlock_read_unlock(&lock); - } - } - - return; -} - -static void -writer(void) -{ - ck_swlock_t contrived; - - for (;;) { - ck_swlock_write_lock(&lock); - /* Write-side critical section. */ - ck_swlock_write_unlock(&lock); - - if (ck_swlock_write_trylock(&lock) == true) { - /* Write-side critical section. */ - ck_swlock_write_unlock(&lock); - } - - ck_swlock_write_latch(&lock); - /* Write-side critical section. */ - - /* This is safe to do with-in a latch. */ - contrived = lock; - lock = contrived; - ck_swlock_write_unlatch(&lock); - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_brlock 3 , -.Xr ck_elide 3 , -.Xr ck_pflock 3 , -.Xr ck_rwlock 3 , -.Xr ck_tflock 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/ck_tflock b/doc/ck_tflock deleted file mode 100644 index 629dbd4eef1c..000000000000 --- a/doc/ck_tflock +++ /dev/null @@ -1,95 +0,0 @@ -.\" -.\" Copyright 2014 Samy Al Bahra. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.Dd April 22, 2014. -.Dt ck_tflock 3 -.Sh NAME -.Nm ck_tflock_ticket_init , -.Nm ck_tflock_ticket_write_lock , -.Nm ck_tflock_ticket_write_unlock , -.Nm ck_tflock_ticket_read_lock , -.Nm ck_tflock_ticket_read_unlock , -.Nd centralized task-fair reader-writer locks -.Sh LIBRARY -Concurrency Kit (libck, \-lck) -.Sh SYNOPSIS -.In ck_tflock.h -.Pp -.Dv ck_tflock_ticket_t lock = CK_TFLOCK_TICKET_INITIALIZER; -.Pp -.Ft void -.Fn ck_tflock_ticket_init "ck_tflock_ticket_t *lock" -.Ft void -.Fn ck_tflock_ticket_write_lock "ck_tflock_ticket_t *lock" -.Ft void -.Fn ck_tflock_ticket_write_unlock "ck_tflock_ticket_t *lock" -.Ft void -.Fn ck_tflock_ticket_read_lock "ck_tflock_ticket_t *lock" -.Ft void -.Fn ck_tflock_ticket_read_unlock "ck_tflock_ticket_t *lock" -.Sh DESCRIPTION -This is a centralized task-fair reader-writer lock. It -requires little space overhead and has a low latency -fast path. -.Sh EXAMPLE -.Bd -literal -offset indent -#include - -static ck_tflock_ticket_t lock = CK_TFLOCK_INITIALIZER; - -static void -reader(void) -{ - - for (;;) { - ck_tflock_ticket_read_lock(&lock); - /* Read-side critical section. */ - ck_tflock_ticket_read_unlock(&lock); - } - - return; -} - -static void -writer(void) -{ - - for (;;) { - ck_tflock_ticket_write_lock(&lock); - /* Write-side critical section. */ - ck_tflock_ticket_write_unlock(&lock); - } - - return; -} -.Ed -.Sh SEE ALSO -.Xr ck_brlock 3 , -.Xr ck_rwlock 3 , -.Xr ck_pflock 3 , -.Xr ck_swlock 3 -.Pp -Additional information available at http://concurrencykit.org/ diff --git a/doc/refcheck.pl b/doc/refcheck.pl deleted file mode 100755 index 1ed3a65d07f0..000000000000 --- a/doc/refcheck.pl +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/perl - -use warnings; -use strict; - -my @files = @ARGV; - -my $h; - -foreach my $file (@files) { - $h->{$file} = 1; -} - -foreach my $file (@files) { - open(my $fh, "<", $file) or die "cannot open < $file: $!"; - while (<$fh>) { - chomp; - if ($_ =~ /\.Xr ((ck|CK)_[a-zA-Z_]+) ([0-9])/) { - my $name = $1; - my $section = $3; - if (!$h->{$name}) { - print STDERR "$file: ref to missing ${name}($section)\n"; - } - } - } - close($fh) or die("cannot close $file: $!"); -} diff --git a/include/ck_md.h.in b/include/ck_md.h.in deleted file mode 100644 index 07dd384ed536..000000000000 --- a/include/ck_md.h.in +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2011-2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_MD_H -#define CK_MD_H - -#ifndef CK_MD_CACHELINE -#define CK_MD_CACHELINE (64) -#endif - -#ifndef CK_MD_PAGESIZE -#define CK_MD_PAGESIZE (4096) -#endif - -#ifndef @RTM_ENABLE@ -#define @RTM_ENABLE@ -#endif /* @RTM_ENABLE@ */ - -#ifndef @POINTER_PACK_ENABLE@ -#define @POINTER_PACK_ENABLE@ -#endif /* @POINTER_PACK_ENABLE@ */ - -#ifndef @VMA_BITS@ -#define @VMA_BITS@ @VMA_BITS_VALUE@ -#endif /* @VMA_BITS@ */ - -#ifndef @MM@ -#define @MM@ -#endif /* @MM@ */ - -#define CK_VERSION "@VERSION@" -#define CK_GIT_SHA "@GIT_SHA@" - -#endif /* CK_MD_H */ diff --git a/regressions/Makefile b/regressions/Makefile deleted file mode 100644 index 3195e52e5fa1..000000000000 --- a/regressions/Makefile +++ /dev/null @@ -1,128 +0,0 @@ -DIR=array \ - backoff \ - barrier \ - bitmap \ - brlock \ - bytelock \ - cohort \ - epoch \ - fifo \ - hp \ - hs \ - rhs \ - ht \ - pflock \ - pr \ - queue \ - ring \ - rwlock \ - swlock \ - sequence \ - spinlock \ - stack \ - swlock \ - tflock - -.PHONY: all clean check - -all: - $(MAKE) -C ./ck_array/validate all - $(MAKE) -C ./ck_cohort/validate all - $(MAKE) -C ./ck_cohort/benchmark all - $(MAKE) -C ./ck_bitmap/validate all - $(MAKE) -C ./ck_backoff/validate all - $(MAKE) -C ./ck_queue/validate all - $(MAKE) -C ./ck_brlock/validate all - $(MAKE) -C ./ck_ht/validate all - $(MAKE) -C ./ck_ht/benchmark all - $(MAKE) -C ./ck_brlock/benchmark all - $(MAKE) -C ./ck_spinlock/validate all - $(MAKE) -C ./ck_spinlock/benchmark all - $(MAKE) -C ./ck_fifo/validate all - $(MAKE) -C ./ck_fifo/benchmark all - $(MAKE) -C ./ck_pr/validate all - $(MAKE) -C ./ck_pr/benchmark all - $(MAKE) -C ./ck_hs/benchmark all - $(MAKE) -C ./ck_hs/validate all - $(MAKE) -C ./ck_rhs/benchmark all - $(MAKE) -C ./ck_rhs/validate all - $(MAKE) -C ./ck_barrier/validate all - $(MAKE) -C ./ck_barrier/benchmark all - $(MAKE) -C ./ck_bytelock/validate all - $(MAKE) -C ./ck_bytelock/benchmark all - $(MAKE) -C ./ck_epoch/validate all - $(MAKE) -C ./ck_rwcohort/validate all - $(MAKE) -C ./ck_rwcohort/benchmark all - $(MAKE) -C ./ck_sequence/validate all - $(MAKE) -C ./ck_sequence/benchmark all - $(MAKE) -C ./ck_stack/validate all - $(MAKE) -C ./ck_stack/benchmark all - $(MAKE) -C ./ck_ring/validate all - $(MAKE) -C ./ck_ring/benchmark all - $(MAKE) -C ./ck_rwlock/validate all - $(MAKE) -C ./ck_rwlock/benchmark all - $(MAKE) -C ./ck_tflock/validate all - $(MAKE) -C ./ck_tflock/benchmark all - $(MAKE) -C ./ck_swlock/validate all - $(MAKE) -C ./ck_swlock/benchmark all - $(MAKE) -C ./ck_pflock/validate all - $(MAKE) -C ./ck_pflock/benchmark all - $(MAKE) -C ./ck_hp/validate all - $(MAKE) -C ./ck_hp/benchmark all - -clean: - $(MAKE) -C ./ck_array/validate clean - $(MAKE) -C ./ck_pflock/validate clean - $(MAKE) -C ./ck_pflock/benchmark clean - $(MAKE) -C ./ck_tflock/validate clean - $(MAKE) -C ./ck_tflock/benchmark clean - $(MAKE) -C ./ck_rwcohort/validate clean - $(MAKE) -C ./ck_rwcohort/benchmark clean - $(MAKE) -C ./ck_backoff/validate clean - $(MAKE) -C ./ck_bitmap/validate clean - $(MAKE) -C ./ck_queue/validate clean - $(MAKE) -C ./ck_cohort/validate clean - $(MAKE) -C ./ck_cohort/benchmark clean - $(MAKE) -C ./ck_brlock/validate clean - $(MAKE) -C ./ck_ht/validate clean - $(MAKE) -C ./ck_ht/benchmark clean - $(MAKE) -C ./ck_hs/validate clean - $(MAKE) -C ./ck_hs/benchmark clean - $(MAKE) -C ./ck_rhs/validate clean - $(MAKE) -C ./ck_rhs/benchmark clean - $(MAKE) -C ./ck_brlock/benchmark clean - $(MAKE) -C ./ck_spinlock/validate clean - $(MAKE) -C ./ck_spinlock/benchmark clean - $(MAKE) -C ./ck_fifo/validate clean - $(MAKE) -C ./ck_fifo/benchmark clean - $(MAKE) -C ./ck_pr/validate clean - $(MAKE) -C ./ck_pr/benchmark clean - $(MAKE) -C ./ck_barrier/validate clean - $(MAKE) -C ./ck_barrier/benchmark clean - $(MAKE) -C ./ck_bytelock/validate clean - $(MAKE) -C ./ck_bytelock/benchmark clean - $(MAKE) -C ./ck_epoch/validate clean - $(MAKE) -C ./ck_sequence/validate clean - $(MAKE) -C ./ck_sequence/benchmark clean - $(MAKE) -C ./ck_stack/validate clean - $(MAKE) -C ./ck_stack/benchmark clean - $(MAKE) -C ./ck_ring/validate clean - $(MAKE) -C ./ck_ring/benchmark clean - $(MAKE) -C ./ck_rwlock/validate clean - $(MAKE) -C ./ck_rwlock/benchmark clean - $(MAKE) -C ./ck_swlock/validate clean - $(MAKE) -C ./ck_swlock/benchmark clean - $(MAKE) -C ./ck_pflock/validate clean - $(MAKE) -C ./ck_pflock/benchmark clean - $(MAKE) -C ./ck_hp/validate clean - $(MAKE) -C ./ck_hp/benchmark clean - -check: all - rc=0; \ - for d in $(DIR) ; do \ - echo "----[ Testing $$d...."; \ - $(MAKE) -C ./ck_$$d/validate check || rc=1; \ - echo; \ - done; \ - exit $$rc - diff --git a/regressions/Makefile.unsupported b/regressions/Makefile.unsupported deleted file mode 100644 index 90aa877ee04f..000000000000 --- a/regressions/Makefile.unsupported +++ /dev/null @@ -1,9 +0,0 @@ -.PHONY: all clean check - -all: - @echo Regressions are currently unsupported for out-of-source builds - -clean: all - -check: all - diff --git a/regressions/ck_array/validate/Makefile b/regressions/ck_array/validate/Makefile deleted file mode 100644 index 3c48167b224a..000000000000 --- a/regressions/ck_array/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=serial - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_array.h ../../../src/ck_array.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_array.c - -check: all - ./serial - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE -ggdb diff --git a/regressions/ck_array/validate/serial.c b/regressions/ck_array/validate/serial.c deleted file mode 100644 index b6d7b562a8c3..000000000000 --- a/regressions/ck_array/validate/serial.c +++ /dev/null @@ -1,178 +0,0 @@ -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATION -#define ITERATION 128 -#endif - -static void -my_free(void *p, size_t m, bool d) -{ - - (void)m; - (void)d; - - free(p); - return; -} - -static void * -my_malloc(size_t b) -{ - - return malloc(b); -} - -static void * -my_realloc(void *r, size_t a, size_t b, bool d) -{ - - (void)a; - (void)d; - - return realloc(r, b); -} - -int -main(void) -{ - void *r; - uintptr_t i; - ck_array_t array; - ck_array_iterator_t iterator; - struct ck_malloc m = { - .malloc = my_malloc, - .free = NULL, - .realloc = my_realloc - }; - - if (ck_array_init(&array, CK_ARRAY_MODE_SPMC, &m, 4) == true) - ck_error("ck_array_init with NULL free succeeded\n"); - - m.free = my_free; - if (ck_array_init(&array, CK_ARRAY_MODE_SPMC, &m, 4) == false) - ck_error("ck_array_init\n"); - - for (i = 0; i < ITERATION; i++) { - if (ck_array_put(&array, (void *)i) == false) - ck_error("ck_error_put\n"); - - if (ck_array_remove(&array, (void *)i) == false) - ck_error("ck_error_remove after put\n"); - } - - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != 0) - ck_error("Non-empty array after put -> remove workload.\n"); - - ck_array_commit(&array); - - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != 0) - ck_error("Non-empty array after put -> remove -> commit workload.\n"); - - for (i = 0; i < ITERATION; i++) { - if (ck_array_put(&array, (void *)i) == false) - ck_error("ck_error_put\n"); - } - - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != 0) - ck_error("Non-empty array after put workload.\n"); - - for (i = 0; i < ITERATION; i++) { - if (ck_array_remove(&array, (void *)i) == false) - ck_error("ck_error_remove after put\n"); - } - - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != 0) - ck_error("Non-empty array after put -> remove workload.\n"); - - ck_array_commit(&array); - - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != 0) - ck_error("Non-empty array after put -> remove -> commit workload.\n"); - - for (i = 0; i < ITERATION; i++) { - if (ck_array_put(&array, (void *)i) == false) - ck_error("ck_error_put\n"); - } - - ck_array_commit(&array); - - i = 0; - CK_ARRAY_FOREACH(&array, &iterator, &r) { - i++; - } - - if (i != ITERATION) - ck_error("Incorrect item count in iteration\n"); - - ck_array_remove(&array, (void *)(uintptr_t)0); - ck_array_remove(&array, (void *)(uintptr_t)1); - ck_array_commit(&array); - i = 0; CK_ARRAY_FOREACH(&array, &iterator, &r) i++; - if (i != ITERATION - 2 || ck_array_length(&array) != ITERATION - 2) - ck_error("Incorrect item count in iteration after remove\n"); - - if (ck_array_put_unique(&array, (void *)UINTPTR_MAX) != 0) - ck_error("Unique value put failed.\n"); - - if (ck_array_put_unique(&array, (void *)(uintptr_t)4) != 1) - ck_error("put of 4 not detected as non-unique.\n"); - - if (ck_array_put_unique(&array, (void *)UINTPTR_MAX) != 1) - ck_error("put of UINTPTR_MAX not detected as non-unique.\n"); - - ck_array_commit(&array); - i = 0; - CK_ARRAY_FOREACH(&array, &iterator, &r) { - i++; - } - if (i != ITERATION - 1 || ck_array_length(&array) != ITERATION - 1) - ck_error("Incorrect item count in iteration after unique put\n"); - - if (ck_array_initialized(&array) == false) - ck_error("Error, expected array to be initialized.\n"); - - for (i = 0; i < ITERATION * 4; i++) { - ck_array_remove(&array, (void *)i); - } - - for (i = 0; i < ITERATION * 16; i++) { - ck_array_put(&array, (void *)i); - } - - ck_array_commit(&array); - - for (i = 0; i < ITERATION * 128; i++) { - ck_array_put(&array, (void *)i); - if (ck_array_put_unique(&array, (void *)i) != 1) - ck_error("put_unique for non-unique value should fail.\n"); - } - - for (i = 0; i < ITERATION * 64; i++) { - bool f = ck_array_remove(&array, (void *)i); - - if (f == false && i < ITERATION * 144) - ck_error("Remove failed for existing entry.\n"); - - if (f == true && i > ITERATION * 144) - ck_error("Remove succeeded for non-existing entry.\n"); - } - - ck_array_commit(&array); - ck_array_deinit(&array, false); - - if (ck_array_initialized(&array) == true) - ck_error("Error, expected array to be uninitialized.\n"); - - return 0; -} - diff --git a/regressions/ck_backoff/validate/Makefile b/regressions/ck_backoff/validate/Makefile deleted file mode 100644 index 39e6d4f325f8..000000000000 --- a/regressions/ck_backoff/validate/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -.PHONY: check clean - -all: validate - -validate: validate.c ../../../include/ck_backoff.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate - -clean: - rm -rf validate *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_backoff/validate/validate.c b/regressions/ck_backoff/validate/validate.c deleted file mode 100644 index 137d48e309e4..000000000000 --- a/regressions/ck_backoff/validate/validate.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -#include -#include "../../common.h" - -int -main(void) -{ - ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; - const ck_backoff_t ceiling = CK_BACKOFF_CEILING + 1; - unsigned int i = 0; - - fprintf(stderr, "Ceiling is: %u (%#x)\n", CK_BACKOFF_CEILING, CK_BACKOFF_CEILING); - - for (;;) { - ck_backoff_t previous = backoff; - ck_backoff_eb(&backoff); - - printf("EB %u\n", backoff); - if (previous == ceiling) { - if (backoff != ceiling) - ck_error("[C] GB: expected %u, got %u\n", ceiling, backoff); - - if (i++ >= 1) - break; - } else if (previous != backoff >> 1) { - ck_error("[N] GB: expected %u (%u), got %u\n", previous << 1, previous, backoff); - } - } - - return 0; -} - diff --git a/regressions/ck_barrier/benchmark/Makefile b/regressions/ck_barrier/benchmark/Makefile deleted file mode 100644 index ea973d2c556f..000000000000 --- a/regressions/ck_barrier/benchmark/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=throughput - -all: $(OBJECTS) - -throughput: throughput.c ../../../include/ck_barrier.h ../../../src/ck_barrier_centralized.c - $(CC) $(CFLAGS) -o throughput throughput.c ../../../src/ck_barrier_centralized.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/benchmark/throughput.c b/regressions/ck_barrier/benchmark/throughput.c deleted file mode 100644 index 1a1c01395c53..000000000000 --- a/regressions/ck_barrier/benchmark/throughput.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#if defined(CK_F_PR_INC_64) && defined(CK_F_PR_LOAD_64) -static int done = 0; -static struct affinity a; -static int nthr; -static int tid; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -struct counter { - uint64_t value; -} CK_CC_CACHELINE; -struct counter *counters; - -static void * -thread(void *null CK_CC_UNUSED) -{ - ck_barrier_centralized_state_t state = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - int id; - - id = ck_pr_faa_int(&tid, 1); - aff_iterate(&a); - - while (ck_pr_load_int(&done) == 0) { - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - ck_barrier_centralized(&barrier, &state, nthr); - ck_pr_inc_64(&counters[id].value); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - uint64_t count; - int i; - - if (argc != 3) { - ck_error("Correct usage: \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - counters = calloc(sizeof(struct counter), nthr); - if (counters == NULL) { - ck_error("ERROR: Could not allocate counters\n"); - } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; ++i) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - - count = 0; - ck_pr_store_int(&done, 1); - for (i = 0; i < nthr; ++i) - count += ck_pr_load_64(&counters[i].value); - printf("%d %16" PRIu64 "\n", nthr, count); - - return (0); -} -#else -int -main(void) -{ - - fputs("Unsupported.", stderr); - return 0; -} -#endif - diff --git a/regressions/ck_barrier/validate/Makefile b/regressions/ck_barrier/validate/Makefile deleted file mode 100644 index f31a1a6d2b4e..000000000000 --- a/regressions/ck_barrier/validate/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=barrier_centralized barrier_combining barrier_dissemination barrier_tournament barrier_mcs - -all: $(OBJECTS) - -barrier_centralized: barrier_centralized.c ../../../include/ck_barrier.h ../../../src/ck_barrier_centralized.c - $(CC) $(CFLAGS) -o barrier_centralized barrier_centralized.c ../../../src/ck_barrier_centralized.c - -barrier_combining: barrier_combining.c ../../../include/ck_barrier.h ../../../src/ck_barrier_combining.c - $(CC) $(CFLAGS) -o barrier_combining barrier_combining.c ../../../src/ck_barrier_combining.c - -barrier_dissemination: barrier_dissemination.c ../../../include/ck_barrier.h ../../../src/ck_barrier_dissemination.c - $(CC) $(CFLAGS) -o barrier_dissemination barrier_dissemination.c ../../../src/ck_barrier_dissemination.c - -barrier_tournament: barrier_tournament.c ../../../include/ck_barrier.h ../../../src/ck_barrier_tournament.c - $(CC) $(CFLAGS) -o barrier_tournament barrier_tournament.c ../../../src/ck_barrier_tournament.c - -barrier_mcs: barrier_mcs.c ../../../include/ck_barrier.h ../../../src/ck_barrier_mcs.c - $(CC) $(CFLAGS) -o barrier_mcs barrier_mcs.c ../../../src/ck_barrier_mcs.c - -check: all - rc=0; \ - for d in $(OBJECTS) ; do \ - echo $$d; \ - ./$$d $(CORES) 1 1 || rc=1; \ - done; \ - exit $$rc - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_barrier/validate/barrier_centralized.c b/regressions/ck_barrier/validate/barrier_centralized.c deleted file mode 100644 index 551913ab667e..000000000000 --- a/regressions/ck_barrier/validate/barrier_centralized.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -#ifndef ENTRIES -#define ENTRIES 512 -#endif - -static struct affinity a; -static int nthr; -static int counters[ENTRIES]; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static int barrier_wait; - -static void * -thread(void *null CK_CC_UNUSED) -{ - ck_barrier_centralized_state_t state = CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - int j, counter; - int i = 0; - - aff_iterate(&a); - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != nthr) - ck_pr_stall(); - - for (j = 0; j < ITERATE; j++) { - i = j++ & (ENTRIES - 1); - ck_pr_inc_int(&counters[i]); - ck_barrier_centralized(&barrier, &state, nthr); - counter = ck_pr_load_int(&counters[i]); - if (counter != nthr * (j / ENTRIES + 1)) { - ck_error("FAILED [%d:%d]: %d != %d\n", i, j - 1, counter, nthr); - } - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - int i; - - if (argc < 3) { - ck_error("Usage: correct \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - - return (0); -} - diff --git a/regressions/ck_barrier/validate/barrier_combining.c b/regressions/ck_barrier/validate/barrier_combining.c deleted file mode 100644 index 98fa0cf339d8..000000000000 --- a/regressions/ck_barrier/validate/barrier_combining.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -#ifndef ENTRIES -#define ENTRIES 512 -#endif - -static struct affinity a; -static int nthr; -static int ngroups; -static int counters[ENTRIES]; -static ck_barrier_combining_t barrier; -static int barrier_wait; - -static void * -thread(void *group) -{ - ck_barrier_combining_state_t state = CK_BARRIER_COMBINING_STATE_INITIALIZER; - int j, counter; - int i = 0; - - aff_iterate(&a); - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != (nthr * ngroups)) - ck_pr_stall(); - - for (j = 0; j < ITERATE; j++) { - i = j++ & (ENTRIES - 1); - ck_pr_inc_int(&counters[i]); - ck_barrier_combining(&barrier, group, &state); - counter = ck_pr_load_int(&counters[i]); - if (counter != nthr * ngroups * (j / ENTRIES + 1)) { - ck_error("FAILED [%d:%d]: %d != %d\n", i, j - 1, counter, nthr * ngroups); - } - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - ck_barrier_combining_group_t *groupings; - ck_barrier_combining_group_t *init_root; - int i; - - init_root = malloc(sizeof(ck_barrier_combining_group_t)); - if (init_root == NULL) { - ck_error("ERROR: Could not allocate initial barrier structure\n"); - } - ck_barrier_combining_init(&barrier, init_root); - - if (argc < 4) { - ck_error("Usage: correct \n"); - } - - ngroups = atoi(argv[1]); - if (ngroups <= 0) { - ck_error("ERROR: Number of groups must be greater than 0\n"); - } - - nthr = atoi(argv[2]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - groupings = malloc(sizeof(ck_barrier_combining_group_t) * ngroups); - if (groupings == NULL) { - ck_error("Could not allocate thread barrier grouping structures\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr * ngroups); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[3]); - - for (i = 0; i < ngroups; i++) - ck_barrier_combining_group_init(&barrier, groupings + i, nthr); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < (nthr * ngroups); i++) { - if (pthread_create(&threads[i], NULL, thread, groupings + (i % ngroups))) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < (nthr * ngroups); i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_barrier/validate/barrier_dissemination.c b/regressions/ck_barrier/validate/barrier_dissemination.c deleted file mode 100644 index e8acc10c7c7e..000000000000 --- a/regressions/ck_barrier/validate/barrier_dissemination.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -#ifndef ENTRIES -#define ENTRIES 512 -#endif - -static struct affinity a; -static int nthr; -static int counters[ENTRIES]; -static int barrier_wait; - -static void * -thread(void *b) -{ - ck_barrier_dissemination_t *barrier = b; - ck_barrier_dissemination_state_t state; - int j, k, counter; - int i = 0; - - aff_iterate(&a); - ck_barrier_dissemination_subscribe(barrier, &state); - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != nthr) - ck_pr_stall(); - - for (j = 0, k = 0; j < ITERATE; j++, k++) { - i = j++ & (ENTRIES - 1); - ck_pr_inc_int(&counters[i]); - ck_barrier_dissemination(barrier, &state); - counter = ck_pr_load_int(&counters[i]); - if (counter != nthr * (j / ENTRIES + 1)) { - ck_error("FAILED [%d:%d]: %d != %d\n", i, j - 1, counter, nthr); - } - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - ck_barrier_dissemination_t *barrier; - ck_barrier_dissemination_flag_t **barrier_internal; - pthread_t *threads; - int i, size; - - if (argc < 3) { - ck_error("Usage: correct \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - barrier = malloc(sizeof(ck_barrier_dissemination_t) * nthr); - if (barrier == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - - barrier_internal = malloc(sizeof(ck_barrier_dissemination_flag_t *) * nthr); - if (barrier_internal == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - - size = ck_barrier_dissemination_size(nthr); - for (i = 0; i < nthr; ++i) { - barrier_internal[i] = malloc(sizeof(ck_barrier_dissemination_flag_t) * size); - if (barrier_internal[i] == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - } - ck_barrier_dissemination_init(barrier, barrier_internal, nthr); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, barrier)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - - return (0); -} - diff --git a/regressions/ck_barrier/validate/barrier_mcs.c b/regressions/ck_barrier/validate/barrier_mcs.c deleted file mode 100644 index c2e3f2b08504..000000000000 --- a/regressions/ck_barrier/validate/barrier_mcs.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -#ifndef ENTRIES -#define ENTRIES 512 -#endif - -static struct affinity a; -static int nthr; -static int counters[ENTRIES]; -static int barrier_wait; - -static void * -thread(void *b) -{ - ck_barrier_mcs_t *barrier = b; - ck_barrier_mcs_state_t state; - int j, counter; - int i = 0; - - aff_iterate(&a); - - ck_barrier_mcs_subscribe(barrier, &state); - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != nthr) - ck_pr_stall(); - - for (j = 0; j < ITERATE; j++) { - i = j++ & (ENTRIES - 1); - ck_pr_inc_int(&counters[i]); - ck_barrier_mcs(barrier, &state); - counter = ck_pr_load_int(&counters[i]); - if (counter != nthr * (j / ENTRIES + 1)) { - ck_error("FAILED [%d:%d]: %d != %d\n", i, j - 1, counter, nthr); - } - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - ck_barrier_mcs_t *barrier; - int i; - - if (argc < 3) { - ck_error("Usage: correct \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - barrier = malloc(sizeof(ck_barrier_mcs_t) * nthr); - if (barrier == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - ck_barrier_mcs_init(barrier, nthr); - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, barrier)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - - return (0); -} - diff --git a/regressions/ck_barrier/validate/barrier_tournament.c b/regressions/ck_barrier/validate/barrier_tournament.c deleted file mode 100644 index f51dab8d64fe..000000000000 --- a/regressions/ck_barrier/validate/barrier_tournament.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -#ifndef ENTRIES -#define ENTRIES 512 -#endif - -static struct affinity a; -static int nthr; -static int counters[ENTRIES]; -static int barrier_wait; -static ck_barrier_tournament_t barrier; - -static void * -thread(CK_CC_UNUSED void *unused) -{ - ck_barrier_tournament_state_t state; - int j, counter; - int i = 0; - - aff_iterate(&a); - ck_barrier_tournament_subscribe(&barrier, &state); - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != nthr) - ck_pr_stall(); - - for (j = 0; j < ITERATE; j++) { - i = j++ & (ENTRIES - 1); - ck_pr_inc_int(&counters[i]); - ck_barrier_tournament(&barrier, &state); - counter = ck_pr_load_int(&counters[i]); - if (counter != nthr * (j / ENTRIES + 1)) { - ck_error("FAILED [%d:%d]: %d != %d\n", i, j - 1, counter, nthr); - } - } - - ck_pr_inc_int(&barrier_wait); - while (ck_pr_load_int(&barrier_wait) != nthr * 2) - ck_pr_stall(); - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - ck_barrier_tournament_round_t **rounds; - int i; - unsigned int size; - - if (argc < 3) { - ck_error("Usage: correct \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - a.delta = atoi(argv[2]); - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - rounds = malloc(sizeof(ck_barrier_tournament_round_t *) * nthr); - if (rounds == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - - size = ck_barrier_tournament_size(nthr); - for (i = 0; i < nthr; ++i) { - rounds[i] = malloc(sizeof(ck_barrier_tournament_round_t) * size); - if (rounds[i] == NULL) { - ck_error("ERROR: Could not allocate barrier structures\n"); - } - } - - ck_barrier_tournament_init(&barrier, rounds, nthr); - - fprintf(stderr, "Creating threads (barrier)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_bitmap/validate/Makefile b/regressions/ck_bitmap/validate/Makefile deleted file mode 100644 index 85e13c834990..000000000000 --- a/regressions/ck_bitmap/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean - -OBJECTS=serial - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_bitmap.h - $(CC) $(CFLAGS) -o serial serial.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -check: all - ./serial - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_bitmap/validate/serial.c b/regressions/ck_bitmap/validate/serial.c deleted file mode 100644 index ba52588b1e5d..000000000000 --- a/regressions/ck_bitmap/validate/serial.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * Copyright 2012-2014 AppNexus, Inc. - * Copyright 2012 Shreyas Prasad. - * Copyright 2014 Paul Khuong. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STATIC_LENGTH -#define STATIC_LENGTH 256 -#endif - -static unsigned int length = 256; -static ck_bitmap_t *g_bits; - -static void -check_iteration(ck_bitmap_t *bits, unsigned int len, bool initial) -{ - ck_bitmap_iterator_t iter; - unsigned int i = 0, j; - - len += 1; - if (initial == true) { - if (bits == g_bits) - len = length; - else - len = STATIC_LENGTH; - } - - ck_bitmap_iterator_init(&iter, bits); - for (j = 0; ck_bitmap_next(bits, &iter, &i) == true; j++) { - if (i == j) - continue; - - ck_error("[4] ERROR: Expected bit %u, got bit %u\n", j, i); - } - - if (j != len) { - ck_error("[5] ERROR: Expected length %u, got length %u\n", len, j); - } - - return; -} - -static void -test(ck_bitmap_t *bits, unsigned int n_length, bool initial) -{ - bool r; - unsigned int i; - CK_BITMAP_INSTANCE(8) u; - - CK_BITMAP_INIT(&u, 8, false); - CK_BITMAP_SET(&u, 1); - CK_BITMAP_SET(&u, 4); - - for (i = 0; i < n_length; i++) { - if (ck_bitmap_test(bits, i) == !initial) { - ck_error("[0] ERROR [%u]: Expected %u got %u\n", i, - initial, !initial); - } - } - - for (i = 0; i < n_length; i++) { - ck_bitmap_set(bits, i); - if (ck_bitmap_test(bits, i) == false) { - ck_error("[1] ERROR: Expected bit to be set: %u\n", i); - } - - ck_bitmap_reset(bits, i); - if (ck_bitmap_test(bits, i) == true) { - ck_error("[2] ERROR: Expected bit to be cleared: %u\n", i); - } - - r = ck_bitmap_bts(bits, i); - if (r == true) { - ck_error("[3] ERROR: Expected bit to be cleared before 1st bts: %u\n", i); - } - if (ck_bitmap_test(bits, i) == false) { - ck_error("[4] ERROR: Expected bit to be set: %u\n", i); - } - r = ck_bitmap_bts(bits, i); - if (r == false) { - ck_error("[5] ERROR: Expected bit to be set before 2nd bts: %u\n", i); - } - if (ck_bitmap_test(bits, i) == false) { - ck_error("[6] ERROR: Expected bit to be set: %u\n", i); - } - - ck_bitmap_reset(bits, i); - if (ck_bitmap_test(bits, i) == true) { - ck_error("[7] ERROR: Expected bit to be cleared: %u\n", i); - } - - ck_bitmap_set(bits, i); - if (ck_bitmap_test(bits, i) == false) { - ck_error("[8] ERROR: Expected bit to be set: %u\n", i); - } - - check_iteration(bits, i, initial); - } - - for (i = 0; i < n_length; i++) { - if (ck_bitmap_test(bits, i) == false) { - ck_error("[9] ERROR: Expected bit to be set: %u\n", i); - } - } - - ck_bitmap_clear(bits); - - for (i = 0; i < n_length; i++) { - if (ck_bitmap_test(bits, i) == true) { - ck_error("[10] ERROR: Expected bit to be reset: %u\n", i); - } - } - - ck_bitmap_union(bits, CK_BITMAP(&u)); - if (ck_bitmap_test(bits, 1) == false || - ck_bitmap_test(bits, 4) == false) { - ck_error("ERROR: Expected union semantics.\n"); - } - - return; -} - -static void -test_init(bool init) -{ - ck_bitmap_t *bitmap; - size_t bytes; - unsigned int i; - - bytes = ck_bitmap_size(length); - bitmap = malloc(bytes); - memset(bitmap, random(), bytes); - - ck_bitmap_init(bitmap, length, init); - - if (ck_bitmap_bits(bitmap) != length) { - ck_error("ERROR: Expected length %u got %u\n", - length, ck_bitmap_bits(bitmap)); - } - - for (i = 0; i < length; i++) { - if (ck_bitmap_test(bitmap, i) != init) { - ck_error("ERROR: Expected bit %i at index %u, got %i\n", - (int)init, i, (int)(!init)); - } - } - - free(bitmap); -} - -static ck_bitmap_t * -random_init(void) -{ - ck_bitmap_t *bitmap; - unsigned int i; - - bitmap = malloc(ck_bitmap_size(length)); - ck_bitmap_init(bitmap, length, false); - - for (i = 0; i < length; i++) { - if (random() & 1) { - ck_bitmap_set(bitmap, i); - } - } - - return bitmap; -} - -static ck_bitmap_t * -copy(const ck_bitmap_t *src) -{ - ck_bitmap_t *bitmap; - size_t bytes = ck_bitmap_size(ck_bitmap_bits(src)); - - bitmap = malloc(bytes); - memcpy(bitmap, src, bytes); - return bitmap; -} - -static void -test_counts(const ck_bitmap_t *x, const ck_bitmap_t *y) -{ - unsigned int count = 0; - unsigned int count_intersect = 0; - unsigned int i; - - for (i = 0; i <= length * 2; i++) { - unsigned actual_limit = i; - unsigned int r; - bool check; - - if (actual_limit > ck_bitmap_bits(x)) - actual_limit = ck_bitmap_bits(x); - - check = ck_bitmap_empty(x, i); - if (check != (count == 0)) { - ck_error("ck_bitmap_empty(%u): got %i expected %i\n", - i, (int)check, (int)(count == 0)); - } - - check = ck_bitmap_full(x, i); - if (check != (count == actual_limit)) { - ck_error("ck_bitmap_full(%u): got %i expected %i\n", - i, (int)check, (int)(count == i)); - } - - r = ck_bitmap_count(x, i); - if (r != count) { - ck_error("ck_bitmap_count(%u): got %u expected %u\n", - i, r, count); - } - - r = ck_bitmap_count_intersect(x, y, i); - if (r != count_intersect) { - ck_error("ck_bitmap_count_intersect(%u): got %u expected %u\n", - i, r, count_intersect); - } - - if (i < length) { - count += ck_bitmap_test(x, i); - count_intersect += ck_bitmap_test(x, i) & ck_bitmap_test(y, i); - } - } -} - -static void -random_test(unsigned int seed) -{ - ck_bitmap_t *x, *x_copy, *y; - unsigned int i; - - srandom(seed); - - test_init(false); - test_init(true); - - x = random_init(); - y = random_init(); - -#define TEST(routine, expected) do { \ - x_copy = copy(x); \ - routine(x_copy, y); \ - for (i = 0; i < length; i++) { \ - bool xi = ck_bitmap_test(x, i); \ - bool yi = ck_bitmap_test(y, i); \ - bool ri = ck_bitmap_test(x_copy, i); \ - bool wanted = expected(xi, yi); \ - \ - if (ri != wanted) { \ - ck_error("In " #routine " at %u: " \ - "got %i expected %i\n", \ - i, ri, wanted); \ - } \ - } \ - free(x_copy); \ - } while (0) - -#define OR(x, y) (x | y) -#define AND(x, y) (x & y) -#define ANDC2(x, y) (x & (~y)) - - TEST(ck_bitmap_union, OR); - TEST(ck_bitmap_intersection, AND); - TEST(ck_bitmap_intersection_negate, ANDC2); - -#undef ANDC2 -#undef AND -#undef OR -#undef TEST - - test_counts(x, y); - - for (i = 0; i < 4; i++) { - ck_bitmap_init(x, length, i & 1); - ck_bitmap_init(y, length, i >> 1); - test_counts(x, y); - } - - free(y); - free(x); -} - -int -main(int argc, char *argv[]) -{ - unsigned int bytes, base; - size_t i, j; - - if (argc >= 2) { - length = atoi(argv[1]); - } - - base = ck_bitmap_base(length); - bytes = ck_bitmap_size(length); - fprintf(stderr, "Configuration: %u bytes\n", - bytes); - - g_bits = malloc(bytes); - memset(g_bits->map, 0xFF, base); - ck_bitmap_init(g_bits, length, false); - test(g_bits, length, false); - - memset(g_bits->map, 0x00, base); - ck_bitmap_init(g_bits, length, true); - test(g_bits, length, true); - - ck_bitmap_test(g_bits, length - 1); - - CK_BITMAP_INSTANCE(STATIC_LENGTH) sb; - fprintf(stderr, "Static configuration: %zu bytes\n", - sizeof(sb)); - memset(CK_BITMAP_BUFFER(&sb), 0xFF, ck_bitmap_base(STATIC_LENGTH)); - CK_BITMAP_INIT(&sb, STATIC_LENGTH, false); - test(CK_BITMAP(&sb), STATIC_LENGTH, false); - memset(CK_BITMAP_BUFFER(&sb), 0x00, ck_bitmap_base(STATIC_LENGTH)); - CK_BITMAP_INIT(&sb, STATIC_LENGTH, true); - test(CK_BITMAP(&sb), STATIC_LENGTH, true); - - CK_BITMAP_CLEAR(&sb); - if (CK_BITMAP_TEST(&sb, 1) == true) { - ck_error("ERROR: Expected bit to be reset.\n"); - } - - CK_BITMAP_SET(&sb, 1); - if (CK_BITMAP_TEST(&sb, 1) == false) { - ck_error("ERROR: Expected bit to be set.\n"); - } - - CK_BITMAP_RESET(&sb, 1); - if (CK_BITMAP_TEST(&sb, 1) == true) { - ck_error("ERROR: Expected bit to be reset.\n"); - } - - for (i = 0; i < 4 * sizeof(unsigned int) * CHAR_BIT; i++) { - length = i; - for (j = 0; j < 10; j++) { - random_test(i * 10 + j); - } - } - - return 0; -} diff --git a/regressions/ck_brlock/benchmark/Makefile b/regressions/ck_brlock/benchmark/Makefile deleted file mode 100644 index cd12e7ca3428..000000000000 --- a/regressions/ck_brlock/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_brlock.h - $(CC) $(CFLAGS) -o latency latency.c - -throughput: throughput.c ../../../include/ck_brlock.h - $(CC) $(CFLAGS) -o throughput throughput.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_brlock/benchmark/latency.c b/regressions/ck_brlock/benchmark/latency.c deleted file mode 100644 index 4db8e269baad..000000000000 --- a/regressions/ck_brlock/benchmark/latency.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_brlock_t brlock = CK_BRLOCK_INITIALIZER; - ck_brlock_reader_t r[8]; - ck_rwlock_t naive; - - for (i = 0; i < sizeof(r) / sizeof(*r); i++) - ck_brlock_read_register(&brlock, &r[i]); - - for (i = 0; i < STEPS; i++) { - ck_brlock_write_lock(&brlock); - ck_brlock_write_unlock(&brlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_brlock_write_lock(&brlock); - ck_brlock_write_unlock(&brlock); - } - e_b = rdtsc(); - printf("WRITE: brlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - ck_rwlock_init(&naive); - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&naive); - ck_rwlock_write_unlock(&naive); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&naive); - ck_rwlock_write_unlock(&naive); - } - e_b = rdtsc(); - printf("WRITE: naive %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_brlock_read_lock(&brlock, &r[0]); - ck_brlock_read_unlock(&r[0]); - } - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_brlock_read_lock(&brlock, &r[0]); - ck_brlock_read_unlock(&r[0]); - } - e_b = rdtsc(); - printf("READ: brlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&naive); - ck_rwlock_read_unlock(&naive); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&naive); - ck_rwlock_read_unlock(&naive); - } - e_b = rdtsc(); - printf("READ: naive %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return (0); -} - diff --git a/regressions/ck_brlock/benchmark/throughput.c b/regressions/ck_brlock/benchmark/throughput.c deleted file mode 100644 index 27ed8036e50c..000000000000 --- a/regressions/ck_brlock/benchmark/throughput.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static int barrier; -static int threads; -static unsigned int flag CK_CC_CACHELINE; -static ck_brlock_t brlock = CK_BRLOCK_INITIALIZER; -static struct affinity affinity; - -static void * -thread_brlock(void *pun) -{ - uint64_t s_b, e_b, a, i; - ck_brlock_reader_t r; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_brlock_read_register(&brlock, &r); - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - ck_brlock_read_lock(&brlock, &r); - ck_brlock_read_unlock(&r); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int t; - pthread_t *p; - uint64_t *latency; - - if (argc != 3) { - ck_error("Usage: throughput \n"); - } - - threads = atoi(argv[2]); - if (threads <= 0) { - ck_error("ERROR: Threads must be a value > 0.\n"); - } - - p = malloc(sizeof(pthread_t) * threads); - if (p == NULL) { - ck_error("ERROR: Failed to initialize thread.\n"); - } - - latency = malloc(sizeof(uint64_t) * threads); - if (latency == NULL) { - ck_error("ERROR: Failed to create latency buffer.\n"); - } - - affinity.delta = atoi(argv[1]); - affinity.request = 0; - - fprintf(stderr, "Creating threads (brlock)..."); - for (t = 0; t < threads; t++) { - if (pthread_create(&p[t], NULL, thread_brlock, latency + t) != 0) { - ck_error("ERROR: Could not create thread %d\n", t); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (t = 0; t < threads; t++) - pthread_join(p[t], NULL); - fprintf(stderr, "done\n\n"); - - for (t = 1; t <= threads; t++) - printf("%10u %20" PRIu64 "\n", t, latency[t - 1]); - - return (0); -} - diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile deleted file mode 100644 index 3a49c43e4594..000000000000 --- a/regressions/ck_brlock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_brlock.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_brlock/validate/validate.c b/regressions/ck_brlock/validate/validate.c deleted file mode 100644 index 20f285a3da72..000000000000 --- a/regressions/ck_brlock/validate/validate.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked = 0; -static int nthr; -static ck_brlock_t lock = CK_BRLOCK_INITIALIZER; - -static void * -thread(void *null CK_CC_UNUSED) -{ - ck_brlock_reader_t r; - int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_brlock_read_register(&lock, &r); - - while (i--) { - ck_brlock_write_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_brlock_write_unlock(&lock); - - ck_brlock_read_lock(&lock, &r); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_brlock_read_unlock(&r); - } - - ck_brlock_read_unregister(&lock, &r); - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - int i; - - if (argc != 3) { - ck_error("Usage: validate \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (mutual exclusion)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_bytelock/benchmark/Makefile b/regressions/ck_bytelock/benchmark/Makefile deleted file mode 100644 index c8190995e55b..000000000000 --- a/regressions/ck_bytelock/benchmark/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency - -all: $(OBJECTS) - -latency: latency.c - $(CC) $(CFLAGS) -o latency latency.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/benchmark/latency.c b/regressions/ck_bytelock/benchmark/latency.c deleted file mode 100644 index be301656ef67..000000000000 --- a/regressions/ck_bytelock/benchmark/latency.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_bytelock_t bytelock = CK_BYTELOCK_INITIALIZER; - ck_rwlock_t naive; - - for (i = 0; i < STEPS; i++) { - ck_bytelock_write_lock(&bytelock, 1); - ck_bytelock_write_unlock(&bytelock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_bytelock_write_lock(&bytelock, 1); - ck_bytelock_write_unlock(&bytelock); - } - e_b = rdtsc(); - printf("WRITE: bytelock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - ck_rwlock_init(&naive); - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&naive); - ck_rwlock_write_unlock(&naive); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&naive); - ck_rwlock_write_unlock(&naive); - } - e_b = rdtsc(); - printf("WRITE: naive %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_bytelock_read_lock(&bytelock, 1); - ck_bytelock_read_unlock(&bytelock, 1); - } - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_bytelock_read_lock(&bytelock, 1); - ck_bytelock_read_unlock(&bytelock, 1); - } - e_b = rdtsc(); - printf("READ: bytelock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&naive); - ck_rwlock_read_unlock(&naive); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&naive); - ck_rwlock_read_unlock(&naive); - } - e_b = rdtsc(); - printf("READ: naive %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return (0); -} - diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile deleted file mode 100644 index 2a890e0c7110..000000000000 --- a/regressions/ck_bytelock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_bytelock.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_bytelock/validate/validate.c b/regressions/ck_bytelock/validate/validate.c deleted file mode 100644 index c164ce471706..000000000000 --- a/regressions/ck_bytelock/validate/validate.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 5000000 -#endif - -struct block { - unsigned int tid; -}; - -static struct affinity a; -static unsigned int locked = 0; -static int nthr; -static ck_bytelock_t lock CK_CC_CACHELINE = CK_BYTELOCK_INITIALIZER; - -static void * -thread(void *null) -{ - struct block *context = null; - int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - if (context->tid == (unsigned int)nthr - 1) - context->tid = sizeof(lock.readers) + 1; - - while (i--) { - ck_bytelock_write_lock(&lock, context->tid); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_bytelock_write_unlock(&lock); - - ck_bytelock_read_lock(&lock, context->tid); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_bytelock_read_unlock(&lock, context->tid); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - struct block *context; - int i; - - if (argc != 3) { - ck_error("Usage: correct \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - context = malloc(sizeof(struct block) * nthr); - if (context == NULL) { - ck_error("ERROR: Could not allocate thread contexts\n"); - } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (mutual exclusion)..."); - for (i = 0; i < nthr; i++) { - context[i].tid = i + 1; - if (pthread_create(&threads[i], NULL, thread, context + i)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_cohort/benchmark/Makefile b/regressions/ck_cohort/benchmark/Makefile deleted file mode 100644 index 6af18b9e06c3..000000000000 --- a/regressions/ck_cohort/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: all clean - -OBJECTS=ck_cohort.THROUGHPUT ck_cohort.LATENCY - -all: $(OBJECTS) - -ck_cohort.THROUGHPUT: ck_cohort.c - $(CC) $(CFLAGS) -o ck_cohort.THROUGHPUT throughput.c -lm - -ck_cohort.LATENCY: ck_cohort.c - $(CC) -DLATENCY $(CFLAGS) -o ck_cohort.LATENCY ck_cohort.c - -clean: - rm -rf *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_cohort/benchmark/ck_cohort.c b/regressions/ck_cohort/benchmark/ck_cohort.c deleted file mode 100644 index 954b616c9b15..000000000000 --- a/regressions/ck_cohort/benchmark/ck_cohort.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../ck_cohort.h" - -#include -#ifdef THROUGHPUT -#include "../../ck_spinlock/benchmark/throughput.h" -#elif defined(LATENCY) -#include "../../ck_spinlock/benchmark/latency.h" -#endif diff --git a/regressions/ck_cohort/benchmark/throughput.c b/regressions/ck_cohort/benchmark/throughput.c deleted file mode 100644 index 7c4776d3c308..000000000000 --- a/regressions/ck_cohort/benchmark/throughput.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * Copyright 2013 Brendon Scheinman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "../../common.h" - -#define max(x, y) (((x) > (y)) ? (x) : (y)) - -static struct affinity a; -static unsigned int ready; - -struct counters { - uint64_t value; -} CK_CC_CACHELINE; - -static struct counters *count; -static uint64_t nthr; -static unsigned int n_cohorts; -static unsigned int barrier; -static int critical CK_CC_CACHELINE; - -static void -ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - ck_spinlock_fas_lock(lock); - return; -} - -static void -ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - ck_spinlock_fas_unlock(lock); - return; -} - -static bool -ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - return ck_spinlock_fas_locked(lock); -} - -CK_COHORT_PROTOTYPE(basic, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) - -struct cohort_record { - CK_COHORT_INSTANCE(basic) cohort; -} CK_CC_CACHELINE; -static struct cohort_record *cohorts; - -static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; - -struct block { - unsigned int tid; -}; - -static void * -fairness(void *null) -{ - struct block *context = null; - unsigned int i = context->tid; - volatile int j; - long int base; - unsigned int core; - CK_COHORT_INSTANCE(basic) *cohort; - - - if (aff_iterate_core(&a, &core)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - cohort = &((cohorts + (core / (int)(a.delta)) % n_cohorts)->cohort); - - while (ck_pr_load_uint(&ready) == 0); - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) != nthr); - - while (ck_pr_load_uint(&ready)) { - CK_COHORT_LOCK(basic, cohort, NULL, NULL); - - count[i].value++; - if (critical) { - base = common_lrand48() % critical; - for (j = 0; j < base; j++); - } - - CK_COHORT_UNLOCK(basic, cohort, NULL, NULL); - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - uint64_t v, d; - unsigned int i; - pthread_t *threads; - struct block *context; - ck_spinlock_t *local_lock; - - if (argc != 5) { - ck_error("Usage: ck_cohort " - " \n"); - } - - n_cohorts = atoi(argv[1]); - if (n_cohorts <= 0) { - ck_error("ERROR: Number of cohorts must be greater than 0\n"); - } - - nthr = n_cohorts * atoi(argv[2]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - critical = atoi(argv[4]); - if (critical < 0) { - ck_error("ERROR: critical section cannot be negative\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - cohorts = malloc(sizeof(struct cohort_record) * n_cohorts); - if (cohorts == NULL) { - ck_error("ERROR: Could not allocate cohort structures\n"); - } - - context = malloc(sizeof(struct block) * nthr); - if (context == NULL) { - ck_error("ERROR: Could not allocate thread contexts\n"); - } - - a.delta = atoi(argv[2]); - a.request = 0; - - count = malloc(sizeof(*count) * nthr); - if (count == NULL) { - ck_error("ERROR: Could not create acquisition buffer\n"); - } - memset(count, 0, sizeof(*count) * nthr); - - fprintf(stderr, "Creating cohorts..."); - for (i = 0 ; i < n_cohorts ; i++) { - local_lock = malloc(max(CK_MD_CACHELINE, sizeof(ck_spinlock_t))); - if (local_lock == NULL) { - ck_error("ERROR: Could not allocate local lock\n"); - } - CK_COHORT_INIT(basic, &((cohorts + i)->cohort), &global_lock, local_lock, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - local_lock = NULL; - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Creating threads (fairness)..."); - for (i = 0; i < nthr; i++) { - context[i].tid = i; - if (pthread_create(&threads[i], NULL, fairness, context + i)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - ck_pr_store_uint(&ready, 1); - common_sleep(10); - ck_pr_store_uint(&ready, 0); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done\n\n"); - - for (i = 0, v = 0; i < nthr; i++) { - printf("%d %15" PRIu64 "\n", i, count[i].value); - v += count[i].value; - } - - printf("\n# total : %15" PRIu64 "\n", v); - printf("# throughput : %15" PRIu64 " a/s\n", (v /= nthr) / 10); - - for (i = 0, d = 0; i < nthr; i++) - d += (count[i].value - v) * (count[i].value - v); - - printf("# average : %15" PRIu64 "\n", v); - printf("# deviation : %.2f (%.2f%%)\n\n", sqrt(d / nthr), (sqrt(d / nthr) / v) * 100.00); - - return 0; -} diff --git a/regressions/ck_cohort/ck_cohort.h b/regressions/ck_cohort/ck_cohort.h deleted file mode 100644 index b0d7f0a483e1..000000000000 --- a/regressions/ck_cohort/ck_cohort.h +++ /dev/null @@ -1,35 +0,0 @@ -#define LOCK_NAME "ck_cohort" -#define LOCK_DEFINE \ - static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ - static ck_spinlock_fas_t local_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; \ - static void \ - ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) \ - { \ - (void)context; \ - ck_spinlock_fas_lock(lock); \ - } \ - \ - static void \ - ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) \ - { \ - (void)context; \ - ck_spinlock_fas_unlock(lock); \ - } \ - \ - static bool \ - ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) \ - { \ - (void)context; \ - return ck_spinlock_fas_locked(lock); \ - } \ - CK_COHORT_PROTOTYPE(fas_fas, \ - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, \ - ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context, \ - ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) \ - static CK_COHORT_INSTANCE(fas_fas) CK_CC_CACHELINE cohort = CK_COHORT_INITIALIZER - - -#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock, \ - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT) -#define LOCK CK_COHORT_LOCK(fas_fas, &cohort, NULL, NULL) -#define UNLOCK CK_COHORT_UNLOCK(fas_fas, &cohort, NULL, NULL) diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile deleted file mode 100644 index 145af3a58e76..000000000000 --- a/regressions/ck_cohort/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_cohort.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate `expr $(CORES) / 2` 2 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_cohort/validate/validate.c b/regressions/ck_cohort/validate/validate.c deleted file mode 100644 index cffbf77ce115..000000000000 --- a/regressions/ck_cohort/validate/validate.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * Copyright 2013 Brendon Scheinman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked; -static int nthr; -static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; - -static void -ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_lock(lock); -} - -static void -ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_unlock(lock); -} - -static bool -ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - return ck_spinlock_fas_locked(lock); -} - -static bool -ck_spinlock_fas_trylock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - return ck_spinlock_fas_trylock(lock); -} - -CK_COHORT_TRYLOCK_PROTOTYPE(fas_fas, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, - ck_spinlock_fas_locked_with_context, ck_spinlock_fas_trylock_with_context, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, - ck_spinlock_fas_locked_with_context, ck_spinlock_fas_trylock_with_context) -static CK_COHORT_INSTANCE(fas_fas) *cohorts; -static int n_cohorts; - -static void * -thread(void *null CK_CC_UNUSED) -{ - int i = ITERATE; - unsigned int l; - unsigned int core; - CK_COHORT_INSTANCE(fas_fas) *cohort; - - if (aff_iterate_core(&a, &core)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - cohort = cohorts + (core / (int)(a.delta)) % n_cohorts; - - while (i--) { - - if (i & 1) { - CK_COHORT_LOCK(fas_fas, cohort, NULL, NULL); - } else { - while (CK_COHORT_TRYLOCK(fas_fas, cohort, NULL, NULL, NULL) == false) { - ck_pr_stall(); - } - } - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - CK_COHORT_UNLOCK(fas_fas, cohort, NULL, NULL); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - int threads_per_cohort; - ck_spinlock_fas_t *local_lock; - int i; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - n_cohorts = atoi(argv[1]); - if (n_cohorts <= 0) { - fprintf(stderr, "setting number of cohorts per thread to 1\n"); - n_cohorts = 1; - } - - threads_per_cohort = atoi(argv[2]); - if (threads_per_cohort <= 0) { - ck_error("ERROR: Threads per cohort must be greater than 0\n"); - } - - nthr = n_cohorts * threads_per_cohort; - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[3]); - - fprintf(stderr, "Creating cohorts..."); - cohorts = malloc(sizeof(CK_COHORT_INSTANCE(fas_fas)) * n_cohorts); - for (i = 0 ; i < n_cohorts ; i++) { - local_lock = malloc(sizeof(ck_spinlock_fas_t)); - CK_COHORT_INIT(fas_fas, cohorts + i, &global_fas_lock, local_lock, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Creating threads..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile deleted file mode 100644 index 446c008a257f..000000000000 --- a/regressions/ck_epoch/validate/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll ck_epoch_call \ - ck_epoch_section ck_epoch_section_2 torture -HALF=`expr $(CORES) / 2` - -all: $(OBJECTS) - -check: all - ./ck_stack $(CORES) 1 - ./ck_epoch_synchronize $(HALF) $(HALF) 1 - ./ck_epoch_poll $(CORES) 1 1 - ./ck_epoch_section - ./ck_epoch_section_2 $(HALF) $(HALF) 1 - ./torture $(HALF) $(HALF) 1 - -ck_epoch_synchronize: ck_epoch_synchronize.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_epoch_synchronize ck_epoch_synchronize.c ../../../src/ck_epoch.c - -ck_epoch_poll: ck_epoch_poll.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_epoch_poll ck_epoch_poll.c ../../../src/ck_epoch.c - -torture: torture.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o torture torture.c ../../../src/ck_epoch.c - -ck_epoch_section: ck_epoch_section.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_epoch_section ck_epoch_section.c ../../../src/ck_epoch.c - -ck_epoch_section_2: ck_epoch_section_2.c ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_epoch_section_2 ck_epoch_section_2.c ../../../src/ck_epoch.c - -ck_epoch_call: ck_epoch_call.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_epoch_call ck_epoch_call.c ../../../src/ck_epoch.c - -ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c - $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_epoch/validate/ck_epoch_call.c b/regressions/ck_epoch/validate/ck_epoch_call.c deleted file mode 100644 index 29e0df841bd8..000000000000 --- a/regressions/ck_epoch/validate/ck_epoch_call.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2014 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -#include "../../common.h" - -static ck_epoch_t epoch; -static unsigned int counter; -static ck_epoch_record_t record[2]; - -static void -cb(ck_epoch_entry_t *p) -{ - - if (counter == 0) - ck_epoch_call(&record[1], p, cb); - - printf("Counter value: %u -> %u\n", - counter, counter + 1); - counter++; - return; -} - -int -main(void) -{ - ck_epoch_entry_t entry; - - ck_epoch_register(&epoch, &record[0]); - ck_epoch_register(&epoch, &record[1]); - - ck_epoch_call(&record[1], &entry, cb); - ck_epoch_barrier(&record[1]); - ck_epoch_barrier(&record[1]); - if (counter != 2) - ck_error("Expected counter value 2, read %u.\n", counter); - - return 0; -} diff --git a/regressions/ck_epoch/validate/ck_epoch_poll.c b/regressions/ck_epoch/validate/ck_epoch_poll.c deleted file mode 100644 index aec6dd096755..000000000000 --- a/regressions/ck_epoch/validate/ck_epoch_poll.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int n_rd; -static unsigned int n_wr; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int e_barrier; -static unsigned int readers; -static unsigned int writers; - -#ifndef PAIRS_S -#define PAIRS_S 100000 -#endif - -#ifndef ITERATE_S -#define ITERATE_S 20 -#endif - -struct node { - unsigned int value; - ck_stack_entry_t stack_entry; - ck_epoch_entry_t epoch_entry; -}; -static ck_stack_t stack = CK_STACK_INITIALIZER; -static ck_epoch_t stack_epoch; -CK_STACK_CONTAINER(struct node, stack_entry, stack_container) -CK_EPOCH_CONTAINER(struct node, epoch_entry, epoch_container) -static struct affinity a; -static const char animate[] = "-/|\\"; - -static void -destructor(ck_epoch_entry_t *p) -{ - struct node *e = epoch_container(p); - - free(e); - return; -} - -static void * -read_thread(void *unused CK_CC_UNUSED) -{ - unsigned int j; - ck_epoch_record_t record CK_CC_CACHELINE; - ck_stack_entry_t *cursor, *n; - - ck_epoch_register(&stack_epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - while (CK_STACK_ISEMPTY(&stack) == true) { - if (ck_pr_load_uint(&readers) != 0) - break; - - ck_pr_stall(); - } - - j = 0; - for (;;) { - ck_epoch_begin(&record, NULL); - CK_STACK_FOREACH(&stack, cursor) { - if (cursor == NULL) - continue; - - n = CK_STACK_NEXT(cursor); - j += ck_pr_load_ptr(&n) != NULL; - } - ck_epoch_end(&record, NULL); - - if (j != 0 && ck_pr_load_uint(&readers) == 0) - ck_pr_store_uint(&readers, 1); - - if (CK_STACK_ISEMPTY(&stack) == true && - ck_pr_load_uint(&e_barrier) != 0) - break; - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - - fprintf(stderr, "[R] Observed entries: %u\n", j); - return (NULL); -} - -static void * -write_thread(void *unused CK_CC_UNUSED) -{ - struct node **entry, *e; - unsigned int i, j, tid; - ck_epoch_record_t record; - ck_stack_entry_t *s; - - ck_epoch_register(&stack_epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_uint(&writers, 1); - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - entry = malloc(sizeof(struct node *) * PAIRS_S); - if (entry == NULL) { - ck_error("Failed allocation.\n"); - } - - for (j = 0; j < ITERATE_S; j++) { - for (i = 0; i < PAIRS_S; i++) { - entry[i] = malloc(sizeof(struct node)); - if (entry == NULL) { - ck_error("Failed individual allocation\n"); - } - } - - for (i = 0; i < PAIRS_S; i++) { - ck_stack_push_upmc(&stack, &entry[i]->stack_entry); - } - - while (ck_pr_load_uint(&readers) == 0) - ck_pr_stall(); - - if (tid == 0) { - fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[W] %2.2f: %c", - (double)j / ITERATE_S, animate[i % strlen(animate)]); - } - - for (i = 0; i < PAIRS_S; i++) { - ck_epoch_begin(&record, NULL); - s = ck_stack_pop_upmc(&stack); - e = stack_container(s); - ck_epoch_end(&record, NULL); - - ck_epoch_call(&record, &e->epoch_entry, destructor); - ck_epoch_poll(&record); - } - } - - ck_epoch_barrier(&record); - - if (tid == 0) { - fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b[W] Peak: %u (%2.2f%%)\n Reclamations: %lu\n\n", - record.n_peak, - (double)record.n_peak / ((double)PAIRS_S * ITERATE_S) * 100, - record.n_dispatch); - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack <#readers> <#writers> \n"); - } - - n_rd = atoi(argv[1]); - n_wr = atoi(argv[2]); - n_threads = n_wr + n_rd; - - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - ck_epoch_init(&stack_epoch); - - for (i = 0; i < n_rd; i++) - pthread_create(threads + i, NULL, read_thread, NULL); - - do { - pthread_create(threads + i, NULL, write_thread, NULL); - } while (++i < n_wr + n_rd); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return (0); -} diff --git a/regressions/ck_epoch/validate/ck_epoch_section.c b/regressions/ck_epoch/validate/ck_epoch_section.c deleted file mode 100644 index 12bcca17393a..000000000000 --- a/regressions/ck_epoch/validate/ck_epoch_section.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2015 John Esmet. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" - -static ck_epoch_t epc; -static ck_epoch_record_t record, record2; -static unsigned int cleanup_calls; - -static void -setup_test(void) -{ - - ck_epoch_init(&epc); - ck_epoch_register(&epc, &record); - ck_epoch_register(&epc, &record2); - cleanup_calls = 0; - - return; -} - -static void -teardown_test(void) -{ - - memset(&epc, 0, sizeof(ck_epoch_t)); - ck_epoch_unregister(&record); - memset(&record, 0, sizeof(ck_epoch_record_t)); - memset(&record2, 0, sizeof(ck_epoch_record_t)); - cleanup_calls = 0; - - return; -} - -static void -cleanup(ck_epoch_entry_t *e) -{ - (void) e; - - cleanup_calls++; - - return; -} - -static void -test_simple_read_section(void) -{ - ck_epoch_entry_t entry; - ck_epoch_section_t section; - - memset(&entry, 0, sizeof(ck_epoch_entry_t)); - setup_test(); - - ck_epoch_begin(&record, §ion); - ck_epoch_call(&record, &entry, cleanup); - assert(cleanup_calls == 0); - ck_epoch_end(&record, §ion); - ck_epoch_barrier(&record); - assert(cleanup_calls == 1); - - teardown_test(); - return; -} - -static void -test_nested_read_section(void) -{ - ck_epoch_entry_t entry1, entry2; - ck_epoch_section_t section1, section2; - - memset(&entry1, 0, sizeof(ck_epoch_entry_t)); - memset(&entry2, 0, sizeof(ck_epoch_entry_t)); - setup_test(); - - ck_epoch_begin(&record, §ion1); - ck_epoch_call(&record, &entry1, cleanup); - assert(cleanup_calls == 0); - - ck_epoch_begin(&record, §ion2); - ck_epoch_call(&record, &entry2, cleanup); - assert(cleanup_calls == 0); - - ck_epoch_end(&record, §ion2); - assert(cleanup_calls == 0); - - ck_epoch_end(&record, §ion1); - assert(cleanup_calls == 0); - - ck_epoch_barrier(&record); - assert(cleanup_calls == 2); - - teardown_test(); - return; -} - -struct obj { - ck_epoch_entry_t entry; - unsigned int destroyed; -}; - -static void * -barrier_work(void *arg) -{ - unsigned int *run; - - run = (unsigned int *)arg; - while (ck_pr_load_uint(run) != 0) { - /* - * Need to use record2, as record is local - * to the test thread. - */ - ck_epoch_barrier(&record2); - usleep(5 * 1000); - } - - return NULL; -} - -static void * -reader_work(void *arg) -{ - ck_epoch_record_t local_record; - ck_epoch_section_t section; - struct obj *o; - - ck_epoch_register(&epc, &local_record); - - o = (struct obj *)arg; - - /* - * Begin a read section. The calling thread has an open read section, - * so the object should not be destroyed for the lifetime of this - * thread. - */ - ck_epoch_begin(&local_record, §ion); - usleep((common_rand() % 100) * 1000); - assert(ck_pr_load_uint(&o->destroyed) == 0); - ck_epoch_end(&local_record, §ion); - - ck_epoch_unregister(&local_record); - - return NULL; -} - -static void -obj_destroy(ck_epoch_entry_t *e) -{ - struct obj *o; - - o = (struct obj *)e; - ck_pr_fas_uint(&o->destroyed, 1); - - return; -} - -static void -test_single_reader_with_barrier_thread(void) -{ - const int num_sections = 10; - struct obj o; - unsigned int run; - pthread_t thread; - ck_epoch_section_t sections[num_sections]; - int shuffled[num_sections]; - - run = 1; - memset(&o, 0, sizeof(struct obj)); - common_srand(time(NULL)); - setup_test(); - - if (pthread_create(&thread, NULL, barrier_work, &run) != 0) { - abort(); - } - - /* Start a bunch of sections. */ - for (int i = 0; i < num_sections; i++) { - ck_epoch_begin(&record, §ions[i]); - shuffled[i] = i; - if (i == num_sections / 2) { - usleep(1 * 1000); - } - } - - /* Generate a shuffle. */ - for (int i = num_sections - 1; i >= 0; i--) { - int k = common_rand() % (i + 1); - int tmp = shuffled[k]; - shuffled[k] = shuffled[i]; - shuffled[i] = tmp; - } - - ck_epoch_call(&record, &o.entry, obj_destroy); - - /* Close the sections in shuffle-order. */ - for (int i = 0; i < num_sections; i++) { - ck_epoch_end(&record, §ions[shuffled[i]]); - if (i != num_sections - 1) { - assert(ck_pr_load_uint(&o.destroyed) == 0); - usleep(3 * 1000); - } - } - - ck_pr_store_uint(&run, 0); - if (pthread_join(thread, NULL) != 0) { - abort(); - } - - ck_epoch_barrier(&record); - assert(ck_pr_load_uint(&o.destroyed) == 1); - - teardown_test(); - - return; -} - -static void -test_multiple_readers_with_barrier_thread(void) -{ - const int num_readers = 10; - struct obj o; - unsigned int run; - ck_epoch_section_t section; - pthread_t threads[num_readers + 1]; - - run = 1; - memset(&o, 0, sizeof(struct obj)); - memset(§ion, 0, sizeof(ck_epoch_section_t)); - common_srand(time(NULL)); - setup_test(); - - /* Create a thread to call barrier() while we create reader threads. - * Each barrier will attempt to move the global epoch forward so - * it will make the read section code coverage more interesting. */ - if (pthread_create(&threads[num_readers], NULL, - barrier_work, &run) != 0) { - abort(); - } - - ck_epoch_begin(&record, §ion); - ck_epoch_call(&record, &o.entry, obj_destroy); - - for (int i = 0; i < num_readers; i++) { - if (pthread_create(&threads[i], NULL, reader_work, &o) != 0) { - abort(); - } - } - - ck_epoch_end(&record, §ion); - - ck_pr_store_uint(&run, 0); - if (pthread_join(threads[num_readers], NULL) != 0) { - abort(); - } - - /* After the barrier, the object should be destroyed and readers - * should return. */ - for (int i = 0; i < num_readers; i++) { - if (pthread_join(threads[i], NULL) != 0) { - abort(); - } - } - - teardown_test(); - return; -} - -int -main(void) -{ - - test_simple_read_section(); - test_nested_read_section(); - test_single_reader_with_barrier_thread(); - test_multiple_readers_with_barrier_thread(); - - return 0; -} diff --git a/regressions/ck_epoch/validate/ck_epoch_section_2.c b/regressions/ck_epoch/validate/ck_epoch_section_2.c deleted file mode 100644 index ca183b1e0a61..000000000000 --- a/regressions/ck_epoch/validate/ck_epoch_section_2.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int n_rd; -static unsigned int n_wr; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int leave; - -#ifndef PAIRS_S -#define PAIRS_S 10000 -#endif - -#ifndef CK_EPOCH_T_DEPTH -#define CK_EPOCH_T_DEPTH 8 -#endif - -static ck_epoch_t epoch; -static struct affinity a; - -static void * -read_thread(void *unused CK_CC_UNUSED) -{ - ck_epoch_record_t *record; - unsigned long long i = 0; - - record = malloc(sizeof *record); - assert(record != NULL); - ck_epoch_register(&epoch, record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - for (;;) { - ck_epoch_section_t section[2]; - ck_epoch_section_t junk[CK_EPOCH_T_DEPTH]; - unsigned int j; - - ck_epoch_begin(record, §ion[0]); - - for (j = 0; j < CK_EPOCH_T_DEPTH; j++) - ck_epoch_begin(record, &junk[j]); - for (j = 0; j < CK_EPOCH_T_DEPTH; j++) - ck_epoch_end(record, &junk[j]); - - if (i > 0) - ck_epoch_end(record, §ion[1]); - - /* Wait for the next synchronize operation. */ - while ((ck_pr_load_uint(&epoch.epoch) & 1) == - section[0].bucket) { - i++; - - if (!(i % 10000000)) { - fprintf(stderr, "%u %u %u\n", - ck_pr_load_uint(&epoch.epoch), - section[0].bucket, record->epoch); - } - - while ((ck_pr_load_uint(&epoch.epoch) & 1) == - section[0].bucket) - ck_pr_stall(); - } - - ck_epoch_begin(record, §ion[1]); - - assert(section[0].bucket != section[1].bucket); - ck_epoch_end(record, §ion[0]); - - assert(ck_pr_load_uint(&record->active) > 0); - - if (ck_pr_load_uint(&leave) == 1) { - ck_epoch_end(record, §ion[1]); - break; - } - - i++; - } - - return NULL; -} - -static void * -write_thread(void *unused CK_CC_UNUSED) -{ - ck_epoch_record_t record; - unsigned long iterations = 0; - - ck_epoch_register(&epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - for (;;) { - if (!(iterations % 1048575)) - fprintf(stderr, "."); - - ck_epoch_synchronize(&record); - iterations++; - - if (ck_pr_load_uint(&leave) == 1) - break; - } - - fprintf(stderr, "%lu iterations\n", iterations); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack <#readers> <#writers> \n"); - } - - n_rd = atoi(argv[1]); - n_wr = atoi(argv[2]); - n_threads = n_wr + n_rd; - - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - ck_epoch_init(&epoch); - - for (i = 0; i < n_rd; i++) - pthread_create(threads + i, NULL, read_thread, NULL); - - do { - pthread_create(threads + i, NULL, write_thread, NULL); - } while (++i < n_wr + n_rd); - - common_sleep(10); - ck_pr_store_uint(&leave, 1); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return (0); -} diff --git a/regressions/ck_epoch/validate/ck_epoch_synchronize.c b/regressions/ck_epoch/validate/ck_epoch_synchronize.c deleted file mode 100644 index a03a4f73b0ce..000000000000 --- a/regressions/ck_epoch/validate/ck_epoch_synchronize.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int n_rd; -static unsigned int n_wr; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int e_barrier; -static unsigned int readers; -static unsigned int writers; - -#ifndef PAIRS_S -#define PAIRS_S 10000 -#endif - -#ifndef ITERATE_S -#define ITERATE_S 20 -#endif - -struct node { - unsigned int value; - ck_stack_entry_t stack_entry; - ck_epoch_entry_t epoch_entry; -}; -static ck_stack_t stack = CK_STACK_INITIALIZER; -static ck_epoch_t stack_epoch; -CK_STACK_CONTAINER(struct node, stack_entry, stack_container) -CK_EPOCH_CONTAINER(struct node, epoch_entry, epoch_container) -static struct affinity a; -static const char animate[] = "-/|\\"; - -static void -destructor(ck_epoch_entry_t *p) -{ - struct node *e = epoch_container(p); - - free(e); - return; -} - -static void * -read_thread(void *unused CK_CC_UNUSED) -{ - unsigned int j; - ck_epoch_record_t record CK_CC_CACHELINE; - ck_stack_entry_t *cursor; - ck_stack_entry_t *n; - unsigned int i; - - ck_epoch_register(&stack_epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - while (CK_STACK_ISEMPTY(&stack) == true) { - if (ck_pr_load_uint(&readers) != 0) - break; - - ck_pr_stall(); - } - - j = 0; - for (;;) { - i = 0; - - ck_epoch_begin(&record, NULL); - CK_STACK_FOREACH(&stack, cursor) { - if (cursor == NULL) - continue; - - n = CK_STACK_NEXT(cursor); - j += ck_pr_load_ptr(&n) != NULL; - - if (i++ > 4098) - break; - } - ck_epoch_end(&record, NULL); - - if (j != 0 && ck_pr_load_uint(&readers) == 0) - ck_pr_store_uint(&readers, 1); - - if (CK_STACK_ISEMPTY(&stack) == true && - ck_pr_load_uint(&e_barrier) != 0) - break; - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - - fprintf(stderr, "[R] Observed entries: %u\n", j); - return (NULL); -} - -static void * -write_thread(void *unused CK_CC_UNUSED) -{ - struct node **entry, *e; - unsigned int i, j, tid; - ck_epoch_record_t record; - ck_stack_entry_t *s; - - ck_epoch_register(&stack_epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_uint(&writers, 1); - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - entry = malloc(sizeof(struct node *) * PAIRS_S); - if (entry == NULL) { - ck_error("Failed allocation.\n"); - } - - for (j = 0; j < ITERATE_S; j++) { - for (i = 0; i < PAIRS_S; i++) { - entry[i] = malloc(sizeof(struct node)); - if (entry == NULL) { - ck_error("Failed individual allocation\n"); - } - } - - for (i = 0; i < PAIRS_S; i++) { - ck_stack_push_upmc(&stack, &entry[i]->stack_entry); - } - - while (ck_pr_load_uint(&readers) == 0) - ck_pr_stall(); - - for (i = 0; i < PAIRS_S; i++) { - ck_epoch_begin(&record, NULL); - s = ck_stack_pop_upmc(&stack); - e = stack_container(s); - ck_epoch_end(&record, NULL); - - if (i & 1) { - ck_epoch_synchronize(&record); - ck_epoch_reclaim(&record); - ck_epoch_call(&record, &e->epoch_entry, destructor); - } else { - ck_epoch_barrier(&record); - destructor(&e->epoch_entry); - } - - if (tid == 0 && (i % 16384) == 0) { - fprintf(stderr, "[W] %2.2f: %c\n", - (double)j / ITERATE_S, animate[i % strlen(animate)]); - } - } - } - - ck_epoch_synchronize(&record); - - if (tid == 0) { - fprintf(stderr, "[W] Peak: %u (%2.2f%%)\n Reclamations: %lu\n\n", - record.n_peak, - (double)record.n_peak / ((double)PAIRS_S * ITERATE_S) * 100, - record.n_dispatch); - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack <#readers> <#writers> \n"); - } - - n_rd = atoi(argv[1]); - n_wr = atoi(argv[2]); - n_threads = n_wr + n_rd; - - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - ck_epoch_init(&stack_epoch); - - for (i = 0; i < n_rd; i++) - pthread_create(threads + i, NULL, read_thread, NULL); - - do { - pthread_create(threads + i, NULL, write_thread, NULL); - } while (++i < n_wr + n_rd); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return (0); -} diff --git a/regressions/ck_epoch/validate/ck_stack.c b/regressions/ck_epoch/validate/ck_stack.c deleted file mode 100644 index fc502284c2cf..000000000000 --- a/regressions/ck_epoch/validate/ck_stack.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int e_barrier; - -#ifndef PAIRS -#define PAIRS 5000000 -#endif - -struct node { - unsigned int value; - ck_epoch_entry_t epoch_entry; - ck_stack_entry_t stack_entry; -}; -static ck_stack_t stack = {NULL, NULL}; -static ck_epoch_t stack_epoch; -CK_STACK_CONTAINER(struct node, stack_entry, stack_container) -CK_EPOCH_CONTAINER(struct node, epoch_entry, epoch_container) -static struct affinity a; - -static void -destructor(ck_epoch_entry_t *p) -{ - struct node *e = epoch_container(p); - - free(e); - return; -} - -static void * -thread(void *unused CK_CC_UNUSED) -{ - struct node **entry, *e; - ck_epoch_record_t record; - ck_stack_entry_t *s; - unsigned long smr = 0; - unsigned int i; - - ck_epoch_register(&stack_epoch, &record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - entry = malloc(sizeof(struct node *) * PAIRS); - if (entry == NULL) { - ck_error("Failed allocation.\n"); - } - - for (i = 0; i < PAIRS; i++) { - entry[i] = malloc(sizeof(struct node)); - if (entry == NULL) { - ck_error("Failed individual allocation\n"); - } - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - for (i = 0; i < PAIRS; i++) { - ck_epoch_begin(&record, NULL); - ck_stack_push_upmc(&stack, &entry[i]->stack_entry); - s = ck_stack_pop_upmc(&stack); - ck_epoch_end(&record, NULL); - - e = stack_container(s); - ck_epoch_call(&record, &e->epoch_entry, destructor); - smr += ck_epoch_poll(&record) == false; - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - - fprintf(stderr, "Deferrals: %lu (%2.2f)\n", smr, (double)smr / PAIRS); - fprintf(stderr, "Peak: %u (%2.2f%%), %u pending\nReclamations: %lu\n\n", - record.n_peak, - (double)record.n_peak / PAIRS * 100, - record.n_pending, - record.n_dispatch); - - ck_epoch_barrier(&record); - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < (n_threads << 1)); - - if (record.n_pending != 0) { - ck_error("ERROR: %u pending, expecting none.\n", - record.n_pending); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 3) { - ck_error("Usage: stack \n"); - } - - n_threads = atoi(argv[1]); - a.delta = atoi(argv[2]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - - ck_epoch_init(&stack_epoch); - - for (i = 0; i < n_threads; i++) - pthread_create(threads + i, NULL, thread, NULL); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return (0); -} diff --git a/regressions/ck_epoch/validate/torture.c b/regressions/ck_epoch/validate/torture.c deleted file mode 100644 index ce3c0498afb5..000000000000 --- a/regressions/ck_epoch/validate/torture.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int n_rd; -static unsigned int n_wr; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int leave; -static unsigned int first; - -struct { - unsigned int value; -} valid CK_CC_CACHELINE = { 1 }; - -struct { - unsigned int value; -} invalid CK_CC_CACHELINE; - -#ifndef PAIRS_S -#define PAIRS_S 10000 -#endif - -#ifndef CK_EPOCH_T_DEPTH -#define CK_EPOCH_T_DEPTH 8 -#endif - -static ck_epoch_t epoch; -static struct affinity a; - -static void -test(struct ck_epoch_record *record) -{ - unsigned int j[3]; - unsigned int b, c; - const unsigned int r = 100; - size_t i; - - for (i = 0; i < 8; i++) { - ck_epoch_begin(record, NULL); - c = ck_pr_load_uint(&invalid.value); - ck_pr_fence_load(); - b = ck_pr_load_uint(&valid.value); - ck_test(c > b, "Invalid value: %u > %u\n", c, b); - ck_epoch_end(record, NULL); - } - - ck_epoch_begin(record, NULL); - - /* This implies no early load of epoch occurs. */ - j[0] = record->epoch; - - - /* We should observe up to one epoch migration. */ - do { - ck_pr_fence_load(); - j[1] = ck_pr_load_uint(&epoch.epoch); - - if (ck_pr_load_uint(&leave) == 1) { - ck_epoch_end(record, NULL); - return; - } - } while (j[1] == j[0]); - - /* No more epoch migrations should occur */ - for (i = 0; i < r; i++) { - ck_pr_fence_strict_load(); - j[2] = ck_pr_load_uint(&epoch.epoch); - - ck_test(j[2] != j[1], "Inconsistency detected: %u %u %u\n", - j[0], j[1], j[2]); - } - - ck_epoch_end(record, NULL); - return; -} - -static void * -read_thread(void *unused CK_CC_UNUSED) -{ - ck_epoch_record_t *record; - - record = malloc(sizeof *record); - assert(record != NULL); - ck_epoch_register(&epoch, record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - do { - test(record); - test(record); - test(record); - test(record); - } while (ck_pr_load_uint(&leave) == 0); - - ck_pr_dec_uint(&n_rd); - - return NULL; -} - -static void * -write_thread(void *unused CK_CC_UNUSED) -{ - ck_epoch_record_t *record; - unsigned long iterations = 0; - bool c = ck_pr_faa_uint(&first, 1); - - record = malloc(sizeof *record); - assert(record != NULL); - ck_epoch_register(&epoch, record); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads); - - do { - /* - * A thread should never observe invalid.value > valid.value. - * inside a protected section. Only - * invalid.value <= valid.value is valid. - */ - if (!c) ck_pr_store_uint(&valid.value, 1); - ck_epoch_synchronize(record); - if (!c) ck_pr_store_uint(&invalid.value, 1); - - ck_pr_fence_store(); - if (!c) ck_pr_store_uint(&valid.value, 2); - ck_epoch_synchronize(record); - if (!c) ck_pr_store_uint(&invalid.value, 2); - - ck_pr_fence_store(); - if (!c) ck_pr_store_uint(&valid.value, 3); - ck_epoch_synchronize(record); - if (!c) ck_pr_store_uint(&invalid.value, 3); - - ck_pr_fence_store(); - if (!c) ck_pr_store_uint(&valid.value, 4); - ck_epoch_synchronize(record); - if (!c) ck_pr_store_uint(&invalid.value, 4); - - ck_epoch_synchronize(record); - if (!c) ck_pr_store_uint(&invalid.value, 0); - ck_epoch_synchronize(record); - - iterations += 4; - } while (ck_pr_load_uint(&leave) == 0 && - ck_pr_load_uint(&n_rd) > 0); - - fprintf(stderr, "%lu iterations\n", iterations); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack <#readers> <#writers> \n"); - } - - n_rd = atoi(argv[1]); - n_wr = atoi(argv[2]); - n_threads = n_wr + n_rd; - - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - ck_epoch_init(&epoch); - - for (i = 0; i < n_rd; i++) - pthread_create(threads + i, NULL, read_thread, NULL); - - do { - pthread_create(threads + i, NULL, write_thread, NULL); - } while (++i < n_wr + n_rd); - - common_sleep(30); - ck_pr_store_uint(&leave, 1); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return 0; -} diff --git a/regressions/ck_fifo/benchmark/Makefile b/regressions/ck_fifo/benchmark/Makefile deleted file mode 100644 index 6e2df2a3a8a5..000000000000 --- a/regressions/ck_fifo/benchmark/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency - -all: $(OBJECTS) - -latency: latency.c - $(CC) $(CFLAGS) -o latency latency.c - -clean: - rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/benchmark/latency.c b/regressions/ck_fifo/benchmark/latency.c deleted file mode 100644 index 267452f8063e..000000000000 --- a/regressions/ck_fifo/benchmark/latency.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ENTRIES -#define ENTRIES 4096 -#endif - -#ifndef STEPS -#define STEPS 40000 -#endif - -int -main(void) -{ - ck_spinlock_fas_t mutex = CK_SPINLOCK_FAS_INITIALIZER; - void *r; - uint64_t s, e, a; - unsigned int i; - unsigned int j; - -#if defined(CK_F_FIFO_SPSC) - ck_fifo_spsc_t spsc_fifo; - ck_fifo_spsc_entry_t spsc_entry[ENTRIES]; - ck_fifo_spsc_entry_t spsc_stub; -#endif - -#if defined(CK_F_FIFO_MPMC) - ck_fifo_mpmc_t mpmc_fifo; - ck_fifo_mpmc_entry_t mpmc_entry[ENTRIES]; - ck_fifo_mpmc_entry_t mpmc_stub; - ck_fifo_mpmc_entry_t *garbage; -#endif - -#ifdef CK_F_FIFO_SPSC - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_spsc_init(&spsc_fifo, &spsc_stub); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) { - ck_spinlock_fas_lock(&mutex); - ck_fifo_spsc_enqueue(&spsc_fifo, spsc_entry + j, NULL); - ck_spinlock_fas_unlock(&mutex); - } - e = rdtsc(); - - a += e - s; - } - printf(" spinlock_enqueue: %16" PRIu64 "\n", a / STEPS / (sizeof(spsc_entry) / sizeof(*spsc_entry))); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_spsc_init(&spsc_fifo, &spsc_stub); - for (j = 0; j < ENTRIES; j++) - ck_fifo_spsc_enqueue(&spsc_fifo, spsc_entry + j, NULL); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) { - ck_spinlock_fas_lock(&mutex); - ck_fifo_spsc_dequeue(&spsc_fifo, &r); - ck_spinlock_fas_unlock(&mutex); - } - e = rdtsc(); - a += e - s; - } - printf(" spinlock_dequeue: %16" PRIu64 "\n", a / STEPS / (sizeof(spsc_entry) / sizeof(*spsc_entry))); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_spsc_init(&spsc_fifo, &spsc_stub); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_fifo_spsc_enqueue(&spsc_fifo, spsc_entry + j, NULL); - e = rdtsc(); - - a += e - s; - } - printf("ck_fifo_spsc_enqueue: %16" PRIu64 "\n", a / STEPS / (sizeof(spsc_entry) / sizeof(*spsc_entry))); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_spsc_init(&spsc_fifo, &spsc_stub); - for (j = 0; j < ENTRIES; j++) - ck_fifo_spsc_enqueue(&spsc_fifo, spsc_entry + j, NULL); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_fifo_spsc_dequeue(&spsc_fifo, &r); - e = rdtsc(); - a += e - s; - } - printf("ck_fifo_spsc_dequeue: %16" PRIu64 "\n", a / STEPS / (sizeof(spsc_entry) / sizeof(*spsc_entry))); -#endif - -#ifdef CK_F_FIFO_MPMC - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_mpmc_init(&mpmc_fifo, &mpmc_stub); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_fifo_mpmc_enqueue(&mpmc_fifo, mpmc_entry + j, NULL); - e = rdtsc(); - - a += e - s; - } - printf("ck_fifo_mpmc_enqueue: %16" PRIu64 "\n", a / STEPS / (sizeof(mpmc_entry) / sizeof(*mpmc_entry))); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_fifo_mpmc_init(&mpmc_fifo, &mpmc_stub); - for (j = 0; j < ENTRIES; j++) - ck_fifo_mpmc_enqueue(&mpmc_fifo, mpmc_entry + j, NULL); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_fifo_mpmc_dequeue(&mpmc_fifo, &r, &garbage); - e = rdtsc(); - a += e - s; - } - printf("ck_fifo_mpmc_dequeue: %16" PRIu64 "\n", a / STEPS / (sizeof(mpmc_entry) / sizeof(*mpmc_entry))); -#endif - - return 0; -} diff --git a/regressions/ck_fifo/validate/Makefile b/regressions/ck_fifo/validate/Makefile deleted file mode 100644 index 6bfc696ddb9b..000000000000 --- a/regressions/ck_fifo/validate/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_fifo_spsc ck_fifo_mpmc ck_fifo_spsc_iterator ck_fifo_mpmc_iterator - -all: $(OBJECTS) - -check: all - ./ck_fifo_spsc $(CORES) 1 64000 - ./ck_fifo_mpmc $(CORES) 1 16000 - ./ck_fifo_spsc_iterator - ./ck_fifo_mpmc_iterator - -ck_fifo_spsc: ck_fifo_spsc.c ../../../include/ck_fifo.h - $(CC) $(CFLAGS) -o ck_fifo_spsc ck_fifo_spsc.c - -ck_fifo_mpmc: ck_fifo_mpmc.c ../../../include/ck_fifo.h - $(CC) $(CFLAGS) -o ck_fifo_mpmc ck_fifo_mpmc.c - -ck_fifo_spsc_iterator: ck_fifo_spsc_iterator.c ../../../include/ck_fifo.h - $(CC) $(CFLAGS) -o ck_fifo_spsc_iterator ck_fifo_spsc_iterator.c - -ck_fifo_mpmc_iterator: ck_fifo_mpmc_iterator.c ../../../include/ck_fifo.h - $(CC) $(CFLAGS) -o ck_fifo_mpmc_iterator ck_fifo_mpmc_iterator.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_fifo/validate/ck_fifo_mpmc.c b/regressions/ck_fifo/validate/ck_fifo_mpmc.c deleted file mode 100644 index 89eb2f4d8e57..000000000000 --- a/regressions/ck_fifo/validate/ck_fifo_mpmc.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifdef CK_F_FIFO_MPMC -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; -}; - -struct entry { - int tid; - int value; -}; - -static int nthr; - -#ifdef CK_F_FIFO_MPMC -static ck_fifo_mpmc_t fifo CK_CC_CACHELINE; -#endif - -static struct affinity a; -static int size; -static unsigned int barrier; - -static void * -test(void *c) -{ -#ifdef CK_F_FIFO_MPMC - struct context *context = c; - struct entry *entry; - ck_fifo_mpmc_entry_t *fifo_entry, *garbage; - int i, j; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < (unsigned int)nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - fifo_entry = malloc(sizeof(ck_fifo_mpmc_entry_t)); - entry = malloc(sizeof(struct entry)); - entry->tid = context->tid; - ck_fifo_mpmc_enqueue(&fifo, fifo_entry, entry); - if (ck_fifo_mpmc_dequeue(&fifo, &entry, &garbage) == false) { - ck_error("ERROR [%u] Queue should never be empty.\n", context->tid); - } - - if (entry->tid < 0 || entry->tid >= nthr) { - ck_error("ERROR [%u] Incorrect value in entry.\n", entry->tid); - } - } - } - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - fifo_entry = malloc(sizeof(ck_fifo_mpmc_entry_t)); - entry = malloc(sizeof(struct entry)); - entry->tid = context->tid; - while (ck_fifo_mpmc_tryenqueue(&fifo, fifo_entry, entry) == false) - ck_pr_stall(); - - while (ck_fifo_mpmc_trydequeue(&fifo, &entry, &garbage) == false) - ck_pr_stall(); - - if (entry->tid < 0 || entry->tid >= nthr) { - ck_error("ERROR [%u] Incorrect value in entry when using try interface.\n", entry->tid); - } - } - } -#endif - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - int i, r; - struct context *context; - ck_fifo_mpmc_entry_t *garbage; - pthread_t *thread; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size > 0); - - context = malloc(sizeof(*context) * nthr); - assert(context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - ck_fifo_mpmc_init(&fifo, malloc(sizeof(ck_fifo_mpmc_entry_t))); - ck_fifo_mpmc_deinit(&fifo, &garbage); - if (garbage == NULL) - ck_error("ERROR: Expected non-NULL stub node on deinit.\n"); - free(garbage); - ck_fifo_mpmc_init(&fifo, malloc(sizeof(ck_fifo_mpmc_entry_t))); - - for (i = 0; i < nthr; i++) { - context[i].tid = i; - r = pthread_create(thread + i, NULL, test, context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - return (0); -} -#else -int -main(void) -{ - fprintf(stderr, "Unsupported.\n"); - return 0; -} -#endif - diff --git a/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c b/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c deleted file mode 100644 index 5ac81757f2cb..000000000000 --- a/regressions/ck_fifo/validate/ck_fifo_mpmc_iterator.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#ifdef CK_F_FIFO_MPMC -struct example { - int x; -}; - -static ck_fifo_mpmc_t mpmc_fifo; - -int -main(void) -{ - int i, length = 3; - struct example *examples; - ck_fifo_mpmc_entry_t *stub, *entries, *entry, *next; - - stub = malloc(sizeof(ck_fifo_mpmc_entry_t)); - if (stub == NULL) - exit(EXIT_FAILURE); - - ck_fifo_mpmc_init(&mpmc_fifo, stub); - - entries = malloc(sizeof(ck_fifo_mpmc_entry_t) * length); - if (entries == NULL) - exit(EXIT_FAILURE); - - examples = malloc(sizeof(struct example) * length); - /* Need these for this unit test. */ - if (examples == NULL) - exit(EXIT_FAILURE); - - for (i = 0; i < length; ++i) { - examples[i].x = i; - ck_fifo_mpmc_enqueue(&mpmc_fifo, entries + i, examples + i); - } - - puts("Testing CK_FIFO_MPMC_FOREACH."); - CK_FIFO_MPMC_FOREACH(&mpmc_fifo, entry) { - printf("Next value in fifo: %d\n", ((struct example *)entry->value)->x); - } - - puts("Testing CK_FIFO_MPMC_FOREACH_SAFE."); - CK_FIFO_MPMC_FOREACH_SAFE(&mpmc_fifo, entry, next) { - if (entry->next.pointer != next) - exit(EXIT_FAILURE); - printf("Next value in fifo: %d\n", ((struct example *)entry->value)->x); - } - - free(examples); - free(entries); - free(stub); - - return (0); -} -#else -int -main(void) -{ - return (0); -} -#endif diff --git a/regressions/ck_fifo/validate/ck_fifo_spsc.c b/regressions/ck_fifo/validate/ck_fifo_spsc.c deleted file mode 100644 index 3d6c38c199c4..000000000000 --- a/regressions/ck_fifo/validate/ck_fifo_spsc.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include - -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; -}; - -struct entry { - int tid; - int value; -}; - -static int nthr; -static ck_fifo_spsc_t *fifo; -static struct affinity a; -static int size; -static unsigned int barrier; - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - ck_fifo_spsc_entry_t *fifo_entry; - int i, j; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - -#ifdef DEBUG - fprintf(stderr, "%p %u: %u -> %u\n", fifo+context->tid, context->tid, context->previous, context->tid); -#endif - - if (context->tid == 0) { - struct entry *entries; - - entries = malloc(sizeof(struct entry) * size); - assert(entries != NULL); - - for (i = 0; i < size; i++) { - entries[i].value = i; - entries[i].tid = 0; - - fifo_entry = malloc(sizeof(ck_fifo_spsc_entry_t)); - ck_fifo_spsc_enqueue(fifo + context->tid, fifo_entry, entries + i); - } - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < (unsigned int)nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - while (ck_fifo_spsc_dequeue(fifo + context->previous, &entry) == false); - if (context->previous != (unsigned int)entry->tid) { - ck_error("T [%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - if (entry->value != j) { - ck_error("V [%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->value, j); - } - - entry->tid = context->tid; - fifo_entry = ck_fifo_spsc_recycle(fifo + context->tid); - if (fifo_entry == NULL) - fifo_entry = malloc(sizeof(ck_fifo_spsc_entry_t)); - - ck_fifo_spsc_enqueue(fifo + context->tid, fifo_entry, entry); - } - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - int i, r; - struct context *context; - pthread_t *thread; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size > 0); - - fifo = malloc(sizeof(ck_fifo_spsc_t) * nthr); - assert(fifo); - - context = malloc(sizeof(*context) * nthr); - assert(context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - for (i = 0; i < nthr; i++) { - ck_fifo_spsc_entry_t *garbage; - - context[i].tid = i; - if (i == 0) { - context[i].previous = nthr - 1; - context[i].next = i + 1; - } else if (i == nthr - 1) { - context[i].next = 0; - context[i].previous = i - 1; - } else { - context[i].next = i + 1; - context[i].previous = i - 1; - } - - ck_fifo_spsc_init(fifo + i, malloc(sizeof(ck_fifo_spsc_entry_t))); - ck_fifo_spsc_deinit(fifo + i, &garbage); - if (garbage == NULL) - ck_error("ERROR: Expected non-NULL stub node on deinit.\n"); - - free(garbage); - ck_fifo_spsc_init(fifo + i, malloc(sizeof(ck_fifo_spsc_entry_t))); - r = pthread_create(thread + i, NULL, test, context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - return (0); -} - diff --git a/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c b/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c deleted file mode 100644 index 97804de0786f..000000000000 --- a/regressions/ck_fifo/validate/ck_fifo_spsc_iterator.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -struct example { - int x; -}; - -static ck_fifo_spsc_t spsc_fifo; - -int -main(void) -{ - int i, length = 3; - struct example *examples; - ck_fifo_spsc_entry_t *stub, *entries, *entry, *next; - - stub = malloc(sizeof(ck_fifo_spsc_entry_t)); - if (stub == NULL) - exit(EXIT_FAILURE); - - ck_fifo_spsc_init(&spsc_fifo, stub); - - entries = malloc(sizeof(ck_fifo_spsc_entry_t) * length); - if (entries == NULL) - exit(EXIT_FAILURE); - - examples = malloc(sizeof(struct example) * length); - /* Need these for this unit test. */ - if (examples == NULL) - exit(EXIT_FAILURE); - - for (i = 0; i < length; ++i) { - examples[i].x = i; - ck_fifo_spsc_enqueue(&spsc_fifo, entries + i, examples + i); - } - - puts("Testing CK_FIFO_SPSC_FOREACH."); - CK_FIFO_SPSC_FOREACH(&spsc_fifo, entry) { - printf("Next value in fifo: %d\n", ((struct example *)entry->value)->x); - } - - puts("Testing CK_FIFO_SPSC_FOREACH_SAFE."); - CK_FIFO_SPSC_FOREACH_SAFE(&spsc_fifo, entry, next) { - if (entry->next != next) - exit(EXIT_FAILURE); - printf("Next value in fifo: %d\n", ((struct example *)entry->value)->x); - } - - free(examples); - free(entries); - free(stub); - - return (0); -} - diff --git a/regressions/ck_hp/benchmark/Makefile b/regressions/ck_hp/benchmark/Makefile deleted file mode 100644 index 2025ea9957f8..000000000000 --- a/regressions/ck_hp/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=fifo_latency stack_latency - -all: $(OBJECTS) - -fifo_latency: fifo_latency.c - $(CC) $(CFLAGS) -o fifo_latency ../../../src/ck_hp.c fifo_latency.c - -stack_latency: stack_latency.c - $(CC) $(CFLAGS) -o stack_latency ../../../src/ck_hp.c stack_latency.c - -clean: - rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/benchmark/fifo_latency.c b/regressions/ck_hp/benchmark/fifo_latency.c deleted file mode 100644 index 77ee2a729be4..000000000000 --- a/regressions/ck_hp/benchmark/fifo_latency.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ENTRIES -#define ENTRIES 4096 -#endif - -#ifndef STEPS -#define STEPS 40000 -#endif - -static ck_hp_fifo_t fifo; -static ck_hp_t fifo_hp; - -int -main(void) -{ - void *r; - uint64_t s, e, a; - unsigned int i; - unsigned int j; - ck_hp_fifo_entry_t hp_entry[ENTRIES]; - ck_hp_fifo_entry_t hp_stub; - ck_hp_record_t record; - - ck_hp_init(&fifo_hp, CK_HP_FIFO_SLOTS_COUNT, 1000000, NULL); - - r = malloc(CK_HP_FIFO_SLOTS_SIZE); - if (r == NULL) { - ck_error("ERROR: Failed to allocate slots.\n"); - } - ck_hp_register(&fifo_hp, &record, r); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_hp_fifo_init(&fifo, &hp_stub); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_hp_fifo_enqueue_mpmc(&record, &fifo, hp_entry + j, NULL); - e = rdtsc(); - - a += e - s; - } - printf("ck_hp_fifo_enqueue_mpmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_hp_fifo_init(&fifo, &hp_stub); - for (j = 0; j < ENTRIES; j++) - ck_hp_fifo_enqueue_mpmc(&record, &fifo, hp_entry + j, NULL); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_hp_fifo_dequeue_mpmc(&record, &fifo, &r); - e = rdtsc(); - a += e - s; - } - printf("ck_hp_fifo_dequeue_mpmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); - - return 0; -} diff --git a/regressions/ck_hp/benchmark/stack_latency.c b/regressions/ck_hp/benchmark/stack_latency.c deleted file mode 100644 index c336de6bc5d8..000000000000 --- a/regressions/ck_hp/benchmark/stack_latency.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ENTRIES -#define ENTRIES 4096 -#endif - -#ifndef STEPS -#define STEPS 40000 -#endif - -static ck_stack_t stack; -static ck_hp_t stack_hp; - -int -main(void) -{ - ck_hp_record_t record; - ck_stack_entry_t entry[ENTRIES]; - uint64_t s, e, a; - unsigned int i; - unsigned int j; - void *r; - - ck_hp_init(&stack_hp, CK_HP_STACK_SLOTS_COUNT, 1000000, NULL); - r = malloc(CK_HP_STACK_SLOTS_SIZE); - if (r == NULL) { - ck_error("ERROR: Failed to allocate slots.\n"); - } - ck_hp_register(&stack_hp, &record, (void *)r); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_hp_stack_push_mpmc(&stack, entry + j); - e = rdtsc(); - - a += e - s; - } - printf("ck_hp_stack_push_mpmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - for (j = 0; j < ENTRIES; j++) - ck_hp_stack_push_mpmc(&stack, entry + j); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) { - r = ck_hp_stack_pop_mpmc(&record, &stack); - } - e = rdtsc(); - a += e - s; - } - printf(" ck_hp_stack_pop_mpmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); - - return 0; -} diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile deleted file mode 100644 index 476b34fabea9..000000000000 --- a/regressions/ck_hp/validate/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_hp_stack nbds_haz_test serial ck_hp_fifo ck_hp_fifo_donner - -all: $(OBJECTS) - -check: all - ./serial - ./ck_hp_stack $(CORES) 100 1 - ./ck_hp_fifo $(CORES) 1 16384 100 - ./nbds_haz_test $(CORES) 15 1 - ./ck_hp_fifo_donner $(CORES) 16384 - -ck_hp_stack: ../../../src/ck_hp.c ck_hp_stack.c ../../../include/ck_hp_stack.h - $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_stack ck_hp_stack.c - -ck_hp_fifo: ../../../src/ck_hp.c ck_hp_fifo.c ../../../include/ck_hp_fifo.h - $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo ck_hp_fifo.c - -ck_hp_fifo_donner: ../../../src/ck_hp.c ck_hp_fifo_donner.c ../../../include/ck_hp_fifo.h - $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_fifo_donner ck_hp_fifo_donner.c - -serial: ../../../src/ck_hp.c serial.c ../../../include/ck_hp_stack.h - $(CC) $(CFLAGS) ../../../src/ck_hp.c -o serial serial.c - -nbds_haz_test: ../../../src/ck_hp.c nbds_haz_test.c - $(CC) $(CFLAGS) ../../../src/ck_hp.c -o nbds_haz_test nbds_haz_test.c - -clean: - rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_hp/validate/ck_hp_fifo.c b/regressions/ck_hp/validate/ck_hp_fifo.c deleted file mode 100644 index 4454283c1f2b..000000000000 --- a/regressions/ck_hp/validate/ck_hp_fifo.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; -}; - -struct entry { - int tid; - int value; -}; - -static ck_hp_fifo_t fifo; -static ck_hp_t fifo_hp; -static int nthr; - -static struct affinity a; -static int size; -static unsigned int barrier; -static unsigned int e_barrier; - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - ck_hp_fifo_entry_t *fifo_entry; - ck_hp_record_t record; - int i, j; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_hp_register(&fifo_hp, &record, malloc(sizeof(void *) * 2)); - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < (unsigned int)nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - fifo_entry = malloc(sizeof(ck_hp_fifo_entry_t)); - entry = malloc(sizeof(struct entry)); - entry->tid = context->tid; - ck_hp_fifo_enqueue_mpmc(&record, &fifo, fifo_entry, entry); - - ck_pr_barrier(); - - fifo_entry = ck_hp_fifo_dequeue_mpmc(&record, &fifo, &entry); - if (fifo_entry == NULL) { - ck_error("ERROR [%u] Queue should never be empty.\n", context->tid); - } - - ck_pr_barrier(); - - if (entry->tid < 0 || entry->tid >= nthr) { - ck_error("ERROR [%u] Incorrect value in entry.\n", entry->tid); - } - - ck_hp_free(&record, &fifo_entry->hazard, fifo_entry, fifo_entry); - } - } - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - fifo_entry = malloc(sizeof(ck_hp_fifo_entry_t)); - entry = malloc(sizeof(struct entry)); - entry->tid = context->tid; - - while (ck_hp_fifo_tryenqueue_mpmc(&record, &fifo, fifo_entry, entry) == false) - ck_pr_stall(); - - while (fifo_entry = ck_hp_fifo_trydequeue_mpmc(&record, &fifo, &entry), fifo_entry == NULL) - ck_pr_stall(); - - if (entry->tid < 0 || entry->tid >= nthr) { - ck_error("ERROR [%u] Incorrect value in entry.\n", entry->tid); - } - - ck_hp_free(&record, &fifo_entry->hazard, fifo_entry, fifo_entry); - } - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < (unsigned int)nthr); - - return (NULL); -} - -static void -destructor(void *p) -{ - - free(p); - return; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - struct context *context; - pthread_t *thread; - int threshold; - - if (argc != 5) { - ck_error("Usage: validate \n"); - } - - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size > 0); - - threshold = atoi(argv[4]); - assert(threshold > 0); - - context = malloc(sizeof(*context) * nthr); - assert(context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - ck_hp_init(&fifo_hp, 2, threshold, destructor); - ck_hp_fifo_init(&fifo, malloc(sizeof(ck_hp_fifo_entry_t))); - - ck_hp_fifo_entry_t *entry; - ck_hp_fifo_deinit(&fifo, &entry); - - if (entry == NULL) - ck_error("ERROR: Expected non-NULL stub node.\n"); - - free(entry); - ck_hp_fifo_init(&fifo, malloc(sizeof(ck_hp_fifo_entry_t))); - - for (i = 0; i < nthr; i++) { - context[i].tid = i; - r = pthread_create(thread + i, NULL, test, context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - return (0); -} - diff --git a/regressions/ck_hp/validate/ck_hp_fifo_donner.c b/regressions/ck_hp/validate/ck_hp_fifo_donner.c deleted file mode 100644 index 1b52a3754f33..000000000000 --- a/regressions/ck_hp/validate/ck_hp_fifo_donner.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2012 Hendrik Donner - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../common.h" - -/* FIFO queue */ -static ck_hp_fifo_t fifo; - -/* Hazard pointer global */ -static ck_hp_t fifo_hp; - -/* thread local element count */ -static unsigned long *count; - -static unsigned long thread_count; - -static unsigned int start_barrier; -static unsigned int end_barrier; - -/* destructor for FIFO queue */ -static void -destructor(void *p) -{ - - free(p); - return; -} - -/* entry struct for FIFO queue entries */ -struct entry { - unsigned long value; -}; - -/* function for thread */ -static void * -queue_50_50(void *elements) -{ - struct entry *entry; - ck_hp_fifo_entry_t *fifo_entry; - ck_hp_record_t *record; - void *slots; - unsigned long j, element_count = *(unsigned long *)elements; - unsigned int seed; - - record = malloc(sizeof(ck_hp_record_t)); - assert(record); - - slots = malloc(CK_HP_FIFO_SLOTS_SIZE); - assert(slots); - - /* different seed for each thread */ - seed = 1337; /*(unsigned int) pthread_self(); */ - - /* - * This subscribes the thread to the fifo_hp state using the thread-owned - * record. - * FIFO queue needs 2 hazard pointers. - */ - ck_hp_register(&fifo_hp, record, slots); - - /* start barrier */ - ck_pr_inc_uint(&start_barrier); - while (ck_pr_load_uint(&start_barrier) < thread_count + 1) - ck_pr_stall(); - - /* 50/50 enqueue-dequeue */ - for(j = 0; j < element_count; j++) { - /* rand_r with thread local state should be thread safe */ - if( 50 < (1+(int) (100.0*common_rand_r(&seed)/(RAND_MAX+1.0)))) { - /* This is the container for the enqueued data. */ - fifo_entry = malloc(sizeof(ck_hp_fifo_entry_t)); - - if (fifo_entry == NULL) { - exit(EXIT_FAILURE); - } - - /* This is the data. */ - entry = malloc(sizeof(struct entry)); - if (entry != NULL) { - entry->value = j; - } - - /* - * Enqueue the value of the pointer entry into FIFO queue using the - * container fifo_entry. - */ - ck_hp_fifo_enqueue_mpmc(record, &fifo, fifo_entry, entry); - } else { - /* - * ck_hp_fifo_dequeue_mpmc will return a pointer to the first unused node and store - * the value of the first pointer in the FIFO queue in entry. - */ - fifo_entry = ck_hp_fifo_dequeue_mpmc(record, &fifo, &entry); - if (fifo_entry != NULL) { - /* - * Safely reclaim memory associated with fifo_entry. - * This inserts garbage into a local list. Once the list (plist) reaches - * a length of 100, ck_hp_free will attempt to reclaim all references - * to objects on the list. - */ - ck_hp_free(record, &fifo_entry->hazard, fifo_entry, fifo_entry); - } - } - } - - /* end barrier */ - ck_pr_inc_uint(&end_barrier); - while (ck_pr_load_uint(&end_barrier) < thread_count + 1) - ck_pr_stall(); - - return NULL; -} - -int -main(int argc, char** argv) -{ - ck_hp_fifo_entry_t *stub; - unsigned long element_count, i; - pthread_t *thr; - - if (argc != 3) { - ck_error("Usage: cktest \n"); - } - - /* Get element count from argument */ - element_count = atoi(argv[2]); - - /* Get element count from argument */ - thread_count = atoi(argv[1]); - - /* pthread handles */ - thr = malloc(sizeof(pthread_t) * thread_count); - - /* array for local operation count */ - count = malloc(sizeof(unsigned long *) * thread_count); - - /* - * Initialize global hazard pointer safe memory reclamation to execute free() - * when a fifo_entry is safe to be deleted. - * Hazard pointer scan routine will be called when the thread local intern plist's - * size exceed 100 entries. - */ - - /* FIFO queue needs 2 hazard pointers */ - ck_hp_init(&fifo_hp, CK_HP_FIFO_SLOTS_COUNT, 100, destructor); - - /* The FIFO requires one stub entry on initialization. */ - stub = malloc(sizeof(ck_hp_fifo_entry_t)); - - /* Behavior is undefined if stub is NULL. */ - if (stub == NULL) { - exit(EXIT_FAILURE); - } - - /* This is called once to initialize the fifo. */ - ck_hp_fifo_init(&fifo, stub); - - /* Create threads */ - for (i = 0; i < thread_count; i++) { - count[i] = (element_count + i) / thread_count; - if (pthread_create(&thr[i], NULL, queue_50_50, (void *) &count[i]) != 0) { - exit(EXIT_FAILURE); - } - } - - /* start barrier */ - ck_pr_inc_uint(&start_barrier); - while (ck_pr_load_uint(&start_barrier) < thread_count + 1); - - /* end barrier */ - ck_pr_inc_uint(&end_barrier); - while (ck_pr_load_uint(&end_barrier) < thread_count + 1); - - /* Join threads */ - for (i = 0; i < thread_count; i++) - pthread_join(thr[i], NULL); - - return 0; -} - diff --git a/regressions/ck_hp/validate/ck_hp_stack.c b/regressions/ck_hp/validate/ck_hp_stack.c deleted file mode 100644 index ad9b927a14fc..000000000000 --- a/regressions/ck_hp/validate/ck_hp_stack.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static unsigned int threshold; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int e_barrier; - -#ifndef PAIRS -#define PAIRS 5000000 -#endif - -struct node { - unsigned int value; - ck_hp_hazard_t hazard; - ck_stack_entry_t stack_entry; -}; -static ck_stack_t stack = {NULL, NULL}; -static ck_hp_t stack_hp; -CK_STACK_CONTAINER(struct node, stack_entry, stack_container) -static struct affinity a; - -static void * -thread(void *unused CK_CC_UNUSED) -{ - struct node **entry, *e; - unsigned int i; - ck_hp_record_t record; - void **pointers; - ck_stack_entry_t *s; - - unused = NULL; - pointers = malloc(sizeof(void *)); - ck_hp_register(&stack_hp, &record, pointers); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - entry = malloc(sizeof(struct node *) * PAIRS); - if (entry == NULL) { - ck_error("Failed allocation.\n"); - } - - for (i = 0; i < PAIRS; i++) { - entry[i] = malloc(sizeof(struct node)); - if (entry == NULL) { - ck_error("Failed individual allocation\n"); - } - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads) - ck_pr_stall(); - - for (i = 0; i < PAIRS; i++) { - ck_hp_stack_push_mpmc(&stack, &entry[i]->stack_entry); - s = ck_hp_stack_pop_mpmc(&record, &stack); - e = stack_container(s); - ck_hp_free(&record, &e->hazard, e, s); - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads) - ck_pr_stall(); - - fprintf(stderr, "Peak: %u (%2.2f%%)\nReclamations: %" PRIu64 "\n\n", - record.n_peak, - (double)record.n_peak / PAIRS * 100, - record.n_reclamations); - - ck_hp_clear(&record); - ck_hp_purge(&record); - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < (n_threads << 1)); - - if (record.n_pending != 0) { - ck_error("ERROR: %u pending, expecting none.\n", - record.n_pending); - } - - return (NULL); -} - -static void -destructor(void *p) -{ - - free(p); - return; -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack \n"); - } - - n_threads = atoi(argv[1]); - threshold = atoi(argv[2]); - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - - ck_hp_init(&stack_hp, 1, threshold, destructor); - - for (i = 0; i < n_threads; i++) - pthread_create(threads + i, NULL, thread, NULL); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - return (0); -} diff --git a/regressions/ck_hp/validate/nbds_haz_test.c b/regressions/ck_hp/validate/nbds_haz_test.c deleted file mode 100644 index 9b85e762b188..000000000000 --- a/regressions/ck_hp/validate/nbds_haz_test.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This is a unit test similar to the implementation in John Dybnis's nbds - * test. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#define STACK_CONTAINER(T, M, N) CK_CC_CONTAINER(stack_entry_t, T, M, N) - -struct stack_entry { - struct stack_entry *next; -} CK_CC_ALIGN(8); -typedef struct stack_entry stack_entry_t; - -struct stack { - struct stack_entry *head; - char *generation; -} CK_CC_PACKED CK_CC_ALIGN(16); -typedef struct stack hp_stack_t; - -static unsigned int threshold; -static unsigned int n_threads; -static unsigned int barrier; -static unsigned int e_barrier; -static unsigned int global_tid; -static unsigned int pops; -static unsigned int pushs; - -#ifndef PAIRS -#define PAIRS 1000000 -#endif - -struct node { - unsigned int value; - ck_hp_hazard_t hazard; - stack_entry_t stack_entry; -}; -hp_stack_t stack = {NULL, NULL}; -ck_hp_t stack_hp; - -STACK_CONTAINER(struct node, stack_entry, stack_container) -static struct affinity a; - -/* - * Stack producer operation safe for multiple unique producers and multiple consumers. - */ -CK_CC_INLINE static void -stack_push_mpmc(struct stack *target, struct stack_entry *entry) -{ - struct stack_entry *lstack; - ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; - - lstack = ck_pr_load_ptr(&target->head); - ck_pr_store_ptr(&entry->next, lstack); - ck_pr_fence_store(); - - while (ck_pr_cas_ptr_value(&target->head, lstack, entry, &lstack) == false) { - ck_pr_store_ptr(&entry->next, lstack); - ck_pr_fence_store(); - ck_backoff_eb(&backoff); - } - - return; -} - -/* - * Stack consumer operation safe for multiple unique producers and multiple consumers. - */ -CK_CC_INLINE static struct stack_entry * -stack_pop_mpmc(ck_hp_record_t *record, struct stack *target) -{ - struct stack_entry *entry; - ck_backoff_t backoff = CK_BACKOFF_INITIALIZER; - - do { - entry = ck_pr_load_ptr(&target->head); - if (entry == NULL) - return (NULL); - - ck_hp_set_fence(record, 0, entry); - } while (entry != ck_pr_load_ptr(&target->head)); - - while (ck_pr_cas_ptr_value(&target->head, entry, entry->next, &entry) == false) { - if (ck_pr_load_ptr(&entry) == NULL) - break; - - ck_hp_set_fence(record, 0, entry); - if (entry != ck_pr_load_ptr(&target->head)) - continue; - - ck_backoff_eb(&backoff); - } - - return (entry); -} - -static void * -thread(void *unused CK_CC_UNUSED) -{ - struct node *entry, *e; - unsigned int i; - ck_hp_record_t record; - void **pointers; - stack_entry_t *s; - unsigned int tid = ck_pr_faa_uint(&global_tid, 1) + 1; - unsigned int r = (unsigned int)(tid + 1) * 0x5bd1e995; - - unused = NULL; - pointers = malloc(sizeof(void *)); - ck_hp_register(&stack_hp, &record, pointers); - - if (aff_iterate(&a)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) < n_threads) - ck_pr_stall(); - - for (i = 0; i < PAIRS; i++) { - r ^= r << 6; r ^= r >> 21; r ^= r << 7; - - if (r & 0x1000) { - entry = malloc(sizeof(struct node)); - assert(entry); - stack_push_mpmc(&stack, &entry->stack_entry); - ck_pr_inc_uint(&pushs); - } else { - s = stack_pop_mpmc(&record, &stack); - if (s == NULL) - continue; - - e = stack_container(s); - ck_hp_free(&record, &e->hazard, e, s); - ck_pr_inc_uint(&pops); - } - } - - ck_pr_inc_uint(&e_barrier); - while (ck_pr_load_uint(&e_barrier) < n_threads); - - return (NULL); -} - -static void -destructor(void *p) -{ - free(p); - return; -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - - if (argc != 4) { - ck_error("Usage: stack \n"); - } - - n_threads = atoi(argv[1]); - threshold = atoi(argv[2]); - a.delta = atoi(argv[3]); - a.request = 0; - - threads = malloc(sizeof(pthread_t) * n_threads); - - ck_hp_init(&stack_hp, 1, threshold, destructor); - - for (i = 0; i < n_threads; i++) - pthread_create(threads + i, NULL, thread, NULL); - - for (i = 0; i < n_threads; i++) - pthread_join(threads[i], NULL); - - fprintf(stderr, "Push: %u\nPop: %u\n", pushs, pops); - return (0); -} diff --git a/regressions/ck_hp/validate/serial.c b/regressions/ck_hp/validate/serial.c deleted file mode 100644 index fd315817af51..000000000000 --- a/regressions/ck_hp/validate/serial.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2010-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../../common.h" - -struct entry { - unsigned int value; - ck_hp_hazard_t hazard; -}; - -static void -destructor(void *pointer) -{ - - fprintf(stderr, "Free %p\n", pointer); - free(pointer); - return; -} - -int -main(int argc, char *argv[]) -{ - ck_hp_t state; - ck_hp_record_t record[2]; - void **pointers; - struct entry *entry, *other; - - (void)argc; - (void)argv; - - ck_hp_init(&state, 1, 1, destructor); - - pointers = malloc(sizeof(void *)); - if (pointers == NULL) { - ck_error("ERROR: Failed to allocate slot.\n"); - } - ck_hp_register(&state, &record[0], pointers); - ck_hp_reclaim(&record[0]); - - entry = malloc(sizeof *entry); - ck_hp_set(&record[0], 0, entry); - ck_hp_reclaim(&record[0]); - ck_hp_free(&record[0], &entry->hazard, entry, entry); - ck_hp_reclaim(&record[0]); - ck_hp_set(&record[0], 0, NULL); - ck_hp_reclaim(&record[0]); - - entry = malloc(sizeof *entry); - ck_hp_set(&record[0], 0, entry); - ck_hp_reclaim(&record[0]); - ck_hp_free(&record[0], &entry->hazard, entry, entry); - ck_hp_reclaim(&record[0]); - ck_hp_set(&record[0], 0, NULL); - ck_hp_reclaim(&record[0]); - - pointers = malloc(sizeof(void *)); - if (pointers == NULL) { - ck_error("ERROR: Failed to allocate slot.\n"); - } - ck_hp_register(&state, &record[1], pointers); - ck_hp_reclaim(&record[1]); - - entry = malloc(sizeof *entry); - ck_hp_set(&record[1], 0, entry); - ck_hp_reclaim(&record[1]); - ck_hp_free(&record[1], &entry->hazard, entry, entry); - ck_hp_reclaim(&record[1]); - ck_hp_set(&record[1], 0, NULL); - ck_hp_reclaim(&record[1]); - - printf("Allocating entry and freeing in other HP record...\n"); - entry = malloc(sizeof *entry); - entry->value = 42; - ck_hp_set(&record[0], 0, entry); - ck_hp_free(&record[1], &entry->hazard, entry, entry); - ck_pr_store_uint(&entry->value, 1); - - other = malloc(sizeof *other); - other->value = 24; - ck_hp_set(&record[1], 0, other); - ck_hp_free(&record[0], &other->hazard, other, other); - ck_pr_store_uint(&other->value, 32); - ck_hp_set(&record[0], 0, NULL); - ck_hp_reclaim(&record[1]); - ck_hp_set(&record[1], 0, NULL); - ck_hp_reclaim(&record[0]); - ck_hp_reclaim(&record[1]); - - return 0; -} diff --git a/regressions/ck_hs/benchmark/Makefile b/regressions/ck_hs/benchmark/Makefile deleted file mode 100644 index 23b674512376..000000000000 --- a/regressions/ck_hs/benchmark/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=serial parallel_bytestring parallel_bytestring.delete apply - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c - -apply: apply.c ../../../include/ck_hs.h ../../../src/ck_hs.c - $(CC) $(CFLAGS) -o apply apply.c ../../../src/ck_hs.c - -parallel_bytestring: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c - -parallel_bytestring.delete: parallel_bytestring.c ../../../include/ck_hs.h ../../../src/ck_hs.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -DHS_DELETE -o parallel_bytestring.delete parallel_bytestring.c ../../../src/ck_hs.c ../../../src/ck_epoch.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_hs/benchmark/apply.c b/regressions/ck_hs/benchmark/apply.c deleted file mode 100644 index ca4a3da12224..000000000000 --- a/regressions/ck_hs/benchmark/apply.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright 2014 Samy Al Bahra. - * Copyright 2014 Backtrace I/O, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" -#include "../../../src/ck_ht_hash.h" - -static ck_hs_t hs; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static unsigned long global_seed; - -static void * -hs_malloc(size_t r) -{ - - return malloc(r); -} - -static void -hs_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - - free(p); - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - h = (unsigned long)MurmurHash64A(c, strlen(c), seed); - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void -set_destroy(void) -{ - - ck_hs_destroy(&hs); - return; -} - -static void -set_init(unsigned int size, unsigned int mode) -{ - - if (ck_hs_init(&hs, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC | mode, hs_hash, hs_compare, - &my_allocator, size, global_seed) == false) { - perror("ck_hs_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static size_t -set_count(void) -{ - - return ck_hs_count(&hs); -} - -static bool -set_reset(void) -{ - - return ck_hs_reset(&hs); -} - -static void * -test_apply(void *key, void *closure) -{ - - (void)key; - - return closure; -} - -static void -run_test(const char *file, size_t r, unsigned int size, unsigned int mode) -{ - FILE *fp; - char buffer[512]; - size_t i, j; - unsigned int d = 0; - uint64_t s, e, a, gp, agp; - struct ck_hs_stat st; - char **t; - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(file, "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - set_init(size, mode); - for (i = 0; i < keys_length; i++) { - unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); - - if (ck_hs_get(&hs, h, keys[i]) == false) { - if (ck_hs_put(&hs, h, keys[i]) == false) - ck_error("ERROR: Failed get to put workload.\n"); - } else { - d++; - } - } - ck_hs_stat(&hs, &st); - - fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n", - set_count(), d, st.probe_maximum); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) - ck_error("ERROR: Failed to reset hash table.\n"); - - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); - - if (ck_hs_get(&hs, h, keys[i]) == false && - ck_hs_put(&hs, h, keys[i]) == false) { - ck_error("ERROR: Failed get to put workload.\n"); - } - } - e = rdtsc(); - a += e - s; - } - gp = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) - ck_error("ERROR: Failed to reset hash table.\n"); - - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - unsigned long h = CK_HS_HASH(&hs, hs_hash, keys[i]); - - if (ck_hs_apply(&hs, h, keys[i], test_apply, (void *)keys[i]) == false) - ck_error("ERROR: Failed in apply workload.\n"); - } - e = rdtsc(); - a += e - s; - } - agp = a / (r * keys_length); - - fclose(fp); - - for (i = 0; i < keys_length; i++) { - free(keys[i]); - } - - printf("Get to put: %" PRIu64 " ticks\n", gp); - printf(" Apply: %" PRIu64 " ticks\n", agp); - - free(keys); - keys_length = 0; - set_destroy(); - return; -} - -int -main(int argc, char *argv[]) -{ - unsigned int r, size; - - common_srand48((long int)time(NULL)); - if (argc < 2) { - ck_error("Usage: ck_hs [ ]\n"); - } - - r = 16; - if (argc >= 3) - r = atoi(argv[2]); - - size = 8; - if (argc >= 4) - size = atoi(argv[3]); - - global_seed = common_lrand48(); - run_test(argv[1], r, size, 0); - - printf("\n==============================================\n" - "Delete mode\n" - "==============================================\n"); - run_test(argv[1], r, size, CK_HS_MODE_DELETE); - return 0; -} - diff --git a/regressions/ck_hs/benchmark/parallel_bytestring.c b/regressions/ck_hs/benchmark/parallel_bytestring.c deleted file mode 100644 index 6d383792db34..000000000000 --- a/regressions/ck_hs/benchmark/parallel_bytestring.c +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include "../../common.h" -#include -#include "../../../src/ck_ht_hash.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static ck_hs_t hs CK_CC_CACHELINE; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static ck_epoch_t epoch_hs; -static ck_epoch_record_t epoch_wr; -static int n_threads; -static bool next_stage; - -enum state { - HS_STATE_STOP = 0, - HS_STATE_GET, - HS_STATE_STRICT_REPLACEMENT, - HS_STATE_DELETION, - HS_STATE_REPLACEMENT, - HS_STATE_COUNT -}; - -static ck_spinlock_t mtx = CK_SPINLOCK_INITIALIZER; -static struct affinity affinerator = AFFINITY_INITIALIZER; -static uint64_t accumulator[HS_STATE_COUNT]; -static int barrier[HS_STATE_COUNT]; -static int state; - -struct hs_epoch { - ck_epoch_entry_t epoch_entry; -}; - -COMMON_ALARM_DECLARE_GLOBAL(hs_alarm, alarm_event, next_stage) - -static void -alarm_handler(int s) -{ - - (void)s; - next_stage = true; - return; -} - -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - h = (unsigned long)MurmurHash64A(c, strlen(c), seed); - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void -hs_destroy(ck_epoch_entry_t *e) -{ - - free(e); - return; -} - -static void * -hs_malloc(size_t r) -{ - ck_epoch_entry_t *b; - - b = malloc(sizeof(*b) + r); - return b + 1; -} - -static void -hs_free(void *p, size_t b, bool r) -{ - struct hs_epoch *e = p; - - (void)b; - - if (r == true) { - /* Destruction requires safe memory reclamation. */ - ck_epoch_call(&epoch_wr, &(--e)->epoch_entry, hs_destroy); - } else { - free(--e); - } - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -static void -set_init(void) -{ - unsigned int mode = CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC; - -#ifdef HS_DELETE - mode |= CK_HS_MODE_DELETE; -#endif - - ck_epoch_init(&epoch_hs); - ck_epoch_register(&epoch_hs, &epoch_wr); - common_srand48((long int)time(NULL)); - if (ck_hs_init(&hs, mode, hs_hash, hs_compare, &my_allocator, 65536, common_lrand48()) == false) { - perror("ck_hs_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -set_remove(const char *value) -{ - unsigned long h; - - h = CK_HS_HASH(&hs, hs_hash, value); - return (bool)ck_hs_remove(&hs, h, value); -} - -static bool -set_replace(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_set(&hs, h, value, &previous); -} - -static bool -set_swap(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_fas(&hs, h, value, &previous); -} - -static void * -set_get(const char *value) -{ - unsigned long h; - void *v; - - h = CK_HS_HASH(&hs, hs_hash, value); - v = ck_hs_get(&hs, h, value); - return v; -} - -static bool -set_insert(const char *value) -{ - unsigned long h; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_put(&hs, h, value); -} - -static size_t -set_count(void) -{ - - return ck_hs_count(&hs); -} - -static bool -set_reset(void) -{ - - return ck_hs_reset(&hs); -} - -static void * -reader(void *unused) -{ - size_t i; - ck_epoch_record_t epoch_record; - int state_previous = HS_STATE_STOP; - int n_state = 0; - uint64_t s, j, a; - - (void)unused; - if (aff_iterate(&affinerator) != 0) - perror("WARNING: Failed to affine thread"); - - s = j = a = 0; - ck_epoch_register(&epoch_hs, &epoch_record); - for (;;) { - j++; - ck_epoch_begin(&epoch_record, NULL); - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - char *r; - - r = set_get(keys[i]); - if (r == NULL) { - if (n_state == HS_STATE_STRICT_REPLACEMENT) { - ck_error("ERROR: Did not find during replacement: %s\n", keys[i]); - } - - continue; - } - - if (strcmp(r, keys[i]) == 0) - continue; - - ck_error("ERROR: Found invalid value: [%s] but expected [%s]\n", (char *)r, keys[i]); - } - a += rdtsc() - s; - ck_epoch_end(&epoch_record, NULL); - - n_state = ck_pr_load_int(&state); - if (n_state != state_previous) { - ck_spinlock_lock(&mtx); - accumulator[state_previous] += a / (j * keys_length); - ck_spinlock_unlock(&mtx); - - ck_pr_inc_int(&barrier[state_previous]); - while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) - ck_pr_stall(); - - state_previous = n_state; - s = j = a = 0; - } - } - - return NULL; -} - -static uint64_t -acc(size_t i) -{ - uint64_t r; - - ck_spinlock_lock(&mtx); - r = accumulator[i]; - ck_spinlock_unlock(&mtx); - - return r; -} - -int -main(int argc, char *argv[]) -{ - FILE *fp; - char buffer[512]; - size_t i, j, r; - unsigned int d = 0; - uint64_t s, e, a, repeated; - char **t; - pthread_t *readers; - double p_r, p_d; - - COMMON_ALARM_DECLARE_LOCAL(hs_alarm, alarm_event) - - r = 20; - s = 8; - p_d = 0.5; - p_r = 0.5; - n_threads = CORES - 1; - - if (argc < 2) { - ck_error("Usage: parallel [ \n" - " ]\n"); - } - - if (argc >= 3) - r = atoi(argv[2]); - - if (argc >= 4) - s = (uint64_t)atoi(argv[3]); - - if (argc >= 5) { - n_threads = atoi(argv[4]); - if (n_threads < 1) { - ck_error("ERROR: Number of readers must be >= 1.\n"); - } - } - - if (argc >= 6) { - p_r = atof(argv[5]) / 100.00; - if (p_r < 0) { - ck_error("ERROR: Probability of replacement must be >= 0 and <= 100.\n"); - } - } - - if (argc >= 7) { - p_d = atof(argv[6]) / 100.00; - if (p_d < 0) { - ck_error("ERROR: Probability of deletion must be >= 0 and <= 100.\n"); - } - } - - COMMON_ALARM_INIT(hs_alarm, alarm_event, r) - - affinerator.delta = 1; - readers = malloc(sizeof(pthread_t) * n_threads); - assert(readers != NULL); - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(argv[1], "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - set_init(); - - for (i = 0; i < (size_t)n_threads; i++) { - if (pthread_create(&readers[i], NULL, reader, NULL) != 0) { - ck_error("ERROR: Failed to create thread %zu.\n", i); - } - } - - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - - fprintf(stderr, " [S] %d readers, 1 writer.\n", n_threads); - fprintf(stderr, " [S] %zu entries stored and %u duplicates.\n\n", - set_count(), d); - - fprintf(stderr, " ,- BASIC TEST\n"); - fprintf(stderr, " | Executing SMR test..."); - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing replacement test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing get test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - a = 0; - fprintf(stderr, " | Executing removal test..."); - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing negative look-up test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - ck_epoch_record_t epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - - fprintf(stderr, " ,- READER CONCURRENCY\n"); - fprintf(stderr, " | Executing reader test..."); - - ck_pr_store_int(&state, HS_STATE_GET); - while (ck_pr_load_int(&barrier[HS_STATE_STOP]) != n_threads) - ck_pr_stall(); - ck_pr_inc_int(&barrier[HS_STATE_STOP]); - common_sleep(r); - ck_pr_store_int(&state, HS_STATE_STRICT_REPLACEMENT); - while (ck_pr_load_int(&barrier[HS_STATE_GET]) != n_threads) - ck_pr_stall(); - - fprintf(stderr, "done (reader = %" PRIu64 " ticks)\n", - acc(HS_STATE_GET) / n_threads); - - fprintf(stderr, " | Executing strict replacement test..."); - - a = repeated = 0; - common_alarm(alarm_handler, &alarm_event, r); - - ck_pr_inc_int(&barrier[HS_STATE_GET]); - for (;;) { - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (i & 1) { - set_replace(keys[i]); - } else { - set_swap(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - - ck_pr_store_int(&state, HS_STATE_DELETION); - while (ck_pr_load_int(&barrier[HS_STATE_STRICT_REPLACEMENT]) != n_threads) - ck_pr_stall(); - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_STRICT_REPLACEMENT) / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing deletion test (%.2f)...", p_d * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HS_STATE_STRICT_REPLACEMENT]); - for (;;) { - double delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - set_remove(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HS_STATE_REPLACEMENT); - while (ck_pr_load_int(&barrier[HS_STATE_DELETION]) != n_threads) - ck_pr_stall(); - - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_DELETION) / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing replacement test (%.2f)...", p_r * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HS_STATE_DELETION]); - for (;;) { - double delete, replace; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - set_remove(keys[i]); - } else { - delete = 0.0; - } - - if (p_r != 0.0) { - replace = common_drand48(); - if (replace <= p_r) { - if ((i & 1) || (delete <= p_d)) { - set_replace(keys[i]); - } else { - set_swap(keys[i]); - } - } - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HS_STATE_STOP); - while (ck_pr_load_int(&barrier[HS_STATE_REPLACEMENT]) != n_threads) - ck_pr_stall(); - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_REPLACEMENT) / n_threads); - - ck_pr_inc_int(&barrier[HS_STATE_REPLACEMENT]); - epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - return 0; -} - diff --git a/regressions/ck_hs/benchmark/serial.c b/regressions/ck_hs/benchmark/serial.c deleted file mode 100644 index ac4caff241b6..000000000000 --- a/regressions/ck_hs/benchmark/serial.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" -#include "../../../src/ck_ht_hash.h" - -static ck_hs_t hs; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static unsigned long global_seed; - -static void * -hs_malloc(size_t r) -{ - - return malloc(r); -} - -static void -hs_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - - free(p); - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - h = (unsigned long)MurmurHash64A(c, strlen(c), seed); - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void -set_destroy(void) -{ - - ck_hs_destroy(&hs); - return; -} - -static void -set_init(unsigned int size, unsigned int mode) -{ - - if (ck_hs_init(&hs, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC | mode, hs_hash, hs_compare, - &my_allocator, size, global_seed) == false) { - perror("ck_hs_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -set_remove(const char *value) -{ - unsigned long h; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_remove(&hs, h, value) != NULL; -} - -static bool -set_swap(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_fas(&hs, h, value, &previous); -} - -static bool -set_replace(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_HS_HASH(&hs, hs_hash, value); - ck_hs_set(&hs, h, value, &previous); - return previous == value; -} - -static void * -set_get(const char *value) -{ - unsigned long h; - void *v; - - h = CK_HS_HASH(&hs, hs_hash, value); - v = ck_hs_get(&hs, h, value); - return v; -} - -static bool -set_insert(const char *value) -{ - unsigned long h; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_put(&hs, h, value); -} - -static bool -set_insert_unique(const char *value) -{ - unsigned long h; - - h = CK_HS_HASH(&hs, hs_hash, value); - return ck_hs_put_unique(&hs, h, value); -} - -static size_t -set_count(void) -{ - - return ck_hs_count(&hs); -} - -static bool -set_reset(void) -{ - - return ck_hs_reset(&hs); -} - -static void -set_gc(void) -{ - - ck_hs_gc(&hs, 0, 0); - return; -} - -static void -set_rebuild(void) -{ - - ck_hs_rebuild(&hs); - return; -} - -static void -keys_shuffle(char **k) -{ - size_t i, j; - char *t; - - for (i = keys_length; i > 1; i--) { - j = rand() % (i - 1); - - if (j != i - 1) { - t = k[i - 1]; - k[i - 1] = k[j]; - k[j] = t; - } - } - - return; -} - -static void -run_test(const char *file, size_t r, unsigned int size, unsigned int mode) -{ - FILE *fp; - char buffer[512]; - size_t i, j; - unsigned int d = 0; - uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng, ss, sts, su, sgc, sb; - struct ck_hs_stat st; - char **t; - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(file, "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - set_init(size, mode); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - ck_hs_stat(&hs, &st); - - fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n", - set_count(), d, st.probe_maximum); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = keys_length; i > 0; i--) - d += set_insert(keys[i - 1]) == false; - e = rdtsc(); - a += e - s; - } - ri = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - si = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - ai = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_swap(keys[i]); - e = rdtsc(); - a += e - s; - } - ss = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - sr = a / (r * keys_length); - - set_reset(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = keys_length; i > 0; i--) { - if (set_get(keys[i - 1]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - rg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - sg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - ag = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - } - sd = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - ng = a / (r * keys_length); - - set_reset(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - } - sts = a / (r * keys_length); - - set_reset(); - - /* Prune duplicates. */ - for (i = 0; i < keys_length; i++) { - if (set_insert(keys[i]) == true) - continue; - - free(keys[i]); - keys[i] = keys[--keys_length]; - } - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_insert_unique(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - } - su = a / (r * keys_length); - - for (i = 0; i < keys_length; i++) - set_insert_unique(keys[i]); - - for (i = 0; i < keys_length / 2; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - set_gc(); - e = rdtsc(); - a += e - s; - } - sgc = a / r; - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - set_rebuild(); - e = rdtsc(); - a += e - s; - } - sb = a / r; - - printf("%zu " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 "\n", - keys_length, ri, si, ai, ss, sr, rg, sg, ag, sd, ng, sts, su, sgc, sb); - - fclose(fp); - - for (i = 0; i < keys_length; i++) { - free(keys[i]); - } - - free(keys); - keys_length = 0; - set_destroy(); - return; -} - -int -main(int argc, char *argv[]) -{ - unsigned int r, size; - - common_srand48((long int)time(NULL)); - if (argc < 2) { - ck_error("Usage: ck_hs [ ]\n"); - } - - r = 16; - if (argc >= 3) - r = atoi(argv[2]); - - size = 8; - if (argc >= 4) - size = atoi(argv[3]); - - global_seed = common_lrand48(); - run_test(argv[1], r, size, 0); - run_test(argv[1], r, size, CK_HS_MODE_DELETE); - fprintf(stderr, "# reverse_insertion serial_insertion random_insertion serial_swap " - "serial_replace reverse_get serial_get random_get serial_remove negative_get tombstone " - "set_unique gc rebuild\n\n"); - - return 0; -} - diff --git a/regressions/ck_hs/validate/Makefile b/regressions/ck_hs/validate/Makefile deleted file mode 100644 index a96e652a07e5..000000000000 --- a/regressions/ck_hs/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=serial - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_hs.h ../../../src/ck_hs.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_hs.c - -check: all - ./serial - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_hs/validate/serial.c b/regressions/ck_hs/validate/serial.c deleted file mode 100644 index a16fc82fe141..000000000000 --- a/regressions/ck_hs/validate/serial.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static void * -hs_malloc(size_t r) -{ - - return malloc(r); -} - -static void -hs_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - free(p); - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -const char *test[] = { "Samy", "Al", "Bahra", "dances", "in", "the", "wind.", "Once", - "upon", "a", "time", "his", "gypsy", "ate", "one", "itsy", - "bitsy", "spider.", "What", "goes", "up", "must", - "come", "down.", "What", "is", "down", "stays", - "down.", "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O", "P", "Q" }; - -const char *negative = "negative"; - -/* Purposefully crappy hash function. */ -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - (void)seed; - h = c[0]; - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void * -test_ip(void *key, void *closure) -{ - const char *a = key; - const char *b = closure; - - if (strcmp(a, b) != 0) - ck_error("Mismatch: %s != %s\n", a, b); - - return closure; -} - -static void * -test_negative(void *key, void *closure) -{ - - (void)closure; - if (key != NULL) - ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); - - return NULL; -} - -static void * -test_unique(void *key, void *closure) -{ - - if (key != NULL) - ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); - - return closure; -} - -static void * -test_remove(void *key, void *closure) -{ - - (void)key; - (void)closure; - - return NULL; -} - -static void -run_test(unsigned int is, unsigned int ad) -{ - ck_hs_t hs[16]; - const size_t size = sizeof(hs) / sizeof(*hs); - size_t i, j; - const char *blob = "#blobs"; - unsigned long h; - - if (ck_hs_init(&hs[0], CK_HS_MODE_SPMC | CK_HS_MODE_OBJECT | ad, hs_hash, hs_compare, &my_allocator, is, 6602834) == false) - ck_error("ck_hs_init\n"); - - for (j = 0; j < size; j++) { - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_hs_get(&hs[j], h, test[i]) != NULL) { - continue; - } - - if (i & 1) { - if (ck_hs_put_unique(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); - } else if (ck_hs_apply(&hs[j], h, test[i], test_unique, (void *)(uintptr_t)test[i]) == false) { - ck_error("ERROR: Failed to apply for insertion.\n"); - } - - if (i & 1) { - if (ck_hs_remove(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); - } else if (ck_hs_apply(&hs[j], h, test[i], test_remove, NULL) == false) { - ck_error("ERROR: Failed to remove apply.\n"); - } - - if (ck_hs_apply(&hs[j], h, test[i], test_negative, (char *)(uintptr_t)test[i]) == false) - ck_error("ERROR: Failed to apply.\n"); - - break; - } - - if (ck_hs_gc(&hs[j], 0, 0) == false) - ck_error("ERROR: Failed to GC empty set.\n"); - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - ck_hs_put(&hs[j], h, test[i]); - if (ck_hs_put(&hs[j], h, test[i]) == true) { - ck_error("ERROR [%u] [1]: put must fail on collision (%s).\n", is, test[i]); - } - if (ck_hs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail after put\n", is); - } - } - - /* Test grow semantics. */ - ck_hs_grow(&hs[j], 128); - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_hs_put(&hs[j], h, test[i]) == true) { - ck_error("ERROR [%u] [2]: put must fail on collision.\n", is); - } - - if (ck_hs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail\n", is); - } - } - - h = blob[0]; - if (ck_hs_get(&hs[j], h, blob) == NULL) { - if (j > 0) - ck_error("ERROR [%u]: Blob must always exist after first.\n", is); - - if (ck_hs_put(&hs[j], h, blob) == false) { - ck_error("ERROR [%u]: A unique blob put failed.\n", is); - } - } else { - if (ck_hs_put(&hs[j], h, blob) == true) { - ck_error("ERROR [%u]: Duplicate blob put succeeded.\n", is); - } - } - - /* Grow set and check get semantics. */ - ck_hs_grow(&hs[j], 512); - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_hs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail\n", is); - } - } - - /* Delete and check negative membership. */ - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - void *r; - - h = test[i][0]; - if (ck_hs_get(&hs[j], h, test[i]) == NULL) - continue; - - if (r = ck_hs_remove(&hs[j], h, test[i]), r == NULL) { - ck_error("ERROR [%u]: remove must not fail\n", is); - } - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Removed incorrect node (%s != %s)\n", (char *)r, test[i], is); - } - } - - /* Test replacement semantics. */ - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - void *r; - bool d; - - h = test[i][0]; - d = ck_hs_get(&hs[j], h, test[i]) != NULL; - if (ck_hs_set(&hs[j], h, test[i], &r) == false) { - ck_error("ERROR [%u]: Failed to set\n", is); - } - - /* Expected replacement. */ - if (d == true && (r == NULL || strcmp(r, test[i]) != 0)) { - ck_error("ERROR [%u]: Incorrect previous value: %s != %s\n", - is, test[i], (char *)r); - } - - /* Replacement should succeed. */ - if (ck_hs_fas(&hs[j], h, test[i], &r) == false) - ck_error("ERROR [%u]: ck_hs_fas must succeed.\n", is); - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Incorrect replaced value: %s != %s\n", - is, test[i], (char *)r); - } - - if (ck_hs_fas(&hs[j], h, negative, &r) == true) - ck_error("ERROR [%u]: Replacement of negative should fail.\n", is); - - if (ck_hs_set(&hs[j], h, test[i], &r) == false) { - ck_error("ERROR [%u]: Failed to set [1]\n", is); - } - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Invalid &hs[j]: %s != %s\n", is, test[i], (char *)r); - } - - /* Attempt in-place mutation. */ - if (ck_hs_apply(&hs[j], h, test[i], test_ip, (void *)(uintptr_t)test[i]) == false) - ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]); - - d = ck_hs_get(&hs[j], h, test[i]) != NULL; - if (d == false) - ck_error("ERROR [%u]: Expected [%s] to exist.\n", is, test[i]); - } - - if (j == size - 1) - break; - - if (ck_hs_move(&hs[j + 1], &hs[j], hs_hash, hs_compare, &my_allocator) == false) - ck_error("Failed to move hash table"); - - if (j & 1) { - ck_hs_gc(&hs[j + 1], 0, 0); - } else { - ck_hs_gc(&hs[j + 1], 26, 26); - } - - if (ck_hs_rebuild(&hs[j + 1]) == false) - ck_error("Failed to rebuild"); - } - - return; -} - -int -main(void) -{ - unsigned int k; - - for (k = 16; k <= 64; k <<= 1) { - run_test(k, 0); - run_test(k, CK_HS_MODE_DELETE); - break; - } - - return 0; -} - diff --git a/regressions/ck_ht/benchmark/Makefile b/regressions/ck_ht/benchmark/Makefile deleted file mode 100644 index fa31274e9f18..000000000000 --- a/regressions/ck_ht/benchmark/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=serial serial.delete parallel_bytestring parallel_bytestring.delete parallel_direct - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_ht.c - -serial.delete: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c - $(CC) $(CFLAGS) -DHT_DELETE -o serial.delete serial.c ../../../src/ck_ht.c - -parallel_bytestring.delete: parallel_bytestring.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -DHT_DELETE -o parallel_bytestring.delete parallel_bytestring.c ../../../src/ck_ht.c ../../../src/ck_epoch.c - -parallel_bytestring: parallel_bytestring.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_ht.c ../../../src/ck_epoch.c - -parallel_direct: parallel_direct.c ../../../include/ck_ht.h ../../../src/ck_ht.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_direct parallel_direct.c ../../../src/ck_ht.c ../../../src/ck_epoch.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE - diff --git a/regressions/ck_ht/benchmark/parallel_bytestring.c b/regressions/ck_ht/benchmark/parallel_bytestring.c deleted file mode 100644 index f3d3854905f4..000000000000 --- a/regressions/ck_ht/benchmark/parallel_bytestring.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static ck_ht_t ht CK_CC_CACHELINE; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static ck_epoch_t epoch_ht; -static ck_epoch_record_t epoch_wr; -static int n_threads; -static bool next_stage; - -enum state { - HT_STATE_STOP = 0, - HT_STATE_GET, - HT_STATE_STRICT_REPLACEMENT, - HT_STATE_DELETION, - HT_STATE_REPLACEMENT, - HT_STATE_COUNT -}; - -static struct affinity affinerator = AFFINITY_INITIALIZER; -static uint64_t accumulator[HT_STATE_COUNT]; -static ck_spinlock_t accumulator_mutex = CK_SPINLOCK_INITIALIZER; -static int barrier[HT_STATE_COUNT]; -static int state; - -struct ht_epoch { - ck_epoch_entry_t epoch_entry; -}; - -COMMON_ALARM_DECLARE_GLOBAL(ht_alarm, alarm_event, next_stage) - -static void -alarm_handler(int s) -{ - - (void)s; - next_stage = true; - return; -} - -static void -ht_destroy(ck_epoch_entry_t *e) -{ - - free(e); - return; -} - -static void * -ht_malloc(size_t r) -{ - ck_epoch_entry_t *b; - - b = malloc(sizeof(*b) + r); - return b + 1; -} - -static void -ht_free(void *p, size_t b, bool r) -{ - struct ht_epoch *e = p; - - (void)b; - - if (r == true) { - /* Destruction requires safe memory reclamation. */ - ck_epoch_call(&epoch_wr, &(--e)->epoch_entry, ht_destroy); - } else { - free(--e); - } - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = ht_malloc, - .free = ht_free -}; - -static void -table_init(void) -{ - unsigned int mode = CK_HT_MODE_BYTESTRING; - -#ifdef HT_DELETE - mode |= CK_HT_WORKLOAD_DELETE; -#endif - - ck_epoch_init(&epoch_ht); - ck_epoch_register(&epoch_ht, &epoch_wr); - common_srand48((long int)time(NULL)); - if (ck_ht_init(&ht, mode, NULL, &my_allocator, 8, common_lrand48()) == false) { - perror("ck_ht_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -table_remove(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_key_set(&entry, value, l); - return ck_ht_remove_spmc(&ht, h, &entry); -} - -static bool -table_replace(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_set(&entry, h, value, l, "REPLACED"); - return ck_ht_set_spmc(&ht, h, &entry); -} - -static void * -table_get(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_key_set(&entry, value, l); - if (ck_ht_get_spmc(&ht, h, &entry) == true) - return ck_ht_entry_value(&entry); - - return NULL; -} - -static bool -table_insert(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_set(&entry, h, value, l, value); - return ck_ht_put_spmc(&ht, h, &entry); -} - -static size_t -table_count(void) -{ - - return ck_ht_count(&ht); -} - -static bool -table_reset(void) -{ - - return ck_ht_reset_spmc(&ht); -} - -static void * -reader(void *unused) -{ - size_t i; - ck_epoch_record_t epoch_record; - int state_previous = HT_STATE_STOP; - int n_state; - uint64_t s, j, a; - - (void)unused; - if (aff_iterate(&affinerator) != 0) - perror("WARNING: Failed to affine thread"); - - s = j = a = 0; - ck_epoch_register(&epoch_ht, &epoch_record); - for (;;) { - j++; - ck_epoch_begin(&epoch_record, NULL); - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - char *r; - - r = table_get(keys[i]); - if (r == NULL) - continue; - - if (strcmp(r, "REPLACED") == 0) - continue; - - if (strcmp(r, keys[i]) == 0) - continue; - - ck_error("ERROR: Found invalid value: [%s] but expected [%s]\n", r, keys[i]); - } - a += rdtsc() - s; - ck_epoch_end(&epoch_record, NULL); - - n_state = ck_pr_load_int(&state); - if (n_state != state_previous) { - ck_spinlock_lock(&accumulator_mutex); - accumulator[state_previous] += a / (j * keys_length); - ck_spinlock_unlock(&accumulator_mutex); - ck_pr_inc_int(&barrier[state_previous]); - while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) - ck_pr_stall(); - - state_previous = n_state; - s = j = a = 0; - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - FILE *fp; - char buffer[512]; - size_t i, j, r; - unsigned int d = 0; - uint64_t s, e, a, repeated; - char **t; - pthread_t *readers; - double p_r, p_d; - - COMMON_ALARM_DECLARE_LOCAL(ht_alarm, alarm_event) - - r = 20; - s = 8; - p_d = 0.5; - p_r = 0.5; - n_threads = CORES - 1; - - if (argc < 2) { - ck_error("Usage: parallel [ \n" - " ]\n"); - } - - if (argc >= 3) - r = atoi(argv[2]); - - if (argc >= 4) - s = (uint64_t)atoi(argv[3]); - - if (argc >= 5) { - n_threads = atoi(argv[4]); - if (n_threads < 1) { - ck_error("ERROR: Number of readers must be >= 1.\n"); - } - } - - if (argc >= 6) { - p_r = atof(argv[5]) / 100.00; - if (p_r < 0) { - ck_error("ERROR: Probability of replacement must be >= 0 and <= 100.\n"); - } - } - - if (argc >= 7) { - p_d = atof(argv[6]) / 100.00; - if (p_d < 0) { - ck_error("ERROR: Probability of deletion must be >= 0 and <= 100.\n"); - } - } - - COMMON_ALARM_INIT(ht_alarm, alarm_event, r) - - affinerator.delta = 1; - readers = malloc(sizeof(pthread_t) * n_threads); - assert(readers != NULL); - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(argv[1], "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - table_init(); - - for (i = 0; i < (size_t)n_threads; i++) { - if (pthread_create(&readers[i], NULL, reader, NULL) != 0) { - ck_error("ERROR: Failed to create thread %zu.\n", i); - } - } - - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - - fprintf(stderr, " [S] %d readers, 1 writer.\n", n_threads); - fprintf(stderr, " [S] %zu entries stored and %u duplicates.\n\n", - table_count(), d); - - fprintf(stderr, " ,- BASIC TEST\n"); - fprintf(stderr, " | Executing SMR test..."); - a = 0; - for (j = 0; j < r; j++) { - if (table_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing replacement test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing get test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (table_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - a = 0; - fprintf(stderr, " | Executing removal test..."); - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - table_insert(keys[i]); - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing negative look-up test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - ck_epoch_record_t epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - - fprintf(stderr, " ,- READER CONCURRENCY\n"); - fprintf(stderr, " | Executing reader test..."); - - ck_pr_store_int(&state, HT_STATE_GET); - while (ck_pr_load_int(&barrier[HT_STATE_STOP]) != n_threads) - ck_pr_stall(); - ck_pr_inc_int(&barrier[HT_STATE_STOP]); - common_sleep(r); - ck_pr_store_int(&state, HT_STATE_STRICT_REPLACEMENT); - while (ck_pr_load_int(&barrier[HT_STATE_GET]) != n_threads) - ck_pr_stall(); - fprintf(stderr, "done (reader = %" PRIu64 " ticks)\n", - accumulator[HT_STATE_GET] / n_threads); - - fprintf(stderr, " | Executing strict replacement test..."); - - a = repeated = 0; - common_alarm(alarm_handler, &alarm_event, r); - - ck_pr_inc_int(&barrier[HT_STATE_GET]); - for (;;) { - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_replace(keys[i]); - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - - ck_pr_store_int(&state, HT_STATE_DELETION); - while (ck_pr_load_int(&barrier[HT_STATE_STRICT_REPLACEMENT]) != n_threads) - ck_pr_stall(); - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_STRICT_REPLACEMENT] / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing deletion test (%.2f)...", p_d * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HT_STATE_STRICT_REPLACEMENT]); - for (;;) { - double delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - table_remove(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HT_STATE_REPLACEMENT); - while (ck_pr_load_int(&barrier[HT_STATE_DELETION]) != n_threads) - ck_pr_stall(); - - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_DELETION] / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing replacement test (%.2f)...", p_r * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HT_STATE_DELETION]); - for (;;) { - double replace, delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - table_remove(keys[i]); - } - if (p_r != 0.0) { - replace = common_drand48(); - if (replace <= p_r) - table_replace(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HT_STATE_STOP); - while (ck_pr_load_int(&barrier[HT_STATE_REPLACEMENT]) != n_threads) - ck_pr_stall(); - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_REPLACEMENT] / n_threads); - - ck_pr_inc_int(&barrier[HT_STATE_REPLACEMENT]); - epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - return 0; -} diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c deleted file mode 100644 index 195bb25e698a..000000000000 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static ck_ht_t ht CK_CC_CACHELINE; -static uintptr_t *keys; -static size_t keys_length = 0; -static ck_epoch_t epoch_ht; -static ck_epoch_record_t epoch_wr; -static int n_threads; -static bool next_stage; - -enum state { - HT_STATE_STOP = 0, - HT_STATE_GET, - HT_STATE_STRICT_REPLACEMENT, - HT_STATE_DELETION, - HT_STATE_REPLACEMENT, - HT_STATE_COUNT -}; - -static struct affinity affinerator = AFFINITY_INITIALIZER; -static uint64_t accumulator[HT_STATE_COUNT]; -static ck_spinlock_t accumulator_mutex = CK_SPINLOCK_INITIALIZER; -static int barrier[HT_STATE_COUNT]; -static int state; - -struct ht_epoch { - ck_epoch_entry_t epoch_entry; -}; - -COMMON_ALARM_DECLARE_GLOBAL(ht_alarm, alarm_event, next_stage) - -static void -alarm_handler(int s) -{ - - (void)s; - next_stage = true; - return; -} - -static void -ht_destroy(ck_epoch_entry_t *e) -{ - - free(e); - return; -} - -static void * -ht_malloc(size_t r) -{ - ck_epoch_entry_t *b; - - b = malloc(sizeof(*b) + r); - return b + 1; -} - -static void -ht_free(void *p, size_t b, bool r) -{ - struct ht_epoch *e = p; - - (void)b; - - if (r == true) { - /* Destruction requires safe memory reclamation. */ - ck_epoch_call(&epoch_wr, &(--e)->epoch_entry, ht_destroy); - } else { - free(--e); - } - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = ht_malloc, - .free = ht_free -}; - -static void -hash_function(ck_ht_hash_t *h, const void *key, size_t key_length, uint64_t seed) -{ - const uintptr_t *value = key; - - (void)key_length; - (void)seed; - h->value = *value; - return; -} - -static void -table_init(void) -{ - - ck_epoch_init(&epoch_ht); - ck_epoch_register(&epoch_ht, &epoch_wr); - common_srand48((long int)time(NULL)); - if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, hash_function, &my_allocator, 8, common_lrand48()) == false) { - perror("ck_ht_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -table_remove(uintptr_t value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - - ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_key_set_direct(&entry, value); - return ck_ht_remove_spmc(&ht, h, &entry); -} - -static bool -table_replace(uintptr_t value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - - ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_set_direct(&entry, h, value, 6605241); - return ck_ht_set_spmc(&ht, h, &entry); -} - -static uintptr_t -table_get(uintptr_t value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - - ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_key_set_direct(&entry, value); - if (ck_ht_get_spmc(&ht, h, &entry) == true) - return ck_ht_entry_value_direct(&entry); - - return 0; -} - -static bool -table_insert(uintptr_t value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - - ck_ht_hash_direct(&h, &ht, value); - ck_ht_entry_set_direct(&entry, h, value, value); - return ck_ht_put_spmc(&ht, h, &entry); -} - -static size_t -table_count(void) -{ - - return ck_ht_count(&ht); -} - -static bool -table_reset(void) -{ - - return ck_ht_reset_spmc(&ht); -} - -static void * -ht_reader(void *unused) -{ - size_t i; - ck_epoch_record_t epoch_record; - int state_previous = HT_STATE_STOP; - int n_state; - uint64_t s, j, a; - - (void)unused; - if (aff_iterate(&affinerator) != 0) - perror("WARNING: Failed to affine thread"); - - s = j = a = 0; - ck_epoch_register(&epoch_ht, &epoch_record); - for (;;) { - j++; - ck_epoch_begin(&epoch_record, NULL); - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - uintptr_t r; - - r = table_get(keys[i]); - if (r == 0) - continue; - - if (r == 6605241) - continue; - - if (r == keys[i]) - continue; - - ck_error("ERROR: Found invalid value: [%ju]\n", - (uintmax_t)r); - } - a += rdtsc() - s; - ck_epoch_end(&epoch_record, NULL); - - n_state = ck_pr_load_int(&state); - if (n_state != state_previous) { - ck_spinlock_lock(&accumulator_mutex); - accumulator[state_previous] += a / (j * keys_length); - ck_spinlock_unlock(&accumulator_mutex); - ck_pr_inc_int(&barrier[state_previous]); - while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) - ck_pr_stall(); - - state_previous = n_state; - s = j = a = 0; - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - size_t i, j, r; - unsigned int d = 0; - uint64_t s, e, a, repeated; - pthread_t *readers; - double p_r, p_d; - - COMMON_ALARM_DECLARE_LOCAL(ht_alarm, alarm_event) - - r = 20; - s = 8; - p_d = 0.5; - p_r = 0.5; - n_threads = CORES - 1; - - if (argc < 2) { - fprintf(stderr, "Usage: parallel <#entries> [ \n" - " ]\n"); - exit(EXIT_FAILURE); - } - - if (argc >= 3) - r = atoi(argv[2]); - - if (argc >= 4) - s = (uint64_t)atoi(argv[3]); - - if (argc >= 5) { - n_threads = atoi(argv[4]); - if (n_threads < 1) { - ck_error("ERROR: Number of readers must be >= 1.\n"); - } - } - - if (argc >= 6) { - p_r = atof(argv[5]) / 100.00; - if (p_r < 0) { - ck_error("ERROR: Probability of replacement must be >= 0 and <= 100.\n"); - } - } - - if (argc >= 7) { - p_d = atof(argv[6]) / 100.00; - if (p_d < 0) { - ck_error("ERROR: Probability of deletion must be >= 0 and <= 100.\n"); - } - } - - COMMON_ALARM_INIT(ht_alarm, alarm_event, r) - - affinerator.delta = 1; - readers = malloc(sizeof(pthread_t) * n_threads); - assert(readers != NULL); - - keys_length = (size_t)atoi(argv[1]); - keys = malloc(sizeof(uintptr_t) * keys_length); - assert(keys != NULL); - - table_init(); - - for (i = 0; i < keys_length; i++) { - keys[i] = (uintptr_t)common_lrand48(); - while (keys[i] == 2) - keys[i] = (uintptr_t)common_lrand48(); - } - - for (i = 0; i < (size_t)n_threads; i++) { - if (pthread_create(&readers[i], NULL, ht_reader, NULL) != 0) { - ck_error("ERROR: Failed to create thread %zu.\n", i); - } - } - - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - - fprintf(stderr, " [S] %zu entries stored and %u duplicates.\n\n", - table_count(), d); - - fprintf(stderr, " ,- BASIC TEST\n"); - fprintf(stderr, " | Executing SMR test..."); - a = 0; - for (j = 0; j < r; j++) { - if (table_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing replacement test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing get test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (table_get(keys[i]) == 0) { - ck_error("ERROR: Unexpected 0 value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - a = 0; - fprintf(stderr, " | Executing removal test..."); - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - table_insert(keys[i]); - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing negative look-up test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_get(2); - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - ck_epoch_record_t epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - - fprintf(stderr, " ,- READER CONCURRENCY\n"); - fprintf(stderr, " | Executing reader test..."); - - ck_pr_store_int(&state, HT_STATE_GET); - while (ck_pr_load_int(&barrier[HT_STATE_STOP]) != n_threads) - ck_pr_stall(); - ck_pr_inc_int(&barrier[HT_STATE_STOP]); - common_sleep(r); - ck_pr_store_int(&state, HT_STATE_STRICT_REPLACEMENT); - while (ck_pr_load_int(&barrier[HT_STATE_GET]) != n_threads) - ck_pr_stall(); - fprintf(stderr, "done (reader = %" PRIu64 " ticks)\n", - accumulator[HT_STATE_GET] / n_threads); - - fprintf(stderr, " | Executing strict replacement test..."); - - a = repeated = 0; - common_alarm(alarm_handler, &alarm_event, r); - - ck_pr_inc_int(&barrier[HT_STATE_GET]); - for (;;) { - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_replace(keys[i]); - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - - ck_pr_store_int(&state, HT_STATE_DELETION); - while (ck_pr_load_int(&barrier[HT_STATE_STRICT_REPLACEMENT]) != n_threads) - ck_pr_stall(); - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_STRICT_REPLACEMENT] / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing deletion test (%.2f)...", p_d * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HT_STATE_STRICT_REPLACEMENT]); - for (;;) { - double delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - table_remove(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HT_STATE_REPLACEMENT); - while (ck_pr_load_int(&barrier[HT_STATE_DELETION]) != n_threads) - ck_pr_stall(); - - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_DELETION] / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing replacement test (%.2f)...", p_r * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HT_STATE_DELETION]); - for (;;) { - double replace, delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - table_remove(keys[i]); - } - if (p_r != 0.0) { - replace = common_drand48(); - if (replace <= p_r) - table_replace(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HT_STATE_STOP); - while (ck_pr_load_int(&barrier[HT_STATE_REPLACEMENT]) != n_threads) - ck_pr_stall(); - table_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), accumulator[HT_STATE_REPLACEMENT] / n_threads); - - ck_pr_inc_int(&barrier[HT_STATE_REPLACEMENT]); - epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - return 0; -} diff --git a/regressions/ck_ht/benchmark/serial.c b/regressions/ck_ht/benchmark/serial.c deleted file mode 100644 index 0daa45ccbeee..000000000000 --- a/regressions/ck_ht/benchmark/serial.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static ck_ht_t ht; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; - -static void * -ht_malloc(size_t r) -{ - - return malloc(r); -} - -static void -ht_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - - free(p); - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = ht_malloc, - .free = ht_free -}; - -static void -table_init(void) -{ - unsigned int mode = CK_HT_MODE_BYTESTRING; - -#ifdef HT_DELETE - mode |= CK_HT_WORKLOAD_DELETE; -#endif - - common_srand48((long int)time(NULL)); - if (ck_ht_init(&ht, mode, NULL, &my_allocator, 8, common_lrand48()) == false) { - perror("ck_ht_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -table_remove(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_key_set(&entry, value, l); - return ck_ht_remove_spmc(&ht, h, &entry); -} - -static bool -table_replace(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_set(&entry, h, value, l, "REPLACED"); - return ck_ht_set_spmc(&ht, h, &entry); -} - -static void * -table_get(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - void *v = NULL; - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_key_set(&entry, value, l); - - if (ck_ht_get_spmc(&ht, h, &entry) == true) { - v = ck_ht_entry_value(&entry); - } - return v; -} - -static bool -table_insert(const char *value) -{ - ck_ht_entry_t entry; - ck_ht_hash_t h; - size_t l = strlen(value); - - ck_ht_hash(&h, &ht, value, l); - ck_ht_entry_set(&entry, h, value, l, "VALUE"); - return ck_ht_put_spmc(&ht, h, &entry); -} - -static size_t -table_count(void) -{ - - return ck_ht_count(&ht); -} - -static bool -table_gc(void) -{ - - return ck_ht_gc(&ht, 0, common_lrand48()); -} - -static bool -table_reset(void) -{ - - return ck_ht_reset_spmc(&ht); -} - -static void -keys_shuffle(char **k) -{ - size_t i, j; - char *t; - - for (i = keys_length; i > 1; i--) { - j = rand() % (i - 1); - - if (j != i - 1) { - t = k[i - 1]; - k[i - 1] = k[j]; - k[j] = t; - } - } - - return; -} - -int -main(int argc, char *argv[]) -{ - FILE *fp; - char buffer[512]; - size_t i, j, r; - unsigned int d = 0; - uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng, gg; - char **t; - struct ck_ht_stat st; - - r = 20; - s = 8; - srand(time(NULL)); - - if (argc < 2) { - ck_error("Usage: ck_ht [ ]\n"); - } - - if (argc >= 3) - r = atoi(argv[2]); - - if (argc >= 4) - s = (uint64_t)atoi(argv[3]); - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(argv[1], "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - table_init(); - - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - ck_ht_stat(&ht, &st); - - fprintf(stderr, "# %zu entries stored, %u duplicates, %" PRIu64 " probe.\n", - table_count(), d, st.probe_maximum); - - fprintf(stderr, "# reverse_insertion serial_insertion random_insertion serial_replace reverse_get serial_get random_get serial_remove negative_get garbage_collect\n\n"); - - a = 0; - for (j = 0; j < r; j++) { - if (table_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = keys_length; i > 0; i--) - d += table_insert(keys[i - 1]) == false; - e = rdtsc(); - a += e - s; - } - ri = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - if (table_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - si = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - if (table_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += table_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - ai = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - sr = a / (r * keys_length); - - table_reset(); - for (i = 0; i < keys_length; i++) - table_insert(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = keys_length; i > 0; i--) { - if (table_get(keys[i - 1]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - rg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (table_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - sg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (table_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - ag = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - table_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - table_insert(keys[i]); - } - sd = a / (r * keys_length); - - for (i = 0; i < keys_length / 2; i++) - table_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - table_gc(); - e = rdtsc(); - a += e - s; - } - gg = a / r; - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - table_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - ng = a / (r * keys_length); - - printf("%zu " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 "\n", - keys_length, ri, si, ai, sr, rg, sg, ag, sd, ng, gg); - - return 0; -} diff --git a/regressions/ck_ht/validate/Makefile b/regressions/ck_ht/validate/Makefile deleted file mode 100644 index cb5682c25069..000000000000 --- a/regressions/ck_ht/validate/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=serial serial.delete - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_ht.c - -serial.delete: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c - $(CC) $(CFLAGS) -DHT_DELETE -o serial.delete serial.c ../../../src/ck_ht.c - -check: all - ./serial - ./serial.delete - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ht/validate/serial.c b/regressions/ck_ht/validate/serial.c deleted file mode 100644 index 9a85c2f7cc19..000000000000 --- a/regressions/ck_ht/validate/serial.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include "../../common.h" -#include "../../../src/ck_ht_hash.h" - -static size_t hash_times_called = 0; - -static void * -ht_malloc(size_t r) -{ - - return malloc(r); -} - -static void -ht_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - free(p); - return; -} - -static void -ht_hash_wrapper(struct ck_ht_hash *h, - const void *key, - size_t length, - uint64_t seed) -{ - hash_times_called++; - - h->value = (unsigned long)MurmurHash64A(key, length, seed); - return; -} - -static struct ck_malloc my_allocator = { - .malloc = ht_malloc, - .free = ht_free -}; - -const char *test[] = {"Samy", "Al", "Bahra", "dances", "in", "the", "wind.", "Once", - "upon", "a", "time", "his", "gypsy", "ate", "one", "itsy", - "bitsy", "spider.", "What", "goes", "up", "must", - "come", "down.", "What", "is", "down", "stays", - "down.", "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O"}; - -static uintptr_t direct[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 3, 4, 5, 9 }; - -const char *negative = "negative"; - -int -main(void) -{ - size_t i, l; - ck_ht_t ht; - ck_ht_entry_t entry; - ck_ht_hash_t h; - ck_ht_iterator_t iterator = CK_HT_ITERATOR_INITIALIZER; - ck_ht_entry_t *cursor; - unsigned int mode = CK_HT_MODE_BYTESTRING; - -#ifdef HT_DELETE - mode |= CK_HT_WORKLOAD_DELETE; -#endif - - if (ck_ht_init(&ht, mode, ht_hash_wrapper, &my_allocator, 2, 6602834) == false) { - perror("ck_ht_init"); - exit(EXIT_FAILURE); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_set(&entry, h, test[i], l, test[i]); - ck_ht_put_spmc(&ht, h, &entry); - } - - l = strlen(test[0]); - ck_ht_hash(&h, &ht, test[0], l); - ck_ht_entry_set(&entry, h, test[0], l, test[0]); - ck_ht_put_spmc(&ht, h, &entry); - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_key_set(&entry, test[i], l); - if (ck_ht_get_spmc(&ht, h, &entry) == false) { - ck_error("ERROR (put): Failed to find [%s]\n", test[i]); - } else { - void *k, *v; - - k = ck_ht_entry_key(&entry); - v = ck_ht_entry_value(&entry); - - if (strcmp(k, test[i]) || strcmp(v, test[i])) { - ck_error("ERROR: Mismatch: (%s, %s) != (%s, %s)\n", - (char *)k, (char *)v, test[i], test[i]); - } - } - } - - ck_ht_hash(&h, &ht, negative, strlen(negative)); - ck_ht_entry_key_set(&entry, negative, strlen(negative)); - if (ck_ht_get_spmc(&ht, h, &entry) == true) { - ck_error("ERROR: Found non-existing entry.\n"); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_key_set(&entry, test[i], l); - - if (ck_ht_get_spmc(&ht, h, &entry) == false) - continue; - - if (ck_ht_remove_spmc(&ht, h, &entry) == false) { - ck_error("ERROR: Failed to delete existing entry\n"); - } - - if (ck_ht_get_spmc(&ht, h, &entry) == true) - ck_error("ERROR: Able to find [%s] after delete\n", test[i]); - - ck_ht_entry_set(&entry, h, test[i], l, test[i]); - if (ck_ht_put_spmc(&ht, h, &entry) == false) - ck_error("ERROR: Failed to insert [%s]\n", test[i]); - - if (ck_ht_remove_spmc(&ht, h, &entry) == false) { - ck_error("ERROR: Failed to delete existing entry\n"); - } - } - - ck_ht_reset_spmc(&ht); - if (ck_ht_count(&ht) != 0) { - ck_error("ERROR: Map was not reset.\n"); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_set(&entry, h, test[i], l, test[i]); - ck_ht_put_spmc(&ht, h, &entry); - } - - for (i = 0; ck_ht_next(&ht, &iterator, &cursor) == true; i++); - if (i != 42) { - ck_error("ERROR: Incorrect number of entries in table.\n"); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_set(&entry, h, test[i], l, test[i]); - ck_ht_set_spmc(&ht, h, &entry); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_key_set(&entry, test[i], l); - if (ck_ht_get_spmc(&ht, h, &entry) == false) { - ck_error("ERROR (set): Failed to find [%s]\n", test[i]); - } else { - void *k, *v; - - k = ck_ht_entry_key(&entry); - v = ck_ht_entry_value(&entry); - - if (strcmp(k, test[i]) || strcmp(v, test[i])) { - ck_error("ERROR: Mismatch: (%s, %s) != (%s, %s)\n", - (char *)k, (char *)v, test[i], test[i]); - } - } - } - - if (ck_ht_gc(&ht, 0, 27) == false) { - ck_error("ck_ht_gc\n"); - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_set(&entry, h, test[i], l, "REPLACED"); - ck_ht_set_spmc(&ht, h, &entry); - - if (strcmp(test[i], "What") == 0) - continue; - - if (strcmp(test[i], "down.") == 0) - continue; - - if (strcmp(ck_ht_entry_value(&entry), test[i]) != 0) { - ck_error("Mismatch detected: %s, expected %s\n", - (char *)ck_ht_entry_value(&entry), - test[i]); - } - } - - ck_ht_iterator_init(&iterator); - while (ck_ht_next(&ht, &iterator, &cursor) == true) { - if (strcmp(ck_ht_entry_value(cursor), "REPLACED") != 0) { - ck_error("Mismatch detected: %s, expected REPLACED\n", - (char *)ck_ht_entry_value(cursor)); - } - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - l = strlen(test[i]); - ck_ht_hash(&h, &ht, test[i], l); - ck_ht_entry_key_set(&entry, test[i], l); - - if (ck_ht_get_spmc(&ht, h, &entry) == false) - continue; - - if (ck_ht_remove_spmc(&ht, h, &entry) == false) { - ck_error("ERROR: Failed to delete existing entry\n"); - } - - if (ck_ht_get_spmc(&ht, h, &entry) == true) - ck_error("ERROR: Able to find [%s] after delete\n", test[i]); - - ck_ht_entry_set(&entry, h, test[i], l, test[i]); - if (ck_ht_put_spmc(&ht, h, &entry) == false) - ck_error("ERROR: Failed to insert [%s]\n", test[i]); - - if (ck_ht_remove_spmc(&ht, h, &entry) == false) { - ck_error("ERROR: Failed to delete existing entry\n"); - } - } - - ck_ht_destroy(&ht); - - if (hash_times_called == 0) { - ck_error("ERROR: Our hash function was not called!\n"); - } - - hash_times_called = 0; - - if (ck_ht_init(&ht, CK_HT_MODE_DIRECT, ht_hash_wrapper, &my_allocator, 8, 6602834) == false) { - perror("ck_ht_init"); - exit(EXIT_FAILURE); - } - - l = 0; - for (i = 0; i < sizeof(direct) / sizeof(*direct); i++) { - ck_ht_hash_direct(&h, &ht, direct[i]); - ck_ht_entry_set_direct(&entry, h, direct[i], (uintptr_t)test[i]); - l += ck_ht_put_spmc(&ht, h, &entry) == false; - } - - if (l != 7) { - ck_error("ERROR: Got %zu failures rather than 7\n", l); - } - - for (i = 0; i < sizeof(direct) / sizeof(*direct); i++) { - ck_ht_hash_direct(&h, &ht, direct[i]); - ck_ht_entry_set_direct(&entry, h, direct[i], (uintptr_t)"REPLACED"); - l += ck_ht_set_spmc(&ht, h, &entry) == false; - } - - ck_ht_iterator_init(&iterator); - while (ck_ht_next(&ht, &iterator, &cursor) == true) { - if (strcmp(ck_ht_entry_value(cursor), "REPLACED") != 0) { - ck_error("Mismatch detected: %s, expected REPLACED\n", - (char *)ck_ht_entry_value(cursor)); - } - } - - ck_ht_destroy(&ht); - - if (hash_times_called == 0) { - ck_error("ERROR: Our hash function was not called!\n"); - } - - return 0; -} diff --git a/regressions/ck_pflock/benchmark/Makefile b/regressions/ck_pflock/benchmark/Makefile deleted file mode 100644 index 6f739d93c408..000000000000 --- a/regressions/ck_pflock/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_rwlock.h - $(CC) $(CFLAGS) -o latency latency.c - -throughput: throughput.c ../../../include/ck_rwlock.h - $(CC) $(CFLAGS) -o throughput throughput.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pflock/benchmark/latency.c b/regressions/ck_pflock/benchmark/latency.c deleted file mode 100644 index a28c9dd5b627..000000000000 --- a/regressions/ck_pflock/benchmark/latency.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2013 John Wittrock. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHEPFISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_pflock_t pflock = CK_PFLOCK_INITIALIZER; - - for (i = 0; i < STEPS; i++) { - ck_pflock_write_lock(&pflock); - ck_pflock_write_unlock(&pflock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_pflock_write_lock(&pflock); - ck_pflock_write_unlock(&pflock); - } - e_b = rdtsc(); - printf("WRITE: pflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - } - e_b = rdtsc(); - printf("READ: pflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return 0; -} - diff --git a/regressions/ck_pflock/benchmark/throughput.c b/regressions/ck_pflock/benchmark/throughput.c deleted file mode 100644 index 429465f9adab..000000000000 --- a/regressions/ck_pflock/benchmark/throughput.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2013 John Wittrock. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHEPFISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static int barrier; -static int threads; -static unsigned int flag CK_CC_CACHELINE; -static ck_pflock_t pflock = CK_PFLOCK_INITIALIZER; -static struct affinity affinity; - -static void * -thread_pflock(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - ck_pflock_read_lock(&pflock); - ck_pflock_read_unlock(&pflock); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int t; - pthread_t *p; - uint64_t *latency; - - if (argc != 3) { - ck_error("Usage: throughput \n"); - } - - threads = atoi(argv[2]); - if (threads <= 0) { - ck_error("ERROR: Threads must be a value > 0.\n"); - } - - p = malloc(sizeof(pthread_t) * threads); - if (p == NULL) { - ck_error("ERROR: Failed to initialize thread.\n"); - } - - latency = malloc(sizeof(uint64_t) * threads); - if (latency == NULL) { - ck_error("ERROR: Failed to create latency buffer.\n"); - } - - affinity.delta = atoi(argv[1]); - affinity.request = 0; - - fprintf(stderr, "Creating threads (pflock)..."); - for (t = 0; t < threads; t++) { - if (pthread_create(&p[t], NULL, thread_pflock, latency + t) != 0) { - ck_error("ERROR: Could not create thread %d\n", t); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (t = 0; t < threads; t++) - pthread_join(p[t], NULL); - fprintf(stderr, "done\n\n"); - - for (t = 1; t <= threads; t++) - printf("%10u %20" PRIu64 "\n", t, latency[t - 1]); - - return 0; -} - diff --git a/regressions/ck_pflock/validate/Makefile b/regressions/ck_pflock/validate/Makefile deleted file mode 100644 index eea9d022ce31..000000000000 --- a/regressions/ck_pflock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_pflock.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pflock/validate/validate.c b/regressions/ck_pflock/validate/validate.c deleted file mode 100644 index 2551755de2f5..000000000000 --- a/regressions/ck_pflock/validate/validate.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra, John Wittrock. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked; -static int nthr; -static ck_pflock_t lock = CK_PFLOCK_INITIALIZER; - -static void * -thread(void *null CK_CC_UNUSED) -{ - int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - ck_pflock_write_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_pflock_write_unlock(&lock); - - ck_pflock_read_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_pflock_read_unlock(&lock); - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - int i; - - if (argc != 3) { - ck_error("Usage: validate \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - fprintf(stderr, "Creating threads (mutual exclusion)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return 0; -} - diff --git a/regressions/ck_pr/benchmark/Makefile b/regressions/ck_pr/benchmark/Makefile deleted file mode 100644 index ae44b330d89e..000000000000 --- a/regressions/ck_pr/benchmark/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -.PHONY: clean - -all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 fp - -fp: fp.c - $(CC) $(CFLAGS) -o fp fp.c - -ck_pr_cas_64_2: ck_pr_cas_64_2.c - $(CC) $(CFLAGS) -o ck_pr_cas_64_2 ck_pr_cas_64_2.c -lm - -ck_pr_cas_64: ck_pr_cas_64.c - $(CC) $(CFLAGS) -o ck_pr_cas_64 ck_pr_cas_64.c -lm - -ck_pr_fas_64: ck_pr_fas_64.c - $(CC) $(CFLAGS) -o ck_pr_fas_64 ck_pr_fas_64.c -lm - -clean: - rm -rf ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_pr/benchmark/benchmark.h b/regressions/ck_pr/benchmark/benchmark.h deleted file mode 100644 index f9e4ed2f02a5..000000000000 --- a/regressions/ck_pr/benchmark/benchmark.h +++ /dev/null @@ -1,130 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" - -/* 8! = 40320, evenly divide 1 .. 8 processor workload. */ -#define WORKLOAD (40320 * 2056) - -struct block { - unsigned int tid; -}; - -static struct affinity a; -static unsigned int ready; -static uint64_t *count; -static uint64_t nthr; - -static uint64_t object[2] CK_CC_CACHELINE; - -static void * -fairness(void *null) -{ - struct block *context = null; - unsigned int i = context->tid; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (ck_pr_load_uint(&ready) == 0); - while (ck_pr_load_uint(&ready)) { - ATOMIC; - ATOMIC; - ATOMIC; - ATOMIC; - ck_pr_store_64(count + i, count[i] + 1); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - uint64_t v, d; - unsigned int i; - pthread_t *threads; - struct block *context; - - if (argc != 3) { - ck_error("Usage: " ATOMIC_STRING " \n"); - exit(EXIT_FAILURE); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - exit(EXIT_FAILURE); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - exit(EXIT_FAILURE); - } - - context = malloc(sizeof(struct block) * nthr); - if (context == NULL) { - ck_error("ERROR: Could not allocate thread contexts\n"); - exit(EXIT_FAILURE); - } - - a.delta = atoi(argv[2]); - a.request = 0; - - count = malloc(sizeof(uint64_t) * nthr); - if (count == NULL) { - ck_error("ERROR: Could not create acquisition buffer\n"); - exit(EXIT_FAILURE); - } - memset(count, 0, sizeof(uint64_t) * nthr); - - fprintf(stderr, "Creating threads (fairness)..."); - for (i = 0; i < nthr; i++) { - context[i].tid = i; - if (pthread_create(&threads[i], NULL, fairness, context + i)) { - ck_error("ERROR: Could not create thread %d\n", i); - exit(EXIT_FAILURE); - } - } - fprintf(stderr, "done\n"); - - ck_pr_store_uint(&ready, 1); - common_sleep(10); - ck_pr_store_uint(&ready, 0); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done\n\n"); - - for (i = 0, v = 0; i < nthr; i++) { - printf("%d %15" PRIu64 "\n", i, count[i]); - v += count[i]; - } - - printf("\n# total : %15" PRIu64 "\n", v); - printf("# throughput : %15" PRIu64 " a/s\n", (v /= nthr) / 10); - - for (i = 0, d = 0; i < nthr; i++) - d += (count[i] - v) * (count[i] - v); - - printf("# average : %15" PRIu64 "\n", v); - printf("# deviation : %.2f (%.2f%%)\n\n", sqrt(d / nthr), (sqrt(d / nthr) / v) * 100.00); - - return (0); -} - diff --git a/regressions/ck_pr/benchmark/ck_pr_cas_64.c b/regressions/ck_pr/benchmark/ck_pr_cas_64.c deleted file mode 100644 index 90dcb64b0e7a..000000000000 --- a/regressions/ck_pr/benchmark/ck_pr_cas_64.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#ifdef CK_F_PR_CAS_64 -#define ATOMIC ck_pr_cas_64(object, 1, 1) -#define ATOMIC_STRING "ck_pr_cas_64" -#include "benchmark.h" -#else -#warning Did not find CAS_64 implementation. -#include - -int -main(void) -{ - exit(EXIT_FAILURE); -} -#endif diff --git a/regressions/ck_pr/benchmark/ck_pr_cas_64_2.c b/regressions/ck_pr/benchmark/ck_pr_cas_64_2.c deleted file mode 100644 index e959b39b2c5f..000000000000 --- a/regressions/ck_pr/benchmark/ck_pr_cas_64_2.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#ifdef CK_F_PR_CAS_64_2 -#define ATOMIC { uint64_t z[2] = {1, 2}; ck_pr_cas_64_2(object, z, z); } -#define ATOMIC_STRING "ck_pr_cas_64_2" -#include "benchmark.h" -#else -#include -#include - -int -main(void) -{ - fprintf(stderr, "Unsupported.\n"); - return 0; -} -#endif diff --git a/regressions/ck_pr/benchmark/ck_pr_fas_64.c b/regressions/ck_pr/benchmark/ck_pr_fas_64.c deleted file mode 100644 index facd7590c24b..000000000000 --- a/regressions/ck_pr/benchmark/ck_pr_fas_64.c +++ /dev/null @@ -1,17 +0,0 @@ -#include - -#ifdef CK_F_PR_FAS_64 -#define ATOMIC ck_pr_fas_64(object, 1) -#define ATOMIC_STRING "ck_pr_fas_64" -#include "benchmark.h" -#else -#warning Did not find FAS_64 implementation. -#include - -int -main(void) -{ - - return 0; -} -#endif diff --git a/regressions/ck_pr/benchmark/fp.c b/regressions/ck_pr/benchmark/fp.c deleted file mode 100644 index f7aa157017ed..000000000000 --- a/regressions/ck_pr/benchmark/fp.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - -#include "../../common.h" - -#ifndef IR -#define IR 3000000 -#endif /* IR */ - -static int a CK_CC_CACHELINE; -static int b CK_CC_CACHELINE; - -int -main(void) -{ - uint64_t s, e; - unsigned int i; - - s = rdtsc(); - for (i = 0; i < IR; i++) { - ck_pr_load_int(&a); - ck_pr_fence_strict_load(); - ck_pr_load_int(&b); - } - e = rdtsc(); - printf("[A] fence_load: %" PRIu64 "\n", (e - s) / IR); - - s = rdtsc(); - for (i = 0; i < IR; i++) { - if (ck_pr_load_int(&a) == 0) - ck_pr_barrier(); - ck_pr_fence_strict_lock(); - ck_pr_load_int(&b); - } - e = rdtsc(); - printf("[A] fence_lock: %" PRIu64 "\n", (e - s) / IR); - - s = rdtsc(); - for (i = 0; i < IR; i++) { - ck_pr_store_int(&a, 0); - ck_pr_fence_strict_store(); - ck_pr_store_int(&b, 0); - } - e = rdtsc(); - printf("[B] fence_store: %" PRIu64 "\n", (e - s) / IR); - - s = rdtsc(); - for (i = 0; i < IR; i++) { - ck_pr_store_int(&a, 0); - ck_pr_fence_strict_memory(); - ck_pr_load_int(&b); - } - e = rdtsc(); - printf("[C] fence_memory: %" PRIu64 "\n", (e - s) / IR); - - s = rdtsc(); - for (i = 0; i < IR; i++) { - ck_pr_store_int(&a, 0); - ck_pr_faa_int(&a, 0); - ck_pr_load_int(&b); - } - e = rdtsc(); - printf("[C] atomic: %" PRIu64 "\n", (e - s) / IR); - return 0; -} diff --git a/regressions/ck_pr/validate/Makefile b/regressions/ck_pr/validate/Makefile deleted file mode 100644 index 9e4a82d16620..000000000000 --- a/regressions/ck_pr/validate/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_pr_cas ck_pr_faa ck_pr_inc ck_pr_dec ck_pr_bts \ - ck_pr_btr ck_pr_btc ck_pr_load ck_pr_store \ - ck_pr_and ck_pr_or ck_pr_xor ck_pr_add ck_pr_sub \ - ck_pr_fas ck_pr_bin ck_pr_btx ck_pr_fax ck_pr_n \ - ck_pr_unary - -all: $(OBJECTS) - -check: all - for d in $(OBJECTS) ; do \ - echo $$d; \ - ./$$d || exit 1; \ - done; - -ck_pr_cas: ck_pr_cas.c - $(CC) $(CFLAGS) -o ck_pr_cas ck_pr_cas.c - -ck_pr_inc: ck_pr_inc.c - $(CC) $(CFLAGS) -o ck_pr_inc ck_pr_inc.c - -ck_pr_dec: ck_pr_dec.c - $(CC) $(CFLAGS) -o ck_pr_dec ck_pr_dec.c - -ck_pr_faa: ck_pr_faa.c - $(CC) $(CFLAGS) -o ck_pr_faa ck_pr_faa.c - -ck_pr_btc: ck_pr_btc.c - $(CC) $(CFLAGS) -o ck_pr_btc ck_pr_btc.c - -ck_pr_btr: ck_pr_btr.c - $(CC) $(CFLAGS) -o ck_pr_btr ck_pr_btr.c - -ck_pr_bts: ck_pr_bts.c - $(CC) $(CFLAGS) -o ck_pr_bts ck_pr_bts.c - -ck_pr_load: ck_pr_load.c - $(CC) $(CFLAGS) -o ck_pr_load ck_pr_load.c - -ck_pr_store: ck_pr_store.c - $(CC) $(CFLAGS) -o ck_pr_store ck_pr_store.c - -ck_pr_and: ck_pr_and.c - $(CC) $(CFLAGS) -o ck_pr_and ck_pr_and.c - -ck_pr_or: ck_pr_or.c - $(CC) $(CFLAGS) -o ck_pr_or ck_pr_or.c - -ck_pr_xor: ck_pr_xor.c - $(CC) $(CFLAGS) -o ck_pr_xor ck_pr_xor.c - -ck_pr_add: ck_pr_add.c - $(CC) $(CFLAGS) -o ck_pr_add ck_pr_add.c - -ck_pr_sub: ck_pr_sub.c - $(CC) $(CFLAGS) -o ck_pr_sub ck_pr_sub.c - -ck_pr_fas: ck_pr_fas.c - $(CC) $(CFLAGS) -o ck_pr_fas ck_pr_fas.c - -ck_tp: ck_tp.c - $(CC) $(CFLAGS) -o ck_tp ck_tp.c - -ck_pr_bin: ck_pr_bin.c - $(CC) $(CFLAGS) -o ck_pr_bin ck_pr_bin.c - -ck_pr_btx: ck_pr_btx.c - $(CC) $(CFLAGS) -o ck_pr_btx ck_pr_btx.c - -ck_pr_fax: ck_pr_fax.c - $(CC) $(CFLAGS) -o ck_pr_fax ck_pr_fax.c - -ck_pr_n: ck_pr_n.c - $(CC) $(CFLAGS) -o ck_pr_n ck_pr_n.c - -ck_pr_unary: ck_pr_unary.c - $(CC) $(CFLAGS) -o ck_pr_unary ck_pr_unary.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_pr/validate/ck_pr_add.c b/regressions/ck_pr/validate/ck_pr_add.c deleted file mode 100644 index 31f1893ec617..000000000000 --- a/regressions/ck_pr/validate/ck_pr_add.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_ADD_T(w, v, d) \ - { \ - uint##w##_t t = v; \ - ck_pr_add_##w(&t, d); \ - if (t != (uint##w##_t)(v + d)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w "]\n",\ - (uint##w##_t)v, d, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_ADD_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_add_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % ((uint##w##_t)-1 / 2); \ - uint##w##_t b = common_rand() % ((uint##w##_t)-1 / 2); \ - CK_PR_ADD_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_ADD_W(m, w) \ - { \ - uint##m##_t t = -1, r = -1 & ~(uint##m##_t)(uint##w##_t)-1; \ - ck_pr_add_##w((uint##w##_t *)(void *)&t, 1); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - t = 0, r = (uint##m##_t)(uint##w##_t)-1; \ - ck_pr_add_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_ADD_64 - if (m == 64) { -#if defined(CK_F_PR_ADD_32) - CK_PR_ADD_W(64, 32); -#endif -#if defined(CK_PR_ADD_16) - CK_PR_ADD_W(64, 16); -#endif -#if defined(CK_PR_ADD_8) - CK_PR_ADD_W(64, 8); -#endif - } -#endif /* CK_PR_ADD_64 */ - -#ifdef CK_F_PR_ADD_32 - if (m == 32) { -#if defined(CK_F_PR_ADD_16) - CK_PR_ADD_W(32, 16); -#endif -#if defined(CK_PR_ADD_8) - CK_PR_ADD_W(32, 8); -#endif - } -#endif /* CK_PR_ADD_32 */ - -#if defined(CK_F_PR_ADD_16) && defined(CK_PR_ADD_8) - if (m == 16) { - CK_PR_ADD_W(16, 8); - } -#endif /* CK_PR_ADD_16 && CK_PR_ADD_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_ADD_64 - CK_PR_ADD_B(64); -#endif - -#ifdef CK_F_PR_ADD_32 - CK_PR_ADD_B(32); -#endif - -#ifdef CK_F_PR_ADD_16 - CK_PR_ADD_B(16); -#endif - -#ifdef CK_F_PR_ADD_8 - CK_PR_ADD_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_and.c b/regressions/ck_pr/validate/ck_pr_and.c deleted file mode 100644 index 4c569bbd1105..000000000000 --- a/regressions/ck_pr/validate/ck_pr_and.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define BM(m, w) ((uint##m##_t)-1 << (w)) - -#define CK_PR_AND_T(w, v, d) \ - { \ - uint##w##_t t = v; \ - ck_pr_and_##w(&t, d); \ - if (t != (uint##w##_t)(v & d)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w "]\n",\ - (uint##w##_t)v, d, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_AND_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_and_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = (uint##w##_t)common_rand(); \ - uint##w##_t b = (uint##w##_t)common_rand(); \ - CK_PR_AND_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_AND_W(m, w) \ - { \ - uint##m##_t t = -1; \ - ck_pr_and_##w((uint##w##_t *)(void *)&t, 0); \ - if (t != BM(m, w)) { \ - printf(" FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, BM(m, w)); \ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_AND_64 - if (m == 64) { -#if defined(CK_F_PR_AND_32) - CK_PR_AND_W(64, 32); -#endif -#if defined(CK_PR_AND_16) - CK_PR_AND_W(64, 16); -#endif -#if defined(CK_PR_AND_8) - CK_PR_AND_W(64, 8); -#endif - } -#endif /* CK_PR_AND_64 */ - -#ifdef CK_F_PR_AND_32 - if (m == 32) { -#if defined(CK_F_PR_AND_16) - CK_PR_AND_W(32, 16); -#endif -#if defined(CK_PR_AND_8) - CK_PR_AND_W(32, 8); -#endif - } -#endif /* CK_PR_AND_32 */ - -#if defined(CK_F_PR_AND_16) && defined(CK_PR_AND_8) - if (m == 16) { - CK_PR_AND_W(16, 8); - } -#endif /* CK_PR_AND_16 && CK_PR_AND_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_AND_64 - CK_PR_AND_B(64); -#endif - -#ifdef CK_F_PR_AND_32 - CK_PR_AND_B(32); -#endif - -#ifdef CK_F_PR_AND_16 - CK_PR_AND_B(16); -#endif - -#ifdef CK_F_PR_AND_8 - CK_PR_AND_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_bin.c b/regressions/ck_pr/validate/ck_pr_bin.c deleted file mode 100644 index 31868f4e64aa..000000000000 --- a/regressions/ck_pr/validate/ck_pr_bin.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" -#define REPEAT 2000000 - -#define TEST_BINARY(K, S, T, P, D) \ - static void \ - run_test_##K##_##S(void) \ - { \ - int i, r; \ - T serial_result = 65535; \ - T ck_result = 65535; \ - \ - puts("***TESTING ck_pr_" #K "_" #S "***"); \ - common_srand((unsigned int)getpid()); \ - for (i = 0; i < REPEAT; ++i) { \ - r = common_rand(); \ - serial_result = serial_result P r; \ - ck_pr_##K##_##S(&ck_result, r); \ - } \ - \ - printf("Value of operation " #K " on 2000000 " \ - "random numbers\n\tusing " #P ": %" #D ",\n" \ - "\tusing ck_pr_"#K"_"#S": %" #D "\n", \ - serial_result, ck_result); \ - (serial_result == ck_result) ? puts("SUCCESS.") \ - : puts("FAILURE."); \ - \ - return; \ - } \ - -#define GENERATE_TEST(K, P) \ - TEST_BINARY(K, int, int, P, d) \ - TEST_BINARY(K, uint, unsigned int, P, u) \ - static void \ - run_test_##K(void) \ - { \ - run_test_##K##_int(); \ - run_test_##K##_uint(); \ - \ - return; \ - } - -GENERATE_TEST(add, +) -GENERATE_TEST(sub, -) -GENERATE_TEST(and, &) -GENERATE_TEST(or, |) -GENERATE_TEST(xor, ^) - -#undef GENERATE_TEST -#undef TEST_BINARY - -int -main(void) -{ - run_test_add(); - run_test_sub(); - run_test_and(); - run_test_or(); - run_test_xor(); - - return (0); -} - - diff --git a/regressions/ck_pr/validate/ck_pr_btc.c b/regressions/ck_pr/validate/ck_pr_btc.c deleted file mode 100644 index 0edec98b003c..000000000000 --- a/regressions/ck_pr/validate/ck_pr_btc.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -/* - * Bit selector. - */ -#define BM(v, b) (((v) >> (b)) & 1) - -#define CK_PR_BTC_T(w, v) \ - { \ - unsigned int j; \ - uint##w##_t r = v; \ - bool t; \ - for (j = 0; j < (w); j++) { \ - t = ck_pr_btc_##w(&r, j); \ - if ((t && !BM(v, j)) || ((BM(v, j) + BM(r, j)) != 1)) { \ - printf("FAIL [%" PRIx##w ":%u]\n", r, j); \ - exit(EXIT_FAILURE); \ - } \ - } \ - } - -#define CK_PR_BTC_B(w) \ - { \ - uint##w##_t o; \ - unsigned int i; \ - printf("ck_pr_btc_" #w ": "); \ - for (i = 0; i < R_REPEAT; i++) { \ - o = (uint##w##_t)common_rand(); \ - CK_PR_BTC_T(w, o); \ - } \ - printf(" SUCCESS\n"); \ - } - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_BTC_64 - CK_PR_BTC_B(64); -#endif - -#ifdef CK_F_PR_BTC_32 - CK_PR_BTC_B(32); -#endif - -#ifdef CK_F_PR_BTC_16 - CK_PR_BTC_B(16); -#endif - -#ifdef CK_F_PR_BTC_8 - CK_PR_BTC_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_btr.c b/regressions/ck_pr/validate/ck_pr_btr.c deleted file mode 100644 index 91abb302c727..000000000000 --- a/regressions/ck_pr/validate/ck_pr_btr.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -/* - * Bit selector. - */ -#define BM(v, b) (((v) >> (b)) & 1) - -#define CK_PR_BTR_T(w, v) \ - { \ - unsigned int j; \ - uint##w##_t r = v, c = v; \ - bool t; \ - for (j = 0; j < (w); j++) { \ - c &= (uint##w##_t)-1 ^ (1 << j); \ - t = ck_pr_btr_##w(&r, j); \ - if ((t && !BM(v, j)) || (r != c)) { \ - printf("FAIL [%" PRIx##w ":%u != %" PRIx##w ":%u]\n", r, j, c, j); \ - exit(EXIT_FAILURE); \ - } \ - } \ - } - -#define CK_PR_BTR_B(w) \ - { \ - uint##w##_t o; \ - unsigned int i; \ - printf("ck_pr_btr_" #w ": "); \ - for (i = 0; i < R_REPEAT; i++) { \ - o = (uint##w##_t)common_rand(); \ - CK_PR_BTR_T(w, o); \ - } \ - printf(" SUCCESS\n"); \ - } - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_BTR_64 - CK_PR_BTR_B(64); -#endif - -#ifdef CK_F_PR_BTR_32 - CK_PR_BTR_B(32); -#endif - -#ifdef CK_F_PR_BTR_16 - CK_PR_BTR_B(16); -#endif - -#ifdef CK_F_PR_BTR_8 - CK_PR_BTR_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_bts.c b/regressions/ck_pr/validate/ck_pr_bts.c deleted file mode 100644 index 1e621651a778..000000000000 --- a/regressions/ck_pr/validate/ck_pr_bts.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -/* - * Bit selector. - */ -#define BM(v, b) (((v) >> (b)) & 1) - -#define CK_PR_BTS_T(w, v) \ - { \ - unsigned int j; \ - uint##w##_t r = v, c = v; \ - bool t; \ - for (j = 0; j < (w); j++) { \ - c |= (uint##w##_t)1 << j; \ - t = ck_pr_bts_##w(&r, j); \ - if ((t && !BM(v, j)) || (r != c)) { \ - printf("FAIL [%" PRIx##w ":%u != %" PRIx##w ":%u]\n", r, j, c, j); \ - exit(EXIT_FAILURE); \ - } \ - } \ - } - -#define CK_PR_BTS_B(w) \ - { \ - uint##w##_t o; \ - unsigned int i; \ - printf("ck_pr_bts_" #w ": "); \ - for (i = 0; i < R_REPEAT; i++) { \ - o = (uint##w##_t)common_rand(); \ - CK_PR_BTS_T(w, o); \ - } \ - printf(" SUCCESS\n"); \ - } - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_BTS_64 - CK_PR_BTS_B(64); -#endif - -#ifdef CK_F_PR_BTS_32 - CK_PR_BTS_B(32); -#endif - -#ifdef CK_F_PR_BTS_16 - CK_PR_BTS_B(16); -#endif - -#ifdef CK_F_PR_BTS_8 - CK_PR_BTS_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_btx.c b/regressions/ck_pr/validate/ck_pr_btx.c deleted file mode 100644 index 2bb3964e97e2..000000000000 --- a/regressions/ck_pr/validate/ck_pr_btx.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" -#define REPEAT 2000000 - -#define TEST_BTX(K, S, M, T, L, P, D, R) \ - static bool \ - test_##K##_##S(M *target, int offset) \ - { \ - T previous; \ - const L change = R (0x01 << offset); \ - \ - previous = (T)*target; \ - *target = previous P change; \ - return ((previous >> offset) & 0x01); \ - } \ - static void \ - run_test_##K##_##S(void) \ - { \ - int i, offset, m; \ - bool serial_t, ck_pr_t; \ - T x = 65535, y = 65535; \ - \ - common_srand((unsigned int)getpid()); \ - m = sizeof(T) * 8; \ - \ - puts("***TESTING ck_pr_"#K"_"#S"***"); \ - for (i = 0; i < REPEAT; ++i) { \ - offset = common_rand() % m; \ - serial_t = test_##K##_##S(&x, offset); \ - ck_pr_t = ck_pr_##K##_##S(&y, offset); \ - \ - if (serial_t != ck_pr_t || x != y ) { \ - printf("Serial(%"#D") and ck_pr(%"#D")" \ - #K"_"#S " do not match.\n" \ - "FAILURE.\n", \ - serial_t, ck_pr_t); \ - \ - return; \ - } \ - } \ - printf("\tserial_"#K"_"#S": %"#D"\n" \ - "\tck_pr_"#K"_"#S": %"#D"\n" \ - "SUCCESS.\n", \ - x, y); \ - \ - return; \ - } - -#define TEST_BTX_S(K, S, T, P, D, R) TEST_BTX(K, S, T, T, T, P, D, R) - -#define GENERATE_TEST(K, P, R) \ - TEST_BTX_S(K, int, int, P, d, R) \ - TEST_BTX_S(K, uint, unsigned int, P, u, R) \ - static void \ - run_test_##K(void) \ - { \ - run_test_##K##_int(); \ - run_test_##K##_uint(); \ - \ - return; \ - } - -GENERATE_TEST(btc, ^, 0+) -GENERATE_TEST(btr, &, ~) -GENERATE_TEST(bts, |, 0+) - -#undef GENERATE_TEST -#undef TEST_BTX_S -#undef TEST_BTX - -int -main(void) -{ - run_test_btc(); - run_test_btr(); - run_test_bts(); - - return (0); -} - - diff --git a/regressions/ck_pr/validate/ck_pr_cas.c b/regressions/ck_pr/validate/ck_pr_cas.c deleted file mode 100644 index 132d1e58c4cd..000000000000 --- a/regressions/ck_pr/validate/ck_pr_cas.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define W(w, x) (uint##w##_t)((x) & (uint##w##_t)~0) - -#define CK_PR_CAS_T(w, v, c, s) \ - { \ - uint##w##_t t = v; \ - bool r; \ - r = ck_pr_cas_##w(&t, c, s); \ - if (((c == v) && (r == false)) || ((c != v) && (r == true)) || \ - ((r == true) && (W(w, s) != t))) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w " -> %" PRIu##w ")" \ - " -> %" PRIu##w "]\n", \ - (uint##w##_t)(v), (uint##w##_t)(c), W(w, s), (uint##w##_t)(t)); \ - } \ - } - -#define CK_PR_CAS_B(w) \ - { \ - unsigned int __ck_i; \ - printf("ck_pr_cas_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % (uint##w##_t)-1; \ - CK_PR_CAS_T(w, a, a + 1, (a - 1)); \ - CK_PR_CAS_T(w, a, a, (a - 1)); \ - CK_PR_CAS_T(w, a, a + 1, a); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_CAS_W(m, w) \ - { \ - uint##m##_t t = -1, r = -1 & ~(uint##m##_t)(uint##w##_t)-1; \ - ck_pr_cas_##w((uint##w##_t *)(void *)&t, (uint##w##_t)t, 0); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", \ - (uint##m##_t)t, (uint##m##_t)r); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_CAS_64 - if (m == 64) { -#if defined(CK_F_PR_CAS_32) - CK_PR_CAS_W(64, 32); -#endif -#if defined(CK_PR_CAS_16) - CK_PR_CAS_W(64, 16); -#endif -#if defined(CK_PR_CAS_8) - CK_PR_CAS_W(64, 8); -#endif - } -#endif /* CK_PR_CAS_64 */ - -#ifdef CK_F_PR_CAS_32 - if (m == 32) { -#if defined(CK_F_PR_CAS_16) - CK_PR_CAS_W(32, 16); -#endif -#if defined(CK_PR_CAS_8) - CK_PR_CAS_W(32, 8); -#endif - } -#endif /* CK_PR_CAS_32 */ - -#if defined(CK_F_PR_CAS_16) && defined(CK_PR_CAS_8) - if (m == 16) { - CK_PR_CAS_W(16, 8); - } -#endif /* CK_PR_CAS_16 && CK_PR_CAS_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_CAS_64 - CK_PR_CAS_B(64); -#endif - -#ifdef CK_F_PR_CAS_32 - CK_PR_CAS_B(32); -#endif - -#ifdef CK_F_PR_CAS_16 - CK_PR_CAS_B(16); -#endif - -#ifdef CK_F_PR_CAS_8 - CK_PR_CAS_B(8); -#endif - -#ifdef CK_F_PR_CAS_64_VALUE - uint64_t a = 0xffffffffaaaaaaaa, b = 0x8888888800000000; - - printf("%" PRIx64 " (%" PRIx64 ") -> ", b, a); - ck_pr_cas_64_value(&a, a, b, &b); - printf("%" PRIx64 " (%" PRIx64 ")\n", b, a); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_dec.c b/regressions/ck_pr/validate/ck_pr_dec.c deleted file mode 100644 index 86ce0885a1df..000000000000 --- a/regressions/ck_pr/validate/ck_pr_dec.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_DEC_T(w, v) \ - { \ - uint##w##_t t = v; \ - ck_pr_dec_##w(&t); \ - if ((t != (uint##w##_t)(v - 1))) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " -> %" PRIu##w "]\n", (uint##w##_t)v, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_DEC_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_dec_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % ((uint##w##_t)-1); \ - CK_PR_DEC_T(w, a); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_DEC_W(m, w) \ - { \ - uint##m##_t t = 0, r = (uint##w##_t)-1; \ - ck_pr_dec_##w((uint##w##_t *)(void *)&t); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_DEC_64 - if (m == 64) { -#if defined(CK_F_PR_DEC_32) - CK_PR_DEC_W(64, 32); -#endif -#if defined(CK_PR_DEC_16) - CK_PR_DEC_W(64, 16); -#endif -#if defined(CK_PR_DEC_8) - CK_PR_DEC_W(64, 8); -#endif - } -#endif /* CK_PR_DEC_64 */ - -#ifdef CK_F_PR_DEC_32 - if (m == 32) { -#if defined(CK_F_PR_DEC_16) - CK_PR_DEC_W(32, 16); -#endif -#if defined(CK_PR_DEC_8) - CK_PR_DEC_W(32, 8); -#endif - } -#endif /* CK_PR_DEC_32 */ - -#if defined(CK_F_PR_DEC_16) && defined(CK_PR_DEC_8) - if (m == 16) { - CK_PR_DEC_W(16, 8); - } -#endif /* CK_PR_DEC_16 && CK_PR_DEC_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_DEC_64 - CK_PR_DEC_B(64); -#endif - -#ifdef CK_F_PR_DEC_32 - CK_PR_DEC_B(32); -#endif - -#ifdef CK_F_PR_DEC_16 - CK_PR_DEC_B(16); -#endif - -#ifdef CK_F_PR_DEC_8 - CK_PR_DEC_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_faa.c b/regressions/ck_pr/validate/ck_pr_faa.c deleted file mode 100644 index 1d10bb9c730e..000000000000 --- a/regressions/ck_pr/validate/ck_pr_faa.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_FAA_T(w, v, d) \ - { \ - uint##w##_t r, t = v; \ - r = ck_pr_faa_##w(&t, d); \ - if ((t != (uint##w##_t)(v + d)) || (r != v)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w \ - " (%" PRIu##w ")]\n", \ - (uint##w##_t)v, d, t, r); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_FAA_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_faa_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % ((uint##w##_t)-1 / 2); \ - uint##w##_t b = common_rand() % ((uint##w##_t)-1 / 2); \ - CK_PR_FAA_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_FAA_W(m, w) \ - { \ - uint##m##_t t = -1, r = -1 & ~(uint##m##_t)(uint##w##_t)-1; \ - ck_pr_faa_##w((uint##w##_t *)(void *)&t, 1); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - t = 0, r = (uint##m##_t)(uint##w##_t)-1; \ - ck_pr_faa_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_FAA_64 - if (m == 64) { -#if defined(CK_F_PR_FAA_32) - CK_PR_FAA_W(64, 32); -#endif -#if defined(CK_PR_FAA_16) - CK_PR_FAA_W(64, 16); -#endif -#if defined(CK_PR_FAA_8) - CK_PR_FAA_W(64, 8); -#endif - } -#endif /* CK_PR_FAA_64 */ - -#ifdef CK_F_PR_FAA_32 - if (m == 32) { -#if defined(CK_F_PR_FAA_16) - CK_PR_FAA_W(32, 16); -#endif -#if defined(CK_PR_FAA_8) - CK_PR_FAA_W(32, 8); -#endif - } -#endif /* CK_PR_FAA_32 */ - -#if defined(CK_F_PR_FAA_16) && defined(CK_PR_FAA_8) - if (m == 16) { - CK_PR_FAA_W(16, 8); - } -#endif /* CK_PR_FAA_16 && CK_PR_FAA_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_FAA_64 - CK_PR_FAA_B(64); -#endif - -#ifdef CK_F_PR_FAA_32 - CK_PR_FAA_B(32); -#endif - -#ifdef CK_F_PR_FAA_16 - CK_PR_FAA_B(16); -#endif - -#ifdef CK_F_PR_FAA_8 - CK_PR_FAA_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_fas.c b/regressions/ck_pr/validate/ck_pr_fas.c deleted file mode 100644 index 00cef4ee9f9e..000000000000 --- a/regressions/ck_pr/validate/ck_pr_fas.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define BM(m, w) ((uint##m##_t)(uint##w##_t)(-1)) - -#define CK_PR_FAS_T(w, v, d) \ - { \ - uint##w##_t r, t = v; \ - r = ck_pr_fas_##w(&t, d); \ - if ((t != d) || (r != v)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w \ - " (%" PRIu##w ")]\n", \ - (uint##w##_t)v, d, t, r); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_FAS_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_fas_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand(); \ - uint##w##_t b = common_rand(); \ - CK_PR_FAS_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_FAS_W(m, w) \ - { \ - uint##m##_t t = 0; \ - ck_pr_fas_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != BM(m, w)) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, BM(m, w)); \ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_FAS_64 - if (m == 64) { -#if defined(CK_F_PR_FAS_32) - CK_PR_FAS_W(64, 32); -#endif -#if defined(CK_PR_FAS_16) - CK_PR_FAS_W(64, 16); -#endif -#if defined(CK_PR_FAS_8) - CK_PR_FAS_W(64, 8); -#endif - } -#endif /* CK_PR_FAS_64 */ - -#ifdef CK_F_PR_FAS_32 - if (m == 32) { -#if defined(CK_F_PR_FAS_16) - CK_PR_FAS_W(32, 16); -#endif -#if defined(CK_PR_FAS_8) - CK_PR_FAS_W(32, 8); -#endif - } -#endif /* CK_PR_FAS_32 */ - -#if defined(CK_F_PR_FAS_16) && defined(CK_PR_FAS_8) - if (m == 16) { - CK_PR_FAS_W(16, 8); - } -#endif /* CK_PR_FAS_16 && CK_PR_FAS_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_FAS_64 - CK_PR_FAS_B(64); -#endif - -#ifdef CK_F_PR_FAS_32 - CK_PR_FAS_B(32); -#endif - -#ifdef CK_F_PR_FAS_16 - CK_PR_FAS_B(16); -#endif - -#ifdef CK_F_PR_FAS_8 - CK_PR_FAS_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_fax.c b/regressions/ck_pr/validate/ck_pr_fax.c deleted file mode 100644 index 9d8c94f2ef91..000000000000 --- a/regressions/ck_pr/validate/ck_pr_fax.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" -#define REPEAT 2000000 - -#define TEST_FAX_FN(S, T, M) \ - static T \ - test_faa_##S(M *target, T delta) \ - { \ - T previous = (T)*target; \ - *target = (T)*target + delta; \ - \ - return (previous); \ - } \ - static T \ - test_fas_##S(M *target, T update) \ - { \ - T previous = *target; \ - *target = update; \ - \ - return (previous); \ - } - -#define TEST_FAX_FN_S(S, T) TEST_FAX_FN(S, T, T) - -TEST_FAX_FN_S(int, int) -TEST_FAX_FN_S(uint, unsigned int) - -#undef TEST_FAX_FN_S -#undef TEST_FAX_FN - -#define TEST_FAX(K, S, T, D) \ - static void \ - run_test_##K##_##S(void) \ - { \ - int i, r; \ - T x = 0, y = 0, x_b, y_b; \ - \ - puts("***TESTING ck_pr_"#K"_"#S"***"); \ - common_srand((unsigned int)getpid()); \ - for (i = 0; i < REPEAT; ++i) { \ - r = common_rand(); \ - x_b = test_##K##_##S(&x, r); \ - y_b = ck_pr_##K##_##S(&y, r); \ - \ - if (x_b != y_b) { \ - printf("Serial fetch does not match ck_pr fetch.\n" \ - "\tSerial: %"#D"\n" \ - "\tck_pr: %"#D"\n", \ - x_b, y_b); \ - \ - return; \ - } \ - } \ - \ - printf("Final result:\n" \ - "\tSerial: %"#D"\n" \ - "\tck_pr: %"#D"\n", \ - x, y); \ - (x == y) ? puts("SUCCESS.") \ - : puts("FAILURE."); \ - \ - return; \ - } \ - - -#define GENERATE_TEST(K) \ - TEST_FAX(K, int, int, d) \ - TEST_FAX(K, uint, unsigned int, u) \ - static void \ - run_test_##K(void) \ - { \ - run_test_##K##_int(); \ - run_test_##K##_uint(); \ - } - -GENERATE_TEST(faa) -GENERATE_TEST(fas) - -#undef GENERATE_TEST -#undef TEST_FAX - -int -main(void) -{ - run_test_faa(); - run_test_fas(); - - return (0); -} - - diff --git a/regressions/ck_pr/validate/ck_pr_inc.c b/regressions/ck_pr/validate/ck_pr_inc.c deleted file mode 100644 index e8524a557c3b..000000000000 --- a/regressions/ck_pr/validate/ck_pr_inc.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_INC_T(w, v) \ - { \ - uint##w##_t t = v; \ - ck_pr_inc_##w(&t); \ - if ((t != (uint##w##_t)(v + 1))) { \ - printf("FAIL [%" PRIu##w " -> %" PRIu##w "]\n", \ - (uint##w##_t)v, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_INC_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_inc_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % ((uint##w##_t)-1); \ - CK_PR_INC_T(w, a); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_INC_W(m, w) \ - { \ - uint##m##_t t = -1, r = -1 & ~(uint##m##_t)(uint##w##_t)-1; \ - ck_pr_inc_##w((uint##w##_t *)(void *)&t); \ - if (t != r) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_INC_64 - if (m == 64) { -#if defined(CK_F_PR_INC_32) - CK_PR_INC_W(64, 32); -#endif -#if defined(CK_PR_INC_16) - CK_PR_INC_W(64, 16); -#endif -#if defined(CK_PR_INC_8) - CK_PR_INC_W(64, 8); -#endif - } -#endif /* CK_PR_INC_64 */ - -#ifdef CK_F_PR_INC_32 - if (m == 32) { -#if defined(CK_F_PR_INC_16) - CK_PR_INC_W(32, 16); -#endif -#if defined(CK_PR_INC_8) - CK_PR_INC_W(32, 8); -#endif - } -#endif /* CK_PR_INC_32 */ - -#if defined(CK_F_PR_INC_16) && defined(CK_PR_INC_8) - if (m == 16) { - CK_PR_INC_W(16, 8); - } -#endif /* CK_PR_INC_16 && CK_PR_INC_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_INC_64 - CK_PR_INC_B(64); -#endif - -#ifdef CK_F_PR_INC_32 - CK_PR_INC_B(32); -#endif - -#ifdef CK_F_PR_INC_16 - CK_PR_INC_B(16); -#endif - -#ifdef CK_F_PR_INC_8 - CK_PR_INC_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_load.c b/regressions/ck_pr/validate/ck_pr_load.c deleted file mode 100644 index a15acd0c5612..000000000000 --- a/regressions/ck_pr/validate/ck_pr_load.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_LOAD_B(w) \ - { \ - uint##w##_t t = (uint##w##_t)-1, a = 0; \ - unsigned int i; \ - printf("ck_pr_load_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - a = ck_pr_load_##w(&t); \ - if (a != t) { \ - printf("FAIL [%#" PRIx##w " != %#" PRIx##w "]\n", a, t); \ - exit(EXIT_FAILURE); \ - } \ - for (i = 0; i < R_REPEAT; i++) { \ - t = (uint##w##_t)common_rand(); \ - a = ck_pr_load_##w(&t); \ - if (a != t) { \ - printf("FAIL [%#" PRIx##w " != %#" PRIx##w "]\n", a, t);\ - exit(EXIT_FAILURE); \ - } \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_LOAD_W(m, w) \ - { \ - uint##m##_t f = 0; \ - uint##w##_t j = (uint##w##_t)-1; \ - f = ck_pr_load_##w(&j); \ - if (f != j) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##w "]\n", f, j);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_LOAD_64 - if (m == 64) { -#if defined(CK_F_PR_LOAD_32) - CK_PR_LOAD_W(64, 32); -#endif -#if defined(CK_PR_LOAD_16) - CK_PR_LOAD_W(64, 16); -#endif -#if defined(CK_PR_LOAD_8) - CK_PR_LOAD_W(64, 8); -#endif - } -#endif /* CK_PR_LOAD_64 */ - -#ifdef CK_F_PR_LOAD_32 - if (m == 32) { -#if defined(CK_F_PR_LOAD_16) - CK_PR_LOAD_W(32, 16); -#endif -#if defined(CK_PR_LOAD_8) - CK_PR_LOAD_W(32, 8); -#endif - } -#endif /* CK_PR_LOAD_32 */ - -#if defined(CK_F_PR_LOAD_16) && defined(CK_PR_LOAD_8) - if (m == 16) - CK_PR_LOAD_W(16, 8); -#endif /* CK_PR_LOAD_16 && CK_PR_LOAD_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_LOAD_64 - CK_PR_LOAD_B(64); -#endif - -#ifdef CK_F_PR_LOAD_32 - CK_PR_LOAD_B(32); -#endif - -#ifdef CK_F_PR_LOAD_16 - CK_PR_LOAD_B(16); -#endif - -#ifdef CK_F_PR_LOAD_8 - CK_PR_LOAD_B(8); -#endif - -#if 0 - uint64_t a[2] = {0, 0}, b[2] = {0x1111111144444444, 0x2222222266666666}; - printf("%" PRIx64 ":%" PRIx64 " -> ", a[0], a[1]); - ck_pr_load_64_2(&b, &a); - printf("%" PRIx64 ":%" PRIx64 "\n", a[0], a[1]); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_n.c b/regressions/ck_pr/validate/ck_pr_n.c deleted file mode 100644 index 81e363932271..000000000000 --- a/regressions/ck_pr/validate/ck_pr_n.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" -#define REPEAT 2000000 - -#define TEST_N(K, S, T, P, D) \ - static void \ - run_test_##K##_##S(void) \ - { \ - int i, r; \ - T x = 0, y = 0; \ - \ - puts("***TESTING ck_pr_"#K"_"#S"***"); \ - common_srand((unsigned int)getpid()); \ - for (i = 0; i < REPEAT; ++i) { \ - r = common_rand(); \ - x += r; \ - x = P x; \ - y += r; \ - ck_pr_##K##_##S(&y); \ - } \ - \ - printf("Value of operation "#K" on 2000000 " \ - "random numbers\n" \ - "\tusing "#P": %"#D",\n" \ - "\tusing ck_pr_"#K"_"#S": %"#D",\n", \ - x, y); \ - (x == y) ? puts("SUCCESS.") \ - : puts("FAILURE."); \ - \ - return; \ - } - -#define GENERATE_TEST(K, P) \ - TEST_N(K, int, int, P, d) \ - TEST_N(K, uint, unsigned int, P, u) \ - static void \ - run_test_##K(void) \ - { \ - run_test_##K##_int(); \ - run_test_##K##_uint(); \ - \ - return; \ - } - -GENERATE_TEST(not, ~) -GENERATE_TEST(neg, -) - -#undef GENERATE_TEST -#undef TEST_N - -int -main(void) -{ - run_test_not(); - run_test_neg(); - - return (0); -} - - diff --git a/regressions/ck_pr/validate/ck_pr_or.c b/regressions/ck_pr/validate/ck_pr_or.c deleted file mode 100644 index 27580c382f57..000000000000 --- a/regressions/ck_pr/validate/ck_pr_or.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define BM(m, w) (uint##m##_t)(uint##w##_t)-1 - -#define CK_PR_OR_T(w, v, d) \ - { \ - uint##w##_t t; \ - ck_pr_or_##w(&t, 1ULL << (w - 1)); \ - t = v; \ - ck_pr_or_##w(&t, d); \ - if (t != (uint##w##_t)(v | d)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w "]\n",\ - (uint##w##_t)v, d, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_OR_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_or_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = (uint##w##_t)common_rand(); \ - uint##w##_t b = (uint##w##_t)common_rand(); \ - CK_PR_OR_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_OR_W(m, w) \ - { \ - uint##m##_t t = 0; \ - ck_pr_or_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != BM(m, w)) { \ - printf(" FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, BM(m, w)); \ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_OR_64 - if (m == 64) { -#if defined(CK_F_PR_OR_32) - CK_PR_OR_W(64, 32); -#endif -#if defined(CK_PR_OR_16) - CK_PR_OR_W(64, 16); -#endif -#if defined(CK_PR_OR_8) - CK_PR_OR_W(64, 8); -#endif - } -#endif /* CK_PR_OR_64 */ - -#ifdef CK_F_PR_OR_32 - if (m == 32) { -#if defined(CK_F_PR_OR_16) - CK_PR_OR_W(32, 16); -#endif -#if defined(CK_PR_OR_8) - CK_PR_OR_W(32, 8); -#endif - } -#endif /* CK_PR_OR_32 */ - -#if defined(CK_F_PR_OR_16) && defined(CK_PR_OR_8) - if (m == 16) { - CK_PR_OR_W(16, 8); - } -#endif /* CK_PR_OR_16 && CK_PR_OR_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_OR_64 - CK_PR_OR_B(64); -#endif - -#ifdef CK_F_PR_OR_32 - CK_PR_OR_B(32); -#endif - -#ifdef CK_F_PR_OR_16 - CK_PR_OR_B(16); -#endif - -#ifdef CK_F_PR_OR_8 - CK_PR_OR_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_store.c b/regressions/ck_pr/validate/ck_pr_store.c deleted file mode 100644 index e4b852b4fcd8..000000000000 --- a/regressions/ck_pr/validate/ck_pr_store.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "../../common.h" -#include - -#include -#include -#include -#include -#include -#include - -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_STORE_B(w) \ - { \ - uint##w##_t t = (uint##w##_t)-1, a = 0, b; \ - ck_pr_store_##w(&b, 1ULL << (w - 1)); \ - unsigned int i; \ - printf("ck_pr_store_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - ck_pr_store_##w(&a, t); \ - if (a != t) { \ - printf("FAIL [%#" PRIx##w " != %#" PRIx##w "]\n", a, t); \ - exit(EXIT_FAILURE); \ - } \ - for (i = 0; i < R_REPEAT; i++) { \ - t = (uint##w##_t)common_rand(); \ - ck_pr_store_##w(&a, t); \ - if (a != t) { \ - printf("FAIL [%#" PRIx##w " != %#" PRIx##w "]\n", a, t);\ - exit(EXIT_FAILURE); \ - } \ - } \ - rg_width(w); \ - printf("SUCCESS\n"); \ - } - -#define CK_PR_STORE_W(m, w) \ - { \ - uint##m##_t f = 0; \ - uint##w##_t j = (uint##w##_t)-1; \ - ck_pr_store_##w((uint##w##_t *)(void *)&f, j); \ - if (f != j) { \ - printf("FAIL [%#" PRIx##m " != %#" PRIx##w "]\n", f, j);\ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_STORE_64 - if (m == 64) { -#if defined(CK_F_PR_STORE_32) - CK_PR_STORE_W(64, 32); -#endif -#if defined(CK_PR_STORE_16) - CK_PR_STORE_W(64, 16); -#endif -#if defined(CK_PR_STORE_8) - CK_PR_STORE_W(64, 8); -#endif - } -#endif /* CK_PR_STORE_64 */ - -#ifdef CK_F_PR_STORE_32 - if (m == 32) { -#if defined(CK_F_PR_STORE_16) - CK_PR_STORE_W(32, 16); -#endif -#if defined(CK_PR_STORE_8) - CK_PR_STORE_W(32, 8); -#endif - } -#endif /* CK_PR_STORE_32 */ - -#if defined(CK_F_PR_STORE_16) && defined(CK_PR_STORE_8) - if (m == 16) - CK_PR_STORE_W(16, 8); -#endif /* CK_PR_STORE_16 && CK_PR_STORE_8 */ - - return; -} - -int -main(void) -{ -#if defined(CK_F_PR_STORE_DOUBLE) && defined(CK_F_PR_LOAD_DOUBLE) - double d; - - ck_pr_store_double(&d, 0.0); - if (ck_pr_load_double(&d) != 0.0) { - ck_error("Stored 0 in double, did not find 0.\n"); - } -#endif - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_STORE_64 - CK_PR_STORE_B(64); -#endif - -#ifdef CK_F_PR_STORE_32 - CK_PR_STORE_B(32); -#endif - -#ifdef CK_F_PR_STORE_16 - CK_PR_STORE_B(16); -#endif - -#ifdef CK_F_PR_STORE_8 - CK_PR_STORE_B(8); -#endif - - return (0); -} diff --git a/regressions/ck_pr/validate/ck_pr_sub.c b/regressions/ck_pr/validate/ck_pr_sub.c deleted file mode 100644 index f51591464597..000000000000 --- a/regressions/ck_pr/validate/ck_pr_sub.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define CK_PR_SUB_T(w, v, d) \ - { \ - uint##w##_t t = v; \ - ck_pr_sub_##w(&t, d); \ - if (t != (uint##w##_t)(v - d)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w "]\n", \ - (uint##w##_t)v, d, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_SUB_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_sub_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = common_rand() % ((uint##w##_t)-1 / 2); \ - uint##w##_t b = common_rand() % ((uint##w##_t)-1 / 2); \ - CK_PR_SUB_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_SUB_W(m, w) \ - { \ - uint##m##_t t = 0, r = (uint##m##_t)(uint##w##_t)-1; \ - ck_pr_sub_##w((uint##w##_t *)(void *)&t, 1); \ - if (t != r) { \ - printf(" FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, r); \ - exit(EXIT_FAILURE); \ - } \ - t = 0; \ - ck_pr_sub_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != 1) { \ - printf(" FAIL [%#" PRIx##m " != 1]\n", t); \ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_SUB_64 - if (m == 64) { -#if defined(CK_F_PR_SUB_32) - CK_PR_SUB_W(64, 32); -#endif -#if defined(CK_PR_SUB_16) - CK_PR_SUB_W(64, 16); -#endif -#if defined(CK_PR_SUB_8) - CK_PR_SUB_W(64, 8); -#endif - } -#endif /* CK_PR_SUB_64 */ - -#ifdef CK_F_PR_SUB_32 - if (m == 32) { -#if defined(CK_F_PR_SUB_16) - CK_PR_SUB_W(32, 16); -#endif -#if defined(CK_PR_SUB_8) - CK_PR_SUB_W(32, 8); -#endif - } -#endif /* CK_PR_SUB_32 */ - -#if defined(CK_F_PR_SUB_16) && defined(CK_PR_SUB_8) - if (m == 16) { - CK_PR_SUB_W(16, 8); - } -#endif /* CK_PR_SUB_16 && CK_PR_SUB_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_SUB_64 - CK_PR_SUB_B(64); -#endif - -#ifdef CK_F_PR_SUB_32 - CK_PR_SUB_B(32); -#endif - -#ifdef CK_F_PR_SUB_16 - CK_PR_SUB_B(16); -#endif - -#ifdef CK_F_PR_SUB_8 - CK_PR_SUB_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_unary.c b/regressions/ck_pr/validate/ck_pr_unary.c deleted file mode 100644 index b2300cd955e8..000000000000 --- a/regressions/ck_pr/validate/ck_pr_unary.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#define REPEAT 2000000 - -#define TEST_UNARY(K, S, M, T, P, D, H) \ - static void \ - test_##K##_##S(M *target) \ - { \ - *target = *target P 1; \ - \ - return; \ - } \ - static void \ - test_##K##_##S##_zero(M *target, bool *zero) \ - { \ - *zero = *target == H; \ - *target = *target P 1; \ - \ - return; \ - } \ - static void \ - run_test_##K##_##S(bool use_zero) \ - { \ - int i; \ - T x = 1, y = 1; \ - bool zero_x = false, zero_y = false; \ - \ - use_zero ? puts("***TESTING ck_pr_"#K"_"#S"_zero***") \ - : puts("***TESTING ck_pr_"#K"_"#S"***"); \ - for (i = 0; i < REPEAT; ++i) { \ - if (use_zero) { \ - test_##K##_##S##_zero(&x, &zero_x); \ - ck_pr_##K##_##S##_zero(&y, &zero_y); \ - } \ - else { \ - test_##K##_##S(&x); \ - ck_pr_##K##_##S(&y); \ - } \ - \ - if (x != y || zero_x != zero_y) { \ - printf("Serial(%"#D") and ck_pr(%"#D")" \ - #K"_"#S" do not match.\n" \ - "FAILURE.\n", \ - x, y); \ - \ - return; \ - } \ - \ - if (zero_x) \ - printf("Variables are zero at iteration %d\n", i); \ - } \ - \ - \ - printf("\tserial_"#K"_"#S": %"#D"\n" \ - "\tck_pr_"#K"_"#S": %"#D"\n" \ - "SUCCESS.\n", \ - x, y); \ - \ - return; \ - } - -#define GENERATE_TEST(K, P, Y, Z) \ - TEST_UNARY(K, int, int, int, P, d, Y) \ - TEST_UNARY(K, uint, unsigned int, unsigned int, P, u, Z) \ - static void \ - run_test_##K(void) \ - { \ - run_test_##K##_int(false); \ - run_test_##K##_int(true); \ - run_test_##K##_uint(false); \ - run_test_##K##_uint(true); \ - } - -GENERATE_TEST(inc, +, -1, UINT_MAX) -GENERATE_TEST(dec, -, 1, 1) - -#undef GENERATE_TEST -#undef TEST_UNARY - -int -main(void) -{ - run_test_inc(); - run_test_dec(); - - return (0); -} - diff --git a/regressions/ck_pr/validate/ck_pr_xor.c b/regressions/ck_pr/validate/ck_pr_xor.c deleted file mode 100644 index 4515cc45236d..000000000000 --- a/regressions/ck_pr/validate/ck_pr_xor.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "../../common.h" -#ifndef R_REPEAT -#define R_REPEAT 200000 -#endif - -#define BM(m, w) ((uint##m##_t)-1 << (w)) - -#define CK_PR_XOR_T(w, v, d) \ - { \ - uint##w##_t t = v; \ - ck_pr_xor_##w(&t, d); \ - if (t != (uint##w##_t)(v ^ d)) { \ - printf("FAIL ["); \ - printf("%" PRIu##w " (%" PRIu##w ") -> %" PRIu##w "]\n",\ - (uint##w##_t)v, d, t); \ - exit(EXIT_FAILURE); \ - } \ - } - -#define CK_PR_XOR_B(w) \ - { \ - unsigned int __ck_i = 0; \ - printf("ck_pr_xor_" #w ": "); \ - if (w < 10) \ - printf(" "); \ - for (__ck_i = 0; __ck_i < R_REPEAT; __ck_i++) { \ - uint##w##_t a = (uint##w##_t)common_rand(); \ - uint##w##_t b = (uint##w##_t)common_rand(); \ - CK_PR_XOR_T(w, a, b); \ - } \ - rg_width(w); \ - printf(" SUCCESS\n"); \ - } - -#define CK_PR_XOR_W(m, w) \ - { \ - uint##m##_t t = -1; \ - ck_pr_xor_##w((uint##w##_t *)(void *)&t, -1); \ - if (t != BM(m, w)) { \ - printf(" FAIL [%#" PRIx##m " != %#" PRIx##m "]\n", t, BM(m, w)); \ - exit(EXIT_FAILURE); \ - } \ - } - -static void -rg_width(int m) -{ - - /* Other architectures are bi-endian. */ -#if !defined(__x86__) && !defined(__x86_64__) - return; -#endif - -#ifdef CK_F_PR_XOR_64 - if (m == 64) { -#if defined(CK_F_PR_XOR_32) - CK_PR_XOR_W(64, 32); -#endif -#if defined(CK_PR_XOR_16) - CK_PR_XOR_W(64, 16); -#endif -#if defined(CK_PR_XOR_8) - CK_PR_XOR_W(64, 8); -#endif - } -#endif /* CK_PR_XOR_64 */ - -#ifdef CK_F_PR_XOR_32 - if (m == 32) { -#if defined(CK_F_PR_XOR_16) - CK_PR_XOR_W(32, 16); -#endif -#if defined(CK_PR_XOR_8) - CK_PR_XOR_W(32, 8); -#endif - } -#endif /* CK_PR_XOR_32 */ - -#if defined(CK_F_PR_XOR_16) && defined(CK_PR_XOR_8) - if (m == 16) { - CK_PR_XOR_W(16, 8); - } -#endif /* CK_PR_XOR_16 && CK_PR_XOR_8 */ - - return; -} - -int -main(void) -{ - - common_srand((unsigned int)getpid()); - -#ifdef CK_F_PR_XOR_64 - CK_PR_XOR_B(64); -#endif - -#ifdef CK_F_PR_XOR_32 - CK_PR_XOR_B(32); -#endif - -#ifdef CK_F_PR_XOR_16 - CK_PR_XOR_B(16); -#endif - -#ifdef CK_F_PR_XOR_8 - CK_PR_XOR_B(8); -#endif - - return (0); -} - diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile deleted file mode 100644 index d6be3dc39d5f..000000000000 --- a/regressions/ck_queue/validate/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -.PHONY: check clean distribution - -HEADER=../../../include/ck_queue.h -OBJECTS=ck_list ck_slist ck_stailq - -all: $(OBJECTS) - -check: all - ./ck_list $(CORES) 5 - ./ck_slist $(CORES) 5 - ./ck_stailq $(CORES) 1000000 - -ck_list: $(HEADER) ck_list.c - $(CC) $(CFLAGS) -o ck_list ck_list.c - -ck_slist: $(HEADER) ck_slist.c - $(CC) $(CFLAGS) -o ck_slist ck_slist.c - -ck_stailq: $(HEADER) ck_stailq.c - $(CC) $(CFLAGS) -o ck_stailq ck_stailq.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_queue/validate/ck_list.c b/regressions/ck_queue/validate/ck_list.c deleted file mode 100644 index daa48b1b98ce..000000000000 --- a/regressions/ck_queue/validate/ck_list.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -struct test { - int value; - CK_LIST_ENTRY(test) list_entry; -}; -static CK_LIST_HEAD(test_list, test) head = CK_LIST_HEAD_INITIALIZER(head); - -static int goal; - -static void -test_foreach(void) -{ - struct test *n, *next, *safe; - int i, s = 0, j = 0, k = 0; - - for (i = goal; i != 0; i = goal) { - s = 0; - - CK_LIST_FOREACH(n, &head, list_entry) { - j++; - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_LIST_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0) - break; - - s = 0; - CK_LIST_FOREACH_SAFE(n, &head, list_entry, safe) { - k++; - - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_LIST_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0 || CK_LIST_EMPTY(&head) == true) - break; - } - - fprintf(stderr, "(%d, %d) ", j, k); - return; -} - -static void * -execute(void *c) -{ - - (void)c; - test_foreach(); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *thread; - struct test *n, a, b; - struct test_list target; - int n_threads, i; - - if (argc != 3) { - ck_error("Usage: %s \n", argv[0]); - } - - n_threads = atoi(argv[1]); - if (n_threads < 1) { - ck_error("ERROR: Number of threads must be >= 1.\n"); - } - - thread = malloc(sizeof(pthread_t) * n_threads); - assert(thread != NULL); - - goal = atoi(argv[2]); - if (goal < 4) { - ck_error("ERROR: Number of entries must be >= 4.\n"); - } - - fprintf(stderr, "Beginning serial test..."); - CK_LIST_INIT(&head); - - for (i = 1; i <= goal; i++) { - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_LIST_INSERT_HEAD(&head, n, list_entry); - } - - test_foreach(); - - for (i = 1; i <= goal; i++) { - n = CK_LIST_FIRST(&head); - CK_LIST_REMOVE(n, list_entry); - free(n); - } - - CK_LIST_INSERT_HEAD(&head, &a, list_entry); - CK_LIST_INSERT_HEAD(&head, &b, list_entry); - CK_LIST_REMOVE(&a, list_entry); - if (CK_LIST_FIRST(&head) != &b) - ck_error("List is in invalid state.\n"); - CK_LIST_REMOVE(&b, list_entry); - - if (CK_LIST_EMPTY(&head) == false) { - ck_error("List is not empty after bulk removal.\n"); - } - - CK_LIST_INSERT_HEAD(&head, &a, list_entry); - CK_LIST_INSERT_AFTER(&a, &b, list_entry); - - if (CK_LIST_NEXT(&b, list_entry) != NULL) - ck_error("Inserted item after last, it should not have no next.\n"); - - CK_LIST_INIT(&head); - - CK_LIST_INSERT_HEAD(&head, &a, list_entry); - CK_LIST_INSERT_BEFORE(&a, &b, list_entry); - - if (CK_LIST_NEXT(&b, list_entry) != &a) - ck_error("Inserted item before last, it should point to last.\n"); - - CK_LIST_INIT(&head); - fprintf(stderr, "done (success)\n"); - - fprintf(stderr, "Beginning parallel traversal..."); - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = 1; - CK_LIST_INSERT_HEAD(&head, n, list_entry); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - for (i = 2; i <= goal; i++) { - volatile int j; - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_LIST_INSERT_HEAD(&head, n, list_entry); - for (j = 0; j <= 1000; j++); - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - CK_LIST_MOVE(&target, &head, list_entry); - - for (i = 1; i <= goal; i++) { - volatile int j; - - if (CK_LIST_EMPTY(&target) == false) { - struct test *r = CK_LIST_FIRST(&target); - CK_LIST_REMOVE(r, list_entry); - } - - for (j = 0; j <= 1000; j++); - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, "done (success)\n"); - return (0); -} - diff --git a/regressions/ck_queue/validate/ck_slist.c b/regressions/ck_queue/validate/ck_slist.c deleted file mode 100644 index 7adf2ef15585..000000000000 --- a/regressions/ck_queue/validate/ck_slist.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -struct test { - int value; - CK_SLIST_ENTRY(test) list_entry; -}; -static CK_SLIST_HEAD(test_list, test) head = CK_SLIST_HEAD_INITIALIZER(head); - -static int goal; - -static void -test_foreach(void) -{ - struct test *n, *next, *safe; - int i, s = 0, j = 0, k = 0; - - for (i = goal; i != 0; i = goal) { - s = 0; - - CK_SLIST_FOREACH(n, &head, list_entry) { - j++; - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_SLIST_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0) - break; - - s = 0; - CK_SLIST_FOREACH_SAFE(n, &head, list_entry, safe) { - k++; - - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_SLIST_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0 || CK_SLIST_EMPTY(&head) == true) - break; - } - - fprintf(stderr, "(%d, %d) ", j, k); - return; -} - -static void * -execute(void *c) -{ - - (void)c; - test_foreach(); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *thread; - struct test *n; - struct test_list target; - int n_threads, i; - - if (argc != 3) { - ck_error("Usage: %s \n", argv[0]); - } - - n_threads = atoi(argv[1]); - if (n_threads < 1) { - ck_error("ERROR: Number of threads must be >= 1.\n"); - } - - thread = malloc(sizeof(pthread_t) * n_threads); - assert(thread != NULL); - - goal = atoi(argv[2]); - if (goal < 4) { - ck_error("ERROR: Number of entries must be >= 4.\n"); - } - - fprintf(stderr, "Beginning serial test..."); - CK_SLIST_INIT(&head); - - for (i = 1; i <= goal; i++) { - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_SLIST_INSERT_HEAD(&head, n, list_entry); - } - - test_foreach(); - - for (i = 1; i <= goal; i++) { - n = CK_SLIST_FIRST(&head); - CK_SLIST_REMOVE_HEAD(&head, list_entry); - free(n); - } - - if (CK_SLIST_EMPTY(&head) == false) { - ck_error("List is not empty after bulk removal.\n"); - } - - fprintf(stderr, "done (success)\n"); - - fprintf(stderr, "Beginning parallel traversal..."); - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = 1; - CK_SLIST_INSERT_HEAD(&head, n, list_entry); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - for (i = 2; i <= goal; i++) { - volatile int j; - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_SLIST_INSERT_HEAD(&head, n, list_entry); - for (j = 0; j <= 1000; j++); - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - CK_SLIST_MOVE(&target, &head, list_entry); - - for (i = 1; i <= goal; i++) { - volatile int j; - - if (CK_SLIST_EMPTY(&target) == false) - CK_SLIST_REMOVE_HEAD(&target, list_entry); - - for (j = 0; j <= 1000; j++); - - if (CK_SLIST_EMPTY(&target) == false) { - struct test *r = CK_SLIST_FIRST(&target); - CK_SLIST_REMOVE(&target, r, test, list_entry); - } - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, "done (success)\n"); - return (0); -} - diff --git a/regressions/ck_queue/validate/ck_stailq.c b/regressions/ck_queue/validate/ck_stailq.c deleted file mode 100644 index 219e93fb19f6..000000000000 --- a/regressions/ck_queue/validate/ck_stailq.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2012-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include "../../common.h" - -struct test { - int value; - CK_STAILQ_ENTRY(test) list_entry; -}; -static CK_STAILQ_HEAD(test_list, test) head = CK_STAILQ_HEAD_INITIALIZER(head); - -static int goal; - -static void -test_foreach(void) -{ - struct test *n, *next, *safe; - int i, s = 0, j = 0, k = 0; - - for (i = goal; i != 0; i = goal) { - s = 0; - - CK_STAILQ_FOREACH(n, &head, list_entry) { - j++; - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_STAILQ_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0) - break; - - s = 0; - CK_STAILQ_FOREACH_SAFE(n, &head, list_entry, safe) { - k++; - - if (s == 0) - s = n->value; - else - s = s - 1; - - if (n->value != s) { - ck_error("\nExpected %d, but got %d.\n", - s, n->value); - } - - next = CK_STAILQ_NEXT(n, list_entry); - if (next != NULL && next->value != s - 1) { - ck_error("\nExpected %d, but got %d.\n", - s, next->value); - } - - i--; - } - - if (i == 0 || CK_STAILQ_EMPTY(&head) == true) - break; - } - - fprintf(stderr, "(%d, %d) ", j, k); - return; -} - -static void * -execute(void *c) -{ - - (void)c; - test_foreach(); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *thread; - struct test *n, a, b; - struct test_list target; - int n_threads, i; - - if (argc != 3) { - ck_error("Usage: %s \n", argv[0]); - } - - n_threads = atoi(argv[1]); - if (n_threads < 1) { - ck_error("ERROR: Number of threads must be >= 1.\n"); - } - - thread = malloc(sizeof(pthread_t) * n_threads); - assert(thread != NULL); - - goal = atoi(argv[2]); - if (goal < 4) { - ck_error("ERROR: Number of entries must be >= 4.\n"); - } - - fprintf(stderr, "Beginning serial test..."); - CK_STAILQ_INIT(&head); - - for (i = 1; i <= goal; i++) { - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_STAILQ_INSERT_HEAD(&head, n, list_entry); - } - - test_foreach(); - - for (i = 1; i <= goal; i++) { - n = CK_STAILQ_FIRST(&head); - CK_STAILQ_REMOVE(&head, n, test, list_entry); - free(n); - } - - if (CK_STAILQ_EMPTY(&head) == false) { - ck_error("List is not empty after bulk removal.\n"); - } - - for (i = 1; i <= goal; i++) { - n = malloc(sizeof *n); - assert(n != NULL); - n->value = goal - i; - CK_STAILQ_INSERT_TAIL(&head, n, list_entry); - } - - test_foreach(); - - for (i = 1; i <= goal; i++) { - n = CK_STAILQ_FIRST(&head); - CK_STAILQ_REMOVE(&head, n, test, list_entry); - free(n); - } - - if (CK_STAILQ_EMPTY(&head) == false) { - ck_error("List is not empty after bulk removal.\n"); - } - - CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); - CK_STAILQ_INSERT_HEAD(&head, &b, list_entry); - CK_STAILQ_REMOVE(&head, &a, test, list_entry); - if (CK_STAILQ_FIRST(&head) != &b) - ck_error("List is in invalid state.\n"); - CK_STAILQ_REMOVE(&head, &b, test, list_entry); - - if (CK_STAILQ_EMPTY(&head) == false) { - ck_error("List is not empty after bulk removal.\n"); - } - - CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); - CK_STAILQ_INSERT_AFTER(&head, &a, &b, list_entry); - - if (CK_STAILQ_NEXT(&b, list_entry) != NULL) - ck_error("Inserted item after last, it should not have no next.\n"); - - CK_STAILQ_INIT(&head); - - CK_STAILQ_INSERT_HEAD(&head, &a, list_entry); - if (CK_STAILQ_NEXT(&a, list_entry) != NULL) - ck_error("Inserted item as last, but it contains next pointer.\n"); - - CK_STAILQ_INIT(&head); - fprintf(stderr, "done (success)\n"); - - fprintf(stderr, "Beginning parallel traversal..."); - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = 1; - CK_STAILQ_INSERT_HEAD(&head, n, list_entry); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - for (i = 2; i <= goal; i++) { - volatile int j; - - n = malloc(sizeof *n); - assert(n != NULL); - n->value = i; - CK_STAILQ_INSERT_HEAD(&head, n, list_entry); - for (j = 0; j <= 1000; j++); - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - for (i = 0; i < n_threads; i++) { - int r = pthread_create(&thread[i], NULL, execute, NULL); - assert(r == 0); - } - - CK_STAILQ_MOVE(&target, &head, list_entry); - - for (i = 1; i <= goal; i++) { - volatile int j; - - if (CK_STAILQ_EMPTY(&target) == false) { - struct test *r = CK_STAILQ_FIRST(&target); - CK_STAILQ_REMOVE(&target, r, test, list_entry); - } - - for (j = 0; j <= 1000; j++); - } - - for (i = 0; i < n_threads; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, "done (success)\n"); - return (0); -} - diff --git a/regressions/ck_rhs/benchmark/Makefile b/regressions/ck_rhs/benchmark/Makefile deleted file mode 100644 index e9979935f1d3..000000000000 --- a/regressions/ck_rhs/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=serial parallel_bytestring - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_rhs.c - -parallel_bytestring: parallel_bytestring.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c ../../../src/ck_epoch.c - $(CC) $(PTHREAD_CFLAGS) $(CFLAGS) -o parallel_bytestring parallel_bytestring.c ../../../src/ck_rhs.c ../../../src/ck_epoch.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_rhs/benchmark/parallel_bytestring.c b/regressions/ck_rhs/benchmark/parallel_bytestring.c deleted file mode 100644 index a95d940ca013..000000000000 --- a/regressions/ck_rhs/benchmark/parallel_bytestring.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#include "../../common.h" -#include -#include "../../../src/ck_ht_hash.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static ck_rhs_t hs CK_CC_CACHELINE; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static ck_epoch_t epoch_hs; -static ck_epoch_record_t epoch_wr; -static int n_threads; -static bool next_stage; - -enum state { - HS_STATE_STOP = 0, - HS_STATE_GET, - HS_STATE_STRICT_REPLACEMENT, - HS_STATE_DELETION, - HS_STATE_REPLACEMENT, - HS_STATE_COUNT -}; - -static ck_spinlock_t mtx = CK_SPINLOCK_INITIALIZER; -static struct affinity affinerator = AFFINITY_INITIALIZER; -static uint64_t accumulator[HS_STATE_COUNT]; -static int barrier[HS_STATE_COUNT]; -static int state; - -struct hs_epoch { - ck_epoch_entry_t epoch_entry; -}; - -COMMON_ALARM_DECLARE_GLOBAL(hs_alarm, alarm_event, next_stage) - -static void -alarm_handler(int s) -{ - - (void)s; - next_stage = true; - return; -} - -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - h = (unsigned long)MurmurHash64A(c, strlen(c), seed); - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void -hs_destroy(ck_epoch_entry_t *e) -{ - - free(e); - return; -} - -static void * -hs_malloc(size_t r) -{ - ck_epoch_entry_t *b; - - b = malloc(sizeof(*b) + r); - return b + 1; -} - -static void -hs_free(void *p, size_t b, bool r) -{ - struct hs_epoch *e = p; - - (void)b; - - if (r == true) { - /* Destruction requires safe memory reclamation. */ - ck_epoch_call(&epoch_wr, &(--e)->epoch_entry, hs_destroy); - } else { - free(--e); - } - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -static void -set_init(void) -{ - unsigned int mode = CK_RHS_MODE_OBJECT | CK_RHS_MODE_SPMC; - - - ck_epoch_init(&epoch_hs); - ck_epoch_register(&epoch_hs, &epoch_wr); - common_srand48((long int)time(NULL)); - if (ck_rhs_init(&hs, mode, hs_hash, hs_compare, &my_allocator, 65536, common_lrand48()) == false) { - perror("ck_rhs_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -set_remove(const char *value) -{ - unsigned long h; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return (bool)ck_rhs_remove(&hs, h, value); -} - -static bool -set_replace(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_set(&hs, h, value, &previous); -} - -static bool -set_swap(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_fas(&hs, h, value, &previous); -} - -static void * -set_get(const char *value) -{ - unsigned long h; - void *v; - - h = CK_RHS_HASH(&hs, hs_hash, value); - v = ck_rhs_get(&hs, h, value); - return v; -} - -static bool -set_insert(const char *value) -{ - unsigned long h; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_put(&hs, h, value); -} - -static size_t -set_count(void) -{ - - return ck_rhs_count(&hs); -} - -static bool -set_reset(void) -{ - - return ck_rhs_reset(&hs); -} - -static void * -reader(void *unused) -{ - size_t i; - ck_epoch_record_t epoch_record; - int state_previous = HS_STATE_STOP; - int n_state = 0; - uint64_t s, j, a; - - (void)unused; - if (aff_iterate(&affinerator) != 0) - perror("WARNING: Failed to affine thread"); - - s = j = a = 0; - ck_epoch_register(&epoch_hs, &epoch_record); - for (;;) { - j++; - ck_epoch_begin(&epoch_record, NULL); - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - char *r; - - r = set_get(keys[i]); - if (r == NULL) { - if (n_state == HS_STATE_STRICT_REPLACEMENT) { - ck_error("ERROR: Did not find during replacement: %s\n", keys[i]); - } - - continue; - } - - if (strcmp(r, keys[i]) == 0) - continue; - - ck_error("ERROR: Found invalid value: [%s] but expected [%s]\n", (char *)r, keys[i]); - } - a += rdtsc() - s; - ck_epoch_end(&epoch_record, NULL); - - n_state = ck_pr_load_int(&state); - if (n_state != state_previous) { - ck_spinlock_lock(&mtx); - accumulator[state_previous] += a / (j * keys_length); - ck_spinlock_unlock(&mtx); - - ck_pr_inc_int(&barrier[state_previous]); - while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) - ck_pr_stall(); - - state_previous = n_state; - s = j = a = 0; - } - } - - return NULL; -} - -static uint64_t -acc(size_t i) -{ - uint64_t r; - - ck_spinlock_lock(&mtx); - r = accumulator[i]; - ck_spinlock_unlock(&mtx); - - return r; -} - -int -main(int argc, char *argv[]) -{ - FILE *fp; - char buffer[512]; - size_t i, j, r; - unsigned int d = 0; - uint64_t s, e, a, repeated; - char **t; - pthread_t *readers; - double p_r, p_d; - - COMMON_ALARM_DECLARE_LOCAL(hs_alarm, alarm_event) - - r = 20; - s = 8; - p_d = 0.5; - p_r = 0.5; - n_threads = CORES - 1; - - if (argc < 2) { - ck_error("Usage: parallel [ \n" - " ]\n"); - } - - if (argc >= 3) - r = atoi(argv[2]); - - if (argc >= 4) - s = (uint64_t)atoi(argv[3]); - - if (argc >= 5) { - n_threads = atoi(argv[4]); - if (n_threads < 1) { - ck_error("ERROR: Number of readers must be >= 1.\n"); - } - } - - if (argc >= 6) { - p_r = atof(argv[5]) / 100.00; - if (p_r < 0) { - ck_error("ERROR: Probability of replacement must be >= 0 and <= 100.\n"); - } - } - - if (argc >= 7) { - p_d = atof(argv[6]) / 100.00; - if (p_d < 0) { - ck_error("ERROR: Probability of deletion must be >= 0 and <= 100.\n"); - } - } - - COMMON_ALARM_INIT(hs_alarm, alarm_event, r) - - affinerator.delta = 1; - readers = malloc(sizeof(pthread_t) * n_threads); - assert(readers != NULL); - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(argv[1], "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - set_init(); - - for (i = 0; i < (size_t)n_threads; i++) { - if (pthread_create(&readers[i], NULL, reader, NULL) != 0) { - ck_error("ERROR: Failed to create thread %zu.\n", i); - } - } - - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - - fprintf(stderr, " [S] %d readers, 1 writer.\n", n_threads); - fprintf(stderr, " [S] %zu entries stored and %u duplicates.\n\n", - set_count(), d); - - fprintf(stderr, " ,- BASIC TEST\n"); - fprintf(stderr, " | Executing SMR test..."); - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing replacement test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing get test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - a = 0; - fprintf(stderr, " | Executing removal test..."); - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - fprintf(stderr, " | Executing negative look-up test..."); - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - fprintf(stderr, "done (%" PRIu64 " ticks)\n", a / (r * keys_length)); - - ck_epoch_record_t epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - - fprintf(stderr, " ,- READER CONCURRENCY\n"); - fprintf(stderr, " | Executing reader test..."); - - ck_pr_store_int(&state, HS_STATE_GET); - while (ck_pr_load_int(&barrier[HS_STATE_STOP]) != n_threads) - ck_pr_stall(); - ck_pr_inc_int(&barrier[HS_STATE_STOP]); - common_sleep(r); - ck_pr_store_int(&state, HS_STATE_STRICT_REPLACEMENT); - while (ck_pr_load_int(&barrier[HS_STATE_GET]) != n_threads) - ck_pr_stall(); - - fprintf(stderr, "done (reader = %" PRIu64 " ticks)\n", - acc(HS_STATE_GET) / n_threads); - - fprintf(stderr, " | Executing strict replacement test..."); - - a = repeated = 0; - common_alarm(alarm_handler, &alarm_event, r); - - ck_pr_inc_int(&barrier[HS_STATE_GET]); - for (;;) { - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (i & 1) { - set_replace(keys[i]); - } else { - set_swap(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - - ck_pr_store_int(&state, HS_STATE_DELETION); - while (ck_pr_load_int(&barrier[HS_STATE_STRICT_REPLACEMENT]) != n_threads) - ck_pr_stall(); - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_STRICT_REPLACEMENT) / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing deletion test (%.2f)...", p_d * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HS_STATE_STRICT_REPLACEMENT]); - for (;;) { - double delete; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - set_remove(keys[i]); - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HS_STATE_REPLACEMENT); - while (ck_pr_load_int(&barrier[HS_STATE_DELETION]) != n_threads) - ck_pr_stall(); - - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_DELETION) / n_threads); - - common_alarm(alarm_handler, &alarm_event, r); - - fprintf(stderr, " | Executing replacement test (%.2f)...", p_r * 100); - a = repeated = 0; - ck_pr_inc_int(&barrier[HS_STATE_DELETION]); - for (;;) { - double delete, replace; - - repeated++; - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_insert(keys[i]); - if (p_d != 0.0) { - delete = common_drand48(); - if (delete <= p_d) - set_remove(keys[i]); - } else { - delete = 0.0; - } - - if (p_r != 0.0) { - replace = common_drand48(); - if (replace <= p_r) { - if ((i & 1) || (delete <= p_d)) { - set_replace(keys[i]); - } else { - set_swap(keys[i]); - } - } - } - } - e = rdtsc(); - a += e - s; - - if (next_stage == true) { - next_stage = false; - break; - } - } - ck_pr_store_int(&state, HS_STATE_STOP); - while (ck_pr_load_int(&barrier[HS_STATE_REPLACEMENT]) != n_threads) - ck_pr_stall(); - set_reset(); - ck_epoch_synchronize(&epoch_wr); - fprintf(stderr, "done (writer = %" PRIu64 " ticks, reader = %" PRIu64 " ticks)\n", - a / (repeated * keys_length), acc(HS_STATE_REPLACEMENT) / n_threads); - - ck_pr_inc_int(&barrier[HS_STATE_REPLACEMENT]); - epoch_temporary = epoch_wr; - ck_epoch_synchronize(&epoch_wr); - - fprintf(stderr, " '- Summary: %u pending, %u peak, %lu reclamations -> " - "%u pending, %u peak, %lu reclamations\n\n", - epoch_temporary.n_pending, epoch_temporary.n_peak, epoch_temporary.n_dispatch, - epoch_wr.n_pending, epoch_wr.n_peak, epoch_wr.n_dispatch); - return 0; -} - diff --git a/regressions/ck_rhs/benchmark/serial.c b/regressions/ck_rhs/benchmark/serial.c deleted file mode 100644 index 18fa8927c3d5..000000000000 --- a/regressions/ck_rhs/benchmark/serial.c +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" -#include "../../../src/ck_ht_hash.h" - -static ck_rhs_t hs; -static char **keys; -static size_t keys_length = 0; -static size_t keys_capacity = 128; -static unsigned long global_seed; - -static void * -hs_malloc(size_t r) -{ - - return malloc(r); -} - -static void -hs_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - - free(p); - - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - h = (unsigned long)MurmurHash64A(c, strlen(c), seed); - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void -set_destroy(void) -{ - - ck_rhs_destroy(&hs); - return; -} - -static void -set_init(unsigned int size, unsigned int mode) -{ - - if (ck_rhs_init(&hs, CK_RHS_MODE_OBJECT | CK_RHS_MODE_SPMC | mode, hs_hash, hs_compare, - &my_allocator, size, global_seed) == false) { - perror("ck_rhs_init"); - exit(EXIT_FAILURE); - } - - return; -} - -static bool -set_remove(const char *value) -{ - unsigned long h; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_remove(&hs, h, value) != NULL; -} - -static bool -set_swap(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_fas(&hs, h, value, &previous); -} - -static bool -set_replace(const char *value) -{ - unsigned long h; - void *previous; - - h = CK_RHS_HASH(&hs, hs_hash, value); - ck_rhs_set(&hs, h, value, &previous); - return previous != NULL; -} - -static void * -set_get(const char *value) -{ - unsigned long h; - void *v; - - h = CK_RHS_HASH(&hs, hs_hash, value); - v = ck_rhs_get(&hs, h, value); - return v; -} - -static bool -set_insert(const char *value) -{ - unsigned long h; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_put(&hs, h, value); -} - -static bool -set_insert_unique(const char *value) -{ - unsigned long h; - - h = CK_RHS_HASH(&hs, hs_hash, value); - return ck_rhs_put_unique(&hs, h, value); -} - -static size_t -set_count(void) -{ - - return ck_rhs_count(&hs); -} - -static bool -set_reset(void) -{ - - return ck_rhs_reset(&hs); -} - -static void -set_gc(void) -{ - - ck_rhs_gc(&hs); - return; -} - -static void -set_rebuild(void) -{ - - ck_rhs_rebuild(&hs); - return; -} - -static void -keys_shuffle(char **k) -{ - size_t i, j; - char *t; - - for (i = keys_length; i > 1; i--) { - j = rand() % (i - 1); - - if (j != i - 1) { - t = k[i - 1]; - k[i - 1] = k[j]; - k[j] = t; - } - } - - return; -} - -static void -run_test(const char *file, size_t r, unsigned int size, unsigned int mode) -{ - FILE *fp; - char buffer[512]; - size_t i, j; - unsigned int d = 0; - uint64_t s, e, a, ri, si, ai, sr, rg, sg, ag, sd, ng, ss, sts, su, sgc, sb; - struct ck_rhs_stat st; - char **t; - - keys = malloc(sizeof(char *) * keys_capacity); - assert(keys != NULL); - - fp = fopen(file, "r"); - assert(fp != NULL); - - while (fgets(buffer, sizeof(buffer), fp) != NULL) { - buffer[strlen(buffer) - 1] = '\0'; - keys[keys_length++] = strdup(buffer); - assert(keys[keys_length - 1] != NULL); - - if (keys_length == keys_capacity) { - t = realloc(keys, sizeof(char *) * (keys_capacity *= 2)); - assert(t != NULL); - keys = t; - } - } - - t = realloc(keys, sizeof(char *) * keys_length); - assert(t != NULL); - keys = t; - - set_init(size, mode); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - ck_rhs_stat(&hs, &st); - - fprintf(stderr, "# %zu entries stored, %u duplicates, %u probe.\n", - set_count(), d, st.probe_maximum); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = keys_length; i > 0; i--) - d += set_insert(keys[i - 1]) == false; - e = rdtsc(); - a += e - s; - } - ri = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - si = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - if (set_reset() == false) { - ck_error("ERROR: Failed to reset hash table.\n"); - } - - s = rdtsc(); - for (i = 0; i < keys_length; i++) - d += set_insert(keys[i]) == false; - e = rdtsc(); - a += e - s; - } - ai = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_swap(keys[i]); - e = rdtsc(); - a += e - s; - } - ss = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_replace(keys[i]); - e = rdtsc(); - a += e - s; - } - sr = a / (r * keys_length); - - set_reset(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = keys_length; i > 0; i--) { - if (set_get(keys[i - 1]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - rg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - sg = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - keys_shuffle(keys); - - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - if (set_get(keys[i]) == NULL) { - ck_error("ERROR: Unexpected NULL value.\n"); - } - } - e = rdtsc(); - a += e - s; - } - ag = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - } - sd = a / (r * keys_length); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) { - set_get("\x50\x03\x04\x05\x06\x10"); - } - e = rdtsc(); - a += e - s; - } - ng = a / (r * keys_length); - - set_reset(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_insert(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - } - sts = a / (r * keys_length); - - set_reset(); - - /* Prune duplicates. */ - for (i = 0; i < keys_length; i++) { - if (set_insert(keys[i]) == true) - continue; - - free(keys[i]); - keys[i] = keys[--keys_length]; - } - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - for (i = 0; i < keys_length; i++) - set_insert_unique(keys[i]); - e = rdtsc(); - a += e - s; - - for (i = 0; i < keys_length; i++) - set_remove(keys[i]); - } - su = a / (r * keys_length); - - for (i = 0; i < keys_length; i++) - set_insert_unique(keys[i]); - - for (i = 0; i < keys_length / 2; i++) - set_remove(keys[i]); - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - set_gc(); - e = rdtsc(); - a += e - s; - } - sgc = a / r; - - a = 0; - for (j = 0; j < r; j++) { - s = rdtsc(); - set_rebuild(); - e = rdtsc(); - a += e - s; - } - sb = a / r; - - printf("%zu " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 " " - "%" PRIu64 "\n", - keys_length, ri, si, ai, ss, sr, rg, sg, ag, sd, ng, sts, su, sgc, sb); - - fclose(fp); - - for (i = 0; i < keys_length; i++) { - free(keys[i]); - } - - free(keys); - keys_length = 0; - set_destroy(); - return; -} - -int -main(int argc, char *argv[]) -{ - unsigned int r, size; - - common_srand48((long int)time(NULL)); - if (argc < 2) { - ck_error("Usage: ck_rhs [ ]\n"); - } - - r = 16; - if (argc >= 3) - r = atoi(argv[2]); - - size = 8; - if (argc >= 4) - size = atoi(argv[3]); - - global_seed = common_lrand48(); - run_test(argv[1], r, size, 0); - run_test(argv[1], r, size, CK_RHS_MODE_READ_MOSTLY); - fprintf(stderr, "# reverse_insertion serial_insertion random_insertion serial_swap " - "serial_replace reverse_get serial_get random_get serial_remove negative_get tombstone " - "set_unique gc rebuild\n\n"); - - return 0; -} - diff --git a/regressions/ck_rhs/validate/Makefile b/regressions/ck_rhs/validate/Makefile deleted file mode 100644 index 5987395f54a3..000000000000 --- a/regressions/ck_rhs/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=serial - -all: $(OBJECTS) - -serial: serial.c ../../../include/ck_rhs.h ../../../src/ck_rhs.c - $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_rhs.c - -check: all - ./serial - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_rhs/validate/serial.c b/regressions/ck_rhs/validate/serial.c deleted file mode 100644 index ef9365fedea4..000000000000 --- a/regressions/ck_rhs/validate/serial.c +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright 2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyrighs - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyrighs - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -static void * -hs_malloc(size_t r) -{ - - return malloc(r); -} - -static void -hs_free(void *p, size_t b, bool r) -{ - - (void)b; - (void)r; - free(p); - return; -} - -static struct ck_malloc my_allocator = { - .malloc = hs_malloc, - .free = hs_free -}; - -const char *test[] = { "Samy", "Al", "Bahra", "dances", "in", "the", "wind.", "Once", - "upon", "a", "time", "his", "gypsy", "ate", "one", "itsy", - "bitsy", "spider.", "What", "goes", "up", "must", - "come", "down.", "What", "is", "down", "stays", - "down.", "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O", "P", "Q" }; - -const char *negative = "negative"; - -/* Purposefully crappy hash function. */ -static unsigned long -hs_hash(const void *object, unsigned long seed) -{ - const char *c = object; - unsigned long h; - - (void)seed; - h = c[0]; - return h; -} - -static bool -hs_compare(const void *previous, const void *compare) -{ - - return strcmp(previous, compare) == 0; -} - -static void * -test_ip(void *key, void *closure) -{ - const char *a = key; - const char *b = closure; - - if (strcmp(a, b) != 0) - ck_error("Mismatch: %s != %s\n", a, b); - - return closure; -} - -static void * -test_negative(void *key, void *closure) -{ - - (void)closure; - if (key != NULL) - ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); - - return NULL; -} - -static void * -test_unique(void *key, void *closure) -{ - - if (key != NULL) - ck_error("ERROR: Apply callback expects NULL argument instead of [%s]\n", key); - - return closure; -} - -static void * -test_remove(void *key, void *closure) -{ - - (void)key; - (void)closure; - - return NULL; -} - -static void -run_test(unsigned int is, unsigned int ad) -{ - ck_rhs_t hs[16]; - const size_t size = sizeof(hs) / sizeof(*hs); - size_t i, j; - const char *blob = "#blobs"; - unsigned long h; - - if (ck_rhs_init(&hs[0], CK_RHS_MODE_SPMC | CK_RHS_MODE_OBJECT | ad, hs_hash, hs_compare, &my_allocator, is, 6602834) == false) - ck_error("ck_rhs_init\n"); - - for (j = 0; j < size; j++) { - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_rhs_get(&hs[j], h, test[i]) != NULL) { - continue; - } - - if (i & 1) { - if (ck_rhs_put_unique(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to insert unique (%s)\n", j, test[i]); - } else if (ck_rhs_apply(&hs[j], h, test[i], test_unique, - (void *)(uintptr_t)test[i]) == false) { - ck_error("ERROR: Failed to apply for insertion.\n"); - } - - if (i & 1) { - if (ck_rhs_remove(&hs[j], h, test[i]) == false) - ck_error("ERROR [%zu]: Failed to remove unique (%s)\n", j, test[i]); - } else if (ck_rhs_apply(&hs[j], h, test[i], test_remove, NULL) == false) { - ck_error("ERROR: Failed to remove apply.\n"); - } - - if (ck_rhs_apply(&hs[j], h, test[i], test_negative, - (void *)(uintptr_t)test[i]) == false) - ck_error("ERROR: Failed to apply.\n"); - - break; - } - - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - ck_rhs_put(&hs[j], h, test[i]); - if (ck_rhs_put(&hs[j], h, test[i]) == true) { - ck_error("ERROR [%u] [1]: put must fail on collision (%s).\n", is, test[i]); - } - if (ck_rhs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail after put\n", is); - } - } - - /* Test grow semantics. */ - ck_rhs_grow(&hs[j], 128); - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_rhs_put(&hs[j], h, test[i]) == true) { - ck_error("ERROR [%u] [2]: put must fail on collision.\n", is); - } - - if (ck_rhs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail\n", is); - } - } - - h = blob[0]; - if (ck_rhs_get(&hs[j], h, blob) == NULL) { - if (j > 0) - ck_error("ERROR [%u]: Blob must always exist after first.\n", is); - - if (ck_rhs_put(&hs[j], h, blob) == false) { - ck_error("ERROR [%u]: A unique blob put failed.\n", is); - } - } else { - if (ck_rhs_put(&hs[j], h, blob) == true) { - ck_error("ERROR [%u]: Duplicate blob put succeeded.\n", is); - } - } - - /* Grow set and check get semantics. */ - ck_rhs_grow(&hs[j], 512); - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - h = test[i][0]; - if (ck_rhs_get(&hs[j], h, test[i]) == NULL) { - ck_error("ERROR [%u]: get must not fail\n", is); - } - } - - /* Delete and check negative membership. */ - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - void *r; - - h = test[i][0]; - if (ck_rhs_get(&hs[j], h, test[i]) == NULL) - continue; - - if (r = ck_rhs_remove(&hs[j], h, test[i]), r == NULL) { - ck_error("ERROR [%u]: remove must not fail\n", is); - } - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Removed incorrect node (%s != %s)\n", (char *)r, test[i], is); - } - } - - /* Test replacement semantics. */ - for (i = 0; i < sizeof(test) / sizeof(*test); i++) { - void *r; - bool d; - - h = test[i][0]; - d = ck_rhs_get(&hs[j], h, test[i]) != NULL; - if (ck_rhs_set(&hs[j], h, test[i], &r) == false) { - ck_error("ERROR [%u]: Failed to set\n", is); - } - - /* Expected replacement. */ - if (d == true && (r == NULL || strcmp(r, test[i]) != 0)) { - ck_error("ERROR [%u]: Incorrect previous value: %s != %s\n", - is, test[i], (char *)r); - } - - /* Replacement should succeed. */ - if (ck_rhs_fas(&hs[j], h, test[i], &r) == false) - ck_error("ERROR [%u]: ck_rhs_fas must succeed.\n", is); - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Incorrect replaced value: %s != %s\n", - is, test[i], (char *)r); - } - - if (ck_rhs_fas(&hs[j], h, negative, &r) == true) - ck_error("ERROR [%u]: Replacement of negative should fail.\n", is); - - if (ck_rhs_set(&hs[j], h, test[i], &r) == false) { - ck_error("ERROR [%u]: Failed to set [1]\n", is); - } - - if (strcmp(r, test[i]) != 0) { - ck_error("ERROR [%u]: Invalid &hs[j]: %s != %s\n", (char *)r, test[i], is); - } - /* Attempt in-place mutation. */ - if (ck_rhs_apply(&hs[j], h, test[i], test_ip, - (void *)(uintptr_t)test[i]) == false) { - ck_error("ERROR [%u]: Failed to apply: %s != %s\n", is, (char *)r, test[i]); - } - - d = ck_rhs_get(&hs[j], h, test[i]) != NULL; - if (d == false) - ck_error("ERROR [%u]: Expected [%s] to exist.\n", is, test[i]); - } - - if (j == size - 1) - break; - - if (ck_rhs_move(&hs[j + 1], &hs[j], hs_hash, hs_compare, &my_allocator) == false) - ck_error("Failed to move hash table"); - - ck_rhs_gc(&hs[j + 1]); - - if (ck_rhs_rebuild(&hs[j + 1]) == false) - ck_error("Failed to rebuild"); - } - - return; -} - -int -main(void) -{ - unsigned int k; - - for (k = 16; k <= 64; k <<= 1) { - run_test(k, 0); - break; - } - - return 0; -} - diff --git a/regressions/ck_ring/benchmark/Makefile b/regressions/ck_ring/benchmark/Makefile deleted file mode 100644 index 4087ed18fb04..000000000000 --- a/regressions/ck_ring/benchmark/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o latency latency.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_ring/benchmark/latency.c b/regressions/ck_ring/benchmark/latency.c deleted file mode 100644 index 657be4dbc0e6..000000000000 --- a/regressions/ck_ring/benchmark/latency.c +++ /dev/null @@ -1,142 +0,0 @@ -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS (128000) -#endif - -struct entry { - int tid; - int value; -}; - -int -main(int argc, char *argv[]) -{ - int i, r, size; - uint64_t s, e, e_a, d_a; - struct entry entry = {0, 0}; - ck_ring_buffer_t *buf; - ck_ring_t ring; - - if (argc != 2) { - ck_error("Usage: latency \n"); - } - - size = atoi(argv[1]); - if (size <= 4 || (size & (size - 1))) { - ck_error("ERROR: Size must be a power of 2 greater than 4.\n"); - } - - buf = malloc(sizeof(ck_ring_buffer_t) * size); - if (buf == NULL) { - ck_error("ERROR: Failed to allocate buffer\n"); - } - - ck_ring_init(&ring, size); - - e_a = d_a = s = e = 0; - for (r = 0; r < ITERATIONS; r++) { - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_enqueue_spsc(&ring, buf, &entry); - ck_ring_enqueue_spsc(&ring, buf, &entry); - ck_ring_enqueue_spsc(&ring, buf, &entry); - ck_ring_enqueue_spsc(&ring, buf, &entry); - e = rdtsc(); - } - e_a += (e - s) / 4; - - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_dequeue_spsc(&ring, buf, &entry); - ck_ring_dequeue_spsc(&ring, buf, &entry); - ck_ring_dequeue_spsc(&ring, buf, &entry); - ck_ring_dequeue_spsc(&ring, buf, &entry); - e = rdtsc(); - } - d_a += (e - s) / 4; - } - - printf("spsc %10d %16" PRIu64 " %16" PRIu64 "\n", size, e_a / ITERATIONS, d_a / ITERATIONS); - - e_a = d_a = s = e = 0; - for (r = 0; r < ITERATIONS; r++) { - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_enqueue_spmc(&ring, buf, &entry); - ck_ring_enqueue_spmc(&ring, buf, &entry); - ck_ring_enqueue_spmc(&ring, buf, &entry); - ck_ring_enqueue_spmc(&ring, buf, &entry); - e = rdtsc(); - } - e_a += (e - s) / 4; - - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_dequeue_spmc(&ring, buf, &entry); - ck_ring_dequeue_spmc(&ring, buf, &entry); - ck_ring_dequeue_spmc(&ring, buf, &entry); - ck_ring_dequeue_spmc(&ring, buf, &entry); - e = rdtsc(); - } - d_a += (e - s) / 4; - } - - printf("spmc %10d %16" PRIu64 " %16" PRIu64 "\n", size, e_a / ITERATIONS, d_a / ITERATIONS); - - ck_ring_init(&ring, size); - e_a = d_a = s = e = 0; - for (r = 0; r < ITERATIONS; r++) { - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_enqueue_mpsc(&ring, buf, &entry); - ck_ring_enqueue_mpsc(&ring, buf, &entry); - ck_ring_enqueue_mpsc(&ring, buf, &entry); - ck_ring_enqueue_mpsc(&ring, buf, &entry); - e = rdtsc(); - } - e_a += (e - s) / 4; - - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_dequeue_mpsc(&ring, buf, &entry); - ck_ring_dequeue_mpsc(&ring, buf, &entry); - ck_ring_dequeue_mpsc(&ring, buf, &entry); - ck_ring_dequeue_mpsc(&ring, buf, &entry); - e = rdtsc(); - } - d_a += (e - s) / 4; - } - printf("mpsc %10d %16" PRIu64 " %16" PRIu64 "\n", size, e_a / ITERATIONS, d_a / ITERATIONS); - ck_ring_init(&ring, size); - e_a = d_a = s = e = 0; - for (r = 0; r < ITERATIONS; r++) { - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_enqueue_mpmc(&ring, buf, &entry); - ck_ring_enqueue_mpmc(&ring, buf, &entry); - ck_ring_enqueue_mpmc(&ring, buf, &entry); - ck_ring_enqueue_mpmc(&ring, buf, &entry); - e = rdtsc(); - } - e_a += (e - s) / 4; - - for (i = 0; i < size / 4; i += 4) { - s = rdtsc(); - ck_ring_dequeue_mpmc(&ring, buf, &entry); - ck_ring_dequeue_mpmc(&ring, buf, &entry); - ck_ring_dequeue_mpmc(&ring, buf, &entry); - ck_ring_dequeue_mpmc(&ring, buf, &entry); - e = rdtsc(); - } - d_a += (e - s) / 4; - } - printf("mpmc %10d %16" PRIu64 " %16" PRIu64 "\n", size, e_a / ITERATIONS, d_a / ITERATIONS); - return (0); -} diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile deleted file mode 100644 index 0b68fad56a09..000000000000 --- a/regressions/ck_ring/validate/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_ring_spsc ck_ring_spmc ck_ring_spmc_template ck_ring_mpmc \ - ck_ring_mpmc_template -SIZE=16384 - -all: $(OBJECTS) - -check: all - ./ck_ring_spsc $(CORES) 1 $(SIZE) - ./ck_ring_spmc $(CORES) 1 $(SIZE) - ./ck_ring_spmc_template $(CORES) 1 $(SIZE) - ./ck_ring_mpmc $(CORES) 1 $(SIZE) - ./ck_ring_mpmc_template $(CORES) 1 $(SIZE) - -ck_ring_spsc: ck_ring_spsc.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o ck_ring_spsc ck_ring_spsc.c \ - ../../../src/ck_barrier_centralized.c - -ck_ring_spmc: ck_ring_spmc.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o ck_ring_spmc ck_ring_spmc.c \ - ../../../src/ck_barrier_centralized.c - -ck_ring_mpmc: ck_ring_mpmc.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o ck_ring_mpmc ck_ring_mpmc.c \ - ../../../src/ck_barrier_centralized.c - -ck_ring_mpmc_template: ck_ring_mpmc_template.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o ck_ring_mpmc_template ck_ring_mpmc_template.c \ - ../../../src/ck_barrier_centralized.c - -ck_ring_spmc_template: ck_ring_spmc_template.c ../../../include/ck_ring.h - $(CC) $(CFLAGS) -o ck_ring_spmc_template ck_ring_spmc_template.c \ - ../../../src/ck_barrier_centralized.c - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_ring/validate/ck_ring_mpmc.c b/regressions/ck_ring/validate/ck_ring_mpmc.c deleted file mode 100644 index 66d7f39a310b..000000000000 --- a/regressions/ck_ring/validate/ck_ring_mpmc.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; - ck_ring_buffer_t *buffer; -}; - -struct entry { - unsigned long value_long; - unsigned int magic; - unsigned int ref; - int tid; - int value; -}; - -static int nthr; -static ck_ring_t *ring; -static ck_ring_t ring_mpmc CK_CC_CACHELINE; -static ck_ring_t ring_mw CK_CC_CACHELINE; -static struct affinity a; -static int size; -static int eb; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static struct context *_context; - -static unsigned int global_counter; - -static void * -test_mpmc(void *c) -{ - unsigned int observed = 0; - unsigned int enqueue = 0; - unsigned int seed; - int i, k, j, tid; - struct context *context = c; - ck_ring_buffer_t *buffer; - unsigned int *csp; - - csp = malloc(sizeof(*csp) * nthr); - assert(csp != NULL); - - memset(csp, 0, sizeof(*csp) * nthr); - - buffer = context->buffer; - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_int(&eb, 1); - ck_pr_fence_memory(); - while (ck_pr_load_int(&eb) != nthr - 1); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - struct entry *o = NULL; - int spin; - - /* Keep trying until we encounter at least one node. */ - if (j & 1) { - if (ck_ring_dequeue_mpmc(&ring_mw, buffer, &o) == false) - o = NULL; - } else { - if (ck_ring_trydequeue_mpmc(&ring_mw, buffer, &o) == false) - o = NULL; - } - - if (o == NULL) { - o = malloc(sizeof(*o)); - if (o == NULL) - continue; - - o->value_long = (unsigned long)ck_pr_faa_uint(&global_counter, 1) + 1; - - o->magic = 0xdead; - o->ref = 0; - o->tid = tid; - - if (ck_ring_enqueue_mpmc(&ring_mw, buffer, o) == false) { - free(o); - } else { - enqueue++; - } - - continue; - } - - observed++; - - if (o->magic != 0xdead) { - ck_error("[%p] (%x)\n", - (void *)o, o->magic); - } - - o->magic = 0xbeef; - - if (csp[o->tid] >= o->value_long) - ck_error("queue semantics violated: %lu <= %lu\n", o->value_long, csp[o->tid]); - - csp[o->tid] = o->value_long; - - if (ck_pr_faa_uint(&o->ref, 1) != 0) { - ck_error("[%p] We dequeued twice.\n", (void *)o); - } - - if ((i % 4) == 0) { - spin = common_rand_r(&seed) % 16384; - for (k = 0; k < spin; k++) { - ck_pr_stall(); - } - } - - free(o); - } - } - - fprintf(stderr, "[%d] dequeue=%u enqueue=%u\n", tid, observed, enqueue); - return NULL; -} - -static void * -test_spmc(void *c) -{ - unsigned int observed = 0; - unsigned long previous = 0; - unsigned int seed; - int i, k, j, tid; - struct context *context = c; - ck_ring_buffer_t *buffer; - - buffer = context->buffer; - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_int(&eb, 1); - ck_pr_fence_memory(); - while (ck_pr_load_int(&eb) != nthr - 1); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - struct entry *o; - int spin; - - /* Keep trying until we encounter at least one node. */ - if (j & 1) { - while (ck_ring_dequeue_mpmc(&ring_mpmc, buffer, - &o) == false); - } else { - while (ck_ring_trydequeue_mpmc(&ring_mpmc, buffer, - &o) == false); - } - - observed++; - if (o->value < 0 - || o->value != o->tid - || o->magic != 0xdead - || (previous != 0 && previous >= o->value_long)) { - ck_error("[0x%p] (%x) (%d, %d) >< (0, %d)\n", - (void *)o, o->magic, o->tid, o->value, size); - } - - o->magic = 0xbeef; - o->value = -31337; - o->tid = -31338; - previous = o->value_long; - - if (ck_pr_faa_uint(&o->ref, 1) != 0) { - ck_error("[%p] We dequeued twice.\n", (void *)o); - } - - if ((i % 4) == 0) { - spin = common_rand_r(&seed) % 16384; - for (k = 0; k < spin; k++) { - ck_pr_stall(); - } - } - - free(o); - } - } - - fprintf(stderr, "[%d] Observed %u\n", tid, observed); - return NULL; -} - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - unsigned int s; - int i, j; - bool r; - ck_ring_buffer_t *buffer = context->buffer; - ck_barrier_centralized_state_t sense = - CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - if (context->tid == 0) { - struct entry *entries; - - entries = malloc(sizeof(struct entry) * size); - assert(entries != NULL); - - if (ck_ring_size(ring) != 0) { - ck_error("More entries than expected: %u > 0\n", - ck_ring_size(ring)); - } - - for (i = 0; i < size; i++) { - entries[i].value = i; - entries[i].tid = 0; - - if (true) { - r = ck_ring_enqueue_mpmc(ring, buffer, - entries + i); - } else { - r = ck_ring_enqueue_mpmc_size(ring, buffer, - entries + i, &s); - - if ((int)s != i) { - ck_error("Size is %u, expected %d.\n", - s, size); - } - } - - assert(r != false); - } - - if (ck_ring_size(ring) != (unsigned int)size) { - ck_error("Less entries than expected: %u < %d\n", - ck_ring_size(ring), size); - } - - if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { - ck_error("Capacity less than expected: %u < %u\n", - ck_ring_size(ring), ck_ring_capacity(ring)); - } - } - - /* - * Wait for all threads. The idea here is to maximize the contention. - */ - ck_barrier_centralized(&barrier, &sense, nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - buffer = _context[context->previous].buffer; - while (ck_ring_dequeue_mpmc(ring + context->previous, - buffer, &entry) == false); - - if (context->previous != (unsigned int)entry->tid) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - if (entry->value < 0 || entry->value >= size) { - ck_error("[%u:%p] %u %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - entry->tid = context->tid; - buffer = context->buffer; - - if (true) { - r = ck_ring_enqueue_mpmc(ring + context->tid, - buffer, entry); - } else { - r = ck_ring_enqueue_mpmc_size(ring + context->tid, - buffer, entry, &s); - - if ((int)s >= size) { - ck_error("Size %u out of range of %d\n", - s, size); - } - } - assert(r == true); - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - unsigned long l; - pthread_t *thread; - ck_ring_buffer_t *buffer; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size >= 4 && (size & size - 1) == 0); - size -= 1; - - ring = malloc(sizeof(ck_ring_t) * nthr); - assert(ring); - - _context = malloc(sizeof(*_context) * nthr); - assert(_context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - fprintf(stderr, "SPSC test:"); - for (i = 0; i < nthr; i++) { - _context[i].tid = i; - if (i == 0) { - _context[i].previous = nthr - 1; - _context[i].next = i + 1; - } else if (i == nthr - 1) { - _context[i].next = 0; - _context[i].previous = i - 1; - } else { - _context[i].next = i + 1; - _context[i].previous = i - 1; - } - - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(ck_ring_buffer_t) * (size + 1)); - _context[i].buffer = buffer; - ck_ring_init(ring + i, size + 1); - r = pthread_create(thread + i, NULL, test, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, " done\n"); - - fprintf(stderr, "SPMC test:\n"); - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(void *) * (size + 1)); - ck_ring_init(&ring_mpmc, size + 1); - for (i = 0; i < nthr - 1; i++) { - _context[i].buffer = buffer; - r = pthread_create(thread + i, NULL, test_spmc, _context + i); - assert(r == 0); - } - - for (l = 0; l < (unsigned long)size * ITERATIONS * (nthr - 1) ; l++) { - struct entry *entry = malloc(sizeof *entry); - - assert(entry != NULL); - entry->value_long = l; - entry->value = (int)l; - entry->tid = (int)l; - entry->magic = 0xdead; - entry->ref = 0; - - /* Wait until queue is not full. */ - if (l & 1) { - while (ck_ring_enqueue_mpmc(&ring_mpmc, - buffer, - entry) == false) - ck_pr_stall(); - } else { - unsigned int s; - - while (ck_ring_enqueue_mpmc_size(&ring_mpmc, - buffer, entry, &s) == false) { - ck_pr_stall(); - } - - if ((int)s >= (size * ITERATIONS * (nthr - 1))) { - ck_error("MPMC: Unexpected size of %u\n", s); - } - } - } - - for (i = 0; i < nthr - 1; i++) - pthread_join(thread[i], NULL); - ck_pr_store_int(&eb, 0); - fprintf(stderr, "MPMC test:\n"); - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(void *) * (size + 1)); - ck_ring_init(&ring_mw, size + 1); - for (i = 0; i < nthr - 1; i++) { - _context[i].buffer = buffer; - r = pthread_create(thread + i, NULL, test_mpmc, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr - 1; i++) - pthread_join(thread[i], NULL); - - return (0); -} diff --git a/regressions/ck_ring/validate/ck_ring_mpmc_template.c b/regressions/ck_ring/validate/ck_ring_mpmc_template.c deleted file mode 100644 index f076e9a6e34d..000000000000 --- a/regressions/ck_ring/validate/ck_ring_mpmc_template.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; - struct entry **buffer; -}; - -struct entry { - unsigned long value_long; - unsigned int magic; - unsigned int ref; - int tid; - int value; -}; - -CK_RING_PROTOTYPE(entry, entry *) - -static int nthr; -static ck_ring_t *ring; -static ck_ring_t ring_spmc CK_CC_CACHELINE; -static struct affinity a; -static int size; -static int eb; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static struct context *_context; - -static void * -test_spmc(void *c) -{ - unsigned int observed = 0; - unsigned long previous = 0; - unsigned int seed; - int i, k, j, tid; - struct context *context = c; - struct entry **buffer; - - buffer = context->buffer; - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_int(&eb, 1); - ck_pr_fence_memory(); - while (ck_pr_load_int(&eb) != nthr - 1); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - struct entry *o; - int spin; - - /* Keep trying until we encounter at least one node. */ - if (j & 1) { - while (CK_RING_DEQUEUE_MPMC(entry, - &ring_spmc, buffer, &o) == false); - } else { - while (CK_RING_TRYDEQUEUE_MPMC(entry, - &ring_spmc, buffer, &o) == false); - } - - observed++; - if (o->value < 0 - || o->value != o->tid - || o->magic != 0xdead - || (previous != 0 && previous >= o->value_long)) { - ck_error("[0x%p] (%x) (%d, %d) >< (0, %d)\n", - (void *)o, o->magic, o->tid, o->value, size); - } - - o->magic = 0xbeef; - o->value = -31337; - o->tid = -31338; - previous = o->value_long; - - if (ck_pr_faa_uint(&o->ref, 1) != 0) { - ck_error("[%p] We dequeued twice.\n", (void *)o); - } - - if ((i % 4) == 0) { - spin = common_rand_r(&seed) % 16384; - for (k = 0; k < spin; k++) { - ck_pr_stall(); - } - } - - free(o); - } - } - - fprintf(stderr, "[%d] Observed %u\n", tid, observed); - return NULL; -} - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - unsigned int s; - int i, j; - bool r; - struct entry **buffer = context->buffer; - ck_barrier_centralized_state_t sense = - CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - if (context->tid == 0) { - struct entry **entries; - - entries = malloc(sizeof(struct entry *) * size); - assert(entries != NULL); - - if (ck_ring_size(ring) != 0) { - ck_error("More entries than expected: %u > 0\n", - ck_ring_size(ring)); - } - - for (i = 0; i < size; i++) { - entries[i] = malloc(sizeof(struct entry)); - assert(entries[i] != NULL); - - entries[i]->value = i; - entries[i]->tid = 0; - - if (i & 1) { - r = CK_RING_ENQUEUE_MPMC(entry, ring, buffer, - &entries[i]); - } else { - r = CK_RING_ENQUEUE_MPMC_SIZE(entry, ring, - buffer, &entries[i], &s); - - if ((int)s != i) { - ck_error("Size is %u, expected %d.\n", - s, size); - } - } - - assert(r != false); - } - - if (ck_ring_size(ring) != (unsigned int)size) { - ck_error("Less entries than expected: %u < %d\n", - ck_ring_size(ring), size); - } - - if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { - ck_error("Capacity less than expected: %u < %u\n", - ck_ring_size(ring), ck_ring_capacity(ring)); - } - } - - /* - * Wait for all threads. The idea here is to maximize the contention. - */ - ck_barrier_centralized(&barrier, &sense, nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - buffer = _context[context->previous].buffer; - while (CK_RING_DEQUEUE_MPMC(entry, - ring + context->previous, - buffer, &entry) == false); - - if (context->previous != (unsigned int)entry->tid) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, - entry->tid, context->previous); - } - - if (entry->value < 0 || entry->value >= size) { - ck_error("[%u:%p] %u %u\n", - context->tid, (void *)entry, - entry->tid, context->previous); - } - - entry->tid = context->tid; - buffer = context->buffer; - - if (i & 1) { - r = CK_RING_ENQUEUE_MPMC(entry, - ring + context->tid, - buffer, &entry); - } else { - r = CK_RING_ENQUEUE_MPMC_SIZE(entry, - ring + context->tid, - buffer, &entry, &s); - - if ((int)s >= size) { - ck_error("Size %u out of range of %d\n", - s, size); - } - } - assert(r == true); - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - unsigned long l; - pthread_t *thread; - struct entry **buffer; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size >= 4 && (size & size - 1) == 0); - size -= 1; - - ring = malloc(sizeof(ck_ring_t) * nthr); - assert(ring); - - _context = malloc(sizeof(*_context) * nthr); - assert(_context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - fprintf(stderr, "SPSC test:"); - for (i = 0; i < nthr; i++) { - _context[i].tid = i; - if (i == 0) { - _context[i].previous = nthr - 1; - _context[i].next = i + 1; - } else if (i == nthr - 1) { - _context[i].next = 0; - _context[i].previous = i - 1; - } else { - _context[i].next = i + 1; - _context[i].previous = i - 1; - } - - buffer = malloc(sizeof(struct entry *) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(struct entry *) * (size + 1)); - _context[i].buffer = buffer; - ck_ring_init(ring + i, size + 1); - r = pthread_create(thread + i, NULL, test, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, " done\n"); - - fprintf(stderr, "MPMC test:\n"); - buffer = malloc(sizeof(struct entry *) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(struct entry *) * (size + 1)); - ck_ring_init(&ring_spmc, size + 1); - for (i = 0; i < nthr - 1; i++) { - _context[i].buffer = buffer; - r = pthread_create(thread + i, NULL, test_spmc, _context + i); - assert(r == 0); - } - - for (l = 0; l < (unsigned long)size * ITERATIONS * (nthr - 1) ; l++) { - struct entry *entry = malloc(sizeof *entry); - - assert(entry != NULL); - entry->value_long = l; - entry->value = (int)l; - entry->tid = (int)l; - entry->magic = 0xdead; - entry->ref = 0; - - /* Wait until queue is not full. */ - if (l & 1) { - while (CK_RING_ENQUEUE_MPMC(entry, &ring_spmc, - buffer, &entry) == false) { - ck_pr_stall(); - } - } else { - unsigned int s; - - while (CK_RING_ENQUEUE_MPMC_SIZE(entry, &ring_spmc, - buffer, &entry, &s) == false) { - ck_pr_stall(); - } - - if ((int)s >= (size * ITERATIONS * (nthr - 1))) { - ck_error("MPMC: Unexpected size of %u\n", s); - } - } - } - - for (i = 0; i < nthr - 1; i++) - pthread_join(thread[i], NULL); - - return 0; -} diff --git a/regressions/ck_ring/validate/ck_ring_spmc.c b/regressions/ck_ring/validate/ck_ring_spmc.c deleted file mode 100644 index 161c0d8515bf..000000000000 --- a/regressions/ck_ring/validate/ck_ring_spmc.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; - ck_ring_buffer_t *buffer; -}; - -struct entry { - unsigned long value_long; - unsigned int magic; - unsigned int ref; - int tid; - int value; -}; - -static int nthr; -static ck_ring_t *ring; -static ck_ring_t ring_spmc CK_CC_CACHELINE; -static struct affinity a; -static int size; -static int eb; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static struct context *_context; - -static void * -test_spmc(void *c) -{ - unsigned int observed = 0; - unsigned long previous = 0; - unsigned int seed; - int i, k, j, tid; - struct context *context = c; - ck_ring_buffer_t *buffer; - - buffer = context->buffer; - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_int(&eb, 1); - ck_pr_fence_memory(); - while (ck_pr_load_int(&eb) != nthr - 1); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - struct entry *o; - int spin; - - /* Keep trying until we encounter at least one node. */ - if (j & 1) { - while (ck_ring_dequeue_spmc(&ring_spmc, buffer, - &o) == false); - } else { - while (ck_ring_trydequeue_spmc(&ring_spmc, buffer, - &o) == false); - } - - observed++; - if (o->value < 0 - || o->value != o->tid - || o->magic != 0xdead - || (previous != 0 && previous >= o->value_long)) { - ck_error("[0x%p] (%x) (%d, %d) >< (0, %d)\n", - (void *)o, o->magic, o->tid, o->value, size); - } - - o->magic = 0xbeef; - o->value = -31337; - o->tid = -31338; - previous = o->value_long; - - if (ck_pr_faa_uint(&o->ref, 1) != 0) { - ck_error("[%p] We dequeued twice.\n", (void *)o); - } - - if ((i % 4) == 0) { - spin = common_rand_r(&seed) % 16384; - for (k = 0; k < spin; k++) { - ck_pr_stall(); - } - } - - free(o); - } - } - - fprintf(stderr, "[%d] Observed %u\n", tid, observed); - return NULL; -} - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - unsigned int s; - int i, j; - bool r; - ck_ring_buffer_t *buffer = context->buffer; - ck_barrier_centralized_state_t sense = - CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - if (context->tid == 0) { - struct entry *entries; - - entries = malloc(sizeof(struct entry) * size); - assert(entries != NULL); - - if (ck_ring_size(ring) != 0) { - ck_error("More entries than expected: %u > 0\n", - ck_ring_size(ring)); - } - - for (i = 0; i < size; i++) { - entries[i].value = i; - entries[i].tid = 0; - - if (i & 1) { - r = ck_ring_enqueue_spmc(ring, buffer, - entries + i); - } else { - r = ck_ring_enqueue_spmc_size(ring, buffer, - entries + i, &s); - - if ((int)s != i) { - ck_error("Size is %u, expected %d.\n", - s, size); - } - } - - assert(r != false); - } - - if (ck_ring_size(ring) != (unsigned int)size) { - ck_error("Less entries than expected: %u < %d\n", - ck_ring_size(ring), size); - } - - if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { - ck_error("Capacity less than expected: %u < %u\n", - ck_ring_size(ring), ck_ring_capacity(ring)); - } - } - - /* - * Wait for all threads. The idea here is to maximize the contention. - */ - ck_barrier_centralized(&barrier, &sense, nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - buffer = _context[context->previous].buffer; - while (ck_ring_dequeue_spmc(ring + context->previous, - buffer, &entry) == false); - - if (context->previous != (unsigned int)entry->tid) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - if (entry->value < 0 || entry->value >= size) { - ck_error("[%u:%p] %u %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - entry->tid = context->tid; - buffer = context->buffer; - - if (i & 1) { - r = ck_ring_enqueue_spmc(ring + context->tid, - buffer, entry); - } else { - r = ck_ring_enqueue_spmc_size(ring + context->tid, - buffer, entry, &s); - - if ((int)s >= size) { - ck_error("Size %u out of range of %d\n", - s, size); - } - } - assert(r == true); - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - unsigned long l; - pthread_t *thread; - ck_ring_buffer_t *buffer; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size >= 4 && (size & size - 1) == 0); - size -= 1; - - ring = malloc(sizeof(ck_ring_t) * nthr); - assert(ring); - - _context = malloc(sizeof(*_context) * nthr); - assert(_context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - fprintf(stderr, "SPSC test:"); - for (i = 0; i < nthr; i++) { - _context[i].tid = i; - if (i == 0) { - _context[i].previous = nthr - 1; - _context[i].next = i + 1; - } else if (i == nthr - 1) { - _context[i].next = 0; - _context[i].previous = i - 1; - } else { - _context[i].next = i + 1; - _context[i].previous = i - 1; - } - - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(ck_ring_buffer_t) * (size + 1)); - _context[i].buffer = buffer; - ck_ring_init(ring + i, size + 1); - r = pthread_create(thread + i, NULL, test, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, " done\n"); - - fprintf(stderr, "SPMC test:\n"); - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(void *) * (size + 1)); - ck_ring_init(&ring_spmc, size + 1); - for (i = 0; i < nthr - 1; i++) { - _context[i].buffer = buffer; - r = pthread_create(thread + i, NULL, test_spmc, _context + i); - assert(r == 0); - } - - for (l = 0; l < (unsigned long)size * ITERATIONS * (nthr - 1) ; l++) { - struct entry *entry = malloc(sizeof *entry); - - assert(entry != NULL); - entry->value_long = l; - entry->value = (int)l; - entry->tid = (int)l; - entry->magic = 0xdead; - entry->ref = 0; - - /* Wait until queue is not full. */ - if (l & 1) { - while (ck_ring_enqueue_spmc(&ring_spmc, - buffer, - entry) == false) - ck_pr_stall(); - } else { - unsigned int s; - - while (ck_ring_enqueue_spmc_size(&ring_spmc, - buffer, entry, &s) == false) { - ck_pr_stall(); - } - - if ((int)s >= (size * ITERATIONS * (nthr - 1))) { - ck_error("MPMC: Unexpected size of %u\n", s); - } - } - } - - for (i = 0; i < nthr - 1; i++) - pthread_join(thread[i], NULL); - - return (0); -} - diff --git a/regressions/ck_ring/validate/ck_ring_spmc_template.c b/regressions/ck_ring/validate/ck_ring_spmc_template.c deleted file mode 100644 index bbc75c11501a..000000000000 --- a/regressions/ck_ring/validate/ck_ring_spmc_template.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; - struct entry **buffer; -}; - -struct entry { - unsigned long value_long; - unsigned int magic; - unsigned int ref; - int tid; - int value; -}; - -CK_RING_PROTOTYPE(entry, entry *) - -static int nthr; -static ck_ring_t *ring; -static ck_ring_t ring_spmc CK_CC_CACHELINE; -static struct affinity a; -static int size; -static int eb; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static struct context *_context; - -static void * -test_spmc(void *c) -{ - unsigned int observed = 0; - unsigned long previous = 0; - unsigned int seed; - int i, k, j, tid; - struct context *context = c; - struct entry **buffer; - - buffer = context->buffer; - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - tid = ck_pr_faa_int(&eb, 1); - ck_pr_fence_memory(); - while (ck_pr_load_int(&eb) != nthr - 1); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - struct entry *o; - int spin; - - /* Keep trying until we encounter at least one node. */ - if (j & 1) { - while (CK_RING_DEQUEUE_SPMC(entry, - &ring_spmc, buffer, &o) == false); - } else { - while (CK_RING_TRYDEQUEUE_SPMC(entry, - &ring_spmc, buffer, &o) == false); - } - - observed++; - if (o->value < 0 - || o->value != o->tid - || o->magic != 0xdead - || (previous != 0 && previous >= o->value_long)) { - ck_error("[0x%p] (%x) (%d, %d) >< (0, %d)\n", - (void *)o, o->magic, o->tid, o->value, size); - } - - o->magic = 0xbeef; - o->value = -31337; - o->tid = -31338; - previous = o->value_long; - - if (ck_pr_faa_uint(&o->ref, 1) != 0) { - ck_error("[%p] We dequeued twice.\n", (void *)o); - } - - if ((i % 4) == 0) { - spin = common_rand_r(&seed) % 16384; - for (k = 0; k < spin; k++) { - ck_pr_stall(); - } - } - - free(o); - } - } - - fprintf(stderr, "[%d] Observed %u\n", tid, observed); - return NULL; -} - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - unsigned int s; - int i, j; - bool r; - struct entry **buffer = context->buffer; - ck_barrier_centralized_state_t sense = - CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - if (context->tid == 0) { - struct entry **entries; - - entries = malloc(sizeof(struct entry *) * size); - assert(entries != NULL); - - if (ck_ring_size(ring) != 0) { - ck_error("More entries than expected: %u > 0\n", - ck_ring_size(ring)); - } - - for (i = 0; i < size; i++) { - entries[i] = malloc(sizeof(struct entry)); - assert(entries[i] != NULL); - - entries[i]->value = i; - entries[i]->tid = 0; - - if (i & 1) { - r = CK_RING_ENQUEUE_SPMC(entry, ring, buffer, - &entries[i]); - } else { - r = CK_RING_ENQUEUE_SPMC_SIZE(entry, ring, - buffer, &entries[i], &s); - - if ((int)s != i) { - ck_error("Size is %u, expected %d.\n", - s, size); - } - } - - assert(r != false); - } - - if (ck_ring_size(ring) != (unsigned int)size) { - ck_error("Less entries than expected: %u < %d\n", - ck_ring_size(ring), size); - } - - if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { - ck_error("Capacity less than expected: %u < %u\n", - ck_ring_size(ring), ck_ring_capacity(ring)); - } - } - - /* - * Wait for all threads. The idea here is to maximize the contention. - */ - ck_barrier_centralized(&barrier, &sense, nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - buffer = _context[context->previous].buffer; - while (CK_RING_DEQUEUE_SPMC(entry, - ring + context->previous, - buffer, &entry) == false); - - if (context->previous != (unsigned int)entry->tid) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, - entry->tid, context->previous); - } - - if (entry->value < 0 || entry->value >= size) { - ck_error("[%u:%p] %u %u\n", - context->tid, (void *)entry, - entry->tid, context->previous); - } - - entry->tid = context->tid; - buffer = context->buffer; - - if (i & 1) { - r = CK_RING_ENQUEUE_SPMC(entry, - ring + context->tid, - buffer, &entry); - } else { - r = CK_RING_ENQUEUE_SPMC_SIZE(entry, - ring + context->tid, - buffer, &entry, &s); - - if ((int)s >= size) { - ck_error("Size %u out of range of %d\n", - s, size); - } - } - assert(r == true); - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - unsigned long l; - pthread_t *thread; - struct entry **buffer; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size >= 4 && (size & size - 1) == 0); - size -= 1; - - ring = malloc(sizeof(ck_ring_t) * nthr); - assert(ring); - - _context = malloc(sizeof(*_context) * nthr); - assert(_context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - fprintf(stderr, "SPSC test:"); - for (i = 0; i < nthr; i++) { - _context[i].tid = i; - if (i == 0) { - _context[i].previous = nthr - 1; - _context[i].next = i + 1; - } else if (i == nthr - 1) { - _context[i].next = 0; - _context[i].previous = i - 1; - } else { - _context[i].next = i + 1; - _context[i].previous = i - 1; - } - - buffer = malloc(sizeof(struct entry *) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(struct entry *) * (size + 1)); - _context[i].buffer = buffer; - ck_ring_init(ring + i, size + 1); - r = pthread_create(thread + i, NULL, test, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - fprintf(stderr, " done\n"); - - fprintf(stderr, "SPMC test:\n"); - buffer = malloc(sizeof(struct entry *) * (size + 1)); - assert(buffer); - memset(buffer, 0, sizeof(struct entry *) * (size + 1)); - ck_ring_init(&ring_spmc, size + 1); - for (i = 0; i < nthr - 1; i++) { - _context[i].buffer = buffer; - r = pthread_create(thread + i, NULL, test_spmc, _context + i); - assert(r == 0); - } - - for (l = 0; l < (unsigned long)size * ITERATIONS * (nthr - 1) ; l++) { - struct entry *entry = malloc(sizeof *entry); - - assert(entry != NULL); - entry->value_long = l; - entry->value = (int)l; - entry->tid = (int)l; - entry->magic = 0xdead; - entry->ref = 0; - - /* Wait until queue is not full. */ - if (l & 1) { - while (CK_RING_ENQUEUE_SPMC(entry, &ring_spmc, - buffer, &entry) == false) { - ck_pr_stall(); - } - } else { - unsigned int s; - - while (CK_RING_ENQUEUE_SPMC_SIZE(entry, &ring_spmc, - buffer, &entry, &s) == false) { - ck_pr_stall(); - } - - if ((int)s >= (size * ITERATIONS * (nthr - 1))) { - ck_error("MPMC: Unexpected size of %u\n", s); - } - } - } - - for (i = 0; i < nthr - 1; i++) - pthread_join(thread[i], NULL); - - return 0; -} - diff --git a/regressions/ck_ring/validate/ck_ring_spsc.c b/regressions/ck_ring/validate/ck_ring_spsc.c deleted file mode 100644 index 910f7e654bdb..000000000000 --- a/regressions/ck_ring/validate/ck_ring_spsc.c +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include -#include -#include "../../common.h" - -#ifndef ITERATIONS -#define ITERATIONS 128 -#endif - -struct context { - unsigned int tid; - unsigned int previous; - unsigned int next; - void *buffer; -}; - -struct entry { - int tid; - int value; -}; - -static int nthr; -static ck_ring_t *ring; -static struct affinity a; -static int size; -static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; -static struct context *_context; - -static void * -test(void *c) -{ - struct context *context = c; - struct entry *entry; - unsigned int s; - int i, j; - bool r; - ck_barrier_centralized_state_t sense = - CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; - ck_ring_buffer_t *buffer; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - buffer = context->buffer; - if (context->tid == 0) { - struct entry *entries; - - entries = malloc(sizeof(struct entry) * size); - assert(entries != NULL); - - if (ck_ring_size(ring) != 0) { - ck_error("More entries than expected: %u > 0\n", - ck_ring_size(ring)); - } - - for (i = 0; i < size; i++) { - entries[i].value = i; - entries[i].tid = 0; - - if (i & 1) { - r = ck_ring_enqueue_spsc(ring, buffer, - entries + i); - } else { - r = ck_ring_enqueue_spsc_size(ring, - buffer, entries + i, &s); - - if ((int)s != i) { - ck_error("Size is %u, expected %d\n", - s, i + 1); - } - } - - assert(r != false); - } - - if (ck_ring_size(ring) != (unsigned int)size) { - ck_error("Less entries than expected: %u < %d\n", - ck_ring_size(ring), size); - } - - if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { - ck_error("Capacity less than expected: %u < %u\n", - ck_ring_size(ring), ck_ring_capacity(ring)); - } - } - - ck_barrier_centralized(&barrier, &sense, nthr); - - for (i = 0; i < ITERATIONS; i++) { - for (j = 0; j < size; j++) { - buffer = _context[context->previous].buffer; - while (ck_ring_dequeue_spsc(ring + context->previous, - buffer, &entry) == false); - - if (context->previous != (unsigned int)entry->tid) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - if (entry->value != j) { - ck_error("[%u:%p] %u != %u\n", - context->tid, (void *)entry, entry->tid, context->previous); - } - - entry->tid = context->tid; - buffer = context->buffer; - if (i & 1) { - r = ck_ring_enqueue_spsc(ring + context->tid, - buffer, entry); - } else { - r = ck_ring_enqueue_spsc_size(ring + - context->tid, buffer, entry, &s); - - if ((int)s >= size) { - ck_error("Size %u is out of range %d\n", - s, size); - } - } - assert(r == true); - } - } - - return NULL; -} - -int -main(int argc, char *argv[]) -{ - int i, r; - ck_ring_buffer_t *buffer; - pthread_t *thread; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - a.request = 0; - a.delta = atoi(argv[2]); - - nthr = atoi(argv[1]); - assert(nthr >= 1); - - size = atoi(argv[3]); - assert(size >= 4 && (size & size - 1) == 0); - size -= 1; - - ring = malloc(sizeof(ck_ring_t) * nthr); - assert(ring); - - _context = malloc(sizeof(*_context) * nthr); - assert(_context); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread); - - for (i = 0; i < nthr; i++) { - _context[i].tid = i; - if (i == 0) { - _context[i].previous = nthr - 1; - _context[i].next = i + 1; - } else if (i == nthr - 1) { - _context[i].next = 0; - _context[i].previous = i - 1; - } else { - _context[i].next = i + 1; - _context[i].previous = i - 1; - } - - buffer = malloc(sizeof(ck_ring_buffer_t) * (size + 1)); - assert(buffer); - _context[i].buffer = buffer; - ck_ring_init(ring + i, size + 1); - r = pthread_create(thread + i, NULL, test, _context + i); - assert(r == 0); - } - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - return (0); -} diff --git a/regressions/ck_rwcohort/benchmark/Makefile b/regressions/ck_rwcohort/benchmark/Makefile deleted file mode 100644 index 054c85c0fabd..000000000000 --- a/regressions/ck_rwcohort/benchmark/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput -OBJECTS=ck_neutral.THROUGHPUT ck_neutral.LATENCY \ - ck_rp.THROUGHPUT ck_rp.LATENCY \ - ck_wp.THROUGHPUT ck_wp.LATENCY - -all: $(OBJECTS) - -ck_neutral.THROUGHPUT: ck_neutral.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_neutral.THROUGHPUT ck_neutral.c - -ck_neutral.LATENCY: ck_neutral.c - $(CC) -DLATENCY $(CFLAGS) -o ck_neutral.LATENCY ck_neutral.c - -ck_rp.THROUGHPUT: ck_rp.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_rp.THROUGHPUT ck_rp.c - -ck_rp.LATENCY: ck_rp.c - $(CC) -DLATENCY $(CFLAGS) -o ck_rp.LATENCY ck_rp.c - -ck_wp.THROUGHPUT: ck_wp.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_wp.THROUGHPUT ck_wp.c - -ck_wp.LATENCY: ck_wp.c - $(CC) -DLATENCY $(CFLAGS) -o ck_wp.LATENCY ck_wp.c - -clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwcohort/benchmark/ck_neutral.c b/regressions/ck_rwcohort/benchmark/ck_neutral.c deleted file mode 100644 index 9fb85db2d569..000000000000 --- a/regressions/ck_rwcohort/benchmark/ck_neutral.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_neutral.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_rwcohort/benchmark/ck_rp.c b/regressions/ck_rwcohort/benchmark/ck_rp.c deleted file mode 100644 index 798e5781030c..000000000000 --- a/regressions/ck_rwcohort/benchmark/ck_rp.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_rp.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_rwcohort/benchmark/ck_wp.c b/regressions/ck_rwcohort/benchmark/ck_wp.c deleted file mode 100644 index 07b0cced1436..000000000000 --- a/regressions/ck_rwcohort/benchmark/ck_wp.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_wp.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_rwcohort/benchmark/latency.h b/regressions/ck_rwcohort/benchmark/latency.h deleted file mode 100644 index 027a8b20a50a..000000000000 --- a/regressions/ck_rwcohort/benchmark/latency.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * Copyright 2013 Brendon Scheinman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static void -ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_lock(lock); -} - -static void -ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_unlock(lock); -} - -static bool -ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - return ck_spinlock_fas_locked(lock); -} - -CK_COHORT_PROTOTYPE(fas_fas, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -LOCK_PROTOTYPE(fas_fas) - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_spinlock_fas_t global_lock = CK_SPINLOCK_FAS_INITIALIZER; - ck_spinlock_fas_t local_lock = CK_SPINLOCK_FAS_INITIALIZER; - CK_COHORT_INSTANCE(fas_fas) cohort = CK_COHORT_INITIALIZER; - LOCK_INSTANCE(fas_fas) rw_cohort = LOCK_INITIALIZER; - - CK_COHORT_INIT(fas_fas, &cohort, &global_lock, &local_lock, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - LOCK_INIT(fas_fas, &rw_cohort, CK_RWCOHORT_WP_DEFAULT_WAIT_LIMIT); - - for (i = 0; i < STEPS; i++) { - WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - } - e_b = rdtsc(); - printf("WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - } - e_b = rdtsc(); - printf("READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return (0); -} - diff --git a/regressions/ck_rwcohort/benchmark/throughput.h b/regressions/ck_rwcohort/benchmark/throughput.h deleted file mode 100644 index 2870855b0807..000000000000 --- a/regressions/ck_rwcohort/benchmark/throughput.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * Copyright 2013 Brendon Scheinman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#define max(x, y) (((x) > (y)) ? (x) : (y)) - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static unsigned int barrier; -static unsigned int flag CK_CC_CACHELINE; -static struct affinity affinity; -static unsigned int nthr; - -static void -ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - ck_spinlock_fas_lock(lock); - return; -} - -static void -ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - ck_spinlock_fas_unlock(lock); - return; -} - -static bool -ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) -{ - - (void)context; - return ck_spinlock_fas_locked(lock); -} - -CK_COHORT_PROTOTYPE(fas_fas, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -LOCK_PROTOTYPE(fas_fas) - -struct cohort_record { - CK_COHORT_INSTANCE(fas_fas) cohort; -} CK_CC_CACHELINE; -static struct cohort_record *cohorts; - -static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; -static LOCK_INSTANCE(fas_fas) rw_cohort = LOCK_INITIALIZER; -static unsigned int n_cohorts; - -struct block { - unsigned int tid; -}; - -static void * -thread_rwlock(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - CK_COHORT_INSTANCE(fas_fas) *cohort; - unsigned int core; - - if (aff_iterate_core(&affinity, &core) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - cohort = &((cohorts + (core / (int)(affinity.delta)) % n_cohorts)->cohort); - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) != nthr) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) != nthr * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -int -main(int argc, char *argv[]) -{ - unsigned int i; - pthread_t *threads; - uint64_t *latency; - struct block *context; - ck_spinlock_fas_t *local_lock; - - if (argc != 4) { - ck_error("Usage: throughput \n"); - } - - n_cohorts = atoi(argv[1]); - if (n_cohorts <= 0) { - ck_error("ERROR: Number of cohorts must be greater than 0\n"); - } - - nthr = n_cohorts * atoi(argv[2]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - cohorts = malloc(sizeof(struct cohort_record) * n_cohorts); - if (cohorts == NULL) { - ck_error("ERROR: Could not allocate cohort structures\n"); - } - - context = malloc(sizeof(struct block) * nthr); - if (context == NULL) { - ck_error("ERROR: Could not allocate thread contexts\n"); - } - - affinity.delta = atoi(argv[3]); - affinity.request = 0; - - latency = malloc(sizeof(*latency) * nthr); - if (latency == NULL) { - ck_error("ERROR: Could not create latency buffer\n"); - } - memset(latency, 0, sizeof(*latency) * nthr); - - fprintf(stderr, "Creating cohorts..."); - for (i = 0 ; i < n_cohorts ; i++) { - local_lock = malloc(max(CK_MD_CACHELINE, sizeof(ck_spinlock_fas_t))); - if (local_lock == NULL) { - ck_error("ERROR: Could not allocate local lock\n"); - } - CK_COHORT_INIT(fas_fas, &((cohorts + i)->cohort), &global_lock, local_lock, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - local_lock = NULL; - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Creating threads (rwlock)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread_rwlock, latency + i) != 0) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done\n\n"); - - for (i = 1; i <= nthr; i++) - printf("%10u %20" PRIu64 "\n", i, latency[i - 1]); - - return (0); -} - diff --git a/regressions/ck_rwcohort/ck_neutral.h b/regressions/ck_rwcohort/ck_neutral.h deleted file mode 100644 index dbbda9d49d35..000000000000 --- a/regressions/ck_rwcohort/ck_neutral.h +++ /dev/null @@ -1,8 +0,0 @@ -#define LOCK_PROTOTYPE CK_RWCOHORT_NEUTRAL_PROTOTYPE -#define LOCK_INSTANCE CK_RWCOHORT_NEUTRAL_INSTANCE -#define LOCK_INITIALIZER CK_RWCOHORT_NEUTRAL_INITIALIZER -#define LOCK_INIT(N, C, W) CK_RWCOHORT_NEUTRAL_INIT(N, C) -#define READ_LOCK CK_RWCOHORT_NEUTRAL_READ_LOCK -#define WRITE_LOCK CK_RWCOHORT_NEUTRAL_WRITE_LOCK -#define READ_UNLOCK CK_RWCOHORT_NEUTRAL_READ_UNLOCK -#define WRITE_UNLOCK CK_RWCOHORT_NEUTRAL_WRITE_UNLOCK diff --git a/regressions/ck_rwcohort/ck_rp.h b/regressions/ck_rwcohort/ck_rp.h deleted file mode 100644 index e20f3d2d6b39..000000000000 --- a/regressions/ck_rwcohort/ck_rp.h +++ /dev/null @@ -1,8 +0,0 @@ -#define LOCK_PROTOTYPE CK_RWCOHORT_RP_PROTOTYPE -#define LOCK_INSTANCE CK_RWCOHORT_RP_INSTANCE -#define LOCK_INITIALIZER CK_RWCOHORT_RP_INITIALIZER -#define LOCK_INIT CK_RWCOHORT_RP_INIT -#define READ_LOCK CK_RWCOHORT_RP_READ_LOCK -#define READ_UNLOCK CK_RWCOHORT_RP_READ_UNLOCK -#define WRITE_LOCK CK_RWCOHORT_RP_WRITE_LOCK -#define WRITE_UNLOCK CK_RWCOHORT_RP_WRITE_UNLOCK diff --git a/regressions/ck_rwcohort/ck_wp.h b/regressions/ck_rwcohort/ck_wp.h deleted file mode 100644 index 556c7dfda762..000000000000 --- a/regressions/ck_rwcohort/ck_wp.h +++ /dev/null @@ -1,8 +0,0 @@ -#define LOCK_PROTOTYPE CK_RWCOHORT_WP_PROTOTYPE -#define LOCK_INSTANCE CK_RWCOHORT_WP_INSTANCE -#define LOCK_INITIALIZER CK_RWCOHORT_WP_INITIALIZER -#define LOCK_INIT CK_RWCOHORT_WP_INIT -#define READ_LOCK CK_RWCOHORT_WP_READ_LOCK -#define WRITE_LOCK CK_RWCOHORT_WP_WRITE_LOCK -#define READ_UNLOCK CK_RWCOHORT_WP_READ_UNLOCK -#define WRITE_UNLOCK CK_RWCOHORT_WP_WRITE_UNLOCK diff --git a/regressions/ck_rwcohort/validate/Makefile b/regressions/ck_rwcohort/validate/Makefile deleted file mode 100644 index 33e3a29f93ef..000000000000 --- a/regressions/ck_rwcohort/validate/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_neutral ck_rp ck_wp - -all: $(OBJECTS) - -ck_neutral: ck_neutral.c ../../../include/ck_rwcohort.h - $(CC) $(CFLAGS) -o ck_neutral ck_neutral.c - -ck_rp: ck_rp.c ../../../include/ck_rwcohort.h - $(CC) $(CFLAGS) -o ck_rp ck_rp.c - -ck_wp: ck_wp.c ../../../include/ck_rwcohort.h - $(CC) $(CFLAGS) -o ck_wp ck_wp.c - -check: all - ./ck_neutral `expr $(CORES) / 2` 2 1 - ./ck_rp `expr $(CORES) / 2` 2 1 - ./ck_wp `expr $(CORES) / 2` 2 1 - -clean: - rm -rf *.dSYM *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwcohort/validate/ck_neutral.c b/regressions/ck_rwcohort/validate/ck_neutral.c deleted file mode 100644 index 7884dc50374b..000000000000 --- a/regressions/ck_rwcohort/validate/ck_neutral.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_neutral.h" -#include "validate.h" diff --git a/regressions/ck_rwcohort/validate/ck_rp.c b/regressions/ck_rwcohort/validate/ck_rp.c deleted file mode 100644 index d63e9d515408..000000000000 --- a/regressions/ck_rwcohort/validate/ck_rp.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_rp.h" -#include "validate.h" diff --git a/regressions/ck_rwcohort/validate/ck_wp.c b/regressions/ck_rwcohort/validate/ck_wp.c deleted file mode 100644 index f89be35ac562..000000000000 --- a/regressions/ck_rwcohort/validate/ck_wp.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_wp.h" -#include "validate.h" diff --git a/regressions/ck_rwcohort/validate/validate.h b/regressions/ck_rwcohort/validate/validate.h deleted file mode 100644 index 8bc9a887f28f..000000000000 --- a/regressions/ck_rwcohort/validate/validate.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * Copything 2013 Brendon Scheinman. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - - -static struct affinity a; -static unsigned int locked; -static int nthr; -static ck_spinlock_fas_t global_fas_lock = CK_SPINLOCK_FAS_INITIALIZER; - -static void -ck_spinlock_fas_lock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_lock(lock); -} - -static void -ck_spinlock_fas_unlock_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - ck_spinlock_fas_unlock(lock); -} - -static bool -ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) -{ - (void)context; - return ck_spinlock_fas_locked(lock); -} - -CK_COHORT_PROTOTYPE(fas_fas, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, - ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -LOCK_PROTOTYPE(fas_fas) - -static CK_COHORT_INSTANCE(fas_fas) *cohorts; -static LOCK_INSTANCE(fas_fas) rw_cohort = LOCK_INITIALIZER; -static int n_cohorts; - -static void * -thread(void *null CK_CC_UNUSED) -{ - int i = ITERATE; - unsigned int l; - unsigned int core; - CK_COHORT_INSTANCE(fas_fas) *cohort; - - if (aff_iterate_core(&a, &core)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - cohort = cohorts + (core / (int)(a.delta)) % n_cohorts; - - while (i--) { - WRITE_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - WRITE_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - - READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - READ_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - int threads_per_cohort; - ck_spinlock_fas_t *local_lock; - int i; - - if (argc != 4) { - ck_error("Usage: validate \n"); - } - - n_cohorts = atoi(argv[1]); - if (n_cohorts <= 0) { - ck_error("ERROR: Number of cohorts must be greater than 0\n"); - } - - threads_per_cohort = atoi(argv[2]); - if (threads_per_cohort <= 0) { - ck_error("ERROR: Threads per cohort must be greater than 0\n"); - } - - nthr = n_cohorts * threads_per_cohort; - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[3]); - - fprintf(stderr, "Creating cohorts..."); - cohorts = malloc(sizeof(CK_COHORT_INSTANCE(fas_fas)) * n_cohorts); - if (cohorts == NULL) { - ck_error("ERROR: Could not allocate base cohort structures\n"); - } - for (i = 0 ; i < n_cohorts ; i++) { - local_lock = malloc(sizeof(ck_spinlock_fas_t)); - CK_COHORT_INIT(fas_fas, cohorts + i, &global_fas_lock, local_lock, - CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Creating threads..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_rwlock/benchmark/Makefile b/regressions/ck_rwlock/benchmark/Makefile deleted file mode 100644 index ed635040032f..000000000000 --- a/regressions/ck_rwlock/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o latency latency.c - -throughput: throughput.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o throughput throughput.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/benchmark/latency.c b/regressions/ck_rwlock/benchmark/latency.c deleted file mode 100644 index 18213c6f6648..000000000000 --- a/regressions/ck_rwlock/benchmark/latency.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include "../../common.h" - -#define CK_F_PR_RTM - -#ifndef STEPS -#define STEPS 2000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_rwlock_t rwlock = CK_RWLOCK_INITIALIZER; - - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&rwlock); - ck_rwlock_write_unlock(&rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_write_lock(&rwlock); - ck_rwlock_write_unlock(&rwlock); - } - e_b = rdtsc(); - printf(" WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - -#ifdef CK_F_PR_RTM - struct ck_elide_config config = CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; - struct ck_elide_stat st = CK_ELIDE_STAT_INITIALIZER; - - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK(ck_rwlock_write, &rwlock); - CK_ELIDE_UNLOCK(ck_rwlock_write, &rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK(ck_rwlock_write, &rwlock); - CK_ELIDE_UNLOCK(ck_rwlock_write, &rwlock); - } - e_b = rdtsc(); - printf(" (rtm) WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_write, &st, &config, &rwlock); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_write, &st, &rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_write, &st, &config, &rwlock); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_write, &st, &rwlock); - } - e_b = rdtsc(); - printf(" (rtm-adaptive) WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); -#endif /* CK_F_PR_RTM */ - - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&rwlock); - ck_rwlock_read_unlock(&rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_rwlock_read_lock(&rwlock); - ck_rwlock_read_unlock(&rwlock); - } - e_b = rdtsc(); - printf(" READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - -#ifdef CK_F_PR_RTM - ck_elide_stat_init(&st); - - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK(ck_rwlock_read, &rwlock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK(ck_rwlock_read, &rwlock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rwlock); - } - e_b = rdtsc(); - printf(" (rtm) READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_read, &st, &config, &rwlock); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_read, &st, &rwlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_read, &st, &config, &rwlock); - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_read, &st, &rwlock); - } - e_b = rdtsc(); - printf(" (rtm-adaptive) READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); -#endif /* CK_F_PR_RTM */ - - return 0; -} - diff --git a/regressions/ck_rwlock/benchmark/throughput.c b/regressions/ck_rwlock/benchmark/throughput.c deleted file mode 100644 index f57fbd81af4c..000000000000 --- a/regressions/ck_rwlock/benchmark/throughput.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static int barrier; -static int threads; -static unsigned int flag CK_CC_CACHELINE; -static struct { - ck_rwlock_t lock; -} rw CK_CC_CACHELINE = { - .lock = CK_RWLOCK_INITIALIZER -}; - -static struct affinity affinity; - -#ifdef CK_F_PR_RTM -static void * -thread_lock_rtm(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_LOCK(ck_rwlock_read, &rw.lock); - CK_ELIDE_UNLOCK(ck_rwlock_read, &rw.lock); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} -#endif /* CK_F_PR_RTM */ - -static void * -thread_lock(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - ck_rwlock_read_lock(&rw.lock); - ck_rwlock_read_unlock(&rw.lock); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -static void -rwlock_test(pthread_t *p, int d, uint64_t *latency, void *(*f)(void *), const char *label) -{ - int t; - - ck_pr_store_int(&barrier, 0); - ck_pr_store_uint(&flag, 0); - - affinity.delta = d; - affinity.request = 0; - - fprintf(stderr, "Creating threads (%s)...", label); - for (t = 0; t < threads; t++) { - if (pthread_create(&p[t], NULL, f, latency + t) != 0) { - ck_error("ERROR: Could not create thread %d\n", t); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (t = 0; t < threads; t++) - pthread_join(p[t], NULL); - fprintf(stderr, "done\n\n"); - - for (t = 1; t <= threads; t++) - printf("%10u %20" PRIu64 "\n", t, latency[t - 1]); - - fprintf(stderr, "\n"); - return; -} - - -int -main(int argc, char *argv[]) -{ - int d; - pthread_t *p; - uint64_t *latency; - - if (argc != 3) { - ck_error("Usage: throughput \n"); - } - - threads = atoi(argv[2]); - if (threads <= 0) { - ck_error("ERROR: Threads must be a value > 0.\n"); - } - - p = malloc(sizeof(pthread_t) * threads); - if (p == NULL) { - ck_error("ERROR: Failed to initialize thread.\n"); - } - - latency = malloc(sizeof(uint64_t) * threads); - if (latency == NULL) { - ck_error("ERROR: Failed to create latency buffer.\n"); - } - - d = atoi(argv[1]); - rwlock_test(p, d, latency, thread_lock, "rwlock"); - -#ifdef CK_F_PR_RTM - rwlock_test(p, d, latency, thread_lock_rtm, "rwlock, rtm"); -#endif /* CK_F_PR_RTM */ - - return 0; -} - diff --git a/regressions/ck_rwlock/validate/Makefile b/regressions/ck_rwlock/validate/Makefile deleted file mode 100644 index 2c2116bd347c..000000000000 --- a/regressions/ck_rwlock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_rwlock/validate/validate.c b/regressions/ck_rwlock/validate/validate.c deleted file mode 100644 index 8a32e0856f28..000000000000 --- a/regressions/ck_rwlock/validate/validate.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked; -static unsigned int tid = 2; -static int nthr; -static ck_rwlock_t lock = CK_RWLOCK_INITIALIZER; -static ck_rwlock_recursive_t r_lock = CK_RWLOCK_RECURSIVE_INITIALIZER; - -static void * -thread_recursive(void *null CK_CC_UNUSED) -{ - int i = ITERATE; - unsigned int l; - unsigned int t = ck_pr_faa_uint(&tid, 1); - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - while (ck_rwlock_recursive_write_trylock(&r_lock, t) == false) - ck_pr_stall(); - - ck_rwlock_recursive_write_lock(&r_lock, t); - ck_rwlock_recursive_write_lock(&r_lock, t); - ck_rwlock_recursive_write_lock(&r_lock, t); - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_rwlock_recursive_write_unlock(&r_lock); - ck_rwlock_recursive_write_unlock(&r_lock); - ck_rwlock_recursive_write_unlock(&r_lock); - ck_rwlock_recursive_write_unlock(&r_lock); - - ck_rwlock_recursive_read_lock(&r_lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_rwlock_recursive_read_unlock(&r_lock); - } - - return (NULL); -} - -#ifdef CK_F_PR_RTM -static void * -thread_rtm_adaptive(void *null CK_CC_UNUSED) -{ - unsigned int i = ITERATE; - unsigned int l; - struct ck_elide_config config = CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; - struct ck_elide_stat st = CK_ELIDE_STAT_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - CK_ELIDE_LOCK_ADAPTIVE(ck_rwlock_write, &st, &config, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK_ADAPTIVE(ck_rwlock_write, &st, &lock); - - CK_ELIDE_LOCK(ck_rwlock_read, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_rwlock_read, &lock); - } - - return NULL; -} - -static void * -thread_rtm_mix(void *null CK_CC_UNUSED) -{ - unsigned int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (i & 1) { - CK_ELIDE_LOCK(ck_rwlock_write, &lock); - } else { - ck_rwlock_write_lock(&lock); - } - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - - if (i & 1) { - CK_ELIDE_UNLOCK(ck_rwlock_write, &lock); - } else { - ck_rwlock_write_unlock(&lock); - } - - if (i & 1) { - CK_ELIDE_LOCK(ck_rwlock_read, &lock); - } else { - ck_rwlock_read_lock(&lock); - } - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - - if (i & 1) { - CK_ELIDE_UNLOCK(ck_rwlock_read, &lock); - } else { - ck_rwlock_read_unlock(&lock); - } - } - - return (NULL); -} - -static void * -thread_rtm(void *null CK_CC_UNUSED) -{ - unsigned int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - CK_ELIDE_LOCK(ck_rwlock_write, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_rwlock_write, &lock); - - CK_ELIDE_LOCK(ck_rwlock_read, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_rwlock_read, &lock); - } - - return (NULL); -} -#endif /* CK_F_PR_RTM */ - -static void * -thread(void *null CK_CC_UNUSED) -{ - unsigned int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - ck_rwlock_write_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_rwlock_write_unlock(&lock); - - ck_rwlock_read_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_rwlock_read_unlock(&lock); - } - - return (NULL); -} - -static void -rwlock_test(pthread_t *threads, void *(*f)(void *), const char *test) -{ - int i; - - fprintf(stderr, "Creating threads (%s)...", test); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, f, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "."); - - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - return; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - - if (argc != 3) { - ck_error("Usage: validate \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - rwlock_test(threads, thread, "regular"); -#ifdef CK_F_PR_RTM - rwlock_test(threads, thread_rtm, "rtm"); - rwlock_test(threads, thread_rtm_mix, "rtm-mix"); - rwlock_test(threads, thread_rtm_adaptive, "rtm-adaptive"); -#endif - rwlock_test(threads, thread_recursive, "recursive"); - return 0; -} - diff --git a/regressions/ck_sequence/benchmark/Makefile b/regressions/ck_sequence/benchmark/Makefile deleted file mode 100644 index 5803a4d29ea6..000000000000 --- a/regressions/ck_sequence/benchmark/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=ck_sequence - -all: $(OBJECTS) - -ck_sequence: ck_sequence.c ../../../include/ck_sequence.h - $(CC) $(CFLAGS) -o ck_sequence ck_sequence.c - -check: all - ./ck_sequence $(CORES) 1 - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=-D_GNU_SOURCE - diff --git a/regressions/ck_sequence/benchmark/ck_sequence.c b/regressions/ck_sequence/benchmark/ck_sequence.c deleted file mode 100644 index f720c31d8b1f..000000000000 --- a/regressions/ck_sequence/benchmark/ck_sequence.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS (65536 * 64) -#endif - -static ck_sequence_t seqlock CK_CC_CACHELINE = CK_SEQUENCE_INITIALIZER; - -int -main(void) -{ - unsigned int i = 0; - unsigned int version; - uint64_t a, s; - - /* Read-side latency. */ - a = 0; - for (i = 0; i < STEPS / 4; i++) { - s = rdtsc(); - ck_sequence_read_retry(&seqlock, ck_sequence_read_begin(&seqlock)); - ck_sequence_read_retry(&seqlock, ck_sequence_read_begin(&seqlock)); - ck_sequence_read_retry(&seqlock, ck_sequence_read_begin(&seqlock)); - ck_sequence_read_retry(&seqlock, ck_sequence_read_begin(&seqlock)); - a += rdtsc() - s; - } - printf("read: %" PRIu64 "\n", a / STEPS); - - a = 0; - for (i = 0; i < STEPS / 4; i++) { - s = rdtsc(); - CK_SEQUENCE_READ(&seqlock, &version); - CK_SEQUENCE_READ(&seqlock, &version); - CK_SEQUENCE_READ(&seqlock, &version); - CK_SEQUENCE_READ(&seqlock, &version); - a += rdtsc() - s; - } - printf("READ %" PRIu64 "\n", a / STEPS); - - /* Write-side latency. */ - a = 0; - for (i = 0; i < STEPS / 4; i++) { - s = rdtsc(); - ck_sequence_write_begin(&seqlock); - ck_sequence_write_end(&seqlock); - ck_sequence_write_begin(&seqlock); - ck_sequence_write_end(&seqlock); - ck_sequence_write_begin(&seqlock); - ck_sequence_write_end(&seqlock); - ck_sequence_write_begin(&seqlock); - ck_sequence_write_end(&seqlock); - a += rdtsc() - s; - } - printf("write: %" PRIu64 "\n", a / STEPS); - - return 0; -} - diff --git a/regressions/ck_sequence/validate/Makefile b/regressions/ck_sequence/validate/Makefile deleted file mode 100644 index bc2e5be4bd8c..000000000000 --- a/regressions/ck_sequence/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=ck_sequence - -all: $(OBJECTS) - -ck_sequence: ck_sequence.c ../../../include/ck_sequence.h - $(CC) $(CFLAGS) -o ck_sequence ck_sequence.c - -check: all - ./ck_sequence $(CORES) 1 - -clean: - rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_sequence/validate/ck_sequence.c b/regressions/ck_sequence/validate/ck_sequence.c deleted file mode 100644 index e0bc700924cc..000000000000 --- a/regressions/ck_sequence/validate/ck_sequence.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -struct example { - unsigned int a; - unsigned int b; - unsigned int c; -}; - -static struct example global CK_CC_CACHELINE; -static ck_sequence_t seqlock CK_CC_CACHELINE = CK_SEQUENCE_INITIALIZER; -static unsigned int barrier; -static struct affinity affinerator; - -static void -validate(struct example *copy) -{ - - if (copy->b != copy->a + 1000) { - ck_error("ERROR: Failed regression: copy->b (%u != %u + %u / %u)\n", - copy->b, copy->a, 1000, copy->a + 1000); - } - - if (copy->c != copy->a + copy->b) { - ck_error("ERROR: Failed regression: copy->c (%u != %u + %u / %u)\n", - copy->c, copy->a, copy->b, copy->a + copy->b); - } - - return; -} - -static void * -consumer(void *unused CK_CC_UNUSED) -{ - struct example copy; - uint32_t version; - unsigned int retries = 0; - unsigned int i; - - unused = NULL; - if (aff_iterate(&affinerator)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (ck_pr_load_uint(&barrier) == 0); - for (i = 0; i < STEPS; i++) { - /* - * Attempt a read of the data structure. If the structure - * has been modified between ck_sequence_read_begin and - * ck_sequence_read_retry then attempt another read since - * the data may be in an inconsistent state. - */ - do { - version = ck_sequence_read_begin(&seqlock); - copy.a = ck_pr_load_uint(&global.a); - copy.b = ck_pr_load_uint(&global.b); - copy.c = ck_pr_load_uint(&global.c); - retries++; - } while (ck_sequence_read_retry(&seqlock, version) == true); - validate(©); - - CK_SEQUENCE_READ(&seqlock, &version) { - copy.a = ck_pr_load_uint(&global.a); - copy.b = ck_pr_load_uint(&global.b); - copy.c = ck_pr_load_uint(&global.c); - retries++; - } - validate(©); - } - - fprintf(stderr, "%u retries.\n", retries - STEPS); - ck_pr_dec_uint(&barrier); - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - unsigned int counter = 0; - bool first = true; - int n_threads, i; - - if (argc != 3) { - ck_error("Usage: ck_sequence \n"); - } - - n_threads = atoi(argv[1]); - if (n_threads <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * n_threads); - if (threads == NULL) { - ck_error("ERROR: Could not allocate memory for threads\n"); - } - - affinerator.delta = atoi(argv[2]); - affinerator.request = 0; - - for (i = 0; i < n_threads; i++) { - if (pthread_create(&threads[i], NULL, consumer, NULL)) { - ck_error("ERROR: Failed to create thread %d\n", i); - } - } - - for (;;) { - /* - * Update the shared data in a non-blocking fashion. - * If the data is modified by multiple writers then - * ck_sequence_write_begin must be called after acquiring - * the associated lock and ck_sequence_write_end must be - * called before relinquishing the lock. - */ - ck_sequence_write_begin(&seqlock); - global.a = counter++; - global.b = global.a + 1000; - global.c = global.b + global.a; - ck_sequence_write_end(&seqlock); - - if (first == true) { - ck_pr_store_uint(&barrier, n_threads); - first = false; - } - - counter++; - if (ck_pr_load_uint(&barrier) == 0) - break; - } - - printf("%u updates made.\n", counter); - return (0); -} - diff --git a/regressions/ck_spinlock/benchmark/Makefile b/regressions/ck_spinlock/benchmark/Makefile deleted file mode 100644 index ca3e1cf20380..000000000000 --- a/regressions/ck_spinlock/benchmark/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -.PHONY: all clean - -OBJECTS=ck_ticket.THROUGHPUT ck_ticket.LATENCY \ - ck_mcs.THROUGHPUT ck_mcs.LATENCY \ - ck_dec.THROUGHPUT ck_dec.LATENCY \ - ck_cas.THROUGHPUT ck_cas.LATENCY \ - ck_fas.THROUGHPUT ck_fas.LATENCY \ - ck_clh.THROUGHPUT ck_clh.LATENCY \ - linux_spinlock.THROUGHPUT linux_spinlock.LATENCY \ - ck_ticket_pb.THROUGHPUT ck_ticket_pb.LATENCY \ - ck_anderson.THROUGHPUT ck_anderson.LATENCY \ - ck_spinlock.THROUGHPUT ck_spinlock.LATENCY \ - ck_hclh.THROUGHPUT ck_hclh.LATENCY - -all: $(OBJECTS) - -ck_spinlock.THROUGHPUT: ck_spinlock.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_spinlock.THROUGHPUT ck_spinlock.c -lm - -ck_spinlock.LATENCY: ck_spinlock.c - $(CC) -DLATENCY $(CFLAGS) -o ck_spinlock.LATENCY ck_spinlock.c -lm - -ck_ticket.THROUGHPUT: ck_ticket.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_ticket.THROUGHPUT ck_ticket.c -lm - -ck_ticket.LATENCY: ck_ticket.c - $(CC) -DLATENCY $(CFLAGS) -o ck_ticket.LATENCY ck_ticket.c -lm - -ck_mcs.THROUGHPUT: ck_mcs.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_mcs.THROUGHPUT ck_mcs.c -lm - -ck_mcs.LATENCY: ck_mcs.c - $(CC) -DLATENCY $(CFLAGS) -o ck_mcs.LATENCY ck_mcs.c -lm - -ck_dec.THROUGHPUT: ck_dec.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_dec.THROUGHPUT ck_dec.c -lm - -ck_dec.LATENCY: ck_dec.c - $(CC) -DLATENCY $(CFLAGS) -o ck_dec.LATENCY ck_dec.c -lm - -ck_cas.THROUGHPUT: ck_cas.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_cas.THROUGHPUT ck_cas.c -lm - -ck_cas.LATENCY: ck_cas.c - $(CC) -DLATENCY $(CFLAGS) -o ck_cas.LATENCY ck_cas.c -lm - -ck_fas.THROUGHPUT: ck_fas.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_fas.THROUGHPUT ck_fas.c -lm - -ck_fas.LATENCY: ck_fas.c - $(CC) -DLATENCY $(CFLAGS) -o ck_fas.LATENCY ck_fas.c -lm - -ck_clh.THROUGHPUT: ck_clh.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_clh.THROUGHPUT ck_clh.c -lm - -ck_clh.LATENCY: ck_clh.c - $(CC) -DLATENCY $(CFLAGS) -o ck_clh.LATENCY ck_clh.c -lm - -ck_hclh.THROUGHPUT: ck_hclh.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_hclh.THROUGHPUT ck_hclh.c -lm - -ck_hclh.LATENCY: ck_hclh.c - $(CC) -DLATENCY $(CFLAGS) -o ck_hclh.LATENCY ck_hclh.c -lm - -linux_spinlock.THROUGHPUT: linux_spinlock.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o linux_spinlock.THROUGHPUT linux_spinlock.c -lm - -linux_spinlock.LATENCY: linux_spinlock.c - $(CC) -DLATENCY $(CFLAGS) -o linux_spinlock.LATENCY linux_spinlock.c -lm - -ck_ticket_pb.THROUGHPUT: ck_ticket_pb.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_ticket_pb.THROUGHPUT ck_ticket_pb.c -lm - -ck_ticket_pb.LATENCY: ck_ticket_pb.c - $(CC) -DLATENCY $(CFLAGS) -o ck_ticket_pb.LATENCY ck_ticket_pb.c -lm - -ck_anderson.THROUGHPUT: ck_anderson.c - $(CC) -DTHROUGHPUT $(CFLAGS) -o ck_anderson.THROUGHPUT ck_anderson.c -lm - -ck_anderson.LATENCY: ck_anderson.c - $(CC) -DLATENCY $(CFLAGS) -o ck_anderson.LATENCY ck_anderson.c -lm - -clean: - rm -rf *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_spinlock/benchmark/ck_anderson.c b/regressions/ck_spinlock/benchmark/ck_anderson.c deleted file mode 100644 index 2f1aecdcefa4..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_anderson.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../ck_anderson.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif - diff --git a/regressions/ck_spinlock/benchmark/ck_cas.c b/regressions/ck_spinlock/benchmark/ck_cas.c deleted file mode 100644 index 96bd9d898895..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_cas.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../ck_cas.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif - diff --git a/regressions/ck_spinlock/benchmark/ck_clh.c b/regressions/ck_spinlock/benchmark/ck_clh.c deleted file mode 100644 index da71d5e30fcd..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_clh.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_clh.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_dec.c b/regressions/ck_spinlock/benchmark/ck_dec.c deleted file mode 100644 index 115c116e3ba5..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_dec.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_dec.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_fas.c b/regressions/ck_spinlock/benchmark/ck_fas.c deleted file mode 100644 index c76c96473db7..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_fas.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_fas.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_hclh.c b/regressions/ck_spinlock/benchmark/ck_hclh.c deleted file mode 100644 index 9ae443e8498c..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_hclh.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_hclh.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_mcs.c b/regressions/ck_spinlock/benchmark/ck_mcs.c deleted file mode 100644 index c2e95ded5ca6..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_mcs.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_mcs.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_spinlock.c b/regressions/ck_spinlock/benchmark/ck_spinlock.c deleted file mode 100644 index 138541e9f3e3..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_spinlock.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_spinlock.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/ck_ticket.c b/regressions/ck_spinlock/benchmark/ck_ticket.c deleted file mode 100644 index 09c9193a07b5..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_ticket.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "../ck_ticket.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif - diff --git a/regressions/ck_spinlock/benchmark/ck_ticket_pb.c b/regressions/ck_spinlock/benchmark/ck_ticket_pb.c deleted file mode 100644 index 6122d6a88063..000000000000 --- a/regressions/ck_spinlock/benchmark/ck_ticket_pb.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../ck_ticket_pb.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/latency.h b/regressions/ck_spinlock/benchmark/latency.h deleted file mode 100644 index afadcd248882..000000000000 --- a/regressions/ck_spinlock/benchmark/latency.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * Copyright 2011 David Joseph. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 30000000 -#endif - -LOCK_DEFINE; - -int -main(void) -{ - CK_CC_UNUSED unsigned int nthr = 1; - - #ifdef LOCK_INIT - LOCK_INIT; - #endif - - #ifdef LOCK_STATE - LOCK_STATE; - #endif - - uint64_t s_b, e_b, i; - CK_CC_UNUSED int core = 0; - - s_b = rdtsc(); - for (i = 0; i < STEPS; ++i) { - #ifdef LOCK - LOCK; - UNLOCK; - LOCK; - UNLOCK; - LOCK; - UNLOCK; - LOCK; - UNLOCK; - #endif - } - e_b = rdtsc(); - printf("%15" PRIu64 "\n", (e_b - s_b) / 4 / STEPS); - - return (0); -} - diff --git a/regressions/ck_spinlock/benchmark/linux_spinlock.c b/regressions/ck_spinlock/benchmark/linux_spinlock.c deleted file mode 100644 index 954019bee930..000000000000 --- a/regressions/ck_spinlock/benchmark/linux_spinlock.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "../linux_spinlock.h" - -#ifdef THROUGHPUT -#include "throughput.h" -#elif defined(LATENCY) -#include "latency.h" -#endif diff --git a/regressions/ck_spinlock/benchmark/throughput.h b/regressions/ck_spinlock/benchmark/throughput.h deleted file mode 100644 index 7851c50cfe51..000000000000 --- a/regressions/ck_spinlock/benchmark/throughput.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2008-2012 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -/* 8! = 40320, evenly divide 1 .. 8 processor workload. */ -#define WORKLOAD (40320 * 2056) - -#ifndef ITERATE -#define ITERATE 65536 -#endif - -struct block { - unsigned int tid; -}; - -static struct affinity a; -static unsigned int ready; - -struct counters { - uint64_t value; -} CK_CC_CACHELINE; - -static struct counters *count; -static uint64_t nthr; -static unsigned int barrier; - -int critical __attribute__((aligned(64))); - -LOCK_DEFINE; - -CK_CC_USED static void -gen_lock(void) -{ - CK_CC_UNUSED int core = 0; -#ifdef LOCK_STATE - LOCK_STATE; -#endif - -#ifdef LOCK - LOCK; -#endif -} - -CK_CC_USED static void -gen_unlock(void) -{ -#ifdef LOCK_STATE - LOCK_STATE; -#endif - -#ifdef UNLOCK - UNLOCK; -#endif -} - -static void * -fairness(void *null) -{ -#ifdef LOCK_STATE - LOCK_STATE; -#endif - struct block *context = null; - unsigned int i = context->tid; - volatile int j; - long int base; - unsigned int core; - - if (aff_iterate_core(&a, &core)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (ck_pr_load_uint(&ready) == 0); - - ck_pr_inc_uint(&barrier); - while (ck_pr_load_uint(&barrier) != nthr); - - while (ready) { - LOCK; - - count[i].value++; - if (critical) { - base = common_lrand48() % critical; - for (j = 0; j < base; j++); - } - - UNLOCK; - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - uint64_t v, d; - unsigned int i; - pthread_t *threads; - struct block *context; - - if (argc != 4) { - ck_error("Usage: " LOCK_NAME " \n"); - exit(EXIT_FAILURE); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - exit(EXIT_FAILURE); - } - -#ifdef LOCK_INIT - LOCK_INIT; -#endif - - critical = atoi(argv[3]); - if (critical < 0) { - ck_error("ERROR: critical section cannot be negative\n"); - exit(EXIT_FAILURE); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - exit(EXIT_FAILURE); - } - - context = malloc(sizeof(struct block) * nthr); - if (context == NULL) { - ck_error("ERROR: Could not allocate thread contexts\n"); - exit(EXIT_FAILURE); - } - - a.delta = atoi(argv[2]); - a.request = 0; - - count = malloc(sizeof(*count) * nthr); - if (count == NULL) { - ck_error("ERROR: Could not create acquisition buffer\n"); - exit(EXIT_FAILURE); - } - memset(count, 0, sizeof(*count) * nthr); - - fprintf(stderr, "Creating threads (fairness)..."); - for (i = 0; i < nthr; i++) { - context[i].tid = i; - if (pthread_create(&threads[i], NULL, fairness, context + i)) { - ck_error("ERROR: Could not create thread %d\n", i); - exit(EXIT_FAILURE); - } - } - fprintf(stderr, "done\n"); - - ck_pr_store_uint(&ready, 1); - common_sleep(10); - ck_pr_store_uint(&ready, 0); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done\n\n"); - - for (i = 0, v = 0; i < nthr; i++) { - printf("%d %15" PRIu64 "\n", i, count[i].value); - v += count[i].value; - } - - printf("\n# total : %15" PRIu64 "\n", v); - printf("# throughput : %15" PRIu64 " a/s\n", (v /= nthr) / 10); - - for (i = 0, d = 0; i < nthr; i++) - d += (count[i].value - v) * (count[i].value - v); - - printf("# average : %15" PRIu64 "\n", v); - printf("# deviation : %.2f (%.2f%%)\n\n", sqrt(d / nthr), (sqrt(d / nthr) / v) * 100.00); - - return (0); -} - diff --git a/regressions/ck_spinlock/ck_anderson.h b/regressions/ck_spinlock/ck_anderson.h deleted file mode 100644 index 7dc8e6eac3fe..000000000000 --- a/regressions/ck_spinlock/ck_anderson.h +++ /dev/null @@ -1,11 +0,0 @@ -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define LOCK_NAME "ck_anderson" -#define LOCK_DEFINE static ck_spinlock_anderson_t lock CK_CC_CACHELINE -#define LOCK_STATE ck_spinlock_anderson_thread_t *nad = NULL -#define LOCK ck_spinlock_anderson_lock(&lock, &nad) -#define UNLOCK ck_spinlock_anderson_unlock(&lock, nad) -#define LOCK_INIT ck_spinlock_anderson_init(&lock, malloc(MAX(64,sizeof(ck_spinlock_anderson_thread_t)) * nthr), nthr) -#define LOCKED ck_spinlock_anderson_locked(&lock) - -#define NO_LOCAL - diff --git a/regressions/ck_spinlock/ck_cas.h b/regressions/ck_spinlock/ck_cas.h deleted file mode 100644 index bd4ae13253de..000000000000 --- a/regressions/ck_spinlock/ck_cas.h +++ /dev/null @@ -1,6 +0,0 @@ -#define LOCK_NAME "ck_cas" -#define LOCK_DEFINE static ck_spinlock_cas_t CK_CC_CACHELINE lock = CK_SPINLOCK_CAS_INITIALIZER -#define LOCK ck_spinlock_cas_lock_eb(&lock) -#define UNLOCK ck_spinlock_cas_unlock(&lock) -#define LOCKED ck_spinlock_cas_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_clh.h b/regressions/ck_spinlock/ck_clh.h deleted file mode 100644 index df7e49fbbdc3..000000000000 --- a/regressions/ck_spinlock/ck_clh.h +++ /dev/null @@ -1,9 +0,0 @@ -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define LOCK_NAME "ck_clh" -#define LOCK_DEFINE static ck_spinlock_clh_t CK_CC_CACHELINE *lock = NULL -#define LOCK_STATE ck_spinlock_clh_t *na = malloc(MAX(sizeof(ck_spinlock_clh_t), 64)) -#define LOCK ck_spinlock_clh_lock(&lock, na) -#define UNLOCK ck_spinlock_clh_unlock(&na) -#define LOCK_INIT ck_spinlock_clh_init(&lock, malloc(MAX(sizeof(ck_spinlock_clh_t), 64))) -#define LOCKED ck_spinlock_clh_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_dec.h b/regressions/ck_spinlock/ck_dec.h deleted file mode 100644 index c21a39010d79..000000000000 --- a/regressions/ck_spinlock/ck_dec.h +++ /dev/null @@ -1,6 +0,0 @@ -#define LOCK_NAME "ck_dec" -#define LOCK_DEFINE static ck_spinlock_dec_t CK_CC_CACHELINE lock = CK_SPINLOCK_DEC_INITIALIZER -#define LOCK ck_spinlock_dec_lock_eb(&lock) -#define UNLOCK ck_spinlock_dec_unlock(&lock) -#define LOCKED ck_spinlock_dec_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_fas.h b/regressions/ck_spinlock/ck_fas.h deleted file mode 100644 index e2447464eed5..000000000000 --- a/regressions/ck_spinlock/ck_fas.h +++ /dev/null @@ -1,6 +0,0 @@ -#define LOCK_NAME "ck_fas" -#define LOCK_DEFINE static ck_spinlock_fas_t CK_CC_CACHELINE lock = CK_SPINLOCK_FAS_INITIALIZER -#define LOCK ck_spinlock_fas_lock_eb(&lock) -#define UNLOCK ck_spinlock_fas_unlock(&lock) -#define LOCKED ck_spinlock_fas_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_hclh.h b/regressions/ck_spinlock/ck_hclh.h deleted file mode 100644 index eb2e6eb7a201..000000000000 --- a/regressions/ck_spinlock/ck_hclh.h +++ /dev/null @@ -1,16 +0,0 @@ -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define LOCK_NAME "ck_clh" -#define LOCK_DEFINE static ck_spinlock_hclh_t CK_CC_CACHELINE *glob_lock; \ - static ck_spinlock_hclh_t CK_CC_CACHELINE *local_lock[CORES / 2] -#define LOCK_STATE ck_spinlock_hclh_t *na = malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)) -#define LOCK ck_spinlock_hclh_lock(&glob_lock, &local_lock[(core % CORES) / 2], na) -#define UNLOCK ck_spinlock_hclh_unlock(&na) -#define LOCK_INIT do { \ - int _i; \ - ck_spinlock_hclh_init(&glob_lock, malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), -1); \ - for (_i = 0; _i < CORES / 2; _i++) { \ - ck_spinlock_hclh_init(&local_lock[_i], malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), _i); } \ -} while (0) - -#define LOCKED ck_spinlock_hclh_locked(&glob_lock) - diff --git a/regressions/ck_spinlock/ck_mcs.h b/regressions/ck_spinlock/ck_mcs.h deleted file mode 100644 index dd127dfea6bc..000000000000 --- a/regressions/ck_spinlock/ck_mcs.h +++ /dev/null @@ -1,7 +0,0 @@ -#define LOCK_NAME "ck_mcs" -#define LOCK_DEFINE static ck_spinlock_mcs_t CK_CC_CACHELINE lock = NULL -#define LOCK_STATE ck_spinlock_mcs_context_t node CK_CC_CACHELINE; -#define LOCK ck_spinlock_mcs_lock(&lock, &node) -#define UNLOCK ck_spinlock_mcs_unlock(&lock, &node) -#define LOCKED ck_spinlock_mcs_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_spinlock.h b/regressions/ck_spinlock/ck_spinlock.h deleted file mode 100644 index 938e1ce4f8e7..000000000000 --- a/regressions/ck_spinlock/ck_spinlock.h +++ /dev/null @@ -1,6 +0,0 @@ -#define LOCK_NAME "ck_spinlock" -#define LOCK_DEFINE static ck_spinlock_t CK_CC_CACHELINE lock = CK_SPINLOCK_INITIALIZER -#define LOCK ck_spinlock_lock_eb(&lock) -#define UNLOCK ck_spinlock_unlock(&lock) -#define LOCKED ck_spinlock_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_ticket.h b/regressions/ck_spinlock/ck_ticket.h deleted file mode 100644 index 39054a697977..000000000000 --- a/regressions/ck_spinlock/ck_ticket.h +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#define LOCK_NAME "ck_ticket" -#define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER -#define LOCK ck_spinlock_ticket_lock(&lock) -#define UNLOCK ck_spinlock_ticket_unlock(&lock) -#ifdef CK_F_SPINLOCK_TICKET_TRYLOCK -#define TRYLOCK ck_spinlock_ticket_trylock(&lock) -#endif -#define LOCKED ck_spinlock_ticket_locked(&lock) - diff --git a/regressions/ck_spinlock/ck_ticket_pb.h b/regressions/ck_spinlock/ck_ticket_pb.h deleted file mode 100644 index b8a7a84ea1f9..000000000000 --- a/regressions/ck_spinlock/ck_ticket_pb.h +++ /dev/null @@ -1,6 +0,0 @@ -#define LOCK_NAME "ck_ticket_pb" -#define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER -#define LOCK ck_spinlock_ticket_lock_pb(&lock, 0) -#define UNLOCK ck_spinlock_ticket_unlock(&lock) -#define LOCKED ck_spinlock_ticket_locked(&lock) - diff --git a/regressions/ck_spinlock/linux_spinlock.h b/regressions/ck_spinlock/linux_spinlock.h deleted file mode 100644 index 5fe1f3e21ef7..000000000000 --- a/regressions/ck_spinlock/linux_spinlock.h +++ /dev/null @@ -1,39 +0,0 @@ -#include - -CK_CC_INLINE static void -spin_lock(volatile unsigned int *lock) -{ -#ifdef __x86_64__ - __asm__ __volatile__( - "\n1:\t" - "lock ; decl %0\n\t" - "jns 2f\n" - "3:\n" - "rep;nop\n\t" - "cmpl $0,%0\n\t" - "jle 3b\n\t" - "jmp 1b\n" - "2:\t" : "=m" (*lock) : : "memory"); -#else - *lock = 1; -#endif - - return; -} - -CK_CC_INLINE static void -spin_unlock(volatile unsigned int *lock) -{ -#ifdef __x86_64__ - __asm__ __volatile__("movl $1,%0" :"=m" (*lock) :: "memory"); -#else - *lock = 0; - return; -#endif -} - -#define LOCK_NAME "linux_spinlock" -#define LOCK_DEFINE volatile unsigned int lock = 1 -#define LOCK spin_lock(&lock) -#define UNLOCK spin_unlock(&lock) - diff --git a/regressions/ck_spinlock/validate/Makefile b/regressions/ck_spinlock/validate/Makefile deleted file mode 100644 index b1d7cba1f7c9..000000000000 --- a/regressions/ck_spinlock/validate/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -.PHONY: check clean - -all: ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock \ - ck_ticket_pb ck_anderson ck_spinlock ck_hclh - -check: all - ./ck_ticket $(CORES) 1 - ./ck_mcs $(CORES) 1 - ./ck_dec $(CORES) 1 - ./ck_cas $(CORES) 1 - ./ck_fas $(CORES) 1 - ./ck_clh $(CORES) 1 - ./ck_hclh $(CORES) 1 - ./linux_spinlock $(CORES) 1 - ./ck_ticket_pb $(CORES) 1 - ./ck_anderson $(CORES) 1 - ./ck_spinlock $(CORES) 1 - -linux_spinlock: linux_spinlock.c - $(CC) $(CFLAGS) -o linux_spinlock linux_spinlock.c - -ck_spinlock: ck_spinlock.c - $(CC) $(CFLAGS) -o ck_spinlock ck_spinlock.c - -ck_ticket_pb: ck_ticket_pb.c - $(CC) $(CFLAGS) -o ck_ticket_pb ck_ticket_pb.c - -ck_clh: ck_clh.c - $(CC) $(CFLAGS) -o ck_clh ck_clh.c - -ck_hclh: ck_hclh.c - $(CC) $(CFLAGS) -o ck_hclh ck_hclh.c - -ck_anderson: ck_anderson.c - $(CC) $(CFLAGS) -o ck_anderson ck_anderson.c - -ck_fas: ck_fas.c - $(CC) $(CFLAGS) -o ck_fas ck_fas.c - -ck_ticket: ck_ticket.c - $(CC) $(CFLAGS) -o ck_ticket ck_ticket.c - -ck_cas: ck_cas.c - $(CC) $(CFLAGS) -o ck_cas ck_cas.c - -ck_mcs: ck_mcs.c - $(CC) $(CFLAGS) -o ck_mcs ck_mcs.c - -ck_dec: ck_dec.c - $(CC) $(CFLAGS) -o ck_dec ck_dec.c - -clean: - rm -rf ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock ck_ticket_pb \ - ck_anderson ck_spinlock ck_hclh *.dSYM *.exe - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE -lm diff --git a/regressions/ck_spinlock/validate/ck_anderson.c b/regressions/ck_spinlock/validate/ck_anderson.c deleted file mode 100644 index b10900ce815e..000000000000 --- a/regressions/ck_spinlock/validate/ck_anderson.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_anderson.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_cas.c b/regressions/ck_spinlock/validate/ck_cas.c deleted file mode 100644 index 162490a1eb16..000000000000 --- a/regressions/ck_spinlock/validate/ck_cas.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_cas.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_clh.c b/regressions/ck_spinlock/validate/ck_clh.c deleted file mode 100644 index 19cb512deac8..000000000000 --- a/regressions/ck_spinlock/validate/ck_clh.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_clh.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_dec.c b/regressions/ck_spinlock/validate/ck_dec.c deleted file mode 100644 index fd351de2ce68..000000000000 --- a/regressions/ck_spinlock/validate/ck_dec.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_dec.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_fas.c b/regressions/ck_spinlock/validate/ck_fas.c deleted file mode 100644 index 5cf407149aba..000000000000 --- a/regressions/ck_spinlock/validate/ck_fas.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_fas.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_hclh.c b/regressions/ck_spinlock/validate/ck_hclh.c deleted file mode 100644 index 001f57bd2782..000000000000 --- a/regressions/ck_spinlock/validate/ck_hclh.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_hclh.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_mcs.c b/regressions/ck_spinlock/validate/ck_mcs.c deleted file mode 100644 index 7adad4364407..000000000000 --- a/regressions/ck_spinlock/validate/ck_mcs.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_mcs.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_spinlock.c b/regressions/ck_spinlock/validate/ck_spinlock.c deleted file mode 100644 index e682905fee55..000000000000 --- a/regressions/ck_spinlock/validate/ck_spinlock.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_spinlock.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_ticket.c b/regressions/ck_spinlock/validate/ck_ticket.c deleted file mode 100644 index be67254eeeec..000000000000 --- a/regressions/ck_spinlock/validate/ck_ticket.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_ticket.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/ck_ticket_pb.c b/regressions/ck_spinlock/validate/ck_ticket_pb.c deleted file mode 100644 index e62ee0ec6941..000000000000 --- a/regressions/ck_spinlock/validate/ck_ticket_pb.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "../ck_ticket_pb.h" -#include "validate.h" diff --git a/regressions/ck_spinlock/validate/linux_spinlock.c b/regressions/ck_spinlock/validate/linux_spinlock.c deleted file mode 100644 index 781e419b04c2..000000000000 --- a/regressions/ck_spinlock/validate/linux_spinlock.c +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef __x86_64__ -#include "../linux_spinlock.h" -#include "validate.h" -#else -#include - -int -main(void) -{ - - fprintf(stderr, "Unsupported.\n"); - return 0; -} -#endif diff --git a/regressions/ck_spinlock/validate/validate.h b/regressions/ck_spinlock/validate/validate.h deleted file mode 100644 index df40584871a6..000000000000 --- a/regressions/ck_spinlock/validate/validate.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -struct block { - unsigned int tid; -}; - -static struct affinity a; -static unsigned int locked = 0; -static uint64_t nthr; - -LOCK_DEFINE; - -static void * -thread(void *null CK_CC_UNUSED) -{ -#ifdef LOCK_STATE - LOCK_STATE; -#endif - unsigned int i = ITERATE; - unsigned int j; - unsigned int core; - - if (aff_iterate_core(&a, &core)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { -#ifdef TRYLOCK - if (i & 1) { - LOCK; - } else { - while (TRYLOCK == false) - ck_pr_stall(); - } -#else - LOCK; -#endif - -#ifdef LOCKED - if (LOCKED == false) - ck_error("is_locked operation failed."); -#endif - - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - ck_pr_store_uint(&locked, locked + 1); - - j = ck_pr_load_uint(&locked); - - if (j != 10) { - ck_error("ERROR (WR): Race condition (%u)\n", j); - exit(EXIT_FAILURE); - } - - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - ck_pr_store_uint(&locked, locked - 1); - - UNLOCK; - LOCK; - - j = ck_pr_load_uint(&locked); - if (j != 0) { - ck_error("ERROR (RD): Race condition (%u)\n", j); - exit(EXIT_FAILURE); - } - - UNLOCK; - } - - return (NULL); -} - -int -main(int argc, char *argv[]) -{ - uint64_t i; - pthread_t *threads; - - if (argc != 3) { - ck_error("Usage: " LOCK_NAME " \n"); - exit(EXIT_FAILURE); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - exit(EXIT_FAILURE); - } - -#ifdef LOCK_INIT - LOCK_INIT; -#endif - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - exit(EXIT_FAILURE); - } - - a.delta = atoi(argv[2]); - a.request = 0; - - fprintf(stderr, "Creating threads (mutual exclusion)..."); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, thread, NULL)) { - ck_error("ERROR: Could not create thread %" PRIu64 "\n", i); - exit(EXIT_FAILURE); - } - } - fprintf(stderr, "done\n"); - - fprintf(stderr, "Waiting for threads to finish correctness regression..."); - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - - return (0); -} - diff --git a/regressions/ck_stack/benchmark/Makefile b/regressions/ck_stack/benchmark/Makefile deleted file mode 100644 index 6e2df2a3a8a5..000000000000 --- a/regressions/ck_stack/benchmark/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency - -all: $(OBJECTS) - -latency: latency.c - $(CC) $(CFLAGS) -o latency latency.c - -clean: - rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/benchmark/latency.c b/regressions/ck_stack/benchmark/latency.c deleted file mode 100644 index 867151c02b0b..000000000000 --- a/regressions/ck_stack/benchmark/latency.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ENTRIES -#define ENTRIES 4096 -#endif - -#ifndef STEPS -#define STEPS 40000 -#endif - -/* - * Note the redundant post-increment of r. This is to silence - * some irrelevant GCC warnings. - */ - -static ck_stack_t stack CK_CC_CACHELINE; - -int -main(void) -{ - ck_stack_entry_t entry[ENTRIES]; - ck_spinlock_fas_t mutex = CK_SPINLOCK_FAS_INITIALIZER; - volatile ck_stack_entry_t * volatile r; - uint64_t s, e, a; - unsigned int i; - unsigned int j; - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) { - ck_spinlock_fas_lock(&mutex); - ck_stack_push_spnc(&stack, entry + j); - ck_spinlock_fas_unlock(&mutex); - } - e = rdtsc(); - - a += e - s; - } - printf(" spinlock_push: %16" PRIu64 "\n", a / STEPS / ENTRIES); - - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - for (j = 0; j < ENTRIES; j++) - ck_stack_push_spnc(&stack, entry + j); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) { - ck_spinlock_fas_lock(&mutex); - r = ck_stack_pop_npsc(&stack); - ck_spinlock_fas_unlock(&mutex); - } - e = rdtsc(); - a += e - s; - } - printf(" spinlock_pop: %16" PRIu64 "\n", a / STEPS / ENTRIES); - r++; - -#ifdef CK_F_STACK_PUSH_UPMC - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_stack_push_upmc(&stack, entry + j); - e = rdtsc(); - - a += e - s; - } - printf("ck_stack_push_upmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); -#endif /* CK_F_STACK_PUSH_UPMC */ - -#ifdef CK_F_STACK_PUSH_MPMC - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_stack_push_mpmc(&stack, entry + j); - e = rdtsc(); - - a += e - s; - } - printf("ck_stack_push_mpmc: %16" PRIu64 "\n", a / STEPS / ENTRIES); -#endif /* CK_F_STACK_PUSH_MPMC */ - -#ifdef CK_F_STACK_PUSH_MPNC - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - ck_stack_push_mpnc(&stack, entry + j); - e = rdtsc(); - - a += e - s; - } - printf("ck_stack_push_mpnc: %16" PRIu64 "\n", a / STEPS / ENTRIES); -#endif /* CK_F_STACK_PUSH_MPNC */ - -#if defined(CK_F_STACK_PUSH_UPMC) && defined(CK_F_STACK_POP_UPMC) - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - for (j = 0; j < ENTRIES; j++) - ck_stack_push_upmc(&stack, entry + j); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - r = ck_stack_pop_upmc(&stack); - e = rdtsc(); - a += e - s; - } - printf(" ck_stack_pop_upmc: %16" PRIu64 "\n", a / STEPS / (sizeof(entry) / sizeof(*entry))); -#endif /* CK_F_STACK_PUSH_UPMC && CK_F_STACK_POP_UPMC */ - -#if defined(CK_F_STACK_POP_MPMC) && defined(CK_F_STACK_PUSH_MPMC) - a = 0; - for (i = 0; i < STEPS; i++) { - ck_stack_init(&stack); - - for (j = 0; j < ENTRIES; j++) - ck_stack_push_mpmc(&stack, entry + j); - - s = rdtsc(); - for (j = 0; j < ENTRIES; j++) - r = ck_stack_pop_mpmc(&stack); - e = rdtsc(); - a += e - s; - } - printf(" ck_stack_pop_mpmc: %16" PRIu64 "\n", a / STEPS / (sizeof(entry) / sizeof(*entry))); - r++; -#endif - - return 0; -} diff --git a/regressions/ck_stack/validate/Makefile b/regressions/ck_stack/validate/Makefile deleted file mode 100644 index 519dca1ec172..000000000000 --- a/regressions/ck_stack/validate/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=serial mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push \ - mpmc_pop upmc_pop spinlock_pop spinlock_eb_pop \ - upmc_trypop mpmc_trypop mpmc_trypair \ - mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair \ - mpmc_trypush upmc_trypush - -all: $(OBJECTS) - -check: all - ./serial - ./mpmc_pair $(CORES) 1 0 - ./upmc_trypop $(CORES) 1 0 - ./mpmc_trypop $(CORES) 1 0 - ./mpmc_trypair $(CORES) 1 0 - ./mpmc_pop $(CORES) 1 0 - ./upmc_pop $(CORES) 1 0 - ./mpnc_push $(CORES) 1 0 - ./mpmc_push $(CORES) 1 0 - ./upmc_push $(CORES) 1 0 - ./mpmc_trypush $(CORES) 1 0 - ./upmc_trypush $(CORES) 1 0 - -serial: serial.c - $(CC) $(CFLAGS) -o serial serial.c - -mpmc_trypush upmc_trypush mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push: push.c - $(CC) -DTRYUPMC $(CFLAGS) -o upmc_trypush push.c - $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypush push.c - $(CC) -DMPNC $(CFLAGS) -o mpnc_push push.c - $(CC) -DMPMC $(CFLAGS) -o mpmc_push push.c - $(CC) -DUPMC $(CFLAGS) -o upmc_push push.c - $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_push push.c - $(CC) -DSPINLOCK -DEB $(CFLAGS) -o spinlock_eb_push push.c - -upmc_trypop mpmc_trypop mpmc_pop tryupmc_pop upmc_pop spinlock_pop spinlock_eb_pop: pop.c - $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypop pop.c - $(CC) -DTRYUPMC $(CFLAGS) -o upmc_trypop pop.c - $(CC) -DMPMC $(CFLAGS) -o mpmc_pop pop.c - $(CC) -DUPMC $(CFLAGS) -o upmc_pop pop.c - $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_pop pop.c - $(CC) -DEB -DSPINLOCK $(CFLAGS) -o spinlock_eb_pop pop.c - -mpmc_trypair mpmc_pair spinlock_pair spinlock_eb_pair pthreads_pair: pair.c - $(CC) -DTRYMPMC $(CFLAGS) -o mpmc_trypair pair.c - $(CC) -DMPMC $(CFLAGS) -o mpmc_pair pair.c - $(CC) -DSPINLOCK $(CFLAGS) -o spinlock_pair pair.c - $(CC) -DEB -DSPINLOCK $(CFLAGS) -o spinlock_eb_pair pair.c - $(CC) -DPTHREADS $(CFLAGS) -o pthreads_pair pair.c - -clean: - rm -rf *~ *.o *.dSYM *.exe $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_stack/validate/pair.c b/regressions/ck_stack/validate/pair.c deleted file mode 100644 index c0f1bb1a532f..000000000000 --- a/regressions/ck_stack/validate/pair.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright 2009 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#ifdef SPINLOCK -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITEMS -#define ITEMS (5765760) -#endif - -#define TVTOD(tv) ((tv).tv_sec+((tv).tv_usec / (double)1000000)) - -struct entry { - int value; -#if defined(SPINLOCK) || defined(PTHREADS) - struct entry *next; -#else - ck_stack_entry_t next; -#endif -} CK_CC_CACHELINE; - -#ifdef SPINLOCK -static struct entry *stack CK_CC_CACHELINE; -ck_spinlock_fas_t stack_spinlock = CK_SPINLOCK_FAS_INITIALIZER; -#define UNLOCK ck_spinlock_fas_unlock -#if defined(EB) -#define LOCK ck_spinlock_fas_lock_eb -#else -#define LOCK ck_spinlock_fas_lock -#endif -#elif defined(PTHREADS) -static struct entry *stack CK_CC_CACHELINE; -pthread_mutex_t stack_spinlock = PTHREAD_MUTEX_INITIALIZER; -#define LOCK pthread_mutex_lock -#define UNLOCK pthread_mutex_unlock -#else -static ck_stack_t stack CK_CC_CACHELINE; -CK_STACK_CONTAINER(struct entry, next, getvalue) -#endif - -static struct affinity affinerator; -static unsigned long long nthr; -static volatile unsigned int barrier = 0; -static unsigned int critical; - -static void * -stack_thread(void *buffer) -{ -#if (defined(MPMC) && defined(CK_F_STACK_POP_MPMC)) || (defined(UPMC) && defined(CK_F_STACK_POP_UPMC)) || (defined(TRYUPMC) && defined(CK_F_STACK_TRYPOP_UPMC)) || (defined(TRYMPMC) && defined(CK_F_STACK_TRYPOP_MPMC)) - ck_stack_entry_t *ref; -#endif - struct entry *entry = buffer; - unsigned long long i, n = ITEMS; - unsigned int seed; - int j; - - if (aff_iterate(&affinerator)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - while (barrier == 0); - - for (i = 0; i < n; i++) { -#if defined(MPMC) - ck_stack_push_mpmc(&stack, &entry->next); -#elif defined(TRYMPMC) - while (ck_stack_trypush_mpmc(&stack, &entry->next) == false) - ck_pr_stall(); -#elif defined(UPMC) - ck_stack_push_upmc(&stack, &entry->next); -#elif defined(TRYUPMC) - while (ck_stack_trypush_upmc(&stack, &entry->next) == false) - ck_pr_stall(); -#elif defined(SPINLOCK) || defined(PTHREADS) - LOCK(&stack_spinlock); - ck_pr_store_ptr(&entry->next, stack); - ck_pr_store_ptr(&stack, entry); - UNLOCK(&stack_spinlock); -#else -# error Undefined operation. -#endif - - if (critical) { - j = common_rand_r(&seed) % critical; - while (j--) - __asm__ __volatile__("" ::: "memory"); - } - -#if defined(MPMC) -#ifdef CK_F_STACK_POP_MPMC - ref = ck_stack_pop_mpmc(&stack); - entry = getvalue(ref); -#endif -#elif defined(TRYMPMC) -#ifdef CK_F_STACK_TRYPOP_MPMC - while (ck_stack_trypop_mpmc(&stack, &ref) == false) - ck_pr_stall(); - entry = getvalue(ref); -#endif /* CK_F_STACK_TRYPOP_MPMC */ -#elif defined(UPMC) - ref = ck_stack_pop_upmc(&stack); - entry = getvalue(ref); -#elif defined(SPINLOCK) || defined(PTHREADS) - LOCK(&stack_spinlock); - entry = stack; - stack = stack->next; - UNLOCK(&stack_spinlock); -#else -# error Undefined operation. -#endif - } - - return (NULL); -} - -static void -stack_assert(void) -{ - -#if defined(SPINLOCK) || defined(PTHREADS) - assert(stack == NULL); -#else - assert(CK_STACK_ISEMPTY(&stack)); -#endif - return; -} - -int -main(int argc, char *argv[]) -{ - struct entry *bucket; - unsigned long long i, d; - pthread_t *thread; - struct timeval stv, etv; - -#if (defined(TRYMPMC) || defined(MPMC)) && (!defined(CK_F_STACK_PUSH_MPMC) || !defined(CK_F_STACK_POP_MPMC)) - fprintf(stderr, "Unsupported.\n"); - return 0; -#endif - - if (argc != 4) { - ck_error("Usage: stack \n"); - } - - { - char *e; - - nthr = strtol(argv[1], &e, 10); - if (errno == ERANGE) { - perror("ERROR: too many threads"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - d = strtol(argv[2], &e, 10); - if (errno == ERANGE) { - perror("ERROR: delta is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - critical = strtoul(argv[3], &e, 10); - if (errno == ERANGE) { - perror("ERROR: critical section is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - } - - srand(getpid()); - - affinerator.request = 0; - affinerator.delta = d; - - bucket = malloc(sizeof(struct entry) * nthr); - assert(bucket != NULL); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread != NULL); - - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, bucket + i); - - barrier = 1; - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - barrier = 0; - - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, bucket + i); - - common_gettimeofday(&stv, NULL); - barrier = 1; - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - common_gettimeofday(&etv, NULL); - - stack_assert(); -#ifdef _WIN32 - printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); -#else - printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); -#endif - return 0; -} diff --git a/regressions/ck_stack/validate/pop.c b/regressions/ck_stack/validate/pop.c deleted file mode 100644 index 0d69d42a8415..000000000000 --- a/regressions/ck_stack/validate/pop.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright 2009-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#ifdef SPINLOCK -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITEMS -#define ITEMS (5765760 * 2) -#endif - -#define TVTOD(tv) ((tv).tv_sec+((tv).tv_usec / (double)1000000)) - -struct entry { - int value; -#ifdef SPINLOCK - struct entry *next; -#else - ck_stack_entry_t next; -#endif -}; - -#ifdef SPINLOCK -static struct entry *stack CK_CC_CACHELINE; -ck_spinlock_fas_t stack_spinlock = CK_SPINLOCK_FAS_INITIALIZER; -#define UNLOCK ck_spinlock_fas_unlock -#if defined(EB) -#define LOCK ck_spinlock_fas_lock_eb -#else -#define LOCK ck_spinlock_fas_lock -#endif -#else -static ck_stack_t stack CK_CC_CACHELINE; -CK_STACK_CONTAINER(struct entry, next, getvalue) -#endif - -static struct affinity affinerator = AFFINITY_INITIALIZER; -static unsigned long long nthr; -static volatile unsigned int barrier = 0; -static unsigned int critical; - -static void * -stack_thread(void *unused CK_CC_UNUSED) -{ -#if (defined(MPMC) && defined(CK_F_STACK_POP_MPMC)) || (defined(UPMC) && defined(CK_F_STACK_POP_UPMC)) || (defined(TRYMPMC) && defined(CK_F_STACK_TRYPOP_MPMC)) || (defined(TRYUPMC) && defined(CK_F_STACK_TRYPOP_UPMC)) - ck_stack_entry_t *ref; -#endif - struct entry *entry = NULL; - unsigned long long i, n = ITEMS / nthr; - unsigned int seed; - int j, previous = INT_MAX; - - if (aff_iterate(&affinerator)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - while (barrier == 0); - - for (i = 0; i < n; i++) { -#ifdef MPMC -#ifdef CK_F_STACK_POP_MPMC - ref = ck_stack_pop_mpmc(&stack); - assert(ref); - entry = getvalue(ref); -#endif /* CK_F_STACK_POP_MPMC */ -#elif defined(TRYMPMC) -#ifdef CK_F_STACK_TRYPOP_MPMC - while (ck_stack_trypop_mpmc(&stack, &ref) == false) - ck_pr_stall(); - assert(ref); - entry = getvalue(ref); -#endif /* CK_F_STACK_TRYPOP_MPMC */ -#elif defined(UPMC) - ref = ck_stack_pop_upmc(&stack); - assert(ref); - entry = getvalue(ref); -#elif defined(TRYUPMC) - while (ck_stack_trypop_upmc(&stack, &ref) == false) - ck_pr_stall(); - assert(ref); - entry = getvalue(ref); -#elif defined(SPINLOCK) - LOCK(&stack_spinlock); - entry = stack; - stack = stack->next; - UNLOCK(&stack_spinlock); -#else -# error Undefined operation. -#endif - - if (critical) { - j = common_rand_r(&seed) % critical; - while (j--) - __asm__ __volatile__("" ::: "memory"); - } - - assert (previous >= entry->value); - previous = entry->value; - } - - return (NULL); -} - -static void -stack_assert(void) -{ - -#ifdef SPINLOCK - assert(stack == NULL); -#else - assert(CK_STACK_ISEMPTY(&stack)); -#endif - return; -} - -static void -push_stack(struct entry *bucket) -{ - unsigned long long i; - -#ifdef SPINLOCK - stack = NULL; -#else - ck_stack_init(&stack); -#endif - - for (i = 0; i < ITEMS; i++) { - bucket[i].value = i % INT_MAX; -#ifdef SPINLOCK - bucket[i].next = stack; - stack = bucket + i; -#else - ck_stack_push_spnc(&stack, &bucket[i].next); -#endif - } - -#ifndef SPINLOCK - ck_stack_entry_t *entry; - i = 0; - CK_STACK_FOREACH(&stack, entry) { - i++; - } - assert(i == ITEMS); -#endif - - return; -} - -int -main(int argc, char *argv[]) -{ - struct entry *bucket; - unsigned long long i, d; - pthread_t *thread; - struct timeval stv, etv; - -#if (defined(TRYMPMC) || defined(MPMC)) && (!defined(CK_F_STACK_PUSH_MPMC) || !defined(CK_F_STACK_POP_MPMC)) - fprintf(stderr, "Unsupported.\n"); - return 0; -#endif - - if (argc != 4) { - ck_error("Usage: stack \n"); - } - - { - char *e; - - nthr = strtol(argv[1], &e, 10); - if (errno == ERANGE) { - perror("ERROR: too many threads"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - d = strtol(argv[2], &e, 10); - if (errno == ERANGE) { - perror("ERROR: delta is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - critical = strtoul(argv[3], &e, 10); - if (errno == ERANGE) { - perror("ERROR: critical section is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - } - - srand(getpid()); - - affinerator.delta = d; - bucket = malloc(sizeof(struct entry) * ITEMS); - assert(bucket != NULL); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread != NULL); - - push_stack(bucket); - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, NULL); - - barrier = 1; - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - barrier = 0; - - push_stack(bucket); - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, NULL); - - common_gettimeofday(&stv, NULL); - barrier = 1; - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - common_gettimeofday(&etv, NULL); - - stack_assert(); -#ifdef _WIN32 - printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); -#else - printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); -#endif - return 0; -} diff --git a/regressions/ck_stack/validate/push.c b/regressions/ck_stack/validate/push.c deleted file mode 100644 index 2b3ea334ddc5..000000000000 --- a/regressions/ck_stack/validate/push.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright 2009-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#ifdef SPINLOCK -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef ITEMS -#define ITEMS (5765760 * 2) -#endif - -#define TVTOD(tv) ((tv).tv_sec+((tv).tv_usec / (double)1000000)) - -struct entry { - int value; -#ifdef SPINLOCK - struct entry *next; -#else - ck_stack_entry_t next; -#endif -}; - -#ifdef SPINLOCK -static struct entry *stack CK_CC_CACHELINE; -#else -static ck_stack_t stack CK_CC_CACHELINE; -#endif - -CK_STACK_CONTAINER(struct entry, next, getvalue) - -static struct affinity affinerator = AFFINITY_INITIALIZER; -static unsigned long long nthr; -static volatile unsigned int barrier = 0; -static unsigned int critical; - -#if defined(SPINLOCK) -ck_spinlock_fas_t stack_spinlock = CK_SPINLOCK_FAS_INITIALIZER; -#define UNLOCK ck_spinlock_fas_unlock -#if defined(EB) -#define LOCK ck_spinlock_fas_lock_eb -#else -#define LOCK ck_spinlock_fas_lock -#endif -#elif defined(PTHREAD) -pthread_mutex_t stack_spinlock = PTHREAD_MUTEX_INITIALIZER; -#define LOCK pthread_mutex_lock -#define UNLOCK pthread_mutex_unlock -#endif - -static void * -stack_thread(void *buffer) -{ - struct entry *bucket = buffer; - unsigned long long i, n = ITEMS / nthr; - unsigned int seed; - int j; - - if (aff_iterate(&affinerator)) { - perror("ERROR: failed to affine thread"); - exit(EXIT_FAILURE); - } - - while (barrier == 0); - - for (i = 0; i < n; i++) { - bucket[i].value = (i + 1) * 2; - -#if defined(MPNC) - ck_stack_push_mpnc(&stack, &bucket[i].next); -#elif defined(MPMC) - ck_stack_push_mpmc(&stack, &bucket[i].next); -#elif defined(TRYMPMC) - while (ck_stack_trypush_mpmc(&stack, &bucket[i].next) == false) - ck_pr_stall(); -#elif defined(TRYUPMC) - while (ck_stack_trypush_upmc(&stack, &bucket[i].next) == false) - ck_pr_stall(); -#elif defined(UPMC) - ck_stack_push_upmc(&stack, &bucket[i].next); -#elif defined(SPINLOCK) || defined(PTHREADS) - LOCK(&stack_spinlock); - bucket[i].next = stack; - stack = bucket + i; - UNLOCK(&stack_spinlock); -#else -# error Undefined operation. -#endif - - if (critical) { - j = common_rand_r(&seed) % critical; - while (j--) - __asm__ __volatile__("" ::: "memory"); - } - } - - return (NULL); -} - -static void -stack_assert(void) -{ -#ifndef SPINLOCK - ck_stack_entry_t *n; -#endif - struct entry *p; - unsigned long long c = 0; - -#ifdef SPINLOCK - for (p = stack; p; p = p->next) - c++; -#else - CK_STACK_FOREACH(&stack, n) { - p = getvalue(n); - (void)((volatile struct entry *)p)->value; - c++; - } -#endif - - assert(c == ITEMS); - return; -} - -int -main(int argc, char *argv[]) -{ - struct entry *bucket; - unsigned long long i, d, n; - pthread_t *thread; - struct timeval stv, etv; - - if (argc != 4) { - ck_error("Usage: stack \n"); - } - - { - char *e; - - nthr = strtol(argv[1], &e, 10); - if (errno == ERANGE) { - perror("ERROR: too many threads"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - d = strtol(argv[2], &e, 10); - if (errno == ERANGE) { - perror("ERROR: delta is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - - critical = strtoul(argv[3], &e, 10); - if (errno == ERANGE) { - perror("ERROR: critical section is too large"); - exit(EXIT_FAILURE); - } else if (*e != '\0') { - ck_error("ERROR: input format is incorrect\n"); - } - } - - srand(getpid()); - - affinerator.request = 0; - affinerator.delta = d; - n = ITEMS / nthr; - -#ifndef SPINLOCK - ck_stack_init(&stack); -#else - stack = NULL; -#endif - - bucket = malloc(sizeof(struct entry) * ITEMS); - assert(bucket != NULL); - - thread = malloc(sizeof(pthread_t) * nthr); - assert(thread != NULL); - - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, bucket + i * n); - - barrier = 1; - - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - - barrier = 0; - -#ifndef SPINLOCK - ck_stack_init(&stack); -#else - stack = NULL; -#endif - - for (i = 0; i < nthr; i++) - pthread_create(&thread[i], NULL, stack_thread, bucket + i * n); - - common_gettimeofday(&stv, NULL); - barrier = 1; - for (i = 0; i < nthr; i++) - pthread_join(thread[i], NULL); - common_gettimeofday(&etv, NULL); - - stack_assert(); -#ifdef _WIN32 - printf("%3llu %.6f\n", nthr, TVTOD(etv) - TVTOD(stv)); -#else - printf("%3llu %.6lf\n", nthr, TVTOD(etv) - TVTOD(stv)); -#endif - return 0; -} diff --git a/regressions/ck_stack/validate/serial.c b/regressions/ck_stack/validate/serial.c deleted file mode 100644 index eb667ca10310..000000000000 --- a/regressions/ck_stack/validate/serial.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2009-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include - -#ifndef SIZE -#define SIZE 1024000 -#endif - -struct entry { - int value; - ck_stack_entry_t next; -}; - -CK_STACK_CONTAINER(struct entry, next, get_entry) - -#define LOOP(PUSH, POP) \ - for (i = 0; i < SIZE; i++) { \ - entries[i].value = i; \ - PUSH(stack, &entries[i].next); \ - } \ - for (i = SIZE - 1; i >= 0; i--) { \ - entry = POP(stack); \ - assert(entry); \ - assert(get_entry(entry)->value == i); \ - } - -static void -serial(ck_stack_t *stack) -{ - struct entry *entries; - ck_stack_entry_t *entry; - int i; - - ck_stack_init(stack); - - entries = malloc(sizeof(struct entry) * SIZE); - assert(entries != NULL); - - LOOP(ck_stack_push_upmc, ck_stack_pop_upmc); -#ifdef CK_F_STACK_POP_MPMC - LOOP(ck_stack_push_mpmc, ck_stack_pop_mpmc); -#endif - LOOP(ck_stack_push_mpnc, ck_stack_pop_upmc); - LOOP(ck_stack_push_spnc, ck_stack_pop_npsc); - - return; -} - -int -main(void) -{ - ck_stack_t stack CK_CC_CACHELINE; - - serial(&stack); - return (0); -} diff --git a/regressions/ck_swlock/benchmark/Makefile b/regressions/ck_swlock/benchmark/Makefile deleted file mode 100644 index 4ec728c2a51c..000000000000 --- a/regressions/ck_swlock/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_swlock.h - $(CC) $(CFLAGS) -o latency latency.c - -throughput: throughput.c ../../../include/ck_swlock.h - $(CC) $(CFLAGS) -o throughput throughput.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_swlock/benchmark/latency.c b/regressions/ck_swlock/benchmark/latency.c deleted file mode 100644 index 73a9482849f4..000000000000 --- a/regressions/ck_swlock/benchmark/latency.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include "../../common.h" - -#define CK_F_PR_RTM - -#ifndef STEPS -#define STEPS 2000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_swlock_t swlock = CK_SWLOCK_INITIALIZER; - - for (i = 0; i < STEPS; i++) { - ck_swlock_write_lock(&swlock); - ck_swlock_write_unlock(&swlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_swlock_write_lock(&swlock); - ck_swlock_write_unlock(&swlock); - } - e_b = rdtsc(); - printf(" WRITE: swlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_swlock_read_lock(&swlock); - ck_swlock_read_unlock(&swlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_swlock_read_lock(&swlock); - ck_swlock_read_unlock(&swlock); - } - e_b = rdtsc(); - printf(" READ: swlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_swlock_write_latch(&swlock); - ck_swlock_write_unlatch(&swlock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_swlock_write_latch(&swlock); - ck_swlock_write_unlatch(&swlock); - } - e_b = rdtsc(); - printf(" LATCH: swlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return 0; -} - diff --git a/regressions/ck_swlock/benchmark/throughput.c b/regressions/ck_swlock/benchmark/throughput.c deleted file mode 100644 index 5b05365751ce..000000000000 --- a/regressions/ck_swlock/benchmark/throughput.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static int barrier; -static int threads; -static unsigned int flag CK_CC_CACHELINE; -static struct { - ck_swlock_t lock; -} rw CK_CC_CACHELINE = { - .lock = CK_SWLOCK_INITIALIZER -}; - -static struct affinity affinity; - -static void * -thread_lock(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - ck_swlock_read_lock(&rw.lock); - ck_swlock_read_unlock(&rw.lock); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -static void -swlock_test(pthread_t *p, int d, uint64_t *latency, void *(*f)(void *), const char *label) -{ - int t; - - ck_pr_store_int(&barrier, 0); - ck_pr_store_uint(&flag, 0); - - affinity.delta = d; - affinity.request = 0; - - fprintf(stderr, "Creating threads (%s)...", label); - for (t = 0; t < threads; t++) { - if (pthread_create(&p[t], NULL, f, latency + t) != 0) { - ck_error("ERROR: Could not create thread %d\n", t); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (t = 0; t < threads; t++) - pthread_join(p[t], NULL); - fprintf(stderr, "done\n\n"); - - for (t = 1; t <= threads; t++) - printf("%10u %20" PRIu64 "\n", t, latency[t - 1]); - - fprintf(stderr, "\n"); - return; -} - - -int -main(int argc, char *argv[]) -{ - int d; - pthread_t *p; - uint64_t *latency; - - if (argc != 3) { - ck_error("Usage: throughput \n"); - } - - threads = atoi(argv[2]); - if (threads <= 0) { - ck_error("ERROR: Threads must be a value > 0.\n"); - } - - p = malloc(sizeof(pthread_t) * threads); - if (p == NULL) { - ck_error("ERROR: Failed to initialize thread.\n"); - } - - latency = malloc(sizeof(uint64_t) * threads); - if (latency == NULL) { - ck_error("ERROR: Failed to create latency buffer.\n"); - } - - d = atoi(argv[1]); - swlock_test(p, d, latency, thread_lock, "swlock"); - - return 0; -} - diff --git a/regressions/ck_swlock/validate/Makefile b/regressions/ck_swlock/validate/Makefile deleted file mode 100644 index 54d62f2033d6..000000000000 --- a/regressions/ck_swlock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_swlock.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_swlock/validate/validate.c b/regressions/ck_swlock/validate/validate.c deleted file mode 100644 index 11366ce6415b..000000000000 --- a/regressions/ck_swlock/validate/validate.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright 2014 Jaidev Sridhar. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked; -static int nthr; -static ck_swlock_t lock = CK_SWLOCK_INITIALIZER; -static ck_swlock_t copy; -#ifdef CK_F_PR_RTM -static void * -thread_rtm_adaptive(void *arg) -{ - unsigned int i = ITERATE; - unsigned int l; - int tid = ck_pr_load_int(arg); - - struct ck_elide_config config = CK_ELIDE_CONFIG_DEFAULT_INITIALIZER; - struct ck_elide_stat st = CK_ELIDE_STAT_INITIALIZER; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (tid == 0) { - CK_ELIDE_LOCK_ADAPTIVE(ck_swlock_write, &st, &config, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK_ADAPTIVE(ck_swlock_write, &st, &lock); - } - - CK_ELIDE_LOCK(ck_swlock_read, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_swlock_read, &lock); - } - - return NULL; -} - -static void * -thread_rtm_mix(void *arg) -{ - unsigned int i = ITERATE; - unsigned int l; - int tid = ck_pr_load_int(arg); - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (tid == 0) { - if (i & 1) { - CK_ELIDE_LOCK(ck_swlock_write, &lock); - } else { - ck_swlock_write_lock(&lock); - } - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - - if (i & 1) { - CK_ELIDE_UNLOCK(ck_swlock_write, &lock); - } else { - ck_swlock_write_unlock(&lock); - } - } - if (i & 1) { - CK_ELIDE_LOCK(ck_swlock_read, &lock); - } else { - ck_swlock_read_lock(&lock); - } - - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - - if (i & 1) { - CK_ELIDE_UNLOCK(ck_swlock_read, &lock); - } else { - ck_swlock_read_unlock(&lock); - } - } - - return (NULL); -} - -static void * -thread_rtm(void *arg) -{ - unsigned int i = ITERATE; - unsigned int l; - int tid = ck_pr_load_int(arg); - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (tid == 0) { - CK_ELIDE_LOCK(ck_swlock_write, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_swlock_write, &lock); - } - - CK_ELIDE_LOCK(ck_swlock_read, &lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - CK_ELIDE_UNLOCK(ck_swlock_read, &lock); - } - - return (NULL); -} -#endif /* CK_F_PR_RTM */ - -static void * -thread_latch(void *arg) -{ - unsigned int i = ITERATE; - unsigned int l; - int tid = ck_pr_load_int(arg); - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (tid == 0) { - /* Writer */ - ck_swlock_write_latch(&lock); - { - memcpy(©, &lock, sizeof(ck_swlock_t)); - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - memcpy(&lock, ©, sizeof(ck_swlock_t)); - } - ck_swlock_write_unlatch(&lock); - } - - ck_swlock_read_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_swlock_read_unlock(&lock); - } - - return (NULL); -} - -static void * -thread(void *arg) -{ - unsigned int i = ITERATE; - unsigned int l; - int tid = ck_pr_load_int(arg); - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - if (tid == 0) { - /* Writer */ - ck_swlock_write_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_swlock_write_unlock(&lock); - } - - ck_swlock_read_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_swlock_read_unlock(&lock); - } - - return (NULL); -} - -static void -swlock_test(pthread_t *threads, void *(*f)(void *), const char *test) -{ - int i, tid[nthr]; - - fprintf(stderr, "Creating threads (%s)...", test); - for (i = 0; i < nthr; i++) { - ck_pr_store_int(&tid[i], i); - if (pthread_create(&threads[i], NULL, f, &tid[i])) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "."); - - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - return; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - - if (argc != 3) { - ck_error("Usage: validate \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - swlock_test(threads, thread, "regular"); - swlock_test(threads, thread_latch, "latch"); -#ifdef CK_F_PR_RTM - swlock_test(threads, thread_rtm, "rtm"); - swlock_test(threads, thread_rtm_mix, "rtm-mix"); - swlock_test(threads, thread_rtm_adaptive, "rtm-adaptive"); -#endif - return 0; -} - diff --git a/regressions/ck_tflock/benchmark/Makefile b/regressions/ck_tflock/benchmark/Makefile deleted file mode 100644 index ed635040032f..000000000000 --- a/regressions/ck_tflock/benchmark/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean distribution - -OBJECTS=latency throughput - -all: $(OBJECTS) - -latency: latency.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o latency latency.c - -throughput: throughput.c ../../../include/ck_rwlock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o throughput throughput.c - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_tflock/benchmark/latency.c b/regressions/ck_tflock/benchmark/latency.c deleted file mode 100644 index fd77d44b066d..000000000000 --- a/regressions/ck_tflock/benchmark/latency.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -#include "../../common.h" - -#define CK_F_PR_RTM - -#ifndef STEPS -#define STEPS 2000000 -#endif - -int -main(void) -{ - uint64_t s_b, e_b, i; - ck_tflock_ticket_t tflock = CK_TFLOCK_TICKET_INITIALIZER; - - for (i = 0; i < STEPS; i++) { - ck_tflock_ticket_write_lock(&tflock); - ck_tflock_ticket_write_unlock(&tflock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_tflock_ticket_write_lock(&tflock); - ck_tflock_ticket_write_unlock(&tflock); - } - e_b = rdtsc(); - printf(" WRITE: tflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - for (i = 0; i < STEPS; i++) { - ck_tflock_ticket_read_lock(&tflock); - ck_tflock_ticket_read_unlock(&tflock); - } - - s_b = rdtsc(); - for (i = 0; i < STEPS; i++) { - ck_tflock_ticket_read_lock(&tflock); - ck_tflock_ticket_read_unlock(&tflock); - } - e_b = rdtsc(); - printf(" READ: tflock %15" PRIu64 "\n", (e_b - s_b) / STEPS); - - return 0; -} - diff --git a/regressions/ck_tflock/benchmark/throughput.c b/regressions/ck_tflock/benchmark/throughput.c deleted file mode 100644 index 41d22bdfa073..000000000000 --- a/regressions/ck_tflock/benchmark/throughput.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../../common.h" - -#ifndef STEPS -#define STEPS 1000000 -#endif - -static int barrier; -static int threads; -static unsigned int flag CK_CC_CACHELINE; -static struct { - ck_tflock_ticket_t lock; -} rw CK_CC_CACHELINE = { - .lock = CK_TFLOCK_TICKET_INITIALIZER -}; - -static struct affinity affinity; - -static void * -thread_lock(void *pun) -{ - uint64_t s_b, e_b, a, i; - uint64_t *value = pun; - - if (aff_iterate(&affinity) != 0) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads) - ck_pr_stall(); - - for (i = 1, a = 0;; i++) { - s_b = rdtsc(); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - ck_tflock_ticket_read_lock(&rw.lock); - ck_tflock_ticket_read_unlock(&rw.lock); - e_b = rdtsc(); - - a += (e_b - s_b) >> 4; - - if (ck_pr_load_uint(&flag) == 1) - break; - } - - ck_pr_inc_int(&barrier); - while (ck_pr_load_int(&barrier) != threads * 2) - ck_pr_stall(); - - *value = (a / i); - return NULL; -} - -static void -tflock_test(pthread_t *p, int d, uint64_t *latency, void *(*f)(void *), const char *label) -{ - int t; - - ck_pr_store_int(&barrier, 0); - ck_pr_store_uint(&flag, 0); - - affinity.delta = d; - affinity.request = 0; - - fprintf(stderr, "Creating threads (%s)...", label); - for (t = 0; t < threads; t++) { - if (pthread_create(&p[t], NULL, f, latency + t) != 0) { - ck_error("ERROR: Could not create thread %d\n", t); - } - } - fprintf(stderr, "done\n"); - - common_sleep(10); - ck_pr_store_uint(&flag, 1); - - fprintf(stderr, "Waiting for threads to finish acquisition regression..."); - for (t = 0; t < threads; t++) - pthread_join(p[t], NULL); - fprintf(stderr, "done\n\n"); - - for (t = 1; t <= threads; t++) - printf("%10u %20" PRIu64 "\n", t, latency[t - 1]); - - fprintf(stderr, "\n"); - return; -} - - -int -main(int argc, char *argv[]) -{ - int d; - pthread_t *p; - uint64_t *latency; - - if (argc != 3) { - ck_error("Usage: throughput \n"); - } - - threads = atoi(argv[2]); - if (threads <= 0) { - ck_error("ERROR: Threads must be a value > 0.\n"); - } - - p = malloc(sizeof(pthread_t) * threads); - if (p == NULL) { - ck_error("ERROR: Failed to initialize thread.\n"); - } - - latency = malloc(sizeof(uint64_t) * threads); - if (latency == NULL) { - ck_error("ERROR: Failed to create latency buffer.\n"); - } - - d = atoi(argv[1]); - tflock_test(p, d, latency, thread_lock, "tflock"); - return 0; -} - diff --git a/regressions/ck_tflock/validate/Makefile b/regressions/ck_tflock/validate/Makefile deleted file mode 100644 index 6ae7c731b4d0..000000000000 --- a/regressions/ck_tflock/validate/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: check clean distribution - -OBJECTS=validate - -all: $(OBJECTS) - -validate: validate.c ../../../include/ck_tflock.h ../../../include/ck_elide.h - $(CC) $(CFLAGS) -o validate validate.c - -check: all - ./validate $(CORES) 1 - -clean: - rm -rf *.dSYM *.exe *~ *.o $(OBJECTS) - -include ../../../build/regressions.build -CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_tflock/validate/validate.c b/regressions/ck_tflock/validate/validate.c deleted file mode 100644 index 22e9e6546679..000000000000 --- a/regressions/ck_tflock/validate/validate.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../common.h" - -#ifndef ITERATE -#define ITERATE 1000000 -#endif - -static struct affinity a; -static unsigned int locked; -static int nthr; -static ck_tflock_ticket_t lock = CK_TFLOCK_TICKET_INITIALIZER; - -static void * -thread(void *null CK_CC_UNUSED) -{ - unsigned int i = ITERATE; - unsigned int l; - - if (aff_iterate(&a)) { - perror("ERROR: Could not affine thread"); - exit(EXIT_FAILURE); - } - - while (i--) { - ck_tflock_ticket_write_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - ck_pr_inc_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 8) { - ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); - } - - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - ck_pr_dec_uint(&locked); - - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); - } - } - ck_tflock_ticket_write_unlock(&lock); - - ck_tflock_ticket_read_lock(&lock); - { - l = ck_pr_load_uint(&locked); - if (l != 0) { - ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); - } - } - ck_tflock_ticket_read_unlock(&lock); - } - - return (NULL); -} - -static void -tflock_ticket_test(pthread_t *threads, void *(*f)(void *), const char *test) -{ - int i; - - fprintf(stderr, "Creating threads (%s)...", test); - for (i = 0; i < nthr; i++) { - if (pthread_create(&threads[i], NULL, f, NULL)) { - ck_error("ERROR: Could not create thread %d\n", i); - } - } - fprintf(stderr, "."); - - for (i = 0; i < nthr; i++) - pthread_join(threads[i], NULL); - fprintf(stderr, "done (passed)\n"); - return; -} - -int -main(int argc, char *argv[]) -{ - pthread_t *threads; - - if (argc != 3) { - ck_error("Usage: validate \n"); - } - - nthr = atoi(argv[1]); - if (nthr <= 0) { - ck_error("ERROR: Number of threads must be greater than 0\n"); - } - - threads = malloc(sizeof(pthread_t) * nthr); - if (threads == NULL) { - ck_error("ERROR: Could not allocate thread structures\n"); - } - - a.delta = atoi(argv[2]); - - tflock_ticket_test(threads, thread, "regular"); - ck_tflock_ticket_init(&lock); - return 0; -} - diff --git a/regressions/common.h b/regressions/common.h deleted file mode 100644 index 13775323a3cb..000000000000 --- a/regressions/common.h +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright 2011-2015 Samy Al Bahra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_COMMON_H -#define CK_COMMON_H - -#include -#include -#include -#include -#include -#include - -#ifdef __linux__ -#include -#include -#include -#elif defined(__MACH__) -#include -#include -#elif defined(__FreeBSD__) -#include -#include -#endif - -#if defined(_WIN32) -#include -#define NOMINMAX -#include -#define DELTA_EPOCH 11644473600000000ULL -#else -#include -#include -#endif - -#ifndef CORES -#define CORES 8 -#endif - -CK_CC_INLINE static void -common_srand(unsigned int i) -{ -#ifdef _WIN32 - srand(i); -#else - srandom(i); -#endif -} - -CK_CC_INLINE static int -common_rand(void) -{ -#ifdef _WIN32 - return rand(); -#else - return random(); -#endif -} - -CK_CC_INLINE static int -common_rand_r(unsigned int *i) -{ -#ifdef _WIN32 - (void)i; - - /* - * When linked with -mthreads, rand() is thread-safe. - * rand_s is also an option. - */ - return rand(); -#else - return rand_r(i); -#endif -} - -CK_CC_INLINE static void -common_srand48(long int i) -{ -#ifdef _WIN32 - srand(i); -#else - srand48(i); -#endif -} - -CK_CC_INLINE static long int -common_lrand48(void) -{ -#ifdef _WIN32 - return rand(); -#else - return lrand48(); -#endif -} - -CK_CC_INLINE static double -common_drand48(void) -{ -#ifdef _WIN32 - return (double)rand()/RAND_MAX; -#else - return drand48(); -#endif -} - -CK_CC_INLINE static void -common_sleep(unsigned int n) -{ -#ifdef _WIN32 - Sleep(n * 1000); -#else - sleep(n); -#endif -} - -CK_CC_INLINE static int -common_gettimeofday(struct timeval *tv, void *tz) -{ -#ifdef _WIN32 - FILETIME ft; - uint64_t tmp_time = 0; - static bool tzflag = false; - struct timezone *tzp = tz; - - if (tv != NULL) { - GetSystemTimeAsFileTime(&ft); - tmp_time |= ft.dwHighDateTime; - tmp_time <<= 32; - tmp_time |= ft.dwLowDateTime; - - /* GetSystemTimeAsFileTime returns 100 nanosecond intervals. */ - tmp_time /= 10; - - /* Windows' epoch starts on 01/01/1601, while Unix' starts on 01/01/1970. */ - tmp_time -= DELTA_EPOCH; - - tv->tv_sec = (long)(tmp_time / 1000000UL); - tv->tv_usec = (long)(tmp_time % 1000000UL); - } - - - if (tz != NULL) { - if (tzflag == false) { - _tzset(); - tzflag = true; - } - - tzp->tz_minuteswest = _timezone / 60; - tzp->tz_dsttime = _daylight; - } - - return 0; -#else - return gettimeofday(tv, tz); -#endif -} - -CK_CC_UNUSED static unsigned int -common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) -{ -#ifdef _WIN32 - (void)sig_handler; - (void)duration; - bool success; - HANDLE *alarm_handle = alarm_event; - success = SetEvent(*alarm_handle); - assert(success != false); - return 0; -#else - (void)alarm_event; - signal(SIGALRM, sig_handler); - return alarm(duration); -#endif -} - -#ifdef _WIN32 -#ifndef SECOND_TIMER -#define SECOND_TIMER 10000000 -#endif -#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) \ -static HANDLE prefix##_common_win_alarm_timer; \ -static HANDLE alarm_event_name; \ -static LARGE_INTEGER prefix##_common_alarm_timer_length; \ - \ -static void CALLBACK \ -prefix##_common_win_alarm_handler(LPVOID arg, DWORD timer_low_value, DWORD timer_high_value) \ -{ \ - (void)arg; \ - (void)timer_low_value; \ - (void)timer_high_value; \ - flag_name = true; \ - return; \ -} \ - \ -static void * \ -prefix##_common_win_alarm(void *unused) \ -{ \ - (void)unused; \ - bool timer_success = false; \ - for (;;) { \ - WaitForSingleObjectEx(alarm_event_name, INFINITE, true); \ - timer_success = SetWaitableTimer(prefix##_common_win_alarm_timer, \ - &prefix##_common_alarm_timer_length, \ - 0, \ - prefix##_common_win_alarm_handler, NULL, false); \ - assert(timer_success != false); \ - WaitForSingleObjectEx(prefix##_common_win_alarm_timer, INFINITE, true); \ - } \ - \ - return NULL; \ -} - -#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ - int64_t prefix##_common_alarm_tl; \ - pthread_t prefix##_common_win_alarm_thread; - -#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) \ - prefix##_common_alarm_tl = -1 * (duration) * SECOND_TIMER; \ - prefix##_common_alarm_timer_length.LowPart = \ - (DWORD) (prefix##_common_alarm_tl & 0xFFFFFFFF); \ - prefix##_common_alarm_timer_length.HighPart = \ - (LONG) (prefix##_common_alarm_tl >> 32); \ - alarm_event_name = CreateEvent(NULL, false, false, NULL); \ - assert(alarm_event_name != NULL); \ - prefix##_common_win_alarm_timer = CreateWaitableTimer(NULL, true, NULL); \ - assert(prefix##_common_win_alarm_timer != NULL); \ - if (pthread_create(&prefix##_common_win_alarm_thread, \ - NULL, \ - prefix##_common_win_alarm, \ - NULL) != 0) \ - ck_error("ERROR: Failed to create common_win_alarm thread.\n"); -#else -#define COMMON_ALARM_DECLARE_GLOBAL(prefix, alarm_event_name, flag_name) -#define COMMON_ALARM_DECLARE_LOCAL(prefix, alarm_event_name) \ - int alarm_event_name = 0; -#define COMMON_ALARM_INIT(prefix, alarm_event_name, duration) -#endif - -struct affinity { - unsigned int delta; - unsigned int request; -}; - -#define AFFINITY_INITIALIZER {0, 0} - -#ifdef __linux__ -#ifndef gettid -static pid_t -gettid(void) -{ - return syscall(__NR_gettid); -} -#endif /* gettid */ - -CK_CC_UNUSED static int -aff_iterate(struct affinity *acb) -{ - cpu_set_t s; - unsigned int c; - - c = ck_pr_faa_uint(&acb->request, acb->delta); - CPU_ZERO(&s); - CPU_SET(c % CORES, &s); - - return sched_setaffinity(gettid(), sizeof(s), &s); -} - -CK_CC_UNUSED static int -aff_iterate_core(struct affinity *acb, unsigned int *core) -{ - cpu_set_t s; - - *core = ck_pr_faa_uint(&acb->request, acb->delta); - CPU_ZERO(&s); - CPU_SET((*core) % CORES, &s); - - return sched_setaffinity(gettid(), sizeof(s), &s); -} -#elif defined(__MACH__) -CK_CC_UNUSED static int -aff_iterate(struct affinity *acb) -{ - thread_affinity_policy_data_t policy; - unsigned int c; - - c = ck_pr_faa_uint(&acb->request, acb->delta) % CORES; - policy.affinity_tag = c; - return thread_policy_set(mach_thread_self(), - THREAD_AFFINITY_POLICY, - (thread_policy_t)&policy, - THREAD_AFFINITY_POLICY_COUNT); -} - -CK_CC_UNUSED static int -aff_iterate_core(struct affinity *acb, unsigned int *core) -{ - thread_affinity_policy_data_t policy; - - *core = ck_pr_faa_uint(&acb->request, acb->delta) % CORES; - policy.affinity_tag = *core; - return thread_policy_set(mach_thread_self(), - THREAD_AFFINITY_POLICY, - (thread_policy_t)&policy, - THREAD_AFFINITY_POLICY_COUNT); -} -#elif defined(__FreeBSD__) -CK_CC_UNUSED static int -aff_iterate(struct affinity *acb CK_CC_UNUSED) -{ - unsigned int c; - cpuset_t mask; - - c = ck_pr_faa_uint(&acb->request, acb->delta) % CORES; - CPU_ZERO(&mask); - CPU_SET(c, &mask); - return (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, - sizeof(mask), &mask)); -} - -CK_CC_UNUSED static int -aff_iterate_core(struct affinity *acb CK_CC_UNUSED, unsigned int *core) -{ - cpuset_t mask; - - *core = ck_pr_faa_uint(&acb->request, acb->delta) % CORES; - CPU_ZERO(&mask); - CPU_SET(*core, &mask); - return (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, - sizeof(mask), &mask)); -} -#else -CK_CC_UNUSED static int -aff_iterate(struct affinity *acb CK_CC_UNUSED) -{ - - return (0); -} - -CK_CC_UNUSED static int -aff_iterate_core(struct affinity *acb CK_CC_UNUSED, unsigned int *core) -{ - *core = 0; - return (0); -} -#endif - -CK_CC_INLINE static uint64_t -rdtsc(void) -{ -#if defined(__x86_64__) - uint32_t eax = 0, edx; -#if defined(CK_MD_RDTSCP) - __asm__ __volatile__("rdtscp" - : "+a" (eax), "=d" (edx) - : - : "%ecx", "memory"); - - return (((uint64_t)edx << 32) | eax); -#else - __asm__ __volatile__("cpuid;" - "rdtsc;" - : "+a" (eax), "=d" (edx) - : - : "%ebx", "%ecx", "memory"); - - __asm__ __volatile__("xorl %%eax, %%eax;" - "cpuid;" - : - : - : "%eax", "%ebx", "%ecx", "%edx", "memory"); - - return (((uint64_t)edx << 32) | eax); -#endif /* !CK_MD_RDTSCP */ -#elif defined(__x86__) - uint32_t eax = 0, edx; -#if defined(CK_MD_RDTSCP) - __asm__ __volatile__("rdtscp" - : "+a" (eax), "=d" (edx) - : - : "%ecx", "memory"); - - return (((uint64_t)edx << 32) | eax); -#else - __asm__ __volatile__("pushl %%ebx;" - "cpuid;" - "rdtsc;" - : "+a" (eax), "=d" (edx) - : - : "%ecx", "memory"); - - __asm__ __volatile__("xorl %%eax, %%eax;" - "cpuid;" - "popl %%ebx;" - : - : - : "%eax", "%ecx", "%edx", "memory"); - - return (((uint64_t)edx << 32) | eax); -#endif /* !CK_MD_RDTSCP */ -#elif defined(__sparcv9__) - uint64_t r; - - __asm__ __volatile__("rd %%tick, %0" - : "=r" (r) - : - : "memory"); - return r; -#elif defined(__ppc64__) - uint32_t high, low, snapshot; - - do { - __asm__ __volatile__("isync;" - "mftbu %0;" - "mftb %1;" - "mftbu %2;" - : "=r" (high), "=r" (low), "=r" (snapshot) - : - : "memory"); - } while (snapshot != high); - - return (((uint64_t)high << 32) | low); -#else - return 0; -#endif -} - -CK_CC_USED static void -ck_error(const char *message, ...) -{ - va_list ap; - - va_start(ap, message); - vfprintf(stderr, message, ap); - va_end(ap); - exit(EXIT_FAILURE); -} - -#define ck_test(A, B, ...) do { \ - if (A) \ - ck_error(B, ##__VA_ARGS__); \ -} while (0) - -#endif /* CK_COMMON_H */ diff --git a/tools/feature.sh b/tools/feature.sh deleted file mode 100755 index f6c89341629e..000000000000 --- a/tools/feature.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# This will generate the list of feature flags for implemented symbols. - -echo '/* DO NOT EDIT. This is auto-generated from feature.sh */' -nm ../regressions/ck_pr/validate/ck_pr_cas|cut -d ' ' -f 3|sed s/ck_pr/ck_f_pr/|awk '/^ck_f_pr/ {print "#define " toupper($1);}'|sort