diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 63e4ac889c7..885a22870bb 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -69,6 +69,7 @@ test: - test -f $PREFIX/include/cudf/detail/binaryop.hpp - test -f $PREFIX/include/cudf/detail/concatenate.hpp - test -f $PREFIX/include/cudf/detail/copy.hpp + - test -f $PREFIX/include/cudf/detail/datetime.hpp - test -f $PREFIX/include/cudf/detail/fill.hpp - test -f $PREFIX/include/cudf/detail/gather.hpp - test -f $PREFIX/include/cudf/detail/groupby.hpp diff --git a/cpp/include/cudf/detail/datetime.hpp b/cpp/include/cudf/detail/datetime.hpp new file mode 100644 index 00000000000..017fe0d96ff --- /dev/null +++ b/cpp/include/cudf/detail/datetime.hpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2021, 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. + */ + +#pragma once + +#include + +#include + +namespace cudf { +namespace datetime { +namespace detail { +/** + * @copydoc cudf::extract_year(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_year( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_month(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_month( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_day(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_day( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_weekday(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_weekday( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_hour(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_hour( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_minute(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_minute( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::extract_second(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr extract_second( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::last_day_of_month(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr last_day_of_month( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::day_of_year(cudf::column_view const&, rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr day_of_year( + cudf::column_view const& column, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @copydoc cudf::add_calendrical_months(cudf::column_view const&, cudf::column_view const&, + * rmm::mr::device_memory_resource *) + * + * @param stream CUDA stream used for device memory operations and kernel launches. + */ +std::unique_ptr add_calendrical_months( + cudf::column_view const& timestamps, + cudf::column_view const& months, + rmm::cuda_stream_view stream = rmm::cuda_stream_default, + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +} // namespace detail +} // namespace datetime +} // namespace cudf diff --git a/cpp/src/datetime/datetime_ops.cu b/cpp/src/datetime/datetime_ops.cu index cf889810b0f..36c3605951e 100644 --- a/cpp/src/datetime/datetime_ops.cu +++ b/cpp/src/datetime/datetime_ops.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-2021, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -278,82 +278,144 @@ std::unique_ptr add_calendrical_months(column_view const& timestamp_colu return output; } -} // namespace detail -std::unique_ptr extract_year(column_view const& column, rmm::mr::device_memory_resource* mr) +std::unique_ptr extract_year(column_view const& column, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } std::unique_ptr extract_month(column_view const& column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); - return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } -std::unique_ptr extract_day(column_view const& column, rmm::mr::device_memory_resource* mr) +std::unique_ptr extract_day(column_view const& column, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } std::unique_ptr extract_weekday(column_view const& column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } -std::unique_ptr extract_hour(column_view const& column, rmm::mr::device_memory_resource* mr) +std::unique_ptr extract_hour(column_view const& column, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } std::unique_ptr extract_minute(column_view const& column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } std::unique_ptr extract_second(column_view const& column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op< detail::extract_component_operator, - cudf::type_id::INT16>(column, 0, mr); + cudf::type_id::INT16>(column, stream, mr); } std::unique_ptr last_day_of_month(column_view const& column, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { - CUDF_FUNC_RANGE(); return detail::apply_datetime_op(column, 0, mr); + cudf::type_id::TIMESTAMP_DAYS>(column, stream, mr); +} + +std::unique_ptr day_of_year(column_view const& column, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) +{ + return detail::apply_datetime_op( + column, stream, mr); +} +} // namespace detail + +std::unique_ptr extract_year(column_view const& column, rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_year(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_month(column_view const& column, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_month(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_day(column_view const& column, rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_day(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_weekday(column_view const& column, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_weekday(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_hour(column_view const& column, rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_hour(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_minute(column_view const& column, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_minute(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr extract_second(column_view const& column, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::extract_second(column, rmm::cuda_stream_default, mr); +} + +std::unique_ptr last_day_of_month(column_view const& column, + rmm::mr::device_memory_resource* mr) +{ + CUDF_FUNC_RANGE(); + return detail::last_day_of_month(column, rmm::cuda_stream_default, mr); } std::unique_ptr day_of_year(column_view const& column, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::apply_datetime_op( - column, 0, mr); + return detail::day_of_year(column, rmm::cuda_stream_default, mr); } std::unique_ptr add_calendrical_months(cudf::column_view const& timestamp_column, @@ -361,7 +423,8 @@ std::unique_ptr add_calendrical_months(cudf::column_view const& ti rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::add_calendrical_months(timestamp_column, months_column, 0, mr); + return detail::add_calendrical_months( + timestamp_column, months_column, rmm::cuda_stream_default, mr); } } // namespace datetime } // namespace cudf