Updating XLA code to account for the device lib files location change in ROCm 3.9

The location of the ROCm device lib files is changing in ROCm 3.9

Current (ROCm 3.8 and before) location is $ROCM_PATH/lib

```
root@ixt-rack-04:/opt/rocm-3.8.0# find . -name *.bc
./lib/oclc_isa_version_701.amdgcn.bc
./lib/ocml.amdgcn.bc
./lib/oclc_daz_opt_on.amdgcn.bc
./lib/oclc_isa_version_700.amdgcn.bc
./lib/oclc_isa_version_810.amdgcn.bc
./lib/oclc_unsafe_math_off.amdgcn.bc
./lib/oclc_wavefrontsize64_off.amdgcn.bc
./lib/oclc_isa_version_803.amdgcn.bc
./lib/oclc_isa_version_1011.amdgcn.bc
./lib/oclc_isa_version_1012.amdgcn.bc
./lib/opencl.amdgcn.bc
./lib/oclc_unsafe_math_on.amdgcn.bc
./lib/oclc_isa_version_1010.amdgcn.bc
./lib/oclc_finite_only_off.amdgcn.bc
./lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
./lib/oclc_daz_opt_off.amdgcn.bc
./lib/oclc_isa_version_802.amdgcn.bc
./lib/ockl.amdgcn.bc
./lib/oclc_isa_version_906.amdgcn.bc
./lib/oclc_isa_version_1030.amdgcn.bc
./lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
./lib/hip.amdgcn.bc
./lib/oclc_isa_version_908.amdgcn.bc
./lib/oclc_isa_version_900.amdgcn.bc
./lib/oclc_isa_version_702.amdgcn.bc
./lib/oclc_wavefrontsize64_on.amdgcn.bc
./lib/hc.amdgcn.bc
./lib/oclc_isa_version_902.amdgcn.bc
./lib/oclc_isa_version_801.amdgcn.bc
./lib/oclc_finite_only_on.amdgcn.bc
./lib/oclc_isa_version_904.amdgcn.bc
```

New (ROCm 3.9 and above) location is $ROCM_PATH/amdgcn/bitcode
```
root@ixt-hq-99:/opt/rocm-3.9.0-3703# find -name *.bc
./amdgcn/bitcode/oclc_isa_version_700.bc
./amdgcn/bitcode/ocml.bc
./amdgcn/bitcode/oclc_isa_version_1030.bc
./amdgcn/bitcode/oclc_isa_version_1010.bc
./amdgcn/bitcode/oclc_isa_version_904.bc
./amdgcn/bitcode/hip.bc
./amdgcn/bitcode/hc.bc
./amdgcn/bitcode/oclc_daz_opt_off.bc
./amdgcn/bitcode/oclc_wavefrontsize64_off.bc
./amdgcn/bitcode/oclc_wavefrontsize64_on.bc
./amdgcn/bitcode/oclc_isa_version_900.bc
./amdgcn/bitcode/oclc_isa_version_1012.bc
./amdgcn/bitcode/oclc_isa_version_702.bc
./amdgcn/bitcode/oclc_daz_opt_on.bc
./amdgcn/bitcode/oclc_unsafe_math_off.bc
./amdgcn/bitcode/ockl.bc
./amdgcn/bitcode/oclc_isa_version_803.bc
./amdgcn/bitcode/oclc_isa_version_908.bc
./amdgcn/bitcode/oclc_isa_version_802.bc
./amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
./amdgcn/bitcode/oclc_finite_only_on.bc
./amdgcn/bitcode/oclc_isa_version_701.bc
./amdgcn/bitcode/oclc_unsafe_math_on.bc
./amdgcn/bitcode/oclc_isa_version_902.bc
./amdgcn/bitcode/oclc_finite_only_off.bc
./amdgcn/bitcode/opencl.bc
./amdgcn/bitcode/oclc_isa_version_906.bc
./amdgcn/bitcode/oclc_isa_version_810.bc
./amdgcn/bitcode/oclc_isa_version_801.bc
./amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
./amdgcn/bitcode/oclc_isa_version_1011.bc
```

Also not the change in the filename(s)

This commit updates the XLA code, that has the device lib path + filename(s) hardcoded, to account for the change in location / filename
This commit is contained in:
Deven Desai 2020-09-17 00:30:15 +00:00
parent 1498747b30
commit 868395d7d0
3 changed files with 24 additions and 0 deletions

View File

