Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ orbs:
commands:
run-cibuildwheel:
parameters:
cibw-config: # environment variables
type: string
default: ""
cibw-version:
type: string
default: 4.2.0 # latest as of August 2026
Expand All @@ -16,7 +19,7 @@ commands:
shell: bash -eo pipefail
command: |
python -m pip install --user cibuildwheel==<< parameters.cibw-version >>
python -m cibuildwheel --output-dir dist
<< parameters.cibw-config >> python -m cibuildwheel --output-dir dist

- store_artifacts: &store-artifacts
path: ./dist
Expand Down Expand Up @@ -122,7 +125,9 @@ jobs:

steps:
- checkout
- run-cibuildwheel
- run: choco install llvm -y
- run-cibuildwheel:
cibw-config: CIBW_ENVIRONMENT_PASS=CXX CXX=clang-cl

python-sdist:
docker:
Expand Down Expand Up @@ -407,7 +412,7 @@ workflows:
name: cpp-gcc-<< matrix.gcc-version >>
matrix:
parameters:
gcc-version: ["12", "latest"]
gcc-version: ["14", "latest"]
- cpp-macOS
- serialization:
requires:
Expand Down
13 changes: 0 additions & 13 deletions dwave/optimization/include/dwave-optimization/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,3 @@ typedef std::int64_t ssize_t;
#include <sys/types.h> // for ssize_t

#endif

namespace dwave::optimization {

// backport unreachable from c++23
[[noreturn]] inline void unreachable() {
#if defined(_MSC_VER) && !defined(__clang__) // MSVC
__assume(false);
#else // GCC, Clang
__builtin_unreachable();
#endif
}

} // namespace dwave::optimization
3 changes: 2 additions & 1 deletion dwave/optimization/include/dwave-optimization/iterators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <concepts>
#include <memory>
#include <span>
#include <utility>

#include "dwave-optimization/common.hpp" // for ssize_t
#include "dwave-optimization/typing.hpp"
Expand Down Expand Up @@ -461,7 +462,7 @@ requires(
case FormatCharacter::signedlonglong_:
return *static_cast<const signed long long*>(ptr);
}
unreachable();
std::unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <optional>
#include <random>
#include <utility>
#include <vector>

#include "dwave-optimization/array.hpp"
Expand Down Expand Up @@ -113,18 +114,18 @@ class DynamicArrayTestingNode : public ArrayOutputMixin<ArrayNode>, public Decis
checkpoint_type& checkpoint
) const override {
assert(false and "not implemented");
unreachable();
std::unreachable();
}
[[noreturn]] void assign_from_checkpoint(
State& state,
checkpoint_type&& checkpoint
) const override {
assert(false and "not implemented");
unreachable();
std::unreachable();
}
[[noreturn]] virtual checkpoint_type checkpoint(State& state) const override {
assert(false and "not implemented");
unreachable();
std::unreachable();
}

// State mutation methods *************************************************
Expand Down Expand Up @@ -185,7 +186,7 @@ class DynamicArrayTestingNode : public ArrayOutputMixin<ArrayNode>, public Decis
case 2:
return set(state, rng);
default:
unreachable();
std::unreachable();
}
}

Expand Down
2 changes: 0 additions & 2 deletions dwave/optimization/src/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ std::vector<ssize_t> broadcast_shapes(
std::vector<ssize_t> shape(std::max(lhs.size(), rhs.size()));

// Walk backwards through the shapes, checking for dimension compatibility.
// Technically span::rbegin() etc are c++23 features but it seems to work on
// all the compilers we care about. Whereas the c++20 ranges::rbegin() etc do not.
auto lit = lhs.rbegin();
const auto lend = lhs.rend();
auto rit = rhs.rbegin();
Expand Down
11 changes: 6 additions & 5 deletions dwave/optimization/src/nodes/binaryop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ranges>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <vector>

#include "_state.hpp"
Expand Down Expand Up @@ -151,7 +152,7 @@ std::pair<double, double> calculate_values_minmax(const Array* lhs_ptr, const Ar
}

assert(false && "not implemeted yet");
unreachable();
std::unreachable();
}

