<commit_before>#
#  Copyright 2009-2015, <NAME>
#  All rights reserved.
#
#  This file is part of Elemental and is under the BSD 2-Clause License,
#  which can be found in the LICENSE file in the root directory, or at
#  http://opensource.org/licenses/BSD-2-Clause
#
include(ExternalProject)
include(ElCheckFunctionExists)
include(ElLibraryName)

# If MATH_LIBS_AT_CONFIG exists, see if it supports ScaLAPACK
if(MATH_LIBS_AT_CONFIG)
  set(CMAKE_REQUIRED_FLAGS "${MPI_C_COMPILE_FLAGS}")
  set(CMAKE_REQUIRED_LINKER_FLAGS "${MPI_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
  set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH})
  set(CMAKE_REQUIRED_LIBRARIES ${MATH_LIBS_AT_CONFIG} ${MPI_C_LIBRARIES})
  El_check_function_exists(dtrsm   EL_HAVE_DTRSM)
  El_check_function_exists(dtrsm_  EL_HAVE_DTRSM_POST)
  if(EL_HAVE_DTRSM OR EL_HAVE_DTRSM_POST)
    set(HAVE_BLAS TRUE)
  else()
    message(WARNING "Could not find BLAS in ${MATH_LIBS_AT_CONFIG}")
  endif()
  El_check_function_exists(dsytrd  EL_HAVE_DSYTRD)
  El_check_function_exists(dsytrd_ EL_HAVE_DSYTRD_POST)
  if(EL_HAVE_DSYTRD OR EL_HAVE_DSYTRD_POST)
    set(HAVE_LAPACK TRUE)
  else()
    message(WARNING "Could not find LAPACK in ${MATH_LIBS_AT_CONFIG}")
  endif()
  if(EL_SCALAPACK_SUFFIX)
    El_check_function_exists(pdsyngst${EL_SCALAPACK_SUFFIX} EL_HAVE_PDSYNGST)
    El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
    if(NOT EL_HAVE_PDSYNGST OR NOT EL_HAVE_CSYS2BLACS)
      message(STATUS "Did not detect ScaLAPACK")
    elseif(HAVE_BLAS AND HAVE_LAPACK)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
      set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
    endif()
  else()
    # NOTE: pdsyngst was chosen because MKL ScaLAPACK only defines pdsyngst_,
    #       but not pdsyngst, despite defining both pdpotrf and pdpotrf_. 
    El_check_function_exists(pdsyngst  EL_HAVE_PDSYNGST)
    El_check_function_exists(pdsyngst_ EL_HAVE_PDSYNGST_POST)
    El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
    if(HAVE_BLAS AND HAVE_LAPACK AND EL_HAVE_PDSYNGST AND EL_HAVE_CSYS2BLACS)
      set(EL_SCALAPACK_SUFFIX)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
    elseif(HAVE_BLAS AND HAVE_LAPACK AND 
           EL_HAVE_PDSYNGST_POST AND EL_HAVE_CSYS2BLACS)
      set(EL_SCALAPACK_SUFFIX _)
      set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
    else()
      message(STATUS "Did not detect ScaLAPACK")
    endif()
  endif()
  if(MATH_LIBS_HAS_SCALAPACK)
    El_check_function_exists(pdlaqr0${EL_SCALAPACK_SUFFIX} EL_HAVE_PDLAQR0)
    El_check_function_exists(pdlaqr1${EL_SCALAPACK_SUFFIX} EL_HAVE_PDLAQR1)
    if(NOT EL_HAVE_PDLAQR0 OR NOT EL_HAVE_PDLAQR1)
      message(STATUS "MATH_LIBS_AT_CONFIG=${MATH_LIBS_AT_CONFIG} supports some of ScaLAPACK, but not PDLAQR{0,1}.")
      set(MATH_LIBS_HAS_SCALAPACK FALSE)
    endif()
  endif()
  set(CMAKE_REQUIRED_FLAGS)
  set(CMAKE_REQUIRED_LINKER_FLAGS)
  set(CMAKE_REQUIRED_INCLUDES)
  set(CMAKE_REQUIRED_LIBRARIES)
