Commit 2026272f authored by Rémi's avatar Rémi
Browse files

Update benchmarks

parent 9560e429
using CPLEX
using Gurobi
using MATLAB
using Polynomials
using JuMP
......@@ -11,7 +11,7 @@ using Plots
# include("../src/jIIR2AG/src/jIIR2AG.jl")
# using .jIIR2AG
# include("../../src/includepkg.jl")
using AdderGraph
using AdderGraphs
using jIIR2AG
using jMCM
using jIIR2HW
......@@ -32,7 +32,7 @@ function one_step_method(instance; verbose::Bool=true)
fbands = [passband, stopband]
abands = [(1-deltapass, 1+deltapass), (0.0, deltastop)]
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
if wordlength >= 10
if wordlength >= 12
......@@ -155,10 +155,10 @@ function truncate_all(b0_init::Float64, b1_init::Float64, b2_init::Float64,
println("MCM for $instancename -- $wordlength")
@time begin
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
solution_b = mcm(model, [b0, b1, b2], wordlength=wordlength, use_nlp=false, ilp=1, use_big_m=true, avoid_internal_shifts = true)
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
solution_a = mcm(model, [a1, a2], wordlength=wordlength, use_nlp=false, ilp=1, use_big_m=true, avoid_internal_shifts = true)
end # @time begin
......@@ -282,10 +282,10 @@ function truncate(b0_init::Float64, b1_init::Float64, b2_init::Float64,
println("MCM for $instancename -- $wordlength --- varepsilon: $varepsilon")
@time begin
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
solution_b = mcm(model, [b0, b1, b2], wordlength=wordlength, use_nlp=false, ilp=1, use_big_m=true, avoid_internal_shifts = true)
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
solution_a = mcm(model, [a1, a2], wordlength=wordlength, use_nlp=false, ilp=1, use_big_m=true, avoid_internal_shifts = true)
end # @time begin
......@@ -601,7 +601,7 @@ function get_all_solutions()
fbands = [passband, stopband]
abands = [(1-deltapass, 1+deltapass), (0.0, deltastop)]
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
if wordlength >= 10
if wordlength >= 12
......@@ -830,9 +830,9 @@ function compute_all_mcm()
for solution in solutions
coefs_a = sort(collect(solution[1]))
coefs_b = sort(collect(solution[2]))
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
mcma = get!(mcm_values, (0, coefs_a[1], coefs_a[2]), length(mcm(model, coefs_a, avoid_internal_shifts=true)))
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
mcmb = get!(mcm_values, (coefs_b[1], coefs_b[2], coefs_b[3]), length(mcm(model, coefs_b, avoid_internal_shifts=true)))
write(io, "$(solution[1][1]);$(solution[1][2]);$(solution[2][1]);$(solution[2][2]);$(solution[2][3]);$(solution[3]);$(solution[4]);$(mcma);$(mcmb)\n")
end
......@@ -932,7 +932,7 @@ function plot_wcpg()
fbands = [passband, stopband]
abands = [(1-deltapass, 1+deltapass), (0.0, deltastop)]
for wordlength in wordlengths
model = Model(CPLEX.Optimizer)
model = Model(Gurobi.Optimizer)
set_silent(model)
if wordlength >= 10
if wordlength >= 12
......
......@@ -44,8 +44,8 @@ function write_flopoco_solution_shiftandadd(solution::Iir2AdderGraphs, instance:
write(io, "coeffa=\"$(solution.coefficients_a[1]):$(solution.coefficients_a[2])\" ")
write(io, "coeffb=\"$(solution.coefficients_b[1]):$(solution.coefficients_b[2]):$(solution.coefficients_b[3])\" ")
write(io, "shifta=$(solution.shifts[1]) shiftb=$(solution.shifts[2]) ")
write(io, "graphb=\"$(produce_adder_graph_with_output_string(solution.addergraph_b, solution.coefficients_b))\" ")
write(io, "grapha=\"$(produce_adder_graph_with_output_string(solution.addergraph_a, solution.coefficients_a))\" ")
write(io, "graphb=\"$(write_addergraph(solution.addergraph_b))\" ")
write(io, "grapha=\"$(write_addergraph(solution.addergraph_a))\" ")
write(io, "method=\"multiplierless\" ")
write(io, "outputFile=$(instance)_dw$(abs(lsbin) < 10 ? "0" : "")$(abs(lsbin))_cw$(wordlength < 10 ? "0" : "")$(wordlength)_shiftandadd.vhd")
if wcpg_val != 0 || wcpg_eps_val != 0
......@@ -90,8 +90,8 @@ function write_flopoco_solution_shiftandadd(solution::Vector{Any}, instance::Str
write(io, "coeffa=\"$(solution[1][1]):$(solution[1][2])\" ")
write(io, "coeffb=\"$(solution[2][1]):$(solution[2][2]):$(solution[2][3])\" ")
write(io, "shifta=$(shifta) shiftb=$(shiftb) ")
write(io, "graphb=\"$(produce_adder_graph_with_output_string(solution[4], solution[2]))\" ")
write(io, "grapha=\"$(produce_adder_graph_with_output_string(solution[3], solution[1]))\" ")
write(io, "graphb=\"$(write_addergraph(solution[4]))\" ")
write(io, "grapha=\"$(write_addergraph(solution[3]))\" ")
write(io, "method=\"multiplierless\" ")
write(io, "outputFile=$(instance)_dw$(abs(lsbin) < 10 ? "0" : "")$(abs(lsbin))_cw$(wordlength < 10 ? "0" : "")$(wordlength)_truncatedshiftandadd.vhd\n")
end
......@@ -160,60 +160,6 @@ end
################################################################################
function produce_adder_graph_with_output_string(addergraph, coefficients)
depth_by_value = Dict([1 => 0])
maximum_depth = 0
for addernode in addergraph.constants
depth_by_value[addernode.value] = max(depth_by_value[addernode.inputs[1]], depth_by_value[addernode.inputs[2]])+1
if depth_by_value[addernode.value] > maximum_depth
maximum_depth = depth_by_value[addernode.value]
end
end
output_values = Vector{Int}()
adderstring = "{"
firstcoefnocomma = true
for coefind in 1:length(coefficients)
coef = coefficients[coefind]
if coef != 0
value = odd(abs(coef))
if !(abs(coef) in output_values)
push!(output_values, abs(coef))
shift = round(Int, log2(abs(coef)/value))
if !firstcoefnocomma
adderstring *= ","
else
firstcoefnocomma = false
end
adderstring *= "{'O',[$(abs(coef))],$(maximum_depth+1),[$(value)],$(depth_by_value[value]),$(shift)}"
end
end
end
if !isempty(addergraph.constants)
adderstring *= ","
end
for addernodeind in length(addergraph.constants):-1:1
addernode = addergraph.constants[addernodeind]
subtractfirst = ""
subtractsecond = ""
if addernode.subtraction[1]
subtractfirst = "-"
elseif addernode.subtraction[2]
subtractsecond = "-"
end
adderstring *= "{'A',[$(addernode.value)],$(depth_by_value[addernode.value]),[$(subtractfirst)$(addernode.inputs[1])],$(depth_by_value[addernode.inputs[1]]),$(addernode.input_shifts[1]),[$(subtractsecond)$(addernode.inputs[2])],$(depth_by_value[addernode.inputs[2]]),$(addernode.input_shifts[2])}"
if addernodeind != 1
adderstring *= ","
end
end
adderstring *= "}"
return adderstring
end
################################################################################
function write_rpag_calls(instancename::String, b0, b1, b2, a1, a2, wordlength, varepsilon, shifta, shiftb)
filename = rpagcalls_base_name*"truncated_calls.csv"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment