Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

reduce_by_key (CUDA) should not assume its output iterator is default constructible #1812

@harrism

Description

@harrism

As discussed in #1804, thrust::reduce_by_key's CUDA implementation assumes that the output iterator it is passed can be default constructed.

pair<KeysOutputIt, ValuesOutputIt> result{};

This is made necessary by the implementation of the dispatch macro:

#define THRUST_INDEX_TYPE_DISPATCH(status, call, count, arguments) \
if (count <= thrust::detail::integer_traits<thrust::detail::int32_t>::const_max) { \
auto THRUST_PP_CAT2(count, _fixed) = static_cast<thrust::detail::int32_t>(count); \
status = call arguments; \
} \
else { \
auto THRUST_PP_CAT2(count, _fixed) = static_cast<thrust::detail::int64_t>(count); \
status = call arguments; \
}

The dispatch mechanism should be modified so that it's return value can be used to initialize a local so that a temporary does not need to be default constructed in order to use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions