diff --git a/cpp/include/cudf/transpose.hpp b/cpp/include/cudf/transpose.hpp index 8b680071e71..a32491bc7bd 100644 --- a/cpp/include/cudf/transpose.hpp +++ b/cpp/include/cudf/transpose.hpp @@ -36,14 +36,16 @@ namespace CUDF_EXPORT cudf { * @throw cudf::logic_error if column types are non-homogeneous * @throw cudf::logic_error if column types are non-fixed-width * - * @param[in] input A table (M cols x N rows) to be transposed - * @param[in] mr Device memory resource used to allocate the device memory of returned value - * @return The transposed input (N cols x M rows) as a `column` and - * `table_view`, representing the owner and transposed table, - * respectively. + * @param[in] input A table (M cols x N rows) to be transposed + * @param[in] stream CUDA stream used for device memory operations and kernel launches + * @param[in] mr Device memory resource used to allocate the device memory of returned value + * @return The transposed input (N cols x M rows) as a `column` and + * `table_view`, representing the owner and transposed table, + * respectively. */ std::pair, table_view> transpose( table_view const& input, + rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); /** @} */ // end of group diff --git a/cpp/src/transpose/transpose.cu b/cpp/src/transpose/transpose.cu index 810fd8afd73..c9872d3ef09 100644 --- a/cpp/src/transpose/transpose.cu +++ b/cpp/src/transpose/transpose.cu @@ -61,10 +61,11 @@ std::pair, table_view> transpose(table_view const& input } // namespace detail std::pair, table_view> transpose(table_view const& input, + rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) { CUDF_FUNC_RANGE(); - return detail::transpose(input, cudf::get_default_stream(), mr); + return detail::transpose(input, stream, mr); } } // namespace cudf diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index cbca0ceef77..666a7d4ba4b 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -750,6 +750,7 @@ ConfigureTest( testing ) ConfigureTest(STREAM_TRANSFORM_TEST streams/transform_test.cpp STREAM_MODE testing) +ConfigureTest(STREAM_TRANSPOSE_TEST streams/transpose_test.cpp STREAM_MODE testing) ConfigureTest(STREAM_UNARY_TEST streams/unary_test.cpp STREAM_MODE testing) # ################################################################################################## diff --git a/cpp/tests/streams/transpose_test.cpp b/cpp/tests/streams/transpose_test.cpp new file mode 100644 index 00000000000..44e785435a5 --- /dev/null +++ b/cpp/tests/streams/transpose_test.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +class TransposeTest : public cudf::test::BaseFixture {}; + +TEST_F(TransposeTest, StringTest) +{ + using ColumnWrapper = cudf::test::strings_column_wrapper; + size_t ncols = 10; + size_t nrows = 10; + + std::mt19937 rng(1); + + auto const values = [&rng, nrows, ncols]() { + std::vector> values(ncols); + std::for_each(values.begin(), values.end(), [&rng, nrows](std::vector& col) { + col.resize(nrows); + std::generate(col.begin(), col.end(), [&rng]() { return std::to_string(rng()); }); + }); + return values; + }(); + + auto input_cols = [&values]() { + std::vector columns; + columns.reserve(values.size()); + for (auto const& value_col : values) { + columns.emplace_back(value_col.begin(), value_col.end()); + } + return columns; + }(); + + auto input_view = [&input_cols]() { + std::vector views(input_cols.size()); + std::transform(input_cols.begin(), input_cols.end(), views.begin(), [](auto const& col) { + return static_cast(col); + }); + return cudf::table_view(views); + }(); + + auto result = transpose(input_view, cudf::test::get_default_stream()); +} + +CUDF_TEST_PROGRAM_MAIN()