diff --git a/projects/hip/samples/0_Intro/square/Makefile b/projects/hip/samples/0_Intro/square/Makefile index aa48cc5864..a1e2464160 100644 --- a/projects/hip/samples/0_Intro/square/Makefile +++ b/projects/hip/samples/0_Intro/square/Makefile @@ -1,20 +1,17 @@ HIP_PATH?= $(wildcard /opt/rocm/hip) HIPCC=$(HIP_PATH)/bin/hipcc -all: square.hip.out +all: square.out +# Step +square.cpp: + $(HIP_PATH)/bin/hipify-perl square.cu > square.cpp + +square.out: square.cpp + $(HIPCC) $(CXXFLAGS) square.cpp -o $@ + +# make step to make native cuda app, if on cuda machine square.cuda.out : square.cu nvcc square.cu -o $@ - -#hipify square.cu > square.cpp -# Then review & finish port in square.cpp -# - -square.hip.out: square.hipref.cpp - $(HIPCC) $(CXXFLAGS) square.hipref.cpp -o $@ - - - - clean: rm -f *.o *.out diff --git a/projects/hip/samples/0_Intro/square/README.md b/projects/hip/samples/0_Intro/square/README.md index 8f9aec73cb..7a9e04fc5f 100644 --- a/projects/hip/samples/0_Intro/square/README.md +++ b/projects/hip/samples/0_Intro/square/README.md @@ -1,16 +1,13 @@ # Square.md Simple test which shows how to use hipify to port CUDA code to HIP. -See related [blog](http://gpuopen.com/hip-to-be-squared-an-introductory-hip-tutorial) that explains the example. +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 -2. Do $ hipify square.cu > square.cpp - -3. Manually edit square.cpp to add hipLaunchParms lp to kernel parms: - vector_square(hipLaunchParm lp, T *C_d, const T *A_d, size_t N) - - (see square.hipref.cpp for the correct output after running hipify and the above manual step) - -4. make +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 diff --git a/projects/hip/samples/0_Intro/square/square.cu b/projects/hip/samples/0_Intro/square/square.cu index 82b31db14a..1c23ba71a1 100644 --- a/projects/hip/samples/0_Intro/square/square.cu +++ b/projects/hip/samples/0_Intro/square/square.cu @@ -38,7 +38,7 @@ THE SOFTWARE. */ template __global__ void -vector_square(T *C_d, const T *A_d, size_t N) +vector_square(T *C_d, T *A_d, size_t N) { size_t offset = (blockIdx.x * blockDim.x + threadIdx.x); size_t stride = blockDim.x * gridDim.x ;