Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ptx code output from existing ll file working. Something funky going …
…on with the create instructions
- Loading branch information
Showing
8 changed files
with
102 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
library(Rllvm) | ||
|
||
m = Module("ptx kernel") | ||
#fun = Function("kern", VoidType, module = m) | ||
fun = simpleFunction("kern", VoidType, mod = m) | ||
|
||
fun$ir$createLocalVariable(Int32Type, "i") | ||
ir$createReturn() | ||
|
||
|
||
|
||
setMetadata(m, "nvvm.annotation", list(m$kern, "kernel", 1L)) | ||
#Rllvm:::setCallingConv(m$simple, as(71L, "CallingConv")) | ||
|
||
|
||
|
||
InitializeNVPTXTarget() | ||
arch = "nvptx64" | ||
|
||
tri <- getDefaultTargetTriple() | ||
setTargetTriple(m, tri) | ||
|
||
|
||
#Used to be trgt = lookupTarget("nvptx64") | ||
trgt = lookupTarget(tri, arch) | ||
# sm_20 is the CPU type and can be sm_20, sm_30 or a variety of others understood by the NVPTX backend | ||
machine = createTargetMachine(trgt, tri, "sm_20") | ||
|
||
# Now add the passes to generate the code. | ||
|
||
pm = passManager(m, FALSE) | ||
|
||
trgtLibInfo = targetLibraryInfo(tri) | ||
addPass(pm, trgtLibInfo) | ||
|
||
addAnalysisPasses(machine, pm) | ||
|
||
dataLayout = getDataLayout(machine) | ||
addPass(pm, dataLayout) | ||
|
||
|
||
# We'll write the code to a string stream rather than a file | ||
|
||
#out = .Call("R_new_raw_string_ostream", "") | ||
#stream = rawFDOstream("/tmp/foo.ptx") | ||
|
||
stream = stringRawOstream() | ||
out = formattedRawOstream(stream) | ||
|
||
if(addPassesToEmitFile(machine, pm, out, 0L)) | ||
stop("failed in addPassesToEmitFile. Is this type of file supported by the manager?") | ||
|
||
run(pm, m) | ||
|
||
# Garbage collect out so that the buffer is flushed | ||
#rm(out); gc() | ||
#.Call("R_flush_formatted_raw_ostream", out) | ||
flush(out) | ||
code = as(stream, "character") | ||
print(nchar(code)) | ||
|
||
#.Call("R_raw_ostream_close", stream, FALSE) | ||
# cat("File size:", file.info("/tmp/foo.ptx")[1, "size"], "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters