Skip to content

Commit

Permalink
Add .clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
loostrum committed Jul 26, 2024
1 parent 98c818b commit 4a205ac
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 117 deletions.
280 changes: 280 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
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: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.8
hooks:
- id: clang-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint
- id: cmake-lint
17 changes: 8 additions & 9 deletions include/tcbf.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef TCBF_H_
#define TCBF_H_

#include <limits.h>

#include <ccglib/ccglib.hpp>
#include <cudawrappers/cu.hpp>
#include <limits.h>

namespace tcbf {

class Beamformer {
public:
Beamformer(const size_t pixels, const size_t frames, const size_t samples,
cu::Device &device, cu::Stream &stream);
public:
Beamformer(const size_t pixels, const size_t frames, const size_t samples, cu::Device &device, cu::Stream &stream);

// static void prepare_A_matrix(const std::string input_path, const
// std::string output_path, const size_t pixels, const size_t samples,
Expand All @@ -20,16 +20,15 @@ class Beamformer {
void write_BF(cu::HostMemory &BF, const std::string path);
void process(cu::HostMemory &RF, cu::HostMemory &BF);

private:
private:
void RF_to_device(cu::HostMemory &RF);
void BF_to_host(cu::HostMemory &BF);

static const size_t kBitsPerSample{1};
static const size_t kBatchSize{1};
static const ccglib::mma::Precision kGEMMPrecision{ccglib::mma::int1};
static const ccglib::mma::Variant kGEMMVariant{ccglib::mma::opt};
const dim3 kGEMMTileSize{
ccglib::mma::GEMM::GetDimensions(kGEMMPrecision, kGEMMVariant)};
const dim3 kGEMMTileSize{ccglib::mma::GEMM::GetDimensions(kGEMMPrecision, kGEMMVariant)};

std::unique_ptr<cu::DeviceMemory> d_A;
std::unique_ptr<cu::DeviceMemory> d_RF;
Expand Down Expand Up @@ -58,6 +57,6 @@ class Beamformer {
cu::Stream &stream_;
};

} // namespace tcbf
} // namespace tcbf

#endif // TCBF_H_
#endif // TCBF_H_
23 changes: 9 additions & 14 deletions src/main.cu
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#include <tcbf.h>

#include <cxxopts.hpp>
#include <fstream>
#include <iostream>

#include <tcbf.h>

cxxopts::Options create_commandline_parser(const char *argv[]) {
cxxopts::Options options(argv[0], "Echoframe standalone beamformer");

options.add_options()("a_matrix", "Full path to input prepared A matrix",
cxxopts::value<std::string>())(
"rf", "Full path to input RF", cxxopts::value<std::string>())(
"bf", "Full path to output BF", cxxopts::value<std::string>())(
"pixels", "Number of pixels", cxxopts::value<size_t>())(
"frames", "Number of frames", cxxopts::value<size_t>())(
options.add_options()("a_matrix", "Full path to input prepared A matrix", cxxopts::value<std::string>())(
"rf", "Full path to input RF", cxxopts::value<std::string>())("bf", "Full path to output BF",
cxxopts::value<std::string>())(
"pixels", "Number of pixels", cxxopts::value<size_t>())("frames", "Number of frames", cxxopts::value<size_t>())(
"samples", "Number of samples", cxxopts::value<size_t>())(
"device", "GPU device ID",
cxxopts::value<unsigned>()->default_value(std::to_string(0)))(
"h,help", "Print help");
"device", "GPU device ID", cxxopts::value<unsigned>()->default_value(std::to_string(0)))("h,help", "Print help");

return options;
}
Expand All @@ -32,8 +28,7 @@ cxxopts::ParseResult parse_commandline(int argc, const char *argv[]) {
exit(EXIT_SUCCESS);
}

std::vector<std::string> required_options{"a_matrix", "rf", "bf",
"pixels", "frames", "samples"};
std::vector<std::string> required_options{"a_matrix", "rf", "bf", "pixels", "frames", "samples"};
for (auto &opt : required_options) {
if (!result.count(opt)) {
std::cerr << "Required argument missing: " << opt << std::endl;
Expand Down Expand Up @@ -72,4 +67,4 @@ int main(int argc, const char *argv[]) {
beamformer.read_RF(RF, path_rf);
beamformer.process(RF, BF);
beamformer.write_BF(BF, path_bf);
}
}
Loading

0 comments on commit 4a205ac

Please sign in to comment.