From f6a7172fe4573f38b400429684c806c5fb0f5546 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Wed, 11 May 2022 12:36:38 +0530 Subject: [PATCH 1/3] SWDEV-326794 - Document for hipMemoryType mismatch with CUDA (#2645) Change-Id: Ib4349fc7446edac39ac09fefaaa4babfc7b81ca8 [ROCm/hip commit: 3786aa85182211d274394f361e869bd6e7bf1cc3] --- .../hip/docs/markdown/hip_porting_guide.md | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 33f6847f75..179ad64a2f 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -467,7 +467,8 @@ int main() ``` ## CU_POINTER_ATTRIBUTE_MEMORY_TYPE -To get pointer's memory type in HIP/HIP-Clang one should use hipPointerGetAttributes API. First parameter of the API is hipPointerAttribute_t which has 'memoryType' as member variable. 'memoryType' indicates input pointer is allocated on device or host. + +To get pointer's memory type in HIP/HIP-Clang, developers should use hipPointerGetAttributes API. First parameter of the API is hipPointerAttribute_t which has 'memoryType' as member variable. 'memoryType' indicates input pointer is allocated on device or host. For example: ``` @@ -481,6 +482,33 @@ hipHostMalloc(&ptrHost, sizeof(double)); hipPointerAttribute_t attr; hipPointerGetAttributes(&attr, ptrHost); /*attr.memoryType will have value as hipMemoryTypeHost*/ ``` +Please note, hipMemoryType enum values are different from cudaMemoryType enum values. + +For example, on AMD platform, memoryType is defined in hip_runtime_api.h, +typedef enum hipMemoryType { + hipMemoryTypeHost, ///< Memory is physically located on host + hipMemoryTypeDevice, ///< Memory is physically located on device. + hipMemoryTypeArray, ///< Array memory, physically located on device. + hipMemoryTypeUnified ///< Not used currently +} hipMemoryType; + +Looking into CUDA toolkit, it defines memoryType as following, +enum cudaMemoryType +{ + cudaMemoryTypeUnregistered = 0, // Unregistered memory. + cudaMemoryTypeHost = 1, // Host memory. + cudaMemoryTypeDevice = 2, // Device memory. + cudaMemoryTypeManaged = 3, // Managed memory +} + +In this case, memoryType translation for hipPointerGetAttributes needs to be handled properly on nvidia platform to get the correct memory type in CUDA, which is done in the file nvidia_hip_runtime_api.h. + +So in any HIP applications which use HIP APIs involving memory types, developers should use #ifdef in order to assign the correct enum values depending on Nvidia or AMD platform. + +As an example, please see the code from the link, +github.com/ROCm-Developer-Tools/HIP/blob/develop/tests/catch/unit/memory/hipMemcpyParam2D.cc#L77-L96. + +With the #ifdef condition, HIP APIs work as expected on both AMD and NVIDIA platforms. ## 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. From 43e1d224917d91da333a0ec243fd91f21a17a070 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 11 May 2022 16:10:51 +0530 Subject: [PATCH 2/3] [CI] skip tests listed in config_amd_linux.json (#2674) [ROCm/hip commit: 9628d0bda7ee403033ce43671fbaeadb37e15e16] --- projects/hip/.jenkins/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/.jenkins/Jenkinsfile b/projects/hip/.jenkins/Jenkinsfile index 283271c749..055a29e4a8 100644 --- a/projects/hip/.jenkins/Jenkinsfile +++ b/projects/hip/.jenkins/Jenkinsfile @@ -98,7 +98,7 @@ def hipBuildTest(String backendLabel) { set -x # Check if backend label contains string "amd" or backend host is a server with amd gpu if [[ $backendLabel =~ amd ]]; then - LLVM_PATH=/opt/rocm/llvm ctest -E 'Unit_hipGraphChildGraphNodeGetGraph_Functional|Unit_hipGraphExecMemcpyNodeSetParamsFromSymbol_Negative' + LLVM_PATH=/opt/rocm/llvm HT_CONFIG_FILE="$HIP_DIR/tests/catch/hipTestMain/config/config_amd_linux.json" ctest -E 'Unit_hipGraphChildGraphNodeGetGraph_Functional|Unit_hipGraphExecMemcpyNodeSetParamsFromSymbol_Negative' else make test fi From 0da08a8100103501727a3f5b78a957fe87827fe8 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Wed, 11 May 2022 23:01:15 +0530 Subject: [PATCH 3/3] SWDEV-322620 - Virtual Memory Management (#2673) Add device attribute for virtual memory management Change-Id: Ie123412a7d1783f42d7c4274dcc3562a829a1e4c [ROCm/hip commit: 96ec4ae295319dcb11695060d176708b6a4d2bd9] --- projects/hip/include/hip/hip_runtime_api.h | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 930e8d1854..cf04e65537 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -449,6 +449,7 @@ typedef enum hipDeviceAttribute_t { hipDeviceAttributeUuid, ///< Cuda only. Unique ID in 16 byte. hipDeviceAttributeWarpSize, ///< Warp size in threads. hipDeviceAttributeMemoryPoolsSupported, ///< Device supports HIP Stream Ordered Memory Allocator + hipDeviceAttributeVirtualMemoryManagementSupported, ///< Device supports HIP virtual memory management hipDeviceAttributeCudaCompatibleEnd = 9999, hipDeviceAttributeAmdSpecificBegin = 10000,