Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
franz committed May 17, 2023
1 parent d922f75 commit 79a6e38
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/CHIPBindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/CHIPGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 7 additions & 7 deletions src/backend/OpenCL/CHIPBackendOpenCL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -535,7 +535,7 @@ CHIPEventOpenCL::CHIPEventOpenCL(CHIPContextOpenCL *ChipContext,
uint64_t CHIPEventOpenCL::getFinishTime() {
int Status = CL_SUCCESS;
uint64_t Ret;
Ret = ClEvent.getProfilingInfo<CL_PROFILING_COMMAND_END>(&Status);
Ret = ClEvent_.getProfilingInfo<CL_PROFILING_COMMAND_END>(&Status);

if (Status != CL_SUCCESS) {
logError("Failed to query event for profiling info.");
Expand All @@ -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;
Expand All @@ -579,7 +579,7 @@ void CHIPEventOpenCL::recordStream(CHIPQueue *ChipQueue) {

size_t CHIPEventOpenCL::getCHIPRefc() {
int Err = CL_SUCCESS;
size_t RefC = ClEvent.getInfo<CL_EVENT_REFERENCE_COUNT>(&Err);
size_t RefC = ClEvent_.getInfo<CL_EVENT_REFERENCE_COUNT>(&Err);
if (Err != CL_SUCCESS) {
logError("failed to get Reference count from OpenCL event");
return 0;
Expand All @@ -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<CL_EVENT_COMMAND_EXECUTION_STATUS>(&Status);
ClEvent_.getInfo<CL_EVENT_COMMAND_EXECUTION_STATUS>(&Status);
CHIPERR_CHECK_LOG_AND_THROW(Status, CL_SUCCESS, hipErrorTbd);
if (ThrowErrorIfNotReady && UpdatedStatus != CL_COMPLETE) {
CHIPERR_LOG_AND_THROW("Event not yet ready", hipErrorNotReady);
Expand Down
18 changes: 9 additions & 9 deletions src/backend/OpenCL/CHIPBackendOpenCL.hh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public:

class CHIPEventOpenCL : public CHIPEvent {
private:
cl::Event ClEvent;
cl::Event ClEvent_;

public:
CHIPEventOpenCL(CHIPContextOpenCL *ChipContext, cl_event ClEvent,
Expand All @@ -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<cl::UserEvent &>(ClEvent); }
cl::Event &get() { return ClEvent_; }
cl::UserEvent &getAsUserEv() { return static_cast<cl::UserEvent &>(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
Expand Down
2 changes: 1 addition & 1 deletion src/backend/OpenCL/SVMemoryRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 79a6e38

Please sign in to comment.