From 905389741cc3f84b3eb7e1e2c1efaa068fdf735a Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 21 Nov 2017 16:44:28 -0600 Subject: [PATCH] Fix some cppcheck style issues. [ROCm/hip commit: 9bba97fdcc825398ba443942b0c0375aa0bba329] --- projects/hip/src/hip_device.cpp | 6 +++--- projects/hip/src/hip_hcc.cpp | 2 ++ projects/hip/src/hip_hcc_internal.h | 11 ++++++----- projects/hip/src/hip_memory.cpp | 26 +++++++++++++------------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 521b56b0e9..4f08d49bf3 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -446,14 +446,14 @@ hipError_t hipChooseDevice( int* device, const hipDeviceProp_t* prop ) { HIP_INIT_API(device,prop); hipDeviceProp_t tempProp; - int deviceCount; - int inPropCount = 0; - int matchedPropCount = 0; hipError_t e = hipSuccess; if((device == NULL) || (prop == NULL)) { e = hipErrorInvalidValue; } if(e == hipSuccess) { + int deviceCount; + int inPropCount = 0; + int matchedPropCount = 0; ihipGetDeviceCount( &deviceCount ); *device = 0; for (int i = 0; i < deviceCount; i++) { diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 2eff57f18b..f15a0eb1d8 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -779,6 +779,8 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) // Get agent name err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, &(prop->name)); + DeviceErrorCheck(err); + char archName[256]; err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &archName); diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h index 69434a6327..3fbd3cfacc 100644 --- a/projects/hip/src/hip_hcc_internal.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -339,7 +339,7 @@ uint64_t hipApiStartTick=0;\ class ihipException : public std::exception { public: - ihipException(hipError_t e) : _code(e) {}; + explicit ihipException(hipError_t e) : _code(e) {}; hipError_t _code; }; @@ -669,7 +669,7 @@ template class ihipEventCriticalBase_t : LockedBase { public: - ihipEventCriticalBase_t(const ihipEvent_t *parentEvent) : + explicit ihipEventCriticalBase_t(const ihipEvent_t *parentEvent) : _parent(parentEvent) {} ~ihipEventCriticalBase_t() {}; @@ -690,7 +690,7 @@ typedef LockedAccessor LockedAccessor_EventCrit_t; // internal hip event structure. class ihipEvent_t { public: - ihipEvent_t(unsigned flags); + explicit ihipEvent_t(unsigned flags); void attachToCompletionFuture(const hc::completion_future *cf, hipStream_t stream, ihipEventType_t eventType); std::pair refreshEventStatus(); // returns pair @@ -720,8 +720,9 @@ template class ihipDeviceCriticalBase_t : LockedBase { public: - ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : - _parent(parentDevice) + explicit ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : + _parent(parentDevice), + _ctxCount(0) { }; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 8ed5e600e2..cedc3c59b5 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -44,7 +44,7 @@ hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyK try { stream->locked_copyAsync(dst, src, sizeBytes, kind); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } } else { @@ -928,7 +928,7 @@ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_ try { stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count, offset, kind); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } } else { @@ -968,7 +968,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t co try { stream->lockedSymbolCopyAsync(acc, dst, src, count, offset, kind); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } } else { @@ -993,7 +993,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind stream->locked_copySync(dst, src, sizeBytes, kind); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1015,7 +1015,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyHostToDevice, false); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1037,7 +1037,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyDeviceToHost, false); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1059,7 +1059,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyDeviceToDevice, false); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1081,7 +1081,7 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) stream->locked_copySync((void*)dst, (void*)src, sizeBytes, hipMemcpyHostToHost, false); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1140,7 +1140,7 @@ hipError_t ihipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch stream->locked_copySync((unsigned char*)dst + i*dpitch, (unsigned char*)src + i*spitch, width, kind); } } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1178,7 +1178,7 @@ hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t sp e = hip_internal::memcpyAsync((unsigned char*)dst + i*dpitch, (unsigned char*)src + i*spitch, width, kind,stream); } } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1231,7 +1231,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con stream->locked_copySync((unsigned char*)dst->data + i*dst_w, (unsigned char*)src + i*src_w, width, kind); } } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1252,7 +1252,7 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, try { stream->locked_copySync((char *)dst->data + wOffset, src, count, kind); } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; } @@ -1302,7 +1302,7 @@ hipError_t hipMemcpy3D(const struct hipMemcpy3DParms *p) } } } - catch (ihipException ex) { + catch (ihipException &ex) { e = ex._code; }