Tezos_benchmark.ModelSourceSpecifying model arity and eliminator type
Abstract representation of models. Models are strongly typed: Model_impl.arg_type exposes what a model expects on input. The relation between arg_type and model_type is encoded through a value of type arity.
Instantiation of a Model_impl.Def with a Costlang.S
module Instantiate
(X : Costlang.S)
(M : Model_impl) :
Instantiated
with type 'a repr = 'a X.repr
and type size = X.size
and type arg_type = M.arg_typeModel that has been applied to some arguments. Typically, we get an Applied model when we apply some workload from a benchmark to its model. Can be obtained with apply.
type 'workload t = | Abstract : {conv : 'workload -> 'arg;model : 'arg model;} -> 'workload t| Aggregate : {model : 'workload -> applied;sub_models : packed_model list;} -> 'workload tModel containers for benchmarks. We distinguish two kinds:
'arg model, with a conv function that transforms a benchmark's workload into the model's arguments.sub_models.Build _ t from _ model, with a type conversion fucntion conv. If ~takes_saturation_reprs: true is given, its generated code will take _ Saturation_reprs.t instead of int.
apply takes a model and an appropriate workload, and returns an applied model
Addition on models. Note that the results is always an Aggregate
Returns the set of free variables of a model
Returns the set of free variables of an applied model
Note that this can be very different from get_free_variable_set.
Commonly used abstract models Except for zero, they all require a unique name in Namespace.t, and some Free_variable.ts. Those free are deduced during the inference in Snoop, and the resulting values are (usually) the gas parameters for the protocol.
zero is the "zero" for the addition on models. It can be seen as the model of the empty code. fun () -> 0
Model for code that executes in constant time fun () -> const
Model ignores the arguments. fun n -> const
val unknown_const1_skip2 :
name:Namespace.t ->
const:Free_variable.t ->
(int * (int * unit)) modelModel ignores the arguments. fun n m -> const
fun n -> coeff × n
val affine :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n
val affine_offset :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
offset:int ->
(int * unit) modelfun n -> intercept + coeff × (n - offset)
fun n -> coeff * n²
val nlogn :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n×log(n)
val nsqrtn_const :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n×sqrt(n)
fun n -> coeff * log(n)
val linear_sum :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a+b)
val linear_sat_sub :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a-b)
val linear_max :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × max(a,b)
val linear_min :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × min(a,b)
val linear_min_offset :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
offset:int ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (min(a,b) - offset)
val linear_mul :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a×b)
val bilinear :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
(int * (int * unit)) modelfun a b -> coeff1 × a + coeff2 × b
val bilinear_affine :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff1 × a + coeff2 × b
val affine_skip1 :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × b
val nlogm :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun n m -> intercept + coeff × n×log(m)
val n_plus_logm :
name:Namespace.t ->
intercept:Free_variable.t ->
linear_coeff:Free_variable.t ->
log_coeff:Free_variable.t ->
(int * (int * unit)) modelfun n m -> intercept + (linear_coeff × n) + (log_coeff × log(m))
val trilinear :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
(int * (int * (int * unit))) modelfun a b c -> coeff1 × a + coeff2 × b + coeff3 × c
val breakdown :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
break:int ->
(int * unit) modelA multi-affine model in two parts. The breakpoint break indicates the point at which the slope changes coefficient.
val breakdown2 :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
break1:int ->
break2:int ->
(int * unit) modelA multi-affine model in three parts, with breakpoints break1 and break2. Expects break1 <= break2
val breakdown2_const :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
const:Free_variable.t ->
break1:int ->
break2:int ->
(int * unit) modelbreakdown2 with a non-zero value at 0
val breakdown2_const_offset :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
const:Free_variable.t ->
break1:int ->
break2:int ->
offset:int ->
(int * unit) modelbreakdown2 with a non-zero value at 0 and offset
val synthesize :
name:Namespace.t ->
binop:(module Binary_operation) ->
x_label:string ->
x_model:'a model ->
y_label:string ->
y_model:'a model ->
'a modelSynthesize two models of the same signature by the specified binary operation.