octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patches to enable MSVC compilation


From: Jaroslav Hajek
Subject: Re: Patches to enable MSVC compilation
Date: Tue, 8 Dec 2009 14:02:23 +0100

On Mon, Dec 7, 2009 at 9:39 PM, Michael Goffioul
<address@hidden> wrote:
> Hi,
>
> Here are 3 patches that re-enable compilation of octave with MSVC.
> I splitted the whole stuff in 3 parts to allow separate handling:
> - msvc_config.diff: changes in the configure script to take into account
>  that *-*-msdosmsvc is not a valid build target anymore with libtool, plus
>  some Makefile changes

> - msvc_compile.diff: code changes that should be safe to apply and
>  should not change the existing logic

I applied those bits that are actually fixes and should be applied
regardless, plus the one workaround in oct-stream.cc that simplifies
code.

Regarding the remaining workaround in dbleQR.h, this is a bug in MSVC
and slightly "downgrades" the code: with this change, the QR::
constants can't be used in integral constant exprs, like regular enums
can. OTOH, this doesn't seem to be currently needed anywhere.
So if this is to be applied, I think it should be clearly marked as a
workaround for certain MSVC version, so that it can be reverted when
no longer needed.

> - msvc_template_bug.diff: changes needed to work around an MSVC
>  template handling bug (seems to be linked to functions as template
>  parameter, while the function signature uses inner types)
>

I oppose this one as this goes against the logic of my recent changes
in mx-inlines and the change is distributed across number of files and
hence not easy to revert. mx-inlines defines "loops" and "appliers",
with loops separated from the appliers.
Further, according to my expectations, this seems to slow some of the
mappers down:

n = 1e7;
a = rand (n, 1);
tic; isnan (a); toc
tic; isinf (a); toc
tic; isfinite (a); toc

current tip (Core 2 Duo @ 1.83GHz, g++ 4.3.3 at -O3 -march=native):
Elapsed time is 0.0301731 seconds.
Elapsed time is 0.0341551 seconds.
Elapsed time is 0.03547 seconds.

with the workaround:
Elapsed time is 0.05843 seconds.
Elapsed time is 0.0553551 seconds.
Elapsed time is 0.0605021 seconds.

so it's a 60-80% slowdown.  The reason probably is that a call to a
function template parameter is always treated as a normal call
(because it's compile-time reference), hence subject to normal
inlining, but a call to a function pointer can only be inlined if the
whole function is inlined and the pointer value is const-propagated to
the code. Apparently GCC still does this when there is a single
instance in a .cc file (abs, conj are not affected) but not when there
are multiple ones (isnan, isinf, isfinite).

I'd suggest you keep the patch as an extra for MSVC and report the bug
to Microsoft (unless you already did).

best regards

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]