From 4d7b8ce2d67511de0903041a5fd7ea4abbda73d3 Mon Sep 17 00:00:00 2001 From: Stanley Tsang Date: Wed, 19 Dec 2018 12:21:02 -0500 Subject: [PATCH] Adding support in the hipify-perl tool for the HIP_SYMBOL macro, which is required for hip API calls involving a device symbol. Added more explicit mention of the HIP_SYMBOL macro in the porting guide. [ROCm/hip commit: 6531262126d68844b70f9659e41316b753c81d8e] --- projects/hip/bin/hipify-perl | 7 ++++--- projects/hip/docs/markdown/hip_porting_guide.md | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/hip/bin/hipify-perl b/projects/hip/bin/hipify-perl index 792bf86d94..191d845ed3 100755 --- a/projects/hip/bin/hipify-perl +++ b/projects/hip/bin/hipify-perl @@ -269,7 +269,8 @@ while (@ARGV) { $ft{'mem'} += s/\bcudaMemcpyDeviceToHost\b/hipMemcpyDeviceToHost/g; $ft{'mem'} += s/\bcudaMemcpyDeviceToDevice\b/hipMemcpyDeviceToDevice/g; $ft{'mem'} += s/\bcudaMemcpyDefault\b/hipMemcpyDefault/g; - $ft{'mem'} += s/\bcudaMemcpyToSymbol\b/hipMemcpyToSymbol/g; + $ft{'mem'} += s/\bcudaMemcpyToSymbol\s*\(\s*(\w+)\b/hipMemcpyToSymbol\(HIP_SYMBOL\($1\)/g; + $ft{'mem'} += s/\bcudaMemcpyFromSymbol\s*\(\s*(.+?)\s*,\s*(.+?)\b/hipMemcpyFromSymbol\($1, HIP_SYMBOL\($2\)/g; $ft{'mem'} += s/\bcudaMemset\b/hipMemset/g; $ft{'mem'} += s/\bcudaMemsetAsync\b/hipMemsetAsync/g; @@ -287,8 +288,8 @@ while (@ARGV) { $ft{'mem'} += s/\bcudaMemcpy2DToArray\b/hipMemcpy2DToArray/g; $ft{'mem'} += s/\bcudaMemcpyToArray\b/hipMemcpyToArray/g; - $ft{'mem'} += s/\bcudaGetSymbolAddress\b/hipGetSymbolAddress/g; - $ft{'mem'} += s/\bcudaGetSymbolSize\b/hipGetSymbolSize/g; + $ft{'mem'} += s/\bcudaGetSymbolAddress\s*\(\s*(.+?)\s*,\s*(.+?)\b/hipGetSymbolAddress\($1, HIP_SYMBOL\($2\)/g; + $ft{'mem'} += s/\bcudaGetSymbolSize\s*\(\s*&(\w+)\s*,\s*(.+?)\b/hipGetSymbolSize(&$1, HIP_SYMBOL\($2\)/g; #-------- # Memory management: diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 6fa0b958a8..90854c3a46 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -418,6 +418,8 @@ HIP support for hipMemcpyToSymbol is complete. This feature allows a kernel to define a device-side data symbol which can be accessed on the host side. The symbol can be in __constant or device space. +Note that the symbol name needs to be encased in the HIP_SYMBOL macro, as shown in the code example below. This also applies to hipMemcpyFromSymbol, hipGetSymbolAddress, and hipGetSymbolSize. + For example: Device Code: