[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-83662-en":3,"doc-seo-83662-105":29,"detail-sidebar-cat-0-en-105":82},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":28},83662,3848291630094,"Emma Wilson","https://eur-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45",6,"Technology","Kotlin-MP DSL and IR Transformer for Parallelism","Kotlin-MP targets efficient hardware parallelism on the JVM for compute-bound workloads, addressing the gap between Kotlin’s high-level concurrency abstractions and low-overhead parallel execution. It introduces a native Kotlin DSL with OpenMP-like syntax to mark parallel regions, schedules, and critical sections, paired with a compiler IR transformer. The transformer rewrites DSL-marked code at compile time into optimized ForkJoinPool tasks, performing loop chunking, thread scheduling, and hardware synchronization for scalable performance, validated by correctness tests and JMH benchmarking.","Kotlin-MP: DSL and IR Transformer for Parallelism  \nRuikai Huang  \narXiv :2607 .02519v1 [ cs .DC] 4 May 2026  \nI. INTRODUCTION  \nWhile Kotlin provides exceptional abstractions for asynchronous concurrency (like Coroutines for I/O), it lacks lowoverhead, directive-based constructs for true hardware parallelism. When developers attempt to parallelize compute-bound mathematical loops using standard task-parallel libraries, they encounter significant runtime overhead such as lambda allocations and state-machine generation due to the abstraction layers, and face difficulties in ensuring readability, reliability and maintainability in implementing them.  \nTo address this, this project proposes Kotlin-MP, a native Kotlin Domain-Specific Language (DSL) paired with a custom Intermediate Representation (IR) transformer as a Kotlin compiler plugin. The DSL provides an intuitive, OpenMP-like syntax for developers to denote parallel regions, schedules, and critical sections. Instead of acting as a standard runtime wrapper, the IR transformer intercepts this DSL at compile-time and structurally rewrites the code. It lowers the parallelized sections directly into optimized java.util.concurrent.ForkJoinPool tasks, automatically managing loop chunking, performing thread scheduling, and injecting hardware synchronization and mutual exclusion.  \nThe main contributions of the work are:  \n• A native Kotlin DSL that offers OpenMP-style constructs to achieve parallelism in a readable and idiomatic form.  \n• A Kotlin compiler IR transformer that recognizes the DSL markers and lowers them at compile time into efficient JVM parallel execution patterns.  \n• An evaluation using behavioral tests and JMH benchmarking to show that the implementation produces correct parallel code and scalable performance on computebound workloads.  \nII. BACKGROUND AND MOTIVATION  \nThere is a fundamental difference between concurrency and parallelism: concurrency is about managing many in-progress tasks; parallelism is about simultaneous execution for speedup. A concurrent program can run on one core via interleaving, while a parallel program needs hardware resources that can execute multiple operations at once [1] . Kotlin’s flagship feature, Coroutines [2], relies on Continuation-Passing Style (CPS) state machines. While exceptional for I/O concurrency, CPS introduces unacceptable instruction overhead when applied to tight, CPU-bound loops. Figure 1 presents a typical sequential implementation of matrix multiplcation in Kotlin: it uses three nested loops to perform the computation. We can apply coroutines to accelarate computation. As shown in Figure 2, the outermost loop i is processed concurrently (and  \n\n| 1 for (i in 0 until size) {\u003Cbr>2 for (j in 0 until size) {\u003Cbr>3 var sum = 0 . 0f\u003Cbr>4 for (k in 0 until size) {\u003Cbr>5 sum += matrixA [i * size + k] * matrixB [k * size +,→ j ]\u003Cbr>6 }\u003Cbr>7 matrixC [i * size + j ] = sum\u003Cbr>8 }\u003Cbr>9 } |\n| --- |\n| Fig. 1. Sequential matrix multiplication implementation. |\n| 1 runBlocking(Dispatchers .Default ) {\u003Cbr>2 (0 until size) .map { i ->\u003Cbr>3 async {\u003Cbr>4 for (j in 0 until size) {\u003Cbr>5 var sum = 0 . 0f\u003Cbr>6 for (k in 0 until size) {\u003Cbr>7 sum += matrixA [i * size + k] * matrixB [k *,→ size + j ]\u003Cbr>8 }\u003Cbr>9 matrixC [i * size + j ] = sum 10 }\u003Cbr>11 }\u003Cbr>12 } .awaitAll () 13 } |\n\nFig. 2. Kotlin coroutine-based matrix multiplication implementation.  \nlikely parallized, depending on the runtime environment and hardware constraint) by assigning every i a coroutine. While the abstraction is straightforward and expressive, the overhead on the lambda construction, scheudling, and state-management is not ideal for dense compute-bound kernels.  \nTo achieve true hardware parallelism on the JVM, the optimal target is Java’s ForkJoinPool [3], which utilizes a specialized Cilk-style [4] work-stealing algorithm designed specifically to keep physical cores saturated during dataparallel operations. However, writing raw ForkJoinPool boilerplate is verb","cbCairrmzzPsVbIP","https://ap.wps.com/l/cbCairrmzzPsVbIP","pdf",230460,1,4,"English","en",105,"# Introduction\n# Background and Motivation","[{\"question\":\"How are Kotlin-MP’s results evaluated?\",\"answer\":\"The work reports behavioral tests for correctness and JMH benchmarking to demonstrate correct parallel code generation and scalable performance on compute-bound workloads.\"}]",1784189592,10,{"code":4,"msg":30,"data":31},"ok",{"site_id":24,"language":23,"slug":32,"title":13,"keywords":33,"description":14,"schema_data":34,"social_meta":77,"head_meta":79,"extra_data":81,"updated_unix":27},"kotlin-mp-dsl-and-ir-transformer-for-parallelism","",{"@graph":35,"@context":76},[36,52,67],{"@type":37,"itemListElement":38},"BreadcrumbList",[39,43,47,50],{"item":40,"name":41,"@type":42,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":44,"name":45,"@type":42,"position":46},"https://docshare.wps.com/document/","Document",2,{"item":48,"name":12,"@type":42,"position":49},"https://docshare.wps.com/document/technology/",3,{"item":51,"name":13,"@type":42,"position":21},"https://docshare.wps.com/document/kotlin-mp-dsl-and-ir-transformer-for-parallelism/83662/",{"url":51,"name":13,"@type":53,"author":54,"headline":13,"publisher":56,"fileFormat":59,"inLanguage":23,"description":14,"dateModified":60,"datePublished":61,"encodingFormat":59,"isAccessibleForFree":62,"interactionStatistic":63},"DigitalDocument",{"name":9,"@type":55},"Person",{"url":40,"name":57,"@type":58},"DocShare","Organization","application/pdf","2026-07-17","2026-07-16",true,{"@type":64,"interactionType":65,"userInteractionCount":20},"InteractionCounter",{"@type":66},"ViewAction",{"@type":68,"mainEntity":69},"FAQPage",[70],{"name":71,"@type":72,"acceptedAnswer":73},"How are Kotlin-MP’s results evaluated?","Question",{"text":74,"@type":75},"The work reports behavioral tests for correctness and JMH benchmarking to demonstrate correct parallel code generation and scalable performance on compute-bound workloads.","Answer","https://schema.org",{"og:url":51,"og:type":78,"og:title":13,"og:site_name":57,"og:description":14},"article",{"robots":80,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":83},[84,88,92,96,101,104,109,114,119,122,125],{"id":20,"doc_module":4,"doc_module_name":45,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":46,"doc_module":4,"doc_module_name":45,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":21,"doc_module":4,"doc_module_name":45,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":45,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":11,"doc_module":4,"doc_module_name":45,"category_name":12,"show_sort_weight":102,"slug":103},50,"technology",{"id":105,"doc_module":4,"doc_module_name":45,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":45,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":45,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":45,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":28,"doc_module":4,"doc_module_name":45,"category_name":123,"show_sort_weight":28,"slug":124},"Lifestyle","lifestyle",{"id":126,"doc_module":4,"doc_module_name":45,"category_name":127,"show_sort_weight":97,"slug":128},19,"General","general"]