template <class BinaryOp>
Expand Down Expand Up @@ -182,7 +183,7 @@ bool calculate_integral(const Array* lhs_ptr, const Array* rhs_ptr) {
}

assert(false && "not implemeted yet");
unreachable();
std::unreachable();
}

template <class BinaryOp>
Expand Down Expand Up @@ -294,7 +295,7 @@ void BinaryOpNode<BinaryOp>::initialize_state(State& state) const {
} else {
// this case is complicated we need to "stretch" dimensions into each other
assert(false && "not yet implemented");
unreachable();
std::unreachable();
}

this->template emplace_data_ptr_<ArrayNodeStateData>(state, std::move(values));
Expand Down Expand Up @@ -427,7 +428,7 @@ void BinaryOpNode<BinaryOp>::propagate(State& state) const {
} else {
// this case is complicated we need to "stretch" dimensions into eachother
assert(false && "not yet implemented");
unreachable();
std::unreachable();
}

if (ptr->diff().size()) Node::propagate(state);
Expand Down Expand Up @@ -512,7 +513,7 @@ SizeInfo binaryop_calculate_sizeinfo(

// not possible for us to be dynamic and none of our predecessors to be
assert(false && "not implemeted");
unreachable();
std::unreachable();
}

template <class BinaryOp>
Expand Down
2 changes: 1 addition & 1 deletion dwave/optimization/src/nodes/collections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ struct DisjointBitSetsNodeData_ : CheckpointableState, NodeStateData {
}

assert(false and "disjoint set elements must be in exactly one bit-set once");
unreachable();
std::unreachable();
}

void commit() {
Expand Down
9 changes: 5 additions & 4 deletions dwave/optimization/src/nodes/creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "dwave-optimization/nodes/creation.hpp"

#include <utility>
#include <variant>

#include "_state.hpp"
Expand Down Expand Up @@ -109,7 +110,7 @@ std::vector<double> arange(const ssize_t start, const ssize_t stop, const ssize_
}
} else {
assert(false && "0 step not allowed");
unreachable();
std::unreachable();
}

return arange;
Expand Down Expand Up @@ -178,7 +179,7 @@ std::pair<double, double> calculate_values_minmax(
}

assert(false && "zero step not allowed");
unreachable();
std::unreachable();
}

const SizeInfo calculate_arange_sizeinfo(
Expand Down Expand Up @@ -226,7 +227,7 @@ const SizeInfo calculate_arange_sizeinfo(
);
} else {
assert(false && "unreachable");
unreachable();
std::unreachable();
}

// Handles all cases EXCEPT the following: "Exactly one predecessor, it
Expand Down Expand Up @@ -423,7 +424,7 @@ void ARangeNode::propagate(State& state) const {
}
} else {
assert(false && "zero step not allowed");
unreachable();
std::unreachable();
}

if (ptr->diff().size()) Node::propagate(state);
Expand Down
9 changes: 2 additions & 7 deletions dwave/optimization/src/nodes/flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,8 @@ void WhereNode::initialize_state(State& state) const {
std::vector<double> values;
values.reserve(condition.size());

// zip would be very nice here...
for (
auto cit = condition.begin(), xit = x.begin(), yit = y.begin();
cit != std::default_sentinel;
++cit, ++xit, ++yit
) {
values.emplace_back((*cit) ? *xit : *yit);
for (const auto& [ci, xi, yi] : std::views::zip(condition, x, y)) {
values.emplace_back(ci ? xi : yi);
}

emplace_data_ptr_<WhereNodeData>(state, std::move(values));
Expand Down
7 changes: 4 additions & 3 deletions dwave/optimization/src/nodes/indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <ranges>
#include <unordered_set>
#include <utility>
#include <variant>

#include "_state.hpp"
Expand Down Expand Up @@ -781,7 +782,7 @@ void AdvancedIndexingNode::replace_predecessor_(ssize_t index, Node* node_ptr) {
}

assert(false and "should not be able to get here");
unreachable();
std::unreachable();
}

void AdvancedIndexingNode::revert(State& state) const {
Expand Down Expand Up @@ -1405,13 +1406,13 @@ SizeInfo basicindexing_calculate_sizeinfo(
} else if (start < 0 && stop >= 0) {
// -start:stop:step - imposes a nonlinear maximum size
assert(false && "not linear, handled above");
unreachable();
std::unreachable();
} else if (start < 0 && stop < 0) {
// -start:-stop:step - imposes a maximum size
sizeinfo.max = num_per_row * (std::max<ssize_t>(stop - start, 0) + step - 1) / step;
} else {
assert(false && "shouldn't be reachable");
unreachable();
std::unreachable();
}
}

Expand Down
4 changes: 3 additions & 1 deletion dwave/optimization/src/nodes/lambda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "dwave-optimization/nodes/lambda.hpp"

#include <utility>

#include "_state.hpp"
#include "dwave-optimization/array.hpp"
#include "dwave-optimization/graph.hpp"
Expand Down Expand Up @@ -352,7 +354,7 @@ void AccumulateZipNode::propagate(State& state) const {
data->emplace_back(val);
} else {
assert(false && "index is too large for current buffer");
unreachable();
std::unreachable();
}
}

