33 lines
960 B
Julia
33 lines
960 B
Julia
|
using CUDA
|
||
|
using .ExpressionProcessing
|
||
|
using .Transpiler
|
||
|
|
||
|
expressions = Vector{Expr}(undef, 2)
|
||
|
variables = Matrix{Float64}(undef, 2,2)
|
||
|
parameters = Vector{Vector{Float64}}(undef, 2)
|
||
|
|
||
|
# Resulting value should be 10 for the first expression
|
||
|
expressions[1] = :(x1 + 1 * x2 + p1)
|
||
|
expressions[2] = :(5 + x1 + 1 * x2 + p1 + p2)
|
||
|
variables[1,1] = 2.0
|
||
|
variables[2,1] = 3.0
|
||
|
variables[1,2] = 0.0
|
||
|
variables[2,2] = 5.0
|
||
|
parameters[1] = Vector{Float64}(undef, 1)
|
||
|
parameters[2] = Vector{Float64}(undef, 2)
|
||
|
parameters[1][1] = 5.0
|
||
|
parameters[2][1] = 5.0
|
||
|
parameters[2][2] = 0.0
|
||
|
|
||
|
|
||
|
@testset "Test TMP transpiler" begin
|
||
|
postfixExpr = expr_to_postfix(expressions[1])
|
||
|
postfixExprs = Vector([postfixExpr])
|
||
|
push!(postfixExprs, expr_to_postfix(expressions[2]))
|
||
|
|
||
|
Transpiler.transpile(postfixExpr)
|
||
|
# CUDA.@sync interpret(postfixExprs, variables, parameters)
|
||
|
end
|
||
|
|
||
|
#TODO: test performance of transpiler PTX generation when doing "return String(take!(buffer))" vs "return take!(buffer)"
|