Skip to content

Commit

Permalink
Merge pull request #54 from ikbuibui/clangFormat
Browse files Browse the repository at this point in the history
Run clang-format on repository
  • Loading branch information
psychocoderHPC authored Jan 24, 2024
2 parents cfe32f0 + 0c1ddb3 commit c3ed1ac
Show file tree
Hide file tree
Showing 94 changed files with 6,694 additions and 6,538 deletions.
160 changes: 160 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
# General options
Language: Cpp
Standard: c++17
DisableFormat: false

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Never
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 119
CommentPragmas: '^ COMMENT pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: true
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
DecimalMinDigits: 7
Hex: 4
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PackConstructorInitializers: CurrentLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0 # default made explicit here
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0 # default made explicit here
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
PPIndentWidth: -1 # follow IndentWidth
QualifierAlignment: Custom
QualifierOrder: ['friend', 'static', 'inline', 'constexpr', 'type', 'const', 'volatile', 'restrict']
ReferenceAlignment: Pointer # follow PointerAlignment
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: WithPreceding
RequiresExpressionIndentation: OuterScope
ShortNamespaceLines: 0
SortIncludes: true
SortUsingDeclarations: Lexicographic
SeparateDefinitionBlocks: Always
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default # follow PointerAlignment
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseCRLF: false
UseTab: Never

# Project specific options -- uncomment and modify as needed
#AttributeMacros: []
#ForEachMacros: []
#IfMacros: []
IncludeCategories:
# Local headers (in "") above all else
- Regex: '"([A-Za-z0-9.\/-_])+"'
Priority: 1
# "redGrapes/foo.hpp" after local headers (occur inside redGrapes)
- Regex: '"redGrapes/([A-Za-z0-9.\/-_])+"'
Priority: 2
# <redGrapes/foo.hpp> after local headers (occur outside redGrapes in examples and test)
- Regex: '<redGrapes/([A-Za-z0-9.\/-_])+>'
Priority: 3
# C++ standard library headers are the last group to be included
- Regex: '<([A-Za-z0-9\/-_])+>'
Priority: 5
# Includes that made it this far are third-party headers and will be placed
# below redGrapes's includes
- Regex: '<([A-Za-z0-9.\/-_])+>'
Priority: 4
# Macros: []
#NamespaceMacros: []
#StatementAttributeLikeMacros: []
#StatementMacros: []
#TypenameMacros: []
#WhitespaceSensitiveMacros: []

...
45 changes: 40 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,49 @@ compile_commands.json
DartConfiguration.tcl
Testing


docs/build
docs/doxyxml

build/

*.swp
*.orig
*.png
*.dot

# tmp files
*~

# netbeans project files
/nbproject/

