[mercury-users] Compiler optimization for large number of factual clauses.

Julien Fischer juliensf at csse.unimelb.edu.au
Sun Jul 1 23:34:25 AEST 2007


On Fri, 29 Jun 2007, Bartlomiej Szymczak wrote:

> Consider the following Mercury code:
>
> :-type c --->
>       c_1;
>       c_2;
> ....(thousands of entries)
>       c_99999.
>
> :-pred rel(c,c).
> :-mode rel(in,in) is semidet.
> :-mode rel(in,out) is nondet.
> :-mode rel(out,in) is nondet.
>
> rel(c_1,c_2).
> rel(c_1,c_3).
> rel(c_3,c_1).
> ....(thousands of entries)
> rel(c_99999,c_3).
>
> I want to ask how fast the "rel" predicate is. Will the compiler
> optimize it by adding some hash table based lookup?

In low-level C grades recent versions of the Mercury compiler (> 0.13.x)
will compile predicates that consist of facts into code that does table
lookups.  (With version 0.13.x and below you have to use fact tables
to obtain similar code.)

> Are all three modes equivalently efficient?

The compiler generates the separate code for each mode of a predicate.
It will attempt to make the code for each mode as efficient as
possible.

Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list