endif()

if(NOT MATH_LIBS_HAS_SCALAPACK AND NOT EL_BUILD_SCALAPACK)
  find_library(ScaLAPACK NAMES scalapack PATHS ${MATH_PATHS})
  if(ScaLAPACK)
    get_filename_component(ScaLAPACK_DIR ScaLAPACK DIRECTORY)
    if(EXISTS "${ScaLAPACK_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}blacs${CMAKE_SHARED_LIBRARY_SUFFIX}" OR 
       EXISTS "${ScaLAPACK_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}blacs${CMAKE_STATIC_LIBRARY_SUFFIX}")
      message(WARNING "Found blacs library in ${ScaLAPACK_DIR}; ScaLAPACK appears to be too old to link to")
    else()
      set(CMAKE_REQUIRED_FLAGS "${MPI_C_COMPILE_FLAGS}")
      set(CMAKE_REQUIRED_LINKER_FLAGS "${MPI_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
      set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH})
      set(CMAKE_REQUIRED_LIBRARIES 
        ${ScaLAPACK} ${MATH_LIBS_AT_CONFIG} ${MPI_C_LIBRARIES})
      El_check_function_exists(dtrsm   EL_HAVE_DTRSM)
      El_check_function_exists(dtrsm_  EL_HAVE_DTRSM_POST)
      if(EL_HAVE_DTRSM OR EL_HAVE_DTRSM_POST)
        set(HAVE_BLAS TRUE)
      else()
        message(WARNING "Could not link BLAS")
      endif()
      El_check_function_exists(dsytrd  EL_HAVE_DSYTRD)
      El_check_function_exists(dsytrd_ EL_HAVE_DSYTRD_POST)
      if(EL_HAVE_DSYTRD OR EL_HAVE_DSYTRD_POST)
        set(HAVE_LAPACK TRUE)
      else()
        message(WARNING "Could not link LAPACK")
      endif()
      if(EL_SCALAPACK_SUFFIX)
        El_check_function_exists(pdsyngst${EL_SCALAPACK_SUFFIX} EL_HAVE_PDSYNGST)
        El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
        if(NOT EL_HAVE_PDSYNGST OR NOT EL_HAVE_CSYS2BLACS)
          message(WARNING "Could not find pdsyngst${EL_SCALAPACK_SUFFIX} and Csys2blacs_handle")
        elseif(HAVE_BLAS AND HAVE_LAPACK)
          set(USE_FOUND_SCALAPACK TRUE)
          set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
        endif()
      else()
        # pdsyngst was chosen because MKL ScaLAPACK only defines pdsyngst_,
        # but not pdsyngst, despite defining both pdpotrf and pdpotrf_. 
        El_check_function_exists(pdsyngst  EL_HAVE_PDSYNGST)
        El_check_function_exists(pdsyngst_ EL_HAVE_PDSYNGST_POST)
        El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
        if(HAVE_BLAS AND HAVE_LAPACK AND 
           EL_HAVE_PDSYNGST AND EL_HAVE_CSYS2BLACS)
          set(EL_SCALAPACK_SUFFIX)
          set(USE_FOUND_SCALAPACK TRUE)
        elseif(HAVE_BLAS AND HAVE_LAPACK AND 
               EL_HAVE_PDSYNGST_POST AND EL_HAVE_CSYS2BLACS)
          set(EL_SCALAPACK_SUFFIX _)
          set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
          set(USE_FOUND_SCALAPACK TRUE)
        else()
          message(STATUS "Could not link ScaLAPACK")
        endif()<commit_msg>Downgrading messages about not being able to detect BLAS and/or LAPACK when combining a found ScaLAPACK library with MATH_LIBS to STATUS from WARNING<commit_after>#
#  Copyright 2009-2015, <NAME>
#  All rights reserved.
#
#  This file is part of Elemental and is under the BSD 2-Clause License,
#  which can be found in the LICENSE file in the root directory, or at
#  http://opensource.org/licenses/BSD-2-Clause
#
include(ExternalProject)
include(ElCheckFunctionExists)
include(ElLibraryName)

