Files
rocm-systems/projects/hip/docs/reference/api_syntax.rst
T
Istvan Kiss 197f73dac9 Sync HIP documentation 2025-10-20 (#1258)
* Add examples to tools folder
* Correct P2P memory access section
* Sync poriting guide
* Add HIP Graph tutorial
* Add hint about using amdgpu-dkms for IPC API
* Add a few more env variables
2025-10-29 07:42:06 +01:00

95 wiersze
2.1 KiB
ReStructuredText

.. meta::
:description: Maps CUDA API syntax to HIP API syntax with an example
:keywords: AMD, ROCm, HIP, CUDA, syntax, HIP syntax
********************************************************************************
CUDA to HIP API Function Comparison
********************************************************************************
This page introduces key syntax differences between CUDA and HIP APIs with a focused code
example and comparison table. For a complete list of mappings, visit :ref:`HIPIFY <HIPIFY:index>`.
The following CUDA code example illustrates several CUDA API syntaxes.
.. literalinclude:: ../tools/example_codes/block_reduction.cu
:start-after: // [sphinx-start]
:end-before: // [sphinx-end]
:language: cpp
The following table maps CUDA API functions to corresponding HIP API functions, as demonstrated in the
preceding code examples.
.. list-table::
:header-rows: 1
:name: syntax-mapping-table
*
- CUDA
- HIP
*
- ``#include <cuda_runtime.h>``
- ``#include <hip/hip_runtime.h>``
*
- ``cudaError_t``
- ``hipError_t``
*
- ``cudaEvent_t``
- ``hipEvent_t``
*
- ``cudaStream_t``
- ``hipStream_t``
*
- ``cudaMalloc``
- ``hipMalloc``
*
- ``cudaStreamCreateWithFlags``
- ``hipStreamCreateWithFlags``
*
- ``cudaStreamNonBlocking``
- ``hipStreamNonBlocking``
*
- ``cudaEventCreate``
- ``hipEventCreate``
*
- ``cudaMemcpyAsync``
- ``hipMemcpyAsync``
*
- ``cudaMemcpyHostToDevice``
- ``hipMemcpyHostToDevice``
*
- ``cudaEventRecord``
- ``hipEventRecord``
*
- ``cudaEventSynchronize``
- ``hipEventSynchronize``
*
- ``cudaEventElapsedTime``
- ``hipEventElapsedTime``
*
- ``cudaFree``
- ``hipFree``
*
- ``cudaEventDestroy``
- ``hipEventDestroy``
*
- ``cudaStreamDestroy``
- ``hipStreamDestroy``
In summary, this comparison highlights the primary differences between CUDA and HIP APIs.