nguyenminhduc9988 / gpuocelot

Automatically exported from code.google.com/p/gpuocelot
0 stars 0 forks source link

Define LLVM IR #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Describe the New Feature:
1. Create an LLVMInstruction class that inherits from Instruction and is
able to represent any valid LLVM instruction.
2. Create a toString function that converts an instruction to a parsable
assembly language representation.

Which milestone does the feature belong to?
Milestone-Release0.6

Which branch does the new feature go in?
Trunk

Original issue reported on code.google.com by gregory....@gatech.edu on 22 Jun 2009 at 8:24

GoogleCodeExporter commented 9 years ago
Hi, I'm learning compiler stuff in my free time and I wanted to make and PTX to 
AMD 
IL conversor as a starting point so that OpenCL programs can run on every GPU 
without 
recompilation.. I think the I may use your PTX parser but I would need to 
update to 
the version 1.5 used in OpenCL SDK.. Since I don't know many about compilers 
and 
about your code perhaps is easier for you to update the parser.. Please watch 
details 
at my comment in issue 3..
Next, I don't know if implementing a direct PTX to AMD IL conversor or adding a 
LLVM 
IR to AMD IL codegen such that can be used as another codegen path in your 1.0 
release (Also what timing your expect for integrating the LLVM stuff into your 
code)
Please add comments about your thoughts..

Original comment by rtf...@gmail.com on 25 Jun 2009 at 3:58

GoogleCodeExporter commented 9 years ago
The philosophy behind an LLVM translator is that it will allow us to run PTX
efficiently on multicore CPUs.  We want to use LLVM because it has a very 
stable back
end code generator for various architectures including x86, PowerPC, and ARM, 
and is
a much cleaner ISA than most native ISAs.  

I think that a PTX to AMD translator would be a very interesting project.  I 
haven't
looked into the AMD architecture enough to say whether or not it could be done
efficiently, but I think that if you did want to do this, it would be a better 
idea
to go straight from PTX to AMD's ISA.  

Our target for a complete LLVM path is late December so you would have to wait 
to
start on that. From a language perspective PTX and LLVM are very similar, so I 
don't
think that it would make much difference which one you chose.

See my comments on [http://code.google.com/p/gpuocelot/issues/detail?id=3 
issue3] for
PTX 1.5.  The short answer is that I won't update the parser to support 1.5 
until
NVIDIA releases an ISA specification for 1.5. 

Original comment by gregory....@gatech.edu on 25 Jun 2009 at 4:18

GoogleCodeExporter commented 9 years ago
Started work on this.  First steps are to define an LLVMInstruction class and a
Translator base class.

Original comment by gregory....@gatech.edu on 13 Jul 2009 at 7:05

GoogleCodeExporter commented 9 years ago
Finished implementing the base IR and unit tests.  The unit tests cover specific
examples from the LLVM programming manual, but they are by no means exhaustive.

The IR as it stands differs dramatically from the PTX IR because we never 
intend to
execute it.  Rather than having a single, all encompassing LLVMInstruction 
class,
LLVMInstruction provides a base class for derived classes for the individual 
LLVM
classes.  This should be more space compact, make the code more readable, and 
allow
code the be shared between similar classes of Instructions.  The downside is 
that a
packed vector of LLVMInstructions is impossible to create, instead we will have 
to
have a packed vector of LLVMInstruciton*'s.  

Someone needs to review the IR so that we can catch anything obviously wrong 
early,
but I am going to move on to the Translator...

Original comment by gregory....@gatech.edu on 29 Jul 2009 at 10:06