serge-sans-paille/pythran

Compile issue

Closed this issue · 2 comments

Hi,

I'm encountering a compile issue with code that used to work fine for a long time. I am a bit lost with this as I get c++ errors that shouldn't really be there. What makes this weirder is that it also is present if I downgrade to pythran 0.10 (which definitely used to work) or upgrade to latest HEAD and is present on both clang and gcc. I'm using arch linux.

$gcc --version
gcc (GCC) 13.1.1 20230714
$clang --version
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$uname -r 
6.4.7-arch1-1
$pythran --version
0.13.1

I could reduce it down to the following (sorry quite long, but further reduction seems to compile):

import numpy as np


def apply_filter(E, wx):
    pols = E.shape[0]
    Ntaps = wx.shape[1]
    Xest = E.dtype.type(0)
    for k in range(pols):
        for i in range(Ntaps):
            Xest += E[k, i]*np.conj(wx[k,i])
    return Xest

#pythran export train_equaliser(complex128[][], int, int, int, float64, complex128[][][], int[], bool, complex128[][], str)
#pythran export train_equaliser(complex64[][], int, int, int, float32, complex64[][][], int[], bool, complex64[][], str)
def train_equaliser(E, TrSyms, Niter, os, mu, wx, modes, adaptive, symbols,  method):
    if method == "mcma":
        errorfct = mcma_error
    elif method == "cma":
        errorfct = cma_error
    else:
        raise ValueError("Unknown method %s"%method)
    nmodes = E.shape[0]
    ntaps = wx.shape[-1]
    assert symbols.shape[0] == nmodes, "symbols must be at least size of modes"
    assert wx.shape[0] == nmodes, "wx needs to have at least as many dimensions as the maximum mode"
    assert E.shape[1] > TrSyms*os+ntaps, "Field must be longer than the number of training symbols"
    assert modes.max() < nmodes, "Maximum mode number must not be higher than number of modes"
    err = np.zeros((nmodes, TrSyms*Niter), dtype=E.dtype)
    #omp parallel for
    for mode in modes:
        for it in range(Niter):
            for i in range(TrSyms):
                X = E[:, i * os:i * os + ntaps]
                Xest = apply_filter(X,  wx[mode])
                err[mode, it*TrSyms+i] = errorfct(Xest, symbols[mode], i)
                wx[mode] += mu * np.conj(err[mode, it*TrSyms+i]) * X
    return err, wx, mu

######################################################
# Error functions
######################################################

def mcma_error(Xest, s1, i):
    J = Xest.dtype.type(1j)
    dr = (s1[0].real - Xest.real**2)
    di = (s1[0].imag - Xest.imag**2)
    return dr*Xest.real + di*Xest.imag*J

def cma_error(Xest, s1, i):
    d = s1[0].real - abs(Xest)**2

Error logs are attached (too long to include here)
log_clang.txt
log_gcc.txt

Not sure what to make of this

Ok I wiggled it down a bit further, not sure if that helps though:

import numpy as np


#pythran export train_equaliser(complex128[][], int, int, int, float64, complex128[][][], int[], bool, complex128[][], str)
def train_equaliser(E, TrSyms, Niter, os, mu, wx, modes, adaptive, symbols,  method):
    if method == "mcma":
        errorfct = cma_error
    elif method == "cma":
        errorfct = mcma_error
    nmodes = E.shape[0]
    for mode in modes:
        err = errorfct(E[0,0], symbols[mode], mode)
    return err, wx, mu

######################################################
# Error functions
######################################################

def cma_error(Xest, s1, i):
    return Xest

def mcma_error(Xest, s1, i):
    return Xest

Reduced test case:

import numpy as np


#pythran export train_equaliser(complex128[][], int[], str)
def train_equaliser(E,  modes, method):
    if method == "mcma":
        errorfct = cma_error
    elif method == "cma":
        errorfct = mcma_error
    mode = modes[0]
    err = errorfct(E[0,0], mode)
    return err

######################################################
# Error functions
######################################################

def cma_error(Xest, i):
    return Xest

def mcma_error(Xest, i):
    return Xest