octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #66882] Convolution code path improvements


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #66882] Convolution code path improvements
Date: Tue, 22 Apr 2025 06:14:15 -0400 (EDT)

Follow-up Comment #58, bug #66882 (group octave):

Using the Fortran types is probably better. If I recall correctly, the C++
standard makes some guarantees about the complex types. But there might still
be some differences between the C and C++ types on some platforms (e.g.,
alignment, calling convention, ...).

I'm currently not set up to reproduce this locally. The error happened in a CI
run. So, I can't readily test if this helps.

Something like the following (untested) would probably work:

diff --git a/liboctave/numeric/oct-convn.cc b/liboctave/numeric/oct-convn.cc
--- a/liboctave/numeric/oct-convn.cc
+++ b/liboctave/numeric/oct-convn.cc
@@ -98,12 +98,12 @@ blas_axpy (const F77_INT& n, const F77_D
            const F77_INT& incx, F77_DBLE_CMPLX *y, const F77_INT& incy)
 {
   // Create a temporary complex array from x
-  std::vector<F77_DBLE_CMPLX> cx(n);
+  OCTAVE_LOCAL_BUFFER (F77_DBLE_CMPLX, cx, n);
   for (F77_INT i = 0; i < n; i++)
-    cx[i] = F77_DBLE_CMPLX(x[i * incx]);
+    cx[i] = F77_DBLE_CMPLX (x[i * incx]);
 
   // Use zaxpy with the complex temporary
-  F77_FUNC (zaxpy, ZAXPY) (n, alpha, cx.data (), incx, y, incy);
+  F77_FUNC (zaxpy, ZAXPY) (n, alpha, cx, incx, y, incy);
 }
 
 // complex<float> * float  - by promoting to complex
@@ -112,12 +112,12 @@ blas_axpy (const F77_INT& n, const F77_C
            const F77_INT& incx, F77_CMPLX *y, const F77_INT& incy)
 {
   // Create a temporary complex array from x
-  std::vector<F77_CMPLX> cx(n);
+  OCTAVE_LOCAL_BUFFER (F77_CMPLX, cx, n);
   for (F77_INT i = 0; i < n; i++)
-    cx[i] = F77_CMPLX(x[i * incx]);
+    cx[i] = F77_CMPLX (x[i * incx]);
 
   // Use caxpy with the complex temporary
-  F77_FUNC (caxpy, CAXPY) (n, alpha, cx.data (), incx, y, incy);
+  F77_FUNC (caxpy, CAXPY) (n, alpha, cx, incx, y, incy);
 }
 
 // Generic fallback for types without BLAS support




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66882>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature


reply via email to

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