Hi,
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?
--- On Tue, 10/5/10, Tobias Grosser <grosser at fim.uni-passau.de> wrote:
From: Tobias Grosser <grosser at fim.uni-passau.de>
Subject: Re: [LLVMdev] Multithreaded code generation
To: llvmdev at cs.uiuc.edu
Date: Tuesday, October 5, 2010, 12:08 PM
On 10/05/2010 09:42 AM, hamed hamzehi wrote:> Hi
> yes, I'm asking for any advice, I want to implement multithreaded code
> generator in LLVM.
> tnx
Hi,
this generally depends which kind of code you want to multithread, because
generally this is a difficult problem.
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.
If you are interested in this area I think this is the way to go:
1. Have a look at pluto[1]
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.
Compile it like this:
gcc -O3 seidel.c -o seidel_sequential
gcc -O3 -fopenmp -lm seidel.par.c -o seidel_parallel
I tried this on a 2 Core / 4 Thread Intel processor
$ time ./seidel_sequential
real 0m6.923s
user 0m6.890s
sys 0m0.010s
$ time ./seidel_parallel
real 0m2.710s
user 0m10.730s
sys 0m0.010s
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.
1. Connect pluto somehow to polly to automatically parallelize any code that can
be compiled by LLVM.
I am planning to work on this during the next six month. The first test cases
will probably work a lot faster.
2. Create OpenMP parallel code.
This is not too difficult. We need an OpenMP library http://mpc.sourceforge.net/
has e.g. an acceptable license (LGPL) and generate the relevant library calls.
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.
If you want to work on this I propose to start with step "2.". Ping me
for further information.
Cheers
Tobi
[1] http://pluto-compiler.sourceforge.net/
[2] http://wiki.llvm.org/Polyhedral_optimization_framework
>
> --- On *Tue, 10/5/10, Duncan Sands /<baldrick at free.fr>/* wrote:
>
>
> From: Duncan Sands <baldrick at free.fr>
> Subject: Re: [LLVMdev] Multithreaded code generation
> To: llvmdev at cs.uiuc.edu
> Date: Tuesday, October 5, 2010, 10:50 AM
>
> Hi Hamed,
>
> > I want to use LLVM to automatically translate sequential codes to
> multithreaded
> > codes for execution on multicore processors.
> > How should I start?
>
> currently LLVM does not have support for anything like this as far
> as I know.
> But perhaps you meant that you want to implement it, and are asking
> for advice?
>
> Ciao,
>
> Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu </mc/compose?to=LLVMdev at cs.uiuc.edu>
> http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-----Inline Attachment Follows-----
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20101005/d0f30c85/attachment.html>