Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit 113aba7

Browse files
committed
Initial commit for public release
0 parents  commit 113aba7

File tree

190 files changed

+32811
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+32811
-0
lines changed

.circleci/config.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
3+
jobs:
4+
build_and_test_1804:
5+
resource_class: xlarge
6+
docker:
7+
- image: pytorch/elf:ci_ubuntu_1804
8+
steps:
9+
- checkout
10+
- run:
11+
name: submodules
12+
command: |
13+
git submodule sync
14+
git submodule update --init --recursive
15+
- run:
16+
name: cpp_style
17+
command: ./codetools/check_cpp_style.sh
18+
- run:
19+
name: python_style
20+
command: ./codetools/check_py_style.sh
21+
- run:
22+
name: compile
23+
command: make clean all VERBOSE=1
24+
- run:
25+
name: cpp_tests
26+
command: make test_cpp
27+
- run:
28+
name: python_tests
29+
command: "true"
30+
31+
workflows:
32+
version: 2
33+
build_and_test_1804:
34+
jobs:
35+
- build_and_test_1804
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:bionic
2+
3+
WORKDIR /tmp/docker_init
4+
SHELL ["/bin/bash", "-c"]
5+
6+
RUN apt-get update
7+
RUN apt-get install -y \
8+
clang-format \
9+
clang-tidy \
10+
cmake \
11+
curl \
12+
g++ \
13+
gcc \
14+
git \
15+
libboost-all-dev \
16+
libzmq3-dev \
17+
;
18+
RUN ln -sf `which clang-format-6.0` /usr/bin/clang-format
19+
RUN curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh > conda_install.sh
20+
RUN bash conda_install.sh -p /conda -b
21+
ENV PATH=/conda/bin:${PATH}
22+
RUN conda update -n base conda
23+
RUN conda create -yn elf_env python=3.6
24+
RUN source activate elf_env
25+
RUN conda install -y \
26+
flake8 \
27+
numpy \
28+
pytest \
29+
zeromq \
30+
;
31+
RUN conda install -c conda-forge autopep8
32+
RUN conda install -c pytorch pytorch torchvision cuda90
33+
34+
RUN rm -rf /tmp/docker_init

.clang-format

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
ColumnLimit: 80
37+
CommentPragmas: '^ IWYU pragma:'
38+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
39+
ConstructorInitializerIndentWidth: 4
40+
ContinuationIndentWidth: 4
41+
Cpp11BracedListStyle: true
42+
DerivePointerAlignment: false
43+
DisableFormat: false
44+
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
45+
IncludeCategories:
46+
- Regex: '^<.*\.h(pp)?>'
47+
Priority: 1
48+
- Regex: '^<.*'
49+
Priority: 2
50+
- Regex: '.*'
51+
Priority: 3
52+
IndentCaseLabels: true
53+
IndentWidth: 2
54+
IndentWrappedFunctionNames: false
55+
KeepEmptyLinesAtTheStartOfBlocks: false
56+
MacroBlockBegin: ''
57+
MacroBlockEnd: ''
58+
MaxEmptyLinesToKeep: 1
59+
NamespaceIndentation: None
60+
ObjCBlockIndentWidth: 2
61+
ObjCSpaceAfterProperty: false
62+
ObjCSpaceBeforeProtocolList: false
63+
PenaltyBreakBeforeFirstCallParameter: 1
64+
PenaltyBreakComment: 300
65+
PenaltyBreakFirstLessLess: 120
66+
PenaltyBreakString: 1000
67+
PenaltyExcessCharacter: 1000000
68+
PenaltyReturnTypeOnItsOwnLine: 200
69+
PointerAlignment: Left
70+
ReflowComments: true
71+
SortIncludes: true
72+
SpaceAfterCStyleCast: false
73+
SpaceBeforeAssignmentOperators: true
74+
SpaceBeforeParens: ControlStatements
75+
SpaceInEmptyParentheses: false
76+
SpacesBeforeTrailingComments: 1
77+
SpacesInAngles: false
78+
SpacesInContainerLiterals: true
79+
SpacesInCStyleCastParentheses: false
80+
SpacesInParentheses: false
81+
SpacesInSquareBrackets: false
82+
Standard: Cpp11
83+
TabWidth: 8
84+
UseTab: Never
85+
...

.flake8

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude =
3+
__init__.py
4+
__pycache__,
5+
.git,
6+
build,
7+
experimental,
8+
third_party,

.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build and interpreter artifacts
2+
*.a
3+
*.bin
4+
*.dSYM
5+
*.o
6+
*.pyc
7+
*.so
8+
build/
9+
__pycache__/
10+
11+
# Random junk
12+
*.sw?
13+
*.db
14+
*.json
15+
*.sgf
16+
*.swo
17+
*.tree
18+
.codemod.bookmark
19+
.nfs*
20+
tmp*.sh
21+
tags
22+
build/
23+
save_dir*/
24+
test-*/
25+
Testing/
26+
pachi-*/
27+
experimental/patterns.prob
28+
experimental/patterns.spat

.gitmodules

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[submodule "third_party/concurrentqueue"]
2+
path = third_party/concurrentqueue
3+
url = https://github.com/cameron314/concurrentqueue.git
4+
[submodule "third_party/cppzmq"]
5+
path = third_party/cppzmq
6+
url = https://github.com/zeromq/cppzmq.git
7+
[submodule "third_party/googletest"]
8+
path = third_party/googletest
9+
url = https://github.com/google/googletest.git
10+
[submodule "third_party/json"]
11+
path = third_party/json
12+
url = https://github.com/nlohmann/json.git
13+
[submodule "third_party/pybind11"]
14+
path = third_party/pybind11
15+
url = https://github.com/pybind/pybind11.git
16+
[submodule "third_party/spdlog"]
17+
path = third_party/spdlog
18+
url = https://github.com/gabime/spdlog.git
19+
[submodule "third_party/tbb"]
20+
path = third_party/tbb
21+
url = https://github.com/01org/tbb.git

