Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#6,107 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
43/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
c
Domínio
backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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;
}
Linguagem predominante
C
Estrelas
7.6k
Forks
1.7k
Merge médio
1d 13h
PRs com merge (30d)
50

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de OpenMathLib/OpenBLAS

Todas as issues de OpenMathLib/OpenBLAS

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.