From 63456bfea02907c2daf78c1af8cbaded3ae1c4a7 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 2 Aug 2017 14:47:13 +0530 Subject: [PATCH 1/4] Disable failing test p2p_copy_coherency [ROCm/hip commit: 2f617bac6d6bdd55ae49e3861395b981607d39ac] --- projects/hip/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp b/projects/hip/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp index 9fadebea1e..0c2c387c2f 100644 --- a/projects/hip/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. /* HIT_START * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS --std=c++11 - * RUN: %t + * RUN: %t EXCLUDE_HIP_PLATFORM all * HIT_END */ From 8d254a711336a4533676e7f6d7d7f1de0e322664 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 8 Aug 2017 07:02:22 +0530 Subject: [PATCH 2/4] Updated context management logic: 1) hipSetDevice sets a flag so that next call to hipCtxGetCurrent returns primary context on current device 2) hipCtxGetCurrent returns primary context on current device if TLS context stack is empty 3) hipCtxPopCurrent falls back to primary context on current device as default 4) hipCtxPushCurrent, hipCtxSetCurrent and hipCtxCreate reset the flag set in hipSetDevice [ROCm/hip commit: 3e84cf4aba89ce89aaf5b6134544c68427c7c527] --- projects/hip/src/hip_context.cpp | 46 ++++++++++++++--------------- projects/hip/src/hip_device.cpp | 1 + projects/hip/src/hip_hcc_internal.h | 1 + 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index 11ef6d6da5..69d75e7f31 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -31,6 +31,7 @@ THE SOFTWARE. // Stack of contexts thread_local std::stack tls_ctxStack; +thread_local bool tls_getPrimaryCtx = true; void ihipCtxStackUpdate() { @@ -65,6 +66,7 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device) *ctx = ictx; ihipSetTlsDefaultCtx(*ctx); tls_ctxStack.push(*ctx); + tls_getPrimaryCtx = false; deviceCrit->addContext(ictx); } @@ -93,8 +95,7 @@ hipError_t hipDriverGetVersion(int *driverVersion) hipError_t e = hipSuccess; if (driverVersion) { *driverVersion = 4; - } - else { + } else { e = hipErrorInvalidValue; } @@ -107,8 +108,7 @@ hipError_t hipRuntimeGetVersion(int *runtimeVersion) hipError_t e = hipSuccess; if (runtimeVersion) { *runtimeVersion = HIP_VERSION_PATCH; - } - else { + } else { e = hipErrorInvalidValue; } @@ -124,9 +124,7 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) if(primaryCtx== ctx) { e = hipErrorInvalidValue; - } - else - { + } else { if(currentCtx == ctx) { //need to destroy the ctx associated with calling thread tls_ctxStack.pop(); @@ -146,19 +144,21 @@ hipError_t hipCtxPopCurrent(hipCtx_t* ctx) { HIP_INIT_API(ctx); hipError_t e = hipSuccess; - ihipCtx_t* tempCtx; - *ctx = ihipGetTlsDefaultCtx(); + ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx(); + auto deviceHandle = currentCtx->getDevice(); + *ctx = currentCtx; + if(!tls_ctxStack.empty()) { tls_ctxStack.pop(); } + if(!tls_ctxStack.empty()) { - tempCtx= tls_ctxStack.top(); - } - else { - tempCtx = nullptr; + currentCtx= tls_ctxStack.top(); + } else { + currentCtx = deviceHandle->_primaryCtx; } - ihipSetTlsDefaultCtx(tempCtx); //TOD0 - Shall check for NULL? + ihipSetTlsDefaultCtx(currentCtx); //TOD0 - Shall check for NULL? return ihipLogStatus(e); } @@ -169,8 +169,8 @@ hipError_t hipCtxPushCurrent(hipCtx_t ctx) if(ctx != NULL) { //TODO- is this check needed? ihipSetTlsDefaultCtx(ctx); tls_ctxStack.push(ctx); - } - else { + tls_getPrimaryCtx = false; + } else { e = hipErrorInvalidContext; } return ihipLogStatus(e); @@ -180,12 +180,11 @@ hipError_t hipCtxGetCurrent(hipCtx_t* ctx) { HIP_INIT_API(ctx); hipError_t e = hipSuccess; - if(!tls_ctxStack.empty()) { + if((tls_getPrimaryCtx) || tls_ctxStack.empty()) { + *ctx = ihipGetTlsDefaultCtx(); + } else { *ctx= tls_ctxStack.top(); } - else { - *ctx = NULL; - } return ihipLogStatus(e); } @@ -195,10 +194,10 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx) hipError_t e = hipSuccess; if(ctx == NULL) { tls_ctxStack.pop(); - } - else { + } else { ihipSetTlsDefaultCtx(ctx); tls_ctxStack.push(ctx); + tls_getPrimaryCtx = false; } return ihipLogStatus(e); } @@ -213,8 +212,7 @@ hipError_t hipCtxGetDevice(hipDevice_t *device) if(ctx == nullptr) { e = hipErrorInvalidContext; // TODO *device = nullptr; - } - else { + } else { auto deviceHandle = ctx->getDevice(); *device = deviceHandle->_deviceId; } diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 5ff6dbf04d..1800c9369c 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -146,6 +146,7 @@ hipError_t hipSetDevice(int deviceId) return ihipLogStatus(hipErrorInvalidDevice); } else { ihipSetTlsDefaultCtx(ihipGetPrimaryCtx(deviceId)); + tls_getPrimaryCtx = true; return ihipLogStatus(hipSuccess); } } diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h index 88c7eedda0..4cb85ffc19 100644 --- a/projects/hip/src/hip_hcc_internal.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -114,6 +114,7 @@ private: //Extern tls extern thread_local hipError_t tls_lastHipError; extern thread_local TidInfo tls_tidInfo; +extern thread_local bool tls_getPrimaryCtx; extern std::vector g_dbStartTriggers; extern std::vector g_dbStopTriggers; From d5716971903a344ec5eacf2b9f0263c6f37bc66c Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 8 Aug 2017 09:13:12 +0530 Subject: [PATCH 3/4] docs update for memcpytosymbol support [ROCm/hip commit: eb25bd72dbd60ad94d6d6e4224f6d20890f91ca3] --- projects/hip/docs/markdown/hip_faq.md | 1 - projects/hip/docs/markdown/hip_porting_guide.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index ddf70f2875..b92ae512c5 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -56,7 +56,6 @@ At a high-level, the following features are not supported: - CUDA Driver API - CUDA IPC Functions (Under Development) - 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. diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 84887fd512..12ec931f2a 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -405,7 +405,7 @@ Code should not assume a warp size of 32 or 64. See [Warp Cross-Lane Functions] ## memcpyToSymbol -HIP support for hipMemCpyToSymbol is complete. This feature allows a kernel +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. From c050396510d1b95c869d0f44a9a95cabe2d066a3 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 8 Aug 2017 10:15:32 +0530 Subject: [PATCH 4/4] Bump min hcc_workweek required for named kernel dispatch to 17312 Change-Id: I8c7b58306b279ed113d03260e4bc6086bb8b4e68 [ROCm/hip commit: 8d6acec1351e4155fdea32960e38b93e49d7456c] --- projects/hip/src/hip_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 10fcd15fdc..74b0092b84 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -452,7 +452,7 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, (startEvent || stopEvent) ? &cf : nullptr -#if (__hcc_workweek__ >= 17300) +#if (__hcc_workweek__ > 17312) , f->_name.c_str() #endif );