Skip to end of banner
Go to start of banner

Porting Cuda Codes to HIP

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Work in Progress for Phase-2 Documentation

The content of this section is currently being updated to include material relevant for Phase-2 of Setonix and the use of GPUs.
On the other hand, all the existing material related to Phase-1 and the use of CPU compute nodes can be considered safe, valid and up-to-date.

HIP: Heterogeneous Interface for Portability is developed by AMD to program on AMD GPUs. 

ROCm environment offers two automated methods for automatically converting CUDA projects to HIP:  Hipify perl a Perl script you can run on the CUDA source code to convert it to HIP format and Hipify clang a preprocessor that operates from within the HIP/ Clang compiler tool chain, converting the code as a preliminary step within the compiler process.

The hipify perl script acts directly on the CUDA source code using a series of simple string replacements. Ex., (sed e ’s/cuda/hip/g’)

To convert the CUDA file foo.cu to HIP format, enter the following after loading hip/4.3.0

$ module load rocm/version
$ hipify-perl foo.cu > new_foo.cpp

You can then compile the HIP ready . cpp file for the ROCm environment using the HIP/ Clang compiler:

$ module load rocm/version
$ hipcc new_foo.cpp

there are couple of utility script availed to support porting the codes 

$ echo $(hipconfig --path)
$ findcode.sh hipcc hipconfig hipconvertinplace.sh hip_embed_pch.sh hipexamine.sh hipify-perl roc-obj-extract finduncodep.sh hipcc_cmake_linker_helper hipconvertinplace-perl.sh hipdemangleatp hipexamine-perl.sh hipify-cmakefile hipvars.pm roc-obj-ls

for example:

$ hipify perl inplace <filename>
It modifies the filename input inplace , replacing input with hipified output, save backup in . prehip file.
$hipexamine-perl.sh <filename/directory>
This script will scan a file/directory to determine which file/files contain CUDA code and how much of that code can be automatically hipified.

$hipconvertinplace-perl.sh <directory>
It converts all the related files that are located inside the directory
  • No labels