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