Skip to content

Commit a1583a7

Browse files
committed
Add int4 += custom implementation for CUDA completeness
1 parent 8748e93 commit a1583a7

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

GPU/GPUbenchmark/Shared/Utils.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ class BSDRnd : public LCGRnd
192192
__host__ __device__ int rnd() { return LCGRnd::rnd(); }
193193
};
194194

195+
196+
// CUDA does not support <type4> operations:
197+
// https://forums.developer.nvidia.com/t/swizzling-float4-arithmetic-support/217
198+
#ifndef __HIPCC__
199+
inline __host__ __device__ void operator+=(int4 &a, int4 b)
200+
{
201+
a.x += b.x;
202+
a.y += b.y;
203+
a.z += b.z;
204+
a.w += b.w;
205+
}
206+
#endif
207+
195208
namespace o2
196209
{
197210
namespace benchmark

GPU/GPUbenchmark/cuda/Kernels.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ __global__ void read_k(
4949
{
5050
chunk_t sink{0};
5151
for (size_t i = blockIdx.x * blockDim.x + threadIdx.x; i < chunkSize; i += blockDim.x * gridDim.x) {
52-
sink = chunkPtr[i] + sink;
52+
sink += chunkPtr[i];
5353
}
5454
chunkPtr[threadIdx.x] = sink;
5555
}

0 commit comments

Comments
 (0)