Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#6,107 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
43/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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;
}
主要言語
C
スター
7.6k
フォーク
1.7k
平均マージ
1日 11時間
マージ済み PR(30日)
53

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenMathLib/OpenBLAS のほかの issue

OpenMathLib/OpenBLAS の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。