include("aux_func.jl") using LinearAlgebra using Statistics using PlotlyJS #using HDF5 folder = "ini_exp_data/" # Getting the BCNN double precision data dp_bcnn = read("$(folder)dp_bcnn.txt", String); dp_bcnn = split(dp_bcnn, "\n") bool_all = occursin.(r"smsp", dp_bcnn) dp_bcnn_all = dp_bcnn[bool_all] dp_bcnn_all = strip.(dp_bcnn_all) bool_add = occursin.(r"dadd", dp_bcnn_all) dp_bcnn_add = dp_bcnn_all[bool_add] dp_bcnn_add = split.(dp_bcnn_add, " ") dp_bcnn_add = filter.(x -> x != "", dp_bcnn_add) temp = [] for arr in dp_bcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_bcnn_add = temp[:] bool_fma = occursin.(r"dfma", dp_bcnn_all) dp_bcnn_fma = dp_bcnn_all[bool_fma] dp_bcnn_fma = split.(dp_bcnn_fma, " ") dp_bcnn_fma = filter.(x -> x != "", dp_bcnn_fma) temp = [] for arr in dp_bcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_bcnn_fma = temp[:] bool_mul = occursin.(r"dmul", dp_bcnn_all) dp_bcnn_mul = dp_bcnn_all[bool_mul] dp_bcnn_mul = split.(dp_bcnn_mul, " ") dp_bcnn_mul = filter.(x -> x != "", dp_bcnn_mul) temp = [] for arr in dp_bcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_bcnn_mul = temp[:] #println("Total bcnn double precision FLOPS: $(sum(dp_bcnn_fma)*2 + sum(dp_bcnn_add) + sum(dp_bcnn_mul))") # Getting the BCNN half precision data hp_bcnn = read("$(folder)hp_bcnn.txt", String); hp_bcnn = split(hp_bcnn, "\n") bool_all = occursin.(r"smsp", hp_bcnn) hp_bcnn_all = hp_bcnn[bool_all] hp_bcnn_all = strip.(hp_bcnn_all) bool_add = occursin.(r"hadd", hp_bcnn_all) hp_bcnn_add = hp_bcnn_all[bool_add] hp_bcnn_add = split.(hp_bcnn_add, " ") hp_bcnn_add = filter.(x -> x != "", hp_bcnn_add) temp = [] for arr in hp_bcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_bcnn_add = temp[:] bool_fma = occursin.(r"hfma", hp_bcnn_all) hp_bcnn_fma = hp_bcnn_all[bool_fma] hp_bcnn_fma = split.(hp_bcnn_fma, " ") hp_bcnn_fma = filter.(x -> x != "", hp_bcnn_fma) temp = [] for arr in hp_bcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_bcnn_fma = temp[:] bool_mul = occursin.(r"hmul", hp_bcnn_all) hp_bcnn_mul = hp_bcnn_all[bool_mul] hp_bcnn_mul = split.(hp_bcnn_mul, " ") hp_bcnn_mul = filter.(x -> x != "", hp_bcnn_mul) temp = [] for arr in hp_bcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_bcnn_mul = temp[:] #println("Total bcnn half precision FLOPS: $(sum(hp_bcnn_fma)*2 + sum(hp_bcnn_add) + sum(hp_bcnn_mul))") # Getting the BCNN single precision data sp_bcnn = read("$(folder)sp_bcnn.txt", String); sp_bcnn = split(sp_bcnn, "\n") bool_all = occursin.(r"smsp", sp_bcnn) sp_bcnn_all = sp_bcnn[bool_all] sp_bcnn_all = strip.(sp_bcnn_all) bool_add = occursin.(r"fadd", sp_bcnn_all) sp_bcnn_add = sp_bcnn_all[bool_add] sp_bcnn_add = split.(sp_bcnn_add, " ") sp_bcnn_add = filter.(x -> x != "", sp_bcnn_add) temp = [] for arr in sp_bcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_bcnn_add = temp[:] bool_fma = occursin.(r"ffma", sp_bcnn_all) sp_bcnn_fma = sp_bcnn_all[bool_fma] sp_bcnn_fma = split.(sp_bcnn_fma, " ") sp_bcnn_fma = filter.(x -> x != "", sp_bcnn_fma) temp = [] for arr in sp_bcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_bcnn_fma = temp[:] bool_mul = occursin.(r"fmul", sp_bcnn_all) sp_bcnn_mul = sp_bcnn_all[bool_mul] sp_bcnn_mul = split.(sp_bcnn_mul, " ") sp_bcnn_mul = filter.(x -> x != "", sp_bcnn_mul) temp = [] for arr in sp_bcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_bcnn_mul = temp[:] #println("Total bcnn single precision FLOPS: $(sum(sp_bcnn_fma)*2 + sum(sp_bcnn_add) + sum(sp_bcnn_mul))") # Getting the BCNN memory data mem_bcnn = read("$(folder)memrw_bcnn.txt", String); mem_bcnn = split(mem_bcnn, "\n") bool_all = occursin.(r"dram", mem_bcnn) mem_bcnn_all = mem_bcnn[bool_all] mem_bcnn_all = strip.(mem_bcnn_all) bool_read = occursin.(r"read", mem_bcnn_all) mem_bcnn_read = mem_bcnn_all[bool_read] mem_bcnn_read = split.(mem_bcnn_read, " ") mem_bcnn_read = filter.(x -> x != "", mem_bcnn_read) bool_write = occursin.(r"write", mem_bcnn_all) mem_bcnn_write = mem_bcnn_all[bool_write] mem_bcnn_write = split.(mem_bcnn_write, " ") mem_bcnn_write = filter.(x -> x != "", mem_bcnn_write) mem_bcnn_read = converttobyte(mem_bcnn_read) mem_bcnn_write = converttobyte(mem_bcnn_write) #println("Total BCNN memory writes $(sum(mem_bcnn_write)/1048576.0) Mb") #println("Total BCNN memory reads $(sum(mem_bcnn_read)/1048576.0) Mb") # Getting the CIFAR BCNN memory data cif_mem_bcnn = read("$(folder)cif_memrw_bcnn.txt", String); cif_mem_bcnn = split(cif_mem_bcnn, "\n") cif_bool_all = occursin.(r"dram", cif_mem_bcnn) cif_mem_bcnn_all = cif_mem_bcnn[cif_bool_all] cif_mem_bcnn_all = strip.(cif_mem_bcnn_all) cif_bool_read = occursin.(r"read", cif_mem_bcnn_all) cif_mem_bcnn_read = cif_mem_bcnn_all[cif_bool_read] cif_mem_bcnn_read = split.(cif_mem_bcnn_read, " ") cif_mem_bcnn_read = filter.(x -> x != "", cif_mem_bcnn_read) cif_bool_write = occursin.(r"write", cif_mem_bcnn_all) cif_mem_bcnn_write = cif_mem_bcnn_all[cif_bool_write] cif_mem_bcnn_write = split.(cif_mem_bcnn_write, " ") cif_mem_bcnn_write = filter.(x -> x != "", cif_mem_bcnn_write) cif_mem_bcnn_read = converttobyte(cif_mem_bcnn_read) cif_mem_bcnn_write = converttobyte(cif_mem_bcnn_write) #println("Total CIFAR BCNN memory writes $(sum(cif_mem_bcnn_write)/1048576.0) Mb") #println("Total CIFAR BCNN memory reads $(sum(cif_mem_bcnn_read)/1048576.0) Mb") # Getting the CNN double precision data dp_fcnn = read("$(folder)dp_fcnn.txt", String); dp_fcnn = split(dp_fcnn, "\n") bool_all = occursin.(r"smsp", dp_fcnn) dp_fcnn_all = dp_fcnn[bool_all] dp_fcnn_all = strip.(dp_fcnn_all) bool_add = occursin.(r"dadd", dp_fcnn_all) dp_fcnn_add = dp_fcnn_all[bool_add] dp_fcnn_add = split.(dp_fcnn_add, " ") dp_fcnn_add = filter.(x -> x != "", dp_fcnn_add) temp = [] for arr in dp_fcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_fcnn_add = temp[:] bool_fma = occursin.(r"dfma", dp_fcnn_all) dp_fcnn_fma = dp_fcnn_all[bool_fma] dp_fcnn_fma = split.(dp_fcnn_fma, " ") dp_fcnn_fma = filter.(x -> x != "", dp_fcnn_fma) temp = [] for arr in dp_fcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_fcnn_fma = temp[:] bool_mul = occursin.(r"dmul", dp_fcnn_all) dp_fcnn_mul = dp_fcnn_all[bool_mul] dp_fcnn_mul = split.(dp_fcnn_mul, " ") dp_fcnn_mul = filter.(x -> x != "", dp_fcnn_mul) temp = [] for arr in dp_fcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end dp_fcnn_mul = temp[:] #println("Total cnn double precision FLOPS: $(sum(dp_fcnn_fma)*2 + sum(dp_fcnn_add) + sum(dp_fcnn_mul))") # Getting the CNN half precision data hp_fcnn = read("$(folder)hp_fcnn.txt", String); hp_fcnn = split(hp_fcnn, "\n") bool_all = occursin.(r"smsp", hp_fcnn) hp_fcnn_all = hp_fcnn[bool_all] hp_fcnn_all = strip.(hp_fcnn_all) bool_add = occursin.(r"hadd", hp_fcnn_all) hp_fcnn_add = hp_fcnn_all[bool_add] hp_fcnn_add = split.(hp_fcnn_add, " ") hp_fcnn_add = filter.(x -> x != "", hp_fcnn_add) temp = [] for arr in hp_fcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_fcnn_add = temp[:] bool_fma = occursin.(r"hfma", hp_fcnn_all) hp_fcnn_fma = hp_fcnn_all[bool_fma] hp_fcnn_fma = split.(hp_fcnn_fma, " ") hp_fcnn_fma = filter.(x -> x != "", hp_fcnn_fma) temp = [] for arr in hp_fcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_fcnn_fma = temp[:] bool_mul = occursin.(r"hmul", hp_fcnn_all) hp_fcnn_mul = hp_fcnn_all[bool_mul] hp_fcnn_mul = split.(hp_fcnn_mul, " ") hp_fcnn_mul = filter.(x -> x != "", hp_fcnn_mul) temp = [] for arr in hp_fcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end hp_fcnn_mul = temp[:] #println("Total cnn half precision FLOPS: $(sum(hp_fcnn_fma)*2 + sum(hp_fcnn_add) + sum(hp_fcnn_mul))") # Getting the CNN single precision data sp_fcnn = read("$(folder)sp_fcnn.txt", String); sp_fcnn = split(sp_fcnn, "\n") bool_all = occursin.(r"smsp", sp_fcnn) sp_fcnn_all = sp_fcnn[bool_all] sp_fcnn_all = strip.(sp_fcnn_all) bool_add = occursin.(r"fadd", sp_fcnn_all) sp_fcnn_add = sp_fcnn_all[bool_add] sp_fcnn_add = split.(sp_fcnn_add, " ") sp_fcnn_add = filter.(x -> x != "", sp_fcnn_add) temp = [] for arr in sp_fcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_fcnn_add = temp[:] bool_fma = occursin.(r"ffma", sp_fcnn_all) sp_fcnn_fma = sp_fcnn_all[bool_fma] sp_fcnn_fma = split.(sp_fcnn_fma, " ") sp_fcnn_fma = filter.(x -> x != "", sp_fcnn_fma) temp = [] for arr in sp_fcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_fcnn_fma = temp[:] bool_mul = occursin.(r"fmul", sp_fcnn_all) sp_fcnn_mul = sp_fcnn_all[bool_mul] sp_fcnn_mul = split.(sp_fcnn_mul, " ") sp_fcnn_mul = filter.(x -> x != "", sp_fcnn_mul) temp = [] for arr in sp_fcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end sp_fcnn_mul = temp[:] #println("Total cnn single precision FLOPS: $(sum(sp_fcnn_fma)*2 + sum(sp_fcnn_add) + sum(sp_fcnn_mul))") # Getting the CNN memory data mem_fcnn = read("$(folder)memrw_fcnn.txt", String); mem_fcnn = split(mem_fcnn, "\n") bool_all = occursin.(r"dram", mem_fcnn) mem_fcnn_all = mem_fcnn[bool_all] mem_fcnn_all = strip.(mem_fcnn_all) bool_read = occursin.(r"read", mem_fcnn_all) mem_fcnn_read = mem_fcnn_all[bool_read] mem_fcnn_read = split.(mem_fcnn_read, " ") mem_fcnn_read = filter.(x -> x != "", mem_fcnn_read) bool_write = occursin.(r"write", mem_fcnn_all) mem_fcnn_write = mem_fcnn_all[bool_write] mem_fcnn_write = split.(mem_fcnn_write, " ") mem_fcnn_write = filter.(x -> x != "", mem_fcnn_write) mem_fcnn_read = converttobyte(mem_fcnn_read) mem_fcnn_write = converttobyte(mem_fcnn_write) #println("Total CNN memory writes $(sum(mem_fcnn_write)/1048576.0) Mb") #println("Total CNN memory reads $(sum(mem_fcnn_read)/1048576.0) Mb") # Getting the CIFAR CNN memory data cif_mem_fcnn = read("$(folder)cif_memrw_fcnn.txt", String); cif_mem_fcnn = split(cif_mem_fcnn, "\n") cif_bool_all = occursin.(r"dram", cif_mem_fcnn) cif_mem_fcnn_all = cif_mem_fcnn[cif_bool_all] cif_mem_fcnn_all = strip.(cif_mem_fcnn_all) cif_bool_read = occursin.(r"read", cif_mem_fcnn_all) cif_mem_fcnn_read = cif_mem_fcnn_all[cif_bool_read] cif_mem_fcnn_read = split.(cif_mem_fcnn_read, " ") cif_mem_fcnn_read = filter.(x -> x != "", cif_mem_fcnn_read) cif_bool_write = occursin.(r"write", cif_mem_fcnn_all) cif_mem_fcnn_write = cif_mem_fcnn_all[cif_bool_write] cif_mem_fcnn_write = split.(cif_mem_fcnn_write, " ") cif_mem_fcnn_write = filter.(x -> x != "", cif_mem_fcnn_write) cif_mem_fcnn_read = converttobyte(cif_mem_fcnn_read) cif_mem_fcnn_write = converttobyte(cif_mem_fcnn_write) #println("Total CIFAR CNN memory writes $(sum(cif_mem_fcnn_write)/1048576.0) Mb") #println("Total CIFAR CNN memory reads $(sum(cif_mem_fcnn_read)/1048576.0) Mb") # Getting the CIFAR BCNN single precision data cif_sp_bcnn = read("$(folder)cif_sp_bcnn.txt", String); cif_sp_bcnn = split(cif_sp_bcnn, "\n") bool_all = occursin.(r"smsp", cif_sp_bcnn) cif_sp_bcnn_all = cif_sp_bcnn[bool_all] cif_sp_bcnn_all = strip.(cif_sp_bcnn_all) bool_add = occursin.(r"fadd", cif_sp_bcnn_all) cif_sp_bcnn_add = cif_sp_bcnn_all[bool_add] cif_sp_bcnn_add = split.(cif_sp_bcnn_add, " ") cif_sp_bcnn_add = filter.(x -> x != "", cif_sp_bcnn_add) temp = [] for arr in cif_sp_bcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_bcnn_add = temp[:] bool_fma = occursin.(r"ffma", cif_sp_bcnn_all) cif_sp_bcnn_fma = cif_sp_bcnn_all[bool_fma] cif_sp_bcnn_fma = split.(cif_sp_bcnn_fma, " ") cif_sp_bcnn_fma = filter.(x -> x != "", cif_sp_bcnn_fma) temp = [] for arr in cif_sp_bcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_bcnn_fma = temp[:] bool_mul = occursin.(r"fmul", cif_sp_bcnn_all) cif_sp_bcnn_mul = cif_sp_bcnn_all[bool_mul] cif_sp_bcnn_mul = split.(cif_sp_bcnn_mul, " ") cif_sp_bcnn_mul = filter.(x -> x != "", cif_sp_bcnn_mul) temp = [] for arr in cif_sp_bcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_bcnn_mul = temp[:] #println("Total bcnn CIFAR single precision FLOPS: $(sum(cif_sp_bcnn_fma)*2 + sum(cif_sp_bcnn_add) + sum(cif_sp_bcnn_mul))") # Getting the CIFAR CNN single precision data cif_sp_fcnn = read("$(folder)cif_sp_fcnn.txt", String); cif_sp_fcnn = split(cif_sp_fcnn, "\n") bool_all = occursin.(r"smsp", cif_sp_fcnn) cif_sp_fcnn_all = cif_sp_fcnn[bool_all] cif_sp_fcnn_all = strip.(cif_sp_fcnn_all) bool_add = occursin.(r"fadd", cif_sp_fcnn_all) cif_sp_fcnn_add = cif_sp_fcnn_all[bool_add] cif_sp_fcnn_add = split.(cif_sp_fcnn_add, " ") cif_sp_fcnn_add = filter.(x -> x != "", cif_sp_fcnn_add) temp = [] for arr in cif_sp_fcnn_add append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_fcnn_add = temp[:] bool_fma = occursin.(r"ffma", cif_sp_fcnn_all) cif_sp_fcnn_fma = cif_sp_fcnn_all[bool_fma] cif_sp_fcnn_fma = split.(cif_sp_fcnn_fma, " ") cif_sp_fcnn_fma = filter.(x -> x != "", cif_sp_fcnn_fma) temp = [] for arr in cif_sp_fcnn_fma append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_fcnn_fma = temp[:] bool_mul = occursin.(r"fmul", cif_sp_fcnn_all) cif_sp_fcnn_mul = cif_sp_fcnn_all[bool_mul] cif_sp_fcnn_mul = split.(cif_sp_fcnn_mul, " ") cif_sp_fcnn_mul = filter.(x -> x != "", cif_sp_fcnn_mul) temp = [] for arr in cif_sp_fcnn_mul append!(temp, parse(Int64, replace(arr[3], r"," => ""))) end cif_sp_fcnn_mul = temp[:] #println("Total cnn CIFAR single precision FLOPS: $(sum(sp_fcnn_fma)*2 + sum(sp_fcnn_add) + sum(sp_fcnn_mul))") #println("\n\n\n\n\n\n") # Data moves mov_pj = 0.00125 # Turing arch values add_μj = 0.0293 mul_μj = 0.2933 fma_μj = 0.8340 # Intel arch values add_pj = 0.000111 mul_pj = 0.000164 fma_pj = 0.000464 tot_mem_bcnn_w_mb = sum(mem_bcnn_write) #sum((1/norm(mem_bcnn_write)).*mem_bcnn_write) /100 tot_mem_bcnn_r_mb = sum(mem_bcnn_read) #sum((1/norm(mem_bcnn_read)).*mem_bcnn_read) /100 tot_mem_fcnn_w_mb = sum(mem_fcnn_write) #sum((1/norm(mem_fcnn_write)).*mem_fcnn_write) /100 tot_mem_fcnn_r_mb = sum(mem_fcnn_read) #sum((1/norm(mem_fcnn_read)).*mem_fcnn_read) /100 rate_mem_bcnn = (tot_mem_bcnn_w_mb / tot_mem_bcnn_r_mb) * mov_pj rate_mem_fcnn = (tot_mem_fcnn_w_mb / tot_mem_fcnn_r_mb) * mov_pj cif_tot_mem_bcnn_w_mb = sum(cif_mem_bcnn_write) #sum((1/norm(cif_mem_bcnn_write)).*cif_mem_bcnn_write) /100 cif_tot_mem_bcnn_r_mb = sum(cif_mem_bcnn_read) #sum((1/norm(cif_mem_bcnn_read)).*cif_mem_bcnn_read) /100 cif_tot_mem_fcnn_w_mb = sum(cif_mem_fcnn_write) #sum((1/norm(cif_mem_fcnn_write)).*cif_mem_fcnn_write) /100 cif_tot_mem_fcnn_r_mb = sum(cif_mem_fcnn_read) #sum((1/norm(cif_mem_fcnn_read)).*cif_mem_fcnn_read) /100 cif_rate_mem_bcnn = (cif_tot_mem_bcnn_w_mb / cif_tot_mem_bcnn_r_mb) * mov_pj cif_rate_mem_fcnn = (cif_tot_mem_fcnn_w_mb / cif_tot_mem_fcnn_r_mb) * mov_pj tot_bcnn_add = sum(sp_bcnn_add) #sum((1/norm(sp_bcnn_add)).*sp_bcnn_add) /100 tot_bcnn_mul = sum(sp_bcnn_mul) #sum((1/norm(sp_bcnn_mul)).*sp_bcnn_mul) /100 tot_bcnn_fma = sum(sp_bcnn_fma) #sum((1/norm(sp_bcnn_fma)).*sp_bcnn_fma) /100 tot_fcnn_add = sum(sp_fcnn_add) #sum((1/norm(sp_fcnn_add)).*sp_fcnn_add) /100 tot_fcnn_mul = sum(sp_fcnn_mul) #sum((1/norm(sp_fcnn_mul)).*sp_fcnn_mul) /100 tot_fcnn_fma = sum(sp_fcnn_fma) #sum((1/norm(sp_fcnn_fma)).*sp_fcnn_fma) /100 rat_bcnn_add_fma = sum(sp_bcnn_add) / sum(sp_bcnn_fma) rat_bcnn_mul_fma = sum(sp_bcnn_mul) / sum(sp_bcnn_fma) rat_fcnn_add_fma = sum(sp_fcnn_add) / sum(sp_fcnn_fma) rat_fcnn_mul_fma = sum(sp_fcnn_mul) / sum(sp_fcnn_fma) #= println("Ratio BCNN ADD/FMA: $(rat_bcnn_add_fma)") println("Ratio BCNN MUL/FMA: $(rat_bcnn_mul_fma)") println("Ratio FCNN ADD/FMA: $(rat_fcnn_add_fma)") println("Ratio FCNN MUL/FMA: $(rat_fcnn_mul_fma)") =# cif_tot_bcnn_add = sum(cif_sp_bcnn_add) #sum((1/norm(cif_sp_bcnn_add)).*cif_sp_bcnn_add) /100 cif_tot_bcnn_mul = sum(cif_sp_bcnn_mul) #sum((1/norm(cif_sp_bcnn_mul)).*cif_sp_bcnn_mul) /100 cif_tot_bcnn_fma = sum(cif_sp_bcnn_fma) #sum((1/norm(cif_sp_bcnn_fma)).*cif_sp_bcnn_fma) /100 cif_tot_fcnn_add = sum(cif_sp_fcnn_add) #sum((1/norm(cif_sp_fcnn_add)).*cif_sp_fcnn_add) /100 cif_tot_fcnn_mul = sum(cif_sp_fcnn_mul) #sum((1/norm(cif_sp_fcnn_mul)).*cif_sp_fcnn_mul) /100 cif_tot_fcnn_fma = sum(cif_sp_fcnn_fma) #sum((1/norm(cif_sp_fcnn_fma)).*cif_sp_fcnn_fma) /100 cif_rat_bcnn_add_fma = sum(cif_sp_bcnn_add) / sum(cif_sp_bcnn_fma) cif_rat_bcnn_mul_fma = sum(cif_sp_bcnn_fma) / sum(cif_sp_bcnn_fma) cif_rat_fcnn_add_fma = sum(cif_sp_fcnn_add) / sum(cif_sp_fcnn_fma) cif_rat_fcnn_mul_fma = sum(cif_sp_fcnn_mul) / sum(cif_sp_fcnn_fma) #= println("Ratio CIFAR BCNN ADD/FMA: $(cif_rat_bcnn_add_fma)") println("Ratio CIFAR BCNN MUL/FMA: $(cif_rat_bcnn_mul_fma)") println("Ratio CIFAR FCNN ADD/FMA: $(cif_rat_fcnn_add_fma)") println("Ratio CIFAR FCNN MUL/FMA: $(cif_rat_fcnn_mul_fma)") =# #add_ratio_bccn = rat_bcnn_add_fma - cif_rat_bcnn_add_fma #* (1 - (add_μj + add_pj)) #mul_ratio_bccn = rat_bcnn_mul_fma - cif_rat_bcnn_mul_fma #* (1 - (mul_μj + mul_pj)) #add_ratio_fccn = rat_fcnn_add_fma - cif_rat_fcnn_add_fma #* (1 - (add_μj + add_pj)) #mul_ratio_fccn = rat_fcnn_mul_fma - cif_rat_fcnn_mul_fma #* (1 - (mul_μj + mul_pj)) #= println("Memory rate of change BCNN: $(sum(mem_bcnn_write)/sum(mem_bcnn_read))") println("Memory rate of change FCNN: $(sum(mem_fcnn_write)/sum(mem_fcnn_read))") println("Memory rate of change CIFAR BCNN: $(sum(cif_mem_bcnn_write)/sum(cif_mem_bcnn_read))") println("Memory rate of change CIFAR FCNN: $(sum(cif_mem_fcnn_write)/sum(cif_mem_fcnn_read))") =# #println("Rate of change ADD BCNN: $(add_ratio_bccn)") #println("Rate of change MUL BCNN: $(mul_ratio_bccn)") #println("Rate of change ADD FCNN: $(add_ratio_fccn)") #println("Rate of change MUL FCNN: $(mul_ratio_fccn)") #avg_rate_bcnn = # ((add_ratio_bccn + mul_ratio_bccn) / 2) * (((add_μj + add_pj) + (mul_μj + mul_pj)) / 2) #avg_rate_fcnn = # ((add_ratio_fccn + mul_ratio_fccn) / 2) * (((add_μj + add_pj) + (mul_μj + mul_pj)) / 2) #println("Avg rate BCNN: $(avg_rate_bcnn)") #println("Avg rate FCNN: $(avg_rate_fcnn)") # get total scaled bcnn_mnist_vector = [tot_bcnn_add,tot_bcnn_mul,tot_bcnn_fma,tot_mem_bcnn_r_mb,tot_mem_bcnn_w_mb] bcnn_cifar_vector = [cif_tot_bcnn_add,cif_tot_bcnn_mul,cif_tot_bcnn_fma,cif_tot_mem_bcnn_r_mb,cif_tot_mem_bcnn_w_mb] fcnn_mnist_vector = [tot_fcnn_add,tot_fcnn_mul,tot_fcnn_fma,tot_mem_bcnn_r_mb,tot_mem_bcnn_w_mb] fcnn_cifar_vector = [cif_tot_fcnn_add,cif_tot_fcnn_mul,cif_tot_fcnn_fma,cif_tot_mem_fcnn_r_mb,cif_tot_mem_fcnn_w_mb] #bcnn_mnist_vector_max = max(bcnn_mnist_vector...) #bcnn_cifar_vector_max = max(bcnn_cifar_vector...) # #fcnn_mnist_vector_max = max(fcnn_mnist_vector...) #fcnn_cifar_vector_max = max(fcnn_cifar_vector...) # #bcnn_mnist_vector = bcnn_mnist_vector ./ (bcnn_mnist_vector_max * 1) #bcnn_cifar_vector = bcnn_cifar_vector ./ (bcnn_cifar_vector_max * 1) # #fcnn_mnist_vector = fcnn_mnist_vector ./ (fcnn_mnist_vector_max * 1) #fcnn_cifar_vector = fcnn_cifar_vector ./ (fcnn_cifar_vector_max * 1) en_plot = plot( [ bar( y=bcnn_mnist_vector, x=["ADD","MUL","FMA","MRE","MWR"], #cumulative_enabled=false, name="MNIST", #marker_color="#eb98b5", marker_color = "rgb(055,033,240)", opacity=0.75 ), bar( y=bcnn_cifar_vector, #y=fcnn_mnist_vector, x=["ADD", "MUL","FMA","MRE","MWR"], #cumulative_enabled=false, name="CIFAR", #marker_color="#330C73", marker_color = "rgb(211,120,000)", opacity=0.75 ) ], #Layout(title="BCNN", xaxis_title="Operations", yaxis_title="Total")#, yaxis_range=[0,1]) Layout(xaxis_title="Operations", yaxis_title="Total")#, yaxis_range=[0,1]) #Layout(xaxis_title="Operations", yaxis_title="Total", yaxis_range=[0,1]) ) savefig(en_plot, "bcnn_oper.png") #savefig(en_plot, "mnist_oper.png") en_plot = plot( [ bar( y=fcnn_mnist_vector, #y=bcnn_cifar_vector, x=["ADD","MUL","FMA","MRE","MWR"], #cumulative_enabled=false, name="MNIST", #marker_color="#eb98b5", marker_color = "rgb(055,033,240)", opacity=0.75 ), bar( y=fcnn_cifar_vector, x=["ADD", "MUL","FMA","MRE","MWR"], #cumulative_enabled=false, name="CIFAR", #marker_color="#330C73", marker_color = "rgb(211,120,000)", opacity=0.75 ) ], #Layout(title="FCNN", xaxis_title="Operations", yaxis_title="Total")#, yaxis_range=[0,1]) Layout(xaxis_title="Operations", yaxis_title="Total")#, yaxis_range=[0,1]) #Layout(xaxis_title="Operations", yaxis_title="Total", yaxis_range=[0,1]) ) savefig(en_plot, "fcnn_oper.png") #savefig(en_plot, "cifar_oper.png") #= amount = 500 # plots #mem_read_plot = plot(mem_bcnn_read[1:amount],title="First $(amount) memory reads",label="BNN reads");plot!(mem_fcnn_read[1:amount],label="CNN reads") #savefig(mem_read_plot,"mem_read.png") mem_read_plot = plot(mem_bcnn_read[1:amount],label="BNN reads");plot!(mem_fcnn_read[1:amount],label="CNN reads") savefig(mem_read_plot,"mem_read.png") #mem_write_plot = plot(mem_bcnn_write[1:amount],title="First $(amount) memory writes",label="BNN writes");plot!(mem_fcnn_write[1:amount],label="CNN writes") #savefig(mem_write_plot,"mem_write.png") mem_write_plot = plot(mem_bcnn_write[1:amount],label="BNN writes");plot!(mem_fcnn_write[1:amount],label="CNN writes") savefig(mem_write_plot,"mem_write.png") #add_plot = plot(sp_bcnn_add[1:amount],title="First $(amount) single precision ADD operations",label="BNN ADD");plot!(sp_fcnn_add[1:amount],label="CNN ADD") #savefig(add_plot,"add_plot.png") add_plot = plot(sp_bcnn_add[1:amount],label="BNN ADD");plot!(sp_fcnn_add[1:amount],label="CNN ADD") savefig(add_plot,"add_plot.png") #mul_plot = plot(sp_bcnn_mul[1:amount],title="First $(amount) single precision MUL operations",label="BNN MUL");plot!(sp_fcnn_mul[1:amount],label="CNN MUL") #savefig(mul_plot,"mul_plot.png") mul_plot = plot(sp_bcnn_mul[1:amount],label="BNN MUL");plot!(sp_fcnn_mul[1:amount],label="CNN MUL") savefig(mul_plot,"mul_plot.png") #fma_plot = plot(sp_bcnn_fma[1:amount],title="First $(amount) single precision FMA operations",label="BNN FMA");plot!(sp_fcnn_fma[1:amount],label="CNN FMA") #savefig(fma_plot,"fma_plot.png") fma_plot = plot(sp_bcnn_fma[1:amount],label="BNN FMA");plot!(sp_fcnn_fma[1:amount],label="CNN FMA") savefig(fma_plot,"fma_plot.png") #mem_bcnn_read=convert.(Float64,mem_bcnn_read) #mem_bcnn_write=convert.(Float64,mem_bcnn_write) #mem_fcnn_read=convert.(Float64,mem_fcnn_read) #mem_fcnn_write=convert.(Float64,mem_fcnn_write) #sp_bcnn_add=convert.(Float64,sp_bcnn_add) #sp_bcnn_fma=convert.(Float64,sp_bcnn_fma) #sp_bcnn_mul=convert.(Float64,sp_bcnn_mul) #sp_fcnn_add=convert.(Float64,sp_fcnn_add) #sp_fcnn_fma=convert.(Float64,sp_fcnn_fma) #sp_fcnn_mul=convert.(Float64,sp_fcnn_mul) #h5write("mem_bcnn_read.h5", "mem_bcnn_read", mem_bcnn_read) #h5write("mem_bcnn_write.h5", "mem_bcnn_write", mem_bcnn_write) #h5write("mem_fcnn_read.h5", "mem_fcnn_read", mem_fcnn_read) #h5write("mem_fcnn_write.h5", "mem_fcnn_write", mem_fcnn_write) #h5write("sp_bcnn_add.h5", "sp_bcnn_add", sp_bcnn_add) #h5write("sp_bcnn_fma.h5", "sp_bcnn_fma", sp_bcnn_fma) #h5write("sp_bcnn_mul.h5", "sp_bcnn_mul", sp_bcnn_mul) #h5write("sp_fcnn_add.h5", "sp_fcnn_add", sp_fcnn_add) #h5write("sp_fcnn_fma.h5", "sp_fcnn_fma", sp_fcnn_fma) #h5write("sp_fcnn_mul.h5", "sp_fcnn_mul", sp_fcnn_mul) =#