Enhancing OpenRCT2 performance: a journey with Cody and SIMD
No items found.
April 25, 2024
This is a guest blog post from our community. Join our Discord to meet the author and connect with other developers passionate about Code Search and AI!
SIMD, Single Instruction Multiple Data, is a way of speeding up computationally intensive tasks by applying the same operation to multiple data items in one go. For this to be applicable, some requirements need to be met, such as data layout or access patterns.
In OpenRCT2 (free and open source remake of RollerCoaster Tycoon 2) we care a lot about performance and there’s long been a piece of code I suspected could be improved by applying the SIMD approach. I’ve been putting it off due to having to write a lot of code that probably wouldn’t make it to the repository, but I found Cody doesn’t complain about any of that and it dutifully came to help.
The code in question is used for arranging paint order and implements checking of bounding box intersections. With a single click of Explain Code, Cody explains in detail the responsibilities of this function:
Before we start changing anything, let's generate some tests. With the function still highlighted, that's just one more click on Generate Unit Tests.
Cody explained it didn’t know what testing framework I used and assumed (correctly, as many C++ projects do) that I use GoogleTest. It then proceeded to generate test cases for all available scenarios. After a minor cleanup from the comments left in the code, I had my tests ready. The template was correctly recognized and had tests generated. The inclusion of a .cpp file instead of .h surprised me, but it was the correct approach for testing a static function without having to remove the modifier.
Subscribe for the latest code AI news and product updates