Skip to content

Commit

Permalink
Fix error: enumeration value 'OperandC' not handled in switch
Browse files Browse the repository at this point in the history
When building with clang 14, the following warning, that is treated
as error, occurs:
enumeration value 'OperandC' not handled in switch [-Werror,-Wswitch]
  • Loading branch information
AndreyPavlenko committed Jan 26, 2025
1 parent ec278de commit d7b9157
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
29 changes: 19 additions & 10 deletions third_party/intel/lib/Dialect/TritonIntelGPU/IR/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,21 @@ DpasEncodingAttr::getDPASRepetitions(ArrayRef<int64_t> shape,
std::max<int64_t>(1, shape[rank - 1] / (shapePerWarp[rank - 1] *
warpsPerCTA[rank - 1]))};
} break;
case OpIdx::OperandC: {
auto shapePerWarp = getShapeC();
int64_t numRepBatch =
rank == 3 ? std::max<int64_t>(1, shape[0] /
(shapePerWarp[0] * warpsPerCTA[0]))
: 1;
return {numRepBatch,
std::max<int64_t>(1, shape[rank - 2] / (shapePerWarp[rank - 2] *
warpsPerCTA[rank - 2])),
std::max<int64_t>(1, shape[rank - 1] / (shapePerWarp[rank - 1] *
warpsPerCTA[rank - 1]))};
} break;
}

auto shapePerWarp = getShapeC();
int64_t numRepBatch =
rank == 3
? std::max<int64_t>(1, shape[0] / (shapePerWarp[0] * warpsPerCTA[0]))
: 1;
return {numRepBatch,
std::max<int64_t>(1, shape[rank - 2] / (shapePerWarp[rank - 2] *
warpsPerCTA[rank - 2])),
std::max<int64_t>(1, shape[rank - 1] / (shapePerWarp[rank - 1] *
warpsPerCTA[rank - 1]))};
llvm_unreachable("unexpected opIdx");
}

unsigned DpasEncodingAttr::getTotalElemsPerThreadForOperand(
Expand All @@ -279,6 +282,9 @@ unsigned DpasEncodingAttr::getTotalElemsPerThreadForOperand(
// dpas operands scalar are evenly sharded to each work item.
return (totalElem / threadsPerWar) * product<int64_t>(rep);
} break;
case OpIdx::OperandC: {
llvm_unreachable("unexpected OpIdx::OperandC");
} break;
}
llvm_unreachable("unexpected opIdx");
}
Expand Down Expand Up @@ -350,6 +356,9 @@ DpasEncodingAttr::getSizePerThreadForOperand(int kWidth, OpIdx opIdx) const {
return {shapeB[rank - 2] / threadsPerWarp[0],
shapeB[rank - 1] / threadsPerWarp[1] * repCluster[rank - 1]};
} break;
case OpIdx::OperandC: {
llvm_unreachable("unexpected OpIdx::OperandC");
} break;
}
llvm_unreachable("unexpected opIdx");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ struct ConvertLayoutOpConversion
repInner = repetitions[1];
repClusterOuter = repCluster[rank - 1];
} break;
case DpasEncodingAttr::OpIdx::OperandC: {
llvm_unreachable("unexpected OpIdx::OperandC");
} break;
}

// TODO: Operands B requires extra steps to combine [8, 16] to [16, 16].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ struct LoadOpConversion
i32_val(outer * repOuterStride + rep * repStride));
offsetY = i32_val(k * repKStride);
} break;
case DpasEncodingAttr::OpIdx::OperandC: {
llvm_unreachable("unexpected OpIdx::OperandC");
} break;
}

offsetX = add(offsetX, offsetBaseX);
Expand Down Expand Up @@ -942,6 +945,9 @@ struct LoadOpConversion
k + row}] =
bitcast(loadVal, unpackedDPASOperandType);
} break;
case DpasEncodingAttr::OpIdx::OperandC: {
llvm_unreachable("unexpected OpIdx::OperandC");
} break;
}
}
}
Expand Down

0 comments on commit d7b9157

Please sign in to comment.