Skip to content

Commit

Permalink
build: cmake: unsupported compilers cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
spalicki committed Jan 2, 2025
1 parent 6602131 commit aea91c9
Show file tree
Hide file tree
Showing 31 changed files with 157 additions and 260 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ Runtime-specific dependencies:

### Validated Configurations

CPU engine was validated on RedHat\* Enterprise Linux 8 with
* GNU Compiler Collection 5.4, 6.1, 7.2, 8.1, 9.1, 11.1, 11.3
* Clang\* 7.1, 8.0, 9.0, 14.0.6
x86-64 CPU engine was validated on RedHat\* Enterprise Linux 8 with
* GNU Compiler Collection 8.5, 9.5, 11.1, 11.3
* Clang\* 11.0, 14.0.6
* [Intel oneAPI DPC++/C++ Compiler] 2024.0

on Windows Server\* 2019 with
Expand All @@ -307,16 +307,19 @@ on Windows Server\* 2019 with
on macOS 11 (Big Sur) with
* Apple LLVM version 13.0

on Ubuntu 20.04 AArch64 with
* GNU Compiler Collection 7.0, 8.0, 9.0, 10.0
* Clang\* 9.0, 17.0
AArch64 CPU engine was validated on Ubuntu 22.04 with
* GNU Compiler Collection 10.0, 13.0
* Clang\* 17.0
* [Arm Compiler for Linux] 24.04
* [Arm Compute Library (ACL)] built for armv8-a arch, latest stable version
available at the time of release

on macOS 14 (Sonoma) with
* Apple LLVM version 15.0

GPU engine was validated on Ubuntu\* 22.04 with
* GNU Compiler Collection 7.2, 8.1, and 9.1
* Clang 7.1, 8.0, 9.0
* GNU Compiler Collection 8.5, and 9.5
* Clang 11.0
* [Intel oneAPI DPC++/C++ Compiler] 2024.0
* [Intel Software for General Purpose GPU capabilities] latest stable version
available at the time of release
Expand Down
9 changes: 1 addition & 8 deletions cmake/OpenMP.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2017-2024 Intel Corporation
# Copyright 2017-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,13 +52,6 @@ if(NOT OpenMP_CXX_FOUND AND MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "(Clang|Intel
# The ICX driver doesn't link OpenMP library even if `/Qopenmp`
# was specified.
set(OpenMP_FLAGS "/Qopenmp -Xclang --dependent-lib=libiomp5md")
else()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
# version < 10 can't pass cl-style `/openmp` flag
set(OpenMP_FLAGS "-Xclang -fopenmp")
# ... and requires explicit linking against omp library
set(OpenMP_CXX_LIBRARIES "libomp.lib")
endif()
endif()
set(OpenMP_C_FLAGS ${OpenMP_FLAGS})
set(OpenMP_CXX_FLAGS ${OpenMP_FLAGS})
Expand Down
16 changes: 6 additions & 10 deletions cmake/SDL.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2017-2024 Intel Corporation
# Copyright 2017-2025 Intel Corporation
# Copyright 2021 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,14 +30,10 @@ macro(sdl_unix_common_ccxx_flags var)
append(${var} "-fPIC -Wformat -Wformat-security")
endmacro()

macro(sdl_gnu_common_ccxx_flags var gnu_version)
if(${gnu_version} VERSION_LESS 4.9)
append(${var} "-fstack-protector-all")
else()
append(${var} "-fstack-protector-strong")
if(NOT (${gnu_version} VERSION_LESS 8.0) AND (DNNL_TARGET_ARCH STREQUAL "X64"))
append(${var} "-fcf-protection=full")
endif()
macro(sdl_gnu_common_ccxx_flags var)
append(${var} "-fstack-protector-strong")
if(DNNL_TARGET_ARCH STREQUAL "X64")
append(${var} "-fcf-protection=full")
endif()
endmacro()

Expand Down Expand Up @@ -65,7 +61,7 @@ if(UNIX)
append(ONEDNN_SDL_COMPILER_FLAGS "-D_FORTIFY_SOURCE=2")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
sdl_gnu_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS CMAKE_CXX_COMPILER_VERSION)
sdl_gnu_common_ccxx_flags(ONEDNN_SDL_COMPILER_FLAGS)
sdl_gnu_src_ccxx_flags(CMAKE_SRC_CCXX_FLAGS)
sdl_gnu_example_ccxx_flags(CMAKE_EXAMPLE_CCXX_FLAGS)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
Expand Down
8 changes: 2 additions & 6 deletions cmake/coverage.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2019-2024 Intel Corporation
# Copyright 2019-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,11 +36,7 @@ if("${DNNL_CODE_COVERAGE}" STREQUAL "GCOV")
message(FATAL_ERROR "GCOV not found in path")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3)
message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...")
endif()
elseif(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang|GNU")
message(FATAL_ERROR "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/host_compiler.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2021-2024 Intel Corporation
# Copyright 2021-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,7 +78,7 @@ if(DPCPP_HOST_COMPILER_KIND MATCHES "^(GNU|CLANG)$")

if(DPCPP_HOST_COMPILER_KIND STREQUAL "GNU")
platform_gnu_nowarn_ccxx_flags(DPCPP_CXX_NOWARN_FLAGS ${DPCPP_HOST_COMPILER_MAJOR_VER}.${DPCPP_HOST_COMPILER_MINOR_VER})
sdl_gnu_common_ccxx_flags(DPCPP_HOST_COMPILER_OPTS DPCPP_HOST_COMPILER_VER)
sdl_gnu_common_ccxx_flags(DPCPP_HOST_COMPILER_OPTS)
sdl_gnu_src_ccxx_flags(DPCPP_SRC_CXX_FLAGS)
sdl_gnu_example_ccxx_flags(DPCPP_EXAMPLE_CXX_FLAGS)

Expand Down
10 changes: 5 additions & 5 deletions cmake/host_compiler_id.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2024 Intel Corporation
# Copyright 2024-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -98,13 +98,13 @@ message(STATUS "Host compiler version: ${DPCPP_HOST_COMPILER_MAJOR_VER}.${DPCPP_

# Check the version of the provided host compiler.
if(DPCPP_HOST_COMPILER_KIND STREQUAL "GNU")
if((DPCPP_HOST_COMPILER_MAJOR_VER LESS 7) OR (DPCPP_HOST_COMPILER_MAJOR_VER EQUAL 7 AND DPCPP_HOST_COMPILER_MINOR_VER LESS 4))
message(FATAL_ERROR "The minimum version of ${DPCPP_HOST_COMPILER_KIND} host compiler is 7.4.")
if(DPCPP_HOST_COMPILER_MAJOR_VER LESS 8)
message(FATAL_ERROR "The minimum version of ${DPCPP_HOST_COMPILER_KIND} host compiler is 8.0.")
endif()
endif()

if(DPCPP_HOST_COMPILER_KIND STREQUAL "CLANG")
if(DPCPP_HOST_COMPILER_MAJOR_VER LESS 8)
message(FATAL_ERROR "The minimum version of ${DPCPP_HOST_COMPILER_KIND} host compiler is 8.0.")
if(DPCPP_HOST_COMPILER_MAJOR_VER LESS 11)
message(FATAL_ERROR "The minimum version of ${DPCPP_HOST_COMPILER_KIND} host compiler is 11.0.")
endif()
endif()
13 changes: 1 addition & 12 deletions cmake/platform.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#===============================================================================
# Copyright 2016-2024 Intel Corporation
# Copyright 2016-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -360,12 +360,6 @@ elseif(UNIX OR MINGW)
append(CMAKE_CCXX_FLAGS "-Wno-ignored-attributes")
endif()

# XXX: Suppress an erroneous warning of nested lambda visibility
# exceeding that of the containing class (GCC Bugzilla - Bug 80947).
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0)
append(CMAKE_CCXX_FLAGS "-Wno-attributes")
endif()

if(DNNL_TARGET_ARCH STREQUAL "AARCH64")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEF_ARCH_OPT_FLAGS "-O3")
Expand Down Expand Up @@ -484,10 +478,5 @@ if (DNNL_TARGET_ARCH STREQUAL "RV64")
message(STATUS "DNNL_RISCV_USE_RVV_INTRINSICS: ${DNNL_RISCV_USE_RVV_INTRINSICS}")
endif()

# Old compiler versions do not support warnings available on newer compilers.
if(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?[Cc]lang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0.0)
append(CMAKE_CCXX_FLAGS "-Wno-unknown-warning-option")
endif()

append(CMAKE_C_FLAGS "${CMAKE_CCXX_FLAGS}")
append(CMAKE_CXX_FLAGS "${CMAKE_CCXX_FLAGS}")
32 changes: 1 addition & 31 deletions src/common/compiler_workarounds.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2020-2024 Intel Corporation
* Copyright 2020-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,6 @@
#ifndef COMPILER_WORKAROUNDS_HPP
#define COMPILER_WORKAROUNDS_HPP

#if (defined __GNUC__) && (!defined(__INTEL_COMPILER)) \
&& (!defined(__INTEL_LLVM_COMPILER)) && (!defined(__clang__major__))
#define NEED_GCC_WA_CHECK 1
#endif

// Workaround 01: clang.
//
// Clang has an issue [1] with `#pragma omp simd` that might lead to segfault.
Expand All @@ -48,31 +43,6 @@
#define CLANG_WA_02_SAFE_TO_USE_OMP_SIMD 1
#endif

