From sebc@cs.tu-berlin.de Fri Nov 16 15:47:15 2001
Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id fAGElFt04040
	for <prolog@swi.psy.uva.nl>; Fri, 16 Nov 2001 15:47:15 +0100 (MET)
Received: from toffees.cs.tu-berlin.de (sebc@toffees.cs.tu-berlin.de [130.149.20.40])
	by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id PAA09648
	for <prolog@swi.psy.uva.nl>; Fri, 16 Nov 2001 15:42:03 +0100 (MET)
From: Sebastian John <sebc@cs.tu-berlin.de>
Received: (from sebc@localhost)
	by toffees.cs.tu-berlin.de (8.9.3/8.9.3) id PAA00813
	for prolog@swi.psy.uva.nl; Fri, 16 Nov 2001 15:42:02 +0100 (MET)
Message-Id: <200111161442.PAA00813@toffees.cs.tu-berlin.de>
To: prolog@swi.psy.uva.nl
Date: Fri, 16 Nov 2001 15:42:02 +0100 (MET)
X-Mailer: ELM [version 2.4ME+ PL60 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: [SWIPL] 

Hi,

thanks for your interests and your emails. But there is still a
problem.

> It is often possible to get huge speedups in Prolog code by
> rewriting the code to use better data structures or algorithms while
> remaining entirely in Prolog.

I can not fasten my problem by using minor prolog optimizations,
because the best theoretical known solution is exponential. I think
some tricks on the CPU cache would do it. 

To make the problem transparent: I use a predicate equiv(+A,+B). For
simplicity I assume A and B are lists. It is not necessary to know the
elements if there are of the kind atom, string, integer etc pp or
compound. The only thing is to know how much elements are in the lists
and which elements of A are part of B. So I want to use such things
like an array of the elements representing the lists A or B on which I
can efficiently compute, ie to test if the terms a identical. 

And I thought prolog use unique representations for all data
structures. I know prolog use unique representations for atoms. And
the only thing is to use them. Eg by getting the pointer to this
representations. Ie different pointers means different terms/atom/...
identical pointers means identical term/atom/... So I would save time
and code to explore the terms without to use PL_is_compound,
PL_is_atom, PL_is_string, PL_is_integer ... and PL_get_compound,
PL_get_atom, PL_get_string, PL_get_integer ..., and all the
PL_new_term_ref() for each substructure.

Perhaps there is no way:

> Not really clean what you want, but the PL_*_pointer() functions
> should be used for one purpose only: return C-pointers to Prolog and
> get the pointer back in C. Never manipulate the value in Prolog
> (other than copying, storing and retrieving).
>
> Normally you use it to give the location of a C-struct to Prolog.

Best

  Sebastian.

--------------------------------------------------------------------
Sebastian John,                    http://www.cs.tu-berlin.de/~sebc,
				        email: sebc@cs.tu-berlin.de,
                                          Tel:      +4930-314-24189,
TU-Berlin                                 Fax:      +4930-314-23516.


>> Hi
>> 
>> Im impressed of your prolog and I want to use it in my research.
>> Although Im not experienced in all details of SWI prolog Im going to
>> use the foreign code interface to fasten the computation. But there
>> are several problems.
>> 
>> To simplify my problem is: going throu a set of arbitrary elements
>> without a need of exploring the internal structure. The only thing is
>> to compare the elements of identity. I feel the PL_get_pointer
>> procedure would the shortest and fastest possibility to return me
>> unique val's of such a list. But unfortunately it fails and assigns -1
>> to ptr. I don't really know what this procedure dose due to the lag of
>> any description. 
>> 
>> Dose anyone know more ... or has a running sample using the
>> PL_get_pointer procedure ?

