Re: Regression fails on Alpha True64 V5.0 for

Поиск
Список
Период
Сортировка
От Tegge, Bernd
Тема Re: Regression fails on Alpha True64 V5.0 for
Дата
Msg-id 5.1.0.14.0.20011121091945.0298c300@dragon.dr.repas.de
обсуждение исходный текст
Ответ на Re: Regression fails on Alpha True64 V5.0 for yesterdays cvs  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Regression fails on Alpha True64 V5.0 for yesterdays cvs  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-ports
At 14:27 19.11.01 -0500, Tom Lane wrote:
>"Tegge, Bernd" <tegge@repas-aeg.de> writes:
> > I've got a rather ugly but usable workaround. See attached timestamp.c
>
>My, that *is* ugly.  Surely there's gotta be something cleaner.
>
>I don't quite understand how it is that the Compaq compiler works at
>all, if it thinks it can optimize random memcpy operations into
>opcodes that assume aligned addresses.

Well, if both operands are ptr to double and the compiler/runtime
system aligns doubles except on explicit request (frex #pragma noalign)
the optimizer probably thought it was safe to replace the memcpy by a
load/store double operation. It probably should not have done this
after casting the pointers to void*, but it did ...

>  We should be coredumping in a
>lot more places than just this.  Since we're not, there's got to be
>some fairly straightforward way of defeating the optimization.
>The extra memcpy looks to me like black magic that doesn't really have
>anything directly to do with the problem.

I had to use the temp vars after the assignment. Otherwise the compiler
optimized them away. Sometimes this thing is amazing.


>I'm surprised that the (void *) cast didn't fix it.  Perhaps it would
>work to use DatumGetPointer rather than DatumGetIntervalP --- that is,
>never give the compiler any hint that the source might be considered
>double-aligned in the first place.

Thanks, *that* did it. We should just extend the comment block above
to going back to DatumGetIntervalP if the array code ever gets fixed.

*** timestamp.c.bak    Wed Nov 21 09:41:35 2001
--- timestamp.c    Wed Nov 21 09:44:46 2001
***************
*** 1569,1577 ****
       * buggy array code: it won't ensure proper alignment of Interval
       * objects on machines where double requires 8-byte alignment. That
       * should be fixed, but in the meantime...
       */
!     memcpy( (void *)&sumX, (void *)DatumGetIntervalP(transdatums[0]), sizeof(Interval));
!     memcpy( (void *)&N, (void *)DatumGetIntervalP(transdatums[1]), sizeof(Interval));
      newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
                                                  IntervalPGetDatum(&sumX),
                                               IntervalPGetDatum(newval)));
--- 1569,1578 ----
       * buggy array code: it won't ensure proper alignment of Interval
       * objects on machines where double requires 8-byte alignment. That
       * should be fixed, but in the meantime...
+      * If it ever gets fixed use DatumGetIntervalP instead of DatumGetPointer
       */
!     memcpy( (void *)&sumX, (void *)DatumGetPointer(transdatums[0]), sizeof(Interval));
!     memcpy( (void *)&N, (void *)DatumGetPointer(transdatums[1]), sizeof(Interval));
      newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl,
                                                  IntervalPGetDatum(&sumX),
                                               IntervalPGetDatum(newval)));
***************
*** 1606,1614 ****
       * buggy array code: it won't ensure proper alignment of Interval
       * objects on machines where double requires 8-byte alignment. That
       * should be fixed, but in the meantime...
       */
!     memcpy( (void *)&sumX, (void *)DatumGetIntervalP(transdatums[0]), sizeof(Interval));
!     memcpy( (void *)&N, (void *)DatumGetIntervalP(transdatums[1]), sizeof(Interval));
      /* SQL92 defines AVG of no values to be NULL */
      if (N.time == 0)
          PG_RETURN_NULL();
--- 1607,1616 ----
       * buggy array code: it won't ensure proper alignment of Interval
       * objects on machines where double requires 8-byte alignment. That
       * should be fixed, but in the meantime...
+          * If it ever gets fixed use DatumGetIntervalP instead of DatumGetPointer
       */
!     memcpy( (void *)&sumX, (void *)DatumGetPointer(transdatums[0]), sizeof(Interval));
!     memcpy( (void *)&N, (void *)DatumGetPointer(transdatums[1]), sizeof(Interval));
      /* SQL92 defines AVG of no values to be NULL */
      if (N.time == 0)
          PG_RETURN_NULL();

В списке pgsql-ports по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Darwin/MacOSX 10.1.1 newbie
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Regression fails on Alpha True64 V5.0 for yesterdays cvs