Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Suspicious line in Reduction.hs #71

Closed
rrnewton opened this Issue · 1 comment

2 participants

@rrnewton
Collaborator

Is this correct? If so, it seems kind of non-idiomatic ;-). Can it be refactored?

for ( ix += gridSize; ix < shapeSize; ix += gridSize )

https://github.com/AccelerateHS/accelerate-cuda/blob/4bb2c51487adc1191006c1f41bd1530ec20602b5/Data/Array/Accelerate/CUDA/CodeGen/Reduction.hs#L145

@tmcdonell
Collaborator

This is correct, although I guess a bit strange...

In the line above we need to initialise the local accumulator y = arr[ix] and then inside the loop we're reading in new values into x = arr[ix] before combining into y, so clearly ix needs to be incremented first. I guess the difficulty is that in the first pass we read array elements into y (to ensure it is initialised) but subsequently read into x. It's a one character change so perhaps comments would help to draw attention to what's going on.

@tmcdonell tmcdonell closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.