message: Change XLA platform_util to support both CUDA/NVPTX and ROCm/AMDGPU
diff: @@ -37,6 +37,9 @@ namespace xla {
  constexpr int kMinCudaComputeCapabilityMajor = 3;
  constexpr int kMinCudaComputeCapabilityMinor = 5;
  +// Minimum supported AMDGPU ISA version is 803.
  +constexpr int kMinAMDGPUISAVersion = 803;
  +
  // The name of the interpreter platform.
  constexpr char kInterpreter[] = "interpreter";
  @@ -48,9 +51,14 @@ string CanonicalPlatformName(const string& name) {
  if (platform_str == "cpu") {
  platform_str = "host";
  }
  - // "gpu" and "cuda" mean the same thing.
  + // When configured on CUDA, "gpu" and "cuda" mean the same thing.
  + // When configured on ROCm, "gpu" and "rocm" mean the same thing.
  if (platform_str == "gpu") {
  +#if GOOGLE_CUDA
  platform_str = "cuda";
  +#elif TENSORFLOW_USE_ROCM
  + platform_str = "rocm";
  +#endif
  }
  return platform_str;
  }
  @@ -203,6 +211,18 @@ static bool IsDeviceSupported(se::StreamExecutor* executor) {
  return false;
  }
  }
  + } else if (executor->platform()->id() == se::rocm::kROCmPlatformId) {
  + int isa_version = 0;
  + if (description.rocm_amdgpu_isa_version(&isa_version)) {
  + if (isa_version < kMinAMDGPUISAVersion) {
  + LOG(INFO) << "StreamExecutor ROCM device ("
  + << executor->device_ordinal() << ") is of "
  + << "obsolete AMDGPU ISA version: "
  + << "gfx" << kMinAMDGPUISAVersion << " required, "
  + << "device is gfx" << isa_version;
  + return false;
  + }
  + }
  }
  return true;
  }
  