Skip to content

Commit 415f885

Browse files
committed
add win scripts
1 parent 8856207 commit 415f885

File tree

6 files changed

+63
-53
lines changed

6 files changed

+63
-53
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -726,20 +726,40 @@ jobs:
726726
shell: bash
727727
run: |
728728
cmake --build build --config Release --parallel
729+
- name: Run func tests (MPI, num_proc=1)
730+
run: python3 scripts/run_tests.py --running-type="processes"
731+
env:
732+
PROC_COUNT: 1
733+
OMP_NUM_THREADS: 3
734+
- name: Run func tests (MPI, num_proc=2)
735+
run: python3 scripts/run_tests.py --running-type="processes"
736+
env:
737+
PROC_COUNT: 2
738+
OMP_NUM_THREADS: 2
739+
- name: Run func tests (MPI, num_proc=3)
740+
run: python3 scripts/run_tests.py --running-type="processes"
741+
env:
742+
PROC_COUNT: 3
743+
OMP_NUM_THREADS: 1
744+
- name: Run func tests (MPI, num_proc=4)
745+
run: python3 scripts/run_tests.py --running-type="processes"
746+
env:
747+
PROC_COUNT: 4
748+
OMP_NUM_THREADS: 1
729749
- name: Run tests (threads, num_threads=1)
730-
run: scripts/run.bat
750+
run: python3 scripts/run_tests.py --running-type="threads"
731751
env:
732752
OMP_NUM_THREADS: 1
733753
- name: Run tests (threads, num_threads=2)
734-
run: scripts/run.bat
754+
run: python3 scripts/run_tests.py --running-type="threads"
735755
env:
736756
OMP_NUM_THREADS: 2
737757
- name: Run tests (threads, num_threads=3)
738-
run: scripts/run.bat
758+
run: python3 scripts/run_tests.py --running-type="threads"
739759
env:
740760
OMP_NUM_THREADS: 3
741761
- name: Run tests (threads, num_threads=4)
742-
run: scripts/run.bat
762+
run: python3 scripts/run_tests.py --running-type="threads"
743763
env:
744764
OMP_NUM_THREADS: 4
745765
windows-msvc-build-extended:
@@ -788,35 +808,35 @@ jobs:
788808
run: |
789809
cmake --build build --config Release --parallel
790810
- name: Run tests (threads, num_threads=5)
791-
run: scripts/run.bat
811+
run: python3 scripts/run_tests.py --running-type="threads"
792812
env:
793813
OMP_NUM_THREADS: 5
794814
- name: Run tests (threads, num_threads=6)
795-
run: scripts/run.bat
815+
run: python3 scripts/run_tests.py --running-type="threads"
796816
env:
797817
OMP_NUM_THREADS: 6
798818
- name: Run tests (threads, num_threads=7)
799-
run: scripts/run.bat
819+
run: python3 scripts/run_tests.py --running-type="threads"
800820
env:
801821
OMP_NUM_THREADS: 7
802822
- name: Run tests (threads, num_threads=8)
803-
run: scripts/run.bat
823+
run: python3 scripts/run_tests.py --running-type="threads"
804824
env:
805825
OMP_NUM_THREADS: 8
806826
- name: Run tests (threads, num_threads=11)
807-
run: scripts/run.bat
827+
run: python3 scripts/run_tests.py --running-type="threads"
808828
env:
809829
OMP_NUM_THREADS: 11
810830
- name: Run tests (threads, num_threads=13)
811-
run: scripts/run.bat
831+
run: python3 scripts/run_tests.py --running-type="threads"
812832
env:
813833
OMP_NUM_THREADS: 13
814834
- name: Run tests (threads, num_threads=15)
815-
run: scripts/run.bat
835+
run: python3 scripts/run_tests.py --running-type="threads"
816836
env:
817837
OMP_NUM_THREADS: 15
818838
- name: Run tests (threads, num_threads=16)
819-
run: scripts/run.bat
839+
run: python3 scripts/run_tests.py --running-type="threads"
820840
env:
821841
OMP_NUM_THREADS: 16
822842
windows-clang-build:

scripts/generate_perf_results.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
22
mkdir build\perf_stat_dir
3-
scripts\run_perf_collector.bat > build\perf_stat_dir\perf_log.txt
3+
python3 scripts/run_tests.py --running-type="performance" > build\perf_stat_dir\perf_log.txt
44
python scripts\create_perf_table.py --input build\perf_stat_dir\perf_log.txt --output build\perf_stat_dir

scripts/run.bat

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/run_perf_collector.bat

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/run_tests.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ class PPCRunner:
2828
def __init__(self):
2929
self.work_dir = None
3030
self.valgrind_cmd = "valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all"
31-
self.ocv_script_name = "setup_vars_opencv4.sh"
32-
self.ocv_script_path = "build/ppc_opencv/install/bin/" + self.ocv_script_name
31+
32+
if platform.system() == "Windows":
33+
self.ocv_script_name = "setup_vars_opencv4.cmd"
34+
self.ocv_script_path = "build/ppc_opencv/install/" + self.ocv_script_name
35+
else:
36+
self.ocv_script_name = "setup_vars_opencv4.sh"
37+
self.ocv_script_path = "build/ppc_opencv/install/bin/" + self.ocv_script_name
38+
39+
if platform.system() == "Windows":
40+
self.mpi_exec = "mpiexec"
41+
else:
42+
self.mpi_exec = "mpirun"
3343

3444
@staticmethod
3545
def __get_project_path():
@@ -39,6 +49,8 @@ def __get_project_path():
3949

