Skip to content

[SYCL][FPGA] Expose value_type and min_capacity from sycl::ext::intel::experimental::pipe #5896

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

Closed
wants to merge 1 commit into from
Closed

[SYCL][FPGA] Expose value_type and min_capacity from sycl::ext::intel::experimental::pipe #5896

wants to merge 1 commit into from

Conversation

pcolberg
Copy link
Contributor

@pcolberg pcolberg commented Mar 25, 2022

This applies commit e1619fa to the experimental implementation to match the supported implementation.

#5471
#5895

Cc: @tyoungsc @shuoniu-intel @rho180 @zibaiwan

@pcolberg pcolberg requested review from a team as code owners March 25, 2022 23:24
@pcolberg pcolberg self-assigned this Mar 25, 2022
@pcolberg pcolberg requested a review from againull March 25, 2022 23:24
@pcolberg
Copy link
Contributor Author

The second commit in #5896 stacks on top of #5895. I will drop the first commit in #5896 once #5895 is merged.

@pcolberg
Copy link
Contributor Author

@tyoungsc I copied the changes to the specification and the implementation verbatim from your commit e1619fa, but noticed that the type of min_capacity is size_t in the specification while it is int32_t in the implementation. Do you know where this difference stems from? Are the types identical in practice? Should either be changed to match the either?

@tyoungsc
Copy link
Contributor

@tyoungsc I copied the changes to the specification and the implementation verbatim from your commit e1619fa, but noticed that the type of min_capacity is size_t in the specification while it is int32_t in the implementation. Do you know where this difference stems from? Are the types identical in practice? Should either be changed to match the either?

I don't know where this stems from :(. No, they will not be identical, size_t will likely be a uint64_t.
I also have no clue why my changes caused the build to break and am not treating this with high priority.

@gmlueck
Copy link
Contributor

gmlueck commented Mar 28, 2022

Needless to say, the spec and the implementation should agree. I see that you also use size_t for the map and unmap member functions of the host pipe class. Should those types match the type of min_capacity?

@tyoungsc
Copy link
Contributor

Needless to say, the spec and the implementation should agree. I see that you also use size_t for the map and unmap member functions of the host pipe class. Should those types match the type of min_capacity?

IMO they should all match and be unsigned, since a negative value for any of them doesn't make sense. Whether we choose uint32_t or uint64_t (size_t), I don't have a preference. Since the spec currently uses size_t for all, I would say we should switch all to size_t.

…::experimental::pipe

This applies commit e1619fa to the
experimental implementation to match the supported implementation.

#5471
#5895
@pcolberg
Copy link
Contributor Author

pcolberg commented Mar 29, 2022

Needless to say, the spec and the implementation should agree. I see that you also use size_t for the map and unmap member functions of the host pipe class. Should those types match the type of min_capacity?

IMO they should all match and be unsigned, since a negative value for any of them doesn't make sense. Whether we choose uint32_t or uint64_t (size_t), I don't have a preference. Since the spec currently uses size_t for all, I would say we should switch all to size_t.

Thanks @gmlueck and @tyoungsc!

@GarveyJoe do you agree with using size_t for min_capacity in the implementation, or do you see a reason for uint32_t, e.g., hardware limitations, efficiency, etc., in which case the specification would need to be adjusted?

@pcolberg
Copy link
Contributor Author

pcolberg commented Mar 29, 2022

The SPIRV API uses int32_t for data type size, alignment, and min_capacity, see ConstantPipeStorage and __spirv_ReadPipe/__spirv_WritePipe. So really the question is whether int32_t should be exposed to the user or not. Since the choice has already been made, we might want to keep it as is and update the specification to match the implementation, as to not break the supported ABI.

kernel_readable_io_pipe and kernel_writeable_io_pipe do use size_t for the min_capacity template parameter, but expose it as an int32_t static member.

@GarveyJoe
Copy link
Contributor

Mike and I must have missed this when initially working on the pipes spec. The SPIR-V spec is clear that the capacity of a pipe must be a 32-bit unsigned integer but at the same time we don't want to break ABI compatibility.

As a compromise we could keep the template parameter as a size_t and make the member a size_t but static_assert if the user tries to use a min_capacity that doesn't fit in an int32_t stating that our compiler can't handle pipes that large. Any existing code that uses a capacity that doesn't fit in an int32_t is presumably broken right now anyways since it can't be translated into SPIR-V so this shouldn't cause any regressions in compiling code.

If we do this we should probably add to the spec a sentence saying that the maximum minimum_capacity supported by a device is implementation defined and that the implementation must emit a diagnostic if that maximum is exceeded. We could also require some reasonable minimum maximum minimum_capacity. There is lots of precedent for this in both C++ and SPIR-V, such as maximum array size (array declarations take a size_t but an implementation doesn't need to be able to create an array of size equal to maximum value a size_t can hold).


// Static members
using value_type = dataT;
size_t min_capacity = min_capacity;
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
size_t min_capacity = min_capacity;
static constexpr size_t min_capacity = min_capacity;

@pcolberg pcolberg removed their assignment Aug 10, 2022
@github-actions github-actions bot added the Stale label Feb 7, 2023
@github-actions github-actions bot closed this Mar 9, 2023
@pcolberg pcolberg deleted the sycl-merge-supported-pipes-impl branch March 15, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants