Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Simple Gallium example not working #175

Open
josefsachsconning opened this issue Nov 16, 2016 · 4 comments
Open

Simple Gallium example not working #175

josefsachsconning opened this issue Nov 16, 2016 · 4 comments

Comments

@josefsachsconning
Copy link
Collaborator

This worked in 0.5.0-pre, i.e. ended up in the debug prompt in the REPL. Am I doing something wrong? What changed?

AWS-Sachs-Ubuntu$ cat /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl
function myfunction1(x)
    return "monadic"
end

function myfunction1(x, y)
    text = "alpha"
    z = myfunction2(x + y)
    return z
end

function myfunction2(a)
    r = a * 10
end
AWS-Sachs-Ubuntu$ ~/src/julia-release-0.5/usr/bin/julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.1-pre+27 (2016-11-04 08:41 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 25f7066 (11 days old release-0.5)
|__/                   |  x86_64-linux-gnu

julia> using Gallium

julia> include("/home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl")
myfunction2 (generic function with 1 method)

julia> bp = Gallium.breakpoint(myfunction1)
Locations (+: active, -: inactive, *: source):
 * Any matching method added to #myfunction1
 * Any matching specialization of myfunction1(x) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:2
 * Any matching specialization of myfunction1(x, y) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:6


julia> myfunction1(1)
"monadic"

Back in 0.5.0-pre, I got this:

julia> bp = Gallium.breakpoint(myfunction1)
Locations (+: active, -: inactive, *: source):
 + myfunction1(x::Int64) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:2
 + myfunction1(x::Int64, y::Int64) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:6
 * Any matching method added to #myfunction1
 * Any matching specialization of myfunction1(x) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:2
 * Any matching specialization of myfunction1(x, y) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:6
@timholy
Copy link
Member

timholy commented Nov 16, 2016

Try putting @noinline in front of your definition of myfunction1, or start julia with julia --inline=no. It's possible that julia -O0 would help, but I think that's more about avoiding the elision of variables than the inlining of functions.

@josefsachsconning
Copy link
Collaborator Author

Using -O0 and --inline=no did not produce different behavior.

AWS-Sachs-Ubuntu$ ~/src/julia-release-0.5/usr/bin/julia -O0 --inline=no
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.1-pre+27 (2016-11-04 08:41 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 25f7066 (12 days old release-0.5)
|__/                   |  x86_64-linux-gnu

julia> using Gallium

julia> include("/home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl")
myfunction2 (generic function with 1 method)

julia> bp = Gallium.breakpoint(myfunction1)
Locations (+: active, -: inactive, *: source):
 * Any matching method added to #myfunction1
 * Any matching specialization of myfunction1(x) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:2
 * Any matching specialization of myfunction1(x, y) at /home/sachs/lib/julia/GalliumExample.jl/src/GalliumExample.jl:6


julia> myfunction1(1)
"monadic"

@josefsachsconning
Copy link
Collaborator Author

I'm curious about a couple things.

(1) What would myfunction1 be inlined into, since it is being called from the REPL?

(2) What changed between 0.5.0-pre, when this worked (see above), and 0.5.0 to produce the different behavior?

@Keno
Copy link
Member

Keno commented Nov 18, 2016

There's a new optimization in 0.5, where it avoids specializing functions if it realizes the return value is always the same and just uses the value directly. That's probably what happens here, so the function never actually gets run. We're looking into disabling that optimization in --inline=no mode.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants