print_op_cache_profile :- \+ operation_computed(_,_,_,_,_),!, % print nothing
(get_preference(try_operation_reuse,false) -> format('OPERATION_REUSE preference not set to TRUE~n',[]) ; true),
format('No operation cached~n',[]),
check_if_op_cache_useful.
print_op_cache_profile :-
b_get_machine_variables(Var),length(Var,VLen),
operation_read_projection_cache(OpKey,OpName,ProjVars,_,WV), (ProjVars = [] ; ProjVars = [_|_]),
length(ProjVars,Len),
operation_read_constants(OpKey,ReadConstants),
(operation_guard_read_info(OpKey,_,IrrelevantVars)
-> format('Operation ~w cached onto ~w/~w variables: ~w (not relevant for guard: ~w, only written: ~w, constants read: ~w)~n',[OpName,Len,VLen,ProjVars,IrrelevantVars,WV,ReadConstants])
; format('Operation ~w cached onto ~w/~w variables: ~w (only written: ~w, constants read: ~w)~n',[OpName,Len,VLen,ProjVars,WV,ReadConstants])
),fail.
print_op_cache_profile :- findall(OpName,operation_read_projection_cache(_,OpName,no_caching,_,_),Ls),
format('Operations not cached: ~w~n',[Ls]),fail.
print_op_cache_profile :- operation_read_projection_cache(OpKey,OpName,ProjVars,_,_), ProjVars = [_|_],
get_nr_next_state_calls(OpName,Nr),
get_nr_cache_results(OpName,RNr),
(inv_op_name(OpName) -> Results='violations' ; Results = 'results'),
format('Next-state-calls for ~w: ~w (~w ~w)~n',[OpName,Nr,RNr,Results]),
operation_guard_read_info(OpKey,RelVars,_),
findall(1,op_guard_fails(_,OpName,_),Fails), length(Fails,NrFails),
format(' projected-failures (on ~w): ~w~n',[RelVars,NrFails]),
fail.
print_op_cache_profile :-
get_total_number_of_next_state_calls(Nr,InvNr),
format('Total Number of Next-state-calls for Operations: ~w~n',[Nr]),
get_counter(op_cached_failures,FailCalls),
format(' - Reused guard failures: ~w~n',[FailCalls]),
get_counter(op_cached_successes,SuccCalls),
format(' - Reused successful operation call results: ~w~n',[SuccCalls]),
format('Total Number of Invariant-check-calls: ~w~n',[InvNr]),
get_counter(inv_cached_successes,SuccInvCalls),
format(' - Reused invariant check results: ~w~n',[SuccInvCalls]),
get_counter(op_cached_errors,Errs),
format('Errors during calls: ~w~n',[Errs]),
get_counter(op_cached_timeouts,Timeouts),
format('Timeouts during calls: ~w~n',[Timeouts]),
get_counter(op_cached_enum_warnings,EnumWarns),
format('Enumeration warnings during calls: ~w~n',[EnumWarns]),
fail.
print_op_cache_profile :- debug_mode(on), nl,
operation_read_projection_cache(_,OpName,Skel,_,_),
format('~n** Local Operation Cache Info for ~w ** (projected on ~w):~n',[OpName,Skel]),
operation_computed(_Hash,OpName,ConstID,PackedValList,ID),
(operation_cached_max_reached(ID,OpName) -> MaxR='(max reached, not all transitions computed)'
; MaxR=''),
format('~nNode ID = ~w, Operation = ~w ~w~n',[ID,OpName,MaxR]),
unpack_bind_list(PackedValList,Skel,State), translate_bstate_limited(State,NodeDesc),
format(' projected state : (ConstID ~w) ~w~n',[ConstID,NodeDesc]),
operation_cached_results(ID,Operation,PackedNewState,_PathInfo),
translate_event_with_limit(Operation,100,OpStr),
unpack_values(PackedNewState,NewState), translate:translate_bstate_limited(NewState,UpdateStr),
format(' ~w -upd-> ~w~n',[OpStr,UpdateStr]),
fail.
print_op_cache_profile :- print_violated_invariants,fail.
print_op_cache_profile :- ahc,print('----------'),nl.