Skip to content
Permalink
Browse files

Add folly dependency

Summary: Pull Request resolved: #4051

Differential Revision: D19851030

Pulled By: bertmaher

fbshipit-source-id: 0677dedebc0acb9fedd0c6880cdd749fdaf213b4
  • Loading branch information
bertmaher authored and facebook-github-bot committed Feb 12, 2020
1 parent bf59d89 commit 75fa5e5f6f1dff1654b4b8dae8de9d034d47b999
Showing with 62 additions and 9 deletions.
  1. +17 −2 .circleci/build.sh
  2. +0 −5 .circleci/config.yml
  3. +3 −0 .gitmodules
  4. +24 −0 CMakeLists.txt
  5. +5 −2 README.md
  6. +3 −0 tests/unittests/CMakeLists.txt
  7. +9 −0 tests/unittests/FollyTest.cpp
  8. +1 −0 thirdparty/folly
@@ -38,6 +38,19 @@ install_pocl() {
cd ../
}

install_fmt() {
git clone https://github.com/fmtlib/fmt
pushd fmt
mkdir build
cd build
cmake ..
make -j`nproc`
sudo make install
popd
}

GLOW_DEPS="libpng-dev libgoogle-glog-dev libboost-all-dev libdouble-conversion-dev libgflags-dev libjemalloc-dev libpthread-stubs0-dev libevent-dev libssl-dev"

if [ "${CIRCLE_JOB}" == "CHECK_CLANG_AND_PEP8_FORMAT" ]; then
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
curl -sSL "https://build.travis-ci.org/files/gpg/llvm-toolchain-trusty-7.asc" | sudo -E apt-key add -
@@ -53,7 +66,8 @@ elif [ "${CIRCLE_JOB}" == "PYTORCH" ]; then
sudo ln -s /usr/bin/llvm-symbolizer-7 /usr/bin/llvm-symbolizer
sudo ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config-7.0

sudo apt-get install -y libpng-dev libgoogle-glog-dev
sudo apt-get install -y ${GLOW_DEPS}
install_fmt
else
# Install Glow dependencies
sudo apt-get update
@@ -64,7 +78,8 @@ else
sudo ln -s /usr/bin/llvm-symbolizer-8 /usr/bin/llvm-symbolizer
sudo ln -s /usr/bin/llvm-config-8 /usr/bin/llvm-config-8.0

sudo apt-get install -y libpng-dev libgoogle-glog-dev
sudo apt-get install -y ${GLOW_DEPS}
install_fmt
fi

# Since we are using llvm-7 in these two branches, we cannot use pip install cmake
@@ -85,10 +85,6 @@ jobs:
environment:
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/caffe2/py2-clang8-ubuntu16.04:283"
<<: *linux_default
SHARED:
environment:
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/caffe2/py2-clang8-ubuntu16.04:283"
<<: *linux_default
32B_DIM_T:
environment:
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/caffe2/py2-clang8-ubuntu16.04:283"
@@ -117,7 +113,6 @@ workflows:
- OPENCL
- ASAN
- TSAN
- SHARED
- 32B_DIM_T
- RELEASE_WITH_EXPENSIVE_TESTS
- COVERAGE
@@ -19,3 +19,6 @@
[submodule "thirdparty/pybind11"]
path = thirdparty/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "thirdparty/folly"]
path = thirdparty/folly
url = https://github.com/facebook/folly.git
@@ -186,6 +186,30 @@ else()
include_directories(${GLOW_THIRDPARTY_DIR}/fp16/include)
endif()

if(NOT EXISTS "${GLOW_THIRDPARTY_DIR}/folly/folly")
message(FATAL_ERROR "No folly git submodule. Run: git submodule update --init --recursive")
else()
# Apple-specific definitions for folly.
if(APPLE)
set(FOLLY_HAVE_WEAK_SYMBOLS ON CACHE BOOL "Compiler supports weak symbols")
set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)
find_package(OpenSSL REQUIRED)
endif()

# Remove Glow-specific CMAKE_CXX_FLAGS to build folly.
set(SAVE_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "")
set(SAVE_CMAKE_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
unset(CMAKE_CXX_STANDARD)
add_subdirectory("${GLOW_THIRDPARTY_DIR}/folly" EXCLUDE_FROM_ALL)
target_include_directories(folly PUBLIC "${OPENSSL_INCLUDE_DIR}")
set(CMAKE_CXX_FLAGS "${SAVE_CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_STANDARD "${SAVE_CMAKE_CXX_STANDARD}")

add_library(folly_jemalloc INTERFACE)
target_link_libraries(folly_jemalloc INTERFACE folly jemalloc)
endif()

add_library(Miniz
${GLOW_THIRDPARTY_DIR}/miniz-2.0.8/miniz.c)
target_include_directories(Miniz PUBLIC ${GLOW_THIRDPARTY_DIR}/miniz-2.0.8)
@@ -79,13 +79,16 @@ Install the required dependencies using either [Homebrew](https://brew.sh/) or
[MacPorts](https://www.macports.org/). If using Homebrew, run:

```bash
brew install cmake graphviz libpng ninja protobuf wget glog autopep8 llvm
brew install cmake graphviz libpng ninja protobuf wget glog autopep8 llvm \
boost double-conversion gflags jemalloc libevent lz4 openssl pkg-config \
snappy xz
```

If using MacPorts, run:

```bash
port install cmake graphviz libpng ninja protobuf-cpp wget google-glog
port install cmake graphviz libpng ninja protobuf-cpp wget google-glog \
boost double-conversion gflags jemalloc libevent lz4 openssl snappy xz
# Choose version >= 7
export LLVM_VERSION=7
port install llvm-$LLVM_VERSION.0
@@ -136,6 +136,9 @@ add_glow_test(NAME GlowOnnxifiManagerTest
--gtest_output=xml:GlowOnnxifiManagerTest.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

add_executable(FollyTest FollyTest.cpp)
target_link_libraries(FollyTest PRIVATE folly_jemalloc gtest TestMain)

add_executable(GraphGradTest
GraphGradTest.cpp)
target_link_libraries(GraphGradTest
@@ -0,0 +1,9 @@
#include <folly/Format.h>
#include <gtest/gtest.h>
#include <sstream>

TEST(Folly, Format) {
std::ostringstream s;
s << folly::format("The answer is {}", 42);
ASSERT_TRUE(s.str() == "The answer is 42");
}
Submodule folly added at c94486

0 comments on commit 75fa5e5

Please sign in to comment.
You can’t perform that action at this time.