4050
@staticmethod
4151
def __source_script(script_path):
52+
if platform.system() == "Windows":
53+
return
4254
command = f"bash -c 'source {script_path} && env'"
4355
result = subprocess.run(command, stdout=subprocess.PIPE, shell=True, text=True)
4456
if result.returncode == 0:
@@ -62,7 +74,8 @@ def setup_env(self):
6274
env_vars = self.__source_script(Path(_work_dir) / self.ocv_script_name)
6375

6476
self.work_dir = Path(_work_dir)
65-
os.environ.update(env_vars)
77+
if not platform.system() == "Windows":
78+
os.environ.update(env_vars)
6679

6780
@staticmethod
6881
def __run_exec(command):
@@ -83,11 +96,14 @@ def run_threads(self):
8396
self.__run_exec(f"{self.valgrind_cmd} {self.work_dir / 'seq_func_tests'} {self.__get_gtest_settings(1)}")
8497
self.__run_exec(f"{self.valgrind_cmd} {self.work_dir / 'stl_func_tests'} {self.__get_gtest_settings(1)}")
8598

86-
self.__run_exec(f"{self.work_dir / 'omp_func_tests'} {self.__get_gtest_settings(3)}")
8799
self.__run_exec(f"{self.work_dir / 'seq_func_tests'} {self.__get_gtest_settings(3)}")
88100
self.__run_exec(f"{self.work_dir / 'stl_func_tests'} {self.__get_gtest_settings(3)}")
89101
self.__run_exec(f"{self.work_dir / 'tbb_func_tests'} {self.__get_gtest_settings(3)}")
90102

103+
if os.environ.get("CLANG_BUILD") == 1:
104+
return
105+
self.__run_exec(f"{self.work_dir / 'omp_func_tests'} {self.__get_gtest_settings(3)}")
106+
91107
def run_core(self):
92108
if platform.system() == "Linux" and not os.environ.get("ASAN_RUN"):
93109
self.__run_exec(f"{self.valgrind_cmd} {self.work_dir / 'core_func_tests'} {self.__get_gtest_settings(1)}")
@@ -97,24 +113,28 @@ def run_core(self):
97113
self.__run_exec(f"{self.work_dir / 'ref_func_tests'} {self.__get_gtest_settings(3)}")
98114

99115
def run_processes(self, additional_mpi_args):
116+
if os.environ.get("CLANG_BUILD") == 1:
117+
return
118+
100119
proc_count = os.environ.get("PROC_COUNT")
101120
if proc_count is None:
102121
raise EnvironmentError("Required environment variable 'PROC_COUNT' is not set.")
103122

104-
mpi_running = f"mpirun {additional_mpi_args} -np {proc_count}"
123+
mpi_running = f"{self.mpi_exec} {additional_mpi_args} -np {proc_count}"
105124
if not os.environ.get("ASAN_RUN"):
106125
self.__run_exec(f"{mpi_running} {self.work_dir / 'all_func_tests'} {self.__get_gtest_settings(10)}")
107126
self.__run_exec(f"{mpi_running} {self.work_dir / 'mpi_func_tests'} {self.__get_gtest_settings(10)}")
108127

109128
def run_performance(self):
110129
if not os.environ.get("ASAN_RUN"):
111130
mpi_running = ""
112-
if platform.system() == "Linux":
113-
mpi_running = "mpirun -np 4"
131+
if platform.system() == "Linux" and platform.system() == "Windows":
132+
mpi_running = f"{self.mpi_exec} -np 4"
114133
elif platform.system() == "Darwin":
115-
mpi_running = "mpirun -np 2"
134+
mpi_running = f"{self.mpi_exec} -np 2"
116135
self.__run_exec(f"{mpi_running} {self.work_dir / 'all_perf_tests'} {self.__get_gtest_settings(1)}")
117136
self.__run_exec(f"{mpi_running} {self.work_dir / 'mpi_perf_tests'} {self.__get_gtest_settings(1)}")
137+
118138
self.__run_exec(f"{self.work_dir / 'omp_perf_tests'} {self.__get_gtest_settings(1)}")
119139
self.__run_exec(f"{self.work_dir / 'seq_perf_tests'} {self.__get_gtest_settings(1)}")
120140
self.__run_exec(f"{self.work_dir / 'stl_perf_tests'} {self.__get_gtest_settings(1)}")

tasks/all/runner.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <string>
1010
#include <utility>
1111

12+
#include "core/util/util.hpp"
1213
#include "oneapi/tbb/global_control.h"
1314

1415
class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
@@ -63,20 +64,8 @@ int main(int argc, char** argv) {
6364
boost::mpi::environment env(argc, argv);
6465
boost::mpi::communicator world;
6566

66-
#ifdef _WIN32
67-
size_t len;
68-
char omp_env[100];
69-
errno_t err = getenv_s(&len, omp_env, sizeof(omp_env), "OMP_NUM_THREADS");
70-
if (err != 0 || len == 0) {
71-
omp_env[0] = '\0';
72-
}
73-
#else
74-
const char* omp_env = std::getenv("OMP_NUM_THREADS");
75-
#endif
76-
int num_threads = (omp_env != nullptr) ? std::atoi(omp_env) : 1;
77-
7867
// Limit the number of threads in TBB
79-
tbb::global_control control(tbb::global_control::max_allowed_parallelism, num_threads);
68+
tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetPPCNumThreads());
8069

8170
::testing::InitGoogleTest(&argc, argv);
8271

0 commit comments

Comments
 (0)