.. meta::
   :description: Tools to automatically translate CUDA source code into portable HIP C++
   :keywords: HIPIFY, ROCm, library, tool, CUDA, CUDA2HIP, hipify-clang, hipify-perl

.. _hipify-perl:

**************************************************************************
Using hipify-perl
**************************************************************************

``hipify-perl`` is a Perl-based script that heavily uses regular expressions and is automatically generated by ``hipify-clang``.

**Advantages:**

- Ease of use
- No correctness checks required for input NVIDIA CUDA source code
- No dependency on third-party tools, except `Perl <https://www.perl.org/>`__

**Disadvantages:**

- Inability or difficulty in translating the following constructs:

  - Macro expansion
  - Namespaces:

    - Redefinition of CUDA entities in user namespaces
    - ``using`` directive

  - Templates (some cases)
  - Differentiating device and host function calls
  - Correct injection of header files
  - Parsing complicated argument lists

Usage
=====

Convert a simple CUDA file (``square.cu``) to HIP using ``hipify-perl``:

.. code:: shell

  hipify-perl square.cu -o=square.cu.hip

This command translates the input file and writes the result to ``square.cu.hip``.

.. note::

  For additional details on ``hipify-perl`` command options, see :ref:`hipify-perl-cmd`.

  For more advanced translation needs, use :ref:`hipify-clang <hipify-clang>`, as it is more comprehensive and accurate.
