fix memory corruption
@@ -32,15 +32,16 @@ extern "C" __global__ void ${name}(${params}) {
unsigned int _tid = threadIdx.x;
int _J_offset = _tid >> __popc(_block_stride - 1); // _tid / _block_stride
- int _j_offset = _J_offset * _out_ind.size();
+ long long _j_offset = (long long)_J_offset * _out_ind.size();
int _J_stride = ${block_size} >> __popc(_block_stride - 1);
long long _j_stride = (long long)_J_stride * _out_ind.size();
- for (int _i_base = blockIdx.x * _block_stride;
+ for (long long _i_base = (long long)blockIdx.x * _block_stride;
_i_base < _out_ind.size();
- _i_base += gridDim.x * _block_stride) {
+ _i_base += (long long)gridDim.x * _block_stride) {
_type_reduce _s = _type_reduce(${identity});
- int _i = _i_base + (_tid & (_block_stride - 1)); // _tid % _block_stride
+ long long _i =
+ _i_base + (_tid & (_block_stride - 1)); // _tid % _block_stride
int _J = _J_offset;
for (long long _j = _i + _j_offset; _j < _in_ind.size();
_j += _j_stride, _J += _J_stride) {