Expand Down
3 changes: 2 additions & 1 deletion dwave/optimization/src/nodes/lp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "dwave-optimization/nodes/lp.hpp"

#include <string>
#include <utility>

#include "../simplex.hpp"
#include "_state.hpp"
Expand Down Expand Up @@ -433,7 +434,7 @@ void LinearProgramNode::replace_predecessor_(ssize_t index, Node* node_ptr) {
if (check_and_replace(lb_ptr_)) return;
if (check_and_replace(ub_ptr_)) return;

unreachable();
std::unreachable();
assert(false and "should never get here");
}

Expand Down
9 changes: 1 addition & 8 deletions dwave/optimization/src/nodes/manipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,7 @@ void ResizeNode::initialize_state(State& state) const {
const ssize_t size = this->size(); // the desired size of our state
assert(size >= 0); // we're never dynamic

std::vector<double> values;
values.reserve(size);

// Fill in from our predecessor, up to our size.
// In c++23 we could use append_range(...) which would be nicer.
for (const auto& v : array_ptr_->view(state) | std::views::take(size)) {
values.emplace_back(v);
}
auto values = std::ranges::to<std::vector>(array_ptr_->view(state) | std::views::take(size));

// Now fill in everything else with our fill value
assert(
Expand Down
5 changes: 3 additions & 2 deletions dwave/optimization/src/nodes/naryop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cmath>
#include <stdexcept>
#include <type_traits>
#include <utility>

#include "_state.hpp"

Expand Down Expand Up @@ -83,7 +84,7 @@ bool calculate_integral(const std::vector<Array*>& operands) {
}

assert(false && "not implemeted yet");
unreachable();
std::unreachable();
}

template <class BinaryOp>
Expand Down Expand Up @@ -142,7 +143,7 @@ ValuesInfo calculate_values_info(const std::vector<Array*>& operands) {
}

assert(false && "not implemeted yet");
unreachable();
std::unreachable();
}

template <class BinaryOp>
Expand Down
8 changes: 4 additions & 4 deletions dwave/optimization/src/nodes/numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ bool satisfies_sum_constraint(
break;
default:
assert(false && "Unexpected operator type.");
unreachable();
std::unreachable();
}
}
}
Expand Down Expand Up @@ -593,7 +593,7 @@ double sum_constraint_delta(
return (lhs < bound) ? (bound - lhs) : 0.0;
default:
assert(false && "Unexpected operator type.");
unreachable();
std::unreachable();
}
}

Expand Down Expand Up @@ -717,7 +717,7 @@ void NumberNode::initialize_state(State& state) const {
initialize_state(state, std::move(values));
} else {
assert(false && "Multiple sum constraints not yet supported.");
unreachable();
std::unreachable();
}
}

Expand Down Expand Up @@ -1608,7 +1608,7 @@ void BinaryNode::initialize_state(State& state) const {
initialize_state(state, std::move(values));
} else {
assert(false && "Multiple sum constraints not yet supported.");
unreachable();
std::unreachable();
}
}

Expand Down
Loading