From 79a6e38f1a42f92a52adc9fbc56a49f03987442b Mon Sep 17 00:00:00 2001 From: Michal Babej Date: Wed, 17 May 2023 13:43:32 +0300 Subject: [PATCH] Style fixes --- src/CHIPBindings.cc | 5 +---- src/CHIPGraph.cc | 3 +-- src/backend/OpenCL/CHIPBackendOpenCL.cc | 14 +++++++------- src/backend/OpenCL/CHIPBackendOpenCL.hh | 18 +++++++++--------- src/backend/OpenCL/SVMemoryRegion.cc | 2 +- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/CHIPBindings.cc b/src/CHIPBindings.cc index 6e702ed5a..31b0b0d39 100644 --- a/src/CHIPBindings.cc +++ b/src/CHIPBindings.cc @@ -350,17 +350,14 @@ hipError_t hipGraphGetNodes(hipGraph_t graph, hipGraphNode_t *nodes, CHIP_TRY if (!graph || !numNodes) RETURN(hipErrorInvalidValue); - // if (!nodes && !numNodes) - // RETURN(hipErrorInvalidValue); CHIPInitialize(); auto Nodes = GRAPH(graph)->getNodes(); if (nodes) { - if (numNodes && (*numNodes > Nodes.size())) + if (*numNodes > Nodes.size()) RETURN(hipErrorInvalidValue); size_t ToCopy = numNodes ? *numNodes : Nodes.size(); memcpy(nodes, Nodes.data(), ToCopy * sizeof(CHIPGraphNode *)); } else { - // numNodes && nodes == nullptr *numNodes = Nodes.size(); } RETURN(hipSuccess); diff --git a/src/CHIPGraph.cc b/src/CHIPGraph.cc index 9088428cf..4a100cd95 100644 --- a/src/CHIPGraph.cc +++ b/src/CHIPGraph.cc @@ -217,13 +217,12 @@ bool CHIPGraphExec::tryLaunchNative(CHIPQueue *Queue) { if (!NativeGraph) return false; - for (auto &Node : OriginalGraph_->getNodes()) { + for (auto &Node : OriginalGraph_->getNodes()) if (!NativeGraph->addNode(Node)) { logError("NativeGraph: failed to add node of type: {}", Node->getType()); return false; } - } if (!NativeGraph->finalize()) { logDebug("NativeGraph: failed to finalize"); diff --git a/src/backend/OpenCL/CHIPBackendOpenCL.cc b/src/backend/OpenCL/CHIPBackendOpenCL.cc index 728a4dcda..885ee1908 100644 --- a/src/backend/OpenCL/CHIPBackendOpenCL.cc +++ b/src/backend/OpenCL/CHIPBackendOpenCL.cc @@ -524,7 +524,7 @@ void CHIPDeviceOpenCL::populateDevicePropertiesImpl() { CHIPEventOpenCL::CHIPEventOpenCL(CHIPContextOpenCL *ChipContext, cl_event ClEvent, CHIPEventFlags Flags, bool UserEvent) - : CHIPEvent((CHIPContext *)(ChipContext), Flags), ClEvent(ClEvent) { + : CHIPEvent((CHIPContext *)(ChipContext), Flags), ClEvent_(ClEvent) { UserEvent_ = UserEvent; } @@ -535,7 +535,7 @@ CHIPEventOpenCL::CHIPEventOpenCL(CHIPContextOpenCL *ChipContext, uint64_t CHIPEventOpenCL::getFinishTime() { int Status = CL_SUCCESS; uint64_t Ret; - Ret = ClEvent.getProfilingInfo(&Status); + Ret = ClEvent_.getProfilingInfo(&Status); if (Status != CL_SUCCESS) { logError("Failed to query event for profiling info."); @@ -562,7 +562,7 @@ void CHIPEventOpenCL::recordStream(CHIPQueue *ChipQueue) { CHIPEventOpenCL *Marker = (CHIPEventOpenCL *)ChipQueue->enqueueMarkerImpl(); // see operator=() on cl::Event // should automatically release ClEvent if it already contains valid handle - ClEvent = Marker->ClEvent; + ClEvent_ = Marker->ClEvent_; Msg = "recordStreamMarker"; EventStatus_ = EVENT_STATUS_RECORDING; delete Marker; @@ -579,7 +579,7 @@ void CHIPEventOpenCL::recordStream(CHIPQueue *ChipQueue) { size_t CHIPEventOpenCL::getCHIPRefc() { int Err = CL_SUCCESS; - size_t RefC = ClEvent.getInfo(&Err); + size_t RefC = ClEvent_.getInfo(&Err); if (Err != CL_SUCCESS) { logError("failed to get Reference count from OpenCL event"); return 0; @@ -595,20 +595,20 @@ bool CHIPEventOpenCL::wait() { return false; } - auto Status = ClEvent.wait(); + auto Status = ClEvent_.wait(); CHIPERR_CHECK_LOG_AND_THROW(Status, CL_SUCCESS, hipErrorTbd); return true; } bool CHIPEventOpenCL::updateFinishStatus(bool ThrowErrorIfNotReady) { logTrace("CHIPEventOpenCL::updateFinishStatus()"); - if (ThrowErrorIfNotReady && ClEvent.get() == nullptr) + if (ThrowErrorIfNotReady && ClEvent_.get() == nullptr) CHIPERR_LOG_AND_THROW("OpenCL has not been initialized cl_event is null", hipErrorNotReady); int Status = CL_SUCCESS; int UpdatedStatus = - ClEvent.getInfo(&Status); + ClEvent_.getInfo(&Status); CHIPERR_CHECK_LOG_AND_THROW(Status, CL_SUCCESS, hipErrorTbd); if (ThrowErrorIfNotReady && UpdatedStatus != CL_COMPLETE) { CHIPERR_LOG_AND_THROW("Event not yet ready", hipErrorNotReady); diff --git a/src/backend/OpenCL/CHIPBackendOpenCL.hh b/src/backend/OpenCL/CHIPBackendOpenCL.hh index 3d644a9a9..b8b6c50cd 100644 --- a/src/backend/OpenCL/CHIPBackendOpenCL.hh +++ b/src/backend/OpenCL/CHIPBackendOpenCL.hh @@ -85,7 +85,7 @@ public: class CHIPEventOpenCL : public CHIPEvent { private: - cl::Event ClEvent; + cl::Event ClEvent_; public: CHIPEventOpenCL(CHIPContextOpenCL *ChipContext, cl_event ClEvent, @@ -103,23 +103,23 @@ public: virtual void hostSignal() override{}; virtual bool updateFinishStatus(bool ThrowErrorIfNotReady = true) override; - cl::Event &get() { return ClEvent; } - cl::UserEvent &getAsUserEv() { return static_cast(ClEvent); } + cl::Event &get() { return ClEvent_; } + cl::UserEvent &getAsUserEv() { return static_cast(ClEvent_); } void reset(cl::UserEvent &&Ev) { - ClEvent = Ev; + ClEvent_ = Ev; logTrace("UserEvent {} Moved into {} || NOW: {}", (void *)Ev.get(), - (void *)this, (void *)ClEvent.get()); + (void *)this, (void *)ClEvent_.get()); } void reset(cl::Event &&Ev) { - ClEvent = Ev; + ClEvent_ = Ev; logTrace("Event {} Moved into {} || NOW: {}", (void *)Ev.get(), - (void *)this, (void *)ClEvent.get()); + (void *)this, (void *)ClEvent_.get()); } void reset(cl_event Ev) { - ClEvent = Ev; + ClEvent_ = Ev; logTrace("Event {} Moved into {} ||| NOW: {}", (void *)Ev, (void *)this, - (void *)ClEvent.get()); + (void *)ClEvent_.get()); } // for elapsedTime diff --git a/src/backend/OpenCL/SVMemoryRegion.cc b/src/backend/OpenCL/SVMemoryRegion.cc index cc76b8a23..1d4f76117 100644 --- a/src/backend/OpenCL/SVMemoryRegion.cc +++ b/src/backend/OpenCL/SVMemoryRegion.cc @@ -70,7 +70,7 @@ void *SVMemoryRegion::allocate(size_t Size, size_t Alignment, Alignment, &Err); break; } - else if (SupportsFineGrain) + } else if (SupportsFineGrain) Ptr = ::clSVMAlloc( Context_(), CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER, Size, 0); else