# If MATH_LIBS_AT_CONFIG exists, see if it supports ScaLAPACK
if(MATH_LIBS_AT_CONFIG)
  set(CMAKE_REQUIRED_FLAGS "${MPI_C_COMPILE_FLAGS}")
  set(CMAKE_REQUIRED_LINKER_FLAGS "${MPI_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
  set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH})
  set(CMAKE_REQUIRED_LIBRARIES ${MATH_LIBS_AT_CONFIG} ${MPI_C_LIBRARIES})
  El_check_function_exists(dtrsm   EL_HAVE_DTRSM)
  El_check_function_exists(dtrsm_  EL_HAVE_DTRSM_POST)
  if(EL_HAVE_DTRSM OR EL_HAVE_DTRSM_POST)
    set(HAVE_BLAS TRUE)
  else()
    message(WARNING "Could not find BLAS in ${MATH_LIBS_AT_CONFIG}")
  endif()
  El_check_function_exists(dsytrd  EL_HAVE_DSYTRD)
  El_check_function_exists(dsytrd_ EL_HAVE_DSYTRD_POST)
  if(EL_HAVE_DSYTRD OR EL_HAVE_DSYTRD_POST)
    set(HAVE_LAPACK TRUE)
  else()
    message(WARNING "Could not find LAPACK in ${MATH_LIBS_AT_CONFIG}")
  endif()
  if(EL_SCALAPACK_SUFFIX)
    El_check_function_exists(pdsyngst${EL_SCALAPACK_SUFFIX} EL_HAVE_PDSYNGST)
    El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
    if(NOT EL_HAVE_PDSYNGST OR NOT EL_HAVE_CSYS2BLACS)
      message(STATUS "Did not detect ScaLAPACK")
    elseif(HAVE_BLAS AND HAVE_LAPACK)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
      set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
    endif()
  else()
    # NOTE: pdsyngst was chosen because MKL ScaLAPACK only defines pdsyngst_,
    #       but not pdsyngst, despite defining both pdpotrf and pdpotrf_. 
    El_check_function_exists(pdsyngst  EL_HAVE_PDSYNGST)
    El_check_function_exists(pdsyngst_ EL_HAVE_PDSYNGST_POST)
    El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
    if(HAVE_BLAS AND HAVE_LAPACK AND EL_HAVE_PDSYNGST AND EL_HAVE_CSYS2BLACS)
      set(EL_SCALAPACK_SUFFIX)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
    elseif(HAVE_BLAS AND HAVE_LAPACK AND 
           EL_HAVE_PDSYNGST_POST AND EL_HAVE_CSYS2BLACS)
      set(EL_SCALAPACK_SUFFIX _)
      set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
      set(MATH_LIBS_HAS_SCALAPACK TRUE)
    else()
      message(STATUS "Did not detect ScaLAPACK")
    endif()
  endif()
  if(MATH_LIBS_HAS_SCALAPACK)
    El_check_function_exists(pdlaqr0${EL_SCALAPACK_SUFFIX} EL_HAVE_PDLAQR0)
    El_check_function_exists(pdlaqr1${EL_SCALAPACK_SUFFIX} EL_HAVE_PDLAQR1)
    if(NOT EL_HAVE_PDLAQR0 OR NOT EL_HAVE_PDLAQR1)
      message(STATUS "MATH_LIBS_AT_CONFIG=${MATH_LIBS_AT_CONFIG} supports some of ScaLAPACK, but not PDLAQR{0,1}.")
      set(MATH_LIBS_HAS_SCALAPACK FALSE)
    endif()
  endif()
  set(CMAKE_REQUIRED_FLAGS)
  set(CMAKE_REQUIRED_LINKER_FLAGS)
  set(CMAKE_REQUIRED_INCLUDES)
  set(CMAKE_REQUIRED_LIBRARIES)
endif()

