Skip to content

Replace oneapi::dpl::__internal::__no_op by oneapi::dpl::identity #2294

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

SergeyKopienko
Copy link
Contributor

@SergeyKopienko SergeyKopienko commented Jun 4, 2025

This PR replaces the internal __no_op functor with the public oneapi::dpl::identity across tests and library headers, and removes the now-unused __no_op definition.

  • Swap out all uses of oneapi::dpl::__internal::__no_op for oneapi::dpl::identity
  • Add #include <functional> (or the library’s functional) where oneapi::dpl::identity is used
  • Remove the __no_op struct from utils.h

@danhoeflinger
Copy link
Contributor

This LGTM, but I think you need to rebase with main.

@@ -18,6 +18,7 @@

#include "../async_extension_defs.h"
#include "async_impl_hetero.h"
#include "oneapi/dpl/functional" // for oneapi::dpl::identity
Copy link
Contributor

@akukanov akukanov Jun 4, 2025

Choose a reason for hiding this comment

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

I am concerned about including a public header file from internal files. As far as I can tell, there is no precedent of that yet.
Perhaps it's not an immediate problem, because now oneapi/dpl/functional and its dependencies do not include any internal headers, Nevertheless, maybe it makes sense to move the actual implementation to an internal header, separate from the public header, and use that for internal purposes.

What do others think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. I think it makes sense to move these functional definitions to an internal header.

Copy link
Contributor Author

@SergeyKopienko SergeyKopienko Jun 5, 2025

Choose a reason for hiding this comment

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

It's not a big deal to move this implementation into internal header.
But as far as this oneapi::dpl::identity was public before, my understanding that it should be public after move into internal header too, in oneapi::dpl namespace.
Correct?

Copy link
Contributor Author

@SergeyKopienko SergeyKopienko Jun 5, 2025

Choose a reason for hiding this comment

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

I am concerned about including a public header file from internal files. As far as I can tell, there is no precedent of that yet. Perhaps it's not an immediate problem, because now oneapi/dpl/functional and its dependencies do not include any internal headers, Nevertheless, maybe it makes sense to move the actual implementation to an internal header, separate from the public header, and use that for internal purposes.

What do others think?

Practically we had this include before but in a little bit another form, I found: https://github.com/search?q=repo%3Auxlfoundation%2FoneDPL%20%23include%20%22..%2Ffunctional%22&type=code

Example from

:

#include "../../functional"

If we allow and prefer this form instead of #include "oneapi/dpl/functional" I will fix my changes.
May be it's also one of options for us?

Copy link
Contributor

@MikeDvorskiy MikeDvorskiy Jun 5, 2025

Choose a reason for hiding this comment

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

maybe it makes sense to move the actual implementation to an internal header

Am I right that oneapi::dpl::identity remains in Public API , and we are talking about the implementation moving? And in the functional public header will contain just using oneapi::dpl::__internal::identity;? (and for the other function objects - minimum, maximum) ?

In that case we are breaking the spec a little bit, where it is saying "The oneDPL function objects are defined in the <oneapi/dpl/functional> header."

References:
oneDPL spec
oneDPL doc

Copy link
Contributor

Choose a reason for hiding this comment

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

```c++
#include "../../functional"

If we allow and prefer this form instead of #include "oneapi/dpl/functional" I will fix my changes.
May be it's also one of options for us?

That one "include" case is again for usage of oneapi::dpl::identity. So, we will not need #include "../../functional" if we decide to use a kind of oneapi::dpl::__internal::identity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My opinion - I would prefer to save changes as is, without move our own struct identity into some another places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its too bad the spec was written in that way...
I think it would probably be a benefit to adjusting the spec to use language more similar to the guide, where it doesn't specify where they are defined, but rather how you can get access to them. I would be incredibly surprised if moving them to an internal namespace and using an alias broke any user code.
I'm really not sure the best course here though, I'd be interested in @akukanov opinion.

@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/replace_no_op_to_identity branch 3 times, most recently from 49c37ae to 52d9b64 Compare June 5, 2025 08:34
@SergeyKopienko SergeyKopienko force-pushed the dev/skopienko/replace_no_op_to_identity branch from 099dfbb to 9b6142d Compare June 6, 2025 15:40
@SergeyKopienko SergeyKopienko requested a review from akukanov June 10, 2025 08:24
# Conflicts:
#	include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h
# Conflicts:
#	test/parallel_api/iterator/input_data_sweep.h
@SergeyKopienko SergeyKopienko requested a review from Copilot June 12, 2025 09:59
Copilot

This comment was marked as outdated.

@SergeyKopienko SergeyKopienko requested a review from Copilot June 13, 2025 15:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the internal __no_op functor and replaces its usages with the public oneapi::dpl::identity, eliminating duplicate implementations and ensuring consistent behavior across tests and library headers.

  • Replace all instances of oneapi::dpl::__internal::__no_op with oneapi::dpl::identity
  • Add necessary includes for functional support in affected files
  • Remove the now-unused __no_op definition from utils.h

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/parallel_api/iterator/transform_iterator_constructible.pass.cpp Updated functor typedefs and test instantiations to use oneapi::dpl::identity
test/parallel_api/iterator/input_data_sweep.h Added include for functional header and updated local functor usage
test/general/interface_check.pass.cpp Removed unused include
include/oneapi/dpl/pstl/utils.h Removed the __no_op struct definition
All other updated source files Replaced internal __no_op usages with oneapi::dpl::identity and adjusted includes accordingly
Comments suppressed due to low confidence (3)

test/parallel_api/iterator/transform_iterator_constructible.pass.cpp:27

  • [nitpick] Consider verifying that inheriting from oneapi::dpl::identity in noop_nodefault preserves the intended behavior; if custom behavior is needed, using composition rather than inheritance might be more appropriate.
struct noop_nodefault : oneapi::dpl::identity

include/oneapi/dpl/pstl/hetero/dpcpp/unseq_backend_sycl.h:27

  • [nitpick] Verify that using the relative include path for the functional header remains robust across different build environments; consider using a canonical include path if available.
#include "../../../functional" // for oneapi::dpl::identity

include/oneapi/dpl/pstl/glue_numeric_impl.h:19

  • [nitpick] Ensure the relative include path for the functional header adheres to the project-wide conventions to prevent future maintenance issues.
#include "../functional" // for oneapi::dpl::identity

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.

4 participants