pytorch/cmake/Modules
shmsong ee2dd35ef4 Resolving native dependency and try_run for cross compile (#59764)
Summary:
This is a PR on build system that provides support for cross compiling on Jetson platforms.

The major change is:

1. Disable try runs for cross compiling in `COMPILER_WORKS`, `BLAS`, and `CUDA`. They will not be able to perform try run on a cross compile setup

Pull Request resolved: https://github.com/pytorch/pytorch/pull/59764

Reviewed By: soulitzer

Differential Revision: D29524363

Pulled By: malfet

fbshipit-source-id: f06d1ad30b704c9a17d77db686c65c0754db07b8
2021-07-09 09:29:21 -07:00
..
FindARM.cmake Make PyTorch partially cross-compilable for Apple M1 (#49701) 2020-12-22 09:33:12 -08:00
FindAtlas.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindAVX.cmake
FindBenchmark.cmake
FindBLAS.cmake Resolving native dependency and try_run for cross compile (#59764) 2021-07-09 09:29:21 -07:00
FindBLIS.cmake Adding a new include directory in BLIS search path (#58166) 2021-05-24 08:57:02 -07:00
FindCUB.cmake
FindFFmpeg.cmake Fix compilation error when buildng with FFMPEG (#27589) 2020-02-13 11:23:48 -08:00
FindGloo.cmake
FindHiredis.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindLAPACK.cmake Search for static OpenBLAS compiled with OpenMP (#59428) 2021-06-04 08:09:21 -07:00
FindLevelDB.cmake
FindLMDB.cmake
FindMAGMA.cmake Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
FindMatlabMex.cmake
FindMKL.cmake find mkl installed by nuget (#34031) 2020-03-03 07:44:20 -08:00
FindMKLDNN.cmake Add --jobs 0 for git submodule update (#61311) 2021-07-07 16:28:18 -07:00
FindNCCL.cmake Fix NCCL version check when nccl.h in non-standard location. (#40982) 2020-07-17 13:54:17 -07:00
FindNuma.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindNumPy.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindOpenBLAS.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindOpenMP.cmake Allow linking against vcomp on Windows (#54132) 2021-03-19 14:36:07 -07:00
Findpybind11.cmake
FindRocksDB.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindSnappy.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindvecLib.cmake Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08:00
FindVSX.cmake Lint trailing newlines (#54737) 2021-03-30 13:09:52 -07:00
FindZMQ.cmake Forbid trailing whitespace (#53406) 2021-03-05 17:22:55 -08: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.