Skip to content

Commit 3fc8959

Browse files
Generated kernel argument order (#82)
* Swap order of arguments from (in, out) to idiomatic (out, in) * Update to next breaking version
1 parent 9c4dad0 commit 3fc8959

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ComputableDAGs"
22
uuid = "62933717-1c9d-4a3f-b06f-7ab7f17ca32d"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
authors = ["Anton Reinhard <[email protected]>", "Uwe Hernandez Acosta"]
55

66
[deps]

ext/KernelAbstractionsExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using Random
88
include("kernel_wrapper.jl")
99

1010
function ComputableDAGs.init_kernel(mod::Module)
11-
mod.eval(Meta.parse("@kernel inbounds = true function _ka_broadcast!(@Const(in::AbstractVector), out::AbstractVector, val::Val)
11+
mod.eval(Meta.parse("@kernel inbounds = true function _ka_broadcast!(out::AbstractVector, @Const(in::AbstractVector), val::Val)
1212
id = @index(Global)
1313
@inline out[id] = _compute_expr(in[id], val)
1414
end"))

src/devices/interface.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ function measure_device! end
5050
kernel(dag::DAG, instance, context_module::Module)
5151
5252
!!! warn
53-
Before calling this function, make sure to have called [`init_kernel`](@ref) in your session!
53+
Before calling this function, make sure to have called [`ComputableDAGs.init_kernel`](@ref) in your session!
5454
55-
For a [`DAG`](@ref), and a problem instance, return a KernelAbstractions kernel of signature `kernel(input::AbstractVector, output::AbstractVector; ndranges::Int64)`, which will return the result of the DAG computation of the input on the given output vector on each index (like a broadcast). This function is only available as an extension when KernelAbstractions is loaded.
55+
For a [`DAG`](@ref), and a problem instance, return a KernelAbstractions kernel of signature `kernel(output::AbstractVector, input::AbstractVector; ndranges::Int64)`, which will return the result of the DAG computation of the input on the given output vector on each index (like a broadcast). This function is only available as an extension when KernelAbstractions is loaded.
5656
5757
A simple example call for a kernel generated from this might look like the following:
5858
```Julia
59-
cuda_kernel(get_backend(inputs), 256)(inputs, outputs; ndrange=length(inputs))
59+
cuda_kernel(get_backend(inputs), 256)(outputs, inputs; ndrange=length(inputs))
6060
```
6161
6262
The internal index used is `@index(Global)` as provided by KernelAbstractions. For more details, please refer to the documentation of KernelAbstractions.jl.

test/gpu/fibonacci.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ function barrier(fib::Fibonacci, backend::Backend, type::Type, size::Int)
1515
dag = graph(fib)
1616
k = kernel(dag, fib, @__MODULE__)
1717

18-
rand_inputs = [(rand(type), rand(type)) for i in 1:size]
18+
rand_inputs = [(rand(type), rand(type)) for _ in 1:size]
1919

2020
in = allocate(backend, Tuple{type, type}, size)
2121
out = allocate(backend, type, size)
2222

2323
copyto!(in, rand_inputs)
2424

25-
k(backend, 32)(in, out; ndrange = length(in))
25+
k(backend, 32)(out, in; ndrange = length(in))
2626

2727
gt_out = fib_gt.(fib.n, getindex.(rand_inputs, 1), getindex.(rand_inputs, 2))
2828
return @test count(isapprox.(Vector(out), gt_out)) == size

0 commit comments

Comments
 (0)