[m-rev.] for review: reduce accesses to thread-specific variable

Peter Wang wangp at students.cs.mu.oz.au
Wed Jul 12 13:42:29 AEST 2006


On 2006-07-07, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> 
> On Fri, 7 Jul 2006, Peter Wang wrote:
> 
> > On saturn this change makes asm_jump.par.gc 7% slower than asm_jump.gc,
> > rather than 21% slower as it was before (according to speedtest).
> >
> > Estimated hours taken: 5
> > Branches: main
> >
> > In low-level, parallel grades which don't use gcc global registers, each
> > reference to a Mercury register (etc.) references a thread-specific Mercury
> > engine base address `MR_thread_engine_base'.  This is either a thread-specific
> > variable or a call to pthread_getspecific().  This patch improves performance
> > in these grades by copying `MR_thread_engine_base' once at the start of each
> > basic block into a local variable, then using the local copy for the rest of
> > the basic block.
> 
> s/the/that/
> 
> >
> > compiler/options.m:
> > 	Add `--local-thread-engine-base' option, enabled by default.
> 
> Does this option need to be set consistently for all modules during
> compilation, or is it safe for some modules to be compiled with
> --local-thread-engine-base and some with --no-thread-engine-base.  If the
> former then the documentation should make mention of it.

It's safe.

> 
> Also, you need to update the user's guide.
> 
> The rest looks okay.

I'm not sure about this patch now.  In the "Compiling logic programs to C"
paper it says (on page 9, about inter-function jumps):

    The main precautions necessary to avoid trouble are (a) making sure
    that none of the functions involved has any local variables [...]

The change I'm making with this patch *is* introducing local variables.
Instead of:

    MR_define_entry(mercury__main_2_0);
	...code...
    MR_def_label(main_2_0,2)
	...more code...

it becomes:

    MR_define_entry(mercury__main_2_0);
	MercuryEngine *MR_local_thread_engine_base = MR_thread_engine_base;
	...code...
    MR_def_label(main_2_0,2)
        MercuryEngine *MR_local_thread_engine_base = MR_thread_engine_base;
	...more code...

where the code now references MR_local_thread_engine_base instead of
MR_thread_engine_base.

Peter

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at csse.unimelb.edu.au
administrative address: owner-mercury-reviews at csse.unimelb.edu.au
unsubscribe: Address: mercury-reviews-request at csse.unimelb.edu.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list