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

Expose max stack depth in hash function to plugin #2680

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/cpp/src/HashJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@

extern "C" {

JNIEXPORT jint JNICALL Java_com_nvidia_spark_rapids_jni_Hash_getMaxNestedDepth(JNIEnv* env, jclass)
{
try {
return spark_rapids_jni::MAX_NESTED_DEPTH;
}
CATCH_STD(env, 0);
ustcfy marked this conversation as resolved.
Show resolved Hide resolved
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_Hash_murmurHash32(
JNIEnv* env, jclass, jint seed, jlongArray column_handles)
{
Expand Down
1 change: 1 addition & 0 deletions src/main/cpp/src/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
namespace spark_rapids_jni {

constexpr int64_t DEFAULT_XXHASH64_SEED = 42;
constexpr int MAX_NESTED_DEPTH = 8;

/**
* @brief Computes the murmur32 hash value of each row in the input set of columns.
Expand Down
3 changes: 1 addition & 2 deletions src/main/cpp/src/hive_hash.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "hash.cuh"
#include "hash.hpp"

#include <cudf/column/column_factories.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
Expand All @@ -37,8 +38,6 @@ using hive_hash_value_t = int32_t;
constexpr hive_hash_value_t HIVE_HASH_FACTOR = 31;
constexpr hive_hash_value_t HIVE_INIT_HASH = 0;

constexpr int MAX_NESTED_DEPTH = 8;

hive_hash_value_t __device__ inline compute_int(int32_t key) { return key; }

hive_hash_value_t __device__ inline compute_long(int64_t key)
Expand Down
3 changes: 1 addition & 2 deletions src/main/cpp/src/xxhash64.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "hash.cuh"
#include "hash.hpp"

#include <cudf/column/column_factories.hpp>
#include <cudf/detail/utilities/algorithm.cuh>
Expand All @@ -34,8 +35,6 @@ namespace {
using hash_value_type = int64_t;
using half_size_type = int32_t;

constexpr int MAX_NESTED_DEPTH = 8;

constexpr __device__ inline int64_t rotate_bits_left_signed(hash_value_type h, int8_t r)
{
return (h << r) | (h >> (64 - r)) & ~(-1 << r);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/nvidia/spark/rapids/jni/Hash.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class Hash {
// there doesn't appear to be a useful constant in spark to reference. this could break.
static final long DEFAULT_XXHASH64_SEED = 42;

public static final int MAX_NESTED_DEPTH = getMaxNestedDepth();

static {
NativeDepsLoader.loadNativeDeps();
}
Expand Down Expand Up @@ -100,6 +102,8 @@ public static ColumnVector hiveHash(ColumnView columns[]) {
return new ColumnVector(hiveHash(columnViews));
}

private static native int getMaxNestedDepth();

private static native long murmurHash32(int seed, long[] viewHandles) throws CudfException;

private static native long xxhash64(long seed, long[] viewHandles) throws CudfException;
Expand Down
Loading