A small attempt at running CLArrays.jl with julia 1.0


I think I got a fair way through the precompile stage, mostly just replacing immutable's with struct's and moving the {T}'s of func{T}() to func() where{T}, but I’ve gotten a bit stuck on an unrecognized :SSAValue, from the Sugar.jl package / methods.jl / line 159

Any tips for what to do here /where i might find a SSAValue type in julia 1.0?
[Added]: Choice of Core.Compiler.OldSSAVal or Core.Compiler.NewSSAVal ? both have matching fieldnames

Small type discovery/listing code for julia 1.0

z = Symbol.(subtypes(Any));
for x in z 

Next tricky error is an Syntax: “…” expression outside call in methods.jl: line 444, pointed at a docstring

Rewrite the ast to resolve everything statically
and infers the dependencies of an expression
function rewrite_ast(m, expr)

Add[2]: fixed with ...,

Now in Transpiler.jl package / rewriting.jl line 211, first multiline fix needed

# get the concrete function objects
const fast_ops = getfield.(Base.FastMath, collect(values(Base.FastMath.fast_op)))
const slow_ops = getfield.(Base.FastMath, collect(keys(Base.FastMath.fast_op)))

const fast_op_2_op = Dict(zip(fast_ops, slow_ops))
> MethodError: no method matching length(::Module)


The main road block is porting the Sugar.jl relooper to 1.0.
I had a nice IR pattern matching going for 0.7 (in Sugar/sd/07), but sadly I did it just before the huge Julia IR changes hit 0.7, so it became all obsolete -.-

I’d say the best strategy would be to use IRTools, solve IRTools.jl#3, best by reusing Charlotte.jl relooper, and then port some of the sugar passes to IRTools - which we should be able to drastically simplify.
Alternatively, we could also try to update the pattern matching approach in sd/07 to work with Julia’s new IR - shouldn’t be too hard, just needs some new ways to match the new IR blocks.

Transpiler.jl will need quite a bit of a rewrite as well, but I hope to drastically simplify a few things - and it should mainly just be about Sugar.jl preparing the IR for Transpiler to consume.

Let me know if you seriously consider working on this, I want to sit down at some point and get this working :wink:


I have build Sugar working in the package shell, test Sugar rolls through to Unicode[4ec0a83e] and then Errors with UndefVar Error: Test not defined. Tbh a lot of what the code is actually doing is probably going quite over my head, but the breakpoint is slowly advancing (I cheated a little somewhere earlier and defined a GotoNode struct with the expected field)

Currently stuck on @cl_intrinsic SpecialFunctions.erfc(::T) where{T <: AbstractFloat} = ret(T)
TypeError in isdefined: expected symbol, got expression, in Intrinsics.jl line 85


Making Sugar.jl compile on 1.0 won’t help you much, since all the IR transformations it does are invalid on 1.0 because of how 1.0 drastically changed the IR.


Ah that’s a bit of a bugger, but i’m quite thankful for the heads up early, I could’ve spent all week or more tinkering away. They do make for good coding challenges though


Yeah, glad you asked :slight_smile:
Porting Charlottes looper to IRTools might actually be not as hard, since it seemed already be written with the design of IRTools in mind… So that would be a tremendous help to get me started!


Just this bit? https://github.com/MikeInnes/Charlotte.jl/blob/master/src/script/looper.jl


Yes! Probably worth coordinating with @MikeInnes!


include(“Charlotte.jl”) with looper.jl, no wasm.jl success
This goes at the start of looper

GotoNode = Core.GotoNode;
Associative = AbstractDict;


Is there any progress on this? I wanted to try CLArrays, but it’s a bummer it doesn’t support Julia 1.0.