Please approve this CL. It will be submitted automatically, and its GitHub pull request will be marked as merged. Imported from GitHub PR #25011 New PR to continue the efforts started by @deven-amd in #20709 / #22669 / #24156. This PR aims to refactor StreamExecutor GPU interfaces so it can be shared among CUDA and ROCm. The PR would be the first part of a series of PRs. Based on @timshen91 's inputs, I've refactored logic in #214156 so : - only contains changes in stream_executor/.... - does not remove any stream_executor/cuda/*.h, so that things outside of stream_executor don't break. All the types and functions in the namespace cuda now alias to namespace gpu counterparts. For example, namespace cuda { using CUDADriver = gpu::GpuDriver; }. - all stream_executor/gpu/BUILD targets should be only visible to //third_party/tensorflow/stream_executor:__subpackages__. - target stream_executor/gpu:X should be only used by stream_executor/cuda:cuda_X or stream_executor/rocm:rocm_X, not cuda_Y. For example, cuda:cuda_platform should depend on cuda:cuda_driver, not gpu:gpu_driver. Copybara import of the project: - 267affbb73df9164baf4e62142fe7201e6a305ee [ROCm][CUDA] StreamExecutor logic for ROCm / CUDA platform by Wen-Heng (Jack) Chung <whchung@gmail.com> - 04fac5bf358059bdb2cd4a3e092e52dc982ea7b0 Merge 267affbb73df9164baf4e62142fe7201e6a305ee into 5f8ea... by Wen-Heng (Jack) Chung <whchung@gmail.com> COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/tensorflow/pull/25011 from ROCmSoftwarePlatform:google-upstream-pr-stream-executor-alt 267affbb73df9164baf4e62142fe7201e6a305ee PiperOrigin-RevId: 231250990
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
/* 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.
|
|
==============================================================================*/
|
|
|
|
#include "tensorflow/stream_executor/gpu/gpu_kernel.h"
|
|
|
|
namespace stream_executor {
|
|
namespace gpu {
|
|
|
|
hipFuncCache_t GpuKernel::GetGpuCacheConfig() const {
|
|
switch (preferred_cache_config_) {
|
|
case KernelCacheConfig::kNoPreference:
|
|
return hipFuncCachePreferNone;
|
|
case KernelCacheConfig::kPreferShared:
|
|
return hipFuncCachePreferShared;
|
|
case KernelCacheConfig::kPreferL1:
|
|
return hipFuncCachePreferL1;
|
|
case KernelCacheConfig::kPreferEqual:
|
|
return hipFuncCachePreferEqual;
|
|
default:
|
|
LOG(FATAL) << "Unknown KernelCacheConfig"
|
|
<< static_cast<int32>(preferred_cache_config_);
|
|
}
|
|
}
|
|
|
|
} // namespace gpu
|
|
} // namespace stream_executor
|