-
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.
Merge pull request #22 from itzmeanjan/modernize-setup
Modernize Infra Setup
- Loading branch information
Showing
28 changed files
with
708 additions
and
433 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: Mozilla | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignArrayOfStructures: None | ||
AlignConsecutiveAssignments: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: true | ||
AlignConsecutiveBitFields: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignConsecutiveDeclarations: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignConsecutiveMacros: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: Align | ||
AlignTrailingComments: | ||
Kind: Always | ||
OverEmptyLines: 0 | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortEnumsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: Inline | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: TopLevel | ||
AlwaysBreakAfterReturnType: TopLevel | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: Yes | ||
AttributeMacros: | ||
- __capability | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BitFieldColonSpacing: Both | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: Never | ||
AfterEnum: true | ||
AfterExternBlock: true | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: true | ||
AfterUnion: true | ||
BeforeCatch: false | ||
BeforeElse: false | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: false | ||
SplitEmptyNamespace: true | ||
BreakAfterAttributes: Never | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakArrays: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeConceptDeclarations: Always | ||
BreakBeforeBraces: Mozilla | ||
BreakBeforeInlineASMColon: OnlyMultiline | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeComma | ||
BreakInheritanceList: BeforeComma | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerIndentWidth: 2 | ||
ContinuationIndentWidth: 2 | ||
Cpp11BracedListStyle: false | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
EmptyLineAfterAccessModifier: Never | ||
EmptyLineBeforeAccessModifier: LogicalBlock | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IfMacros: | ||
- KJ_IF_MAYBE | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentAccessModifiers: false | ||
IndentCaseBlocks: false | ||
IndentCaseLabels: true | ||
IndentExternBlock: AfterExternBlock | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentRequiresClause: true | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
InsertBraces: false | ||
InsertNewlineAtEOF: false | ||
InsertTrailingCommas: None | ||
IntegerLiteralSeparator: | ||
Binary: 0 | ||
BinaryMinDigits: 0 | ||
Decimal: 0 | ||
DecimalMinDigits: 0 | ||
Hex: 0 | ||
HexMinDigits: 0 | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
LambdaBodyIndentation: Signature | ||
LineEnding: DeriveLF | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCBreakBeforeNestedBlockParam: true | ||
ObjCSpaceAfterProperty: true | ||
ObjCSpaceBeforeProtocolList: false | ||
PackConstructorInitializers: BinPack | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakOpenParenthesis: 0 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyIndentedWhitespace: 0 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
PPIndentWidth: -1 | ||
QualifierAlignment: Leave | ||
ReferenceAlignment: Pointer | ||
ReflowComments: true | ||
RemoveBracesLLVM: false | ||
RemoveSemicolon: false | ||
RequiresClausePosition: OwnLine | ||
RequiresExpressionIndentation: OuterScope | ||
SeparateDefinitionBlocks: Leave | ||
ShortNamespaceLines: 1 | ||
SortIncludes: CaseSensitive | ||
SortJavaStaticImport: Before | ||
SortUsingDeclarations: LexicographicNumeric | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: false | ||
SpaceAroundPointerQualifiers: Default | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCaseColon: false | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeParensOptions: | ||
AfterControlStatements: true | ||
AfterForeachMacros: true | ||
AfterFunctionDefinitionName: false | ||
AfterFunctionDeclarationName: false | ||
AfterIfMacros: true | ||
AfterOverloadedOperator: false | ||
AfterRequiresInClause: false | ||
AfterRequiresInExpression: false | ||
BeforeNonEmptyParentheses: false | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceBeforeSquareBrackets: false | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: Never | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInLineCommentPrefix: | ||
Minimum: 1 | ||
Maximum: -1 | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Latest | ||
StatementAttributeLikeMacros: | ||
- Q_EMIT | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseTab: Never | ||
WhitespaceSensitiveMacros: | ||
- BOOST_PP_STRINGIZE | ||
- CF_SWIFT_NAME | ||
- NS_SWIFT_NAME | ||
- PP_STRINGIZE | ||
- STRINGIZE | ||
... | ||
|
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,3 +1,6 @@ | ||
[submodule "sha3"] | ||
path = sha3 | ||
url = https://github.com/itzmeanjan/sha3.git | ||
[submodule "gtest-parallel"] | ||
path = gtest-parallel | ||
url = https://github.com/google/gtest-parallel.git |
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,29 +1,75 @@ | ||
CXX = g++ | ||
CXXFLAGS = -std=c++20 -Wall -Wextra -pedantic | ||
OPTFLAGS = -O3 -march=native -mtune=native | ||
IFLAGS = -I ./include | ||
DEP_IFLAGS = -I ./sha3/include | ||
# From https://gmplib.org/manual/Headers-and-Libraries | ||
LFLAGS = -lgmpxx -lgmp | ||
CXX ?= clang++ | ||
CXX_FLAGS = -std=c++20 | ||
WARN_FLAGS = -Wall -Wextra -pedantic | ||
OPT_FLAGS = -O3 -march=native | ||
LINK_FLAGS = -flto | ||
GMP_LINK_FLAGS = -lgmpxx -lgmp | ||
|
||
all: testing | ||
SHA3_INC_DIR = ./sha3/include | ||
I_FLAGS = -I ./include | ||
DEP_IFLAGS = -I $(SHA3_INC_DIR) | ||
|
||
test/a.out: test/main.cpp include/*.hpp include/test/*.hpp | ||
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(IFLAGS) $(DEP_IFLAGS) $< -o $@ $(LFLAGS) | ||
SRC_DIR = include | ||
FALCON_SOURCES := $(wildcard $(SRC_DIR)/*.hpp) | ||
BUILD_DIR = build | ||
|
||
testing: test/a.out | ||
./$< | ||
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 | ||
GTEST_PARALLEL = ./gtest-parallel/gtest-parallel | ||
|
||
bench/a.out: bench/main.cpp include/*.hpp include/bench/*.hpp | ||
# make sure you've google-benchmark globally installed; | ||
# see https://github.com/google/benchmark/tree/84c71fa#installation | ||
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(IFLAGS) $(DEP_IFLAGS) $< -o $@ $(LFLAGS) -lbenchmark | ||
BENCHMARK_DIR = benchmarks | ||
BENCHMARK_SOURCES := $(wildcard $(BENCHMARK_DIR)/*.cpp) | ||
BENCHMARK_HEADERS := $(wildcard $(BENCHMARK_DIR)/*.hpp) | ||
BENCHMARK_OBJECTS := $(addprefix $(BUILD_DIR)/, $(notdir $(patsubst %.cpp,%.o,$(BENCHMARK_SOURCES)))) | ||
BENCHMARK_LINK_FLAGS = -lbenchmark -lbenchmark_main -lpthread | ||
BENCHMARK_BINARY = $(BUILD_DIR)/bench.out | ||
PERF_LINK_FLAGS = -lbenchmark -lbenchmark_main -lpfm -lpthread | ||
PERF_BINARY = $(BUILD_DIR)/perf.out | ||
|
||
benchmark: bench/a.out | ||
./$< --benchmark_time_unit=us --benchmark_counters_tabular=true | ||
all: test | ||
|
||
$(BUILD_DIR): | ||
mkdir -p $@ | ||
|
||
$(SHA3_INC_DIR): | ||
git submodule update --init sha3 | ||
|
||
$(GTEST_PARALLEL): $(SHA3_INC_DIR) | ||
git submodule update --init gtest-parallel | ||
|
||
$(BUILD_DIR)/%.o: $(TEST_DIR)/%.cpp $(BUILD_DIR) $(SHA3_INC_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 $@ $(GMP_LINK_FLAGS) | ||
|
||
test: $(TEST_BINARY) $(GTEST_PARALLEL) | ||
$(GTEST_PARALLEL) $< --print_test_times | ||
|
||
$(BUILD_DIR)/%.o: $(BENCHMARK_DIR)/%.cpp $(BUILD_DIR) $(SHA3_INC_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 $@ $(GMP_LINK_FLAGS) | ||
|
||
benchmark: $(BENCHMARK_BINARY) | ||
# Must *not* build google-benchmark with libPFM | ||
./$< --benchmark_time_unit=us --benchmark_min_warmup_time=.5 --benchmark_enable_random_interleaving=true --benchmark_repetitions=16 --benchmark_min_time=0.1s --benchmark_display_aggregates_only=true --benchmark_counters_tabular=true | ||
|
||
$(PERF_BINARY): $(BENCHMARK_OBJECTS) | ||
$(CXX) $(OPT_FLAGS) $(LINK_FLAGS) $^ $(PERF_LINK_FLAGS) -o $@ $(GMP_LINK_FLAGS) | ||
|
||
perf: $(PERF_BINARY) | ||
# Must build google-benchmark with libPFM, follow https://gist.github.com/itzmeanjan/05dc3e946f635d00c5e0b21aae6203a7 | ||
./$< --benchmark_time_unit=us --benchmark_min_warmup_time=.5 --benchmark_enable_random_interleaving=true --benchmark_repetitions=16 --benchmark_min_time=0.1s --benchmark_display_aggregates_only=true --benchmark_counters_tabular=true --benchmark_perf_counters=CYCLES | ||
|
||
.PHONY: format clean | ||
|
||
clean: | ||
find . -name '*.out' -o -name '*.o' -o -name '*.so' -o -name '*.gch' | xargs rm -rf | ||
rm -rf $(BUILD_DIR) | ||
|
||
format: | ||
find . -name '*.hpp' -o -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i --style=Mozilla | ||
format: $(FALCON_SOURCES) $(TEST_SOURCES) $(DUDECT_TEST_SOURCES) $(BENCHMARK_SOURCES) $(BENCHMARK_HEADERS) | ||
clang-format -i $^ |
Oops, something went wrong.