diff options
author | Jongsoo Park <jongsoo@fb.com> | 2019-01-02 04:00:53 +0300 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-01-02 04:03:20 +0300 |
commit | b86d64219a0cb8fc2f8e9595c91986faff17863c (patch) | |
tree | 376d104407c9f5d881b77c89a29de1103377bd04 /bench | |
parent | bd35fce789f33bbb026617b1dff722d173586951 (diff) |
use 1 omp thread unless OMP_NUM_THREADS is explicitly set (#53)
Summary:
Pull Request resolved: https://github.com/pytorch/FBGEMM/pull/53
As title
Reviewed By: jianyuh
Differential Revision: D13561724
fbshipit-source-id: 815ab310f2f4862c65ad0e3d61bf221cb8cf679b
Diffstat (limited to 'bench')
-rw-r--r-- | bench/FP16Benchmark.cc | 7 | ||||
-rw-r--r-- | bench/Im2ColFusedRequantizeBenchmark.cc | 6 | ||||
-rw-r--r-- | bench/PackedFloatInOutBenchmark.cc | 6 | ||||
-rw-r--r-- | bench/PackedRequantizeAcc16Benchmark.cc | 1 | ||||
-rw-r--r-- | bench/PackedRequantizeAcc32Benchmark.cc | 1 |
5 files changed, 17 insertions, 4 deletions
diff --git a/bench/FP16Benchmark.cc b/bench/FP16Benchmark.cc index fd9de5b..c42ee29 100644 --- a/bench/FP16Benchmark.cc +++ b/bench/FP16Benchmark.cc @@ -212,8 +212,11 @@ void performance_test() { int main(int /*argc*/, char** /*argv*/) { #ifdef _OPENMP - omp_set_num_threads(1); + // Use 1 thread unless OMP_NUM_THREADS is explicit set. + const char* val = getenv("OMP_NUM_THREADS"); + if (val == nullptr || !*val) { + omp_set_num_threads(1); + } #endif - performance_test(); } diff --git a/bench/Im2ColFusedRequantizeBenchmark.cc b/bench/Im2ColFusedRequantizeBenchmark.cc index d564ad4..b583358 100644 --- a/bench/Im2ColFusedRequantizeBenchmark.cc +++ b/bench/Im2ColFusedRequantizeBenchmark.cc @@ -350,7 +350,11 @@ void performance_test() { int main() { #ifdef _OPENMP - omp_set_num_threads(1); + // Use 1 thread unless OMP_NUM_THREADS is explicit set. + const char* val = getenv("OMP_NUM_THREADS"); + if (val == nullptr || !*val) { + omp_set_num_threads(1); + } #endif performance_test<int16_t>(); performance_test<int32_t>(); diff --git a/bench/PackedFloatInOutBenchmark.cc b/bench/PackedFloatInOutBenchmark.cc index f2589f7..1397125 100644 --- a/bench/PackedFloatInOutBenchmark.cc +++ b/bench/PackedFloatInOutBenchmark.cc @@ -256,7 +256,11 @@ void performance_test() { int main(int /* unused */, char** /* unused */) { #ifdef _OPENMP - omp_set_num_threads(1); + // Use 1 thread unless OMP_NUM_THREADS is explicit set. + const char* val = getenv("OMP_NUM_THREADS"); + if (val == nullptr || !*val) { + omp_set_num_threads(1); + } #endif performance_test(); return 0; diff --git a/bench/PackedRequantizeAcc16Benchmark.cc b/bench/PackedRequantizeAcc16Benchmark.cc index 89cca4f..8706f96 100644 --- a/bench/PackedRequantizeAcc16Benchmark.cc +++ b/bench/PackedRequantizeAcc16Benchmark.cc @@ -445,6 +445,7 @@ void performance_test() { int main() { #ifdef _OPENMP + // Use 1 thread unless OMP_NUM_THREADS is explicit set. const char* val = getenv("OMP_NUM_THREADS"); if (val == nullptr || !*val) { omp_set_num_threads(1); diff --git a/bench/PackedRequantizeAcc32Benchmark.cc b/bench/PackedRequantizeAcc32Benchmark.cc index 56066a0..2f04795 100644 --- a/bench/PackedRequantizeAcc32Benchmark.cc +++ b/bench/PackedRequantizeAcc32Benchmark.cc @@ -323,6 +323,7 @@ void performance_test() { int main(int /* unused */, char** /* unused */) { #ifdef _OPENMP + // Use 1 thread unless OMP_NUM_THREADS is explicit set. const char* val = getenv("OMP_NUM_THREADS"); if (val == nullptr || !*val) { omp_set_num_threads(1); |