Skip to content

[SYCL] Refactor queue to improve ABI stability #985

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

Merged
merged 18 commits into from
Jan 31, 2020

Conversation

alexbatashev
Copy link
Contributor

This patch is a part of effort to decouple SYCL Runtime library
interface from its actual implementation. The goal is to improve
SYCL ABI/API compatibility between different versions of library.

The following modifications were applied to queue and queue_impl
classes:

  1. Removed include of queue_impl header from queue.hpp and replaced
    it with forward declaration.
  2. Move member function implementations from queue.hpp to queue.cpp
  3. Documentation was improved for both queue and queue_impl
  4. queue_impl now tries to follow LLVM code style
  5. std::shared_ptr was replaced with shared_ptr_class for queue class
  6. Command group is now passed inside the library as function_class<void(handler&)>

Applying aforementioned changes requires modifying other header files.
While some of those may seem as a regression, affected classes will be
covered by future patches.

Signed-off-by: Alexander Batashev [email protected]

const size_t MaxNumQueues = 256;

enum QueueOrder { Ordered, OOO };

class queue_impl {
public:
/// Constructs a SYCL queue with an async_handler and property_list provided
/// from a device.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure it's phrased carefully. "async_handler and property_list provided from a device" - sounds like error handler and property list are associated with "a device" rather than "a queue".

event submit_impl(T cgf, std::shared_ptr<queue_impl> self) {
handler Handler(std::move(self), m_HostQueue);
cgf(Handler);
/// Performs actual command group submission to the queue.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need add "actual" here? I'm not sure that context is clear for everyone.

@alexbatashev alexbatashev force-pushed the private/abatashe/refactor_queue branch from 700ec1c to 9692303 Compare December 31, 2019 08:01
template <class Obj>
friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);

/// A template-free version of submit.
event submit_impl(function_class<void(handler &)> CGH);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we not removing T in submit because it's in the spec?
What failure will we see in runtime if T passed to submit is not function_class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@garimagu table 4.22 of the spec explicitly specifies what T may be. Those are all callable objects of the same signature. So, user is not expected to pass anything incompatible with function_class and they get a compilation failure if the do. Furthermore, there're no behavior changes, even without this patch custom object causes failure.

@alexbatashev alexbatashev force-pushed the private/abatashe/refactor_queue branch from 9692303 to c415a98 Compare January 23, 2020 07:57
Alexander Batashev added 17 commits January 24, 2020 10:41
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
Signed-off-by: Alexander Batashev <[email protected]>
@alexbatashev alexbatashev force-pushed the private/abatashe/refactor_queue branch from c415a98 to 7e1a82f Compare January 24, 2020 07:47
romanovvlad
romanovvlad previously approved these changes Jan 28, 2020
/// Constructs a SYCL queue with an async_handler and property_list provided
/// form a device and a context.
///
/// @param Device is a pointer to device_impl.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you see any value in the comments like this?
This comment repeats information, which I can get form the constructor declaration - I see the type of Device parameter.
You could say something useful about relations between the queue and device - e.g. that commands submitted to the queue will be executed on the Device.
I would expect a comment clarifying why Device is needed to construct the queue, not what is the parameter type.

I really appreciate your work with commenting the code, but please, do not add comments just for the sake of having some comments.

Signed-off-by: Alexander Batashev <[email protected]>
@romanovvlad romanovvlad merged commit ba96fd7 into intel:sycl Jan 31, 2020
@alexbatashev alexbatashev deleted the private/abatashe/refactor_queue branch July 28, 2021 06:44
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.

4 participants