pytorch/cmake/Modules
Hong Xu 388dc4f2a6 Let user be able to change MKLDNN "-m" flags back and forth in subsequent builds (#23608)
Summary:
Currently once user has set `USE_NATIVE_ARCH` to OFF, they will never be able to turn it on for MKLDNN again by simply changing `USE_NATIVE_ARCH`. This commit fixes this issue.

Following up 09ba4df031
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23608

Differential Revision: D16599600

Pulled By: ezyang

fbshipit-source-id: 88bbec1b1504b5deba63e56f78632937d003a1f6
2019-08-01 06:05:36 -07:00
..
FindARM.cmake [build] Setup to build ATen from root CMake file (#7163) 2018-05-02 19:33:31 -07:00
FindAtlas.cmake Initial building with deps 2016-12-13 09:29:01 -05:00
FindAVX.cmake AVX2 with GCC9 fix. (#18991) 2019-04-07 08:27:00 -07:00
FindBenchmark.cmake cmake: stop including files from the install directory 2017-09-01 23:33:14 -07:00
FindBLAS.cmake Support for Jetson Xavier (#15660) 2019-01-02 18:51:42 -08:00
FindCUB.cmake Convert all tabs to spaces, add CI. (#18959) 2019-04-09 08:12:26 -07:00
FindFFmpeg.cmake Adding video data layer for caffe2 2017-05-05 14:16:38 -07:00
FindGloo.cmake [c10d] NCCL Process Group implementation (#8182) 2018-06-08 10:33:27 -07:00
FindHiredis.cmake Adding back untracked files from manual github pull 2017-01-12 08:59:19 -08:00
FindLAPACK.cmake Add torch.backends.openmp.is_available(); fix some cmake messages (#16425) 2019-01-31 16:15:46 -08:00
FindLevelDB.cmake Initial building with deps 2016-12-13 09:29:01 -05:00
FindLMDB.cmake Added Ninja generator support on Windows 2017-07-26 00:32:20 -07:00
FindMAGMA.cmake [build] Setup to build ATen from root CMake file (#7163) 2018-05-02 19:33:31 -07:00
FindMatlabMex.cmake Initial building with deps 2016-12-13 09:29:01 -05:00
FindMKL.cmake Fix sequential MKL case (#22062) 2019-06-24 12:56:43 -07:00
FindMKLDNN.cmake Let user be able to change MKLDNN "-m" flags back and forth in subsequent builds (#23608) 2019-08-01 06:05:36 -07:00
FindNCCL.cmake Add sanity checks for NCCL detection. 2019-07-29 13:47:05 -07:00
FindNuma.cmake Add Numa support (#2152) 2018-03-05 23:30:20 -08:00
FindNumPy.cmake Initial building with deps 2016-12-13 09:29:01 -05:00
FindOpenBLAS.cmake Added a search path to find OpenBLAS for convenience (homebrew install) 2016-12-29 16:15:25 -05:00
FindOpenMP.cmake Some essential changes needed before updating the Windows AMI (#20353) 2019-05-10 09:08:51 -07:00
Findpybind11.cmake Convert all tabs to spaces, add CI. (#18959) 2019-04-09 08:12:26 -07:00
FindRocksDB.cmake Adding back untracked files from manual github pull 2017-01-12 08:59:19 -08:00
FindSnappy.cmake CMake completions work 2017-01-11 16:59:22 -08:00
FindvecLib.cmake Initial building with deps 2016-12-13 09:29:01 -05:00
FindZMQ.cmake Adding back untracked files from manual github pull 2017-01-12 08:59:19 -08:00
README.md Update the cmake build configuration for AppleClang compiler (#15820) 2019-02-04 08:53:47 -08:00

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.