mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Remove unused atomics detection code. (#23089)
Summary:
USE_{C11,MSC,GCC}_ATOMICS are not used in PyTorch or submodules. Now we remove their underlying detection code.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23089
Differential Revision: D16402750
Pulled By: ezyang
fbshipit-source-id: fde84b958eb0b5b4d3f0406acefa92ab30ea43be
This commit is contained in:
parent
4e5f70089f
commit
a62c687445
|
|
@ -1247,72 +1247,6 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||
add_compile_options(-DUSE_AVX2)
|
||||
ENDIF()
|
||||
|
||||
CHECK_C_SOURCE_RUNS("
|
||||
#include <stdatomic.h>
|
||||
// ATOMIC_INT_LOCK_FREE is flaky on some older gcc versions
|
||||
// so if this define is not usable a preprocessor definition
|
||||
// we fail this check and fall back to GCC atomics
|
||||
#if ATOMIC_INT_LOCK_FREE == 2
|
||||
#define TH_ATOMIC_IPC_REFCOUNT 1
|
||||
#endif
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
int oa;
|
||||
atomic_store(&a, 1);
|
||||
atomic_fetch_add(&a, 1);
|
||||
oa = atomic_load(&a);
|
||||
if(!atomic_compare_exchange_strong(&a, &oa, 3))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
" HAS_C11_ATOMICS)
|
||||
|
||||
IF (NOT HAS_C11_ATOMICS)
|
||||
CHECK_C_SOURCE_RUNS("
|
||||
#include <intrin.h>
|
||||
int main()
|
||||
{
|
||||
long a;
|
||||
_InterlockedExchange(&a, 1);
|
||||
_InterlockedExchangeAdd(&a, 1);
|
||||
if(_InterlockedCompareExchange(&a, 3, 2) != 2)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
" HAS_MSC_ATOMICS)
|
||||
|
||||
CHECK_C_SOURCE_RUNS("
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
__sync_lock_test_and_set(&a, 1);
|
||||
__sync_fetch_and_add(&a, 1);
|
||||
if(!__sync_bool_compare_and_swap(&a, 2, 3))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
" HAS_GCC_ATOMICS)
|
||||
ENDIF()
|
||||
|
||||
IF (HAS_C11_ATOMICS)
|
||||
ADD_DEFINITIONS(-DUSE_C11_ATOMICS=1)
|
||||
MESSAGE(STATUS "Atomics: using C11 intrinsics")
|
||||
ELSEIF (HAS_MSC_ATOMICS)
|
||||
ADD_DEFINITIONS(-DUSE_MSC_ATOMICS=1)
|
||||
MESSAGE(STATUS "Atomics: using MSVC intrinsics")
|
||||
ELSEIF (HAS_GCC_ATOMICS)
|
||||
ADD_DEFINITIONS(-DUSE_GCC_ATOMICS=1)
|
||||
MESSAGE(STATUS "Atomics: using GCC intrinsics")
|
||||
ELSE()
|
||||
SET(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
FIND_PACKAGE(Threads)
|
||||
IF(THREADS_FOUND)
|
||||
ADD_DEFINITIONS(-DUSE_PTHREAD_ATOMICS=1)
|
||||
MESSAGE(STATUS "Atomics: using pthread")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (WIN32 AND NOT CYGWIN)
|
||||
SET(BLAS_INSTALL_LIBRARIES "OFF"
|
||||
CACHE BOOL "Copy the required BLAS DLLs into the TH install dirs")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user