added tests but need to do rewrites. focus on GPU execution for now
Some checks are pending
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Waiting to run
Some checks are pending
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Waiting to run
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
module ExpressionExecutorCuda
|
||||
include("Interpreter.jl")
|
||||
include("ExpressionProcessing.jl")
|
||||
|
||||
export interpret_gpu
|
||||
export evaluate_gpu
|
||||
export test
|
||||
|
||||
const SymbolTable64 = Dict{Tuple{Expr, Symbol},Float64}
|
||||
# const SymbolTable64 = Dict{Tuple{Expr, Symbol},Float64}
|
||||
#
|
||||
# Some assertions:
|
||||
# Variables and parameters start their naming with "1" meaning the first variable/parameter has to be "x1/p1" and not "x0/p0"
|
||||
@ -40,60 +41,18 @@ end
|
||||
- It replaces every variable with the according value stored in X and p.
|
||||
- It transforms the expressions into postfix form and returns them.
|
||||
"
|
||||
function preprocess_expressions!(exprs::Vector{Expr}, X::Matrix{Float64}, p::Vector{Vector{Float64}})::Vector{String}
|
||||
symtable = construct_symtable(exprs, X, p)
|
||||
postfixExpressions =
|
||||
function preprocess_expressions!(exprs::Vector{Expr}, X::Matrix{Float64}, p::Vector{Vector{Float64}})::Array{String}
|
||||
symtable = ExpressionProcessing.construct_symtable(exprs, X, p)
|
||||
postfixExpressions = Array{String,1}()
|
||||
|
||||
# Test if multi threading provides a speedup and if it does, roughly determin the size at which it is beneficial.
|
||||
for i in eachindex(exprs)
|
||||
replace_variables!(exprs[i], symtable)
|
||||
expr = deepcopy(exprs[i])
|
||||
ExpressionProcessing.replace_variables!(exprs[i], symtable, expr)
|
||||
push!(postfixExpressions, ExpressionProcessing.expr_to_postfix(exprs[i]))
|
||||
end
|
||||
|
||||
return expr_to_postfix()
|
||||
end
|
||||
|
||||
function expr_to_postfix()::Array{String}
|
||||
# TODO
|
||||
end
|
||||
|
||||
# Probaly move the below function into another module
|
||||
|
||||
"Replaces all the variables and parameters of the given expression with their corresponding value stored in the symtable"
|
||||
function replace_variables!(ex::Expr, symtable::SymbolTable64)
|
||||
for i in 1:length(ex.args)
|
||||
arg = ex.args[i]
|
||||
if typeof(arg) === Expr
|
||||
replace_variables!(ex, symtable)
|
||||
elseif haskey(symtable, (ex,arg)) # We found a variable/parameter and can replace it with the actual value
|
||||
ex.args[i] = symtable[(ex,arg)]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function construct_symtable(expressions::Vector{Expr}, mat::Matrix{Float64}, params::Vector{Vector{Float64}})::SymbolTable64
|
||||
symtable = SymbolTable64()
|
||||
|
||||
for i in eachindex(expressions)
|
||||
expr = expressions[i]
|
||||
values = mat[:,i]
|
||||
parameters = params[i]
|
||||
|
||||
fill_symtable!(expr, symtable, values, "x")
|
||||
fill_symtable!(expr, symtable, parameters, "p")
|
||||
end
|
||||
|
||||
return symtable
|
||||
end
|
||||
|
||||
function fill_symtable!(expr::Expr, symtable::SymbolTable64, values::Vector{Float64}, symbolPrefix::String)
|
||||
varIndex = 1
|
||||
for j in eachindex(values)
|
||||
val = values[j]
|
||||
sym = Symbol(symbolPrefix, varIndex)
|
||||
|
||||
symtable[expr,sym] = val
|
||||
varIndex += 1
|
||||
end
|
||||
return postfixExpressions
|
||||
end
|
||||
|
||||
end
|
||||
@ -102,7 +61,8 @@ end
|
||||
|
||||
# Flow
|
||||
# input: Vector expr == expressions contains eg. 4 expressions
|
||||
# Matrix X == |expr| columns, n rows. n == number of variabls x1..xn; n is the same for all expressions
|
||||
# Matrix X == |expr| columns, n rows. n == number of variabls x1..xn; n is the same for all expressions --- WRONG
|
||||
# Matrix X == k columns, n rows. k == number of variables in the expressions (every expression must have the same number of variables); n == number of different values for xk where k is the column
|
||||
# VectorVector p == vector size |expr| containing vector size m. m == number of parameters per expression. p can be different for each expression
|
||||
#
|
||||
# The following can be done on the CPU
|
||||
|
Reference in New Issue
Block a user