Locate libdevice files for OSS build.
1. Created open-source target libdevice_root that wraps all libdevice files. 2. platform/posix/cuda_libdevice_path depends on the libdevice_root target. 3. Added cuda_libdevice_path_test that verifies libdevice files exist in the computed libdevice directory. Change: 141237087
This commit is contained in:
parent
008f80e623
commit
b2bcf5f75e
@ -1802,6 +1802,20 @@ tf_cc_tests_gpu(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tf_cc_test_gpu(
|
||||||
|
name = "cuda_libdevice_path_test",
|
||||||
|
size = "small",
|
||||||
|
srcs = ["platform/cuda_libdevice_path_test.cc"],
|
||||||
|
linkstatic = tf_kernel_tests_linkstatic(),
|
||||||
|
tags = tf_cuda_tests_tags(),
|
||||||
|
deps = [
|
||||||
|
":cuda_libdevice_path",
|
||||||
|
":lib",
|
||||||
|
":test",
|
||||||
|
":test_main",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
tf_cc_test_gpu(
|
tf_cc_test_gpu(
|
||||||
name = "memory_types_test",
|
name = "memory_types_test",
|
||||||
size = "small",
|
size = "small",
|
||||||
|
36
tensorflow/core/platform/cuda_libdevice_path_test.cc
Normal file
36
tensorflow/core/platform/cuda_libdevice_path_test.cc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include "tensorflow/core/platform/cuda_libdevice_path.h"
|
||||||
|
|
||||||
|
#include "tensorflow/core/lib/core/status_test_util.h"
|
||||||
|
#include "tensorflow/core/lib/io/path.h"
|
||||||
|
#include "tensorflow/core/platform/env.h"
|
||||||
|
#include "tensorflow/core/platform/test.h"
|
||||||
|
|
||||||
|
namespace tensorflow {
|
||||||
|
|
||||||
|
#if GOOGLE_CUDA
|
||||||
|
TEST(CudaLibdevicePathTest, LibdevicePath) {
|
||||||
|
VLOG(2) << "Libdevice root = " << LibdeviceRoot();
|
||||||
|
std::vector<string> libdevice_files;
|
||||||
|
TF_EXPECT_OK(Env::Default()->GetMatchingPaths(
|
||||||
|
io::JoinPath(LibdeviceRoot(), "libdevice.compute_*.bc"),
|
||||||
|
&libdevice_files));
|
||||||
|
EXPECT_LT(0, libdevice_files.size());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace tensorflow
|
@ -143,7 +143,7 @@ def tf_additional_cupti_wrapper_deps():
|
|||||||
return ["//tensorflow/core/platform/default/gpu:cupti_wrapper"]
|
return ["//tensorflow/core/platform/default/gpu:cupti_wrapper"]
|
||||||
|
|
||||||
def tf_additional_libdevice_data():
|
def tf_additional_libdevice_data():
|
||||||
return []
|
return ["@local_config_cuda//cuda:libdevice_root"]
|
||||||
|
|
||||||
def tf_additional_libdevice_deps():
|
def tf_additional_libdevice_deps():
|
||||||
return []
|
return []
|
||||||
|
@ -15,11 +15,24 @@ limitations under the License.
|
|||||||
|
|
||||||
#include "tensorflow/core/platform/cuda_libdevice_path.h"
|
#include "tensorflow/core/platform/cuda_libdevice_path.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "tensorflow/core/lib/strings/strcat.h"
|
||||||
|
#include "tensorflow/core/platform/default/logging.h"
|
||||||
|
|
||||||
namespace tensorflow {
|
namespace tensorflow {
|
||||||
|
|
||||||
string CudaRoot() {
|
string CudaRoot() {
|
||||||
// TODO(b/33147798): Compute the CUDA root for open-source build.
|
// 'bazel test' sets TEST_SRCDIR.
|
||||||
return ".";
|
const string kRelativeCudaRoot = "local_config_cuda/cuda";
|
||||||
|
const char* env = getenv("TEST_SRCDIR");
|
||||||
|
if (env && env[0] != '\0') {
|
||||||
|
return strings::StrCat(env, "/", kRelativeCudaRoot);
|
||||||
|
} else {
|
||||||
|
LOG(WARNING) << "TEST_SRCDIR environment variable not set: "
|
||||||
|
<< "using $PWD/" << kRelativeCudaRoot << "as the CUDA root.";
|
||||||
|
return kRelativeCudaRoot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tensorflow
|
} // namespace tensorflow
|
||||||
|
6
third_party/gpus/cuda/BUILD.tpl
vendored
6
third_party/gpus/cuda/BUILD.tpl
vendored
@ -160,3 +160,9 @@ cc_library(
|
|||||||
],
|
],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "libdevice_root",
|
||||||
|
data = glob(["nvvm/libdevice/*.bc"]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user