apache / apache/arrow

[C++][SIMD] Avoid one-definition-rule violation of `arrow::internal::BitmapWriter` without depending on `-O2`

Aperta
#36,902 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Component: C++ Type: enhancement
Lingua principale
C++
Stelle
17.1k
Fork
4.3k
Merge medio
3g 18h
PR unite (30g)
91

Descrizione

### Describe the enhancement requested

Contexts:

* https://github.com/apache/arrow/issues/31132#issuecomment-1378082076
* GH-14342
* GH-36685

We have runtime SIMD dispatch feature. For example, it's used in `cpp/src/parquet/level_conversion.cc` to run BMI2 based `DefLevelsToBitmap` implementation if available.

`DefLevelsToBitmap` (`DefLevelsToBitmapSimd`) is implemented in `cpp/src/parquet/level_conversion_inc.h` and it's built with/without BMI2. `DefLevelsToBitmapSimd` uses `arrow::internal::BitmapWriter`. If `arrow::internal::BitmapWriter` in `DefLevelsToBitmapSimd` is not inlined, one-definition-rule violation is happen. If it's happen, `libparquet.dylib` has two `BitmapWriter` definitions for with/without BMI2. If BMI2 version `BitmapWriter` is used on BMI2 unavailable machine, "illegal opcode" is happen.

GH-14342 resolved this by forcing to use `-O2` to enforce inlining. But it doesn't work with Homebrew. Because Homebrew overrides `-O*` specified by us.

If we can avoid one-definition-rule violation of `arrow::internal::BitmapWriter` without depending on `-O2`, we can provide a Homebrew bottle that can use the BMI2 based implementation on machines that support BMI2.

### Component(s)

C++

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with cpp/src/parquet/level_conversion.cc and cpp/src/parquet/level_conversion_inc.h, focusing on DefLevelsToBitmap, DefLevelsToBitmapSimd, and their use of arrow::internal::BitmapWriter. Check how the BMI2 and non-BMI2 variants are built and dispatched. Done means avoiding duplicate BitmapWriter definitions and illegal opcodes without depending on -O2, including for Homebrew builds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp
Ambito
build-system, performance
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.