github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/gpus/cuda/BUILD.tpl (about)

     1  load(":build_defs.bzl", "cuda_header_library")
     2  
     3  licenses(["restricted"])  # MPL2, portions GPL v3, LGPL v3, BSD-like
     4  
     5  package(default_visibility = ["//visibility:public"])
     6  
     7  config_setting(
     8      name = "using_nvcc",
     9      values = {
    10          "define": "using_cuda_nvcc=true",
    11      },
    12  )
    13  
    14  config_setting(
    15      name = "using_clang",
    16      values = {
    17          "define": "using_cuda_clang=true",
    18      },
    19  )
    20  
    21  # Equivalent to using_clang && -c opt.
    22  config_setting(
    23      name = "using_clang_opt",
    24      values = {
    25          "define": "using_cuda_clang=true",
    26          "compilation_mode": "opt",
    27      },
    28  )
    29  
    30  config_setting(
    31      name = "darwin",
    32      values = {"cpu": "darwin"},
    33  )
    34  
    35  config_setting(
    36      name = "freebsd",
    37      values = {"cpu": "freebsd"},
    38  )
    39  
    40  cuda_header_library(
    41      name = "cuda_headers",
    42      hdrs = [
    43          "cuda/cuda_config.h",
    44          ":cuda-include"
    45      ],
    46      include_prefix = "third_party/gpus",
    47      includes = [
    48          ".",  # required to include cuda/cuda/cuda_config.h as cuda/config.h
    49          "cuda/include",
    50      ],
    51  )
    52  
    53  cc_library(
    54      name = "cudart_static",
    55      srcs = ["cuda/lib/%{cudart_static_lib}"],
    56      linkopts = select({
    57          ":freebsd": [],
    58          "//conditions:default": ["-ldl"],
    59      }) + [
    60          "-lpthread",
    61          %{cudart_static_linkopt}
    62      ],
    63  )
    64  
    65  cc_library(
    66      name = "cuda_driver",
    67      srcs = ["cuda/lib/%{cuda_driver_lib}"],
    68  )
    69  
    70  cc_library(
    71      name = "cudart",
    72      srcs = ["cuda/lib/%{cudart_lib}"],
    73      data = ["cuda/lib/%{cudart_lib}"],
    74      linkstatic = 1,
    75  )
    76  
    77  cuda_header_library(
    78      name = "cublas_headers",
    79      hdrs = [":cublas-include"],
    80      include_prefix = "third_party/gpus/cuda/include",
    81      strip_include_prefix = "cublas/include",
    82      deps = [":cuda_headers"],
    83      includes = ["cublas/include"],
    84  )
    85  
    86  cc_library(
    87      name = "cublas",
    88      srcs = ["cuda/lib/%{cublas_lib}"],
    89      data = ["cuda/lib/%{cublas_lib}"],
    90      linkstatic = 1,
    91  )
    92  
    93  cc_library(
    94      name = "cusolver",
    95      srcs = ["cuda/lib/%{cusolver_lib}"],
    96      data = ["cuda/lib/%{cusolver_lib}"],
    97      linkopts = ["-lgomp"],
    98      linkstatic = 1,
    99  )
   100  
   101  cc_library(
   102      name = "cudnn",
   103      srcs = ["cuda/lib/%{cudnn_lib}"],
   104      data = ["cuda/lib/%{cudnn_lib}"],
   105      linkstatic = 1,
   106  )
   107  
   108  cc_library(
   109      name = "cudnn_header",
   110      hdrs = [":cudnn-include"],
   111      include_prefix = "third_party/gpus/cudnn",
   112      strip_include_prefix = "cudnn/include",
   113      deps = [":cuda_headers"],
   114  )
   115  
   116  cc_library(
   117      name = "cufft",
   118      srcs = ["cuda/lib/%{cufft_lib}"],
   119      data = ["cuda/lib/%{cufft_lib}"],
   120      linkstatic = 1,
   121  )
   122  
   123  cc_library(
   124      name = "curand",
   125      srcs = ["cuda/lib/%{curand_lib}"],
   126      data = ["cuda/lib/%{curand_lib}"],
   127      linkstatic = 1,
   128  )
   129  
   130  cc_library(
   131      name = "cuda",
   132      deps = [
   133          ":cublas",
   134          ":cuda_headers",
   135          ":cudart",
   136          ":cudnn",
   137          ":cufft",
   138          ":curand",
   139      ],
   140  )
   141  
   142  cuda_header_library(
   143      name = "cupti_headers",
   144      hdrs = [":cuda-extras"],
   145      include_prefix="third_party/gpus",
   146      includes = ["cuda/extras/CUPTI/include/"],
   147      deps = [":cuda_headers"],
   148  )
   149  
   150  cc_library(
   151      name = "cupti_dsos",
   152      data = ["cuda/lib/%{cupti_lib}"],
   153  )
   154  
   155  cc_library(
   156      name = "cusparse",
   157      srcs = ["cuda/lib/%{cusparse_lib}"],
   158      data = ["cuda/lib/%{cusparse_lib}"],
   159      linkopts = ["-lgomp"],
   160      linkstatic = 1,
   161  )
   162  
   163  cc_library(
   164      name = "libdevice_root",
   165      data = [":cuda-nvvm"],
   166  )
   167  
   168  %{copy_rules}