benchmarking: updated transpiler to drastically reduce the number of transpilations at the expense of memory usage
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:
@ -49,19 +49,26 @@ end
|
||||
# Convert Expressions to PTX Code and execute that instead
|
||||
function evaluate_gpu(expressions::Vector{Expr}, X::Matrix{Float32}, p::Vector{Vector{Float32}}; repetitions=1)::Matrix{Float32}
|
||||
@assert axes(expressions) == axes(p)
|
||||
variableCols = size(X, 2)
|
||||
variableRows = size(X, 1)
|
||||
numVariableSets = size(X, 2) # nr. of columns of X
|
||||
variableSetSize = size(X, 1) # nr. of rows of X
|
||||
|
||||
variables = CuArray(X)
|
||||
|
||||
exprs = Vector{ExpressionProcessing.PostfixType}(undef, length(expressions))
|
||||
largestParameterSetSize = Utils.get_max_inner_length(p) # parameters get transformed into matrix. Will be nr. of rows in parameter matrix
|
||||
|
||||
compiledKernels = Vector{CuFunction}(undef, length(expressions))
|
||||
kernelName = "evaluate_gpu"
|
||||
@inbounds Threads.@threads for i in eachindex(expressions)
|
||||
exprs[i] = ExpressionProcessing.expr_to_postfix(expressions[i])
|
||||
ex = ExpressionProcessing.expr_to_postfix(expressions[i])
|
||||
ptxKernel = Transpiler.transpile(ex, variableSetSize, largestParameterSetSize, numVariableSets, i-1, kernelName) # i-1 because julia is 1-based but PTX needs 0-based indexing
|
||||
compiledKernels[i] = Transpiler.CompileKernel(ptxKernel, kernelName)
|
||||
end
|
||||
|
||||
results = Matrix{Float32}(undef, variableCols, length(exprs))
|
||||
results = Matrix{Float32}(undef, numVariableSets, length(exprs))
|
||||
for i in 1:repetitions # Simulate parameter tuning -> local search (X remains the same, p gets changed in small steps and must be performed sequentially, which it is with this impl)
|
||||
results = Transpiler.evaluate(exprs, variables, variableCols, variableRows, p)
|
||||
# evaluate
|
||||
# results = Transpiler.evaluate(exprs, variables, numVariableSets, variableSetSize, p)
|
||||
results = Transpiler.evaluate(compiledKernels, variables, variableSetSize, p)
|
||||
end
|
||||
|
||||
return results
|
||||
@ -103,7 +110,6 @@ function interpret_cpu(exprs::Vector{Expr}, X::Matrix{Float32}, p::Vector{Vector
|
||||
res
|
||||
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 --- WRONG
|
||||
|
Reference in New Issue
Block a user