Skip to content

macOS OpenMP build failure #390

@mdmeeker

Description

@mdmeeker
  • On macOS on Apple Silicon
  • Homebrew OpenMP
  • Built PyKokkos from source, main branch

When @pk.workunit is invoked, the JIT compiler calls find_package(Kokkos) which loads KokkosConfig.cmake which then calls

FIND_DEPENDENCY(OpenMP REQUIRED COMPONENTS CXX)

Apple Clang/CMake cannot find OpenMP though and so fails with

Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)

User must therefore set CPATH and LIBRARY_PATH. My current hack is to activate my uv venv with

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [ ! -d "$SCRIPT_DIR/.venv" ]; then
    echo "Error: .venv not found. Run 'make setup' first."
    return 1 2>/dev/null || exit 1
fi

source "$SCRIPT_DIR/.venv/bin/activate"

if [ "$(uname)" = "Darwin" ]; then
    OMP_PREFIX="$(brew --prefix libomp 2>/dev/null)"
    if [ -n "$OMP_PREFIX" ]; then
        export CPATH="${OMP_PREFIX}/include${CPATH:+:$CPATH}"
        export LIBRARY_PATH="${OMP_PREFIX}/lib${LIBRARY_PATH:+:$LIBRARY_PATH}"
    fi
fi

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