13

You know your codebase is fucked beyond restoration when a one-dimensional array is indexed using two indices and this formula.

FUCK.

Comments
  • 11
    ...which includes division and floating point numbers too. What the fuck man.
  • 5
    sudo shred -zfu -n 32 that/travesty
  • 5
    Also: yes. Tags are important, and another place for content! They aren't in guaranteed order, though. 🙁
  • 4
    Well, calculated indices do make sense to me.. Except I'd use a descriptive method to calculate them rather than inlining all the logic
  • 1
    @endor
    And the only explanation is one comment that gives the formula and states
    "; using the sum of an arithmetic series."

    smh....
  • 6
    Judging by GPU and OpenCL tags, it's a formula to avoid GPU bank conflicts. Look it up, and for the love of whoever wrote that, don't touch it util you really understand what every single constant in that formula means, because someone spent a couple hours to make sure all threads can rad their ids within the same clock.
  • 2
    @hitko Yeah, was about to wade in to say a similar thing. I suspect whoever wrote that took more than a couple of hours to properly verify all those constants as well.
  • 2
    @hitko @AlmondSauce
    Don't get me wrong. I know how it works and what it does, I was in the room when the data structure was agreed upon and did some of the maths to find the constants.

    I'm mad because there is no fancy reason as to why the index is so unintuitive, we do it because the data on the CPU is structured in an object-oriented way and it is faster to build the array(s) in this way than one that makes the indices nicer.

    It would be beneficial to readability and performance(reducing cache misses greatly) if we would structure the data on the CPU differently, but NO we rather do this as a quick fix.
Add Comment