Skip to content

Commit 487dc7b

Browse files
committed
init commit
0 parents  commit 487dc7b

File tree

139 files changed

+318001
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+318001
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.o
2+
*.a
3+
*.out
4+
*.rar
5+
*.zip
6+
*.json
7+
.vscode
8+
vgcore.*
9+
log/
10+
# Temporary
11+
*.html
12+
*.txt

00_makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
OptimizationLevel = -O2
2+
3+
AllWarnings = -Wall -Wextra -pedantic
4+
SomeWarnings = -Wall
5+
LittleWarnings =
6+
NoWarnings = -w
7+
8+
Linker =
9+
Compiler = $(OptimizationLevel) -DNDEBUG -DDEBUG $(NoWarnings)
10+
11+
SrcDir = src
12+
BinDir = bin
13+
IntDir = $(BinDir)/intermediates
14+
LibDir = libs
15+
VerDir = 00_compare_hashes
16+
17+
Libs = $(wildcard $(LibDir)/*.a)
18+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h) .FORCE
19+
Objs = $(IntDir)/$(VerDir)/main.o $(IntDir)/file_loader.o $(IntDir)/dictionary.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
20+
Exec = 00_compare_hashes.out
21+
22+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
23+
g++ -o $(BinDir)/$(Exec) $(Linker) $(Objs) $(Libs)
24+
25+
$(IntDir)/$(VerDir)/main.o: $(SrcDir)/$(VerDir)/main.cpp $(Deps)
26+
g++ -o $(IntDir)/$(VerDir)/main.o -c $(SrcDir)/$(VerDir)/main.cpp $(Compiler)
27+
28+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
29+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
30+
31+
$(IntDir)/dictionary.o: $(SrcDir)/dictionary.cpp $(Deps)
32+
g++ -o $(IntDir)/dictionary.o -c $(SrcDir)/dictionary.cpp $(Compiler)
33+
34+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
35+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
36+
37+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
38+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
39+
40+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
41+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)
42+
43+
.FORCE:

00_makefile_speed_tests

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
OptimizationLevel = -O2
2+
3+
AllWarnings = -Wall -Wextra -pedantic
4+
SomeWarnings = -Wall
5+
LittleWarnings =
6+
NoWarnings = -w
7+
8+
Linker = $(OptimizationLevel)
9+
Compiler = $(OptimizationLevel) -DNDEBUG $(NoWarnings)
10+
11+
SrcDir = src
12+
BinDir = bin
13+
IntDir = $(BinDir)/intermediates
14+
LibDir = libs
15+
VerDir = 00_compare_hashes
16+
17+
Libs = $(wildcard $(LibDir)/*.a)
18+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h) .FORCE
19+
Objs = $(IntDir)/$(VerDir)/main_speed_tests.o $(IntDir)/hash_functions.o
20+
Exec = 00_speed_tests.out
21+
22+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
23+
g++ -o $(BinDir)/$(Exec) $(Linker) $(Objs) $(Libs)
24+
25+
$(IntDir)/$(VerDir)/main_speed_tests.o: $(SrcDir)/$(VerDir)/main_speed_tests.cpp $(Deps)
26+
g++ -o $(IntDir)/$(VerDir)/main_speed_tests.o -c $(SrcDir)/$(VerDir)/main_speed_tests.cpp $(Compiler)
27+
28+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
29+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)
30+
31+
.FORCE:

00_run.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
MAIN_LEVEL=1
2+
3+
###################################
4+
echo ""
5+
echo "====Testing distributions of hash functions===="
6+
make -f 00_makefile OptimizationLevel=-O$MAIN_LEVEL
7+
echo ""
8+
9+
cd bin
10+
./00_compare_hashes.out
11+
cd ..
12+
###################################
13+
14+
##################################
15+
OUTPUT_SPEED_TEST=res/00_compare_hashes/speed_comparison.txt
16+
17+
echo "" > bin/$OUTPUT_SPEED_TEST
18+
19+
for level in {0..3}
20+
do
21+
echo "====Testing speed of hash functions -O$level====" >> bin/$OUTPUT_SPEED_TEST
22+
make -f 00_makefile_speed_tests OptimizationLevel=-O$level >> bin/$OUTPUT_SPEED_TEST
23+
24+
cd bin
25+
./00_speed_tests.out >> $OUTPUT_SPEED_TEST
26+
cd ..
27+
echo "" >> bin/$OUTPUT_SPEED_TEST
28+
echo "" >> bin/$OUTPUT_SPEED_TEST
29+
done
30+
##################################

01_makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
AllWarnings = -Wall -Wextra -pedantic
2+
SomeWarnings = -Wall
3+
LittleWarnings =
4+
NoWarnings =
5+
6+
Linker =
7+
Compiler = -O1 $(NoWarnings)
8+
9+
SrcDir = src
10+
BinDir = bin
11+
IntDir = $(BinDir)/intermediates
12+
LibDir = libs
13+
VerDir = 01_define
14+
15+
Libs = $(wildcard $(LibDir)/*.a)
16+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h)
17+
Objs = $(IntDir)/$(VerDir)/main.o $(IntDir)/$(VerDir)/html_writer.o $(IntDir)/file_loader.o $(IntDir)/dictionary.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
18+
Exec = define.out
19+
20+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
21+
g++ -o $(BinDir)/$(Exec) $(Linker) $(Objs) $(Libs)
22+
23+
$(IntDir)/$(VerDir)/main.o: $(SrcDir)/$(VerDir)/main.cpp $(Deps)
24+
g++ -o $(IntDir)/$(VerDir)/main.o -c $(SrcDir)/$(VerDir)/main.cpp $(Compiler)
25+
26+
$(IntDir)/$(VerDir)/html_writer.o: $(SrcDir)/$(VerDir)/html_writer.cpp $(Deps)
27+
g++ -o $(IntDir)/$(VerDir)/html_writer.o -c $(SrcDir)/$(VerDir)/html_writer.cpp $(Compiler)
28+
29+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
30+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
31+
32+
$(IntDir)/dictionary.o: $(SrcDir)/dictionary.cpp $(Deps)
33+
g++ -o $(IntDir)/dictionary.o -c $(SrcDir)/dictionary.cpp $(Compiler)
34+
35+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
36+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
37+
38+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
39+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
40+
41+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
42+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)

02_harry_potter_makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
AllWarnings = -Wall -Wextra -pedantic
2+
SomeWarnings = -Wall
3+
LittleWarnings =
4+
NoWarnings =
5+
6+
Linker =
7+
Compiler = -O1 $(AllWarnings)
8+
9+
SrcDir = src
10+
BinDir = bin
11+
IntDir = $(BinDir)/intermediates
12+
LibDir = libs
13+
VerDir = 02_optimize
14+
15+
Libs = $(wildcard $(LibDir)/*.a)
16+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h)
17+
Objs = $(IntDir)/$(VerDir)/main_harry_potter.o $(IntDir)/$(VerDir)/html_writer.o $(IntDir)/file_loader.o $(IntDir)/dictionary.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
18+
Exec = 02_optimize.out
19+
20+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
21+
g++ -o $(BinDir)/$(Exec) $(Linker) $(Objs) $(Libs)
22+
23+
$(IntDir)/$(VerDir)/main_harry_potter.o: $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Deps)
24+
g++ -o $(IntDir)/$(VerDir)/main_harry_potter.o -c $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Compiler)
25+
26+
$(IntDir)/$(VerDir)/html_writer.o: $(SrcDir)/$(VerDir)/html_writer.cpp $(Deps)
27+
g++ -o $(IntDir)/$(VerDir)/html_writer.o -c $(SrcDir)/$(VerDir)/html_writer.cpp $(Compiler)
28+
29+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
30+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
31+
32+
$(IntDir)/dictionary.o: $(SrcDir)/dictionary.cpp $(Deps)
33+
g++ -o $(IntDir)/dictionary.o -c $(SrcDir)/dictionary.cpp $(Compiler)
34+
35+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
36+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
37+
38+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
39+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
40+
41+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
42+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)

02_makefile_failed1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
OptimizationLevel = -O2
2+
Optimize = 0
3+
OptimizationVersion = HASH_TABLE_ONLY
4+
5+
ifneq ($(Optimize), 0)
6+
OptimizationVersion = CRC32_OPTIMIZED
7+
OPTIMIZE_AVX_DEFINE = -DAVX_STRING_OPTIMIZATION
8+
OPTIMIZE_FIND_DEFINE = -DOPTIMIZED_FIND
9+
OPTIMIZE_FIND_ASM_FILE = $(SrcDir)/02_optimize/optimized/optimized_find_avx.s
10+
endif
11+
12+
AllWarnings = -Wall -Wextra -pedantic
13+
SomeWarnings = -Wall
14+
LittleWarnings =
15+
NoWarnings =
16+
17+
Linker = $(OptimizationLevel)
18+
Compiler = $(OptimizationLevel) -mavx2 -march=native -DDEBUG -DNDEBUG -D$(OptimizationVersion) $(OPTIMIZE_FIND_DEFINE) $(OPTIMIZE_AVX_DEFINE) $(NoWarnings)
19+
20+
SrcDir = src
21+
BinDir = bin
22+
IntDir = $(BinDir)/intermediates
23+
LibDir = libs
24+
VerDir = 02_optimize/failed_1
25+
26+
Libs = $(wildcard $(LibDir)/*.a)
27+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h) .FORCE
28+
Objs = $(IntDir)/$(VerDir)/main_harry_potter.o $(IntDir)/$(VerDir)/html_writer.o $(IntDir)/file_loader.o $(IntDir)/dictionary.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
29+
Exec = 02_failed1.out
30+
31+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
32+
g++ -o $(BinDir)/$(Exec) $(Linker) $(OPTIMIZE_FIND_ASM_FILE) $(Objs) $(Libs)
33+
34+
$(IntDir)/$(VerDir)/main_harry_potter.o: $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Deps)
35+
g++ -o $(IntDir)/$(VerDir)/main_harry_potter.o -c $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Compiler)
36+
37+
$(IntDir)/$(VerDir)/html_writer.o: $(SrcDir)/$(VerDir)/html_writer.cpp $(Deps)
38+
g++ -o $(IntDir)/$(VerDir)/html_writer.o -c $(SrcDir)/$(VerDir)/html_writer.cpp $(Compiler)
39+
40+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
41+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
42+
43+
$(IntDir)/dictionary.o: $(SrcDir)/dictionary.cpp $(Deps)
44+
g++ -o $(IntDir)/dictionary.o -c $(SrcDir)/dictionary.cpp $(Compiler)
45+
46+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
47+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
48+
49+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
50+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
51+
52+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
53+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)
54+
55+
.FORCE:

02_makefile_failed2

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
AllWarnings = -Wall -Wextra -pedantic
2+
SomeWarnings = -Wall
3+
LittleWarnings =
4+
NoWarnings =
5+
6+
Linker =
7+
Compiler = -DDEBUG -DNDEBUG -O1 $(NoWarnings)
8+
9+
SrcDir = src
10+
BinDir = bin
11+
IntDir = $(BinDir)/intermediates
12+
LibDir = libs
13+
VerDir = 02_optimize/failed_2
14+
15+
Libs = $(wildcard $(LibDir)/*.a)
16+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h) .FORCE
17+
Objs = $(IntDir)/$(VerDir)/main_harry_potter.o $(IntDir)/$(VerDir)/html_writer.o $(IntDir)/file_loader.o $(IntDir)/dictionary.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
18+
Exec = 02_failed2.out
19+
20+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
21+
g++ -o $(BinDir)/$(Exec) $(Linker) $(Objs) $(Libs)
22+
23+
$(IntDir)/$(VerDir)/main_harry_potter.o: $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Deps)
24+
g++ -o $(IntDir)/$(VerDir)/main_harry_potter.o -c $(SrcDir)/$(VerDir)/main_harry_potter.cpp $(Compiler)
25+
26+
$(IntDir)/$(VerDir)/html_writer.o: $(SrcDir)/$(VerDir)/html_writer.cpp $(Deps)
27+
g++ -o $(IntDir)/$(VerDir)/html_writer.o -c $(SrcDir)/$(VerDir)/html_writer.cpp $(Compiler)
28+
29+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
30+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
31+
32+
$(IntDir)/dictionary.o: $(SrcDir)/dictionary.cpp $(Deps)
33+
g++ -o $(IntDir)/dictionary.o -c $(SrcDir)/dictionary.cpp $(Compiler)
34+
35+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
36+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
37+
38+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
39+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
40+
41+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
42+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)
43+
44+
.FORCE:

02_makefile_optimized

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ================ Version ================
2+
OptimizeAVX = 0
3+
OptimizeFind = 0
4+
OptimizationVersion =
5+
OptimizationLevel = -O2
6+
7+
OPTIMIZE_FIND_DEFINE =
8+
OPTIMIZE_FIND_ASM_FILE =
9+
ifneq ($(OptimizeFind), 0)
10+
OPTIMIZE_FIND_DEFINE = -DOPTIMIZED_FIND
11+
12+
ifneq ($(OptimizeAVX), 0)
13+
OPTIMIZE_FIND_ASM_FILE = $(SrcDir)/$(VerDir)/optimized_find_avx.s
14+
else
15+
OPTIMIZE_FIND_ASM_FILE = $(SrcDir)/$(VerDir)/optimized_find.s
16+
endif
17+
endif
18+
19+
OPTIMIZE_AVX_DEFINE =
20+
ifneq ($(OptimizeAVX), 0)
21+
OPTIMIZE_AVX_DEFINE = -DAVX_STRING_OPTIMIZATION
22+
endif
23+
# ================ Version ================
24+
25+
# ================ Options ================
26+
AllWarnings = -Wall -Wextra -pedantic
27+
SomeWarnings = -Wall
28+
LittleWarnings =
29+
NoWarnings =
30+
31+
Linker = $(OptimizationLevel)
32+
Compiler = $(OptimizationLevel) -mavx2 -march=native -DNDEBUG -D$(OptimizationVersion) $(OPTIMIZE_FIND_DEFINE) $(OPTIMIZE_AVX_DEFINE) $(NoWarnings)
33+
# ================ Constants ================
34+
35+
# ================ Files ================
36+
SrcDir = src
37+
BinDir = bin
38+
IntDir = $(BinDir)/intermediates
39+
LibDir = libs
40+
VerDir = 02_optimize/optimized
41+
42+
Libs = $(wildcard $(LibDir)/*.a)
43+
Deps = $(wildcard $(SrcDir)/*.h) $(wildcard $(LibDir)/*.h) .FORCE
44+
Objs = $(IntDir)/$(VerDir)/main_optimized.o $(IntDir)/file_loader.o $(IntDir)/hash_table.o $(IntDir)/bucket.o $(IntDir)/hash_functions.o
45+
Exec = 02_optimized.out
46+
# ================ Files ================
47+
48+
# ================ Make rules ================
49+
$(BinDir)/$(Exec): $(Objs) $(Libs) $(Deps)
50+
g++ -o $(BinDir)/$(Exec) $(Linker) $(OPTIMIZE_FIND_ASM_FILE) $(Objs) $(Libs)
51+
52+
$(IntDir)/$(VerDir)/main_optimized.o: $(SrcDir)/$(VerDir)/main_optimized.cpp $(Deps)
53+
g++ -o $(IntDir)/$(VerDir)/main_optimized.o -c $(SrcDir)/$(VerDir)/main_optimized.cpp $(Compiler)
54+
55+
$(IntDir)/file_loader.o: $(SrcDir)/file_loader.cpp $(Deps)
56+
g++ -o $(IntDir)/file_loader.o -c $(SrcDir)/file_loader.cpp $(Compiler)
57+
58+
$(IntDir)/hash_table.o: $(SrcDir)/hash_table.cpp $(Deps)
59+
g++ -o $(IntDir)/hash_table.o -c $(SrcDir)/hash_table.cpp $(Compiler)
60+
61+
$(IntDir)/bucket.o: $(SrcDir)/bucket.cpp $(Deps)
62+
g++ -o $(IntDir)/bucket.o -c $(SrcDir)/bucket.cpp $(Compiler)
63+
64+
$(IntDir)/hash_functions.o: $(SrcDir)/hash_functions.cpp $(Deps)
65+
g++ -o $(IntDir)/hash_functions.o -c $(SrcDir)/hash_functions.cpp $(Compiler)
66+
# ================ Make rules ================
67+
68+
.FORCE:

0 commit comments

Comments
 (0)