2016-01-26 10:43:41 -05:00
|
|
|
# Square.md
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2021-05-07 18:24:37 -04:00
|
|
|
Simple test below is an example, shows how to use hipify-perl to port CUDA code to HIP:
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2020-10-05 13:20:58 -04:00
|
|
|
- Add hip/bin path to the PATH
|
2016-01-26 20:14:33 -06:00
|
|
|
|
2020-10-05 13:20:58 -04:00
|
|
|
```
|
|
|
|
|
$ export PATH=$PATH:[MYHIP]/bin
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- Define environment variable
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ export HIP_PATH=[MYHIP]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- Build executible file
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ cd ~/hip/samples/0_Intro/square
|
|
|
|
|
$ make
|
2021-11-25 04:42:09 -05:00
|
|
|
/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
|
2020-10-05 13:20:58 -04:00
|
|
|
```
|
|
|
|
|
- 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!
|
|
|
|
|
```
|