ggml-blas: Fix BLAS Compile Definitions#18205
Conversation
7cff6e2 to
a33d9c5
Compare
…n if no blas vendor set
a33d9c5 to
a31b064
Compare
|
Hey @ggerganov there doesn't seem to be a code owner for ggml-blas. Who should I request a review from? |
There was a problem hiding this comment.
Pull request overview
This PR fixes BLAS compile definition issues where vendor-specific definitions (BLIS, NVPL, OpenBLAS, etc.) were not being set when BLAS_INCLUDE_DIRS was provided externally, causing compilation or linking problems.
Key changes:
- Moves BLAS vendor compile definitions from conditional pkg-config blocks to a consolidated section that executes for all configurations
- Adds support for AOCL and AOCL_mt vendors to set
GGML_BLAS_USE_BLIS - Adds missing
GGML_BLAS_USE_NVPLandGGML_BLAS_USE_OPENBLAScompile definitions - Replaces header-based
OPENBLAS_VERSIONchecks with CMake-basedGGML_BLAS_USE_OPENBLASchecks - Converts multiple independent
#ifblocks to mutually-exclusive#if/#elif/#elifchains for thread setting
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ggml/src/ggml-blas/CMakeLists.txt | Removes vendor-specific compile definitions from pkg-config block; adds consolidated compile definition logic that runs for all vendors; adds AOCL support and missing NVPL/OpenBLAS definitions |
| ggml/src/ggml-blas/ggml-blas.cpp | Replaces OPENBLAS_VERSION with GGML_BLAS_USE_OPENBLAS; converts separate #if blocks to #if/#elif/#elif chains for thread setting and vendor identification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if defined(GGML_BLAS_USE_OPENBLAS) | ||
| openblas_set_num_threads(ctx->n_threads); |
There was a problem hiding this comment.
The header inclusion logic (lines 9-19) doesn't explicitly handle GGML_BLAS_USE_OPENBLAS, falling through to the generic cblas.h include. This differs from the previous approach where OPENBLAS_VERSION (defined by OpenBLAS headers) was used to guard OpenBLAS-specific code, providing a guarantee that the declarations were available. With the new CMake-based GGML_BLAS_USE_OPENBLAS definition, there's a potential mismatch if the wrong cblas.h is found. Consider adding an explicit case for OpenBLAS in the header inclusion chain to include the OpenBLAS-specific header and ensure openblas_set_num_threads() and related functions are properly declared.
There was a problem hiding this comment.
Odd that Copilot annotated the wrong line. Line 18 is intentionally left as an else because I assume that handles the ATLAS and FlexiBLAS backends. I didn't change that logic.
|
Hm, honestly it's a bit difficult for me to trace the full logic of the changes. Are you confident enough this is an improvement / do you expect any potential issues? |
|
The main change is that in the original, each |
|
After this change, compilation warnings appeared in my MinGW64 build:
Compilation log: ...and so on. AI replaced in And the problem was solved. |
|
@AndVinni I agree with the AI suggestion to hide those warnings. Would you like to open a pull or should I? It seems that I fixed a bug for your build: Like me, you are setting |
|
Please proceed as you see fit. I will not have access to the industrial computer on which I built it for a long time, so I will not be able to re-verify. |
This PR fixes a few issues in encountered while building with BLAS:
BLAS_INCLUDE_DIRS, BLAS compile definitions (BLIS, NVPL, etc.) are not set because the vendor cases are not reachedGGML_BLAS_USE_BLISwas not set because the vendor is notFLAME.OPENBLAS_VERSIONdoes not seem to be a stable way to check for OpenBLAS. It was evaluating as true when I was building with AOCL. I changed it to be consistent with the other options (BLIS and NVPL).GGML_BLAS_USE_NVPLwas never set in any case.