-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from itzmeanjan/update-sha3
Refactor FrodoKEM Implementation
- Loading branch information
Showing
17 changed files
with
393 additions
and
367 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,64 @@ | ||
CXX = g++ | ||
CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic | ||
OPTFLAGS = -O3 -march=native -mtune=native | ||
IFLAGS = -I ./include | ||
DEPFLAGS = -I ./sha3/include -I ./subtle/include | ||
CXX_FLAGS = -std=c++20 | ||
WARN_FLAGS = -Wall -Wextra -pedantic | ||
OPT_FLAGS = -O3 -march=native -mtune=native | ||
LINK_FLAGS = -flto | ||
I_FLAGS = -I ./include | ||
DEP_IFLAGS = -I ./sha3/include -I ./subtle/include | ||
|
||
all: testing | ||
SRC_DIR = include | ||
FRODO_SOURCES := $(wildcard $(SRC_DIR)/*.hpp) | ||
BUILD_DIR = build | ||
|
||
test/a.out: test/main.cpp include/*.hpp include/test/*.hpp sha3/include/*.hpp subtle/include/*.hpp | ||
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(IFLAGS) $(DEPFLAGS) $< -o $@ | ||
TEST_DIR = tests | ||
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp) | ||
TEST_OBJECTS := $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %.cpp,%.o,$(TEST_SOURCES)))) | ||
TEST_LINK_FLAGS = -lgtest -lgtest_main | ||
TEST_BINARY = $(BUILD_DIR)/test.out | ||
|
||
testing: test/a.out | ||
BENCHMARK_DIR = benchmarks | ||
BENCHMARK_SOURCES := $(wildcard $(BENCHMARK_DIR)/*.cpp) | ||
BENCHMARK_OBJECTS := $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %.cpp,%.o,$(BENCHMARK_SOURCES)))) | ||
BENCHMARK_LINK_FLAGS = -lbenchmark -lbenchmark_main | ||
BENCHMARK_BINARY = $(BUILD_DIR)/bench.out | ||
PERF_LINK_FLAGS = -lbenchmark -lbenchmark_main -lpfm | ||
PERF_BINARY = $(BUILD_DIR)/perf.out | ||
|
||
all: test | ||
|
||
$(BUILD_DIR): | ||
mkdir -p $@ | ||
|
||
$(BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp $(BUILD_DIR) | ||
$(CXX) $(CXX_FLAGS) $(WARN_FLAGS) $(OPT_FLAGS) $(I_FLAGS) $(DEP_IFLAGS) -c $< -o $@ | ||
|
||
$(TEST_BINARY): $(TEST_OBJECTS) | ||
$(CXX) $(OPT_FLAGS) $(LINK_FLAGS) $^ $(TEST_LINK_FLAGS) -o $@ | ||
|
||
test: $(TEST_BINARY) | ||
./$< | ||
|
||
bench/a.out: bench/main.cpp include/*.hpp include/bench/*.hpp sha3/include/*.hpp subtle/include/*.hpp | ||
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(IFLAGS) $(DEPFLAGS) $< -lbenchmark -o $@ | ||
$(BUILD_DIR)/%.o: $(BENCHMARK_DIR)/%.cpp $(BUILD_DIR) | ||
$(CXX) $(CXX_FLAGS) $(WARN_FLAGS) $(OPT_FLAGS) $(I_FLAGS) $(DEP_IFLAGS) -c $< -o $@ | ||
|
||
$(BENCHMARK_BINARY): $(BENCHMARK_OBJECTS) | ||
$(CXX) $(OPT_FLAGS) $(LINK_FLAGS) $^ $(BENCHMARK_LINK_FLAGS) -o $@ | ||
|
||
benchmark: $(BENCHMARK_BINARY) | ||
# Must *not* build google-benchmark with libPFM | ||
./$< --benchmark_time_unit=ms --benchmark_min_warmup_time=1. --benchmark_counters_tabular=true | ||
|
||
$(PERF_BINARY): $(BENCHMARK_OBJECTS) | ||
$(CXX) $(OPT_FLAGS) $(LINK_FLAGS) $^ $(PERF_LINK_FLAGS) -o $@ | ||
|
||
perf: $(PERF_BINARY) | ||
# Must build google-benchmark with libPFM, follow https://gist.github.com/itzmeanjan/05dc3e946f635d00c5e0b21aae6203a7 | ||
./$< --benchmark_time_unit=ms --benchmark_min_warmup_time=1. --benchmark_perf_counters=CYCLES --benchmark_counters_tabular=true | ||
|
||
benchmark: bench/a.out | ||
# Don't forget to put all CPU cores on performance mode before running benchmarks, | ||
# follow https://github.com/google/benchmark/blob/2dd015df/docs/reducing_variance.md | ||
./$< --benchmark_time_unit=ms --benchmark_counters_tabular=true | ||
.PHONY: format clean | ||
|
||
clean: | ||
find . -name '*.out' -o -name '*.o' -o -name '*.so' -o -name '*.gch' | xargs rm -rf | ||
rm -rf build | ||
|
||
format: | ||
find . -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i --style=Mozilla | ||
format: $(FRODO_SOURCES) $(TEST_SOURCES) $(BENCHMARK_SOURCES) | ||
clang-format -i --style=Mozilla $^ |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.