Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
duncantl committed Aug 6, 2012
1 parent 5bfaa26 commit f3e9222
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Changelog
@@ -1,7 +1,10 @@
Version 0.4-1

* Compiles and installs with LLVM 3.1.


* parseIR() function allows us to parse IR code and so we
could create the code via strings.

Version 0.4-0

* Added getDescription() and method for Type and getTypeID(),
Expand Down
11 changes: 1 addition & 10 deletions FAQ.xml
@@ -1,12 +1,3 @@
<faq>
<q>
I get errors of the form
<quote>
failed to create execution engine: Unable to find target for this triple (no targets are registered)
</quote>
What's the problem?
<a>
You need to call InitializeNativeTarget() before creating the execution engine.
</a>
</q>

</faq>
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -215,3 +215,6 @@ exportMethods(getDescription)
export(isVoidType, isFloatType, isDoubleType, isX86_FP80Type, isFP128Type,
isPPC_FP128Type, isLabelType, isMetadataType, isIntegerType, isFunctionType,
isStructType, isArrayType, isPointerType, isOpaqueType, isVectorType)


export(parseIR)
12 changes: 12 additions & 0 deletions R/IRBuilder.R
Expand Up @@ -313,3 +313,15 @@ function(ir)
{
.Call("R_IRBuilder_getTrue", ir)
}


parseIR =
function(content, context = NULL, asText = is(content, "AsIs") || !file.exists(content))
{
if(!asText)
content = path.expand(content)
else
content = paste(as.character(content), collapse = "\n")

.Call("R_llvm_ParseIRFile", content, as.logical(asText), context)
}
9 changes: 9 additions & 0 deletions Todo.xml
Expand Up @@ -2,6 +2,15 @@

<items>

<item>
Find out how to parse IR text into IR structures.
<br/>
ParseIRFile() in opt.cpp.
So Support/IRReader.h
<br/>
For BitCode, see include/llvm/Bitcode/ReaderWriter.h
</item>

<item>
In the TU, ExecutionEngine create method has an NA for the type of one of the parameters.
The type is there and the name of the type is also there, just not shown.
Expand Down
2 changes: 1 addition & 1 deletion Web/GNUmakefile
@@ -1,5 +1,5 @@
PKG=Rllvm
WEB_DIR=www.omegahat.org:/home3/WebSites/Omega/$(PKG)
WEB_DIR=www.omegahat.org:~/OmegaWeb/$(PKG)


shipIndex: index.html extra
Expand Down
6 changes: 4 additions & 2 deletions Web/index.html.in
Expand Up @@ -6,8 +6,10 @@

<body>
<h1>The Rllvm Package</h1>
<p align=right><a href="https://github.com/duncantl/Rllvm">Rllvm on github</a></p>
<p align=right><a href="@TAR_FILE@">@TAR_FILE@</a> (@DATE@)</p>
<p align=right><a href="philosophy.html">Manual</a></p>
<p align=left><img src="../new.jpg"/><a href="JSM2012/frames.html">JSM2012 Talk</a></p>
<!--<p align=right><a href="philosophy.html">Manual</a></p> -->

The Rllvm package is an R-interface to the <a
href="http://llvm.org">llvm</a> library that provides
Expand Down Expand Up @@ -145,7 +147,7 @@ This is distributed under the GPL2 License.
<address><a href="http://www.stat.ucdavis.edu/~duncan">Duncan Temple Lang</a>
<a href=mailto:duncan@wald.ucdavis.edu>&lt;duncan@wald.ucdavis.edu&gt;</a></address>
<!-- hhmts start -->
Last modified: Wed Sep 8 09:57:12 PDT 2010
Last modified: Sun Aug 5 20:34:49 PDT 2012
<!-- hhmts end -->

</body> </html>
32 changes: 32 additions & 0 deletions src/IRBuilder.cpp
Expand Up @@ -593,3 +593,35 @@ R_IRBuilder_getCurrentFunctionReturnType(SEXP r_builder)
}




#include <llvm/Support/IRReader.h>
extern "C"
SEXP
R_llvm_ParseIRFile(SEXP r_content, SEXP r_inMemory, SEXP r_context)
{
llvm::Module *mod;
llvm::SMDiagnostic err;

llvm::LLVMContext *context;
if(Rf_length(r_context))
context = (GET_REF(r_context, LLVMContext)); // llvm::cast<llvm::LLVMContext>
else
context = & llvm::getGlobalContext();

std::string fn(CHAR(STRING_ELT(r_content, 0)));

if(LOGICAL(r_inMemory)[0]) {
llvm::MemoryBuffer *buf;
buf = llvm::MemoryBuffer::getMemBuffer(fn);
mod = llvm::ParseIR(buf, err, *context);
} else {
mod = llvm::ParseIRFile(fn, err, *context);
}
if(!mod) {
PROBLEM "failed to parse IR: (line = %d, col = %d), %s",
err.getLineNo(), err.getColumnNo(), err.getMessage().c_str()
ERROR;
}
return(mod ? R_createRef(mod, "Module") : R_NilValue );
}
18 changes: 18 additions & 0 deletions tests/cumsum.Rdb
Expand Up @@ -416,6 +416,24 @@ Now we compare the byte-compiled code and the LLVM-compiled code:
</r:code>
</para>

<para>
Curiously, on eeyore - an Ubuntu Linux machine -
we get much worse performance comparing
interpreted to LLVM-compiled code.
The interpreted code is running about 30 faster on
the Linux box.
The LLVM-code is running about as 10th as fast as it does on OS X.
<r:code>
print((rowMeans(interp)/rowMeans(ll))[1:3], digits = 3)
<r:output><![CDATA[
user.self sys.self elapsed
23.8803 0.0435 20.5082
]]></r:output>
</r:code>
This may be due to
</para>


</section>
</article>

10 changes: 10 additions & 0 deletions tests/rw2d.Rdb
Expand Up @@ -368,6 +368,8 @@ With an optimized R (i.e. compiled with -O3)


<invisible>
All of these done with the same version of Rllvm &amp; LLVM
3.1 and
R-2.16 on my Mac laptop Aug 4, 2012

Time Speedup
Expand All @@ -389,6 +391,14 @@ Interpeted 255.310 1.000000
Byte Compiled 167.970 1.519974
Vectorized 1.365 187.040293
Rllvm 0.970 263.206186


eeyore:
Time Speedup
Interpeted 171.62 1.000000
Byte Compiled 85.49 2.007486
Vectorized 0.88 195.022727
Rllvm 0.70 245.171429
</invisible>


Expand Down

0 comments on commit f3e9222

Please sign in to comment.