Files
rocm-systems/projects/hip-tests/samples/0_Intro/square
Jaydeep Patel c28e388ab2 SWDEV-418116 - FindHIP.cmake is moved to /opt/rocm/lib/cmake/hip/ from /opt/rocm/hip/cmake/
Refer hipify-perl from /opt/rocm/bin/.

Change-Id: I95af838136b124d776323442253e8c74278d69e5


[ROCm/hip-tests commit: 560ef9b945]
2023-10-27 03:08:45 -04:00
..

Square.md

Simple test below is an example, shows how to use hipify-perl to port CUDA code to HIP:

  • Add hip/bin path to the PATH
$ export PATH=$PATH:[MYHIP]/bin
  • Define environment variable
$ export HIP_PATH=[MYHIP]
  • Build executable file
$ cd ~/hip/samples/0_Intro/square
  mkdir -p build && cd build

  cmake -DCMAKE_PREFIX_PATH=<path/to/rocm> -DHIP_CXX_COMPILER=<path/to/clang> ..
  make

$ Building without cmake
/opt/rocm/hip/bin/hipify-perl square.cu > square.cpp
/opt/rocm/hip/bin/hipcc  square.cpp -o square.out
/opt/rocm/hip/bin/hipcc -use-staticlib  square.cpp -o square.out.static
  • Execute file
$ ./square.out
info: running on device Navi 14 [Radeon Pro W5500]
info: allocate host mem (  7.63 MB)
info: allocate device mem (  7.63 MB)
info: copy Host2Device
info: launch 'vector_square' kernel
info: copy Device2Host
info: check result
PASSED!