[AMD] Fix some legacy hipify script (#70594)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70594

Pull Request resolved: https://github.com/facebookincubator/gloo/pull/315

Fix some out-dated hipify script:
* python -> python3 (fb internal)
* rocblas return code
* gloo makefile for hip clang

Test Plan: Sandcastle + OSS build

Reviewed By: malfet, shintaro-iwasaki

Differential Revision: D33402839

fbshipit-source-id: 5893039451bcf77bbbb1b88d2e46ae3e39caa154
This commit is contained in:
Xiaodong Wang 2022-01-05 11:32:41 -08:00 committed by Facebook GitHub Bot
parent 34c49d3d3b
commit 025cd69a86
2 changed files with 26 additions and 21 deletions

View File

@ -206,6 +206,8 @@ const char* cublasGetErrorString(cublasStatus_t error) {
return "rocblas_status_size_increased"; return "rocblas_status_size_increased";
case rocblas_status_size_unchanged: case rocblas_status_size_unchanged:
return "rocblas_status_size_unchanged"; return "rocblas_status_size_unchanged";
default:
return "unrecognized_rocblas_error";
#endif #endif
} }
// To suppress compiler warning. // To suppress compiler warning.

View File

@ -116,7 +116,8 @@ ignores = [
def is_hip_clang() -> bool: def is_hip_clang() -> bool:
try: try:
hip_path = os.getenv('HIP_PATH', '/opt/rocm/hip') hip_path = os.getenv('HIP_PATH', '/opt/rocm/hip')
return 'HIP_COMPILER=clang' in open(hip_path + '/lib/.hipInfo').read() with open(hip_path + '/lib/.hipInfo') as f:
return 'HIP_COMPILER=clang' in f.read()
except IOError: except IOError:
return False return False
@ -124,16 +125,17 @@ def is_hip_clang() -> bool:
if is_hip_clang(): if is_hip_clang():
gloo_cmake_file = "third_party/gloo/cmake/Hip.cmake" gloo_cmake_file = "third_party/gloo/cmake/Hip.cmake"
do_write = False do_write = False
with open(gloo_cmake_file, "r") as sources: if os.path.exists(gloo_cmake_file):
lines = sources.readlines() with open(gloo_cmake_file, "r") as sources:
newlines = [line.replace(' hip_hcc ', ' amdhip64 ') for line in lines] lines = sources.readlines()
if lines == newlines: newlines = [line.replace(' hip_hcc ', ' amdhip64 ') for line in lines]
print("%s skipped" % gloo_cmake_file) if lines == newlines:
else: print("%s skipped" % gloo_cmake_file)
with open(gloo_cmake_file, "w") as sources: else:
for line in newlines: with open(gloo_cmake_file, "w") as sources:
sources.write(line) for line in newlines:
print("%s updated" % gloo_cmake_file) sources.write(line)
print("%s updated" % gloo_cmake_file)
gloo_cmake_file = "third_party/gloo/cmake/Modules/Findrccl.cmake" gloo_cmake_file = "third_party/gloo/cmake/Modules/Findrccl.cmake"
if os.path.exists(gloo_cmake_file): if os.path.exists(gloo_cmake_file):
@ -153,16 +155,17 @@ if os.path.exists(gloo_cmake_file):
if is_hip_clang(): if is_hip_clang():
gloo_cmake_file = "third_party/gloo/cmake/Dependencies.cmake" gloo_cmake_file = "third_party/gloo/cmake/Dependencies.cmake"
do_write = False do_write = False
with open(gloo_cmake_file, "r") as sources: if os.path.exists(gloo_cmake_file):
lines = sources.readlines() with open(gloo_cmake_file, "r") as sources:
newlines = [line.replace('HIP_HCC_FLAGS', 'HIP_CLANG_FLAGS') for line in lines] lines = sources.readlines()
if lines == newlines: newlines = [line.replace('HIP_HCC_FLAGS', 'HIP_CLANG_FLAGS') for line in lines]
print("%s skipped" % gloo_cmake_file) if lines == newlines:
else: print("%s skipped" % gloo_cmake_file)
with open(gloo_cmake_file, "w") as sources: else:
for line in newlines: with open(gloo_cmake_file, "w") as sources:
sources.write(line) for line in newlines:
print("%s updated" % gloo_cmake_file) sources.write(line)
print("%s updated" % gloo_cmake_file)
hipify_python.hipify( hipify_python.hipify(
project_directory=proj_dir, project_directory=proj_dir,