CMakeLists.txt

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
cmake_minimum_required(VERSION 3.3)
2+
3+
# Basic third-party dependencies
4+
5+
find_package(Threads)
6+
7+
#find_package(Boost REQUIRED COMPONENTS
8+
# thread
9+
#)
10+
#include_directories(${Boost_INCLUDE_DIR})
11+
12+
# Include third-party dependencies
13+
14+
add_subdirectory(
15+
third_party
16+
${CMAKE_CURRENT_BINARY_DIR}/third_party)
17+
find_package(TBB REQUIRED tbb) # Need to find_package in parent scope
18+
19+
# Sanity checks
20+
21+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
22+
# require at least gcc 7.1
23+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1)
24+
message(FATAL_ERROR "GCC version must be at least 7.1!")
25+
endif()
26+
endif()
27+
28+
# Variables from Git
29+
30+
execute_process(COMMAND git rev-parse HEAD
31+
OUTPUT_VARIABLE GIT_COMMIT_HASH)
32+
string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH)
33+
execute_process(COMMAND git diff-index --quiet HEAD --
34+
RESULT_VARIABLE GIT_UNSTAGED)
35+
if(${GIT_UNSTAGED})
36+
set(GIT_STAGED_STRING unstaged)
37+
else()
38+
set(GIT_STAGED_STRING staged)
39+
endif()
40+
41+
# Global compiler config
42+
43+
set(CMAKE_CXX_STANDARD 17)
44+
set(PYBIND11_CPP_STANDARD -std=c++17)
45+
set(CMAKE_CXX_FLAGS
46+
"${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-register -fPIC -march=native")
47+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
48+
if(NOT CMAKE_BUILD_TYPE)
49+
set(CMAKE_BUILD_TYPE Release)
50+
endif()
51+
52+
# Define a convenience function for tests
53+
function(add_cpp_tests prefix lib_to_link)
54+
set(test_list ${ARGV})
55+
list(REMOVE_AT test_list 0)
56+
list(REMOVE_AT test_list 0)
57+
foreach(test_file ${test_list})
58+
string(REPLACE "/" "_" test_name ${test_file})
59+
string(REPLACE ".cc" "" test_name ${test_name})
60+
string(CONCAT test_name ${prefix} ${test_name})
61+
add_executable(${test_name} ${test_file})
62+
add_test(${test_name} ${test_name})
63+
target_link_libraries(${test_name} ${lib_to_link} gtest)
64+
endforeach(test_file)
65+
endfunction(add_cpp_tests)
66+
67+
# Include everything in src_cpp
68+
69+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src_cpp/)
70+
71+
# Main ELF library
72+
73+
add_subdirectory(
74+
src_cpp/elf
75+
${CMAKE_CURRENT_BINARY_DIR}/elf)
76+
77+
# ELF games
78+
79+
add_subdirectory(
80+
src_cpp/elfgames/go
81+
${CMAKE_CURRENT_BINARY_DIR}/elfgames/go)

CODE_OF_CONDUCT.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
===============
2+
Code of Conduct
3+
===============
4+
5+
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the `full text`__ so that you can understand what actions will and will not be tolerated.
6+
7+
__ https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct)

CONTRIBUTING.rst

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
===================
2+
Contributing to ELF
3+
===================
4+
5+
We want to make contributing to this project as easy and transparent as possible.
6+
7+
Dependencies
8+
============
9+
10+
In addition to the project dependencies, you'll need the following if you'd like to contribute code to ELF2::
11+
12+
sudo apt-get install clang-format clang-tidy
13+
conda install flake8 pytest
14+
conda install -c conda-forge autopep8
15+
16+
Pull Requests
17+
=============
18+
19+
We actively welcome your pull requests.
20+
21+
1. Fork the repo and create your branch from ``master``.
22+
2. If you've added code that should be tested, add tests.
23+
3. If you've changed APIs, update the documentation.
24+
4. Ensure the test suite passes.
25+
5. Make sure your code lints (see the ``codetools/`` directory).
26+
6. If you haven't already, complete the Contributor License Agreement ("CLA").
27+
28+
We have a continuous integration system that will double-check steps 4 and 5 for you.
29+
30+
Contributor License Agreement ("CLA")
31+
=====================================
32+
33+
In order to accept your pull request, we need you to submit a CLA. You only need
34+
to do this once to work on any of Facebook's open source projects.
35+
36+
Complete your CLA `here`__.
37+
38+
__ https://code.facebook.com/cla
39+
40+
Issues
41+
======
42+
43+
We use GitHub issues to track public bugs. Please ensure your description is
44+
clear and has sufficient instructions to be able to reproduce the issue.
45+
46+
This project is still an extremely unstable prototype so we will be limited in
47+
the amount of support we're able to provide.
48+
49+
Coding Style
50+
============
51+
52+
- For C++, we use a style very similar to the `HHVM style guide`__. This prescription is not formal, and our ``.clang-format`` file and existing code should eventually be a good source of truth. Due to a quirk of ``Python.h``, all ``pybind`` includes must be first in the include order.
53+
- For Python, we use pep8.
54+
55+
__ https://github.com/facebook/hhvm/blob/master/hphp/doc/coding-conventions.md
56+
57+
We have tools to check your C++ and Python code in the ``codetools/`` directory
58+
59+
License
60+
=======
61+
62+
By contributing to ELF, you agree that your contributions will be licensed
63+
under the LICENSE file in the root directory of this source tree.

0 commit comments

Comments
 (0)