Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Move codegen.cpp to a native Julia pipeline using the C interface + MLIR.jl #22

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build*/
Brutus/Manifest.toml
llvm
julia
MLIR.jl
Brutus/dev
1 change: 1 addition & 0 deletions Brutus/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.0"

[deps]
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
MLIR = "bfde9dd4-8f40-4a1e-be09-1475335e1c92"

[compat]
julia = "1.5"
65 changes: 65 additions & 0 deletions Brutus/scratch/juliacodegen.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module JuliaCodegen

using Brutus
using MLIR

println("\n---- brutus_id ----\n")
function brutus_id(N)
return N
end

v = Brutus.call(brutus_id, 5)
@time v = Brutus.call(brutus_id, 5)
display(v)

println("\n---- brutus_add ----\n")

function brutus_add(N1, N2)
return N1 + N2
end

v = Brutus.call(brutus_add, 5.0, 10.0)
@time v = Brutus.call(brutus_add, 5.0, 10.0)
display(v)

println("\n---- structs ----\n")

struct Foo
x
end

function bar()
f = Foo(5.0)
b = Foo(f.x + 10.0)
return f
end

v = Brutus.call(bar; dump_options = Brutus.DumpAll)
display(v)

#println("\n---- switch ----\n")
#
#function switch(N)
# N > 10 ? 5 : 10
#end
#
#v = Brutus.call(switch, 15)
#display(v)

#println("\n---- gauss ----\n")
#
#function gauss(N)
# k = 0
# for i in 1 : N
# k += i
# end
# return k
#end
#
#mi = Brutus.get_methodinstance(Tuple{typeof(gauss), Int})
#ir_code, rt = Brutus.code_ircode(mi)
#display(ir_code)
#mod = Brutus.Compiler.codegen_jlir(ir_code, rt, "gauss")
#MLIR.IR.dump(mod)

end # module
2 changes: 1 addition & 1 deletion Brutus/src/Brutus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import GPUCompiler: AbstractCompilerTarget, AbstractCompilerParams
export emit

include("init.jl")
include("codegen.jl")
include("compiler/Compiler.jl")
include("reflection.jl")
include("interface.jl")

Expand Down
105 changes: 0 additions & 105 deletions Brutus/src/codegen.jl

This file was deleted.

11 changes: 11 additions & 0 deletions Brutus/src/compiler/Compiler.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Compiler

using MLIR
import MLIR.IR as JLIR
import Base: push!

include("opbuilder.jl")
include("jlirgen.jl")
include("codegen.jl")

end # module
Loading