Skip to content

Commit

Permalink
relicensed to MIT; added benching shell script; cleaned up some nits
Browse files Browse the repository at this point in the history
  • Loading branch information
BartMassey committed Feb 17, 2018
1 parent 8f48636 commit bdf1cb9
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 717 deletions.
679 changes: 0 additions & 679 deletions COPYING

This file was deleted.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Copyright (c) 2018 Bart Massey
#
# [This program is licensed under the GPL version 3 or later.]
# Please see the file COPYING in the source
# [This program is licensed under the "MIT License"]
# Please see the file LICENSE in the source
# distribution of this software for license terms.

[package]
name = "popcount"
version = "0.0.1"
authors = [ "Bart Massey <[email protected]>" ]
license-file = "COPYING"
license-file = "LICENSE"

[[bin]]
name = "popcount_rs"
Expand Down
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright © 2018 Bart Massey

[This program is licensed under the "MIT License"]

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2014 Bart Massey
# ALL RIGHTS RESERVED
# [This program is licensed under the GPL version 3 or later.]
# Please see the file COPYING in the source
# [This program is licensed under the "MIT License"]
# Please see the file LICENSE in the source
# distribution of this software for license terms.

GCC = gcc -O4
Expand Down
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Popcount
Copyright &copy; 2007 Bart Massey
2018-02-16
2018-02-17

Here's some implementations of bit population count in C and
Rust, with benchmarks.
Expand Down Expand Up @@ -106,9 +106,8 @@ I gave in March 2014. Enjoy.

## License

This work is made available under the GPL version 3 or
later. Please see the file COPYING in this distribution for
license terms.
This work is made available under the "MIT License". Please
see the file LICENSE in this distribution for license terms.

## Notes and Results

Expand All @@ -117,11 +116,11 @@ current entry, then older entries in chronological order.

### Benchmark Results

Performance as of 2018-02-16. GCC 7.3.0, Clang 4.1.0-10,
Rustc 1.24.0-nightly 2018-01-01. Intel Core i7-4770K
Performance as of 2018-02-17. GCC 7.3.0, Clang 4.1.0-10,
Rustc 1.25.0-nightly 2018-02-04. Intel Core i7-4770K
(Haswell) CPU @ 3.50GHz. <blockquote>

$ for i in popcount_gcc popcount_clang popcount_rs ; do echo $i; ./$i 1000000 ;done
$ sh run-bench.sh

popcount_gcc
popcount_naive: 6.25e+07 iters in 926 msecs for 14.82 nsecs/iter
Expand Down Expand Up @@ -158,25 +157,25 @@ Rustc 1.24.0-nightly 2018-01-01. Intel Core i7-4770K
50332463787

popcount_rs
popcount_naive: 6.25e7 iters in 1068 msecs for 17.09 nsecs/iter
popcount_naive: 6.25e7 iters in 1065 msecs for 17.04 nsecs/iter
popcount_8: 2.5e8 iters in 1206 msecs for 4.82 nsecs/iter
popcount_6: 2.5e8 iters in 1158 msecs for 4.63 nsecs/iter
popcount_hakmem: 2.5e8 iters in 1335 msecs for 5.34 nsecs/iter
popcount_keane: 2.5e8 iters in 1236 msecs for 4.94 nsecs/iter
popcount_anderson: 1.66666e8 iters in 1151 msecs for 6.91 nsecs/iter
popcount_3: 2.5e8 iters in 1031 msecs for 4.12 nsecs/iter
popcount_4: 2.5e8 iters in 1011 msecs for 4.04 nsecs/iter
popcount_2: 2.5e8 iters in 1040 msecs for 4.16 nsecs/iter
popcount_6: 2.5e8 iters in 1159 msecs for 4.64 nsecs/iter
popcount_hakmem: 2.5e8 iters in 1340 msecs for 5.36 nsecs/iter
popcount_keane: 2.5e8 iters in 1238 msecs for 4.95 nsecs/iter
popcount_anderson: 1.66666e8 iters in 1160 msecs for 6.96 nsecs/iter
popcount_3: 2.5e8 iters in 1027 msecs for 4.11 nsecs/iter
popcount_4: 2.5e8 iters in 1010 msecs for 4.04 nsecs/iter
popcount_2: 2.5e8 iters in 1037 msecs for 4.15 nsecs/iter
popcount_mult: 2.5e8 iters in 986 msecs for 3.95 nsecs/iter
popcount_tabular_8: 2.5e8 iters in 835 msecs for 3.34 nsecs/iter
popcount_tabular_16: 2.5e8 iters in 1450 msecs for 5.80 nsecs/iter
popcount_rs: 1e9 iters in 1290 msecs for 1.29 nsecs/iter
popcount_x86: 1e9 iters in 1292 msecs for 1.29 nsecs/iter
popcount_tabular_8: 2.5e8 iters in 814 msecs for 3.26 nsecs/iter
popcount_tabular_16: 2.5e8 iters in 1196 msecs for 4.78 nsecs/iter
popcount_rs: 1e9 iters in 1289 msecs for 1.29 nsecs/iter
popcount_x86: 1e9 iters in 1291 msecs for 1.29 nsecs/iter
50332463787

</blockquote>

### 2018-02-16
### 2018-02-18

I replaced the C and Rust standard random number generators
with a common linear congruential PRNG seeded
Expand All @@ -194,11 +193,14 @@ care. Patches welcome.
After some work, the C and Rust versions run identical
benchmarks in identical order and produce an identical total
popcount. They are thus as comparable as I know how to make
them.
them. I added a benchmarking shell script.

I reorganized this README to be in some sane order and
cleaned it up quite a lot.

I relicensed to MIT. This should make it easier for folks to
embed these popcounts in random open source things.

### 2007-11-27

Of the things I tried the one that seemed to be
Expand Down
6 changes: 2 additions & 4 deletions popcount.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*
* Copyright (c) 2007 Bart Massey
* ALL RIGHTS RESERVED
*
* [This program is licensed under the GPL version 3 or later.]
* Please see the file COPYING in the source
* [This program is licensed under the "MIT License"]
* Please see the file LICENSE in the source
* distribution of this software for license terms.
*/

Expand Down
5 changes: 2 additions & 3 deletions popcount.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) 2018 Bart Massey
//
// [This program is licensed under the GPL version 3 or later.]
// Please see the file COPYING in the source
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.

#![feature(asm)]
Expand Down
6 changes: 3 additions & 3 deletions run-bench.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh
# Copyright © 2018 Bart Massey
# [This program is licensed under the GPL version 3 or later.]
# Please see the file COPYING in the source
# [This program is licensed under the "MIT License"]
# Please see the file LICENSE in the source
# distribution of this software for license terms.

for i in popcount_gcc popcount_clang popcount_rs
do
echo ""
echo $i
./$i 1000000
echo ""
done

0 comments on commit bdf1cb9

Please sign in to comment.