<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>In fact I have some theory on instruction level parallelism( i have a partitioning algorithm), then first of all, i want to generate a multithreaded code from LLVM IR (in assembly level) with a given partitioning. My problem is how can i use a thread library(like Pthread) or OS system calls in LLVM IR to create and manage threads?<br><br>--- On <b>Tue, 10/5/10, Tobias Grosser <i><grosser@fim.uni-passau.de></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Tobias Grosser <grosser@fim.uni-passau.de><br>Subject: Re: [LLVMdev] Multithreaded code generation<br>To: llvmdev@cs.uiuc.edu<br>Date: Tuesday, October 5, 2010, 12:08 PM<br><br><div class="plainMail">On 10/05/2010 09:42 AM, hamed hamzehi wrote:<br>> Hi<br>> yes, I'm asking for any advice, I want to
 implement multithreaded code<br>> generator in LLVM.<br>> tnx<br><br>Hi,<br><br>this generally depends which kind of code you want to multithread, because generally this is a difficult problem.<br>However, if you limit yourself for the moment to loops that fit into the polyhedral model, you can take advantage of the existing research in this area, which already produced some nice solutions.<br><br>If you are interested in this area I think this is the way to go:<br><br>1. Have a look at pluto[1]<br><br>Pluto is a source to source compiler that can auto parallelize hand selected code. To check how it works I attached you an example, where it translates normal C code to OpenMP parallelized code.<br><br>Compile it like this:<br><br>gcc -O3 seidel.c -o seidel_sequential<br>gcc -O3 -fopenmp -lm seidel.par.c -o seidel_parallel<br><br>I tried this on a 2 Core / 4 Thread Intel processor<br><br>$ time ./seidel_sequential<br><br>real   
 0m6.923s<br>user    0m6.890s<br>sys    0m0.010s<br><br>$ time ./seidel_parallel<br><br>real    0m2.710s<br>user    0m10.730s<br>sys    0m0.010s<br><br>One way to get this feature automatically into LLVM is by using polly [2]. Polly can detect and code generate all loops, that can be parallelized by pluto. So there are only two things missing.<br><br>1. Connect pluto somehow to polly to automatically parallelize any code that can be compiled by LLVM.<br><br>I am planning to work on this during the next six month. The first test cases will probably work a lot faster.<br><br>2. Create OpenMP parallel code.<br><br>This is not too difficult. We need an OpenMP library <a href="http://mpc.sourceforge.net/" target="_blank">http://mpc.sourceforge.net/</a> has e.g. an acceptable license (LGPL) and generate the relevant library calls.<br>As a first step this can be done without pluto
 support in Polly. We just limit ourselves to parallelize only loops, that do not carry  dependences.<br><br>If you want to work on this I propose to start with step "2.". Ping me for further information.<br><br>Cheers<br>Tobi<br><br>[1] <a href="http://pluto-compiler.sourceforge.net/" target="_blank">http://pluto-compiler.sourceforge.net/</a><br>[2] <a href="http://wiki.llvm.org/Polyhedral_optimization_framework" target="_blank">http://wiki.llvm.org/Polyhedral_optimization_framework</a><br><br>> <br>> --- On *Tue, 10/5/10, Duncan Sands /<<a ymailto="mailto:baldrick@free.fr" href="/mc/compose?to=baldrick@free.fr">baldrick@free.fr</a>>/* wrote:<br>> <br>> <br>>     From: Duncan Sands <<a ymailto="mailto:baldrick@free.fr" href="/mc/compose?to=baldrick@free.fr">baldrick@free.fr</a>><br>>     Subject: Re: [LLVMdev] Multithreaded code generation<br>>     To: <a
 ymailto="mailto:llvmdev@cs.uiuc.edu" href="/mc/compose?to=llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>>     Date: Tuesday, October 5, 2010, 10:50 AM<br>> <br>>     Hi Hamed,<br>> <br>>      > I want to use LLVM to automatically translate sequential codes to<br>>     multithreaded<br>>      > codes for execution on multicore processors.<br>>      > How should I start?<br>> <br>>     currently LLVM does not have support for anything like this as far<br>>     as I know.<br>>     But perhaps you meant that you want to implement it, and are asking<br>>     for advice?<br>> <br>>     Ciao,<br>> <br>>     Duncan.<br>> 
    _______________________________________________<br>>     LLVM Developers mailing list<br>>     <a ymailto="mailto:LLVMdev@cs.uiuc.edu" href="/mc/compose?to=LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> </mc/compose?to=<a ymailto="mailto:LLVMdev@cs.uiuc.edu" href="/mc/compose?to=LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>><br>>     <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>>     <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>> <br>> <br>> <br>> <br>> _______________________________________________<br>> LLVM Developers mailing list<br>> <a ymailto="mailto:LLVMdev@cs.uiuc.edu" href="/mc/compose?to=LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a
 href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>LLVM Developers mailing list<br><a ymailto="mailto:LLVMdev@cs.uiuc.edu" href="/mc/compose?to=LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></td></tr></table><br>