Refactor stream executor BUILD files.
PiperOrigin-RevId: 227048559
This commit is contained in:
parent
1a8bc41039
commit
8f4567a139
tensorflow
core/platform
stream_executor
@ -18,11 +18,6 @@ limitations under the License.
|
||||
|
||||
#include "tensorflow/core/platform/platform.h"
|
||||
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/dso_loader.h"
|
||||
#else
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
#endif
|
||||
#include "tensorflow/stream_executor/cuda/cuda_platform_id.h"
|
||||
#include "tensorflow/stream_executor/device_memory.h"
|
||||
#include "tensorflow/stream_executor/dnn.h"
|
||||
@ -31,6 +26,7 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
||||
#include "tensorflow/stream_executor/multi_platform_manager.h"
|
||||
#include "tensorflow/stream_executor/platform.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/scratch_allocator.h"
|
||||
#include "tensorflow/stream_executor/stream.h"
|
||||
#include "tensorflow/stream_executor/stream_executor.h"
|
||||
|
@ -18,11 +18,6 @@ limitations under the License.
|
||||
|
||||
#include "tensorflow/core/platform/platform.h"
|
||||
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/dso_loader.h"
|
||||
#else
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
#endif
|
||||
#include "tensorflow/stream_executor/cuda/cuda_platform_id.h"
|
||||
#include "tensorflow/stream_executor/device_memory.h"
|
||||
#include "tensorflow/stream_executor/dnn.h"
|
||||
@ -31,6 +26,7 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
||||
#include "tensorflow/stream_executor/multi_platform_manager.h"
|
||||
#include "tensorflow/stream_executor/platform.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/scratch_allocator.h"
|
||||
#include "tensorflow/stream_executor/stream.h"
|
||||
#include "tensorflow/stream_executor/stream_executor.h"
|
||||
|
@ -58,16 +58,12 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/cuda/cuda_stream.h"
|
||||
#include "tensorflow/stream_executor/cuda/cuda_timer.h"
|
||||
#include "tensorflow/stream_executor/device_memory.h"
|
||||
|
||||
#ifndef PLATFORM_GOOGLE
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
#endif
|
||||
|
||||
#include "tensorflow/stream_executor/lib/env.h"
|
||||
#include "tensorflow/stream_executor/lib/initialize.h"
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
||||
#include "tensorflow/stream_executor/lib/status_macros.h"
|
||||
#include "tensorflow/stream_executor/lib/stringprintf.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/platform/logging.h"
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
#include "tensorflow/stream_executor/plugin_registry.h"
|
||||
|
@ -23,14 +23,10 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/cuda/cuda_platform_id.h"
|
||||
#include "tensorflow/stream_executor/cuda/cuda_stream.h"
|
||||
#include "tensorflow/stream_executor/device_memory.h"
|
||||
|
||||
#ifndef PLATFORM_GOOGLE
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
#endif
|
||||
|
||||
#include "tensorflow/stream_executor/lib/env.h"
|
||||
#include "tensorflow/stream_executor/lib/initialize.h"
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/platform/logging.h"
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
#include "tensorflow/stream_executor/plugin_registry.h"
|
||||
|
@ -21,17 +21,15 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/cuda/cuda_platform_id.h"
|
||||
#include "tensorflow/stream_executor/cuda/cuda_stream.h"
|
||||
#include "tensorflow/stream_executor/device_memory.h"
|
||||
|
||||
#ifndef PLATFORM_GOOGLE
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
#endif
|
||||
|
||||
#include "tensorflow/stream_executor/lib/env.h"
|
||||
#include "tensorflow/stream_executor/lib/initialize.h"
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/platform/logging.h"
|
||||
#include "tensorflow/stream_executor/rng.h"
|
||||
// clang-format off
|
||||
#include "cuda/include/curand.h"
|
||||
// clang-format on
|
||||
|
||||
// Formats curandStatus_t to output prettified values into a log stream.
|
||||
std::ostream &operator<<(std::ostream &in, const curandStatus_t &status) {
|
||||
|
@ -16,55 +16,6 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_LIB_INITIALIZE_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_LIB_INITIALIZE_H_
|
||||
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/initialize.h"
|
||||
#else
|
||||
|
||||
#undef REGISTER_MODULE_INITIALIZER
|
||||
#undef DECLARE_MODULE_INITIALIZER
|
||||
#undef REGISTER_MODULE_INITIALIZER_SEQUENCE
|
||||
|
||||
namespace stream_executor {
|
||||
namespace port {
|
||||
|
||||
class Initializer {
|
||||
public:
|
||||
typedef void (*InitializerFunc)();
|
||||
explicit Initializer(InitializerFunc func) { func(); }
|
||||
|
||||
struct Dependency {
|
||||
Dependency(const char *n, Initializer *i) : name(n), initializer(i) {}
|
||||
const char *const name;
|
||||
Initializer *const initializer;
|
||||
};
|
||||
|
||||
struct DependencyRegisterer {
|
||||
DependencyRegisterer(const char *type, const char *name,
|
||||
Initializer *initializer,
|
||||
const Dependency &dependency);
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace port
|
||||
} // namespace stream_executor
|
||||
|
||||
#define REGISTER_INITIALIZER(type, name, body) \
|
||||
static void google_init_##type##_##name() { body; } \
|
||||
::stream_executor::port::Initializer google_initializer_##type##_##name( \
|
||||
google_init_##type##_##name)
|
||||
|
||||
#define REGISTER_MODULE_INITIALIZER(name, body) \
|
||||
REGISTER_INITIALIZER(module, name, body)
|
||||
|
||||
#define DECLARE_INITIALIZER(type, name) \
|
||||
extern ::stream_executor::port::Initializer google_initializer_##type##_##name
|
||||
|
||||
#define DECLARE_MODULE_INITIALIZER(name) DECLARE_INITIALIZER(module, name)
|
||||
|
||||
#define REGISTER_MODULE_INITIALIZER_SEQUENCE(name1, name2)
|
||||
|
||||
#endif // !defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/initialize.h"
|
||||
|
||||
#endif // TENSORFLOW_STREAM_EXECUTOR_LIB_INITIALIZE_H_
|
||||
|
@ -16,8 +16,6 @@ limitations under the License.
|
||||
// TODO(jhen): Replace hardcoded, platform specific path strings in GetXXXPath()
|
||||
// with a function in e.g. cuda.h.
|
||||
|
||||
#include "tensorflow/stream_executor/dso_loader.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <initializer_list>
|
||||
@ -30,6 +28,7 @@ limitations under the License.
|
||||
#include "tensorflow/stream_executor/lib/path.h"
|
||||
#include "tensorflow/stream_executor/lib/str_util.h"
|
||||
#include "tensorflow/stream_executor/lib/stringprintf.h"
|
||||
#include "tensorflow/stream_executor/platform/dso_loader.h"
|
||||
#include "tensorflow/stream_executor/platform/logging.h"
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
|
||||
@ -89,10 +88,13 @@ string GetCudnnVersion() { return TF_CUDNN_VERSION; }
|
||||
#if defined(__APPLE__)
|
||||
// On Mac OS X, CUDA sometimes installs libcuda.dylib instead of
|
||||
// libcuda.1.dylib.
|
||||
return status.ok() ? status : GetDsoHandle(
|
||||
FindDsoPath(port::Env::Default()->FormatLibraryFileName("cuda", ""),
|
||||
GetCudaDriverLibraryPath()),
|
||||
dso_handle);
|
||||
return status.ok()
|
||||
? status
|
||||
: GetDsoHandle(
|
||||
FindDsoPath(
|
||||
port::Env::Default()->FormatLibraryFileName("cuda", ""),
|
||||
GetCudaDriverLibraryPath()),
|
||||
dso_handle);
|
||||
#else
|
||||
return status;
|
||||
#endif
|
||||
@ -144,7 +146,7 @@ static mutex& GetRpathMutex() {
|
||||
<< ". LD_LIBRARY_PATH: "
|
||||
<< (ld_library_path != nullptr ? ld_library_path : "")
|
||||
#endif
|
||||
;
|
||||
;
|
||||
return port::Status(port::error::FAILED_PRECONDITION,
|
||||
absl::StrCat("could not dlopen DSO: ", path,
|
||||
"; dlerror: ", s.error_message()));
|
||||
@ -218,27 +220,27 @@ static std::vector<string>* CreatePrimordialRpaths() {
|
||||
|
||||
/* static */ string DsoLoader::GetCudaLibraryDirPath() {
|
||||
#if defined(__APPLE__)
|
||||
return "external/local_config_cuda/cuda/lib";
|
||||
return "third_party/gpus/cuda/lib";
|
||||
#else
|
||||
return "external/local_config_cuda/cuda/lib64";
|
||||
return "third_party/gpus/cuda/lib64";
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ string DsoLoader::GetCudaDriverLibraryPath() {
|
||||
#if defined(__APPLE__)
|
||||
return "external/local_config_cuda/cuda/driver/lib";
|
||||
return "third_party/gpus/cuda/driver/lib";
|
||||
#elif defined(PLATFORM_WINDOWS)
|
||||
return "";
|
||||
#else
|
||||
return "external/local_config_cuda/cuda/driver/lib64";
|
||||
return "third_party/gpus/cuda/driver/lib64";
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ string DsoLoader::GetCudaCuptiLibraryPath() {
|
||||
#if defined(__APPLE__)
|
||||
return "external/local_config_cuda/cuda/extras/CUPTI/lib";
|
||||
return "third_party/gpus/cuda/extras/CUPTI/lib";
|
||||
#else
|
||||
return "external/local_config_cuda/cuda/extras/CUPTI/lib64";
|
||||
return "third_party/gpus/cuda/extras/CUPTI/lib64";
|
||||
#endif
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_DSO_LOADER_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_DSO_LOADER_H_
|
||||
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
#include <vector>
|
||||
#include "tensorflow/stream_executor/platform/port.h"
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "tensorflow/stream_executor/lib/status.h"
|
62
tensorflow/stream_executor/platform/default/initialize.h
Normal file
62
tensorflow/stream_executor/platform/default/initialize.h
Normal file
@ -0,0 +1,62 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DEFAULT_INITIALIZE_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DEFAULT_INITIALIZE_H_
|
||||
|
||||
#undef REGISTER_MODULE_INITIALIZER
|
||||
#undef DECLARE_MODULE_INITIALIZER
|
||||
#undef REGISTER_MODULE_INITIALIZER_SEQUENCE
|
||||
|
||||
namespace stream_executor {
|
||||
namespace port {
|
||||
|
||||
class Initializer {
|
||||
public:
|
||||
typedef void (*InitializerFunc)();
|
||||
explicit Initializer(InitializerFunc func) { func(); }
|
||||
|
||||
struct Dependency {
|
||||
Dependency(const char *n, Initializer *i) : name(n), initializer(i) {}
|
||||
const char *const name;
|
||||
Initializer *const initializer;
|
||||
};
|
||||
|
||||
struct DependencyRegisterer {
|
||||
DependencyRegisterer(const char *type, const char *name,
|
||||
Initializer *initializer,
|
||||
const Dependency &dependency);
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace port
|
||||
} // namespace stream_executor
|
||||
|
||||
#define REGISTER_INITIALIZER(type, name, body) \
|
||||
static void google_init_##type##_##name() { body; } \
|
||||
::stream_executor::port::Initializer google_initializer_##type##_##name( \
|
||||
google_init_##type##_##name)
|
||||
|
||||
#define REGISTER_MODULE_INITIALIZER(name, body) \
|
||||
REGISTER_INITIALIZER(module, name, body)
|
||||
|
||||
#define DECLARE_INITIALIZER(type, name) \
|
||||
extern ::stream_executor::port::Initializer google_initializer_##type##_##name
|
||||
|
||||
#define DECLARE_MODULE_INITIALIZER(name) DECLARE_INITIALIZER(module, name)
|
||||
|
||||
#define REGISTER_MODULE_INITIALIZER_SEQUENCE(name1, name2)
|
||||
|
||||
#endif // TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DEFAULT_INITIALIZE_H_
|
@ -16,7 +16,8 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DEFAULT_MUTEX_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DEFAULT_MUTEX_H_
|
||||
|
||||
#include "tensorflow/stream_executor/platform/mutex.h"
|
||||
#include "tensorflow/core/platform/mutex.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
|
||||
namespace stream_executor {
|
||||
|
||||
|
31
tensorflow/stream_executor/platform/dso_loader.h
Normal file
31
tensorflow/stream_executor/platform/dso_loader.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DSO_LOADER_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DSO_LOADER_H_
|
||||
|
||||
#include "tensorflow/stream_executor/platform/platform.h"
|
||||
|
||||
// Include appropriate platform-dependent implementations
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/dso_loader.h"
|
||||
#elif defined(PLATFORM_POSIX) || defined(PLATFORM_POSIX_ANDROID) || \
|
||||
defined(PLATFORM_GOOGLE_ANDROID)
|
||||
#include "tensorflow/stream_executor/platform/default/dso_loader.h"
|
||||
#else
|
||||
#error Define the appropriate PLATFORM_<foo> macro for this platform
|
||||
#endif
|
||||
|
||||
#endif // TENSORFLOW_STREAM_EXECUTOR_PLATFORM_DSO_LOADER_H_
|
27
tensorflow/stream_executor/platform/initialize.h
Normal file
27
tensorflow/stream_executor/platform/initialize.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_INITIALIZE_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_INITIALIZE_H_
|
||||
|
||||
#include "tensorflow/stream_executor/platform/platform.h"
|
||||
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/initialize.h"
|
||||
#else
|
||||
#include "tensorflow/stream_executor/platform/default/initialize.h"
|
||||
#endif
|
||||
|
||||
#endif // TENSORFLOW_STREAM_EXECUTOR_PLATFORM_INITIALIZE_H_
|
@ -16,8 +16,7 @@ limitations under the License.
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_MUTEX_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_MUTEX_H_
|
||||
|
||||
#include "tensorflow/core/platform/mutex.h"
|
||||
#include "tensorflow/core/platform/types.h"
|
||||
#include "tensorflow/stream_executor/platform/platform.h"
|
||||
|
||||
#if defined(PLATFORM_GOOGLE)
|
||||
#include "tensorflow/stream_executor/platform/google/mutex.h"
|
||||
|
36
tensorflow/stream_executor/platform/platform.h
Normal file
36
tensorflow/stream_executor/platform/platform.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright 2018 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORFLOW_STREAM_EXECUTOR_PLATFORM_PLATFORM_H_
|
||||
#define TENSORFLOW_STREAM_EXECUTOR_PLATFORM_PLATFORM_H_
|
||||
|
||||
#if !defined(PLATFORM_POSIX) && !defined(PLATFORM_GOOGLE) && \
|
||||
!defined(PLATFORM_POSIX_ANDROID) && !defined(PLATFORM_GOOGLE_ANDROID)
|
||||
|
||||
// Choose which platform we are on.
|
||||
#if defined(ANDROID) || defined(__ANDROID__)
|
||||
#define PLATFORM_POSIX_ANDROID
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#define PLATFORM_POSIX
|
||||
|
||||
#else
|
||||
// If no platform specified, use:
|
||||
#define PLATFORM_POSIX
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // TENSORFLOW_STREAM_EXECUTOR_PLATFORM_PLATFORM_H_
|
Loading…
Reference in New Issue
Block a user