diff options
author | Xusong Wang <xusongw@google.com> | 2021-07-02 21:04:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-07-02 21:04:17 +0000 |
commit | fae4e736e4f76755306a7e8fe5c7678d44faab32 (patch) | |
tree | 5067808e44ddcbb268905e8940bfe346bf57e473 | |
parent | 2c708f6093cdda049cfc76e90f55481afa80317e (diff) | |
parent | bb026242e605c2254f2d0fba7731eb9fe49bdcda (diff) | |
download | NeuralNetworks-fae4e736e4f76755306a7e8fe5c7678d44faab32.tar.gz |
Merge "Fix sync fence FD leak in fenced compute." into sc-dev
-rw-r--r-- | runtime/ExecutionBuilder.cpp | 3 | ||||
-rw-r--r-- | runtime/ExecutionBuilder.h | 6 | ||||
-rw-r--r-- | runtime/NeuralNetworks.cpp | 1 |
3 files changed, 2 insertions, 8 deletions
diff --git a/runtime/ExecutionBuilder.cpp b/runtime/ExecutionBuilder.cpp index b2728a4fc..d9ccb0d30 100644 --- a/runtime/ExecutionBuilder.cpp +++ b/runtime/ExecutionBuilder.cpp @@ -996,9 +996,8 @@ int ExecutionBuilder::computeFenced(const std::vector<int>& waitFor, VLOG(EXECUTION) << "ExecutionBuilder::computeFenced"; int result; const auto deadline = makeDeadline(mTimeoutDuration); - std::tie(result, mSyncFenceFd, mFencedExecutionCallback) = + std::tie(result, *syncFence, mFencedExecutionCallback) = computeFencedInternal(waitFor, timeoutDurationAfterFence, deadline); - *syncFence = mSyncFenceFd; // If there is an error, call finishComputation to mark the computation as completed. // Otherwise, we will call finishComputation in SyncFenceEvent::wait(). if (result != ANEURALNETWORKS_NO_ERROR) { diff --git a/runtime/ExecutionBuilder.h b/runtime/ExecutionBuilder.h index a8709a748..4b3b1906f 100644 --- a/runtime/ExecutionBuilder.h +++ b/runtime/ExecutionBuilder.h @@ -166,8 +166,6 @@ class ExecutionBuilder { bool updateMemories(); - bool hasSyncFence() const { return mSyncFenceFd > 0; } - const ModelBuilder* mModel; const ExecutionPlan* mPlan; @@ -243,10 +241,6 @@ class ExecutionBuilder { std::optional<bool> mOutputsFullySpecified; bool areOutputsFullySpecified(); - // The sync fence fd that is created in the computeFenced call, if any. - // (Sometimes no sync fence fd will be created.) - int mSyncFenceFd = -1; - // The callback used to query execution related info in the case of fenced // execution; otherwise, nullptr. If the execution plan has multiple steps, // this is the callback associated with the last step. If the last step diff --git a/runtime/NeuralNetworks.cpp b/runtime/NeuralNetworks.cpp index 053a8b780..b91d3ce45 100644 --- a/runtime/NeuralNetworks.cpp +++ b/runtime/NeuralNetworks.cpp @@ -1596,6 +1596,7 @@ int ANeuralNetworksExecution_startComputeWithDependencies( // TODO(miaowang): support dynamic output shape only with memory domain. // For now just return empty output shapes. [r](ErrorStatus status) { return r->finishComputation(status, {}); }); + close(syncFenceToSignal); if (n != ANEURALNETWORKS_NO_ERROR) { *event = nullptr; } else { |