Skip to content

Commit

Permalink
Move row conversion code from cudf (#1838)
Browse files Browse the repository at this point in the history
* Revert "Use cuda::proclaim_return_type on device lambdas (#1662)"

This reverts commit 763406c.

# Conflicts:
#	src/main/cpp/benchmarks/row_conversion.cpp
#	src/main/cpp/src/bloom_filter.cu
#	src/main/cpp/src/map_utils.cu
#	src/main/cpp/src/xxhash64.cu
#	thirdparty/cudf

Signed-off-by: Nghia Truong <[email protected]>

* Remove redundant header

Signed-off-by: Nghia Truong <[email protected]>

* Update copyright year

Signed-off-by: Nghia Truong <[email protected]>

---------

Signed-off-by: Nghia Truong <[email protected]>
  • Loading branch information
ttnghia authored Mar 6, 2024
1 parent 99445a7 commit 5a09147
Show file tree
Hide file tree
Showing 7 changed files with 3,618 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ add_library(
src/map_utils.cu
src/murmur_hash.cu
src/parse_uri.cu
src/row_conversion.cu
src/timezones.cu
src/utilities.cu
src/xxhash64.cu
Expand Down
14 changes: 7 additions & 7 deletions src/main/cpp/benchmarks/row_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ void fixed_width(nvbench::state& state)
bytes_per_row += cudf::size_of(t);
}

auto rows = cudf::convert_to_rows_fixed_width_optimized(table->view());
auto rows = spark_rapids_jni::convert_to_rows_fixed_width_optimized(table->view());

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
if (direction == "to row") {
auto _rows = cudf::convert_to_rows_fixed_width_optimized(table->view());
auto _rows = spark_rapids_jni::convert_to_rows_fixed_width_optimized(table->view());
} else {
for (auto const& r : rows) {
cudf::lists_column_view const l(r->view());
auto out = cudf::convert_from_rows_fixed_width_optimized(l, schema);
auto out = spark_rapids_jni::convert_from_rows_fixed_width_optimized(l, schema);
}
}
});
Expand Down Expand Up @@ -117,16 +117,16 @@ static void variable_or_fixed_width(nvbench::state& state)
}
}

auto rows = cudf::convert_to_rows(table->view());
auto rows = spark_rapids_jni::convert_to_rows(table->view());

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
auto new_rows = cudf::convert_to_rows(table->view());
auto new_rows = spark_rapids_jni::convert_to_rows(table->view());
if (direction == "to row") {
auto _rows = cudf::convert_to_rows(table->view());
auto _rows = spark_rapids_jni::convert_to_rows(table->view());
} else {
for (auto const& r : rows) {
cudf::lists_column_view const l(r->view());
auto out = cudf::convert_from_rows(l, schema);
auto out = spark_rapids_jni::convert_from_rows(l, schema);
}
}
});
Expand Down
17 changes: 9 additions & 8 deletions src/main/cpp/src/RowConversionJni.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
* Copyright (c) 2022-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,7 @@

#include "cudf_jni_apis.hpp"
#include "dtype_utils.hpp"

#include <cudf/row_conversion.hpp>
#include "row_conversion.hpp"

extern "C" {

Expand All @@ -32,7 +31,7 @@ Java_com_nvidia_spark_rapids_jni_RowConversion_convertToRowsFixedWidthOptimized(
cudf::jni::auto_set_device(env);
cudf::table_view const* n_input_table = reinterpret_cast<cudf::table_view const*>(input_table);
std::vector<std::unique_ptr<cudf::column>> cols =
cudf::convert_to_rows_fixed_width_optimized(*n_input_table);
spark_rapids_jni::convert_to_rows_fixed_width_optimized(*n_input_table);
int const num_columns = cols.size();
cudf::jni::native_jlongArray outcol_handles(env, num_columns);
std::transform(cols.begin(), cols.end(), outcol_handles.begin(), [](auto& col) {
Expand All @@ -51,8 +50,9 @@ Java_com_nvidia_spark_rapids_jni_RowConversion_convertToRows(JNIEnv* env, jclass
try {
cudf::jni::auto_set_device(env);
cudf::table_view const* n_input_table = reinterpret_cast<cudf::table_view const*>(input_table);
std::vector<std::unique_ptr<cudf::column>> cols = cudf::convert_to_rows(*n_input_table);
int const num_columns = cols.size();
std::vector<std::unique_ptr<cudf::column>> cols =
spark_rapids_jni::convert_to_rows(*n_input_table);
int const num_columns = cols.size();
cudf::jni::native_jlongArray outcol_handles(env, num_columns);
std::transform(cols.begin(), cols.end(), outcol_handles.begin(), [](auto& col) {
return cudf::jni::release_as_jlong(col);
Expand Down Expand Up @@ -84,7 +84,7 @@ Java_com_nvidia_spark_rapids_jni_RowConversion_convertFromRowsFixedWidthOptimize
std::back_inserter(types_vec),
[](jint type, jint scale) { return cudf::jni::make_data_type(type, scale); });
std::unique_ptr<cudf::table> result =
cudf::convert_from_rows_fixed_width_optimized(list_input, types_vec);
spark_rapids_jni::convert_from_rows_fixed_width_optimized(list_input, types_vec);
return cudf::jni::convert_table_for_return(env, result);
}
CATCH_STD(env, 0);
Expand All @@ -110,7 +110,8 @@ JNIEXPORT jlongArray JNICALL Java_com_nvidia_spark_rapids_jni_RowConversion_conv
n_scale.begin(),
std::back_inserter(types_vec),
[](jint type, jint scale) { return cudf::jni::make_data_type(type, scale); });
std::unique_ptr<cudf::table> result = cudf::convert_from_rows(list_input, types_vec);
std::unique_ptr<cudf::table> result =
spark_rapids_jni::convert_from_rows(list_input, types_vec);
return cudf::jni::convert_table_for_return(env, result);
}
CATCH_STD(env, 0);
Expand Down
Loading

0 comments on commit 5a09147

Please sign in to comment.