diff options
author | Jongsoo Park <jongsoo@fb.com> | 2019-01-31 10:20:24 +0300 |
---|---|---|
committer | Facebook Github Bot <facebook-github-bot@users.noreply.github.com> | 2019-01-31 10:22:59 +0300 |
commit | 1c3685adb3aff4241d83da0c62f94f4f4bd37511 (patch) | |
tree | 0b09d92fe428d951cb5579a886f466223ee194e7 | |
parent | 03a8fa506ee0822e3ab045f8e3df902abcfd2e74 (diff) |
use 1 thread in benchmarks if OMP_NUM_THREADS is not explicitly set (#66)
Summary:
Pull Request resolved: https://github.com/pytorch/FBGEMM/pull/66
As title says
Reviewed By: jianyuh
Differential Revision: D13834515
fbshipit-source-id: 928778ea3207e25eb9861cce683f88b9164d5521
-rw-r--r-- | bench/Depthwise3DBenchmark.cc | 8 | ||||
-rw-r--r-- | bench/DepthwiseBenchmark.cc | 8 | ||||
-rw-r--r-- | bench/GroupwiseConvRequantizeBenchmark.cc | 7 | ||||
-rw-r--r-- | bench/I8SpmdmBenchmark.cc | 8 |
4 files changed, 30 insertions, 1 deletions
diff --git a/bench/Depthwise3DBenchmark.cc b/bench/Depthwise3DBenchmark.cc index a9b4e4b..596fa15 100644 --- a/bench/Depthwise3DBenchmark.cc +++ b/bench/Depthwise3DBenchmark.cc @@ -27,6 +27,14 @@ using namespace std; using namespace fbgemm; 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); + } +#endif + // Depthwise is memory BW bound so we want to flush LLC. bool flush = true; std::vector<char> llc; diff --git a/bench/DepthwiseBenchmark.cc b/bench/DepthwiseBenchmark.cc index 0fe1b5c..6500e29 100644 --- a/bench/DepthwiseBenchmark.cc +++ b/bench/DepthwiseBenchmark.cc @@ -25,6 +25,14 @@ using namespace std; using namespace fbgemm; 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); + } +#endif + // From Xray OCR vector<vector<int>> shapes = { // NOTE: clang-format wants to use a different formatting but the current diff --git a/bench/GroupwiseConvRequantizeBenchmark.cc b/bench/GroupwiseConvRequantizeBenchmark.cc index 032d0d3..991013f 100644 --- a/bench/GroupwiseConvRequantizeBenchmark.cc +++ b/bench/GroupwiseConvRequantizeBenchmark.cc @@ -500,7 +500,12 @@ void performance_test() { int main() { #ifdef _OPENMP - omp_set_num_threads(1); + // TODO: enable once fbgemmGroupwiseConv support multi-threading + /*// 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/I8SpmdmBenchmark.cc b/bench/I8SpmdmBenchmark.cc index 4223d0c..fdec2d0 100644 --- a/bench/I8SpmdmBenchmark.cc +++ b/bench/I8SpmdmBenchmark.cc @@ -25,6 +25,14 @@ using namespace std; using namespace fbgemm; 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); + } +#endif + const vector<array<int, 3>> shapes = { // M, N, K {1024, 1024, 1024}, |