Skip to content

Add IE Config for NUM_BUILD_THREADS#15

Merged
yeonbok merged 5 commits intoyeonbok:taylor_async_batch_WW11_rebase_both_tbb_threadpool_default_with_threadpoolfrom
donghyeo:ie_config_num_build_threads
Mar 25, 2021
Merged

Add IE Config for NUM_BUILD_THREADS#15
yeonbok merged 5 commits intoyeonbok:taylor_async_batch_WW11_rebase_both_tbb_threadpool_default_with_threadpoolfrom
donghyeo:ie_config_num_build_threads

Conversation

@donghyeo
Copy link
Copy Markdown
Collaborator

Details:

  • Add a new IE config key, KEY_CLDNN_MAX_NUM_THREADS, which sets the number of threads used to build program.
  • Default value is maximum concurrency

Tickets:

Copy link
Copy Markdown
Owner

@yeonbok yeonbok left a comment

Choose a reason for hiding this comment

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

LGTM

}
} catch (const std::exception&) {
THROW_IE_EXCEPTION << "Wrong value for property key " << CLDNNConfigParams::KEY_CLDNN_MAX_NUM_THREADS
<< ". Expected only integer";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

please add a usage example here too:
e.g., "Please specify the number of threads you want to use for build as integer. If you set this with a value out of range, it will be set as default number, i.e., maximum number of available threads."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are you saying we should set the number of threads to its default for the cases when invalid config value is given, such as string or character, and not throw an exception?

Copy link
Copy Markdown
Owner

@yeonbok yeonbok Mar 25, 2021

Choose a reason for hiding this comment

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

no. I mean just update the message here to be shown by the user.

THROW_IE_EXCEPTION_WITH_STATUS(NotFound) << "Unsupported KEY_CLDNN_ENABLE_FP16_FOR_QUANTIZED_MODELS flag value: " << val;
}
} else if (key.compare(CLDNNConfigParams::KEY_CLDNN_MAX_NUM_THREADS) == 0) {
int max_threads = std::thread::hardware_concurrency();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency
It can return 0 if the environment does not defined the available concurrency.
I think we need to set it as 1 if it returns 0.

device_id(""),
kernels_cache_dir("") {
kernels_cache_dir(""),
n_threads(std::thread::hardware_concurrency()) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Samely, need to handle if the return value is 0.

bool memory_pool = true,
uint16_t n_streams = 1,
const std::string& kernels_cache_path = "",
int n_threads = std::thread::hardware_concurrency(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

here too

tuning_cache_path("cache.json"),
kernels_cache_path("") {}
kernels_cache_path(""),
n_threads(std::thread::hardware_concurrency()) {}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

here too

Copy link
Copy Markdown
Owner

@yeonbok yeonbok left a comment

Choose a reason for hiding this comment

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

Please apply the comment

@yeonbok yeonbok merged commit 3ff6755 into yeonbok:taylor_async_batch_WW11_rebase_both_tbb_threadpool_default_with_threadpool Mar 25, 2021
yeonbok pushed a commit that referenced this pull request Mar 25, 2021
* Add IE Config for n_threads

* Use IE Config n_threads in kernel_cache

* Change default value of KEY_CLDNN_MAX_NUM_THREADS

* set n_threads as 1 if concurrency returns 0

* Update error message
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.

2 participants