blob: df402787eeb6f8d648bbc4d309ed1bd5de3ff7b8 [file] [log] [blame]
# Subfolders in the third_party folder are used to help install things more
# easily and you should pre-install them on your machine.
###############################################################################
# BLAS
# This section is intended to be the central location that hosts all possible
# BLAS backends. Note that all these are only linking flags, so if one of the
# libraries is not used, don't bother installing it - Caffe2 will still build
# normally.
##############################################################################
# A catch-all target: all the targets should link to this instead of ther
# specific libraries below.
cc_library(
name = "blas",
srcs = [],
deps = [":" + Brewery.Env.Config.BLAS_BACKEND],
)
# Atlas
cc_thirdparty_target(
name = "atlas",
cc_obj_files = [ "-lcblas -latlas" ],
)
# Eigen
# Current eigen version: 3.3 beta 1
if Brewery.Env.Config.USE_SYSTEM_EIGEN:
# If we are using system eigen, this is just a dummy placeholder that does
# nothing. Also, Eigen is a header-only library so there is no cc_obj_files.
cc_thirdparty_target(
name = "eigen",
cc_obj_files = [],
)
else:
# We need to copy over the code included in Caffe.
shell_script(
name = "eigen",
srcs = ["BREW"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/eigen/Eigen $DST/",
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/eigen/unsupported $DST/",
],
)
# Intel MKL.
cc_thirdparty_target(
name = "mkl",
cc_obj_files = [ "-lmkl_rt" ],
)
# OpenBLAS
cc_thirdparty_target(
name = "openblas",
cc_obj_files = [ "-lopenblas" ],
)
# TODO: add the OS X veclib/Accelerate framework backend.
###############################################################################
# CUDA
# This section includes all cuda-related dependencies.
##############################################################################
if Brewery.Env.Config.LINK_CUDA_STATIC:
cc_thirdparty_target(
name = "cuda",
cc_obj_files = [
"-lcublas_static",
"-lcurand_static",
"-lcudart_static",
"-lculibos",
"-ldl",
] +
(["-lrt"] if Brewery.Env.NEED_LIBRT else [])
)
else:
cc_thirdparty_target(
name = "cuda",
cc_obj_files = [
"-lcublas",
"-lcurand",
"-lcudart",
"-lculibos",
"-ldl",
] +
(["-lrt"] if Brewery.Env.NEED_LIBRT else [])
)
cc_thirdparty_target(
name = "cudnn",
deps = [":cuda"],
cc_obj_files = ["-lcudnn_static"],
)
cc_thirdparty_target(
name = "nvrtc",
deps = [
":cuda",
],
cc_obj_files = [
"-lnvrtc",
"-lcuda",
],
)
shell_script(
name = "cnmem_header",
srcs = ["cnmem/include/cnmem.h"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp $CAFFE2_SRCDIR/$CAFFE2_CWD/cnmem/include/cnmem.h $DST/",
],
)
cc_library(
name = "cnmem",
srcs = [
"cnmem/src/cnmem.cpp",
],
deps = [
":cnmem_header",
":cuda",
]
)
shell_script(
name = "nccl_header",
srcs = ["nccl/src/nccl.h"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp $CAFFE2_SRCDIR/$CAFFE2_CWD/nccl/src/nccl.h $DST/",
],
)
cuda_library(
name = "nccl",
srcs = Glob(["nccl/src/*.cu"]),
deps = [
":nccl_header",
":cuda",
],
compiler_flags=[
"-Wno-switch", # NCCL does not follow strict switch enum check.
"-DNCCL_MAJOR=1 -DNCCL_MINOR=2 -DNCCL_PATCH=3",
"-DCUDA_MAJOR=__CUDACC_VER_MAJOR__ -DCUDA_MINOR=__CUDACC_VER_MINOR__",
],
)
shell_script(
name = "cub",
srcs = Glob(["cub/cub/*.h", "cub/cub/*/*.h", "cub/cub/*/*/*.h"]),
commands = [
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/cub/cub $DST/",
],
)
###############################################################################
# Protobuf
# This section includes all protobuf-related dependencies.
# Current protobuf version: 3.0.0
##############################################################################
if Brewery.Env.Config.USE_SYSTEM_PROTOBUF:
# Use system-installed protobuf.
cc_thirdparty_target(
name = "protobuf_lite",
cc_obj_files=["-lprotobuf-lite"],
)
cc_thirdparty_target(
name = "protobuf",
cc_obj_files=["-lprotobuf"],
)
cc_thirdparty_target(
name = "protoc",
cc_obj_files=[],
)
else:
# Use custom protobuf.
shell_script(
name = "protobuf_headers",
srcs = Glob([
"BREW",
"protobuf/src/google/protobuf/*.h",
"protobuf/src/google/protobuf/*/*.h",
"protobuf/src/google/protobuf/*/*/*.h",
"protobuf/src/google/protobuf/*/*/*/*.h",
]),
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"rsync -am --include='*.h' -f 'hide,! */' $CAFFE2_SRCDIR/$CAFFE2_CWD/protobuf/src/google $DST",
],
)
cc_library(
name = "protobuf_lite",
srcs = [
"protobuf/src/google/protobuf/arena.cc",
"protobuf/src/google/protobuf/arenastring.cc",
"protobuf/src/google/protobuf/extension_set.cc",
"protobuf/src/google/protobuf/generated_message_util.cc",
"protobuf/src/google/protobuf/io/coded_stream.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"protobuf/src/google/protobuf/message_lite.cc",
"protobuf/src/google/protobuf/repeated_field.cc",
"protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
"protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
"protobuf/src/google/protobuf/stubs/bytestream.cc",
"protobuf/src/google/protobuf/stubs/common.cc",
"protobuf/src/google/protobuf/stubs/int128.cc",
"protobuf/src/google/protobuf/stubs/once.cc",
"protobuf/src/google/protobuf/stubs/status.cc",
"protobuf/src/google/protobuf/stubs/statusor.cc",
"protobuf/src/google/protobuf/stubs/stringpiece.cc",
"protobuf/src/google/protobuf/stubs/stringprintf.cc",
"protobuf/src/google/protobuf/stubs/structurally_valid.cc",
"protobuf/src/google/protobuf/stubs/strutil.cc",
"protobuf/src/google/protobuf/stubs/time.cc",
"protobuf/src/google/protobuf/wire_format_lite.cc",
],
deps = [
":protobuf_headers",
]
)
cc_library(
name = "protobuf",
srcs = [
"protobuf/src/google/protobuf/any.cc",
"protobuf/src/google/protobuf/any.pb.cc",
"protobuf/src/google/protobuf/api.pb.cc",
"protobuf/src/google/protobuf/compiler/importer.cc",
"protobuf/src/google/protobuf/compiler/parser.cc",
"protobuf/src/google/protobuf/descriptor.cc",
"protobuf/src/google/protobuf/descriptor.pb.cc",
"protobuf/src/google/protobuf/descriptor_database.cc",
"protobuf/src/google/protobuf/duration.pb.cc",
"protobuf/src/google/protobuf/dynamic_message.cc",
"protobuf/src/google/protobuf/empty.pb.cc",
"protobuf/src/google/protobuf/extension_set_heavy.cc",
"protobuf/src/google/protobuf/field_mask.pb.cc",
"protobuf/src/google/protobuf/generated_message_reflection.cc",
"protobuf/src/google/protobuf/io/gzip_stream.cc",
"protobuf/src/google/protobuf/io/printer.cc",
"protobuf/src/google/protobuf/io/strtod.cc",
"protobuf/src/google/protobuf/io/tokenizer.cc",
"protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc",
"protobuf/src/google/protobuf/map_field.cc",
"protobuf/src/google/protobuf/message.cc",
"protobuf/src/google/protobuf/reflection_ops.cc",
"protobuf/src/google/protobuf/service.cc",
"protobuf/src/google/protobuf/source_context.pb.cc",
"protobuf/src/google/protobuf/struct.pb.cc",
"protobuf/src/google/protobuf/stubs/mathlimits.cc",
"protobuf/src/google/protobuf/stubs/substitute.cc",
"protobuf/src/google/protobuf/text_format.cc",
"protobuf/src/google/protobuf/timestamp.pb.cc",
"protobuf/src/google/protobuf/type.pb.cc",
"protobuf/src/google/protobuf/unknown_field_set.cc",
"protobuf/src/google/protobuf/util/field_comparator.cc",
"protobuf/src/google/protobuf/util/field_mask_util.cc",
"protobuf/src/google/protobuf/util/internal/datapiece.cc",
"protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/error_listener.cc",
"protobuf/src/google/protobuf/util/internal/field_mask_utility.cc",
"protobuf/src/google/protobuf/util/internal/json_escaping.cc",
"protobuf/src/google/protobuf/util/internal/json_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/json_stream_parser.cc",
"protobuf/src/google/protobuf/util/internal/object_writer.cc",
"protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc",
"protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc",
"protobuf/src/google/protobuf/util/internal/type_info.cc",
"protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc",
"protobuf/src/google/protobuf/util/internal/utility.cc",
"protobuf/src/google/protobuf/util/json_util.cc",
"protobuf/src/google/protobuf/util/message_differencer.cc",
"protobuf/src/google/protobuf/util/time_util.cc",
"protobuf/src/google/protobuf/util/type_resolver_util.cc",
"protobuf/src/google/protobuf/wire_format.cc",
"protobuf/src/google/protobuf/wrappers.pb.cc",
],
deps = [":protobuf_lite"],
)
cc_library(
name = "protoc_lib",
srcs = [
"protobuf/src/google/protobuf/compiler/code_generator.cc",
"protobuf/src/google/protobuf/compiler/command_line_interface.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc",
"protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
"protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_context.cc",
"protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_extension.cc",
"protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_file.cc",
"protobuf/src/google/protobuf/compiler/java/java_generator.cc",
"protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc",
"protobuf/src/google/protobuf/compiler/java/java_helpers.cc",
"protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_map_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_builder.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_message_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc",
"protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
"protobuf/src/google/protobuf/compiler/java/java_service.cc",
"protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
"protobuf/src/google/protobuf/compiler/java/java_string_field.cc",
"protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_enum.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_extension.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_file.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_generator.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_helpers.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_map_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_message.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_message_field.cc",
"protobuf/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/js/js_generator.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
"protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
"protobuf/src/google/protobuf/compiler/plugin.cc",
"protobuf/src/google/protobuf/compiler/plugin.pb.cc",
"protobuf/src/google/protobuf/compiler/python/python_generator.cc",
"protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc",
"protobuf/src/google/protobuf/compiler/subprocess.cc",
"protobuf/src/google/protobuf/compiler/zip_writer.cc",
],
deps = [":protobuf"],
)
cc_binary(
name = "protoc",
srcs = ["protobuf/src/google/protobuf/compiler/main.cc"],
deps = [":protoc_lib"],
)
###############################################################################
# Google googletest
# Current version: release-1.8.0
##############################################################################
shell_script(
name = "gtest_hdrs",
srcs = ["BREW"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/googletest/googletest/include/gtest $DST/",
# The following is so that gtest-all.cc can find the related cc files.
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/googletest/googletest/src $DST/",
],
)
cc_library(
name="gtest",
srcs=[
"googletest/googletest/src/gtest-all.cc",
],
deps=["gtest_hdrs"],
)
###############################################################################
# Nervana
##############################################################################
shell_script(
name = "nervana_header",
srcs = ["nervanagpu/nervanagpu/kernels/C_interface/nervana_c_api.h"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp $CAFFE2_SRCDIR/$CAFFE2_CWD/nervanagpu/nervanagpu/kernels/C_interface/nervana_c_api.h $DST/",
],
)
cuda_library(
name = "nervana_c_interface",
srcs = ["nervanagpu/nervanagpu/kernels/C_interface/nervana_c_api.cu"],
deps = [
":nervana_header",
":cuda",
],
)
###############################################################################
# Other libraries
# This section includes all other libraries in alphabet order.
##############################################################################
cc_thirdparty_target(
name="gflags",
cc_obj_files = ["-lgflags"] if Brewery.Env.Config.USE_GFLAGS else [],
)
cc_thirdparty_target(
name="glog",
cc_obj_files = ["-lglog"] if Brewery.Env.Config.USE_GLOG else [],
)
cc_thirdparty_target(
name = "leveldb",
deps = [":snappy"],
cc_obj_files = [ "-lleveldb" ],
)
cc_thirdparty_target(
name = "libz",
cc_obj_files = [ "-lz" ],
)
cc_thirdparty_target(
name = "libbz2",
cc_obj_files = [ "-lbz2" ],
)
cc_thirdparty_target(
name = "rocksdb",
deps = [":libz", ":libbz2", ":snappy"],
cc_obj_files = [ "-lrocksdb" ],
)
cc_thirdparty_target(
name = "lmdb",
cc_obj_files = ["-llmdb"],
)
cc_thirdparty_target(
name = "libzmq",
cc_obj_files = [ "-lzmq" ],
)
cc_thirdparty_target(
name="opencv",
cc_obj_files=[
"-lopencv_core",
"-lopencv_highgui",
"-lopencv_imgproc",
],
)
cc_thirdparty_target(
name="openmpi",
cc_obj_files = ['-l' + s for s in Brewery.Env.MPI_LIBS]
)
cc_thirdparty_target(
name = "snappy",
cc_obj_files = ["-lsnappy"],
)
shell_script(
name = "pybind11",
srcs = ["BREW"],
commands=[
"DST=$CAFFE2_GENDIR/third_party/include/",
"mkdir -p $DST",
"cp -r $CAFFE2_SRCDIR/$CAFFE2_CWD/pybind11/include/pybind11 $DST/",
],
)