Skip to content

Commit

Permalink
Check the stack depth GPU will use does not exceed threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
Chong Gao committed Dec 20, 2024
1 parent 9d1bac2 commit 16119f4
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3995,6 +3995,24 @@ object GpuOverrides extends Logging {
// HyperLogLogPlusPlus supports all the types that Xxhash 64 supports
Seq(ParamCheck("input",XxHash64Shims.supportedTypes, TypeSig.all))),
(a, conf, p, r) => new UnaryExprMeta[HyperLogLogPlusPlus](a, conf, p, r) {

// It's the same as Xxhash64
override def tagExprForGpu(): Unit = {
val maxDepth = a.children.map(
c => XxHash64Utils.computeMaxStackSize(c.dataType)).max
if (maxDepth > Hash.MAX_STACK_DEPTH) {
willNotWorkOnGpu(s"The data type requires a stack depth of $maxDepth, " +
s"which exceeds the GPU limit of ${Hash.MAX_STACK_DEPTH}. " +
"The algorithm to calculate stack depth: " +
"1: Primitive type counts 1 depth; " +
"2: Array of Structure counts: 1 + depthOf(Structure); " +
"3: Array of Other counts: depthOf(Other); " +
"4: Structure counts: 1 + max of depthOf(child); " +
"5: Map counts: 2 + max(depthOf(key), depthOf(value)); "
)
}
}

override def convertToGpu(child: Expression): GpuExpression = {
GpuHyperLogLogPlusPlus(child, a.relativeSD)
}
Expand Down

0 comments on commit 16119f4

Please sign in to comment.