if(NOT MATH_LIBS_HAS_SCALAPACK AND NOT EL_BUILD_SCALAPACK)
  find_library(ScaLAPACK NAMES scalapack PATHS ${MATH_PATHS})
  if(ScaLAPACK)
    get_filename_component(ScaLAPACK_DIR ScaLAPACK DIRECTORY)
    if(EXISTS "${ScaLAPACK_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}blacs${CMAKE_SHARED_LIBRARY_SUFFIX}" OR 
       EXISTS "${ScaLAPACK_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}blacs${CMAKE_STATIC_LIBRARY_SUFFIX}")
      message(WARNING "Found blacs library in ${ScaLAPACK_DIR}; ScaLAPACK appears to be too old to link to")
    else()
      set(CMAKE_REQUIRED_FLAGS "${MPI_C_COMPILE_FLAGS}")
      set(CMAKE_REQUIRED_LINKER_FLAGS "${MPI_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
      set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH})
      set(CMAKE_REQUIRED_LIBRARIES 
        ${ScaLAPACK} ${MATH_LIBS_AT_CONFIG} ${MPI_C_LIBRARIES})
      El_check_function_exists(dtrsm   EL_HAVE_DTRSM)
      El_check_function_exists(dtrsm_  EL_HAVE_DTRSM_POST)
      if(EL_HAVE_DTRSM OR EL_HAVE_DTRSM_POST)
        set(HAVE_BLAS TRUE)
      else()
        message(STATUS "Cannot link BLAS with found ScaLAPACK and MATH_LIBS")
      endif()
      El_check_function_exists(dsytrd  EL_HAVE_DSYTRD)
      El_check_function_exists(dsytrd_ EL_HAVE_DSYTRD_POST)
      if(EL_HAVE_DSYTRD OR EL_HAVE_DSYTRD_POST)
        set(HAVE_LAPACK TRUE)
      else()
        message(STATUS "Cannot link LAPACK with found ScaLAPACK and MATH_LIBS")
      endif()
      if(EL_SCALAPACK_SUFFIX)
        El_check_function_exists(pdsyngst${EL_SCALAPACK_SUFFIX} EL_HAVE_PDSYNGST)
        El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
        if(NOT EL_HAVE_PDSYNGST OR NOT EL_HAVE_CSYS2BLACS)
          message(WARNING "Could not find pdsyngst${EL_SCALAPACK_SUFFIX} and Csys2blacs_handle")
        elseif(HAVE_BLAS AND HAVE_LAPACK)
          set(USE_FOUND_SCALAPACK TRUE)
          set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
        endif()
      else()
        # pdsyngst was chosen because MKL ScaLAPACK only defines pdsyngst_,
        # but not pdsyngst, despite defining both pdpotrf and pdpotrf_. 
        El_check_function_exists(pdsyngst  EL_HAVE_PDSYNGST)
        El_check_function_exists(pdsyngst_ EL_HAVE_PDSYNGST_POST)
        El_check_function_exists(Csys2blacs_handle EL_HAVE_CSYS2BLACS)
        if(HAVE_BLAS AND HAVE_LAPACK AND 
           EL_HAVE_PDSYNGST AND EL_HAVE_CSYS2BLACS)
          set(EL_SCALAPACK_SUFFIX)
          set(USE_FOUND_SCALAPACK TRUE)
        elseif(HAVE_BLAS AND HAVE_LAPACK AND 
               EL_HAVE_PDSYNGST_POST AND EL_HAVE_CSYS2BLACS)
          set(EL_SCALAPACK_SUFFIX _)
          set(EL_HAVE_SCALAPACK_SUFFIX TRUE)
          set(USE_FOUND_SCALAPACK TRUE)
        else()
          message(STATUS "Could not link ScaLAPACK")
        endif()
{'fraction_non_alphanumeric': 0.06652173913043478, 'fraction_numerical': 0.005739130434782609, 'mean_word_length': 4.556038647342995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1879109', 'n_tokens_mistral': 4850, 'n_tokens_neox': 4610, 'n_words': 745}