         printf(", %.3f avg ms, %.3f billion items/s, %.3f logical GB/s", avg_millis, grate, gbandwidth);
     }
 
-
-    // Cleanup
-    if (h_values)           delete[] h_values;
-    if (h_segment_offsets)  delete[] h_segment_offsets;
-    if (h_reference)        delete[] h_reference;
-
+    // Device cleanup
     if (d_values) CubDebugExit(g_allocator.DeviceFree(d_values));
     if (d_segment_offsets) CubDebugExit(g_allocator.DeviceFree(d_segment_offsets));
     if (d_output) CubDebugExit(g_allocator.DeviceFree(d_output));
     if (d_temp_storage) CubDebugExit(g_allocator.DeviceFree(d_temp_storage));
+
+    // Host cleanup
+    if (h_values)           delete[] h_values;
+    if (h_segment_offsets)  delete[] h_segment_offsets;
+    if (h_reference)        delete[] h_reference;
 }
 
 

                    }
                }
            }

            // Advance to the next region in the decision path
            block_diagonal += TILE_ITEMS;

                    tail_flags[ITEM]                = 0;

                    // Whether or not we slide (a) right along the segment path or (b) down the value path
                    if (valid_segment && (!valid_value || (segment_end_offset <= value_offset)))
                    {
                        // Consume this segment index

