-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c3c4d7
commit 5ea2da6
Showing
20 changed files
with
324 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
AUTOMAKE_OPTIONS = foreign | ||
ACLOCAL_AMFLAGS = -I m4 --install | ||
|
||
bin_PROGRAMS = general clone count intersection union disjointunion difference | ||
general_SOURCES = general.cpp | ||
clone_SOURCES = clone.cpp | ||
count_SOURCES = count.cpp | ||
intersection_SOURCES = intersection.cpp | ||
union_SOURCES = union.cpp | ||
disjointunion_SOURCES = disjointunion.cpp | ||
difference_SOURCES = difference.cpp | ||
|
||
AM_CXXFLAGS = -I $(top_builddir) -I $(top_builddir)/inc |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "FastBitset.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
f.set(1); | ||
printf("Initial bitset:\n"); | ||
f.printBitset(); | ||
|
||
FastBitset g = f; | ||
printf("Testing assignment:\n"); | ||
g.printBitset(); | ||
|
||
f.reset(); | ||
g.reset(); | ||
if (f.any() || g.any()) printf("Reset failed.\n"); | ||
else printf("Reset succeeded.\n"); | ||
|
||
for (int i = 1; i < f.size(); i += 2) | ||
f.set(i); | ||
printf("\nTesting clone:\n"); | ||
f.printBitset(); | ||
f.clone(g); | ||
g.printBitset(); | ||
|
||
if (f == g) printf("Equality operation succeeded.\n"); | ||
else printf("Equality failed.\n"); | ||
|
||
printf("\nTesting Partial Clone (1).\n"); | ||
for (int i = 0; i < f.size() >> 1; i++) | ||
f.unset(i); | ||
f.printBitset(); | ||
g.reset(); | ||
f.clone(g, 1, 1); | ||
g.printBitset(); | ||
|
||
printf("\nTesting Partial Clone (2).\n"); | ||
for (int i = 0; i < f.size() >> 1; i++) | ||
f.set(i); | ||
f.printBitset(); | ||
FastBitset h(f.size()); | ||
f.partial_clone(h, 16, 64); | ||
h.printBitset(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "FastBitset.h" | ||
|
||
void countAll(FastBitset &f) | ||
{ | ||
printf("Version 1: %" PRIu64 "\n", f.count_v1()); | ||
printf("Version 2: %" PRIu64 "\n", f.count_v2()); | ||
printf("Version 3: %" PRIu64 "\n", f.count_v3()); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
for (int i = 0; i < f.size(); i += 2) | ||
f.set(i); | ||
|
||
printf("Testing bit counting.\n"); | ||
f.printBitset(); | ||
countAll(f); | ||
|
||
for (int i = f.size() * 3 / 4; i < f.size(); i++) | ||
f.unset(i); | ||
f.printBitset(); | ||
countAll(f); | ||
|
||
for (int i = 0; i < f.size() >> 2; i++) | ||
f.set(i); | ||
f.printBitset(); | ||
countAll(f); | ||
|
||
printf("\nTesting partial count.\n"); | ||
f.reset(); | ||
for (int i = 0; i < f.size() >> 1; i++) | ||
f.set(i); | ||
for (int i = f.size() >> 1; i < f.size(); i += 4) | ||
f.set(i); | ||
f.printBitset(); | ||
printf("First half: %" PRIu64 "\n", f.partial_count(0, 64)); | ||
printf("Middle half: %" PRIu64 "\n", f.partial_count(32, 64)); | ||
printf("Final half: %" PRIu64 "\n", f.partial_count(64, 64)); | ||
|
||
FastBitset g(300); | ||
g.set(); | ||
|
||
printf("\nTesting set().\n"); | ||
printf("Blocks used: %" PRIu64 "\n", g.getNumBlocks()); | ||
printf("Bits set: %" PRIu64 "\n", g.count_bits()); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "FastBitset.h" | ||
|
||
void initialize(FastBitset &f, FastBitset &g) | ||
{ | ||
f.reset(); g.reset(); | ||
for (int i = 0; i < f.size() >> 1; i += 2) | ||
f.set(i); | ||
for (int i = f.size() >> 1; i < f.size(); i++) | ||
f.set(i); | ||
for (int i = 1; i < g.size(); i += 2) | ||
g.set(i); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
FastBitset g(128); | ||
initialize(f, g); | ||
|
||
printf("Testing set difference.\n"); | ||
printf("Version 1:\n"); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setDifference_v1(g); | ||
f.printBitset(); | ||
|
||
#ifdef AVX2_ENABLED | ||
printf("\nVersion 2:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setDifference_v2(g); | ||
f.printBitset(); | ||
#endif | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "FastBitset.h" | ||
|
||
void initialize(FastBitset &f, FastBitset &g) | ||
{ | ||
f.reset(); g.reset(); | ||
for (int i = 0; i < f.size() >> 1; i += 2) | ||
f.set(i); | ||
for (int i = 1; i < g.size(); i += 2) | ||
g.set(i); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
FastBitset g(128); | ||
initialize(f, g); | ||
|
||
printf("Testing set disjoint union.\n"); | ||
printf("Version 1:\n"); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setDisjointUnion_v1(g); | ||
f.printBitset(); | ||
|
||
#ifdef AVX2_ENABLED | ||
printf("\nVersion 2:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setDisjointUnion_v2(g); | ||
f.printBitset(); | ||
#endif | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "FastBitset.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
f.set(1); | ||
f.printBitset(); | ||
printf("Size: %" PRIu64 "\n", f.size()); | ||
printf("Number of Blocks: %" PRIu64 "\n", f.getNumBlocks()); | ||
printf("Block Size: %" PRIu64 "\n", f.getBlockSize()); | ||
|
||
printf("Any set? %s\n", f.any() ? "Yes" : "No"); | ||
printf("Any in first block? %s\n", f.any_in_range(0, 64) ? "Yes" : "No"); | ||
printf("Any in second block? %s\n", f.any_in_range(65, 64) ? "Yes" : "No"); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "FastBitset.h" | ||
|
||
void initialize(FastBitset &f, FastBitset &g) | ||
{ | ||
f.reset(); g.reset(); | ||
for (int i = 0; i < f.size() >> 1; i += 2) | ||
f.set(i); | ||
for (int i = f.size() >> 1; i < f.size(); i++) | ||
f.set(i); | ||
for (int i = 1; i < g.size(); i += 2) | ||
g.set(i); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
FastBitset f(128); | ||
FastBitset g(128); | ||
initialize(f, g); | ||
|
||
printf("Testing set intersection.\n"); | ||
printf("Version 1:\n"); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setIntersection_v1(g); | ||
f.printBitset(); | ||
|
||
#ifdef AVX2_ENABLED | ||
printf("\nVersion 2:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.setIntersection_v2(g); | ||
f.printBitset(); | ||
#endif | ||
|
||
printf("\nTesting partial intersection.\n"); | ||
printf("First half:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.partial_intersection(g, 0, 64); | ||
f.printBitset(); | ||
|
||
printf("\nMiddle half:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.partial_intersection(g, 32, 64); | ||
f.printBitset(); | ||
|
||
printf("\nFinal half:\n"); | ||
initialize(f, g); | ||
f.printBitset(); | ||
g.printBitset(); | ||
f.partial_intersection(g, 64, 64); | ||
f.printBitset(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
set -eu -o pipefail | ||
|
||
./general | ||
echo -e '\n' | ||
./clone | ||
echo -e '\n' | ||
./count | ||
echo -e '\n' | ||
./intersection | ||
echo -e '\n' | ||
./union | ||
echo -e '\n' | ||
./disjointunion | ||
echo -e '\n' | ||
./difference | ||
echo -e '\n' | ||
echo 'Completed all tests on FastBitset.' |
Binary file not shown.
Oops, something went wrong.