                     block_aggregate,                // Block-wide total (unused)
                     prefix_op);                     // Prefix operator for seeding the block-wide scan with the running total
 
+/*
+                CubLog("\t\t Scanned tuples %s<%d,%.1f>, %s<%d,%.1f>\n",
+                    tail_flags[0] ? "*" : "", partial_reductions[0].key, partial_reductions[0].value,
+                    tail_flags[1] ? "*" : "", partial_reductions[1].key, partial_reductions[1].value);
+*/
                 // The first segment index for this region (hoist?)
                 Offset first_segment_idx = temp_storage.block_segment_idx[0];
 

                    tail_flags[ITEM]                = 0;

                    // Whether or not we slide (a) right along the segment path or (b) down the value path
                    bool prefer_segment = (segment_end_offset <= value_offset);

                    if (valid_segment && prefer_segment)
                    {
                        // Consume this segment index


        #pragma unroll
        for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++)
        {
            segment_ids[ITEM] = partial_reductions[ITEM].key;
        }

        // Flag segment heads by looking for discontinuities
        BlockDiscontinuity(temp_storage.discontinuity).FlagHeads(
            head_flags,                         // [out] Head flags
            segment_ids,                        // Segment ids
            NewSegmentOp(),                     // Functor for detecting start of new rows
            prefix_op.running_total.key);       // Last segment ID from previous tile to compare with first segment ID in this tile

        // Reduce-value-by-segment across partial_reductions using exclusive prefix scan
        KeyValuePair block_aggregate;
        BlockScan(temp_storage.scan).ExclusiveScan(
            partial_reductions,                   // Scan input
            partial_reductions,                   // Scan output
            scan_op,                        // Scan operator
            block_aggregate,                // Block-wide total (unused)
            prefix_op);                     // Prefix operator for seeding the block-wide scan with the running total
/*
        CubLog("Scanned tuples %s<%d,%.1f>, %s<%d,%.1f>\n",
            head_flags[0] ? "*" : "", partial_reductions[0].key, partial_reductions[0].value,
            head_flags[1] ? "*" : "", partial_reductions[1].key, partial_reductions[1].value);
*/
        // Scatter an accumulated reduction if it is the head of a valid segment
        #pragma unroll
        for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++)
        {
            if (head_flags[ITEM])
            {
                d_output[partial_reductions[ITEM].key] = partial_reductions[ITEM].value;
            }
        }
    }
