opm-simulators/bin/hipify_file.sh
Tobias Meyer Andersen e9d6b326cc Add HIP support for AMD GPUs
This commits adds cmake functionality that can
hipify the cuistl framework to support AMD GPUs.

Some tests have been written as HIP does not mirror
CUDA exactly.

CONVERT_CUDA_TO_HIP is the new CMAKE argument.
CMAKE version is increased to include HIP
as a language (3.21 required).

A macro is added to create a layer of indirection
that will make only cuistl files that have been
changed rehipified.

Some BDA stuff is extracted to make sure CUDA
is not accidentally included.
2024-05-06 15:56:53 +02:00

21 lines
739 B
Bash

#!/bin/bash
# the script is intended to be run like this: bash hipify_file.sh ${PROJECT_BUILD_DIR} ${PROJECT_BINARY_DIR}
# it should be run automatically on the correct files through cmake
input_file=$1
output_file=$2
# make sure the output folder exists
mkdir -p $(dirname $output_file)
# hipify out-of-place
hipify-perl $input_file > $output_file
# expand includes so we only need include_directories (path to hip)
sed -i 's/^#include <hipblas\.h>/#include <hipblas\/hipblas.h>/g' $output_file
sed -i 's/^#include <hipsparse\.h>/#include <hipsparse\/hipsparse.h>/g' $output_file
# make sure includes refer to hipistl/ files (the ones that are also hipified)
sed -i 's/cuistl\//hipistl\//g' $output_file
echo "$output_file hipified"