Conversation
This patch enables BLIS to build on Windows using Clang compilers with
GNU-style command-line interface (e.g., LLVM/Clang, not Clang-CL) and
adds compatibility for systems with OpenMP 2.0 implementations.
Changes:
1. CMakeLists.txt: Detect Clang with GNU frontend on Windows
- Check CMAKE_C_COMPILER_FRONTEND_VARIANT to distinguish GNU-style
Clang from MSVC-style Clang-CL
- Use -fopenmp-simd for GNU-style Clang on Windows
- Maintains backward compatibility with MSVC toolchain
2. frame/thread/bli_thread.c: Add OpenMP 2.0 compatibility shims
- Provide fallback implementations for omp_get_active_level() and
omp_get_max_active_levels() (OpenMP 3.0 functions)
- Windows SDK and some legacy OpenMP implementations only support
OpenMP 2.0
- Shims safely disable nested parallelism (rare in BLAS workloads)
- Zero performance overhead on systems with OpenMP 3.0+
Testing:
- Validated on Windows with TheRock's LLVM/Clang toolchain
- Builds successfully with OpenMP threading enabled
- ILP64 support functional
- Zen4-optimized kernels compile and link correctly
Rationale:
This enables BLIS to be built with consistent toolchains across Linux
and Windows platforms, supporting projects that use custom LLVM builds
rather than platform-default compilers.
Signed-off-by: Tony Davis <tony.davis@amd.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR enables BLIS to build on Windows using GNU-style Clang compilers (e.g., LLVM/Clang built from source) and adds compatibility for OpenMP 2.0 implementations. The changes support AMD's ROCm testing infrastructure while maintaining full backward compatibility with existing MSVC/Clang-CL toolchains.
Changes:
- Added compiler frontend detection in CMake to distinguish GNU-style Clang from MSVC/Clang-CL on Windows
- Added OpenMP 2.0 compatibility shims for functions introduced in OpenMP 3.0
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CMakeLists.txt | Adds detection of Clang with GNU-style frontend on Windows to use -fopenmp-simd instead of /openmp:experimental |
| frame/thread/bli_thread.c | Provides fallback implementations of omp_get_active_level() and omp_get_max_active_levels() for OpenMP 2.0 environments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove Clang-specific CMake changes (not needed for MSVC use case) - Use _OPENMP version check instead of _MSC_VER for better portability - _OPENMP < 200811 detects any OpenMP 2.x implementation (200203 = 2.0, 200811 = 3.0) - More future-proof: won't break when MSVC adds OpenMP 3.0 support - Thanks to GitHub Copilot for suggesting this improvement Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks @tony-davis - will look into this. |
|
@tony-davis , For more details on Contribution Guidelines and the process, please refer to https://github.com/amd/blis/blob/master/CONTRIBUTING.md. |
Summary
This PR adds compatibility for OpenMP 2.0 implementations (e.g., MSVC, older GCC) that lack functions introduced in OpenMP 3.0. BLIS currently uses
omp_get_active_level()andomp_get_max_active_levels()which are not available in OpenMP 2.0, preventing compilation on Windows with MSVC and other OpenMP 2.0 environments.Changes
frame/thread/bli_thread.cAdded OpenMP 2.0 compatibility shims that detect OpenMP version using the standard
_OPENMPmacro:Why
_OPENMP < 200811instead of_MSC_VER?_OPENMPis defined by all OpenMP-compliant compilers(Credit: GitHub Copilot suggested this improvement over the original
_MSC_VERcheck)Testing
Environment:
/openmpflag)Results:
Compatibility
Backward Compatibility: ✅ Fully maintained
Impact:
Checklist