-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust get_bit_size_for_range() for size-1 domains.
- Loading branch information
1 parent
c98c187
commit 846b14a
Showing
2 changed files
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#include "int_packer.h" | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
|
||
using namespace std; | ||
|
@@ -24,6 +23,11 @@ static IntPacker::Bin get_bit_mask(int from, int to) { | |
} | ||
|
||
static int get_bit_size_for_range(int range) { | ||
assert(range >= 1); | ||
// Domains in domain-abstracted tasks may have size one. | ||
if (range == 1) { | ||
return 1; | ||
} | ||
int num_bits = 0; | ||
while ((1U << num_bits) < static_cast<unsigned int>(range)) | ||
++num_bits; | ||
|
@@ -84,8 +88,6 @@ void IntPacker::set(Bin *buffer, int var, int value) const { | |
|
||
void IntPacker::pack_bins(const vector<int> &ranges) { | ||
assert(var_infos.empty()); | ||
assert(all_of(ranges.begin(), ranges.end(), | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jendrikseipp
Author
Contributor
|
||
[](int range) {return range > 1;})); | ||
|
||
int num_vars = ranges.size(); | ||
var_infos.resize(num_vars); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm not sure but a range of 0 (or -1) could still cause an issue so the assertion might be useful with a
>= 1
instead of the>1
. But since the assertion wasn't there before, not adding it just leave things as they were, so no need to add it if you think it's not worth the hassle.