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

[WIP] decimal meta adjustment for GPU runtime #976

Closed

Conversation

sperlingxx
Copy link
Collaborator

@sperlingxx sperlingxx commented Oct 19, 2020

Catalyst analyzer will apply promotePrecision and checkOverflow on binary arithmetic expressions if data in both sides of expressions are decimal types (refer to link).

Considering GPU_MAX_PRECISION of decimal type can only be up to 19 (half of MAX_PRECISION in spark), we need to reapply precision and scale adjustment with GPU constraints. To achieve this, we introduce two new expression-rules PromotePrecisionExprMeta and CheckOverflowExprMeta into GpuOverrides.

In order to keep align with decimal overflow controlling behavior of spark, we follow the same strategy as catalyst with GPU constraints replacement. But in spark catalyst runtime, overflow decimal value will be replaced by null. (Otherwise, overflow exception will be thrown.) In cuDF runtime, overflow check for decimal operations is still missing.

@svcngcc
Copy link
Contributor

svcngcc commented Oct 19, 2020

Can one of the admins verify this patch?

Copy link
Collaborator

@revans2 revans2 left a comment

Choose a reason for hiding this comment

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

Until we support casting to decimal I don't see any value of adding this in.

@@ -532,6 +532,20 @@ object GpuOverrides {
// There are so many of these that we don't need to print them out.
override def print(append: StringBuilder, depth: Int, all: Boolean): Unit = {}
}),
// TODO: maybe we should apply the conversion between decimal32 and decimal64 to promote precision?
expr[PromotePrecision](
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the same as KnownFloatingPointNormalized or KnownNotNull. In those cases we don't throw it away, we replace it with s GPU version that is essentially a noop. It has little performance impact and lets us keep the same structure that spark has.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! And this PR has been refactored.

override def convertToGpu(child: Expression): GpuExpression = {
child match {
case c: GpuCast => c.child.asInstanceOf[GpuExpression]
case c => throw new IllegalStateException(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this guaranteed 100% of the time that the child will be a cast? If not then we need to figure out better way to handle this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So far, it is 100% guaranteed since case class PrecisionPromotionwill only be created inside private method DecimalPrecision.promotePrecisionwith Cast Op.

@sperlingxx sperlingxx changed the title promote precision elimination for GPU decimal support [decimal support] GpuPromotePrecision and GpuCheckOverflow Oct 20, 2020
@sperlingxx sperlingxx changed the title [decimal support] GpuPromotePrecision and GpuCheckOverflow [decimal support] PromotePrecisionExprMeta and CheckOverflowExprMeta Oct 20, 2020
@sperlingxx
Copy link
Collaborator Author

sperlingxx commented Oct 20, 2020

Until we support casting to decimal I don't see any value of adding this in.

Yes. Because initial work for decimal is W.I.P. in terms of cuDF java library, I am trying to work on something which is independent on cudf.DataType in parallel.

@revans2
Copy link
Collaborator

revans2 commented Oct 20, 2020

I am fine with you wanting to work ahead. I just wasn't aware that this patch is still a work in progress. Sorry for the confusion.

@sameerz sameerz added the feature request New feature or request label Oct 20, 2020
Signed-off-by: sperlingxx <lovedreamf@gmail.com>
@sperlingxx sperlingxx changed the title [decimal support] PromotePrecisionExprMeta and CheckOverflowExprMeta [decimal support] decimal meta adjustment for GPU runtime Oct 21, 2020
@sperlingxx sperlingxx changed the title [decimal support] decimal meta adjustment for GPU runtime [WIP] decimal meta adjustment for GPU runtime Oct 21, 2020
Copy link
Member

@jlowe jlowe left a comment

Choose a reason for hiding this comment

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

This should be retargeted to branch-0.4.

tgravescs pushed a commit to tgravescs/spark-rapids that referenced this pull request Nov 30, 2023
…IDIA#976)

Signed-off-by: spark-rapids automation <70000568+nvauto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants