Skip to content
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

Add support for sessions to share a global threadpool. #3177

Merged
merged 11 commits into from
Mar 18, 2020
Merged

Conversation

pranavsharma
Copy link
Contributor

@pranavsharma pranavsharma commented Mar 11, 2020

Description: Add support for sessions to share a global threadpool.

Motivation and Context
The OCR team has a requirement to run multiple sessions (models) in a process. ORT creates an intra and inter thread pool for every session. This is clearly not efficient in this scenario. Hence, we need to design a way to have these 2 thread pools be shared between multiple sessions.

After discussion with the OCR team, option #3 in this design doc seems to be the simplest. They don't have any requirement for this feature to be available in language bindings other than C/C++.

Usage will be as follows. Also see documentation under docs/C_API.md.

  1. Call CreateEnvWithGlobalThreadPools()
  2. Call DisablePerSessionThreads()
  3. Call Run()

Also moved the logger to the Environment class as part of this change to facilitate easier passing of global threadpools to session. We wanted to do this any way.

@pranavsharma pranavsharma requested a review from a team as a code owner March 11, 2020 18:47
@yuslepukhin
Copy link
Member

#include "pch.h"

Does not seem to have changed


Refers to: winml/adapter/winml_adapter_environment.cpp:5 in a4405e8. [](commit_id = a4405e8, deletion_comment = False)

@pranavsharma pranavsharma changed the title WIP: Add support for sessions to share a global threadpool. Add support for sessions to share a global threadpool. Mar 15, 2020
@pranavsharma pranavsharma changed the title Add support for sessions to share a global threadpool. WIP: Add support for sessions to share a global threadpool. Mar 15, 2020
@pranavsharma pranavsharma changed the title WIP: Add support for sessions to share a global threadpool. Add support for sessions to share a global threadpool. Mar 16, 2020
@pranavsharma
Copy link
Contributor Author

This is ready for review. Debugging the Android CI failure meanwhile....

@skottmckay
Copy link
Contributor

skottmckay commented Mar 17, 2020

&OrtApis::GetDenotationFromTypeInfo,

Move the 'feel free to add/remove/rearrange' down to V3, and update this to say DO NOT MODIFY as per the V1 comments #Closed


Refers to: onnxruntime/core/session/onnxruntime_c_api.cc:1496 in c0e64c7. [](commit_id = c0e64c7, deletion_comment = False)

@pranavsharma
Copy link
Contributor Author

Most of the test_inference/test_environment code is from before including the one that has the cryptic comment :-).

@pranavsharma
Copy link
Contributor Author

Android

It looks like all tests exes are run inside the android emulator and hence even the global threadpools test exe shares the same env that was created before which explains the test failure. I don't know much about the emulator, so for now I'll disable these tests for android.

Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants