Parallelizing Irregular DOACROSS Loops Using ChatGPT and Transactional Memory in OpenMP
摘要
Large Language Models (LLMs) are currently at their peak and have found widespread use due to their strong natural language processing capabilities across multiple languages. Consequently, their applications have extended to programming tasks, ranging from teaching coding to beginners to addressing advanced challenges such as the automatic parallelization of sequential loops. However, some loops are inherently difficult to parallelize because: (a) dependencies between iterations are hard to detect, and (b) these dependencies are irregular and often depend on runtime input—the so-called irregular DOACROSS loops. In such cases, programmers may benefit from assistance in identifying these dependencies and determining appropriate parallelization techniques. This paper demonstrates that ChatGPT can serve as an effective programming assistant for parallelizing such challenging loops, provided the user has a solid understanding of DOACROSS semantics. Additionally, many of the parallel code variants generated by ChatGPT rely on the critical construct, prompting a reconsideration of earlier ideas for integrating transactional memory (TM) into OpenMP. To this end, we propose OpenHTM, a specification that enables HTM-based speculative execution within the OpenMP API. Experiments using automotive_susan_c benchmark from cBench suite—initially parallelized by ChatGPT-4o—show that OpenHTM can achieve speed-ups of up to 3.91 \(\times \) compared to the serial version on IBM POWER.