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

Clarify the size of integer used for the kernel attributes #450

Open
jzc opened this issue Jul 27, 2023 · 9 comments · May be fixed by #721
Open

Clarify the size of integer used for the kernel attributes #450

jzc opened this issue Jul 27, 2023 · 9 comments · May be fixed by #721
Labels
clarification Something is unclear

Comments

@jzc
Copy link
Contributor

jzc commented Jul 27, 2023

For kernel attributes like reqd_work_group_size, reqd_sub_group_size, what integer size is used for the argument? I assume since range use size_t, the types should be size_t.

@jzc
Copy link
Contributor Author

jzc commented Jul 27, 2023

FYI @gmlueck

@gmlueck
Copy link
Contributor

gmlueck commented Jul 27, 2023

I certainly think that the attributes should accept any integer value that can be represented in a size_t.

I suppose the behavior for even larger values is debatable. One option is to allow any C++ integer literal. At runtime the implementation would see if the device supports the requested work-group / sub-group size. This would almost certainly be "no" for any value that is larger than size_t, so you would get a runtime exception when trying to submit the kernel.

Were you asking about values that are no bigger than size_t, or were you asking about the weird case where values are legal integer literals that are bigger than size_t?

@jzc
Copy link
Contributor Author

jzc commented Jul 27, 2023

Just the case where values that can fit in size_t. I just wanted to double check because the spec says that arguments are to be integral constant expressions, which from one point of view, this doesn't say what type the argument should be, although from another point of view, this means every integral type should be supported (i.e. the type doesn't matter, just the actual number represented, as long as the value fits in some integral type).

I didn't think about that weird case, but from that cppreference page, it says that literals that can't fit inside any integer type make the program ill-formed, so I don't think that's an issue.

@gmlueck
Copy link
Contributor

gmlueck commented Jul 27, 2023

I didn't think about that weird case, but from that cppreference page, it says that literals that can't fit inside any integer type make the program ill-formed, so I don't think that's an issue.

Yes, but there could be integer types that are larger than size_t.

@AlexeySachkov
Copy link
Contributor

I don't think that we should consider integer types which are larger than size_t. The reason for that is to make the spec consistent: all queries related to properties set by those attributes return size_t and therefore I don't think that it makes sense to allow a value bigger than size_t. Why do we allow to write a kernel, which can't be launched by any conformant device?

info::device::max_work_item_sizes<N> returns range<N>; info::device::max_work_group_size returns size_t; info::device::sub_group_sizes returns std::vector<size_t>

@gmlueck
Copy link
Contributor

gmlueck commented Aug 2, 2023

Yes, I think that makes sense too. We should change the spec wording from:

Each argument must be an integral constant expression.

To:

Each argument must be an integral constant expression that is representable by size_t.

Except for reqd_sub_group_size, which should change to:

Each argument must be an integral constant expression that is representable by uint32_t.

This is because the APIs for sub-group size all return uint32_t.

@AlexeySachkov
Copy link
Contributor

Except for reqd_sub_group_size, which should change to:

Each argument must be an integral constant expression that is representable by uint32_t.

This is because the APIs for sub-group size all return uint32_t.

Max number of sub-groups in a work-group is defined as uint32_t, but sub-group sizes are defined as size_t

@gmlueck
Copy link
Contributor

gmlueck commented Aug 2, 2023

The sub_group::get_local_linear_id function returns a uint32_t, for example.

@AlexeySachkov
Copy link
Contributor

The sub_group::get_local_linear_id function returns a uint32_t, for example.

Oh, I see. Should we also consider updating info::device::sub_group_sizes query then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Something is unclear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants