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 gcc 13 and clang 14 the following warning, that is
treated as error, occurs:
error: enumeration value 'OperandC' not handled in switch [-Werror,-Wswitch]
  • Loading branch information
AndreyPavlenko committed Jan 23, 2025
1 parent fe29adf commit fd4c1b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
28 changes: 17 additions & 11 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,8 @@ 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 OperandC");
}
llvm_unreachable("unexpected opIdx");
}
Expand Down Expand Up @@ -350,8 +355,9 @@ DpasEncodingAttr::getSizePerThreadForOperand(int kWidth, OpIdx opIdx) const {
return {shapeB[rank - 2] / threadsPerWarp[0],
shapeB[rank - 1] / threadsPerWarp[1] * repCluster[rank - 1]};
} break;
default:
llvm_unreachable("unexpected opIdx");
}
llvm_unreachable("unexpected opIdx");
}

SmallVector<unsigned> DpasEncodingAttr::getContigPerThread() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ struct ConvertLayoutOpConversion
repInner = repetitions[1];
repClusterOuter = repCluster[rank - 1];
} break;
default:
llvm_unreachable("unexpected opIdx");
}

// 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,8 @@ struct LoadOpConversion
i32_val(outer * repOuterStride + rep * repStride));
offsetY = i32_val(k * repKStride);
} break;
default:
llvm_unreachable("unexpected opIdx");
}

offsetX = add(offsetX, offsetBaseX);
Expand Down Expand Up @@ -942,6 +944,8 @@ struct LoadOpConversion
k + row}] =
bitcast(loadVal, unpackedDPASOperandType);
} break;
default:
llvm_unreachable("unexpected opIdx");
}
}
}
Expand Down

0 comments on commit fd4c1b6

Please sign in to comment.