New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make HostManager own Devices #2393
Conversation
Also it's necessary to block until requests are done because otherwise this would be a use-after-free glow/lib/Runtime/HostManager/HostManager.cpp Line 154 in d8cbb67
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, might be worth running the resnet-runtime example too.
@@ -214,6 +215,12 @@ ThreadPoolExecutor::~ThreadPoolExecutor() { | |||
void ThreadPoolExecutor::run(const DAGNode *root, | |||
std::unique_ptr<Context> context, | |||
RunIdentifierTy runId, ResultCBTy cb) { | |||
// Don't process new requests if the executor is shutting down. | |||
if (shuttingDown_) { | |||
cb(runId, ResultCode::Canceled, std::move(context)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, should it be a ResultCode::Failed? It never really started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gcatron I don't know what these mean, it would be good if they had some comments saying what each of them is. Canceled sounds more correct though just from guessing because there was nothing wrong with the request, it just got there too late.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you tell me what each of these are, I can add a comment in this PR to the ResultCode enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they are a bit vague, canceled sounds good.
// requests from being serviced. | ||
executor_->shutdown(); | ||
assert(activeRequestCount_ == 0 && | ||
"All requests should be finished when shutting downt HostManager."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downt -> down
caabd5b
to
deff232
Compare
@gcatron thanks for the speedy review! |
tests/unittests/ExecutorTest.cpp
Outdated
deviceManagerMap_.insert(std::make_pair(testDeviceId, deviceManager)); | ||
testDeviceManagerMap_.insert(std::make_pair(testDeviceId, deviceManager)); | ||
llvm::make_unique<TestDeviceManager>(deviceManagerThreads); | ||
deviceManagerMap_.insert( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: deviceManagerMap_.emplace(testDeviceId, std::move(deviceManager)) and in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdzhabarov I didn't write that but yeah I agree it's better I'll change it
Description:
Make it so HostManager owns DeviceManagers and the rest of the runtime just uses them. Make the blocking on shutdown in Executor explicit to ensure that no inflight requests will be using DeviceManagers. Prevent processing new requests while shutting down.
Testing:
ninja all
cd to downloaded_models and
../bin/resnet-runtime ../../tests/images/imagenet
Documentation:
Fixes #2384
Fixes #2297