Skip to content

Commit f7240de

Browse files
authored
Merge branch 'master' into acc-perf
2 parents 2030402 + af7a027 commit f7240de

8 files changed

Lines changed: 49 additions & 36 deletions

File tree

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ CheckOptions:
8888
- key: readability-identifier-length.MinimumParameterNameLength
8989
value: 1
9090
- key: misc-include-cleaner.IgnoreHeaders
91-
value: '(__chrono/.*|stdlib\.h)'
91+
value: '(__chrono/.*|stdlib\.h|3rdparty/.*)'

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ jobs:
2121
run: |
2222
sudo apt-get update
2323
sudo apt-get install --no-install-recommends -y \
24-
gcc-14 g++-14 ninja-build python3-pip clang-format-16
24+
gcc-14 g++-14 ninja-build python3-pip
25+
wget https://apt.llvm.org/llvm.sh
26+
chmod u+x llvm.sh
27+
sudo ./llvm.sh 20 all
2528
python3 -m pip install -r requirements.txt
2629
- name: Run pre-commit checks
2730
run: |

3rdparty/stb_image_wrapper.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#define STB_IMAGE_IMPLEMENTATION
22

3-
// NOLINTNEXTLINE(misc-include-cleaner)
43
#include "stb_library.hpp"

cmake/configure.cmake

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,52 +39,37 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
3939
set(CMAKE_SKIP_BUILD_RPATH OFF)
4040

4141
if(UNIX)
42-
set(COMMON_COMPILER_FLAGS
43-
"${COMMON_COMPILER_FLAGS} \
44-
-Wall -Wextra \
45-
-Wsign-compare")
42+
add_compile_options(-Wall -Wextra -Wsign-compare)
43+
4644
if(NOT APPLE)
47-
set(COMMON_COMPILER_FLAGS
48-
"${COMMON_COMPILER_FLAGS} \
49-
-Wpedantic \
50-
-Wpointer-arith \
51-
-Wcast-align \
52-
-Wwrite-strings \
53-
-Wswitch-enum \
54-
-Wnull-dereference \
55-
-Wswitch-enum \
56-
-Wformat=2 \
57-
-Wmissing-declarations \
58-
-Wno-c11-extensions")
45+
add_compile_options(
46+
-Wpedantic
47+
-Wpointer-arith
48+
-Wcast-align
49+
-Wwrite-strings
50+
-Wswitch-enum
51+
-Wnull-dereference
52+
-Wformat=2
53+
-Wmissing-declarations
54+
-Wno-c11-extensions)
5955
endif(NOT APPLE)
60-
set(CMAKE_C_FLAGS
61-
"${CMAKE_C_FLAGS} \
62-
-Wold-style-definition \
63-
-Wmissing-prototypes")
56+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wold-style-definition>)
57+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wmissing-prototypes>)
6458

6559
if("${ENABLE_ADDRESS_SANITIZER}"
6660
OR "${ENABLE_UB_SANITIZER}"
6761
OR "${ENABLE_LEAK_SANITIZER}")
68-
set(COMMON_COMPILER_FLAGS
69-
"${COMMON_COMPILER_FLAGS} -Wno-cast-align -Wno-cast-function-type")
62+
add_compile_options(-Wno-cast-align -Wno-cast-function-type)
7063
endif()
7164

72-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
73-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILER_FLAGS}")
7465
if(USE_COVERAGE)
75-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
76-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
66+
add_compile_options(--coverage)
67+
add_link_options(--coverage)
7768
endif(USE_COVERAGE)
7869
endif()
7970

8071
if(MSVC)
81-
set(COMMON_FLAGS "/W4 /wd4267 /wd4244")
82-
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS}")
83-
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS}")
84-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
85-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_FLAGS}")
86-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_FLAGS}")
87-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
72+
add_compile_options(/W4 /wd4267 /wd4244)
8873
endif(MSVC)
8974

9075
find_package(Threads REQUIRED)

docs/user_guide/environment_variables.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The following environment variables can be used to configure the project's runti
55

66
- ``PPC_NUM_PROC``: Specifies the number of processes to launch.
77
Default: ``1``
8+
Can be queried from C++ with ``ppc::util::GetNumProc()``.
89

910
- ``PPC_NUM_THREADS``: Specifies the number of threads to use.
1011
Default: ``1``

modules/util/include/util.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
5252

5353
std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
5454
int GetNumThreads();
55+
int GetNumProc();
5556
double GetTaskMaxTime();
5657
double GetPerfMaxTime();
5758

modules/util/src/util.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ int ppc::util::GetNumThreads() {
2828
return 1;
2929
}
3030

31+
int ppc::util::GetNumProc() {
32+
const auto num_proc = env::get<int>("PPC_NUM_PROC");
33+
if (num_proc.has_value()) {
34+
return num_proc.value();
35+
}
36+
return 1;
37+
}
38+
3139
double ppc::util::GetTaskMaxTime() {
3240
const auto val = env::get<double>("PPC_TASK_MAX_TIME");
3341
if (val.has_value()) {

modules/util/tests/util.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,19 @@ TEST(GetPerfMaxTime, ReadsFromEnvironment) {
108108
env::detail::set_scoped_environment_variable scoped("PPC_PERF_MAX_TIME", "12.5");
109109
EXPECT_DOUBLE_EQ(ppc::util::GetPerfMaxTime(), 12.5);
110110
}
111+
112+
TEST(GetNumProc, ReturnsDefaultWhenUnset) {
113+
const auto old = env::get<int>("PPC_NUM_PROC");
114+
if (old.has_value()) {
115+
env::detail::delete_environment_variable("PPC_NUM_PROC");
116+
}
117+
EXPECT_EQ(ppc::util::GetNumProc(), 1);
118+
if (old.has_value()) {
119+
env::detail::set_environment_variable("PPC_NUM_PROC", std::to_string(*old));
120+
}
121+
}
122+
123+
TEST(GetNumProc, ReadsFromEnvironment) {
124+
env::detail::set_scoped_environment_variable scoped("PPC_NUM_PROC", "4");
125+
EXPECT_EQ(ppc::util::GetNumProc(), 4);
126+
}

0 commit comments

Comments
 (0)