mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Allow linking against vcomp on Windows (#54132)
Summary: Fixes https://github.com/pytorch/pytorch/issues/54054 Pull Request resolved: https://github.com/pytorch/pytorch/pull/54132 Reviewed By: zou3519 Differential Revision: D27181524 Pulled By: malfet fbshipit-source-id: b79b34afb7edcc594d9b5907c5a7505b9cc5683b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6f7a5a47af
commit
6a4d2c61d5
@ -238,6 +238,8 @@ Build with CPU
|
|||||||
|
|
||||||
It's fairly easy to build with CPU. Visual Studio 2019 version 16.7.6 (MSVC toolchain version 14.27) or higher is recommended.
|
It's fairly easy to build with CPU. Visual Studio 2019 version 16.7.6 (MSVC toolchain version 14.27) or higher is recommended.
|
||||||
|
|
||||||
|
Note on OpenMP: The desired OpenMP implementation is Intel OpenMP (iomp). In order to link against iomp, you'll need to manually download the library and set up the buliding environment by tweaking `CMAKE_INCLUDE_PATH` and `LIB`. The instruction [here](https://github.com/pytorch/pytorch/blob/master/docs/source/notes/windows.rst#building-from-source) is an example for setting up both MKL and Intel OpenMP. Without these configuraions for CMake, Microsoft Visual C OpenMP runtime (vcomp) will be used.
|
||||||
|
|
||||||
Build with CUDA
|
Build with CUDA
|
||||||
|
|
||||||
[NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) is needed to build Pytorch with CUDA.
|
[NVTX](https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm) is needed to build Pytorch with CUDA.
|
||||||
|
@ -86,9 +86,15 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
|
|||||||
set(OMP_FLAG_GNU "-fopenmp")
|
set(OMP_FLAG_GNU "-fopenmp")
|
||||||
set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp")
|
set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp")
|
||||||
|
|
||||||
# AppleClang may need a header file, search for omp.h with hints to brew
|
if(WIN32)
|
||||||
# default include dir
|
# Prefer Intel OpenMP header which can be provided by CMAKE_INCLUDE_PATH.
|
||||||
find_path(__header_dir "omp.h" HINTS "/usr/local/include")
|
# Note that CMAKE_INCLUDE_PATH is searched before CMAKE_SYSTEM_INCLUDE_PATH (MSVC path in this case)
|
||||||
|
find_path(__header_dir "omp.h")
|
||||||
|
else()
|
||||||
|
# AppleClang may need a header file, search for omp.h with hints to brew
|
||||||
|
# default include dir
|
||||||
|
find_path(__header_dir "omp.h" HINTS "/usr/local/include")
|
||||||
|
endif()
|
||||||
set(OMP_FLAG_AppleClang "-Xpreprocessor -fopenmp" "-Xpreprocessor -fopenmp -I${__header_dir}")
|
set(OMP_FLAG_AppleClang "-Xpreprocessor -fopenmp" "-Xpreprocessor -fopenmp -I${__header_dir}")
|
||||||
|
|
||||||
set(OMP_FLAG_HP "+Oopenmp")
|
set(OMP_FLAG_HP "+Oopenmp")
|
||||||
@ -101,7 +107,12 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
|
|||||||
set(OMP_FLAG_Intel "-qopenmp")
|
set(OMP_FLAG_Intel "-qopenmp")
|
||||||
endif()
|
endif()
|
||||||
set(OMP_FLAG_MIPSpro "-mp")
|
set(OMP_FLAG_MIPSpro "-mp")
|
||||||
set(OMP_FLAG_MSVC "-openmp:experimental" "-openmp:experimental -I${__header_dir}" "-openmp" "-openmp -I${__header_dir}")
|
if(__header_dir MATCHES ".*Microsoft Visual Studio.*")
|
||||||
|
# MSVC header. No need to pass it as additional include.
|
||||||
|
set(OMP_FLAG_MSVC "-openmp:experimental" "-openmp")
|
||||||
|
else()
|
||||||
|
set(OMP_FLAG_MSVC "-openmp:experimental -I${__header_dir}" "-openmp -I${__header_dir}")
|
||||||
|
endif()
|
||||||
set(OMP_FLAG_PathScale "-openmp")
|
set(OMP_FLAG_PathScale "-openmp")
|
||||||
set(OMP_FLAG_NAG "-openmp")
|
set(OMP_FLAG_NAG "-openmp")
|
||||||
set(OMP_FLAG_Absoft "-openmp")
|
set(OMP_FLAG_Absoft "-openmp")
|
||||||
@ -132,7 +143,6 @@ set(OpenMP_C_CXX_TEST_SOURCE
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
omp_get_max_threads();
|
omp_get_max_threads();
|
||||||
omp_get_level();
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
breaks_on_purpose
|
breaks_on_purpose
|
||||||
|
Reference in New Issue
Block a user