...
Note |
---|
title | 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.
...
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 a CUDA file (foo.cu
, for example) to HIP format, enter the following after loading hip/4.3.0
...
a ROCm module:
Column |
---|
|
Code Block |
---|
language | bash |
---|
theme | DJango |
---|
title | Terminal N. Loading ROCm module and using the hipify-perl tool for translating the code from CUDA to HIP |
---|
| $ module load rocm/ | version<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 provided in the ROCm installation:
Column |
---|
|
Code Block |
---|
language | bash |
---|
theme | DJango |
---|
title | Terminal N. Compiling the code with hipcc |
---|
| $ | module load rocm/version
$ hipcc new_foo.cpp
|
There are several other utility scripts and options available to support the porting of codes that you can find in the rocm installation. These include:
hipify-clang
hipify-perl
hipexamine.sh
hipexamine-perl.sh
hipconvertinplace.sh
hipconvertinplace-perl.sh
For example, hipify-perl -inplace
option saves the HIP version of the code in the same file. The original CUDA code is saved in the backup file .prehip:
Column |
---|
|
Code Block |
---|
language | bash |
---|
theme | DJango |
---|
title | Terminal N. Compiling the code with hipcc |
---|
| $ hipify-perl -inplace <filename> |
|
Or hipexamine-perl.sh
scans a file/directory to determine which file/files contain CUDA code and how much of that code can be automatically hipified.
Code Block |
---|
$ hipexamine-perl.sh <filename/directory>
|
Or hipconvertinplace-perl.sh
converts all the related files that are located inside the directory
Code Block |
---|
$ hipconvertinplace-perl.sh <directory>
|
for more information see HIP programming guide, ROCm-Developer-Tools, HIPIFY/README