@ -67,6 +67,10 @@ limitations under the License.
#include "tensorflow/core/profiler/lib/traceme.h" #include "tensorflow/core/profiler/lib/traceme.h"
#include "tensorflow/core/util/env_var.h" #include "tensorflow/core/util/env_var.h"
#if TENSORFLOW_USE_ROCM
#include "rocm/rocm_config.h"
#endif
namespace xla { namespace xla {
namespace gpu { namespace gpu {
namespace { namespace {
@ -560,11 +564,18 @@ namespace {
static std::vector<string> GetROCDLPaths(int amdgpu_version, static std::vector<string> GetROCDLPaths(int amdgpu_version,
const string& rocdl_dir_path) { const string& rocdl_dir_path) {
// AMDGPU version-neutral bitcodes. // AMDGPU version-neutral bitcodes.
#if TF_ROCM_VERSION >= 30900
static std::vector<string>* rocdl_filenames = new std::vector<string>(
{"hc.bc", "opencl.bc", "ocml.bc", "ockl.bc", "oclc_finite_only_off.bc",
"oclc_daz_opt_off.bc", "oclc_correctly_rounded_sqrt_on.bc",
"oclc_unsafe_math_off.bc", "oclc_wavefrontsize64_on.bc"});
#else
static std::vector<string>* rocdl_filenames = new std::vector<string>( static std::vector<string>* rocdl_filenames = new std::vector<string>(
{"hc.amdgcn.bc", "opencl.amdgcn.bc", "ocml.amdgcn.bc", "ockl.amdgcn.bc", {"hc.amdgcn.bc", "opencl.amdgcn.bc", "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc", "oclc_daz_opt_off.amdgcn.bc", "oclc_finite_only_off.amdgcn.bc", "oclc_daz_opt_off.amdgcn.bc",
"oclc_correctly_rounded_sqrt_on.amdgcn.bc", "oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", "oclc_wavefrontsize64_on.amdgcn.bc"}); "oclc_unsafe_math_off.amdgcn.bc", "oclc_wavefrontsize64_on.amdgcn.bc"});
#endif
// Construct full path to ROCDL bitcode libraries. // Construct full path to ROCDL bitcode libraries.
std::vector<string> result; std::vector<string> result;
@ -575,7 +586,11 @@ static std::vector<string> GetROCDLPaths(int amdgpu_version,
// Add AMDGPU version-specific bitcodes. // Add AMDGPU version-specific bitcodes.
result.push_back(tensorflow::io::JoinPath( result.push_back(tensorflow::io::JoinPath(
rocdl_dir_path, rocdl_dir_path,
#if TF_ROCM_VERSION >= 30900
absl::StrCat("oclc_isa_version_", amdgpu_version, ".bc")));
#else
absl::StrCat("oclc_isa_version_", amdgpu_version, ".amdgcn.bc"))); absl::StrCat("oclc_isa_version_", amdgpu_version, ".amdgcn.bc")));
#endif
return result; return result;
} }

View File

@ -36,7 +36,11 @@ string RocmRoot() {
} }
string RocdlRoot() { string RocdlRoot() {
#if TF_ROCM_VERSION >= 30900
return tensorflow::io::JoinPath(tensorflow::RocmRoot(), "amdgcn/bitcode");
#else
return tensorflow::io::JoinPath(tensorflow::RocmRoot(), "lib"); return tensorflow::io::JoinPath(tensorflow::RocmRoot(), "lib");
#endif
} }
} // namespace tensorflow } // namespace tensorflow

View File

@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/core/platform/rocm_rocdl_path.h" #include "tensorflow/core/platform/rocm_rocdl_path.h"
#include "rocm/rocm_config.h"
#include "tensorflow/core/lib/core/status_test_util.h" #include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/path.h" #include "tensorflow/core/platform/path.h"
@ -27,7 +28,11 @@ TEST(RocmRocdlPathTest, ROCDLPath) {
VLOG(2) << "ROCm-Device-Libs root = " << RocdlRoot(); VLOG(2) << "ROCm-Device-Libs root = " << RocdlRoot();
std::vector<string> rocdl_files; std::vector<string> rocdl_files;
TF_EXPECT_OK(Env::Default()->GetMatchingPaths( TF_EXPECT_OK(Env::Default()->GetMatchingPaths(
#if TF_ROCM_VERSION >= 30900
io::JoinPath(RocdlRoot(), "*.bc"), &rocdl_files));
#else
io::JoinPath(RocdlRoot(), "*.amdgcn.bc"), &rocdl_files)); io::JoinPath(RocdlRoot(), "*.amdgcn.bc"), &rocdl_files));
#endif
EXPECT_LT(0, rocdl_files.size()); EXPECT_LT(0, rocdl_files.size());
} }
#endif #endif