Using hipify-perl

Contents

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

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:

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 hipify-perl commands.

For more advanced translation needs, use hipify-clang, as it is more comprehensive and accurate.