added operator tests. single value operators not working yet
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:
2024-08-25 13:01:58 +02:00
parent 929789b6ff
commit 6a1811ae6b
3 changed files with 83 additions and 28 deletions

View File

@ -21,7 +21,8 @@ function expr_to_postfix(expr::Expr)::PostfixType
postfix = PostfixType()
operator = get_operator(expr.args[1])
# push!(postfix, expr.args[2], expr.args[3], operator)
# TODO: Add suppport for single value operators like "abs(x)"
for j in 2:length(expr.args)
arg = expr.args[j]
if typeof(arg) === Expr
@ -80,13 +81,13 @@ function convert_var_to_int(var::Symbol)::Int
end
function convert_to_ExpressionElement(element)::ExpressionElement
Value = reinterpret(Int64, element)
value = reinterpret(Int64, element)
if element isa Float64
return ExpressionElement(FLOAT64, Value)
return ExpressionElement(FLOAT64, value)
elseif element isa Int64
return ExpressionElement(INDEX, Value)
return ExpressionElement(INDEX, value)
elseif element isa Operator
return ExpressionElement(OPERATOR, Value)
return ExpressionElement(OPERATOR, value)
else
error("Element was of type '$(typeof(element))', which is not supported.")
end

View File

@ -20,7 +20,7 @@ function interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variab
cudaStepsize = CuArray([get_max_inner_length(expressions), get_max_inner_length(parameters), size(variables, 1)]) # max num of values per expression; max nam of parameters per expression; number of variables per expression
# each expression has nr. of variable sets (nr. of columns of the variables) results and there are n expressions
cudaResults = CuArray{Float64}(undef, length(expressions), variableCols)
cudaResults = CuArray{Float64}(undef, variableCols, length(expressions))
# Start kernel for each expression to ensure that no warp is working on different expressions
for i in eachindex(expressions)
@ -33,8 +33,6 @@ function interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variab
end
# TODO: Wait for all the kernels to finish to return the result
# return cudaResults
println(cudaResults)
return cudaResults
end
@ -53,8 +51,6 @@ function interpret_expression(expressions::CuDeviceArray{ExpressionElement}, var
operationStack = MVector{MAX_STACK_SIZE, Float64}(undef) # Try to get this to function with variable size too, to allow better memory usage
operationStackTop = 0 # stores index of the last defined/valid value
# return
for setIndex in index:stride
firstVariableIndex = ((setIndex - 1) * stepsize[3]) # Exclusive
@ -76,7 +72,7 @@ function interpret_expression(expressions::CuDeviceArray{ExpressionElement}, var
operationStack[operationStackTop] = reinterpret(Float64, expressions[i].Value)
elseif expressions[i].Type == OPERATOR
# TODO Maybe put this in seperate function
type = expressions[i].Type
type = reinterpret(Operator, expressions[i].Value)
if type == ADD
operationStackTop -= 1
operationStack[operationStackTop] = operationStack[operationStackTop] + operationStack[operationStackTop + 1]