Files
rocm-systems/hipamd/hipify-clang
Evgeny Mankov e90a76a1ef [HIPIFY][fix][#211] Algorithm for explicit insert of hip include directive
If in source CUDA file main header (cuda_runtime.h or cuda.h) is not presented, corresponding HIP main header (hip_runtime.h) should be explicitly included in output hipified file.

[Algorithm]
1. If #pragma once is presented, HIP main header should be placed just after it;
2. Otherwise if any other (not CUDA main) header is presented, HIP main header should be placed just before it;
3. Otherwise HIP main header should be placed in the beginning of output file.

P.S.
There might be one more situation when #ifndef #define ... #endif guard for the entire file is presented (make sense for *.h, *.hpp, *.cuh files). In this case HIP main include should be placed just after such #ifdef, or after #pragma once, if it is also presented. This situation will be handled in a separate change.
2018-01-15 21:05:05 +03:00
..

hipify-clang

hipify-clang is a clang-based tool to automatically translate CUDA source code into portable HIP C++.

Table of Contents

Build and install

Dependencies

hipify-clang requires clang+llvm of at least version 3.8.

In most cases, you can get a suitable version of clang+llvm with your package manager.

Failing that, you can download a release archive, extract it somewhere, and set CMAKE_PREFIX_PATH so cmake can find it.

Build

Assuming this repository is at ./HIP:

mkdir build inst

cd build
cmake \
 -DCMAKE_INSTALL_PREFIX=../inst \
 -DCMAKE_BUILD_TYPE=Release \
 -DBUILD_HIPIFY_CLANG=ON \
 ../HIP

make -j install

The binary can then be found at ./inst/bin/hipify-clang.

Test

hipify-clang has unit tests using LLVM lit/FileCheck.

To run it:

  1. Ensure lit and FileCheck are installed - these are distributed with LLVM.
  2. Ensure socat is installed - your distro almost certainly has a package for this.
  3. Build with the HIPIFY_CLANG_TESTS option turned on.
  4. make test-hipify

Running and using hipify-clang

To process a file, hipify-clang needs access to the same headers that would be needed to compile it with clang.

For example:

hipify-clang square.cu -- \
  -x cuda \
  --cuda-path=/opt/cuda \
  --cuda-gpu-arch=sm_30 \
  -isystem /opt/cuda/samples/common/inc

hipify-clang arguments are given first, followed by a separator, and then the arguments you'd pass to clang if you were compiling the input file. The Clang manual for compiling CUDA may be useful.

For a list of hipify-clang options, run hipify-clang --help.

Disclaimer

The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. Terms and limitations applicable to the purchase or use of AMD's products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale.

AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.

Copyright (c) 2014-2017 Advanced Micro Devices, Inc. All rights reserved.