Skip to content

Do not pretend to default initialize a device lambda #5015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: branch-25.06
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cpp/src/prims/count_if_v.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,9 +35,9 @@ namespace detail {

template <typename vertex_t, typename VertexValueInputIterator, typename VertexOp>
struct count_if_call_v_op_t {
vertex_t local_vertex_partition_range_first{};
VertexValueInputIterator vertex_value_input_first{};
VertexOp v_op{};
vertex_t local_vertex_partition_range_first;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can default initializing vertex_t (which is either int32_t or int64_t) or can this be also problematic?

VertexValueInputIterator vertex_value_input_first;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we default initialize iterators as well? Or is this because of possible thrust::transform_iterator with lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning with removing all default initializers is that partially initializing the struct does not make any sense and it is only ever initialized in a single place, so it feels "cleaner" to initialize all or nothing

Nothing I feel strongly about though

VertexOp v_op;

__device__ bool operator()(vertex_t i)
{
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/prims/transform_reduce_v.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,9 +36,9 @@ namespace detail {

template <typename vertex_t, typename VertexValueInputIterator, typename VertexOp, typename T>
struct transform_reduce_call_v_op_t {
vertex_t local_vertex_partition_range_first{};
VertexValueInputIterator vertex_value_input_first{};
VertexOp v_op{};
vertex_t local_vertex_partition_range_first;
VertexValueInputIterator vertex_value_input_first;
VertexOp v_op;

__device__ T operator()(vertex_t i)
{
Expand Down
16 changes: 8 additions & 8 deletions cpp/src/prims/update_v_frontier.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ template <typename vertex_t,
typename key_t,
typename payload_t>
struct update_v_frontier_call_v_op_t {
VertexValueInputIterator vertex_value_input_first{};
VertexValueOutputIterator vertex_value_output_first{};
VertexOp v_op{};
vertex_t local_vertex_partition_range_first{};
VertexValueInputIterator vertex_value_input_first;
VertexValueOutputIterator vertex_value_output_first;
VertexOp v_op;
vertex_t local_vertex_partition_range_first;

__device__ uint8_t operator()(thrust::tuple<key_t, payload_t> pair) const
{
Expand Down Expand Up @@ -87,10 +87,10 @@ struct update_v_frontier_call_v_op_t<vertex_t,
VertexOp,
key_t,
void> {
VertexValueInputIterator vertex_value_input_first{};
VertexValueOutputIterator vertex_value_output_first{};
VertexOp v_op{};
vertex_t local_vertex_partition_range_first{};
VertexValueInputIterator vertex_value_input_first;
VertexValueOutputIterator vertex_value_output_first;
VertexOp v_op;
vertex_t local_vertex_partition_range_first;

__device__ uint8_t operator()(key_t key) const
{
Expand Down