From 99727231a35c6c4ec5201d3eb76dac8760c8dfbc Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 29 Aug 2016 08:04:08 -0500 Subject: [PATCH] Doc update. Describe memcpytosymbol, threadfence_system workarounds --- docs/markdown/hip_faq.md | 11 ++++--- docs/markdown/hip_porting_guide.md | 46 ++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/docs/markdown/hip_faq.md b/docs/markdown/hip_faq.md index cca0965ce2..d62f40510a 100644 --- a/docs/markdown/hip_faq.md +++ b/docs/markdown/hip_faq.md @@ -32,10 +32,12 @@ HIP provides the following: - Devices (hipSetDevice(), hipGetDeviceProperties(), etc.) - Memory management (hipMalloc(), hipMemcpy(), hipFree(), etc.) -- Streams (hipStreamCreate(), etc.) +- Streams (hipStreamCreate(),hipStreamSynchronize(), hipStreamWaitEvent(), etc.) - Events (hipEventRecord(), hipEventElapsedTime(), etc.) - Kernel launching (hipLaunchKernel is a standard C/C++ function that replaces <<< >>>) +- HIP Module API to control when adn how code is loaded. - CUDA-style kernel coordinate functions (threadIdx, blockIdx, blockDim, gridDim) +- Cross-lane instructions including shfl, ballot, any, all - Most device-side math built-ins - Error reporting (hipGetLastError(), hipGetErrorString()) @@ -53,6 +55,7 @@ At a high-level, the following features are not supported: - CUDA array, mipmappedArray and pitched memory - MemcpyToSymbol functions +- Queue priority controls See the [API Support Table](CUDA_Runtime_API_functions_supported_by_HIP.md) for more detailed information. @@ -60,10 +63,10 @@ See the [API Support Table](CUDA_Runtime_API_functions_supported_by_HIP.md) for - Device-side dynamic memory allocations (malloc, free, new, delete) (CUDA 4.0) - Virtual functions, indirect functions and try/catch (CUDA 4.0) - `__prof_trigger` -- PTX assembly (CUDA 4.0) +- PTX assembly (CUDA 4.0). HCC supports inline GCN assembly. - Several kernel features are under development. See the [HIP Kernel Language](hip_kernel_language.md) for more information. These include: - printf - - assert__ + - assert - `__restrict__` - `__launch_bounds__` - `__threadfence*_`, `__syncthreads*` @@ -74,7 +77,7 @@ See the [API Support Table](CUDA_Runtime_API_functions_supported_by_HIP.md) for ### Is HIP a drop-in replacement for CUDA? No. HIP provides porting tools which do most of the work do convert CUDA code into portable C++ code that uses the HIP APIs. Most developers will port their code from CUDA to HIP and then maintain the HIP version. -HIP code provides the same performance as coding in native CUDA, plus the benefit that the code can also run on AMD platforms. +HIP code provides the same performance as native CUDA code, plus the benefits of running on AMD platforms. ### What specific version of CUDA does HIP support? HIP APIs and features do not map to a specific CUDA version. HIP provides a strong subset of functionality provided in CUDA, and the hipify tools can diff --git a/docs/markdown/hip_porting_guide.md b/docs/markdown/hip_porting_guide.md index 4d376f4a5f..45e5455ea4 100644 --- a/docs/markdown/hip_porting_guide.md +++ b/docs/markdown/hip_porting_guide.md @@ -395,13 +395,53 @@ For new projects or ports which can be re-factored, we recommend the use of the This indicates that the code is standard C++ code, but also provides a unique indication for make tools to run hipcc when appropriate. -### Workarounds +## Workarounds -#### warpSize +### warpSize Code should not assume a warp size of 32 or 64. See [Warp Cross-Lane Functions](hip_kernel_language.md#warp-cross-lane-functions) for information on how to write portable wave-aware code. +## memcpyToSymbol -#### Textures and Cache Control +HIP support for hipMemCpyToSymbol is under-development. 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. As a workaround, programs can pass the symbol +as an argument to the kernel, and use standard hipMemcpy routines to initialize it. + +For example: + +Device Code: +``` +// Cuda Device Code +__constant__ float Array[1024]; +__global__ void Inc(float *Out){ + Int tx = hipThreadIdx_x; + Out[tx] = Array[tx] + 1; +} + +// HIP Device Code +__global__ void Inc(hipLaunchParm lp, float *Array, float *Out){ + Int tx = hipThreadIdx_x; + Out[tx] = Array[tx] + 1; +} +``` + +Host Code: +``` +// CUDA Host Code +cudaMemcpyToSymbol(Array, hostArray, sizeofArray); + +// HIP Host Code +hipMemcpy(Array, hostArray, sizeofArray); +``` + +## threadfence_system +Threadfence_system makes all device memory writes, all writes to mapped host memory, and all writes to peer memory visible to CPU and other GPU devices. +Some implementations can provide this behavior by flushing the GPU L2 cache. +HIP/HCC does not provide this functionality. As a workaround, users can set the environment variable `HSA_DISABLE_CACHE=1` to +disable the GPU L2 cache. This will affect all accesses and for all kernels and so may have +a performance impact. + +### Textures and Cache Control >Texture support is under-development and not yet supported by HIP.