Skip to content

[SYCL][FPGA] Initial implementation of pipes feature - #292

Merged
bader merged 3 commits into
intel:syclfrom
MrSidims:private/MrSidims/GlobalPipes_WOCL
Jul 15, 2019
Merged

bader merged 3 commits into
intel:syclfrom
MrSidims:private/MrSidims/GlobalPipes_WOCL

Conversation

@MrSidims

@MrSidims MrSidims commented Jul 8, 2019

Copy link
Copy Markdown
Contributor

No description provided.

@keryell keryell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a super-useful feature on FPGA.
I have nevertheless a few remarks.

Comment thread clang/lib/Sema/SemaType.cpp Outdated
Comment thread clang/lib/Sema/SemaType.cpp Outdated
Comment thread sycl/doc/extensions/SYCL_pipes_lowering_to_SPIRV.rst Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Spurious ,.
I do not know if "leveraged" is good here. Do you improve SPIR-V or you just recycle it for another purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SPIR-V representation is re-used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then clarify...

Comment thread sycl/doc/extensions/SYCL_pipes_lowering_to_SPIRV.rst Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unclear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have rewrote this one, please check it.

Comment thread sycl/include/CL/sycl/pipes.hpp Outdated
Comment thread sycl/include/CL/sycl/pipes.hpp Outdated
Comment thread sycl/include/CL/sycl/pipes.hpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

static bool write(const dataT &Data) instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The const reference is good. The status return code move to returned bool makes the signatures of read and write differ more than I would like. Read returns the data type in both cases. How strongly do you think that write should return bool success status, while read returns the data and takes a status ref arg?

Comment thread sycl/include/CL/sycl/pipes.hpp Outdated
Comment thread sycl/test/fpga_tests/fpga_pipes.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any user-friendly documentation on how this Pipe extension works?
One of the things that confuses me is that, in the test above, there is nothing preventing a SYCL runtime to execute goo_nb before foo_nb, since the intersection of the requirements is empty and SYCL queues are out-of-order.

Is that relevant in your case? I figure for an FPGA it doesn't matter, but there is nothing in this extension that suggest it shouldn't work on anything that is not an FPGA but supports pipes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there any user-friendly documentation on how this Pipe extension works?

It's going to be published. Don't really know when.
There is SYCL 2.2 spec (which is deprecated, but yet can provide some information). Also this implementation doesn't follows it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I figure for an FPGA it doesn't matter, but there is nothing in this extension that suggest it shouldn't work on anything that is not an FPGA but supports pipes.

Yeah, I shall put some code in device information quarrying.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We'll publish the extension document soon in this repo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The problem is to come with a terse API and at the same time not giving up any performance on the table...
Perhaps a more explicit naming in the case of (non-)blocking? Adding a tag to pick another overload? Adding a template parameter?...
I understand that relying on an accessor to encode the blocking behavior like in SYCL 2.2 might be a too heavy syntax....

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The pipes extension at SYCL level is described in the document, currently as a pending PR, at:
#635

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah thank you for the cross-reference. It prevents me from looking for it...

Comment thread sycl/test/fpga_tests/fpga_pipes.cpp Outdated
Comment thread sycl/include/CL/sycl/pipes.hpp Outdated

@asavonic asavonic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current documentation mostly covers SPIR-V and LLVM IR levels.
Please describe how this feature is represented and used (with examples) at SYCL level.

Comment thread clang/include/clang/Basic/TokenKinds.def Outdated
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch 2 times, most recently from f97d84a to 30ae85f Compare July 11, 2019 15:16

@keryell keryell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting!
Still a few remarks.

Comment thread clang/lib/Parse/ParseDecl.cpp Outdated
Comment thread sycl/doc/extensions/SYCL_pipes_usage.rst Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the memory model of a pipe in the case you are executing it in a parallel_for and not a single_task?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you expect some independent-forward-progress here in the case dataSize > 1 (the capacity of the pipe...)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I expect that. I should re-write the example code into:
cgh.parallel_for<class bar>(range<1> { 1024 }, [=](id<1> idx) { write_acc[idx] = my_pipe::read(); });

OpenCL analog of the code above is:
__kernel void foo(__read_only pipe uint in_pipe, __global uint *dst) { int gid = get_global_id(0); read_pipe(in_pipe, &dst[gid]); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But it is illegal OpenCL code in general. You have to use pipe reservation for this and and I am not sure we want this anyway on FPGA...
So the assumptions are probably to be described in the document describing the extension.
What happens if there are multiple work-group on different CU using the same pipe input or output?

@MrSidims MrSidims Jul 15, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But it is illegal OpenCL code in general. You have to use pipe reservation for this and and I am not sure we want this anyway on FPGA...

You are right.

What happens if there are multiple work-group on different CU using the same pipe input or output?

... to be described in the document describing the extension :) I added a quote from there:

