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 system related parameters to performance related algorithms' parameters #2724

Merged
merged 18 commits into from
May 17, 2024

Conversation

Vika-F
Copy link
Contributor

@Vika-F Vika-F commented Apr 15, 2024

Following changed were added:

  • system_parameters class holding system-related performance parameters implemented.
  • all the performance-related hyperparameters classes like covariance::detail::compute_parameters are now derived from system_parameters class because in the future those system-related parameters might be chosen on per-algorithm basis.

@Vika-F Vika-F marked this pull request as ready for review April 24, 2024 09:30
@Vika-F Vika-F requested review from avolkov-intel and removed request for samir-nasibli and Alexsandruss April 24, 2024 09:31
@Vika-F
Copy link
Contributor Author

Vika-F commented Apr 24, 2024

@keeranroth and @rakshithgb-fujitsu,
Can you please take a look on this PR?
It adds new API that deals with the enabled CPU instruction set and other system-related parameters in oneDAL.

Copy link
Contributor

@keeranroth keeranroth left a comment

Choose a reason for hiding this comment

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

Overall looks good. Just some cosmetic comments

@@ -80,6 +81,9 @@ void cpu_info_impl::print_any(const std::any& value, std::stringstream& ss) cons
else if (ti == typeid(cpu_vendor)) {
print<cpu_vendor>(value, ss);
}
else {
throw unimplemented{ dal::detail::error_messages::unsupported_data_type() };
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pass the typeid of ti so that this message is a little more specific? It would be nice to know what the unknown type is

Comment on lines 23 to 24
system_parameters::system_parameters()
: impl_(detail::pimpl<system_parameters_impl>(new system_parameters_impl())) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid the use of bare new. Use std::make_unique here. pimpl is a shared pointer, but going from unique to shared pointer is easy. It should probably be looked at in the future, whether impl_ should be a unique pointer in here. It is a private field and the constructor creates the object, so it seems like ownership is clear here.

This might be opening a can of worms, but the ownership of objects is a little lax in the rest of the code. I'd like to see more unique pointers, especially in new code. Maybe that's just me, though.

Suggested change
system_parameters::system_parameters()
: impl_(detail::pimpl<system_parameters_impl>(new system_parameters_impl())) {}
system_parameters::system_parameters()
: impl_(std::make_unique<system_parameters_impl>()) {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for this valid observation. I have replaced new with make_unique.

Regarding making impl_ a unique pointer.
I'd prefer not to do it in the scope of this PR because:

  1. it would lead to the inconsistency with the rest of oneDAL's code
  2. modifying detail::pimpl's definition will require extensive testing, including performance testing as pimpl is used widely in the code. For me it looks like a separate task with unknown outcome.

I've forwarded your observations to my team. We'll think on how to prioritize this.

/// Stores system-related parameters that affect the performance of the algorithms.
/// Those parameters can differ from the `get_global_context().get_cpu_info()`.
///
/// `cpu_info` reports the parameters available in hardware, when `system_parameters`
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
/// `cpu_info` reports the parameters available in hardware, when `system_parameters`
/// `cpu_info` reports the parameters available in hardware, where `system_parameters`

/// are the software-enabled parameters that can differ from `cpu_info`.
class system_parameters : public base {
public:
/// Creates a new default ``system_parameters`` instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Use of double backticks here, where single backticks are used in other places in this file. Keep the usage consistent

Suggested change
/// Creates a new default ``system_parameters`` instance.
/// Creates a new default `system_parameters` instance.

#endif

private:
detail::pimpl<system_parameters_impl> impl_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a unique pointer?

Suggested change
detail::pimpl<system_parameters_impl> impl_;
std::unique_ptr<system_parameters_impl> impl_;

ss << std::any_cast<std::uint32_t>(value);
}
else {
throw unimplemented{ dal::detail::error_messages::unsupported_data_type() };
Copy link
Contributor

Choose a reason for hiding this comment

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

Can information about ti be printed in the exception as well?

Update: Looking at the code, this is not a simple ask, so ignore me. I've raised issue #2742


std::string system_parameters_impl::dump() const {
std::ostringstream ss;
for (auto it = sys_info_.begin(); it != sys_info_.end(); ++it) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for (auto it = sys_info_.begin(); it != sys_info_.end(); ++it) {
for (auto const& it : sys_info_) {

or if we can assume C++17:

  for (auto const &[name, val] : sys_info_) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C++17 variant was implemented here and in cpu_info

std::string dump(sycl::queue& queue) const;
#endif

protected:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think that this is ever used as a base class, so this should be private

Copy link
Contributor

@Alexandr-Solovev Alexandr-Solovev left a comment

Choose a reason for hiding this comment

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

Overall looks good to me with previous comments

Copy link
Contributor

@keeranroth keeranroth left a comment

Choose a reason for hiding this comment

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

All looks good to me. Thanks for the updates

Copy link
Contributor

@Alexandr-Solovev Alexandr-Solovev left a comment

Choose a reason for hiding this comment

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

Please fix conflicts and wait private CI checks

@Vika-F
Copy link
Contributor Author

Vika-F commented Apr 29, 2024

/intelci: run

@Vika-F
Copy link
Contributor Author

Vika-F commented Apr 30, 2024

/intelci: run

@Vika-F
Copy link
Contributor Author

Vika-F commented May 8, 2024

/intelci: run

Merge changes from main branch
@Vika-F
Copy link
Contributor Author

Vika-F commented May 10, 2024

/intelci: run

@Vika-F
Copy link
Contributor Author

Vika-F commented May 13, 2024

/intelci: run

@Vika-F
Copy link
Contributor Author

Vika-F commented May 15, 2024

@Vika-F
Copy link
Contributor Author

Vika-F commented May 16, 2024

/intelci: run

@Vika-F
Copy link
Contributor Author

Vika-F commented May 16, 2024

@Vika-F Vika-F merged commit 5c3a22c into oneapi-src:main May 17, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants