Skip to content

Commit 90a58d0

Browse files
authored
fix scaling for count and update CI (#328)
1 parent 6cde30a commit 90a58d0

File tree

8 files changed

+46
-27
lines changed

8 files changed

+46
-27
lines changed

.github/workflows/cov.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
env:
1414
B2_OPTS: -q -j2 warnings-as-errors=on
15+
GCC_VERSION: 11
1516

1617
jobs:
1718
cov:
@@ -49,12 +50,12 @@ jobs:
4950
cd libs/histogram
5051
5152
# don't compile examples in coverage build, coverage must come from tests alone
52-
../../b2 $B2_OPTS toolset=gcc-8 cxxstd=latest coverage=on test//all
53+
../../b2 $B2_OPTS toolset=gcc-${GCC_VERSION} cxxstd=latest coverage=on test//all
5354
5455
- name: Process coverage data
5556
run: |
5657
cd libs/histogram
57-
GCOV=gcov-8 tools/cov.py
58+
GCOV=gcov-${GCC_VERSION} tools/cov.py
5859
5960
- uses: coverallsapp/[email protected]
6061
with:

.github/workflows/fast.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ jobs:
3737
- name: ctest
3838
run: |
3939
cd build
40+
cmake --build . -j3 --target tests # temporary workaround (I hope)
4041
ctest -C Debug --output-on-failure

.github/workflows/slow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
cd libs/histogram
108108
../../b2 $B2_OPTS toolset=gcc-10 cxxstd=20 cxxflags="-O3 -funsafe-math-optimizations" test//all examples
109109
110-
clang6:
110+
clang10:
111111
runs-on: ubuntu-latest
112112
steps:
113113
- uses: actions/checkout@v2
@@ -127,4 +127,4 @@ jobs:
127127
- name: Test cxxstd=17 ubsan asan
128128
run: |
129129
cd libs/histogram
130-
../../b2 $B2_OPTS toolset=clang-6 cxxstd=17 variant=histogram_ubasan test//all
130+
../../b2 $B2_OPTS toolset=clang-10 cxxstd=17 variant=histogram_ubasan test//all

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
4545

4646
include(CTest)
4747
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
48+
add_dependencies(check tests) # needed to build the "run" tests
4849

4950
if(BUILD_TESTING)
5051

include/boost/histogram/detail/atomic_number.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ struct atomic_number : std::atomic<T> {
4242
return *this;
4343
}
4444

45+
// not thread-safe
46+
atomic_number& operator*=(const T& x) noexcept {
47+
this->store(this->load() * x);
48+
return *this;
49+
}
50+
4551
private:
4652
// for integral types
4753
template <class U = T>

include/boost/histogram/histogram.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class histogram : detail::mutex_base<Axes, Storage> {
279279
detail::sample_args_passed_vs_expected<sample_args_passed,
280280
typename acc_traits::args>();
281281
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
282-
mp11::tuple_apply(
282+
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
283283
[&](const auto&... sargs) {
284284
constexpr bool sample_valid =
285285
std::is_convertible<sample_args_passed, typename acc_traits::args>::value;
@@ -309,7 +309,7 @@ class histogram : detail::mutex_base<Axes, Storage> {
309309
detail::sample_args_passed_vs_expected<sample_args_passed,
310310
typename acc_traits::args>();
311311
std::lock_guard<typename mutex_base::type> guard{mutex_base::get()};
312-
mp11::tuple_apply(
312+
mp11::tuple_apply( // LCOV_EXCL_LINE: gcc-11 is missing this line for no reason
313313
[&](const auto&... sargs) {
314314
constexpr bool weight_valid = acc_traits::weight_support;
315315
static_assert(weight_valid, "error: accumulator does not support weights");

test/accumulators_count_test.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,38 @@ template <class T, bool B>
1717
void run_tests() {
1818
using c_t = accumulators::count<T, B>;
1919

20-
c_t c;
21-
++c;
22-
BOOST_TEST_EQ(c.value(), 1);
23-
BOOST_TEST_EQ(str(c), "1"s);
24-
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
25-
BOOST_TEST_EQ(str(c, 2, true), "1 "s);
26-
27-
c += 2;
28-
BOOST_TEST_EQ(str(c), "3"s);
29-
30-
BOOST_TEST_EQ(c, static_cast<T>(3));
31-
BOOST_TEST_NE(c, static_cast<T>(2));
32-
33-
c_t one(1), two(2), one_copy(1);
34-
BOOST_TEST_LT(one, two);
35-
BOOST_TEST_LE(one, two);
36-
BOOST_TEST_LE(one, one_copy);
37-
BOOST_TEST_GT(two, one);
38-
BOOST_TEST_GE(two, one);
39-
BOOST_TEST_GE(one, one_copy);
20+
{
21+
c_t c;
22+
++c;
23+
BOOST_TEST_EQ(c.value(), 1);
24+
BOOST_TEST_EQ(str(c), "1"s);
25+
BOOST_TEST_EQ(str(c, 2, false), " 1"s);
26+
BOOST_TEST_EQ(str(c, 2, true), "1 "s);
27+
28+
c += 2;
29+
BOOST_TEST_EQ(str(c), "3"s);
30+
31+
BOOST_TEST_EQ(c, static_cast<T>(3));
32+
BOOST_TEST_NE(c, static_cast<T>(2));
33+
}
34+
35+
{
36+
c_t one(1), two(2), one_copy(1);
37+
BOOST_TEST_LT(one, two);
38+
BOOST_TEST_LE(one, two);
39+
BOOST_TEST_LE(one, one_copy);
40+
BOOST_TEST_GT(two, one);
41+
BOOST_TEST_GE(two, one);
42+
BOOST_TEST_GE(one, one_copy);
43+
}
4044

4145
BOOST_TEST_EQ(c_t{} += c_t{}, c_t{});
46+
47+
{
48+
c_t two(2);
49+
auto six = two * 3;
50+
BOOST_TEST_EQ(six, static_cast<T>(6));
51+
}
4252
}
4353

4454
int main() {

tools/cov.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
LCOV_VERSION = "1.15"
2020

21-
gcov = os.environ.get("GCOV", "gcov-8")
21+
gcov = os.environ.get("GCOV", "gcov")
2222

2323
gcov_version = gcov.split("-")[1] if "-" in gcov else None
2424
gcc_version = f"gcc-{gcov_version}" if gcov_version else "gcc"

0 commit comments

Comments
 (0)