You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
inclusive_scan_by_keys calls the 'sum' operator needlessly #801
inclusive_scan_by_keys is called with a one-element keys vector. It should just copy the first input element to the output vector but in addition it invokes the 'sum' operator 4096 times!
Reproduction code (bug.cu)
#include <thrust/device_vector.h>
#include <thrust/scan.h>
#include <stdio.h>
class Agg {
public:
__device__ int operator()(int x, int y) {
printf("%d %d\n", x, y);
return x + y;
}
};
int main(int argc, char** argv) {
auto partitions = thrust::device_vector<int>(1, 0);
auto in = thrust::device_vector<int>(1, 0);
auto out = thrust::device_vector<int>(1, 0);
thrust::inclusive_scan_by_key(
partitions.begin(),
partitions.end(),
in.begin(),
out.begin(),
thrust::equal_to<int>(),
Agg()
);
return 0;
}
@allisonvacanti same issue on thrust::inclusive_scan, even reduce_by_key. I think it's because cub::BlockScan doesn't support passing valid_items like cub::BlockLoad and cub::BlockStore, so for those out-of-bound items (could be uninitialized value) will still be combined in ScanOp.
That sounds about right, thanks for the report and initial investigation! I can't give an ETA at the moment, but this is something we should fix in CUB.
Activity
elikl commentedon Mar 23, 2022
Note: In our real world application this behavior causes illegal cuda memory access.
lilohuang commentedon Mar 25, 2022
@allisonvacanti same issue on thrust::inclusive_scan, even reduce_by_key. I think it's because cub::BlockScan doesn't support passing valid_items like cub::BlockLoad and cub::BlockStore, so for those out-of-bound items (could be uninitialized value) will still be combined in ScanOp.
cc @senior-zero
alliepiper commentedon Mar 25, 2022
That sounds about right, thanks for the report and initial investigation! I can't give an ETA at the moment, but this is something we should fix in CUB.
elikl commentedon Mar 31, 2022
@allisonvacanti looks related to #789 and #780
jrhemstad commentedon Mar 31, 2022
Yeah, I thought this sounded familiar. I think this is a duplicate of those issues.
elikl commentedon Mar 31, 2022
@jrhemstad Note that both #789 and #780 got 'unverified' tags and here we have a clear reproduction.
alliepiper commentedon Apr 4, 2022
They're not quite duplicates since they are in different algorithms, so let's leave the others open to track what needs fixing.