Skip to content

Commit

Permalink
Don't instantiate template for low DIM counts, to fix a warning (#1077)
Browse files Browse the repository at this point in the history
* Don't instantiate template for low DIM counts, to fix a warning

* Reverse the order on the comparison
  • Loading branch information
manopapad authored Nov 23, 2023
1 parent a5aa130 commit 0474c7d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cunumeric/matrix/batched_cholesky_template.inl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct _cholesky_supported {

template <VariantKind KIND>
struct BatchedCholeskyImpl {
template <Type::Code CODE, int DIM>
template <Type::Code CODE, int32_t DIM, std::enable_if_t<(DIM > 2)>* = nullptr>
void operator()(Array& input_array, Array& output_array) const
{
using VAL = legate_type_of<CODE>;
Expand Down Expand Up @@ -94,16 +94,16 @@ struct BatchedCholeskyImpl {

if (shape.empty()) return;

int num_blocks = 1;
for (int i = 0; i < (DIM - 2); ++i) { num_blocks *= (shape.hi[i] - shape.lo[i] + 1); }
int32_t num_blocks = 1;
for (int32_t i = 0; i < (DIM - 2); ++i) { num_blocks *= (shape.hi[i] - shape.lo[i] + 1); }

auto m = static_cast<int32_t>(shape.hi[DIM - 2] - shape.lo[DIM - 2] + 1);
auto n = static_cast<int32_t>(shape.hi[DIM - 1] - shape.lo[DIM - 1] + 1);
assert(m > 0 && n > 0);

auto block_stride = m * n;

for (int i = 0; i < num_blocks; ++i) {
for (int32_t i = 0; i < num_blocks; ++i) {
if constexpr (_cholesky_supported<CODE>::value) {
CopyBlockImpl<KIND>()(output, input, sizeof(VAL) * block_stride);
PotrfImplBody<KIND, CODE>()(output, m, n);
Expand All @@ -119,6 +119,12 @@ struct BatchedCholeskyImpl {
}
}
}

template <Type::Code CODE, int32_t DIM, std::enable_if_t<DIM <= 2>* = nullptr>
void operator()(Array& input_array, Array& output_array) const
{
assert(false);
}
};

template <VariantKind KIND>
Expand Down

0 comments on commit 0474c7d

Please sign in to comment.