This module implements some predicates which provide access to and control of many parameters of the Ciao runtime, including internal statistics, loaded modules, special properties of the predicates, garbage collection, etc.
Some of these facilities are accessed or controlled via specific predicates (see later) while in other cases such access and control is preformed through the mechanism of flags. Such flags contain values for some global parameters of the system and also control the behavior of some system or library predicates. Each flag has a name and an associated predefined value, and except some system flags which are fixed, in general their associated value is changeable.
Flags can be given values at compile time, via declarations, and then the changes affect only the module being processed. Predicates are also available to consult and change flag values at run time, in which case their effect is global from that moment on in the execution (see prolog_flag/3 and related predicates below). Note that corresponding flag-processing declarations and predicates have the same predicate name; only the run-time version is documented.
Some flags are pre-defined in the system. In addition, new flags can be also be defined. The mechanism to do this is described in define_flag/3. Through this mechanism, many Ciao modules and language extensions define additional flags. Flags that are predefined in the system (engine) are documented here and the rest are generally documented in the modules/libraries that define them.
The predefined flags in the system are the following:
The state is initially error. ISO
Usage:
Prints statistics about the system.
Usage 1:statistics(Tick_option,Tick_result)
Gather information about clock ticks (either run, user, system or wall tick) since the last consultation or since the start of the program. A tick is the smallest amount of time that the clock can measure.
tick_option(runtick). tick_option(usertick). tick_option(systemtick). tick_option(walltick).
tick_option(runtick). tick_option(usertick). tick_option(systemtick). tick_option(walltick).
Usage 2:statistics(Clockfreq_option,Clockfreq_result)
Gather information about frequency of the clocks used to measure the ticks (either run-user, system or wall clock). Results are returned in Hertz. This value also can be defined as the amount of ticks that a clock can measure in one second.
clockfreq_option(runclockfreq). clockfreq_option(userclockfreq). clockfreq_option(systemclockfreq). clockfreq_option(wallclockfreq).
clockfreq_option(runclockfreq). clockfreq_option(userclockfreq). clockfreq_option(systemclockfreq). clockfreq_option(wallclockfreq).
Usage 3:statistics(Time_option,Time_result)
Gather information about time (either process time or wall time) since the last consultation or since start of program. Results are returned in milliseconds. Note that internally, time is calculated as:
Time_result = (Tick_result / Clockfreq_result) * 1000
time_option(runtime). time_option(usertime). time_option(systemtime). time_option(walltime).
time_option(runtime). time_option(usertime). time_option(systemtime). time_option(walltime).
Usage 4:statistics(Memory_option,Memory_result)
Gather information about memory consumption.
memory_option(memory). memory_option(symbols). memory_option(program). memory_option(global_stack). memory_option(local_stack). memory_option(trail). memory_option(choice).
memory_option(memory). memory_option(symbols). memory_option(program). memory_option(global_stack). memory_option(local_stack). memory_option(trail). memory_option(choice).
Usage 5:statistics(GC_option,GC_result)
Gather information about garbage collection.
gc_option(garbage_collection). gc_option(stack_shifts).
gc_option(garbage_collection). gc_option(stack_shifts).
Usage 6:statistics(Symbol_option,Symbol_result)
Gather information about number of symbols and predicates.
symbol_option(symbols).
symbol_option(symbols).
Usage 7:statistics(Option,Arg2)
If Option is unbound, it is bound by backtracking to the values of all the other cases.
Usage:time_option(M)
M is an option to get information about execution time.
time_option(runtime). time_option(usertime). time_option(systemtime). time_option(walltime).
Usage:tick_option(M)
M is an option to get information about execution ticks.
tick_option(runtick). tick_option(usertick). tick_option(systemtick). tick_option(walltick).
Usage:clockfreq_option(M)
M is and option to get information about the frequency of clocks used to get the ticks.
clockfreq_option(runclockfreq). clockfreq_option(userclockfreq). clockfreq_option(systemclockfreq). clockfreq_option(wallclockfreq).
Usage:memory_option(M)
M is an option to get information about memory usage.
memory_option(memory). memory_option(symbols). memory_option(program). memory_option(global_stack). memory_option(local_stack). memory_option(trail). memory_option(choice).
Usage:gc_option(M)
M is an option to get information about garbage collection.
gc_option(garbage_collection). gc_option(stack_shifts).
Usage:symbol_option(M)
M is an option to get information about the number of symbols in the program.
symbol_option(symbols).
Usage:time_result(Result)
Result is a two-element list of numbers. The first number is the time since the start of the execution; the second number is the time since the previous time consultation to time.
Usage:tick_result(Result)
Result is a two-element list of numbers. The first number is the number of ticks since the start of the execution; the second number is the number of ticks since the previous consultation to tick.
Usage:clockfreq_result(Result)
Result is a number which gives the frequency in Hertz used by the clock get the ticks.
Usage:memory_result(Result)
Result is a two-element list of integers. The first element is the space taken up by the option selected, measured in bytes; the second integer is zero for program space (which grows as necessary), and the amount of free space otherwise.
Usage:gc_result(Result)
Result is a tree-element list of integers, related to garbage collection and memory management. When stack_shifts is selected, the first one is the number of shifts (reallocations) of the local stack; the second is the number of shifts of the trail; and the third is the time spent in these shifts. When garbage_collection is selected, the numbers are, respectively, the number of garbage collections performed, the number of bytes freed, and the time spent in garbage collection.
Usage:symbol_result(Result)
Result is a two-element list of integers. The first one is the number of atom, functor, and predicate names in the symbol table. The second is the number of predicates known to be defined (although maybe without clauses).
Usage:time(G)
Execute G and print runtime statistics to the user, for each solution.
Usage:current_atom(Atom)
Enumerates on backtracking all the existing atoms in the system.
Usage:new_atom(Atom)
Returns, on success, in Atom a new atom, not existing before in the system. The entry argument must be a variable. The idea behind this atom generation is to provide a fast source of identifiers for new objects, concurrent predicates, etc. on the fly.
When called using a free variable as argument, it will retrieve on backtracking all modules currently loaded. This is useful when called from the Ciao toplevel.
When called using a module name as argument it will check whether the given module is loaded or not. This is useful when called from user programs.
Usage 1:current_module(Module)
Retrieves (on backtracking) in Module all the loaded modules (either statically or dynamically).
Usage 2:current_module(Module)
Checks whether module Module is loaded or not (either statically or dynamically).
Usage:predicate_property(Head,Property)
The predicate Head, visible from the current module, (a goal) has the property Property.
Usage:
Forces garbage collection when called.
Set existing flag FlagName to Value. Can also be a declaration (which is then compile-time and module-local).
Usage:ISO
FlagName is an existing flag and Value is the value currently associated with it.
Usage:
FlagName is an existing flag. Unify OldValue with the value associated with it, and set it to new value NewValue. Can also be a declaration (which is then compile-time and module-local).
Usage 1:prolog_flag(FlagName,OldValue,NewValue)
Usage 2:prolog_flag(FlagName,OldValue,NewValue)
Same as current_prolog_flag(FlagName, OldValue). OldValue and NewValue must be strictly identical variables.
Same as set_prolog_flag/2, but storing the current value of Flag to restore it with pop_prolog_flag/1. Can also be a declaration (which is then compile-time and module-local).
Usage:
Restore the value of Flag previous to the last non-canceled push_prolog_flag/2 on it. Can also be a declaration (which is then compile-time and module-local).
Usage:
Allows reading or changing the prompt used for reading in terms.
Usage 1:prompt(Old,New)
Unify Old with the current prompt for reading, change it to New. To read the current prompt just call prompt(X,X).
Usage 2:prompt(Old,New)
Unify Old with the current prompt for reading without changing it. On calls, Old and New must be strictly identical variables.
Usage:
Enable reporting of file errors. Equivalent to set_prolog_flag(fileerrors, on)
Usage:
Disable reporting of file errors. Equivalent to set_prolog_flag(fileerrors, off)
Usage:
Enable garbage collection. Equivalent to set_prolog_flag(gc, on)
Usage:
Disable garbage collection. Equivalent to set_prolog_flag(gc, off)
New flags can be defined by writing facts of this predicate. Flag is the name of the new flag, Values defines the posible values for the flag (see below) and Default defines the predefined value associated with the flag (which should be compatible with Values).
Usage:define_flag(Flag,FlagValues,Default)