From 67e4e5727085041d676d0f655a63ba0e9bbc764d Mon Sep 17 00:00:00 2001 From: Andrei Zhabinski Date: Sun, 9 Feb 2020 14:53:20 +0300 Subject: [PATCH 1/4] Stop converting integers to Float32 in to_device() --- src/cuda.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cuda.jl b/src/cuda.jl index 5372dae..41d9358 100644 --- a/src/cuda.jl +++ b/src/cuda.jl @@ -32,7 +32,7 @@ function to_device(device::GPU, x) flds = fieldnames(T) if is_cuarray(x) return x - elseif isa(x, Real) + elseif isa(x, AbstractFloat) return Float32(x) elseif isa(x, Tuple) return ((to_device(device, el) for el in x)...,) From 9fb8693ce185b7504fa1e2c8d3fd96eead6f78ea Mon Sep 17 00:00:00 2001 From: Andrei Zhabinski Date: Sun, 9 Feb 2020 22:41:27 +0300 Subject: [PATCH 2/4] Stop using .= in generated code (performance experiment) --- src/compile.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compile.jl b/src/compile.jl index 699d7bd..a753d2f 100644 --- a/src/compile.jl +++ b/src/compile.jl @@ -20,7 +20,8 @@ end function Espresso.to_expr(op::Call) arg_names = map(make_name, op.args) call = Expr(:call, op.fn, arg_names...) - assign = (op.val isa Array || is_cuarray(op.val)) ? :(.=) : :(=) + # assign = (op.val isa Array || is_cuarray(op.val)) ? :(.=) : :(=) + assign = :(=) return Expr(assign, make_name(op.id), call) end From 2d05c740f4c61c15683d8d1a05823dbd61594c20 Mon Sep 17 00:00:00 2001 From: Andrei Zhabinski Date: Sun, 9 Feb 2020 23:03:18 +0300 Subject: [PATCH 3/4] Use .= for broadcasting only in generated code --- src/compile.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compile.jl b/src/compile.jl index a753d2f..633fc5f 100644 --- a/src/compile.jl +++ b/src/compile.jl @@ -20,8 +20,8 @@ end function Espresso.to_expr(op::Call) arg_names = map(make_name, op.args) call = Expr(:call, op.fn, arg_names...) - # assign = (op.val isa Array || is_cuarray(op.val)) ? :(.=) : :(=) - assign = :(=) + assign = ((op.val isa Array || is_cuarray(op.val)) && op.fn == broadcast) ? :(.=) : :(=) + # assign = :(=) return Expr(assign, make_name(op.id), call) end From 1a255984135603a0c846ea028beb7f6af16a802d Mon Sep 17 00:00:00 2001 From: Andrei Zhabinski Date: Sun, 9 Feb 2020 23:11:45 +0300 Subject: [PATCH 4/4] Remove .= again --- src/compile.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compile.jl b/src/compile.jl index 633fc5f..87f1994 100644 --- a/src/compile.jl +++ b/src/compile.jl @@ -20,8 +20,8 @@ end function Espresso.to_expr(op::Call) arg_names = map(make_name, op.args) call = Expr(:call, op.fn, arg_names...) - assign = ((op.val isa Array || is_cuarray(op.val)) && op.fn == broadcast) ? :(.=) : :(=) - # assign = :(=) + # assign = ((op.val isa Array || is_cuarray(op.val)) && op.fn == broadcast) ? :(.=) : :(=) + assign = :(=) return Expr(assign, make_name(op.id), call) end