Project

General

Profile

« Previous | Next » 

Revision 8980b5cf

Added by Pierre-Loïc Garoche over 8 years ago

Modified Salsa plugin to apply the algorithm until no more progress can be made

View differences:

src/plugins/salsa/machine_salsa_opt.ml
75 75
    | LT.MComment _ -> Vars.empty    
76 76
  )
77 77

  
78
let rec iterTransformExpr fresh_id e_salsa abstractEnv old_range =
79
  let new_expr, new_range = 
80
    Salsa.MainEPEG.transformExpression fresh_id e_salsa abstractEnv 
81
  in
82
  Format.eprintf "New range: %a@." 	  RangesInt.pp_val new_range;
83
  if Salsa.Float.errLt new_range old_range < 0 then 
84
    
85
    iterTransformExpr fresh_id new_expr abstractEnv new_range
86
  else
87
    new_expr, new_range
88

  
78 89

  
79 90
(* Optimize a given expression. It returns another expression and a computed range. *)
80 91
let optimize_expr nodename constEnv printed_vars vars_env ranges formalEnv e : LT.value_t * RangesInt.t option = 
......
174 185
	    MC.pp_val (salsa_expr2value_t vars_env constEnv e_salsa)
175 186
	    (Utils.fprintf_list ~sep:",@ "(fun fmt (l,r) -> Format.fprintf fmt "%s -> %a" l FloatIntSalsa.pp r)) abstractEnv
176 187
	;
188
	let range_before = Float.evalExpr e_salsa abstractEnv in
177 189
	  
178 190
	let new_e_salsa, e_val = 
179
	  Salsa.MainEPEG.transformExpression fresh_id e_salsa abstractEnv 
191
	  iterTransformExpr fresh_id e_salsa abstractEnv range_before
180 192
	in
181 193

  
182
	  let range_before = Float.evalExpr e_salsa abstractEnv in
183 194
	  let range_after = Float.evalExpr new_e_salsa abstractEnv in
184 195

  
185 196
    	let new_e = try salsa_expr2value_t vars_env constEnv new_e_salsa   with Not_found -> assert false in
......
512 523
	in
513 524
	let minv, maxv = get_cst minv, get_cst maxv in
514 525
	if debug then Format.eprintf "%s in [%f, %f]@ " v minv maxv;
515
	RangesInt.enlarge ranges v (Salsa.SalsaTypes.I(minv, maxv),Salsa.SalsaTypes.J(0.,0.))
526
	let irange = Salsa.SalsaTypes.I(minv, maxv) in
527
	RangesInt.enlarge ranges v (irange, Salsa.Float.ulp irange)
516 528
      )
517 529
      | _ -> 
518 530
	Format.eprintf 
src/plugins/salsa/salsaDatatypes.ml
131 131
      if r = 0. then
132 132
	Salsa.Builder.mk_cst (ST.I(-. min_float, min_float),Float.ulp (ST.I(-. min_float, min_float)))
133 133
      else
134
	Salsa.Builder.mk_cst (ST.I(r*.(1.-.epsilon_float),r*.(1.+.epsilon_float)),Float.ulp (ST.I(r,r)))
134
	Salsa.Builder.mk_cst (ST.I(r*.(1.-.epsilon_float),r*.(1.+.epsilon_float)), Float.ulp (ST.I(r,r)))
135 135
    | _ -> assert false
136 136
end
137 137

  

Also available in: Unified diff