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

The interface for host-based UDF implementation for reduction contexts. More...

#include <host_udf.hpp>

Inheritance diagram for cudf::reduce_host_udf:
cudf::host_udf_base

Public Member Functions

virtual std::unique_ptr< scalaroperator() (column_view const &input, data_type output_dtype, std::optional< std::reference_wrapper< scalar const >> init, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
 Perform 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 reduction contexts.

An implementation of host-based UDF for 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 classes must also define the operator() function to perform reduction operations.

Example:

struct my_udf_aggregation : cudf::reduce_host_udf {
my_udf_aggregation() = default;
[[nodiscard]] std::unique_ptr<scalar> operator()(
column_view const& input,
data_type output_dtype,
std::optional<std::reference_wrapper<scalar const>> init,
rmm::device_async_resource_ref mr) const override
{
// Perform reduction computation using the input data and return the reduction result.
// This is where the actual 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
The interface for host-based UDF implementation for reduction contexts.
Definition: host_udf.hpp:131
virtual std::unique_ptr< scalar > operator()(column_view const &input, data_type output_dtype, std::optional< std::reference_wrapper< scalar const >> init, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const =0
Perform reduction operations.

Definition at line 131 of file host_udf.hpp.

Member Function Documentation

◆ operator()()

virtual std::unique_ptr<scalar> cudf::reduce_host_udf::operator() ( column_view const &  input,
data_type  output_dtype,
std::optional< std::reference_wrapper< scalar const >>  init,
rmm::cuda_stream_view  stream,
rmm::device_async_resource_ref  mr 
) const
pure virtual

Perform reduction operations.

Parameters
inputThe input column for reduction
output_dtypeThe data type for the final output scalar
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: