Skip to content

Commit 025cd69

Browse files
xw285cornellfacebook-github-bot
authored andcommitted
[AMD] Fix some legacy hipify script (pytorch#70594)
Summary: Pull Request resolved: pytorch#70594 Pull Request resolved: pytorch/gloo#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
1 parent 34c49d3 commit 025cd69

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

caffe2/core/common_gpu.cc

+2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ const char* cublasGetErrorString(cublasStatus_t error) {
206206
return "rocblas_status_size_increased";
207207
case rocblas_status_size_unchanged:
208208
return "rocblas_status_size_unchanged";
209+
default:
210+
return "unrecognized_rocblas_error";
209211
#endif
210212
}
211213
// To suppress compiler warning.

tools/amd_build/build_amd.py

+24-21
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,26 @@
116116
def is_hip_clang() -> bool:
117117
try:
118118
hip_path = os.getenv('HIP_PATH', '/opt/rocm/hip')
119-
return 'HIP_COMPILER=clang' in open(hip_path + '/lib/.hipInfo').read()
119+
with open(hip_path + '/lib/.hipInfo') as f:
120+
return 'HIP_COMPILER=clang' in f.read()
120121
except IOError:
121122
return False
122123

123124
# TODO Remove once gloo submodule is recent enough to contain upstream fix.
124125
if is_hip_clang():
125126
gloo_cmake_file = "third_party/gloo/cmake/Hip.cmake"
126127
do_write = False
127-
with open(gloo_cmake_file, "r") as sources:
128-
lines = sources.readlines()
129-
newlines = [line.replace(' hip_hcc ', ' amdhip64 ') for line in lines]
130-
if lines == newlines:
131-
print("%s skipped" % gloo_cmake_file)
132-
else:
133-
with open(gloo_cmake_file, "w") as sources:
134-
for line in newlines:
135-
sources.write(line)
136-
print("%s updated" % gloo_cmake_file)
128+
if os.path.exists(gloo_cmake_file):
129+
with open(gloo_cmake_file, "r") as sources:
130+
lines = sources.readlines()
131+
newlines = [line.replace(' hip_hcc ', ' amdhip64 ') for line in lines]
132+
if lines == newlines:
133+
print("%s skipped" % gloo_cmake_file)
134+
else:
135+
with open(gloo_cmake_file, "w") as sources:
136+
for line in newlines:
137+
sources.write(line)
138+
print("%s updated" % gloo_cmake_file)
137139

138140
gloo_cmake_file = "third_party/gloo/cmake/Modules/Findrccl.cmake"
139141
if os.path.exists(gloo_cmake_file):
@@ -153,16 +155,17 @@ def is_hip_clang() -> bool:
153155
if is_hip_clang():
154156
gloo_cmake_file = "third_party/gloo/cmake/Dependencies.cmake"
155157
do_write = False
156-
with open(gloo_cmake_file, "r") as sources:
157-
lines = sources.readlines()
158-
newlines = [line.replace('HIP_HCC_FLAGS', 'HIP_CLANG_FLAGS') for line in lines]
159-
if lines == newlines:
160-
print("%s skipped" % gloo_cmake_file)
161-
else:
162-
with open(gloo_cmake_file, "w") as sources:
163-
for line in newlines:
164-
sources.write(line)
165-
print("%s updated" % gloo_cmake_file)
158+
if os.path.exists(gloo_cmake_file):
159+
with open(gloo_cmake_file, "r") as sources:
160+
lines = sources.readlines()
161+
newlines = [line.replace('HIP_HCC_FLAGS', 'HIP_CLANG_FLAGS') for line in lines]
162+
if lines == newlines:
163+
print("%s skipped" % gloo_cmake_file)
164+
else:
165+
with open(gloo_cmake_file, "w") as sources:
166+
for line in newlines:
167+
sources.write(line)
168+
print("%s updated" % gloo_cmake_file)
166169

167170
hipify_python.hipify(
168171
project_directory=proj_dir,

0 commit comments

Comments
 (0)