Skip to content

Commit e6042fb

Browse files
pxLimythrocks
andauthored
[auto-merge] bot-auto-merge-release/26.04 to main [skip ci] [bot] (#4411)
auto-merge triggered by github actions on `bot-auto-merge-release/26.04` to create a PR keeping `main` up-to-date. If this PR is unable to be merged due to conflicts, it will remain open until manually fix. --------- Signed-off-by: MithunR <mithunr@nvidia.com> Signed-off-by: spark-rapids automation <70000568+nvauto@users.noreply.github.com> Co-authored-by: MithunR <mithunr@nvidia.com>
2 parents 66cda62 + b2d5ab5 commit e6042fb

File tree

7 files changed

+772
-316
lines changed

7 files changed

+772
-316
lines changed

src/main/cpp/benchmarks/bloom_filter.cu

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2026, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,17 +22,18 @@
2222
#include <hash/hash.hpp>
2323
#include <nvbench/nvbench.cuh>
2424

25-
static void bloom_filter_put(nvbench::state& state)
25+
namespace {
26+
27+
void bloom_filter_put_impl(nvbench::state& state, int version)
2628
{
2729
constexpr int num_rows = 150'000'000;
2830
constexpr int num_hashes = 3;
2931

30-
// create the bloom filter
3132
cudf::size_type const bloom_filter_bytes = state.get_int64("bloom_filter_bytes");
3233
cudf::size_type const bloom_filter_longs = bloom_filter_bytes / sizeof(int64_t);
33-
auto bloom_filter = spark_rapids_jni::bloom_filter_create(num_hashes, bloom_filter_longs);
34+
auto bloom_filter =
35+
spark_rapids_jni::bloom_filter_create(version, num_hashes, bloom_filter_longs);
3436

35-
// create a column of hashed values
3637
data_profile_builder builder;
3738
builder.no_validity();
3839
auto const src = create_random_table({{cudf::type_id::INT64}}, row_count{num_rows}, builder);
@@ -41,7 +42,7 @@ static void bloom_filter_put(nvbench::state& state)
4142
auto const stream = cudf::get_default_stream();
4243
state.set_cuda_stream(nvbench::make_cuda_stream_view(stream.value()));
4344
state.exec(nvbench::exec_tag::timer | nvbench::exec_tag::sync,
44-
[&](nvbench::launch& launch, auto& timer) {
45+
[&](nvbench::launch&, auto& timer) {
4546
timer.start();
4647
spark_rapids_jni::bloom_filter_put(*bloom_filter, *input);
4748
stream.synchronize();
@@ -57,7 +58,24 @@ static void bloom_filter_put(nvbench::state& state)
5758
state.add_element_count(static_cast<double>(bytes_written) / time, "Write bytes/sec");
5859
}
5960

60-
NVBENCH_BENCH(bloom_filter_put)
61-
.set_name("Bloom Filter Put")
61+
void bloom_filter_put_v1(nvbench::state& state)
62+
{
63+
bloom_filter_put_impl(state, spark_rapids_jni::bloom_filter_version_1);
64+
}
65+
66+
void bloom_filter_put_v2(nvbench::state& state)
67+
{
68+
bloom_filter_put_impl(state, spark_rapids_jni::bloom_filter_version_2);
69+
}
70+
71+
} // namespace
72+
73+
NVBENCH_BENCH(bloom_filter_put_v1)
74+
.set_name("Bloom Filter Put V1")
75+
.add_int64_axis("bloom_filter_bytes",
76+
{512 * 1024, 1024 * 1024, 2 * 1024 * 1024, 4 * 1024 * 1024, 8 * 1024 * 1024});
77+
78+
NVBENCH_BENCH(bloom_filter_put_v2)
79+
.set_name("Bloom Filter Put V2")
6280
.add_int64_axis("bloom_filter_bytes",
6381
{512 * 1024, 1024 * 1024, 2 * 1024 * 1024, 4 * 1024 * 1024, 8 * 1024 * 1024});

src/main/cpp/src/BloomFilterJni.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023-2025, NVIDIA CORPORATION.
2+
* Copyright (c) 2023-2026, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,17 +20,33 @@
2020
#include "jni_utils.hpp"
2121
#include "utilities.hpp"
2222

23+
#include <limits>
24+
2325
extern "C" {
2426

2527
JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_BloomFilter_creategpu(
26-
JNIEnv* env, jclass, jint numHashes, jlong bloomFilterBits)
28+
JNIEnv* env, jclass, jint version, jint numHashes, jlong bloomFilterBits, jint seed)
2729
{
2830
JNI_TRY
2931
{
3032
cudf::jni::auto_set_device(env);
3133

32-
int bloom_filter_longs = static_cast<int>((bloomFilterBits + 63) / 64);
33-
auto bloom_filter = spark_rapids_jni::bloom_filter_create(numHashes, bloom_filter_longs);
34+
// Per the Spark implementation, according to the BitArray class,
35+
// https://github.com/apache/spark/blob/5075ea6a85f3f1689766cf08a7d5b2ce500be1fb/common/sketch/src/main/java/org/apache/spark/util/sketch/BitArray.java#L34
36+
// the number of longs representing the bit array can only be Integer.MAX_VALUE, at the most.
37+
// (This is presumably because the BitArray is indexed with an int32_t.)
38+
// This implies that the maximum supported bloom filter bit count is Integer.MAX_VALUE * 64.
39+
40+
JNI_ARG_CHECK(
41+
env,
42+
bloomFilterBits > 0 &&
43+
bloomFilterBits <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()) * 64,
44+
"bloom filter bit count must be positive and less than or equal to the maximum supported "
45+
"size",
46+
0);
47+
auto const bloom_filter_longs = static_cast<int32_t>((bloomFilterBits + 63) / 64);
48+
auto bloom_filter =
49+
spark_rapids_jni::bloom_filter_create(version, numHashes, bloom_filter_longs, seed);
3450
return reinterpret_cast<jlong>(bloom_filter.release());
3551
}
3652
JNI_CATCH(env, 0);

0 commit comments

Comments
 (0)