Skip to content

Commit

Permalink
Formatting changes + fix windows OSS build (#406)
Browse files Browse the repository at this point in the history
Summary:
Add .clang-format 
Copied from https://github.com/pytorch/pytorch/blob/main/.clang-format


Reviewed By: wconstab, fduwjj

Differential Revision: D69275930

Pulled By: c-p-i-o
  • Loading branch information
c-p-i-o authored and facebook-github-bot committed Feb 8, 2025
1 parent b67ecd8 commit 23d66d7
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 26 deletions.
127 changes: 127 additions & 0 deletions .github/config/lint/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros:
- FOR_EACH_RANGE
- FOR_EACH
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
Macros:
- >-
PyObject_HEAD_INIT(type)={
/* this is not exactly match with PyObject_HEAD_INIT in Python source code
* but it is enough for clang-format */
{ 0xFFFFFFFF },
(type)
},
- >-
PyVarObject_HEAD_INIT(type, size)={
{
/* manually expand PyObject_HEAD_INIT(type) above
* because clang-format do not support recursive expansion */
{ 0xFFFFFFFF },
(type)
},
(size)
},
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 2000000
PointerAlignment: Left
PPIndentWidth: 0
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
StatementMacros:
- C10_DEFINE_bool
- C10_DEFINE_int
- C10_DEFINE_int32
- C10_DEFINE_int64
- C10_DEFINE_string
- C10_DEFINE_REGISTRY_WITHOUT_WARNING
- C10_REGISTER_CREATOR
- DEFINE_BINARY
- PyObject_HEAD
- PyObject_VAR_HEAD
- PyException_HEAD
- TORCH_DECLARE_bool

TabWidth: 8
UseTab: Never
---
Language: ObjC
ColumnLimit: 120
AlignAfterOpenBracket: Align
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
...
16 changes: 8 additions & 8 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ jobs:
cd libuv-v1.38.0
mkdir -p build
cd build
mkdir -p ${{ env.gtest_lib_path }}
mkdir -p ${{ env.libuv_path }}
cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.libuv_path }}
msbuild INSTALL.vcxproj
- name: Install googletest
run: |
conda activate py376_build
curl https://codeload.github.com/google/googletest/tar.gz/release-1.10.0 --output `
googletest-release-1.10.0.tar.gz
tar xzvf googletest-release-1.10.0.tar.gz
cd googletest-release-1.10.0
curl -L https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz `
--output googletest-1.15.2.tar.gz
tar xzvf googletest-1.15.2.tar.gz
cd googletest-1.15.2
mkdir -p build
cd build
if (Test-Path -Path ${{ env.gtest_lib_path }}) {
echo "Directory already exists"
} else {
mkdir ${{ env.gtest_lib_path }}
mkdir -p ${{ env.gtest_lib_path }}
}
cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.gtest_lib_path }} -Dgtest_force_shared_crt=ON
msbuild INSTALL.vcxproj
Expand All @@ -76,9 +76,9 @@ jobs:
mkdir -p build
cd build
cmake .. -DBUILD_TEST=ON -Dlibuv_ROOT=${{ env.libuv_path }} `
-DGTEST_LIBRARY=${{ env.gtest_lib_path }}/lib/gtestd.lib `
-DGTEST_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest.lib `
-DGTEST_INCLUDE_DIR=${{ env.gtest_lib_path }}/include `
-DGTEST_MAIN_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest_maind.lib
-DGTEST_MAIN_LIBRARY=${{ env.gtest_lib_path }}/lib/gtest_main.lib
msbuild ALL_BUILD.vcxproj
- name: Test
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ jobs:
DEFAULT_BRANCH: "main"
# disable JSCPD (copy-paste checker)
VALIDATE_JSCPD: false
# disable CPP
VALIDATE_CPP: false
3 changes: 3 additions & 0 deletions gloo/allreduce_bcube.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#include <cstring>
#include <iomanip>
#include <iostream>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "gloo/algorithm.h"
#include "gloo/common/error.h"
Expand Down
19 changes: 19 additions & 0 deletions gloo/test/base_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ namespace test {

const char* kDefaultDevice = "localhost";

// Transports that instantiated algorithms can be tested against.
const std::vector<Transport> kTransportsForClassAlgorithms = {
Transport::TCP,
#if GLOO_HAVE_TRANSPORT_TCP_TLS
Transport::TCP_TLS,
#endif
};

// Transports that function algorithms can be tested against.
// This is the new style of calling collectives and must be
// preferred over the instantiated style.
const std::vector<Transport> kTransportsForFunctionAlgorithms = {
Transport::TCP,
#if GLOO_HAVE_TRANSPORT_TCP_TLS
Transport::TCP_TLS,
#endif
Transport::UV,
};

std::shared_ptr<::gloo::transport::Device> createDevice(Transport transport) {
#if GLOO_HAVE_TRANSPORT_TCP
if (transport == Transport::TCP) {
Expand Down
20 changes: 2 additions & 18 deletions gloo/test/base_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,8 @@ enum Transport {
UV,
};

// Transports that instantiated algorithms can be tested against.
const std::vector<Transport> kTransportsForClassAlgorithms{
Transport::TCP,
#if GLOO_HAVE_TRANSPORT_TCP_TLS
Transport::TCP_TLS,
#endif
};

// Transports that function algorithms can be tested against.
// This is the new style of calling collectives and must be
// preferred over the instantiated style.
const std::vector<Transport> kTransportsForFunctionAlgorithms{
Transport::TCP,
#if GLOO_HAVE_TRANSPORT_TCP_TLS
Transport::TCP_TLS,
#endif
Transport::UV,
};
extern const std::vector<Transport> kTransportsForClassAlgorithms;
extern const std::vector<Transport> kTransportsForFunctionAlgorithms;

std::shared_ptr<::gloo::transport::Device> createDevice(Transport transport);

Expand Down

0 comments on commit 23d66d7

Please sign in to comment.