[m-dev.] Re: tabled_for_io interacts badly with c code which contains labels
Ian MacLarty
maclarty at cs.mu.OZ.AU
Tue Aug 9 13:02:35 AEST 2005
On 9 Aug 2005, at 12:30, Zoltan Somogyi wrote:
> On 08-Aug-2005, Ian MacLarty <maclarty at cs.mu.OZ.AU> wrote:
>> Zoltan, could we wrap the original code in a procedure,
>
> In many cases, the body is much cheaper to execute than a function
> call,
> so that would be a significant performance loss. However, there is no
> reason
> why the author of the foreign_proc can't use that technique where it is
> needed.
>
I don't agree with requiring the author to change their code to make it
work with I/O tabling. This might mean existing libraries which make
use of foreign code would need to be modified to work with the
declarative debugger which is undesirable.
>> or change the
>> I/O tabling transformation somehow to overcome this problem?
>
> We could modify the transformation to put something like
> "#define MR_IO_TABLING_COPY_NUM 1" before one copy and
> "#define MR_IO_TABLING_COPY_NUM 2" before the other, and let the C code
> include that macro in the label name.
>
This has the same problem where the implementor of the foreign proc
must be aware of I/O tabling and the limitations it imposes.
What about changing the transformation to something like the following?
p(A, B, S0, S) :-
(if
% Get the global I/O table, the global I/O
% counter, and the starting point for tabling
% I/O actions, if we are in the tabled range.
table_io_in_range(T0, Counter, Start)
then
% Look up the input arguments.
impure table_lookup_insert_start_int(T0, Counter,
Start, T),
(if
semipure table_io_has_occurred(T)
then
semipure table_memo_get_answer_block(T, Block),
impure table_restore_string_answer(Block, 0, B),
RunOrigCode = no,
SaveAnswers = no
else
RunOrigCode = yes,
SaveAnswers = yes
)
else
RunOrigCode = yes,
SaveAnswers = no
),
(
RunOrigCode = yes,
<original code>,
(
SaveAnswers = yes,
% Save the answers in the table.
impure table_io_create_answer_block(T, 1, Block),
impure table_save_string_answer(Block, 0, B)
;
SaveAnswers = no
)
;
RunOrigCode = no,
table_io_copy_io_state(S0, S)
).
Surely not copying the code would be more cache efficient?
Ian.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list