From ad8a61545ac8318e9ad23df716d00a90b3edd6a3 Mon Sep 17 00:00:00 2001 From: Julia Jiang Date: Mon, 21 Sep 2020 11:15:40 -0400 Subject: [PATCH] SWDEV-253250-update instruction for hip sample Change-Id: Iebc2887a3687e6c565999f4faf1cd4cf893e24cd --- samples/0_Intro/square/README.md | 42 ++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/samples/0_Intro/square/README.md b/samples/0_Intro/square/README.md index c185903993..0bbb2f7e39 100644 --- a/samples/0_Intro/square/README.md +++ b/samples/0_Intro/square/README.md @@ -1,13 +1,39 @@ # Square.md -Simple test which shows how to use hipify-perl to port CUDA code to HIP. -See related [blog](http://gpuopen.com/hip-to-be-squared-an-introductory-hip-tutorial) that explains the example. +Simple test which shows how to use hipify-perl to port CUDA code to HIP. +See related [blog](http://gpuopen.com/hip-to-be-squared-an-introductory-hip-tutorial) that explains the example. Now it is even simpler and requires no manual modification to the hipified source code - just hipify and compile: -1. Add hip/bin path to the PATH : - export PATH=$PATH:[MYHIP]/bin +- Add hip/bin path to the PATH -2. $ make - Make runs these steps. This can be performed on either CUDA or AMD platform: - hipify-perl square.cu > square.cpp # convert cuda code to hip code - hipcc square.cpp # compile into executable +``` +$ export PATH=$PATH:[MYHIP]/bin +``` + +- Define environment variable + +``` +$ export HIP_PATH=[MYHIP] +``` + +- Build executible file + +``` +$ cd ~/hip/samples/0_Intro/square +$ make +/home/user/hip/bin/hipify-perl square.cu > square.cpp +/home/user/hip/bin/hipcc square.cpp -o square.out +/home/user/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! +```