CMake: Clean up unused definitions (#69216)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69216

This cleans up 4 pre-processor defines not used by any code:
- HAVE_GCC_GET_CPUID
- USE_GCC_GET_CPUID
- USE_AVX
- USE_AVX2

`cpuid` isn't used in PyTorch any more, we only use `cpuinfo`.
`USE_AVX*` is also not used, instead `HAVE_*_CPU_DEFINITIONS` tells
you which `CPU_CAPABILITY` flags are being compiled.

There is also `fbgemm`'s code path adding `third_party` as an include
path, despite `fbgemm` having a dedicated include directory and a
CMake setup that properly includes it.

Test Plan: Imported from OSS

Reviewed By: albanD

Differential Revision: D33794424

Pulled By: malfet

fbshipit-source-id: 99d504af088818d4a26c2f6ce67ec0d59a5eb703
This commit is contained in:
Peter Bell 2022-01-31 14:40:38 -08:00 committed by Facebook GitHub Bot
parent f7d127b654
commit 2e099d41f0
4 changed files with 0 additions and 65 deletions

View File

@ -14,9 +14,6 @@ COMMON_COPTS = [
"-DHAVE_SHM_OPEN=1",
"-DHAVE_SHM_UNLINK=1",
"-D_FILE_OFFSET_BITS=64",
"-DHAVE_GCC_GET_CPUID",
"-DTH_BLAS_MKL",
"-DUSE_GCC_GET_CPUID",
"-DTH_HAVE_THREAD",
"-DUSE_FBGEMM",
"-DUSE_DISTRIBUTED",
@ -369,8 +366,6 @@ cc_library(
)
ATEN_COPTS = COMMON_COPTS + [
"-DUSE_AVX",
"-DUSE_AVX2",
"-DCAFFE2_BUILD_MAIN_LIBS",
"-DHAVE_AVX_CPU_DEFINITION",
"-DHAVE_AVX2_CPU_DEFINITION",
@ -1543,9 +1538,6 @@ cu_library(
)
PERF_COPTS = [
"-DHAVE_GCC_GET_CPUID",
"-DUSE_AVX",
"-DUSE_AVX2",
"-DTH_HAVE_THREAD",
"-DHAVE_AVX_CPU_DEFINITION",
"-DHAVE_AVX2_CPU_DEFINITION",

View File

@ -824,8 +824,6 @@ if(USE_FBGEMM)
endif()
if(USE_FBGEMM)
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
include_directories(SYSTEM "${CAFFE2_THIRD_PARTY_ROOT}")
caffe2_update_option(USE_FBGEMM ON)
else()
caffe2_update_option(USE_FBGEMM OFF)
@ -1694,56 +1692,6 @@ if(NOT INTERN_BUILD_MOBILE)
add_compile_options(-mcpu=cortex-a9)
endif()
CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
# Check for a cpuid intrinsic
if(HAVE_CPUID_H)
CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
int main()
{
unsigned int eax, ebx, ecx, edx;
return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
}" HAVE_GCC_GET_CPUID)
endif()
if(HAVE_GCC_GET_CPUID)
add_compile_options(-DHAVE_GCC_GET_CPUID)
endif()
CHECK_C_SOURCE_COMPILES("#include <stdint.h>
static inline void cpuid(uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
uint32_t a = *eax, b, c = *ecx, d;
asm volatile ( \"cpuid\" : \"+a\"(a), \"=b\"(b), \"+c\"(c), \"=d\"(d) );
*eax = a; *ebx = b; *ecx = c; *edx = d;
}
int main() {
uint32_t a,b,c,d;
cpuid(&a, &b, &c, &d);
return 0;
}" NO_GCC_EBX_FPIC_BUG)
if(NOT NO_GCC_EBX_FPIC_BUG)
add_compile_options(-DUSE_GCC_GET_CPUID)
endif()
find_package(VSX) # checks VSX
find_package(ZVECTOR) # checks ZVECTOR
# checks AVX and AVX2. Already called once in MiscCheck.cmake. Called again here for clarity --
# cached results will be used so no extra overhead.
find_package(AVX)
# we don't set -mavx and -mavx2 flags globally, but only for specific files
# however, we want to enable the AVX codepaths, so we still need to
# add USE_AVX and USE_AVX2 macro defines
if(C_AVX_FOUND)
message(STATUS "AVX compiler support found")
add_compile_options(-DUSE_AVX)
endif()
if(C_AVX2_FOUND)
message(STATUS "AVX2 compiler support found")
add_compile_options(-DUSE_AVX2)
endif()
if(WIN32 AND NOT CYGWIN)
set(BLAS_INSTALL_LIBRARIES "OFF"
CACHE BOOL "Copy the required BLAS DLLs into the TH install dirs")

View File

@ -55,8 +55,6 @@ cc_library(
"third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h",
],
copts = [
"-DUSE_AVX",
"-DUSE_AVX2",
"-DDNNL_DLL",
"-DDNNL_DLL_EXPORTS",
"-DDNNL_ENABLE_CONCURRENT_EXEC",

View File

@ -15,9 +15,6 @@ SLEEF_COPTS = [
"-fno-math-errno",
"-fno-trapping-math",
"-DCAFFE2_USE_GLOO",
"-DHAVE_GCC_GET_CPUID",
"-DUSE_AVX",
"-DUSE_AVX2",
"-std=gnu99",
]