Skip to content

Commit 13bc761

Browse files
authored
Merge pull request #14552 from JiabinYang/fix_mac/fix_pinned_memory
fix Mac unittest error on reading pined memory flag
2 parents 3639d99 + 560b9b5 commit 13bc761

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

paddle/fluid/memory/allocation/retry_allocator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TEST(RetryAllocator, RetryAllocator) {
4141

4242
size_t thread_num = 32;
4343
size_t sleep_time = 40;
44-
size_t extra_time = 2;
44+
size_t extra_time = 10;
4545

4646
// Reserve to perform more tests in the future
4747
std::vector<std::shared_ptr<Allocator>> allocators;

paddle/testing/paddle_gtest_main.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ int main(int argc, char** argv) {
3131
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
3232
new_argv.push_back(
3333
strdup("--tryfromenv=fraction_of_gpu_memory_to_use,allocator_strategy"));
34+
#elif __clang__
35+
new_argv.push_back(
36+
strdup("--tryfromenv=use_mkldnn,initial_cpu_memory_in_"
37+
"mb,allocator_strategy"));
38+
new_argv.push_back(strdup("--undefok=use_mkldnn,initial_cpu_memory_in_mb"));
3439
#else
3540
new_argv.push_back(
3641
strdup("--tryfromenv=use_pinned_memory,use_mkldnn,initial_cpu_memory_in_"

python/paddle/fluid/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def __bootstrap__():
9191
"""
9292
import sys
9393
import os
94+
import platform
9495
from . import core
9596

9697
in_test = 'unittest' in sys.modules
@@ -110,14 +111,17 @@ def __bootstrap__():
110111
print('PLEASE USE OMP_NUM_THREADS WISELY.', file=sys.stderr)
111112

112113
os.environ['OMP_NUM_THREADS'] = str(num_threads)
113-
114+
sysstr = platform.system()
114115
read_env_flags = [
115-
'use_pinned_memory', 'check_nan_inf', 'benchmark', 'eager_delete_scope',
116-
'use_mkldnn', 'use_ngraph', 'initial_cpu_memory_in_mb',
117-
'init_allocated_mem', 'free_idle_memory', 'paddle_num_threads',
118-
"dist_threadpool_size", 'eager_delete_tensor_gb', 'allocator_strategy',
116+
'check_nan_inf', 'benchmark', 'eager_delete_scope', 'use_mkldnn',
117+
'use_ngraph', 'initial_cpu_memory_in_mb', 'init_allocated_mem',
118+
'free_idle_memory', 'paddle_num_threads', "dist_threadpool_size",
119+
'eager_delete_tensor_gb', 'allocator_strategy',
119120
'reader_queue_speed_test_mode', 'print_sub_graph_dir'
120121
]
122+
if 'Darwin' not in sysstr:
123+
read_env_flags.append('use_pinned_memory')
124+
121125
if os.name != 'nt':
122126
read_env_flags.append('warpctc_dir')
123127
read_env_flags.append('cpu_deterministic')

0 commit comments

Comments
 (0)