# Code::Blocks project files
/*.cbp
/*.layout

# Visual Studio Code configuration files
.vscode

# JetBrains project files and tmp's
.idea/
/venv/

# python byte code
*.pyc

# original backup files
*.orig

# doxygen output
docs/xml/
docs/doxyxml
docs/doxygen_sqlite3.db
docs/html/
# sphinx & breathe output
docs/build/

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Visual Studio configuration and output files
out
/.vs
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ int main()
[] ( auto a ) { std::cout << a << std::endl; },
a.read()
);

rg::finalize();

return 0;
}
Expand All @@ -88,6 +90,8 @@ RedGrapes is documented using in-code doxygen comments and reStructured-text fil
* [Getting Started](docs/source/tutorial/index.rst)
* [Components](docs/source/components.rst)
* [Contributing](docs/source/contributing.rst)
## Comparision with Similar Projects
Expand Down
30 changes: 30 additions & 0 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
############
Contributing
############

Formatting
==========

Please format your code before before opening pull requests using clang-format 16 and the .clang-format file placed in the repository root.

Visual Studio and CLion
-----------------------

Suport for clang-format is built-in since Visual Studio 2017 15.7 and CLion 2019.1.
The .clang-format file in the repository will be automatically detected and formatting is done as you type, or triggered when pressing the format hotkey.

Bash
----

First install clang-format-16. Instructions therefore can be found on the web.
To format your changes since branching off develop, you can run this command in bash:

.. code-block:: bash
git clang-format-16 develop
To format all code in your working copy, you can run this command in bash:

.. code-block:: bash
find -iname '*.cpp' -o -iname '*.hpp' | xargs clang-format-16 -i
55 changes: 45 additions & 10 deletions examples/#cholesky.cpp#
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <iostream>
#include <cblas.h>
#include <lapacke.h>
#include <redGrapes/task/property/inherit.hpp>
#include <redGrapes/task/property/label.hpp>

#include <cblas.h>
#include <lapacke.h>

#include <iostream>

#define REDGRAPES_TASK_PROPERTIES redGrapes::LabelProperty
#include <redGrapes/redGrapes.hpp>
#include <redGrapes/resource/ioresource.hpp>
Expand Down Expand Up @@ -81,8 +83,21 @@ int main(int argc, char* argv[])
[blksz](auto a, auto b, auto c)
{
spdlog::info("dgemm");
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,
blksz, blksz, blksz, -1.0, *a, blksz, *b, blksz, 1.0, *c, blksz);
cblas_dgemm(
CblasColMajor,
CblasNoTrans,
CblasTrans,
blksz,
blksz,
blksz,
-1.0,
*a,
blksz,
*b,
blksz,
1.0,
*c,
blksz);
},
rg::TaskProperties::Builder().label("gemm"),
A[k * nblks + i].read(),
Expand All @@ -98,8 +113,18 @@ int main(int argc, char* argv[])
[blksz, nblks](auto a, auto c)
{
spdlog::info("dsyrk");
cblas_dsyrk(CblasColMajor, CblasLower, CblasNoTrans,
blksz, blksz, -1.0, *a, blksz, 1.0, *c, blksz);
cblas_dsyrk(
CblasColMajor,
CblasLower,
CblasNoTrans,
blksz,
blksz,
-1.0,
*a,
blksz,
1.0,
*c,
blksz);
},
A[i * nblks + j].read(),
A[j * nblks + j].write());
Expand All @@ -121,9 +146,19 @@ int main(int argc, char* argv[])
[blksz, nblks](auto a, auto b)
{
spdlog::info("dtrsm");
cblas_dtrsm(CblasColMajor,
CblasRight, CblasLower, CblasTrans, CblasNonUnit,
blksz, blksz, 1.0, *a, blksz, *b, blksz);
cblas_dtrsm(
CblasColMajor,
CblasRight,
CblasLower,
CblasTrans,
CblasNonUnit,
blksz,
blksz,
1.0,
*a,
blksz,
*b,
blksz);
},
A[j * nblks + j].read(),
A[j * nblks + i].write());
Expand Down
31 changes: 12 additions & 19 deletions examples/1_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,31 @@
*/

#include <redGrapes/redGrapes.hpp>
#include <redGrapes/resource/ioresource.hpp>
#include <redGrapes/resource/fieldresource.hpp>
#include <redGrapes/resource/ioresource.hpp>
#include <redGrapes/resource/resource_user.hpp>

int main(int, char*[])
{
redGrapes::init(1);
redGrapes::FieldResource< std::vector<int> > a;
redGrapes::FieldResource<std::vector<int>> a;
redGrapes::IOResource<int> b;
redGrapes::IOResource<int> c;

redGrapes::ResourceUser user1({
a.read(), // complete resource
a.write().area( {0}, {10} ), // write only indices 0 to 10
b.write()
});
redGrapes::ResourceUser user1(
{a.read(), // complete resource
a.write().area({0}, {10}), // write only indices 0 to 10
b.write()});

redGrapes::ResourceUser user2({
b.read()
});
redGrapes::ResourceUser user2({b.read()});

redGrapes::ResourceUser user3({
b.read(),
c.write()
});
redGrapes::ResourceUser user3({b.read(), c.write()});

std::cout << "is_serial(user1,user1) = " << redGrapes::ResourceUser::is_serial(user1,user1) << std::endl;
std::cout << "is_serial(user1,user2) = " << redGrapes::ResourceUser::is_serial(user1,user2) << std::endl;
std::cout << "is_serial(user1,user3) = " << redGrapes::ResourceUser::is_serial(user1,user3) << std::endl;
std::cout << "is_serial(user2,user3) = " << redGrapes::ResourceUser::is_serial(user2,user3) << std::endl;
std::cout << "is_serial(user1,user1) = " << redGrapes::ResourceUser::is_serial(user1, user1) << std::endl;
std::cout << "is_serial(user1,user2) = " << redGrapes::ResourceUser::is_serial(user1, user2) << std::endl;
std::cout << "is_serial(user1,user3) = " << redGrapes::ResourceUser::is_serial(user1, user3) << std::endl;
std::cout << "is_serial(user2,user3) = " << redGrapes::ResourceUser::is_serial(user2, user3) << std::endl;

redGrapes::finalize();
return 0;
}

Loading

0 comments on commit c3ed1ac

Please sign in to comment.