tried storing data in CuArray. Weird type error is happening
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled
This commit is contained in:
@ -1,34 +1,35 @@
|
||||
module Interpreter
|
||||
using CUDA
|
||||
include("ExpressionProcessing.jl")
|
||||
using .ExpressionProcessing: PostfixType, Add, Subtract, Operator
|
||||
|
||||
export Interpret
|
||||
export CudaTest
|
||||
|
||||
@enum Operators Add=1 Subtract=2 Multiply=3 Division=4 Power=5 Abs=6 Log=7 Exp=8 Sqrt=9
|
||||
|
||||
function CudaTest()
|
||||
N = 2^20
|
||||
x = CUDA.fill(1.0f0, N)
|
||||
y = CUDA.fill(2.0f0, N)
|
||||
|
||||
kernelAdd = @cuda launch=false InterpretExplicit!(Add, x, y)
|
||||
kernelAdd = @cuda launch=false InterpretExplicit!(ExpressionProcessing.Add, x, y)
|
||||
# kernelAdd = @cuda launch=false InterpretExplicit!(Add, x, y, reference)
|
||||
config = launch_configuration(kernelAdd.fun)
|
||||
threads = min(length(y), config.threads)
|
||||
blocks = cld(length(y), threads)
|
||||
|
||||
kernelAdd(Add, x, y; threads, blocks)
|
||||
println(y[1])
|
||||
# println(y[1])
|
||||
# @test all(Array(y) .== 3.0f0)
|
||||
|
||||
kernelSubtract = @cuda launch=false InterpretExplicit!(Subtract, x, y)
|
||||
kernelSubtract = @cuda launch=false InterpretExplicit!(ExpressionProcessing.Subtract, x, y)
|
||||
configSub = launch_configuration(kernelSubtract.fun)
|
||||
threadsSub = min(length(y), configSub.threads)
|
||||
blocksSub = cld(length(y), threadsSub)
|
||||
CUDA.fill!(y, 2.0f0)
|
||||
|
||||
kernelSubtract(Subtract, x, y; threadsSub, blocksSub)
|
||||
# kernelSubtract(Subtract, x, y; threadsSub, blocksSub)
|
||||
# @test all(Array(y) .== -1.0f0)
|
||||
println(y[1])
|
||||
# println(y[1])
|
||||
end
|
||||
|
||||
"Interprets the given expressions with the values provided.
|
||||
@ -42,22 +43,27 @@ function Interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variab
|
||||
# create CUDA array and fill it with the expressions, variables and parameters
|
||||
# calculate needed number of threads, probably based off of the number of expressions, so I can ensure each warp takes the same execution path
|
||||
# Start the kernel
|
||||
cudaExprs = Vector{CuArray{ExpressionProcessing.PostfixType}}(undef, length(expressions))
|
||||
for i in eachindex(expressions)
|
||||
push!(cudaExprs, CuArray(expressions[i]))
|
||||
end
|
||||
# cudaExprs = CuArray(copy(expressions))
|
||||
end
|
||||
|
||||
|
||||
# Kernel
|
||||
function InterpretExplicit!(op::Operators, x, y)
|
||||
function InterpretExplicit!(op::Operator, x, y)
|
||||
index = (blockIdx().x - 1) * blockDim().x + threadIdx().x
|
||||
stride = gridDim().x * blockDim().x
|
||||
|
||||
if op == Add
|
||||
@cuprintln("Performing Addition") # Will only be displayed when the GPU is synchronized
|
||||
# @cuprintln("Performing Addition") # Will only be displayed when the GPU is synchronized
|
||||
for i = index:stride:length(y)
|
||||
@inbounds y[i] += x[i]
|
||||
end
|
||||
return
|
||||
elseif op == Subtract
|
||||
@cuprintln("Performing Subtraction") # Will only be displayed when the GPU is synchronized
|
||||
# @cuprintln("Performing Subtraction") # Will only be displayed when the GPU is synchronized
|
||||
for i = index:stride:length(y)
|
||||
@inbounds y[i] -= x[i]
|
||||
end
|
||||
|
Reference in New Issue
Block a user