Skip to content

Document constants and mappings. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tools/amd_build/pyHIPIFY/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
""" Constants for annotations in the mapping.
The constants defined here are used to annotate the mapping tuples in cuda_to_hip_mappings.py.
They are based on
https://github.com/ROCm-Developer-Tools/HIP/blob/master/hipify-clang/src/Statistics.h
and fall in three categories: 1) type of mapping, 2) API of mapping, 3) unsupported
mapping.
"""

CONV_VERSION = 0,
CONV_INIT = 1
CONV_DEVICE = 2
Expand Down
12 changes: 12 additions & 0 deletions tools/amd_build/pyHIPIFY/cuda_to_hip_mappings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
from constants import *

""" Mapping of CUDA functions, include files, constants, and types to ROCm/HIP equivalents

This closely follows the implementation in hipify-clang
https://github.com/ROCm-Developer-Tools/HIP/blob/master/hipify-clang/src/CUDA2HipMap.cpp
and its structure.
There are different maps for fundamental names, include files, identifies, sparse, and
PyTorch specific translations.
Each of the entries in these maps translates a CUDA string to a tuple containing the
ROCm/HIP string, a type and API annotation and - optionally - an annotation if it is not
supported in ROCm/HIP yet.
"""

CUDA_TYPE_NAME_MAP = {
"CUresult": ("hipError_t", CONV_TYPE, API_DRIVER),
"cudaError_t": ("hipError_t", CONV_TYPE, API_RUNTIME),
Expand Down