Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

CBLAS complex non-absolute index extensions depend on stride-hole elements

Ouverte
#6,107 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
43/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
c
Domaine
backend

Piste de recherche

Read interface/imax.c, especially the non-absolute path selecting ISMAX_K/ISMIN_K and IDMAX_K/IDMIN_K, then trace how the complex CBLAS wrapper passes incx. Use the provided Linux reproducer with an LP64 library and 32-bit BLAS integers; done means the four functions' results no longer depend on stride-hole values, without changing the separate absolute-extrema path. The intended general complex ordering remains unresolved.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

cblas_icmax, cblas_icmin, cblas_izmax, and cblas_izmin return different
indexes when only the unused elements between the specified complex inputs
are changed.

With n=4 and incx=2 (interpreted in complex elements), the logical inputs
are elements 0, 2, 4, and 6: [1+0i, 2+0i, 3+0i, 4+0i]. The baseline fills
holes 1, 3, and 5 with zero; the second array fills those holes with
[100+0i, -100+0i, 50+0i]. The logical inputs are bit-for-bit identical.

The central problem is dependence on stride-hole memory. Under the usual
real-axis ordering the expected zero-based max/min indexes are 3/0, but the
input-invariance failure does not require choosing a general ordering for
complex numbers. These are the non-absolute index extensions, not
cblas_icamax or cblas_izamax.

Observed output

The unchanged reproducer below prints this on the independently checked
0.3.21 binary:

REPRO: cblas_icmax expected=3 baseline=2 changed_holes=1
REPRO: cblas_icmin expected=0 baseline=1 changed_holes=3
REPRO: cblas_izmax expected=3 baseline=2 changed_holes=1
REPRO: cblas_izmin expected=0 baseline=1 changed_holes=3
SUMMARY: BUG reproduced=4/4

The independently checked 0.3.30 binary gives the same numeric results, with
scipy_ prefixed symbol names.

Source diagnosis

In interface/imax.c at v0.3.34,
the non-absolute path selects the real ISMAX_K / ISMIN_K or
IDMAX_K / IDMIN_K kernel, even when COMPLEX is defined. The CBLAS wrapper
casts to FLOAT * and passes incx without converting complex-element stride
to scalar stride. That explains this witness: for scalar step 2 it sees
[1, 0, 2, 0] or [1, 100, 2, -100], rather than the four logical inputs.

A fix needs to address the complex-to-scalar stride conversion without
changing the separate absolute-extrema path. Simply doubling the stride is
a candidate direction for this real-axis witness, not a demonstrated complete
fix or a definition of the extensions' general complex ordering. Please
clarify the intended contract if these exported extensions are meant to use a
different stride or comparison convention.

Runtime evidence and source scope

An independent x86-64 Linux check reproduced the result in both of these
existing bundled libraries, using GCC 14.2.0 and OPENBLAS_NUM_THREADS=1:

Library openblas_get_config() Reproduction
CasADi-bundled libcasadi-tp-openblas.so OpenBLAS 0.3.21 NO_AFFINITY CORE2 MAX_THREADS=16 Four of four exports
SciPy-bundled libscipy_openblas-6cdc3b4a.so OpenBLAS 0.3.30 DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=64 Four of four exports; only the lookup names were changed to add scipy_

These are configuration strings from particular distributed binaries, not
claims about every build of those releases. The original investigation also
reported the same result in AArch64 builds of v0.3.34 (e0166008be8e466242aa76b2ff75ce3f0fbf574a) and
31e82fa8c509e6f0d96288de3c20d8916d894e72. Those AArch64 runs were not independently repeated in the x86-64
check; the physical runner/operating-system details are not inferred here.

The relevant source was inspected at v0.3.34 and 31e82fa8c509e6f0d96288de3c20d8916d894e72. At the time of
review, develop was 277ef7801416412ee970873701fdf14d603d2c3f; its intervening WASM packing commit does not
change these interface files. The current-head statement is a source check,
not a claim of running a binary built from that commit.

Reproduce on Linux

Use an LP64 OpenBLAS shared library with 32-bit BLAS integers and unprefixed
symbols, compiled for the same architecture as the test. Do not use this
hard-coded int call interface against an ILP64 / INTERFACE64=1 library.

cc -O2 -Wall -Wextra -Werror -o repro repro.c -ldl
OPENBLAS_NUM_THREADS=1 ./repro /absolute/path/to/libopenblas.so

Exit 0 means all four bug witnesses were reproduced. Exit 1 means incomplete
reproduction, not proof of correctness; exit 2 means a detected setup error.
No register-poisoning harness is needed for this direct-call reproducer.

Complete repro.c
/* Fixed-array reproduction for the non-absolute complex index extensions.
 * Only complex elements 0, 2, 4 and 6 belong to the input with incx=2. */
#include <dlfcn.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

typedef size_t (*index_fn)(int, const void *, int);

static size_t check(void *lib, const char *name, const void *baseline,
                    const void *changed_holes, size_t expected) {
    index_fn fn = (index_fn)dlsym(lib, name);
    if (!fn) { fprintf(stderr, "missing %s\n", name); exit(2); }
    size_t first = fn(4, baseline, 2);
    size_t second = fn(4, changed_holes, 2);
    printf("REPRO: %s expected=%zu baseline=%zu changed_holes=%zu\n",
           name, expected, first, second);
    return first != second && second != expected;
}

int main(int argc, char **argv) {
    if (argc != 2) { fprintf(stderr, "usage: repro LIBRARY\n"); return 2; }
    void *lib = dlopen(argv[1], RTLD_NOW | RTLD_LOCAL);
    if (!lib) { fprintf(stderr, "dlopen: %s\n", dlerror()); return 2; }
    /* Seven complex elements, stored as interleaved real/imaginary scalars.
     * The four logical inputs (elements 0, 2, 4, 6) are identical; only
     * the three unused stride holes differ between the two arrays. */
    const float cf_base[] = {1,0, 0,0, 2,0, 0,0, 3,0, 0,0, 4,0};
    const float cf_holes[] = {1,0, 100,0, 2,0, -100,0, 3,0, 50,0, 4,0};
    const double zd_base[] = {1,0, 0,0, 2,0, 0,0, 3,0, 0,0, 4,0};
    const double zd_holes[] = {1,0, 100,0, 2,0, -100,0, 3,0, 50,0, 4,0};
    size_t bugs = 0;
    bugs += check(lib, "cblas_icmax", cf_base, cf_holes, 3);
    bugs += check(lib, "cblas_icmin", cf_base, cf_holes, 0);
    bugs += check(lib, "cblas_izmax", zd_base, zd_holes, 3);
    bugs += check(lib, "cblas_izmin", zd_base, zd_holes, 0);
    printf("SUMMARY: %s reproduced=%zu/4\n", bugs == 4 ? "BUG" : "INCOMPLETE", bugs);
    dlclose(lib);
    return bugs == 4 ? 0 : 1;
}
Langage dominant
C
Étoiles
7.6k
Forks
1.7k
Merge moyen
1 j 13 h
PR mergées (30 j)
50

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de OpenMathLib/OpenBLAS

Toutes les issues de OpenMathLib/OpenBLAS

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.