Skip to content

[SYCL] Add validation + exception handling to SYCL_PARALLEL_FOR_RANGE_ROUNDING_PARAMS #19381

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 8 commits into
base: sycl
Choose a base branch
from

Conversation

ianayl
Copy link
Contributor

@ianayl ianayl commented Jul 9, 2025

No description provided.

@ianayl ianayl requested a review from a team as a code owner July 9, 2025 22:54
@ianayl ianayl requested a review from slawekptak July 9, 2025 22:54
@ianayl ianayl temporarily deployed to WindowsCILock July 9, 2025 22:54 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 9, 2025 23:21 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 9, 2025 23:21 — with GitHub Actions Inactive
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

We should have a test added for the change

@ianayl ianayl temporarily deployed to WindowsCILock July 10, 2025 20:23 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 10, 2025 20:51 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 10, 2025 20:51 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 21:42 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 22:08 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 22:08 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 22:33 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 23:00 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 11, 2025 23:00 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 17:19 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 17:46 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 17:46 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 19:39 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 20:11 — with GitHub Actions Inactive
@ianayl ianayl temporarily deployed to WindowsCILock July 14, 2025 20:11 — with GitHub Actions Inactive
@ianayl
Copy link
Contributor Author

ianayl commented Jul 17, 2025

@intel/llvm-reviewers-runtime PR ready for review, thanks in advance!

size_t &MinRange) {
static const char *RoundParams = BaseT::getRawValue();
size_t &MinRange, bool ForceUpdate = false) {
const char *RoundParams = BaseT::getRawValue();
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 want to remove static from the declaration of *RoundParams ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially removed it because I figured the variable should be re-read every time, but in hindsight this whole statement should be moved elsewhere to avoid this being called everytime the function is ran...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In hindsight's hindsight, if the env variable is empty getRawValue returns null; in which it actually makes sense the check is where it is

if (Pos != std::string::npos) {
MF = std::stoi(Params.substr(0, Pos));
if (Pos != std::string::npos && GuardedStoi(MF, Params.substr(0, Pos)) &&
MF > 0) {
Copy link
Contributor

@cperkinsintel cperkinsintel Jul 23, 2025

Choose a reason for hiding this comment

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

should this be MF >= 0 ( GTE instead of GT) ? 0 is a valid return from GuardedStoi, no? Or maybe 0 should not be valid in GuardedStoi.

Copy link
Contributor Author

@ianayl ianayl Jul 24, 2025

Choose a reason for hiding this comment

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

The way we currently have range rounding, MF=0 results in a division by zero error: This PR helps prevent the crash that would happen as a result.

I don't think it makes sense anyway, as according to https://github.com/intel/llvm/blob/970e2ef386e6287202cbaf69ff3871889bed5959/sycl/doc/EnvironmentVariables.md, the minimum factor is the "range that the rounded range should be a multiple of (Default 16)": Rounding parallel_for ranges to a multiple of 0 should probably not be possible. Thus, I have a test case to explicitly check that MF=0 should not be accepted.

@ianayl ianayl requested a review from cperkinsintel July 24, 2025 20:10
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.

3 participants