ck_bag: Drop support for this data structure.

Could not find suitable use-case and generally doesn't
appear interesting to academics in the existing
form. Maybe it will make a come-back in the future with
fewer memory and latency compromises.
ck_pring
Samy Al Bahra 12 years ago
parent cfd8fd8d4b
commit 0610a0d0a8

@ -67,18 +67,6 @@ OBJECTS=CK_ARRAY_FOREACH \
ck_epoch_reclaim \
ck_epoch_synchronize \
ck_epoch_unregister \
ck_bag_allocator_set \
ck_bag_block_count \
ck_bag_block_next \
ck_bag_count \
ck_bag_destroy \
ck_bag_init \
ck_bag_iterator_init \
ck_bag_member_spmc \
ck_bag_next \
ck_bag_put_spmc \
ck_bag_remove_spmc \
ck_bag_set_spmc \
ck_hs_init \
ck_hs_destroy \
CK_HS_HASH \

@ -1,64 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_ALLOCATOR_SET
.Sh NAME
.Nm ck_bag_allocator_set
.Nd specify ck_bag memory allocation functions
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_allocator_set "struct ck_malloc *m, size_t alloc_overhead"
.Sh DESCRIPTION
The
.Fn ck_bag_allocator_set
function initializes the memory allocation functions used by the ck_bag
implementation according to the function pointers specified by the structure
pointed to by the
.Fa allocator
argument. it is mandatory that this function is called before any other ck_bag operations.
.Sh RETURN VALUES
.Fn ck_bag_allocator_set
returns a value of true, otherwise returns a value of false to indicate failure.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,63 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_BLOCK_COUNT 3
.Sh NAME
.Nm ck_bag_block_count
.Nd determine the number of entries in a ck_bag_block
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft uint16_t
.Fn ck_bag_block_count "struct ck_bag_block *block"
.Sh DESCRIPTION
The
.Fn ck_bag_block_count
function will return the number of entries in a ck_bag_block pointed to by the
.Fa block
argument.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,65 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_BLOCK_NEXT 3
.Sh NAME
.Nm ck_bag_block_next
.Nd extract next pointer from a ck_bag_block
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft struct ck_bag_block *
.Fn ck_bag_block_next "struct ck_bag_block *block"
.Sh DESCRIPTION
The
.Fn ck_bag_block_next
function will return the next pointer extracted from the
.Fa block
argument. On x86_64 platforms, both the number of entries and the next pointer
are stored within a single pointer. For all other platforms, this should be considered
an empty operation.
.Sh ERRORS
Behavior is undefined if
.Fa block
has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,63 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_COUNT 3
.Sh NAME
.Nm ck_bag_count
.Nd determine number of entries in a ck_bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft unsigned int
.Fn ck_bag_count "struct ck_bag *bag"
.Sh DESCRIPTION
The
.Fn ck_bag_count
function will return the number of entries in a ck_bag pointed to by the
.Fa bag
argument.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,68 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_DESTROY 3
.Sh NAME
.Nm ck_bag_destroy
.Nd destroy a ck_bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft void
.Fn ck_bag_destroy "struct ck_bag *bag"
.Sh DESCRIPTION
The
.Fn ck_bag_destroy
function will request the underlying allocator, associated with the ck_bag,
to immediately destroy the ck_bag pointed to by the
.Fa bag
argument
.Pp
The user must guarantee that no other threads are accessing the object pointed to by the
.Fa bag
argument when
.Fn ck_bag_destroy
is called.
.Sh ERRORS
This function will not fail.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,88 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_INIT 3
.Sh NAME
.Nm ck_bag_init
.Nd initialize ck_bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_init "struct ck_bag *bag" "size_t n_cachelines" "enum ck_bag_allocation_strategy as"
.Sh DESCRIPTION
The
.Fn ck_bag_init
function will initialize the object pointed to by the
.Fa bag
argument. If the
.Fa n_cachelines
argument is equivalent to CK_BAG_DEFAULT, then the block_size for the bag will
be CK_BAG_PAGESIZE (CK_MD_PAGESIZE). Otherwise, the block_size for the bag will
be n_cachelines * CK_MD_CACHELINE. The block_size, the number of bytes in a
single ck_bag_block, is set on a bag basis.
.Pp
.Fn ck_bag_init
will return false if the calculated block_size is less than the number of bytes
required by block overhead. Block overhead includes any allocator overhead
established from a previous call to the
.Fn ck_bag_allocator_set
function.
.Fn ck_bag_init
will also return false if you have compiled ck to pointer pack
and the number of entries within a block is greater than CK_BAG_MAX_N_ENTRIES.
On x86_64, CK_BAG_MAX_N_ENTRIES is equal to 4096.
.Sh RETURN VALUES
If
.Fn ck_bag_init
returns true then the object pointed to by the
.Fa bag
argument has been initialized. Otherwise, the object pointed to by the
.Fa bag
argument is not a valid ck_bag.
.Sh ERRORS
Behavior is undefined if
.Fa bag
does not point to a valid ck_bag object or if ck_bag_allocator_set has not been
called previously.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,69 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_ITERATOR_INIT 3
.Sh NAME
.Nm ck_bag_iterator_init
.Nd initialize a ck_bag_iterator
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft void
.Fn ck_bag_iterator_init "ck_bag_iterator_t *iterator, ck_bag_t *bag"
.Sh DESCRIPTION
The
.Fn ck_bag_iterator_init
function will initialize the object pointed to by the
.Fa iterator
argument.
.Pp
An iterator is used to iterate through the entries pointed to by the
.Fa bag
argument by using the
.Fn ck_bag_next
function.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,71 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_MEMBER_SPMC 3
.Sh NAME
.Nm ck_bag_member_spmc
.Nd determine whether a bag contains an entry
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_member_spmc "ck_bag_t *bag, void *entry"
.Sh DESCRIPTION
The
.Fn ck_bag_member_spmc
function will return true if the an item contained within the ck_bag
pointed to by the
.Fa bag
argument is equivalent to the
.Fa entry
argument.
.Sh RETURN VALUES
.Fn ck_bag_member_spmc
returns true if the
.Fa entry
argument was found in the bag, otherwise false.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,75 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_NEXT 3
.Sh NAME
.Nm ck_bag_next
.Nd iterate to the next entry in the ck_bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_next "struct ck_bag_iterator *iterator, void **entry"
.Sh DESCRIPTION
The
.Fn ck_bag_next
function will assign the
.Fa entry
argument the next entry in the ck_bag. It is expected
.Fa iterator
has been initialized using the ck_bag_iterator_init(3) function.
.Sh RETURN VALUES
If
.Fn ck_bag_next
returns true then the object pointed to by
.Fa entry
points to a valid ck_bag entry. If
.Fn ck_bag_next
returns false then the value of
.Fa entry
is undefined.
.Sh ERRORS
Behavior is undefined if the ck_bag_iterator pointed to by the
.Fa iterator
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,71 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_PUT_SPMC 3
.Sh NAME
.Nm ck_bag_put_spmc
.Nd place an item into a bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_put_spmc "ck_bag_t *bag, void *entry"
.Sh DESCRIPTION
The
.Fn ck_bag_put_spmc
function will store the
.Fa entry
argument in the ck_bag pointed to by the
.Fa bag
argument. This function is safe in the presence of concurrent
.Fn ck_bag_next
operations.
.Sh RETURN VALUES
Upon completion
.Fn ck_bag_put_spmc
returns true on if the item has been placed within the bag, otherwise false.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,69 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_REMOVE_SPMC 3
.Sh NAME
.Nm ck_bag_remove_spmc
.Nd remove an entry from a bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_remove_spmc "ck_bag_t *bag, void *entry"
.Sh DESCRIPTION
The
.Fn ck_bag_remove_spmc
function will remove the first item equivalent to the value of the
.Fa entry
argument within the ck_bag pointed to by the
.Fa bag
argument.
.Sh RETURN VALUES
Upon completion
.Fn ck_bag_remove_spmc
returns true if an item in the ck_bag was removed, otherwise false on failure.
.Sh ERRORS
Behavior is undefined if
.Fa bag
has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,80 +0,0 @@
.\"
.\" Copyright 2012-2013 Abel P. Mathew
.\" 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 July 16th, 2012
.Dt CK_BAG_SET_SPMC 3
.Sh NAME
.Nm ck_bag_set_spmc
.Nd replace the first occurence of a value in a bag
.Sh LIBRARY
Concurrency Kit (libck, \-lck)
.Sh SYNOPSIS
.In ck_bag.h
.Ft bool
.Fn ck_bag_set_spmc "ck_bag_t *bag, void *compare, void *update"
.Sh DESCRIPTION
The
.Fn ck_bag_set_spmc
function will find the first occurence of the
.Fa compare
argument in the ck_bag pointed to by the
.Fa bag
argument and replace this entry with the value passed in by the
.Fa update
argument. If the no entries in the
.Fa bag
are equal to the
.Fa compare
argument, then a new entry with the value of
.Fa update
will placed in the bag.
This function is safe in the presence of concurrent
.Fn ck_bag_next
operations.
.Sh RETURN VALUES
Upon completion
.Fn ck_bag_set_spmc
returns true on success, false on failure.
.Sh ERRORS
Behavior is undefined if the ck_bag pointed to by the
.Fa bag
argument has not been initialized.
.Sh SEE ALSO
.Xr ck_bag_allocator_set(3),
.Xr ck_bag_block_next(3),
.Xr ck_bag_destroy(3),
.Xr ck_bag_iterator_init(3),
.Xr ck_bag_next(3),
.Xr ck_bag_remove_spmc(3),
.Xr ck_bag_block_count(3),
.Xr ck_bag_count(3),
.Xr ck_bag_init(3),
.Xr ck_bag_member_spmc(3),
.Xr ck_bag_put_spmc(3),
.Xr ck_bag_set_spmc(3)
.Pp
Additional information available at http://concurrencykit.org/

@ -1,197 +0,0 @@
/*
* Copyright 2012-2013 Abel P. Mathew
* 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 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_BAG_H
#define _CK_BAG_H
#include <ck_cc.h>
#include <ck_malloc.h>
#include <ck_md.h>
#include <ck_pr.h>
#include <ck_queue.h>
#include <ck_stdint.h>
#include <stdbool.h>
#include <stddef.h>
/*
* ck_bag is a lock-free spmc linked list of blocks.
*
* A block consists of:
* next:
* Linkage for bag linked list.
* avail_next, avail_prev:
* Linkage for bag's available linked list (to support 0(1) inserts).
* array:
* flexible array member.
*
* The top 3 bytes of "next" contain the # of entries within block->array.
*
* Valid entries in block->array are contigious and stored at the front
* of the array. Empty entries are stored at the back.
*/
/*
* Bag growth strategies.
*/
enum ck_bag_allocation_strategy {
CK_BAG_ALLOCATE_GEOMETRIC = 0,
CK_BAG_ALLOCATE_LINEAR
};
/*
* max: max n_entries per block
* bytes: sizeof(ck_bag_block) + sizeof(flex. array member)
* + inline allocator overhead
*/
struct ck_bag_block_info {
size_t max;
size_t bytes;
};
/*
* Determine whether pointer packing should be enabled.
*/
#if defined(CK_MD_POINTER_PACK_ENABLE) && defined(CK_MD_VMA_BITS)
#define CK_BAG_PP
#endif
#define CK_BAG_DEFAULT 0
struct ck_bag_block_md {
#ifdef CK_BAG_PP
struct ck_bag_block *ptr;
#else
struct ck_bag_block *ptr;
uintptr_t n_entries CK_CC_PACKED;
#endif
};
struct ck_bag_block {
struct ck_bag_block_md next;
CK_LIST_ENTRY(ck_bag_block) avail_entry;
void *array[];
} CK_CC_CACHELINE;
struct ck_bag {
struct ck_bag_block *head;
CK_LIST_HEAD(avail_list, ck_bag_block) avail_blocks;
unsigned int n_entries;
unsigned int n_blocks;
enum ck_bag_allocation_strategy alloc_strat;
struct ck_bag_block_info info;
};
typedef struct ck_bag ck_bag_t;
struct ck_bag_iterator {
struct ck_bag_block *block;
uint16_t index;
uint16_t n_entries;
};
typedef struct ck_bag_iterator ck_bag_iterator_t;
#ifdef CK_BAG_PP
#define CK_BAG_BLOCK_ENTRIES_MASK (~(uintptr_t)0 << CK_MD_VMA_BITS)
#endif
CK_CC_INLINE static struct ck_bag_block *
ck_bag_block_next(struct ck_bag_block *block)
{
#ifdef CK_BAG_PP
return (struct ck_bag_block *)((uintptr_t)block & ~CK_BAG_BLOCK_ENTRIES_MASK);
#else
return block;
#endif
}
CK_CC_INLINE static unsigned int
ck_bag_count(struct ck_bag *bag)
{
return ck_pr_load_uint(&bag->n_entries);
}
CK_CC_INLINE static uint16_t
ck_bag_block_count(struct ck_bag_block *block)
{
#ifdef CK_BAG_PP
return (uintptr_t)ck_pr_load_ptr(&block->next.ptr) >> CK_MD_VMA_BITS;
#else
return (uintptr_t)ck_pr_load_ptr(&block->next.n_entries);
#endif
}
CK_CC_INLINE static void
ck_bag_iterator_init(ck_bag_iterator_t *iterator, ck_bag_t *bag)
{
iterator->block = ck_pr_load_ptr(&bag->head);
iterator->index = 0;
iterator->n_entries = 0;
if (iterator->block != NULL)
iterator->n_entries = ck_bag_block_count(iterator->block);
return;
}
CK_CC_INLINE static bool
ck_bag_next(struct ck_bag_iterator *iterator, void **entry)
{
struct ck_bag_block *next;
if (iterator->block == NULL)
return NULL;
if (iterator->index >= iterator->n_entries) {
next = ck_pr_load_ptr(&iterator->block->next.ptr);
iterator->block = ck_bag_block_next(next);
if (iterator->block == NULL)
return false;
iterator->n_entries = ck_bag_block_count(iterator->block);
if (iterator->n_entries == 0)
return false;
iterator->index = 0;
ck_pr_fence_load();
}
*entry = ck_pr_load_ptr(&iterator->block->array[iterator->index++]);
return true;
}
bool ck_bag_init(struct ck_bag *, size_t, enum ck_bag_allocation_strategy);
bool ck_bag_allocator_set(struct ck_malloc *, size_t);
void ck_bag_destroy(ck_bag_t *);
bool ck_bag_put_spmc(ck_bag_t *, void *);
bool ck_bag_set_spmc(struct ck_bag *, void *, void *);
bool ck_bag_remove_spmc(ck_bag_t *, void *);
bool ck_bag_member_spmc(ck_bag_t *, void *);
#endif /* _CK_BAG_H */

@ -1,6 +1,5 @@
DIR=array \
backoff \
bag \
barrier \
bitmap \
brlock \
@ -60,7 +59,6 @@ all:
$(MAKE) -C ./ck_pflock/benchmark all
$(MAKE) -C ./ck_hp/validate all
$(MAKE) -C ./ck_hp/benchmark all
$(MAKE) -C ./ck_bag/validate all
clean:
$(MAKE) -C ./ck_array/validate clean
@ -102,7 +100,6 @@ clean:
$(MAKE) -C ./ck_pflock/benchmark clean
$(MAKE) -C ./ck_hp/validate clean
$(MAKE) -C ./ck_hp/benchmark clean
$(MAKE) -C ./ck_bag/validate clean
check: all
rc=0; \

@ -1,17 +0,0 @@
.PHONY: check clean distribution
OBJECTS=order
all: $(OBJECTS)
order: order.c ../../../include/ck_bag.h ../../../src/ck_bag.c ../../../src/ck_epoch.c
$(CC) $(CFLAGS) -o order order.c ../../../src/ck_bag.c ../../../src/ck_epoch.c
check: all
./order
clean:
rm -rf *.dSYM *.exe *~ *.o $(OBJECTS)
include ../../../build/regressions.build
CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE

@ -1,294 +0,0 @@
/*
* Copyright 2012-2013 Abel P. Mathew
* 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 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 <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <ck_bag.h>
#include <ck_epoch.h>
#include "../../common.h"
#define NUM_READER_THREADS 2
#define READ_LATENCY 8
static ck_bag_t bag;
static ck_epoch_t epoch_bag;
static ck_epoch_record_t epoch_wr;
static int leave;
static unsigned int barrier;
static unsigned int writer_max = 32768;
struct bag_epoch {
ck_epoch_entry_t epoch_entry;
};
static void
bag_destroy(ck_epoch_entry_t *e)
{
free(e);
return;
}
static void *
bag_malloc(size_t r)
{
struct bag_epoch *b;
b = malloc(sizeof(*b) + r);
return b + 1;
}
static void
bag_free(void *p, size_t b, bool r)
{
struct bag_epoch *e = p;
(void)b;
if (r == true) {
ck_epoch_call(&epoch_bag, &epoch_wr, &(--e)->epoch_entry, bag_destroy);
} else {
free(--e);
}
return;
}
static struct ck_malloc allocator = {
.malloc = bag_malloc,
.free = bag_free
};
static void *
reader(void *arg)
{
void *curr_ptr;
intptr_t curr, prev, curr_max, prev_max;
unsigned long long n_entries = 0, iterations = 0;
ck_epoch_record_t epoch_record;
ck_bag_iterator_t iterator;
struct ck_bag_block *block = NULL;
(void)arg;
ck_epoch_register(&epoch_bag, &epoch_record);
/*
* Check if entries within a block are sequential. Since ck_bag inserts
* newly occupied blocks at the beginning of the list, there is no ordering
* guarantee across the bag.
*/
for (;;) {
ck_epoch_begin(&epoch_bag, &epoch_record);
ck_bag_iterator_init(&iterator, &bag);
curr_max = prev_max = prev = -1;
block = NULL;
while (ck_bag_next(&iterator, &curr_ptr) == true) {
if (block != iterator.block) {
prev = -1;
curr = 0;
prev_max = curr_max;
curr_max = 0;
block = iterator.block;
}
curr = (uintptr_t)(curr_ptr);
if (curr < prev) {
/* Ascending order within block violated */
ck_error("%p: %p: %ju\nERROR: %ju < %ju\n",
(void *)&epoch_record, (void *)iterator.block, (uintmax_t)curr, (uintmax_t)curr, (uintmax_t)prev);
} else if (prev_max != -1 && curr > prev_max) {
/* Max of prev block > max of current block */
ck_error("%p: %p: %ju\nERROR: %ju > %ju\n",
(void *)&epoch_record, (void *)iterator.block, (uintmax_t)curr, (uintmax_t)curr, (uintmax_t)prev_max);
}
curr_max = curr;
prev = curr;
n_entries++;
}
ck_epoch_end(&epoch_bag, &epoch_record);
iterations++;
if (ck_pr_load_int(&leave) == 1)
break;
}
fprintf(stderr, "Read %llu entries in %llu iterations.\n", n_entries, iterations);
ck_pr_inc_uint(&barrier);
while (ck_pr_load_uint(&barrier) != NUM_READER_THREADS + 1)
ck_pr_stall();
return NULL;
}
static void *
writer_thread(void *unused)
{
unsigned int i;
unsigned int iteration = 0;
(void)unused;
for (;;) {
iteration++;
for (i = 1; i <= writer_max; i++) {
if (ck_bag_put_spmc(&bag, (void *)(uintptr_t)i) == false) {
perror("ck_bag_put_spmc");
exit(EXIT_FAILURE);
}
if (ck_bag_member_spmc(&bag, (void *)(uintptr_t)i) == false) {
ck_error("ck_bag_put_spmc [%u]: %u\n", iteration, i);
}
}
if (ck_pr_load_int(&leave) == 1)
break;
for (i = 1; i < writer_max; i++) {
void *replace = (void *)(uintptr_t)i;
if (ck_bag_set_spmc(&bag, (void *)(uintptr_t)i, replace) == false) {
ck_error("ERROR: set %ju != %ju",
(uintmax_t)(uintptr_t)replace, (uintmax_t)i);
}
}
for (i = writer_max; i > 0; i--) {
if (ck_bag_member_spmc(&bag, (void *)(uintptr_t)i) == false) {
ck_error("ck_bag_member_spmc [%u]: %u\n", iteration, i);
}
if (ck_bag_remove_spmc(&bag, (void *)(uintptr_t)i) == false) {
ck_error("ck_bag_remove_spmc [%u]: %u\n", iteration, i);
}
}
ck_epoch_poll(&epoch_bag, &epoch_wr);
}
fprintf(stderr, "Writer %u iterations, %u writes per iteration.\n", iteration, writer_max);
while (ck_pr_load_uint(&barrier) != NUM_READER_THREADS)
ck_pr_stall();
ck_pr_inc_uint(&barrier);
return NULL;
}
int
main(int argc, char **argv)
{
pthread_t *readers;
pthread_t writer;
unsigned int i, curr;
void *curr_ptr;
ck_bag_iterator_t bag_it;
size_t b = CK_BAG_DEFAULT;
if (argc >= 2) {
int r = atoi(argv[1]);
if (r <= 0) {
ck_error("# entries in block must be > 0\n");
}
b = (size_t)r;
}
if (argc >= 3) {
int r = atoi(argv[2]);
if (r < 16) {
ck_error("# entries must be >= 16\n");
}
writer_max = (unsigned int)r;
}
ck_epoch_init(&epoch_bag);
ck_epoch_register(&epoch_bag, &epoch_wr);
ck_bag_allocator_set(&allocator, sizeof(struct bag_epoch));
if (ck_bag_init(&bag, b, CK_BAG_ALLOCATE_GEOMETRIC) == false) {
ck_error("Error: failed ck_bag_init().");
}
fprintf(stderr, "Configuration: %u entries, %zu bytes/block, %zu entries/block\n", writer_max, bag.info.bytes, bag.info.max);
i = 1;
/* Basic Test */
ck_bag_put_spmc(&bag, (void *)(uintptr_t)i);
ck_bag_remove_spmc(&bag, (void *)(uintptr_t)i);
ck_bag_put_spmc(&bag, (void *)(uintptr_t)i);
/* Sequential test */
for (i = 1; i <= 10; i++)
ck_bag_put_spmc(&bag, (void *)(uintptr_t)i);
for (i = 1; i <= 10; i++)
ck_bag_remove_spmc(&bag, (void *)(uintptr_t)i);
for (i = 10; i > 0; i--)
ck_bag_remove_spmc(&bag, (void *)(uintptr_t)i);
for (i = 1; i <= 10; i++)
ck_bag_put_spmc(&bag, (void *)(uintptr_t)i);
ck_bag_iterator_init(&bag_it, &bag);
while (ck_bag_next(&bag_it, &curr_ptr)) {
curr = (uintptr_t)(curr_ptr);
if (curr > (uintptr_t)i)
ck_error("ERROR: %ju != %u\n", (uintmax_t)curr, i);
ck_bag_remove_spmc(&bag, curr_ptr);
}
/* Concurrent test */
pthread_create(&writer, NULL, writer_thread, NULL);
readers = malloc(sizeof(pthread_t) * NUM_READER_THREADS);
for (i = 0; i < NUM_READER_THREADS; i++) {
pthread_create(&readers[i], NULL, reader, NULL);
}
fprintf(stderr, "Waiting...");
common_sleep(30);
fprintf(stderr, "done\n");
ck_pr_store_int(&leave, 1);
for (i = 0; i < NUM_READER_THREADS; i++)
pthread_join(readers[i], NULL);
pthread_join(writer, NULL);
fprintf(stderr, "Current entries: %u\n", ck_bag_count(&bag));
ck_bag_destroy(&bag);
return 0;
}

@ -15,7 +15,6 @@ OBJECTS=ck_barrier_centralized.o \
ck_epoch.o \
ck_ht.o \
ck_hp.o \
ck_bag.o \
ck_hs.o \
ck_array.o
@ -30,9 +29,6 @@ libck.a: $(OBJECTS)
ck_array.o: $(INCLUDE_DIR)/ck_array.h $(SDIR)/ck_array.c
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_array.o $(SDIR)/ck_array.c
ck_bag.o: $(INCLUDE_DIR)/ck_bag.h $(SDIR)/ck_bag.c
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_bag.o $(SDIR)/ck_bag.c
ck_epoch.o: $(INCLUDE_DIR)/ck_epoch.h $(SDIR)/ck_epoch.c
$(CC) $(CFLAGS) -c -o $(TARGET_DIR)/ck_epoch.o $(SDIR)/ck_epoch.c

@ -1,340 +0,0 @@
/*
* Copyright 2012-2013 Abel P. Mathew
* 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 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 <ck_bag.h>
#include <ck_cc.h>
#include <ck_md.h>
#include <ck_pr.h>
#include <ck_malloc.h>
#include <ck_stdint.h>
#include <stdbool.h>
#include <string.h>
#define CK_BAG_PAGESIZE CK_MD_PAGESIZE
#ifdef CK_BAG_PP
#define CK_BAG_MAX_N_ENTRIES (1 << ((sizeof(void *) * 8) - CK_MD_VMA_BITS))
#endif
static struct ck_malloc allocator;
static size_t allocator_overhead;
bool
ck_bag_init(struct ck_bag *bag,
size_t n_cachelines,
enum ck_bag_allocation_strategy as)
{
size_t block_overhead, block_size;
CK_LIST_INIT(&bag->avail_blocks);
bag->head = NULL;
bag->n_entries = 0;
bag->n_blocks = 0;
bag->alloc_strat = as;
block_overhead = sizeof(struct ck_bag_block) + allocator_overhead;
block_size = (n_cachelines == CK_BAG_DEFAULT) ?
CK_BAG_PAGESIZE : n_cachelines * CK_MD_CACHELINE;
if (block_size < block_overhead)
return false;
bag->info.max = (block_size / sizeof(void *));
#ifdef CK_BAG_PP
if (bag->info.max > CK_BAG_MAX_N_ENTRIES)
return false;
#endif
bag->info.bytes = block_overhead + sizeof(void *) * bag->info.max;
return true;
}
void
ck_bag_destroy(struct ck_bag *bag)
{
struct ck_bag_block *cursor = NULL;
/*
* Free unoccupied blocks on the available list that are not linked to the
* bag list.
*/
CK_LIST_FOREACH(cursor, &bag->avail_blocks, avail_entry) {
if (ck_bag_block_count(cursor) == 0) {
CK_LIST_REMOVE(cursor, avail_entry);
allocator.free(cursor, bag->info.bytes, false);
}
}
cursor = bag->head;
while (bag->head != NULL) {
cursor = bag->head;
bag->head = ck_bag_block_next(cursor->next.ptr);
allocator.free(cursor, bag->info.bytes, false);
}
return;
}
bool
ck_bag_allocator_set(struct ck_malloc *m, size_t alloc_overhead)
{
if (m->malloc == NULL || m->free == NULL)
return false;
allocator = *m;
allocator_overhead = alloc_overhead;
return true;
}
bool
ck_bag_put_spmc(struct ck_bag *bag, void *entry)
{
struct ck_bag_block *cursor, *new_block, *new_bag_head, *prev_block;
uint16_t n_entries_block;
size_t blocks_alloc, i;
uintptr_t next = 0;
new_block = new_bag_head = prev_block = NULL;
cursor = CK_LIST_FIRST(&bag->avail_blocks);
if (cursor != NULL) {
n_entries_block = ck_bag_block_count(cursor);
} else {
/* The bag is full, allocate a new set of blocks */
prev_block = CK_LIST_FIRST(&bag->avail_blocks);
if (bag->alloc_strat == CK_BAG_ALLOCATE_GEOMETRIC)
blocks_alloc = (bag->n_blocks + 1) << 1;
else
blocks_alloc = 1;
for (i = 0; i < blocks_alloc; i++) {
new_block = allocator.malloc(bag->info.bytes);
if (new_block == NULL)
return false;
#ifdef CK_BAG_PP
new_block->next.ptr = NULL;
#else
new_block->next.n_entries = 0;
#endif
if (i == 0) {
new_bag_head = new_block;
CK_LIST_INSERT_HEAD(&bag->avail_blocks, new_block, avail_entry);
} else {
CK_LIST_INSERT_AFTER(prev_block, new_block, avail_entry);
}
prev_block = new_block;
}
cursor = new_bag_head;
n_entries_block = 0;
bag->n_blocks += blocks_alloc;
}
cursor->array[n_entries_block++] = entry;
ck_pr_fence_store();
#ifdef CK_BAG_PP
next = ((uintptr_t)n_entries_block << CK_MD_VMA_BITS);
#endif
if (n_entries_block == 1) {
/* Place newly filled block at the head of bag list */
if (bag->head != NULL) {
#ifdef CK_BAG_PP
next += ((uintptr_t)(void *)ck_bag_block_next(bag->head));
#else
next = (uintptr_t)(void *)ck_bag_block_next(bag->head);
#endif
}
#ifndef CK_BAG_PP
ck_pr_store_ptr(&cursor->next.n_entries, (void *)(uintptr_t)n_entries_block);
#endif
ck_pr_store_ptr(&cursor->next.ptr, (void *)next);
ck_pr_store_ptr(&bag->head, cursor);
} else {
/* Block is already on bag list, update n_entries */
#ifdef CK_BAG_PP
next += ((uintptr_t)(void *)ck_bag_block_next(cursor->next.ptr));
ck_pr_store_ptr(&cursor->next, (void *)next);
#else
ck_pr_store_ptr(&cursor->next.n_entries, (void *)(uintptr_t)n_entries_block);
#endif
/* the block is full, remove from available_list */
if (n_entries_block == bag->info.max) {
CK_LIST_REMOVE(cursor, avail_entry);
}
}
ck_pr_store_uint(&bag->n_entries, bag->n_entries + 1);
return true;
}
/*
* Replace prev_entry with new entry if exists, otherwise insert into bag.
*/
bool
ck_bag_set_spmc(struct ck_bag *bag, void *compare, void *update)
{
struct ck_bag_block *cursor;
uint16_t block_index;
uint16_t n_entries_block = 0;
cursor = bag->head;
while (cursor != NULL) {
n_entries_block = ck_bag_block_count(cursor);
for (block_index = 0; block_index < n_entries_block; block_index++) {
if (cursor->array[block_index] != compare)
continue;
ck_pr_store_ptr(&cursor->array[block_index], update);
return true;
}
cursor = ck_bag_block_next(cursor->next.ptr);
}
return ck_bag_put_spmc(bag, update);
}
bool
ck_bag_remove_spmc(struct ck_bag *bag, void *entry)
{
struct ck_bag_block *cursor, *copy, *prev;
uint16_t block_index, n_entries;
cursor = bag->head;
prev = NULL;
while (cursor != NULL) {
n_entries = ck_bag_block_count(cursor);
for (block_index = 0; block_index < n_entries; block_index++) {
if (cursor->array[block_index] == entry)
goto found;
}
prev = cursor;
cursor = ck_bag_block_next(cursor->next.ptr);
}
return true;
found:
/* Cursor points to containing block, block_index is index of deletion */
if (n_entries == 1) {
if (prev == NULL) {
struct ck_bag_block *new_head = ck_bag_block_next(cursor->next.ptr);
ck_pr_store_ptr(&bag->head, new_head);
} else {
uintptr_t next;
#ifdef CK_BAG_PP
next = ((uintptr_t)prev->next.ptr & (CK_BAG_BLOCK_ENTRIES_MASK)) |
(uintptr_t)(void *)ck_bag_block_next(cursor->next.ptr);
#else
next = (uintptr_t)(void *)cursor->next.ptr;
#endif
ck_pr_store_ptr(&prev->next.ptr, (struct ck_bag_block *)next);
}
CK_LIST_REMOVE(cursor, avail_entry);
bag->n_blocks--;
} else {
uintptr_t next_ptr;
copy = allocator.malloc(bag->info.bytes);
if (copy == NULL)
return false;
memcpy(copy, cursor, bag->info.bytes);
copy->array[block_index] = copy->array[--n_entries];
next_ptr = (uintptr_t)(void *)ck_bag_block_next(copy->next.ptr);
#ifdef CK_BAG_PP
copy->next.ptr = (void *)(((uintptr_t)n_entries << CK_MD_VMA_BITS) | next_ptr);
#else
copy->next.n_entries = n_entries;
copy->next.ptr = (struct ck_bag_block *)next_ptr;
#endif
ck_pr_fence_store();
if (prev == NULL) {
ck_pr_store_ptr(&bag->head, copy);
} else {
#ifdef CK_BAG_PP
uintptr_t next = ((uintptr_t)prev->next.ptr & (CK_BAG_BLOCK_ENTRIES_MASK)) |
(uintptr_t)(void *)ck_bag_block_next(copy);
ck_pr_store_ptr(&prev->next.ptr, (struct ck_bag_block *)next);
#else
ck_pr_store_ptr(&prev->next.ptr, copy);
#endif
}
if (n_entries != bag->info.max-1) {
/* Only remove cursor if it was previously on the avail_list */
CK_LIST_REMOVE(cursor, avail_entry);
}
CK_LIST_INSERT_HEAD(&bag->avail_blocks, copy, avail_entry);
}
allocator.free(cursor, sizeof(struct ck_bag_block), true);
ck_pr_store_uint(&bag->n_entries, bag->n_entries - 1);
return true;
}
bool
ck_bag_member_spmc(struct ck_bag *bag, void *entry)
{
struct ck_bag_block *cursor;
uint16_t block_index, n_entries;
if (bag->head == NULL)
return NULL;
cursor = ck_pr_load_ptr(&bag->head);
while (cursor != NULL) {
n_entries = ck_bag_block_count(cursor);
for (block_index = 0; block_index < n_entries; block_index++) {
if (ck_pr_load_ptr(&cursor->array[block_index]) == entry)
return true;
}
cursor = ck_bag_block_next(ck_pr_load_ptr(&cursor->next));
}
return false;
}
Loading…
Cancel
Save