Revert "Enable mimalloc on non-Windows platforms and make default for AArch64 builds (#164741)"

This reverts commit 87eccf10e8484c9e59ef81ae7bdee68d3db4f605.

Reverted https://github.com/pytorch/pytorch/pull/164741 on behalf of https://github.com/malfet due to But it breaks MacOS builds, see https://github.com/pytorch/pytorch/actions/runs/18382886648/job/52373781138 ([comment](https://github.com/pytorch/pytorch/pull/164741#issuecomment-3386859778))
This commit is contained in:
PyTorch MergeBot
2025-10-09 17:30:22 +00:00
parent 91040f4934
commit 688efd9741
3 changed files with 10 additions and 11 deletions

View File

@ -388,9 +388,9 @@ cmake_dependent_option(USE_PRIORITIZED_TEXT_FOR_LD "Use prioritized text linker
option(USE_MIMALLOC "Use mimalloc" OFF)
# Enable third party mimalloc library to improve memory allocation performance
# on Windows and AArch64.
# on Windows.
option(USE_MIMALLOC_ON_MKL "Use mimalloc on MKL" OFF)
if(WIN32 OR CPU_AARCH64)
if(WIN32)
set(USE_MIMALLOC ON)
# Not enable USE_MIMALLOC_ON_MKL due to it caused issue:

View File

@ -108,15 +108,12 @@ void* alloc_cpu(size_t nbytes) {
"DefaultCPUAllocator: not enough memory: you tried to allocate ",
nbytes,
" bytes.");
#elif defined(USE_MIMALLOC)
data = mi_malloc_aligned(nbytes, gAlignment);
CAFFE_ENFORCE(
data,
"DefaultCPUAllocator: not enough memory: you tried to allocate ",
nbytes,
" bytes.");
#elif defined(_MSC_VER)
#ifdef USE_MIMALLOC
data = mi_malloc_aligned(nbytes, gAlignment);
#else
data = _aligned_malloc(nbytes, gAlignment);
#endif
CAFFE_ENFORCE(
data,
"DefaultCPUAllocator: not enough memory: you tried to allocate ",
@ -163,10 +160,12 @@ void* alloc_cpu(size_t nbytes) {
}
void free_cpu(void* data) {
#ifdef _MSC_VER
#ifdef USE_MIMALLOC
mi_free(data);
#elif defined(_MSC_VER)
#else
_aligned_free(data);
#endif
#else
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(data);

View File

@ -225,7 +225,7 @@
#
# USE_MIMALLOC
# Static link mimalloc into C10, and use mimalloc in alloc_cpu & alloc_free.
# By default, It is only enabled on Windows and AArch64.
# By default, It is only enabled on Windows.
#
# BUILD_LIBTORCH_WHL
# Builds libtorch.so and its dependencies as a wheel