Accesses to a single pipe within two work-items of the same kernel, and/or threads of the host program: No ordering guarantees are made on the order of pipe operations across device work-items or host threads. For example, if two work-items executing a kernel write to a pipe, there are no guarantees that the work-item with lower id (for any definition of id) executes before the pipe write from a higher id. The execution order of work-items executing a kernel are not defined by SYCL, may be dynamically reordered, and may not be deterministic. If ordering guarantees are required across work-items and/or host threads, synchronization mechanisms such as atomics or barriers must be used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@keryell, are you okay to merge this PR?

Yes I am fine with merging.
It looks like in #318 there are some corrections that will be done later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it legal to have a local class some_pipe declaration like here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I don't try to use it after - yes. It's a forward declaration that adds appropriate mangling for fields and methods of the template class pipe.

Comment thread sycl/doc/extensions/SYCL_pipes_usage.rst Outdated
Comment thread sycl/doc/extensions/SYCL_pipes_usage.rst Outdated
Comment thread sycl/doc/extensions/SYCL_pipes_usage.rst Outdated
Comment thread sycl/doc/extensions/SYCL_pipes_usage.rst Outdated
Comment thread sycl/test/fpga_tests/fpga_pipes.cpp Outdated
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch from fffd69f to c627b78 Compare July 12, 2019 08:57
@MrSidims
MrSidims requested a review from asavonic July 12, 2019 10:01
Comment thread clang/lib/Parse/ParseTentative.cpp Outdated
Comment thread clang/lib/Parse/ParseDecl.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add a check for that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No. If this keyword appears in any other language, clang already will report it be unknown keyword.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but if there is __pipe used in an existing library, unrelated to SYCL?
But do we need such a keyword?

@MrSidims MrSidims Jul 15, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

But do we need such a keyword?

Will be reworked as attribute. Or you suggest to do some forward declaration expecting the translator to do its work?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the attribute is fine.

Comment thread clang/lib/Sema/SemaDecl.cpp Outdated
Comment thread sycl/include/CL/sycl/pipes.hpp Outdated
@bader bader self-assigned this Jul 12, 2019
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch 2 times, most recently from 81c2eff to ec15072 Compare July 12, 2019 12:10
Comment thread clang/lib/Sema/SemaDecl.cpp Outdated
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch 2 times, most recently from fdacf2e to ad598c1 Compare July 12, 2019 12:50
bader
bader previously approved these changes Jul 12, 2019
@bader
bader dismissed asavonic’s stale review July 12, 2019 18:00

Documentation has been added.

Comment thread sycl/include/CL/sycl/pipes.hpp Outdated
@bader

bader commented Jul 14, 2019

Copy link
Copy Markdown
Contributor

@keryell, @Ruyk, @asavonic, please, "resolve conversations", which do not require follow-up actions.
I'd like to merge this pull request, but it's hard to say if all issues are resolved or not - there are 97 comment at the moment.

I think there are at least three issues left to resolve (updated by @keryell last Friday).

Dmitry Sidorov added 2 commits July 15, 2019 11:22
Pipe types construction rely on keywords mechanism.
Consider following code:
    __read_only __pipe int p;

It declares a read only pipe with integer layout.
In LLVM IR this type is seen as 'pipe_ro_t'.

Write only pipe type will be looking like 'pipe_wo_t'.

Signed-off-by: Dmitry Sidorov <[email protected]>
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch from ad598c1 to a5f9027 Compare July 15, 2019 08:36
bader
bader previously approved these changes Jul 15, 2019
Pipe are supported via generation SPIR-V friendly IR
and lowering it directly to SPIR-V code.

non-blocking pipes are supported;
blocking pipes are supported as a workaround.

Signed-off-by: Dmitry Sidorov <[email protected]>
@MrSidims
MrSidims force-pushed the private/MrSidims/GlobalPipes_WOCL branch from a5f9027 to cb9c774 Compare July 15, 2019 09:52
@bader

bader commented Jul 15, 2019

Copy link
Copy Markdown
Contributor

@keryell, are you okay to merge this PR?

@bader
bader merged commit 74527fc into intel:sycl Jul 15, 2019
mkinsner pushed a commit to mkinsner/llvm that referenced this pull request Nov 13, 2019
adamfidel pushed a commit to adamfidel/llvm that referenced this pull request Feb 9, 2026
* [SYCL][Graph] Duplicate sub-graph nodes

Duplicates the nodes of a sub-graph when added to its parents to enable multiple parents.
As a result nodes of the initial sub-graph and the one of the main graph are no longer
the exact same (shared_pointer) but two different nodes with similar content.
A few unitests have been updated accordingly and an equal operator has been added
to node_impl to ease comparison between nodes.
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.

8 participants