[ROCm] Remove usage of deprecated ROCm component header includes (#97620)

- clang parameter 'amdgpu-target' changed to 'offload-arch'
- HIP and MIOpen includes path updated for extensions

Pull Request resolved: https://github.com/pytorch/pytorch/pull/97620
Approved by: https://github.com/ezyang, https://github.com/jithunnair-amd
This commit is contained in:
Pruthvi Madugundu
2023-03-28 19:28:38 +00:00
committed by PyTorch MergeBot
parent 4afef85dda
commit 08f125bcac
4 changed files with 3 additions and 10 deletions

View File

@ -1288,7 +1288,7 @@ if(USE_ROCM)
# host linker to link.
list(APPEND HIP_CLANG_FLAGS -fno-gpu-rdc)
foreach(pytorch_rocm_arch ${PYTORCH_ROCM_ARCH})
list(APPEND HIP_CLANG_FLAGS --amdgpu-target=${pytorch_rocm_arch})
list(APPEND HIP_CLANG_FLAGS --offload-arch=${pytorch_rocm_arch})
endforeach()
set(Caffe2_HIP_INCLUDE

View File

@ -313,5 +313,4 @@ if(HIP_FOUND)
find_library(ROCM_HIPRTC_LIB ${hip_library_name} HINTS ${HIP_PATH}/lib)
# roctx is part of roctracer
find_library(ROCM_ROCTX_LIB roctx64 HINTS ${ROCTRACER_PATH}/lib)
set(roctracer_INCLUDE_DIRS ${ROCTRACER_PATH}/include)
endif()

View File

@ -139,7 +139,6 @@ if(USE_ROCM)
__HIP_PLATFORM_HCC__
)
list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${ROCM_ROCTX_LIB})
list(APPEND TORCH_PYTHON_INCLUDE_DIRECTORIES ${roctracer_INCLUDE_DIRS})
endif()
if(USE_EXPERIMENTAL_CUDNN_V8_API)

View File

@ -200,7 +200,6 @@ CUDA was not found on the system, please set the CUDA_HOME or the CUDA_PATH
environment variable or add NVCC to your system PATH. The extension compilation will fail.
'''
ROCM_HOME = _find_rocm_home()
MIOPEN_HOME = _join_rocm_home('miopen') if ROCM_HOME else None
HIP_HOME = _join_rocm_home('hip') if ROCM_HOME else None
IS_HIP_EXTENSION = True if ((ROCM_HOME is not None) and (torch.version.hip is not None)) else False
ROCM_VERSION = None
@ -1142,10 +1141,6 @@ def include_paths(cuda: bool = False) -> List[str]:
if cuda and IS_HIP_EXTENSION:
paths.append(os.path.join(lib_include, 'THH'))
paths.append(_join_rocm_home('include'))
if MIOPEN_HOME is not None:
paths.append(os.path.join(MIOPEN_HOME, 'include'))
if HIP_HOME is not None:
paths.append(os.path.join(HIP_HOME, 'include'))
elif cuda:
cuda_home_include = _join_cuda_home('include')
# if we have the Debian/Ubuntu packages for cuda, we get /usr as cuda home.
@ -1804,7 +1799,7 @@ def _get_rocm_arch_flags(cflags: Optional[List[str]] = None) -> List[str]:
# (from `extra_compile_args`)
if cflags is not None:
for flag in cflags:
if 'amdgpu-target' in flag:
if 'amdgpu-target' in flag or 'offload-arch' in flag:
return ['-fno-gpu-rdc']
# Use same defaults as used for building PyTorch
# Allow env var to override, just like during initial cmake build.
@ -1817,7 +1812,7 @@ def _get_rocm_arch_flags(cflags: Optional[List[str]] = None) -> List[str]:
archs = []
else:
archs = _archs.replace(' ', ';').split(';')
flags = ['--amdgpu-target=%s' % arch for arch in archs]
flags = ['--offload-arch=%s' % arch for arch in archs]
flags += ['-fno-gpu-rdc']
return flags