Skip to content

CMakeLists.txt defaults to Debug build causing severe performance degradation #6

@tony-davis

Description

@tony-davis

Problem

AOCL's top-level CMakeLists.txt defaults both CMAKE_BUILD_TYPE and CMAKE_CONFIGURATION_TYPES to "Debug" if not explicitly set. This causes severe performance issues that are difficult to diagnose, as the README shows Release builds in all examples but never warns about the Debug default.

Impact

We encountered this when integrating AOCL 5.2 BLAS (ILP64) into our build system. Despite passing -DCMAKE_BUILD_TYPE=Release, we experienced:

  • 100-450x slowdowns on Level 3 triangular BLAS operations (trsm, trmm)
  • CI test timeouts (15+ minutes vs <1 minute expected)
  • No obvious indication the library was built in Debug mode

Root cause: We didn't pass -DCMAKE_CONFIGURATION_TYPES=Release, so BLIS silently built in Debug mode despite CMAKE_BUILD_TYPE=Release being set.

Code Location

CMakeLists.txt lines 13-23 (AOCL 5.2):

# Set the build configurations
if(NOT DEFINED CMAKE_CONFIGURATION_TYPES)
    set(CMAKE_CONFIGURATION_TYPES "Debug" CACHE STRING "Build configurations" FORCE)
elseif(CMAKE_CONFIGURATION_TYPES MATCHES "Debug;")
    set(CMAKE_CONFIGURATION_TYPES "Debug" CACHE STRING "Build configurations" FORCE)
endif()

# Set the build type
if(NOT DEFINED CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
elseif(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
endif()

Why This Is Problematic

  1. Unexpected for performance libraries: Most numerical libraries default to Release or no build type
  2. Silent failure: No warnings are emitted when building in Debug mode
  3. Misleading documentation: README.md shows -DCMAKE_BUILD_TYPE=Release in examples but doesn't mention it's required, not optional
  4. Dual variable confusion: Even if CMAKE_BUILD_TYPE=Release is set, CMAKE_CONFIGURATION_TYPES can override it for multi-config generators

Suggested Solutions

Option 1 (Best): Default to Release for a performance-critical library

if(NOT DEFINED CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
    message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release")
endif()

Option 2: Add prominent warning when building in Debug mode

if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_CONFIGURATION_TYPES STREQUAL "Debug")
    message(WARNING "Building in Debug mode - expect 10-100x+ performance degradation. "
                    "Set -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release for production use.")
endif()

Option 3 (Minimal): Update README.md to explicitly warn that Release build type is required for acceptable performance, not just recommended.

Environment

  • AOCL version: 5.2.0 (commit from public AOCL GitHub)
  • Build configuration: ILP64, OpenMP threading, static library
  • Compiler: GCC 13.3.0
  • Platform: Linux, AMD EPYC 9655 (Zen 5)

Reproducer

# Without CMAKE_CONFIGURATION_TYPES=Release (buggy - Debug mode)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_ILP64=ON -DENABLE_AOCL_BLAS=ON
cmake --build build
# Result: ~100-450x slower than expected on trsm/trmm

# Workaround (correct - Release mode)
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES=Release -DENABLE_ILP64=ON -DENABLE_AOCL_BLAS=ON
cmake --build build
# Result: Normal performance

Thank you for considering this issue. AOCL is an excellent library, and improving the default build configuration would prevent others from encountering this subtle but critical performance trap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions