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

[SPEC] Clarify the behaviour of UR warning messages #1055

Closed

Conversation

fabiomestre
Copy link
Contributor

@fabiomestre fabiomestre commented Nov 9, 2023

  • This commit updates the specification to clarify the behaviour
    of UR_RESULT_ERROR_ADAPTER_SPECIFIC when returning warning messages.
  • This is a temporary change until specific error codes for warnings
    are added.

@fabiomestre fabiomestre marked this pull request as ready for review November 9, 2023 15:09
@fabiomestre fabiomestre changed the title [SPEC] Clarify the behaviour of UR warnning messages [SPEC] Clarify the behaviour of UR warning messages Nov 9, 2023
* This commit updates the specification to clarify the behaviour
of UR_RESULT_ERROR_ADAPTER_SPECIFIC when returning warning messages.
* This is a temporary change until specific error codes for warnings
are added.
///
/// @details
/// To be used after another entry-point has returned
/// ::UR_RESULT_ERROR_ADAPTER_SPECIFIC in order to retrieve a message describing
/// the circumstances of the underlying driver error and the error code
/// returned by the failed driver entry-point.
///
/// * If `pError` is ::UR_RESULT_SUCCESS, ::UR_RESULT_ERROR_ADAPTER_SPECIFIC

Choose a reason for hiding this comment

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

Although I understand it, I wonder if any adapter would add support to return a warning with SUCESS through urAdapterGetLastError. Returning a message through urAdapterGetLastError has an overhead (strncpy a mesage, keep track of the last message, etc).

this of course could be optional, but I'm concerned this would open the door for UR customers to start requesting warnings, given that the spec allows it, and then having pushback from underlying drivers or adapters that dont want to implement such warning because of performance considerations.

Copy link
Contributor Author

@fabiomestre fabiomestre Nov 27, 2023

Choose a reason for hiding this comment

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

For context, this spec change is a follow up to the discussion that happened in #989

At the moment, the UR spec says that UR_RESULT_ERROR_ADAPTER_SPECIFIC can be used to return a warning or error but doesn't specify how. The aim to this PR was to clarify what is the correct way to do it.

There are already adapters using UR_RESULT_ERROR_ADAPTER_SPECIFIC in this way. For example CUDA is doing it for a few entrypoints. In addition, this is the behaviour that SYCL-RT expects.

I understand that there are performance / design implications to returning a warning. The intent was for it to be an optional feature.

I guess that we have to decide whether we want to support warnings on UR or not. If the answer is yes, then that should be documented in the spec (which this PR aims to do). If the answer is no, then we need to update the spec, SYCL-RT and all the adapters that are using UR_RESULT_ERROR_ADAPTER_SPECIFIC in this way.

Copy link
Contributor

@kbenzie kbenzie Nov 27, 2023

Choose a reason for hiding this comment

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

As an interface layer between higher level languages and lower level drivers I don't think UR should stand in the way of either users requesting more information about why a feature they want to use isn't working or adapters informing users why performance is suboptimal.

As @fabiomestre says, the spec already supports this but does so in an unclear way. If you are concearned about the performance implecations in an adatper @jandres742 then perhaps we should think about ways of opting in to their use rather than being on by default, perahps with an environment variable.

Choose a reason for hiding this comment

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

thanks @kbenzie , @fabiomestre . I wouldn't even want this to be with env var, as that implies having branches on several places, even on critical paths.

Dont know if we need to clarify on this PR or in the spec that the warnings are optional, but if that's the intention, then I'm ok with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its reasonable to have spec language stating that emitting warnings is optional at the discretion of the adapter maintainers. @fabiomestre if you could update the spec language to clarify that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a bullet point to clarify that the warnings are optional in the latest commit.

@jandres742
Copy link

@fabiomestre

This is a temporary change until specific error codes for warnings
are added.

could you elaborate on the temporary nature of this change?

@fabiomestre
Copy link
Contributor Author

fabiomestre commented Nov 27, 2023

@fabiomestre

This is a temporary change until specific error codes for warnings
are added.

could you elaborate on the temporary nature of this change?

The solution would temporary because there are plans to split UR_RESULT_ERROR_ADAPTER_SPECIFIC into 2 different errors: #762

This would still require the adapters to set a message if they want to return a warning though.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@a1fbbde). Click here to learn what that means.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1055   +/-   ##
=======================================
  Coverage        ?   16.14%           
=======================================
  Files           ?      220           
  Lines           ?    30793           
  Branches        ?     3481           
=======================================
  Hits            ?     4973           
  Misses          ?    25770           
  Partials        ?       50           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 82 to 88

* If `pError` is $X_RESULT_SUCCESS, $X_RESULT_ERROR_ADAPTER_SPECIFIC
represents a warning instead. This means that the entry-point call did not
fail. However it might not have behaved as expected.

* Using $X_RESULT_ERROR_ADAPTER_SPECIFIC to emit warnings is an optional
feature. Its usage is left at the discretion of adapter maintainers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Indenting the bullet points makes them stand out more to the eye, also matches the surrounding style.

Suggested change
* If `pError` is $X_RESULT_SUCCESS, $X_RESULT_ERROR_ADAPTER_SPECIFIC
represents a warning instead. This means that the entry-point call did not
fail. However it might not have behaved as expected.
* Using $X_RESULT_ERROR_ADAPTER_SPECIFIC to emit warnings is an optional
feature. Its usage is left at the discretion of adapter maintainers.
* If `pError` is $X_RESULT_SUCCESS, $X_RESULT_ERROR_ADAPTER_SPECIFIC
represents a warning instead. This means that the entry-point call did not
fail. However it might not have behaved as expected.
* Using $X_RESULT_ERROR_ADAPTER_SPECIFIC to emit warnings is an optional
feature. Its usage is left at the discretion of adapter maintainers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

@fabiomestre fabiomestre marked this pull request as draft December 8, 2023 15:05
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