diff --git a/package/src/ExpressionExecutorCuda.jl b/package/src/ExpressionExecutorCuda.jl index 4c68111..5c6a32b 100644 --- a/package/src/ExpressionExecutorCuda.jl +++ b/package/src/ExpressionExecutorCuda.jl @@ -17,7 +17,7 @@ export test # Evaluate Expressions on the GPU function interpret_gpu(exprs::Vector{Expr}, X::Matrix{Float64}, p::Vector{Vector{Float64}})::Matrix{Float64} # Ensure that no two expressions are interpreted in the same "warp" - expr1 = exprs[1] + exprsPostfix = ExpressionProcessing.expr_to_postfix(exprs[1]) end # Convert Expressions to PTX Code and execute that instead diff --git a/package/src/ExpressionProcessing.jl b/package/src/ExpressionProcessing.jl index 7a379d9..a78fc4c 100644 --- a/package/src/ExpressionProcessing.jl +++ b/package/src/ExpressionProcessing.jl @@ -4,17 +4,19 @@ export construct_symtable export replace_variables! export expr_to_postfix export SymbolTable64 +export PostfixType const SymbolTable64 = Dict{Tuple{Expr, Symbol},Float64} +const PostfixType = Array{Union{Float64,String},1} # Maybe switch from Array{String} to Array{Union{Float64, Symbol}}? -function expr_to_postfix(expr::Expr)::Array{Union{Float64,String}} - postfix = Array{Union{Float64,String},1}() +function expr_to_postfix(expr::Expr)::PostfixType + postfix = PostfixType() operator = String(expr.args[1]) # push!(postfix, expr.args[2], expr.args[3], operator) - for i in 2:length(expr.args) - arg = expr.args[i] + for j in 2:length(expr.args) + arg = expr.args[j] if typeof(arg) === Expr append!(postfix, expr_to_postfix(arg)) elseif typeof(arg) === Symbol diff --git a/package/src/Interpreter.jl b/package/src/Interpreter.jl index 926db9c..77fe650 100644 --- a/package/src/Interpreter.jl +++ b/package/src/Interpreter.jl @@ -1,5 +1,6 @@ module Interpreter using CUDA +include("ExpressionProcessing.jl") export CudaTest @@ -30,6 +31,19 @@ function CudaTest() println(y[1]) end +"Interprets the given expressions with the values provided. +# Arguments + - expressions::Vector{ExpressionProcessing.PostfixType} : The expressions to execute in postfix form + - variables::Matrix{Float64} : The variables to use. Each column is mapped to the variables x1..xn + - parameters::Vector{Vector{Float64}} : The parameters to use. Each Vector contains the values for the parameters p1..pn. The number of parameters can be different for every expression +" +function Interpret(expressions::Vector{ExpressionProcessing.PostfixType}, variables::Matrix{Float64}, parameters::Vector{Vector{Float64}}) + # TODO: + # 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 +end + # Kernel function InterpretExplicit!(op::Operators, x, y)