All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
cudf::segmented_reduce_host_udf Struct Referenceabstract

The interface for host-based UDF implementation for segmented reduction context. More...

#include <host_udf.hpp>

Inheritance diagram for cudf::segmented_reduce_host_udf:
cudf::host_udf_base

Public Member Functions

virtual std::unique_ptr< columnoperator() (column_view const &input, device_span< size_type const > offsets, data_type output_dtype, null_policy null_handling, std::optional< std::reference_wrapper< scalar const >> init, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
 Perform segmented reduction operations. More...
 
- Public Member Functions inherited from cudf::host_udf_base
virtual ~host_udf_base ()=default
 Default destructor.
 
virtual std::size_t do_hash () const
 Computes hash value of the instance. More...
 
virtual bool is_equal (host_udf_base const &other) const =0
 Compares two instances of the derived class for equality. More...
 
virtual std::unique_ptr< host_udf_baseclone () const =0
 Clones the instance. More...
 

Detailed Description

The interface for host-based UDF implementation for segmented reduction context.

An implementation of host-based UDF for segmented reduction needs to be derived from this class. In addition to implementing the virtual functions declared in the base class host_udf_base, such derived class must also define the operator() function to perform segmented reduction.

Example:

struct my_udf_aggregation : cudf::segmented_reduce_host_udf {
my_udf_aggregation() = default;
[[nodiscard]] std::unique_ptr<column> operator()(
column_view const& input,
device_span<size_type const> offsets,
data_type output_dtype,
null_policy null_handling,
std::optional<std::reference_wrapper<scalar const>> init,
rmm::device_async_resource_ref mr) const override
{
// Perform computation using the input data and return the result.
// This is where the actual segmented reduction logic is implemented.
}
[[nodiscard]] bool is_equal(host_udf_base const& other) const override
{
// Check if the other object is also instance of this class.
// If there are internal state variables, they may need to be checked for equality as well.
return dynamic_cast<my_udf_aggregation const*>(&other) != nullptr;
}
[[nodiscard]] std::unique_ptr<host_udf_base> clone() const override
{
return std::make_unique<my_udf_aggregation>();
}
};
virtual bool is_equal(host_udf_base const &other) const =0
Compares two instances of the derived class for equality.
virtual std::unique_ptr< host_udf_base > clone() const =0
Clones the instance.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
null_policy
Enum to specify whether to include nulls or exclude nulls.
Definition: types.hpp:126
The interface for host-based UDF implementation for segmented reduction context.
Definition: host_udf.hpp:189
virtual std::unique_ptr< column > operator()(column_view const &input, device_span< size_type const > offsets, data_type output_dtype, null_policy null_handling, std::optional< std::reference_wrapper< scalar const >> init, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
Perform segmented reduction operations.

Definition at line 189 of file host_udf.hpp.

Member Function Documentation

◆ operator()()

virtual std::unique_ptr<column> cudf::segmented_reduce_host_udf::operator() ( column_view const &  input,
device_span< size_type const >  offsets,
data_type  output_dtype,
null_policy  null_handling,
std::optional< std::reference_wrapper< scalar const >>  init,
rmm::cuda_stream_view  stream,
rmm::device_async_resource_ref  mr 
) const
pure virtual

Perform segmented reduction operations.

Parameters
inputThe input column for reduction
offsetsA list of offsets defining the segments for reduction
output_dtypeThe data type for the final output column
null_handlingIf INCLUDE then the reduction result is valid only if all elements in the segment are valid, and if EXCLUDE then the reduction result is valid if any element in the segment is valid
initThe initial value of the reduction
streamThe CUDA stream to use for any kernel launches
mrDevice memory resource to use for any allocations
Returns
The output result of the aggregation

The documentation for this struct was generated from the following file: