perl6-internals
[Top] [All Lists]

Re: [perl #58410] [TODO] Deprecate n_* variants of the math opcodes

To: perl6-internals@perl.org
Subject: Re: [perl #58410] [TODO] Deprecate n_* variants of the math opcodes
From: Geoffrey Broadwell <geoff@broadwell.org>
Date: Thu, 28 Aug 2008 10:15:21 -0700
Cc: bugs-bitbucket@netlabs.develooper.com
Delivered-to: mailing list perl6-all@perl.org
Delivered-to: perl6-all-poster@perl.org
Delivered-to: mailing list perl6-internals@perl.org
Delivered-to: perl6-internals@perl.org
In-reply-to: <rt-3.6.HEAD-29762-1219907031-437.58410-72-0@perl.org>
List-help: <mailto:perl6-all-help@perl.org>
List-id: <perl6-all.perl.org>
List-id: <perl6-internals.perl.org>
List-post: <mailto:perl6-all@perl.org>
List-subscribe: <mailto:perl6-all-subscribe@perl.org>
List-unsubscribe: <mailto:perl6-all-unsubscribe@perl.org>
Mailing-list: contact perl6-all-help@perl.org; run by ezmlm
References: <RT-Ticket-58410@perl.org> <48B64DB6.8050200@perl.org> <rt-3.6.HEAD-29762-1219907031-437.58410-72-0@perl.org>
On Thu, 2008-08-28 at 00:03 -0700, Allison Randal wrote:
> Briefly discussed on the phone with Patrick, Jerry, and chromatic: The 
> versions of the math opcodes that modify an existing destination PMC 
> instead of creating a new destination PMC are not useful to HLLs, 
> because they make assumptions about assignment semantics that don't hold 
> true for all (or possibly even any) HLLs. Code generated from PCT takes 
> the result of the math op as a temporary result value, and then performs 
> a separate assignment operation to the HLL result variable, following 
> the HLLs semantics for assignment.
> 
> The plan is to make the regular variants (like 'add') create a new 
> destination PMC, and then deprecate the old n_* variants (like 'n_add').

What is the replacement for the old "regular" variants that use a
pre-existing destination?

A few years ago when I was doing copious Perl 5 PDL work, I found that
in certain loops I would get bottlenecked entirely by creation and
destruction of temporaries.  I might be doing several dozen math
operations per iteration, but I as the programmer knew that I only
needed a handful of temporaries, and these could be created outside the
loop.  The vast majority of the object cycling was quite obviously
wasted.  In some cases, I could work around this by considerably
uglifying the code and/or reaching through several layers of
abstraction, but sometimes there was no recourse except to drop to
PDL::PP (specially preprocessed C) or even C itself.

I'd like to be able to write decently-performing math libraries in PIR,
instead of having to drop down all the way to C.  Being forced to create
and destroy loads of temporaries I don't need will make this nigh
impossible, let alone putting a major strain on the GC subsystem.

Will there be some way to stay in PIR and still optimize away temporary
cycling?


-'f



<Prev in Thread] Current Thread [Next in Thread>