pytorch/cmake/Modules
Yu, Guangye 8051ee802c Add XPU compiler version control in cmake to keep BC (#139258)
# Motivation
This PR aims to maintain backward compatibility when building PyTorch XPU with the old and new compilers.

# Additional Context
The details are described here. The new compiler (2025.0.0) has some breaking changes compared with the old compiler(2024.1), for examples:
1. On Windows, sycl library is named `sycl7.lib` in the old compiler but is named `sycl.lib` in the new compiler.
2. On Linux, in order to support ABI=0, we have to link `libsycl-preview.so` in the old compiler but we could link `libsycl.so` in the new compiler to have the same ABI compatibility.
3. We added a macro `SYCL_COMPILER_VERSION` to support our new code has good backward compatibility with the old compiler. Now the new feature(Event elapsed_time, memory summary, and device architecture property) introduced by the new compiler will be controlled within the macro `SYCL_COMPILER_VERSION`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/139258
Approved by: https://github.com/EikanWang, https://github.com/atalman, https://github.com/gujinghui
2024-11-09 13:31:21 +00:00
..
FindAPL.cmake Enable Windows Arm64 (#133088) 2024-10-24 16:10:44 +00:00
FindARM.cmake Extending the Pytorch vec backend for SVE (ARM) (#119571) 2024-09-18 18:59:10 +00:00
FindAtlas.cmake
FindAVX.cmake Simplify CMake code (#127683) 2024-06-05 15:17:31 +00:00
FindBenchmark.cmake
FindBLAS.cmake Fix FindBLAS.cmake (#129713) 2024-06-28 02:15:16 +00:00
FindBLIS.cmake
FindCUB.cmake
FindCUDAToolkit.cmake [Reland] Add wrappers for synchronous GPUDirect Storage APIs (#133489) 2024-08-15 17:11:52 +00:00
FindCUDSS.cmake SparseCsrCUDA: cuDSS backend for linalg.solve (#129856) 2024-08-22 07:57:30 +00:00
FindCUSPARSELT.cmake Fix finding Intel MKL on Windows, as well as LAPACK, cuDNN and cuSPARSELt (#108040) 2023-09-08 14:41:00 +00:00
FindFlexiBLAS.cmake
FindGloo.cmake
FindITT.cmake
FindLAPACK.cmake Enable Windows Arm64 (#133088) 2024-10-24 16:10:44 +00:00
FindMAGMA.cmake
FindMKL.cmake Fix mkl-static issue for Windows. (#130697) 2024-07-15 19:28:11 +00:00
FindMKLDNN.cmake Add XPU compiler version control in cmake to keep BC (#139258) 2024-11-09 13:31:21 +00:00
FindNCCL.cmake
FindNuma.cmake
FindOpenBLAS.cmake added path to correct directory containing headers (#110063) 2023-10-04 21:56:36 +00:00
FindOpenMP.cmake [Reland] Improve MKL related logic in FindOpenMP.cmake (#104224) 2023-09-02 07:55:11 +00:00
FindOpenTelemetryApi.cmake [rfc] opentelemetry in pytorch (#122999) 2024-04-21 15:20:21 +00:00
Findpybind11.cmake
FindSanitizer.cmake lower cmake version requirement in FindSanitizer.cmake (#97073) 2023-04-22 02:02:14 +00:00
FindSYCLToolkit.cmake Add XPU compiler version control in cmake to keep BC (#139258) 2024-11-09 13:31:21 +00:00
FindvecLib.cmake
FindVSX.cmake
FindZVECTOR.cmake s390x: use runtime detection for vectorization support (#123936) 2024-05-03 21:34:37 +00:00
README.md

This folder contains various custom cmake modules for finding libraries and packages. Details about some of them are listed below.

FindOpenMP.cmake

This is modified from the file included in CMake 3.13 release, with the following changes:

  • Replace VERSION_GREATER_EQUAL with NOT ... VERSION_LESS as VERSION_GREATER_EQUAL is not supported in CMake 3.5 (our min supported version).

  • Update the separate_arguments commands to not use NATIVE_COMMAND which is not supported in CMake 3.5 (our min supported version).

  • Make it respect the QUIET flag so that, when it is set, try_compile failures are not reported.

  • For AppleClang compilers, use -Xpreprocessor instead of -Xclang as the later is not documented.

  • For AppleClang compilers, an extra flag option is tried, which is -Xpreprocessor -openmp -I${DIR_OF_omp_h}, where ${DIR_OF_omp_h} is a obtained using find_path on omp.h with brew's default include directory as a hint. Without this, the compiler will complain about missing headers as they are not natively included in Apple's LLVM.

  • For non-GNU compilers, whenever we try a candidate OpenMP flag, first try it with directly linking MKL's libomp if it has one. Otherwise, we may end up linking two libomps and end up with this nasty error:

    OMP: Error #15: Initializing libomp.dylib, but found libiomp5.dylib already
    initialized.
    
    OMP: Hint This means that multiple copies of the OpenMP runtime have been
    linked into the program. That is dangerous, since it can degrade performance
    or cause incorrect results. The best thing to do is to ensure that only a
    single OpenMP runtime is linked into the process, e.g. by avoiding static
    linking of the OpenMP runtime in any library. As an unsafe, unsupported,
    undocumented workaround you can set the environment variable
    KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but
    that may cause crashes or silently produce incorrect results. For more
    information, please see http://openmp.llvm.org/
    

    See NOTE [ Linking both MKL and OpenMP ] for details.