Skip to content

Converting the toolkit to HIP

Gabriel Wlazłowski edited this page Mar 17, 2023 · 3 revisions

Hipify the code

To be able to use the toolkit with AMD ROCm you need to first hipify the code. Use provided script hipify.sh. The script uses hipify-perl conversion tool. You can download it from here. In the script you need to set correctly invocation of the hipify-perl tool.

# SETTINGS
HIPIFY_CMD="hipify-perl -hip-kernel-execution-syntax"

The script must be executed from the main folder of W-SLDA Toolkit:

gawlazlo@uan02:/project/project_465000150/share/wslda> ./hipify.sh 
---> Converting WSLDA to HIP environment
+ cd hpc-engine
+ mkdir -p hip
+ rm -rf *
+ for cufile in *.cu
+ hipify-perl -hip-kernel-execution-syntax -o hip/ccpca_dens.cpp ccpca_dens.cu
...
+ set +x
---> Conversion of WSLDA to HIP is DONE.

Compiling the code with HIP

In order to activate compilation with hipcc compiler (analog of nvcc compiler) add to Makefile flags HIPCC and HIPCCFLAGS. For example:

# COMPILERS
CXX=cc
# NVCC= commented intentionally, it is replaced by HIPCC below
HIPCC=hipcc
PYTHON=python

# DIRECTORY SETTINGS 
WSLDADIR=$(WSLDA)
OBJDIR=./obj/
# folder where executable binary will be placed (will be created automatically)
BINDIR=./

# COMPILER FLAGS
# You may need to add also info about the platform 
# and path to HIP include files for C compiler
CFLAGS=-D__HIP_PLATFORM_AMD__ -I$(HIP_PATH)/include
# NVCCFLAGS= commented intentionally, it is replaced by HIPCCFLAGS below
HIPCCFLAGS=-std=c++14 --offload-arch=gfx90a 

# LIBRARIES
# You need to link to amdhip64 and hipfft libs
LIBS= -L$(HIP_LIB_PATH) -lamdhip64 -L$(EBROOTHIPFFT)/lib -lhipfft -lm

Example

See for LUMI supercomputer templates.

Clone this wiki locally