Skip to content

Commit

Permalink
Add note on ifdefing based on CUDA_VERSION for ROCm path (pytorch#62850)
Browse files Browse the repository at this point in the history
Summary:
CUDA_VERSION and HIP_VERSION follow very unrelated versioning schemes, so it does not make sense to use CUDA_VERSION to determine the ROCm path. This note explicitly addresses it.

Pull Request resolved: pytorch#62850

Reviewed By: mruberry

Differential Revision: D30547562

Pulled By: malfet

fbshipit-source-id: 02990fa66a88466c2330ab85f446b25b78545150
  • Loading branch information
jithunnair-amd authored and facebook-github-bot committed Aug 25, 2021
1 parent b5b9ce1 commit 730ce29
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/source/notes/hip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ torch.distributed backends

Currently, only the "nccl" and "gloo" backends for torch.distributed are supported on ROCm.

.. _cuda-api-to_hip-api-mappings:

CUDA API to HIP API mappings in C++
-----------------------------------

Please refer: https://rocmdocs.amd.com/en/latest/Programming_Guides/HIP_API_Guide.html

NOTE: The CUDA_VERSION macro, cudaRuntimeGetVersion and cudaDriverGetVersion APIs do not
semantically map to the same values as HIP_VERSION macro, hipRuntimeGetVersion and
hipDriverGetVersion APIs. Please do not use them interchangeably when doing version checks.

Eg: Instead of
#if defined(CUDA_VERSION) && CUDA_VERSION >= 11000
If it is desired to not take the code path for ROCm/HIP:
#if defined(CUDA_VERSION) && CUDA_VERSION >= 11000 && !defined(USE_ROCM)
If it is desired to take the code path for ROCm/HIP:
#if (defined(CUDA_VERSION) && CUDA_VERSION >= 11000) || defined(USE_ROCM)
If it is desired to take the code path for ROCm/HIP only for specific HIP versions:
#if (defined(CUDA_VERSION) && CUDA_VERSION >= 11000) || (defined(USE_ROCM) && ROCM_VERSION >= 40300)


Refer to CUDA Semantics doc
---------------------------

Expand Down

0 comments on commit 730ce29

Please sign in to comment.