// Workaround 03: GCC
//
// For very large functions with too much control flow (i.e. if, switch, goto
// statements), GCC 7 may struggle to perform optimizations based on tree
// dominator (i.e. -ftree-dominator-opts, which is enabled with O1), thereby
// producing an internal compiler error (ICE). Specifically, it seems that the
// jump threading optimization is the culprit, which cannot be disabled on its
// own. There is no reliable way to reproduce the ICE, therefore it is not clear
// which __GCC_MINOR__ version fixes issue.
#if (defined NEED_GCC_WA_CHECK) && (__GNUC__ == 7)
#define GCC_WA_NO_TREE_DOMINATOR_OPTS 1
#else
#define GCC_WA_NO_TREE_DOMINATOR_OPTS 0
#endif

// Workaround 05: GCC
//
// NOTE: inside lambda, type cast variables captured by reference using
// either c-like "(type)var" or functional "type(var)" notation in order
// to avoid gcc7 bug with c++14 standard
// (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83204).
#if (defined NEED_GCC_WA_CHECK) && (__GNUC__ <= 7)
#define GCC_WA_LAMBDA_C_CAST
#endif

// Workaround 05: c++17 vs c++20
//
// C++17/20 are contradictory wrt capturing this and using default '=' capture.
Expand Down
14 changes: 1 addition & 13 deletions src/common/dnnl_thread.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2017-2023 Intel Corporation
* Copyright 2017-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -192,18 +192,6 @@ inline int dnnl_get_current_num_threads() {
#define PRAGMA_OMP_SIMD(...) PRAGMA_MACRO(CHAIN2(omp, simd __VA_ARGS__))
#endif // defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER)

// process simdlen; it is supported for Clang >= 3.9; ICC >= 17.0; GCC >= 6.1
// No support on Windows.
#if (defined(__clang_major__) \
&& (__clang_major__ < 3 \
|| (__clang_major__ == 3 && __clang_minor__ < 9))) \
|| (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1700) \
|| (!defined(__INTEL_COMPILER) && !defined(__clang__) \
&& (defined(_MSC_VER) || __GNUC__ < 6 \
|| (__GNUC__ == 6 && __GNUC_MINOR__ < 1)))
#define simdlen(x)
#endif // long simdlen if

namespace dnnl {
namespace impl {

Expand Down
6 changes: 1 addition & 5 deletions src/cpu/matmul/gemm_bf16_matmul.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2019-2024 Intel Corporation
* Copyright 2019-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -271,11 +271,7 @@ status_t gemm_bf16_matmul_t<dst_type>::execute_ref(
const dim_t acc_stride = gemm_based::get_scratchpad_block_elements(
batch, M, N, use_single_gemm_call, nthr);

#ifdef GCC_WA_LAMBDA_C_CAST
parallel(nthr, [= WA_THIS_COPY_CAPTURE, &st](int ithr, int nthr) {
#else
parallel(nthr, [&](int ithr, int nthr) {
#endif
size_t t_work_start {0}, t_work_end {0};
balance211(work_amount, nthr, ithr, t_work_start, t_work_end);

Expand Down
6 changes: 1 addition & 5 deletions src/cpu/matmul/gemm_x8s8s32x_matmul.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2019-2024 Intel Corporation
* Copyright 2019-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -297,11 +297,7 @@ status_t gemm_x8s8s32x_matmul_t::execute_ref(const exec_ctx_t &ctx) const {
bool postops_in_matmul = need_post_processing(pd(), dst_zero_point_f32);
assert(IMPLICATION(postops_in_matmul, params.has_pp_kernel_));

#ifdef GCC_WA_LAMBDA_C_CAST
parallel(nthr, [= WA_THIS_COPY_CAPTURE, &st](int ithr, int nthr) {
#else
parallel(nthr, [&](int ithr, int nthr) {
#endif
size_t t_work_start {0}, t_work_end {0};
balance211(work_amount, nthr, ithr, t_work_start, t_work_end);

Expand Down
4 changes: 2 additions & 2 deletions src/cpu/x64/gemm/amx/jit_avx512_core_amx_copy_kern.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2020-2021 Intel Corporation
* Copyright 2020-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@ class jit_avx512_core_amx_copy_kern : public jit_generator {
void copy_n(int unroll_n, Xbyak::Label &epilogue);
void copy_ns(int unroll_n, Xbyak::Label &epilogue);

void generate() override ATTRIBUTE_OPTIMIZE;
void generate() override;

private:
static const int offset_a_ = 0, offset_b_ = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/x64/gemm/amx/jit_avx512_core_amx_gemm_kern.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2020-2021 Intel Corporation
* Copyright 2020-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ class jit_avx512_core_amx_gemm_kern : public jit_generator {
DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_avx512_core_amx_gemm_kern);

protected:
void generate() override ATTRIBUTE_OPTIMIZE;
void generate() override;
const int typea;
const int typeb;
const int typec;
Expand Down
Loading

0 comments on commit aea91c9

Please sign in to comment.