Julie, it may help someone else to understand what is needed if you would
share what it is that you are trying to accomplish in words.
On Friday, March 11, 2016 at 12:24:36 PM UTC-5, Julia Tylors wrote:
>
> Maybe the code generated should be looking something like this :
>
>
> GenSym(0) =
> ((top(getfield))((top(getfield))(Transmission,:Download),:download_task))(Val{symbol("##7731")},x,y,v1,v2)
> #s222 = (top(start))(GenSym(0))
> GenSym(1) = (top(indexed_next))(GenSym(0),1,#s222)
> v3 = (top(getfield))(GenSym(1),1)
> #s222 = (top(getfield))(GenSym(1),2)
> GenSym(2) = (top(indexed_next))(GenSym(0),2,#s222)
> v4 = (top(getfield))(GenSym(2),1)
> #s222 = (top(getfield))(GenSym(2),2)
>
> I am kind of confused, can somebody offer some solution to my problem?
> Thanks
>
> On Thursday, March 10, 2016 at 11:50:47 PM UTC-8, Julia Tylors wrote:
>>
>> Now the generated code looks like this:
>>
>> AST(:($(Expr(:lambda, Any[:x,:y],
>> Any[Any[Any[:x,:Any,1],Any[:y,:Any,1],Any[:v1,:Any,7],Any[:v2,:Any,7]],Any[],0,Any[]],
>>
>> :(begin # none, line 2:
>> NewvarNode(:v1)
>> NewvarNode(:v2)
>> v1 = 2.1
>> v2 = 2.2
>> (v1,v2) =
>> ((top(getfield))((top(getfield))(Transmission,:Download),:download_task))(Val{symbol("##7731")},x,y,v1,v2)
>>
>> return v1 + v2
>> end)))))
>>
>> however, when i call test(1.1,2.2), it gives me the following error:
>>
>> signal (11): Segmentation fault
>> var_binding_pointer at codegen.cpp:2858
>> emit_assignment at codegen.cpp:3052
>> emit_function at codegen.cpp:4697
>> jl_eh_restore_state at julia.h:1410
>> jl_compile at codegen.cpp:812
>> jl_trampoline_compile_function at builtins.c:1025
>> jl_apply at gf.c:1709
>> do_call at interpreter.c:66
>> eval at interpreter.c:213
>> jl_toplevel_eval_flex at toplevel.c:544
>> jl_eh_restore_state at julia.h:1410
>> eval_user_input at ./REPL.jl:62
>> unknown function (ip: 0x7f52402a9497)
>> jl_apply at gf.c:1711
>> anonymous at ./REPL.jl:85
>> start_task at task.c:246
>> unknown function (ip: (nil))
>> Segmentation fault
>>
>>
>>
>>
>>
>> On Thursday, March 10, 2016 at 10:07:05 PM UTC-8, Julia Tylors wrote:
>>>
>>> I fixed it, It should have been like this:
>>>
>>> (:v1,:v2) =
>>> ((top(getfield))((top(getfield))(Staged,:Runtime),:kernel_call))(Val{symbol("##7731")},x,y,v1,v2)
>>>
>>> On Thursday, March 10, 2016 at 3:48:49 PM UTC-8, Yichao Yu wrote:
>>>>
>>>> On Thu, Mar 10, 2016 at 6:04 PM, Julia Tylors <[email protected]>
>>>> wrote:
>>>> >
>>>> >
>>>> > Hi fellows, I have a problem which i can't solve.
>>>> >
>>>> > I have a function test(x,y) which has the ast as follows:
>>>> > (test.env.defs.func.code)
>>>> >
>>>> >
>>>> > :($(Expr(:method, :test,
>>>> > :((top(svec))((top(apply_type))(Tuple,Any,Any),(top(svec))())),
>>>> > AST(:($(Expr(:lambda, Any[:x,:y],
>>>> >
>>>> Any[Any[Any[:x,:Any,1],Any[:y,:Any,1],Any[:v1,:Any,7],Any[:v2,:Any,7]],Any[],0,Any[]],
>>>>
>>>>
>>>> > :(begin # none, line 2:
>>>> > NewvarNode(:v1)
>>>> > NewvarNode(:v2)
>>>> > v1 = 2.1
>>>> > v2 = 2.2
>>>> > $(Expr(:(=), :v1, :v2,
>>>> >
>>>> :(((top(getfield))((top(getfield))(Transmission,:Download),:download_task))(Val{symbol("##7775")},x,y,v1,v2))))
>>>>
>>>>
>>>> > return v1 + v2
>>>> > end))))), false)))
>>>> >
>>>> >
>>>>
>>>> Can you show how you generated `test`?
>>>>
>>>> >
>>>> > when i call test(1.1,2.2), it returns 4.4 but it should have returned
>>>> > v1 = 1.1*2.2 = 2.42
>>>> > v2 = 2.2*2.1 = 4.62
>>>> >
>>>> > so the result should be v1+v2 , 7.04
>>>> >
>>>> > Here is the download_task function.
>>>> > @generated function download_task{id}(::Type{Val{id}}, args...)
>>>> > println("Download Task $id for argument types $args")
>>>> > :((args[1] * args[2]), (args[2] * args[3]))
>>>> > end
>>>> >
>>>> > I am suspicious about the part in bold
>>>> >
>>>> > $(Expr(:(=), :v1, :v2,
>>>> >
>>>> :(((top(getfield))((top(getfield))(Transmission,:Download),:download_task))(Val{symbol("##7775")},x,y,v1,v2))))
>>>>
>>>>
>>>> >
>>>> > this part doesn't get executed! Or somewhat expanded wrong. I am not
>>>> totally
>>>> > sure.
>>>> > Anyone with a better understanding , please help me out.!
>>>> >
>>>> > Thanks
>>>>
>>>