Prepared for Cuda execution
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:
Daniel 2024-07-12 16:35:30 +02:00
parent 59b1d77ad6
commit d4f9156c08
3 changed files with 21 additions and 5 deletions

View File

@ -17,7 +17,7 @@ export test
# Evaluate Expressions on the GPU # Evaluate Expressions on the GPU
function interpret_gpu(exprs::Vector{Expr}, X::Matrix{Float64}, p::Vector{Vector{Float64}})::Matrix{Float64} 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" # Ensure that no two expressions are interpreted in the same "warp"
expr1 = exprs[1] exprsPostfix = ExpressionProcessing.expr_to_postfix(exprs[1])
end end
# Convert Expressions to PTX Code and execute that instead # Convert Expressions to PTX Code and execute that instead

View File

@ -4,17 +4,19 @@ export construct_symtable
export replace_variables! export replace_variables!
export expr_to_postfix export expr_to_postfix
export SymbolTable64 export SymbolTable64
export PostfixType
const SymbolTable64 = Dict{Tuple{Expr, Symbol},Float64} const SymbolTable64 = Dict{Tuple{Expr, Symbol},Float64}
const PostfixType = Array{Union{Float64,String},1}
# Maybe switch from Array{String} to Array{Union{Float64, Symbol}}? # Maybe switch from Array{String} to Array{Union{Float64, Symbol}}?
function expr_to_postfix(expr::Expr)::Array{Union{Float64,String}} function expr_to_postfix(expr::Expr)::PostfixType
postfix = Array{Union{Float64,String},1}() postfix = PostfixType()
operator = String(expr.args[1]) operator = String(expr.args[1])
# push!(postfix, expr.args[2], expr.args[3], operator) # push!(postfix, expr.args[2], expr.args[3], operator)
for i in 2:length(expr.args) for j in 2:length(expr.args)
arg = expr.args[i] arg = expr.args[j]
if typeof(arg) === Expr if typeof(arg) === Expr
append!(postfix, expr_to_postfix(arg)) append!(postfix, expr_to_postfix(arg))
elseif typeof(arg) === Symbol elseif typeof(arg) === Symbol

View File

@ -1,5 +1,6 @@
module Interpreter module Interpreter
using CUDA using CUDA
include("ExpressionProcessing.jl")
export CudaTest export CudaTest
@ -30,6 +31,19 @@ function CudaTest()
println(y[1]) println(y[1])
end 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 # Kernel
function InterpretExplicit!(op::Operators, x, y) function InterpretExplicit!(op::Operators, x, y)