Make ATen HIPify out-of-place, but still reuse CUDA names. (#14866)
authorEdward Yang <ezyang@fb.com>
Wed, 12 Dec 2018 03:11:02 +0000 (19:11 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 12 Dec 2018 03:15:27 +0000 (19:15 -0800)
commitb7106429697bf6a9e374d68aef839cbcfdfd3bf6
tree8c3c8a4e29ab1b53739789a1caa9bf4cc34d3428
parent5c2c40ad871544b4721955c4472fdc7a72628976
Make ATen HIPify out-of-place, but still reuse CUDA names. (#14866)

Summary:
```
    This diff changes the HIPification of ATen to be out-of-place.
    We now have the following mappings:

    - ATen/cuda => ATen/hip
    - ATen/native/cuda => ATen/native/hip
    - ATen/native/sparse/cuda => ATen/native/sparse/hip
    - THC => THH
    - THCUNN => THHUNN

    The build system is adjusted to know about these new build paths,
    and HIPify is taught how to adjust include paths and
    THC_GENERIC_FILE appropriately.  ATen_hip is now built as
    the ATen_hip library, rather than reusing ATen_cuda.

    However, despite these new filepaths, none of the identifiers in ATen
    have actually changed.  So, e.g., THHGeneral.h still defines functions
    named THC_blahblah, and HIP still shows up as CUDA in PyTorch itself.
    We'll tackle this in a subsequent PR; this diff is just to get the files
    out-of-place.

    Minor extra improvements:

    - Don't edit tmp_install when hipifying
    - HIP no longer builds native_cudnn_cpp; it was unnecessary
    - Caffe2_HIP_INCLUDES is now Caffe2_HIP_INCLUDE, for consistency
      with all the other variables.
    - HIP build now properly respects ATEN_CUDA_FILES_GEN_LIB (it
      did not previously.)
    - You can now override file extension matching in pyHIPIFY
      by explicitly specifying its full name in the matching list.
      This is used so we can HIPify CMakeLists.txt in some situations.

    A little bit of string and ceiling wax:

    - gen.py grows a --rocm flag so that it knows to generate CUDA
      files which actually refer to the HIP headers (e.g., THH.h)
      We'll get rid of this eventually and generate real HIP files,
      but not for this PR.
    - Management of HIP dependencies is now completely deleted
      from the ATen CMakeLists.txt.  The old code was dead (because
      it was shoveled in ATen_CUDA_DEPENDENCY_LIBS and promptly
      ignored by the Caffe2 build system) and didn't actually work.
```

Stacked on https://github.com/pytorch/pytorch/pull/14849 review last commit only
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14866

Differential Revision: D13419475

Pulled By: ezyang

fbshipit-source-id: cb4c843df69a1d8369314c9fab1b7719520fa3db
15 files changed:
aten/CMakeLists.txt
aten/src/ATen/CMakeLists.txt
aten/src/ATen/gen.py
aten/src/ATen/miopen/Utils.h
aten/src/ATen/native/miopen/BatchNorm_miopen.cpp
aten/src/ATen/native/miopen/Conv_miopen.cpp
caffe2/CMakeLists.txt
cmake/Codegen.cmake
cmake/Dependencies.cmake
cmake/public/utils.cmake
third_party/sleef
tools/amd_build/build_amd.py
tools/amd_build/pyHIPIFY/hipify_python.py
tools/cwrap/plugins/NNExtension.py
torch/csrc/autograd/engine.cpp