Skip to content

Commit

Permalink
Merge branch 'branch-24.10' into doc/pylibcudf-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt711 authored Sep 23, 2024
2 parents 6941df6 + 6255906 commit 17aadd6
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
arch: "amd64"
branch: ${{ inputs.branch }}
build_type: ${{ inputs.build_type || 'branch' }}
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
date: ${{ inputs.date }}
node_type: "gpu-v100-latest-1"
run_script: "ci/build_docs.sh"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
build_type: pull-request
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/test_java.sh"
static-configure:
needs: checks
Expand All @@ -181,7 +181,7 @@ jobs:
build_type: pull-request
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/test_notebooks.sh"
docs-build:
needs: conda-python-build
Expand All @@ -191,7 +191,7 @@ jobs:
build_type: pull-request
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/build_docs.sh"
wheel-build-libcudf:
needs: checks
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
sha: ${{ inputs.sha }}
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/test_cpp_memcheck.sh"
static-configure:
secrets: inherit
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
sha: ${{ inputs.sha }}
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/test_java.sh"
conda-notebook-tests:
secrets: inherit
Expand All @@ -93,7 +93,7 @@ jobs:
sha: ${{ inputs.sha }}
node_type: "gpu-v100-latest-1"
arch: "amd64"
container_image: "rapidsai/ci-conda:latest"
container_image: "rapidsai/ci-conda:cuda12.5.1-ubuntu22.04-py3.11"
run_script: "ci/test_notebooks.sh"
wheel-tests-cudf:
secrets: inherit
Expand Down
43 changes: 43 additions & 0 deletions cpp/include/cudf/datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
#pragma once

#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/export.hpp>
#include <cudf/utilities/memory_resource.hpp>

#include <rmm/cuda_stream_view.hpp>

#include <memory>

/**
Expand All @@ -40,97 +43,111 @@ namespace datetime {
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t years
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_year(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts month from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t months
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_month(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts day from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t days
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_day(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts a weekday from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t days
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_weekday(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts hour from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t hours
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_hour(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts minute from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t minutes
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_minute(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Extracts second from any datetime type and returns an int16_t
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t seconds
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_second(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -141,13 +158,15 @@ std::unique_ptr<cudf::column> extract_second(
* For example, the millisecond fraction of 1.234567890 seconds is 234.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t milliseconds
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_millisecond_fraction(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -158,13 +177,15 @@ std::unique_ptr<cudf::column> extract_millisecond_fraction(
* For example, the microsecond fraction of 1.234567890 seconds is 567.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t microseconds
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_microsecond_fraction(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -175,13 +196,15 @@ std::unique_ptr<cudf::column> extract_microsecond_fraction(
* For example, the nanosecond fraction of 1.234567890 seconds is 890.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of the extracted int16_t nanoseconds
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> extract_nanosecond_fraction(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/** @} */ // end of group
Expand All @@ -196,27 +219,31 @@ std::unique_ptr<cudf::column> extract_nanosecond_fraction(
* cudf::column.
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column containing last day of the month as TIMESTAMP_DAYS
* @throw cudf::logic_error if input column datatype is not TIMESTAMP
*/
std::unique_ptr<cudf::column> last_day_of_month(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Computes the day number since the start of the year from the datetime and
* returns an int16_t cudf::column. The value is between [1, {365-366}]
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of datatype INT16 containing the day number since the start of the year
* @throw cudf::logic_error if input column datatype is not a TIMESTAMP
*/
std::unique_ptr<cudf::column> day_of_year(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -245,13 +272,15 @@ std::unique_ptr<cudf::column> day_of_year(
*
* @param timestamps cudf::column_view of timestamp type
* @param months cudf::column_view of integer type containing the number of months to add
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of timestamp type containing the computed timestamps
*/
std::unique_ptr<cudf::column> add_calendrical_months(
cudf::column_view const& timestamps,
cudf::column_view const& months,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand Down Expand Up @@ -280,13 +309,15 @@ std::unique_ptr<cudf::column> add_calendrical_months(
*
* @param timestamps cudf::column_view of timestamp type
* @param months cudf::scalar of integer type containing the number of months to add
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @return cudf::column of timestamp type containing the computed timestamps
*/
std::unique_ptr<cudf::column> add_calendrical_months(
cudf::column_view const& timestamps,
cudf::scalar const& months,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -297,13 +328,15 @@ std::unique_ptr<cudf::column> add_calendrical_months(
* `output[i] is null` if `column[i]` is null
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @returns cudf::column of datatype BOOL8 truth value of the corresponding date
* @throw cudf::logic_error if input column datatype is not a TIMESTAMP
*/
std::unique_ptr<cudf::column> is_leap_year(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -315,11 +348,13 @@ std::unique_ptr<cudf::column> is_leap_year(
* @throw cudf::logic_error if input column datatype is not a TIMESTAMP
*
* @param column cudf::column_view of the input datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
* @return cudf::column of datatype INT16 of days in month of the corresponding date
*/
std::unique_ptr<cudf::column> days_in_month(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -331,11 +366,13 @@ std::unique_ptr<cudf::column> days_in_month(
* @throw cudf::logic_error if input column datatype is not a TIMESTAMP
*
* @param column The input column containing datetime values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
* @return A column of INT16 type indicating which quarter the date is in
*/
std::unique_ptr<cudf::column> extract_quarter(
cudf::column_view const& column,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
Expand All @@ -357,6 +394,7 @@ enum class rounding_frequency : int32_t {
*
* @param column cudf::column_view of the input datetime values
* @param freq rounding_frequency indicating the frequency to round up to
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @throw cudf::logic_error if input column datatype is not TIMESTAMP.
Expand All @@ -365,13 +403,15 @@ enum class rounding_frequency : int32_t {
std::unique_ptr<cudf::column> ceil_datetimes(
cudf::column_view const& column,
rounding_frequency freq,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Round datetimes down to the nearest multiple of the given frequency.
*
* @param column cudf::column_view of the input datetime values
* @param freq rounding_frequency indicating the frequency to round down to
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @throw cudf::logic_error if input column datatype is not TIMESTAMP.
Expand All @@ -380,13 +420,15 @@ std::unique_ptr<cudf::column> ceil_datetimes(
std::unique_ptr<cudf::column> floor_datetimes(
cudf::column_view const& column,
rounding_frequency freq,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Round datetimes to the nearest multiple of the given frequency.
*
* @param column cudf::column_view of the input datetime values
* @param freq rounding_frequency indicating the frequency to round to
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the returned column
*
* @throw cudf::logic_error if input column datatype is not TIMESTAMP.
Expand All @@ -395,6 +437,7 @@ std::unique_ptr<cudf::column> floor_datetimes(
std::unique_ptr<cudf::column> round_datetimes(
cudf::column_view const& column,
rounding_frequency freq,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/** @} */ // end of group
Expand Down
Loading

0 comments on commit 17aadd6

Please sign in to comment.