Update PlainStream with context
This commit is contained in:
parent
a26699c5b5
commit
bb271dd046
@ -1,17 +1,28 @@
|
|||||||
include("Stream.jl")
|
include("Stream.jl")
|
||||||
|
|
||||||
function devices()
|
function devices()::Vector{DeviceWithRepr}
|
||||||
return ["CPU"]
|
return [(undef, "CPU", "Palin")]
|
||||||
end
|
end
|
||||||
|
|
||||||
function make_stream(arraysize::Int, scalar::T, device::Int, silent::Bool)::VectorData{T} where {T}
|
function make_stream(
|
||||||
if device != 1
|
arraysize::Int,
|
||||||
error("Only CPU device is supported")
|
scalar::T,
|
||||||
end
|
_::DeviceWithRepr,
|
||||||
return VectorData{T}(1:arraysize, 1:arraysize, 1:arraysize, scalar, arraysize)
|
silent::Bool,
|
||||||
|
)::Tuple{VectorData{T},Nothing} where {T}
|
||||||
|
return (
|
||||||
|
VectorData{T}(
|
||||||
|
Vector{T}(undef, arraysize),
|
||||||
|
Vector{T}(undef, arraysize),
|
||||||
|
Vector{T}(undef, arraysize),
|
||||||
|
scalar,
|
||||||
|
arraysize,
|
||||||
|
),
|
||||||
|
nothing
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function init_arrays!(data::VectorData{T}, init::Tuple{T,T,T}) where {T}
|
function init_arrays!(data::VectorData{T}, _, init::Tuple{T,T,T}) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.a[i] = init[1]
|
@inbounds data.a[i] = init[1]
|
||||||
@inbounds data.b[i] = init[2]
|
@inbounds data.b[i] = init[2]
|
||||||
@ -19,37 +30,37 @@ function init_arrays!(data::VectorData{T}, init::Tuple{T,T,T}) where {T}
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function copy!(data::VectorData{T}) where {T}
|
function copy!(data::VectorData{T}, _) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.c[i] = data.a[i]
|
@inbounds data.c[i] = data.a[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mul!(data::VectorData{T}) where {T}
|
function mul!(data::VectorData{T}, _) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.b[i] = data.scalar * data.c[i]
|
@inbounds data.b[i] = data.scalar * data.c[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function add!(data::VectorData{T}) where {T}
|
function add!(data::VectorData{T}, _) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.c[i] = data.a[i] + data.b[i]
|
@inbounds data.c[i] = data.a[i] + data.b[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function triad!(data::VectorData{T}) where {T}
|
function triad!(data::VectorData{T}, _) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.a[i] = data.b[i] + (data.scalar * data.c[i])
|
@inbounds data.a[i] = data.b[i] + (data.scalar * data.c[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function nstream!(data::VectorData{T}) where {T}
|
function nstream!(data::VectorData{T}, _) where {T}
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds data.a[i] += data.b[i] + data.scalar * data.c[i]
|
@inbounds data.a[i] += data.b[i] + data.scalar * data.c[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function dot(data::VectorData{T}) where {T}
|
function dot(data::VectorData{T}, _) where {T}
|
||||||
sum = zero(T)
|
sum = zero(T)
|
||||||
for i = 1:data.size
|
for i = 1:data.size
|
||||||
@inbounds sum += data.a[i] * data.b[i]
|
@inbounds sum += data.a[i] * data.b[i]
|
||||||
@ -57,7 +68,7 @@ function dot(data::VectorData{T}) where {T}
|
|||||||
return sum
|
return sum
|
||||||
end
|
end
|
||||||
|
|
||||||
function read_data(data::VectorData{T})::VectorData{T} where {T}
|
function read_data(data::VectorData{T}, _)::VectorData{T} where {T}
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user