| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2022 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
#include "MessageDecoderE64.hpp" |
| 9 |
|
| 10 |
using namespace iga; |
| 11 |
|
| 12 |
struct MessageDecoderOtherE64 : MessageDecoderE64 { |
| 13 |
MessageDecoderOtherE64(Platform _platform, SFID _sfid, ExecSize _execSize, |
| 14 |
int _src0Len, int _src1Len, uint64_t _desc, |
| 15 |
RegRef id0, RegRef id1, DecodeResult &_result) |
| 16 |
: MessageDecoderE64(_platform, _sfid, _execSize, _src0Len, _src1Len, |
| 17 |
_desc, id0, id1, _result) {} |
| 18 |
|
| 19 |
void decodeGTWY(); |
| 20 |
void decodeRTA(); |
| 21 |
void decodeBTD(); |
| 22 |
void decodeRC(); |
| 23 |
|
| 24 |
private: |
| 25 |
const SendOpDefinition &addOpCode(SendOp op); |
| 26 |
}; // MessageDecoderOtherE64 |
| 27 |
|
| 28 |
const SendOpDefinition &MessageDecoderOtherE64::addOpCode(SendOp op) { |
| 29 |
auto opBits = getDescBits(0, 6); |
| 30 |
const auto &sOpInfo = lookupSendOp(op); |
| 31 |
result.info.op = op; |
| 32 |
result.info.description = sOpInfo.description; |
| 33 |
result.info.symbol = sOpInfo.mnemonic; |
| 34 |
addField("Opcode", 0, 6, opBits, sOpInfo.description); |
| 35 |
return sOpInfo; |
| 36 |
} |
| 37 |
|
| 38 |
void MessageDecoderOtherE64::decodeGTWY() { |
| 39 |
enum GW_OPCODE { |
| 40 |
SIG_EOT = 0x0, |
| 41 |
SIG_BAR = 0x4, |
| 42 |
SIG_NAMED_BAR = 0x5, |
| 43 |
SAVE_BAR = 0x8, |
| 44 |
RESTORE_BAR = 0x9, |
| 45 |
SIG_EOTR = 0xA, |
| 46 |
RESTORE_BTD_STACK = 0xB, |
| 47 |
SIG_SIPBAR = 0xC, |
| 48 |
}; |
| 49 |
result.info.execWidth = int(execSize); |
| 50 |
|
| 51 |
const auto opBits = getDescBits(0, 6); |
| 52 |
|
| 53 |
auto decodeBarrierSigDesc = [&](SendOp op) { |
| 54 |
addOpCode(op); |
| 55 |
|
| 56 |
uint32_t actvThrds = decodeField<uint32_t>( |
| 57 |
"ActiveThreadsOnly", 7, 1, [&](uint32_t enc, std::stringstream &mss) { |
| 58 |
if (enc) { |
| 59 |
mss << "EOT'd threads are not expected to " |
| 60 |
"arrive at barrier"; |
| 61 |
} else { |
| 62 |
mss << "All threads are expected to arrive at barrier"; |
| 63 |
result.syntax.controls += ".all"; |
| 64 |
result.info.description += " (include exited)"; |
| 65 |
} |
| 66 |
return enc; |
| 67 |
}); |
| 68 |
|
| 69 |
if (actvThrds && op == SendOp::SIGNAL_NAMED_BARRIER) |
| 70 |
error(7, 1, "ActiveThreadsOnly forbidden on named barrier"); |
| 71 |
addReserved(6, 1); |
| 72 |
addReserved(8, 46 - 8 + 1); |
| 73 |
}; // decodeBarrierSigDesc |
| 74 |
|
| 75 |
auto decodeEotDesc = [&](SendOp op) |
| 76 |
{ |
| 77 |
addOpCode(op); |
| 78 |
addReserved(6, 1); |
| 79 |
decodeField("EotSubfunc", 7, 2, |
| 80 |
[&](uint32_t enc, std::stringstream &mss) -> void { |
| 81 |
switch (enc) { |
| 82 |
case 0x0: |
| 83 |
mss << "normal"; |
| 84 |
break; |
| 85 |
case 0x1: |
| 86 |
mss << "replay saved EOT"; |
| 87 |
result.info.description += " (replay saved)"; |
| 88 |
break; |
| 89 |
case 0x2: |
| 90 |
mss << "replay not run"; |
| 91 |
result.info.description += " (replay not run)"; |
| 92 |
break; |
| 93 |
case 0x3: |
| 94 |
mss << "empty EOT (no valid thread state)"; |
| 95 |
result.info.description += " (empty state)"; |
| 96 |
break; |
| 97 |
default: |
| 98 |
mss << "?"; |
| 99 |
break; |
| 100 |
} |
| 101 |
}); |
| 102 |
addReserved(9, 46 - 9 + 1); |
| 103 |
}; // decodeEotDesc |
| 104 |
|
| 105 |
auto decodeSimpleDescriptor = [&](SendOp op) { |
| 106 |
addOpCode(op); |
| 107 |
addReserved(6, 41); |
| 108 |
}; |
| 109 |
|
| 110 |
result.info.dstLenBytes = 0; |
| 111 |
result.info.src0LenBytes = 0; |
| 112 |
result.info.src1LenBytes = 0; // all gateway messages lack src1 |
| 113 |
|
| 114 |
switch (opBits) { |
| 115 |
case SIG_BAR: |
| 116 |
decodeBarrierSigDesc(SendOp::SIGNAL_BARRIER); |
| 117 |
addDocs( |
| 118 |
DocRef::Kind::MSGOP, "GW_SIG_BARRIER", "72051", |
| 119 |
DocRef::Kind::DESC, "GW_SIGBAR_DESC", "72052", |
| 120 |
DocRef::Kind::SRC0, "GW_SIGBAR_PAYLOAD", "72057"); |
| 121 |
result.info.src0LenBytes = 12; // r0.2[31:24] ... call it r0.{0,1,2} |
| 122 |
break; |
| 123 |
case SIG_NAMED_BAR: |
| 124 |
decodeBarrierSigDesc(SendOp::SIGNAL_NAMED_BARRIER); |
| 125 |
addDocs( |
| 126 |
DocRef::Kind::MSGOP, "GW_SIG_BARRIER", "72135", |
| 127 |
DocRef::Kind::DESC, "GW_SIGBAR_DESC", "72052", |
| 128 |
DocRef::Kind::SRC0, "GW_NAMEDBAR_PAYLOAD", "72064"); |
| 129 |
result.info.src0LenBytes = 12; // r0.2[31:0] ... call it r0.{0,1,2} |
| 130 |
break; |
| 131 |
case SIG_SIPBAR: |
| 132 |
decodeBarrierSigDesc(SendOp::SIGNAL_SYSTEM_ROUTINE_BARRIER); |
| 133 |
addDocs( |
| 134 |
DocRef::Kind::MSGOP, "GW_SIG_SIPBARRIER", "72058", |
| 135 |
DocRef::Kind::DESC, "GW_SIGBAR_DESC", "72052", |
| 136 |
DocRef::Kind::SRC0, "GW_SIGBAR_PAYLOAD", "72057", |
| 137 |
DocRef::Kind::DST, "MDP_SIP_BARRIER_RESPONSE", "70576"); |
| 138 |
result.info.dstLenBytes = 4; // DST.0[31:0] = "First Thread" |
| 139 |
result.info.src0LenBytes = 12; // r0.2[31:24] ... call it r0.{0,1,2} |
| 140 |
break; |
| 141 |
case SIG_EOT: |
| 142 |
decodeEotDesc(SendOp::EOT); |
| 143 |
addDocs( |
| 144 |
DocRef::Kind::MSGOP, "GW_EOT", "72054", |
| 145 |
DocRef::Kind::DESC, "GW_EOT_DESC", "72055", |
| 146 |
DocRef::Kind::SRC0, "GW_EOT_PAYLOAD", "70051"); |
| 147 |
result.info.dstLenBytes = 0; |
| 148 |
result.info.src0LenBytes = 12; // r0.2[31:24] ... call it r0.{0,1,2} |
| 149 |
break; |
| 150 |
case SIG_EOTR: |
| 151 |
decodeSimpleDescriptor(SendOp::EOTR); |
| 152 |
addDocs( |
| 153 |
DocRef::Kind::MSGOP, "GW_SIG_EOTR", "72060", |
| 154 |
DocRef::Kind::DESC, "GW_EOTR_DESC", "72092", |
| 155 |
DocRef::Kind::SRC0, "EOR_PAYLOAD", "67738"); |
| 156 |
result.info.src0LenBytes = 1; // reg[7:0] walker id |
| 157 |
break; |
| 158 |
case SAVE_BAR: |
| 159 |
decodeSimpleDescriptor(SendOp::SAVE_BARRIER); |
| 160 |
addDocs( |
| 161 |
DocRef::Kind::MSGOP, "GW_SAVE_BAR", "72068", |
| 162 |
DocRef::Kind::DESC, "GW_SAVE_RESTORE_BAR_DESC", "72067", |
| 163 |
DocRef::Kind::DST, "SAVE_RESTORE_BAR_PAYLOAD", "67043", |
| 164 |
DocRef::Kind::SRC0, "MDP_SAVE_BARRIER", "70584"); |
| 165 |
result.info.src0LenBytes = 12; // named barrier ID src0.2[7:0] |
| 166 |
result.info.dstLenBytes = BYTES_PER_REGISTER; |
| 167 |
break; |
| 168 |
case RESTORE_BAR: |
| 169 |
decodeSimpleDescriptor(SendOp::RESTORE_BARRIER); |
| 170 |
addDocs( |
| 171 |
DocRef::Kind::MSGOP, "GW_RESTORE_BAR", "72059", |
| 172 |
DocRef::Kind::DESC, "GW_SAVE_RESTORE_BAR_DESC", "72067", |
| 173 |
DocRef::Kind::SRC0, "SAVE_RESTORE_BAR_PAYLOAD", "67043"); |
| 174 |
result.info.src0LenBytes = BYTES_PER_REGISTER; |
| 175 |
break; |
| 176 |
case RESTORE_BTD_STACK: |
| 177 |
decodeSimpleDescriptor(SendOp::RESTORE_STACK); |
| 178 |
addDocs( |
| 179 |
DocRef::Kind::MSGOP, "RESTORE_BTD_STACK", "72108", |
| 180 |
DocRef::Kind::DESC, "GW_RESTORE_STACK_DESC", "72113", |
| 181 |
DocRef::Kind::SRC0, "STK_RSTR_PAYLOAD", "68749"); |
| 182 |
break; |
| 183 |
default: |
| 184 |
error(0, 6, "inavlid gateway op"); |
| 185 |
} // switch |
| 186 |
if (execSize != ExecSize::SIMD1 && execSize != ExecSize::INVALID) { |
| 187 |
error(0, 6, "exec size must be SIMD1"); |
| 188 |
} |
| 189 |
if (indDesc0 != REGREF_INVALID) { |
| 190 |
error(0, 6, "IND0 should not be set"); |
| 191 |
} |
| 192 |
if (indDesc1 != REGREF_INVALID) { |
| 193 |
error(0, 6, "IND1 should not be set"); |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
void MessageDecoderOtherE64::decodeRTA() { |
| 198 |
addDocs(DocRef::Kind::DESC, "TRACERAY_MSD_SIMPLIFIED", "72132", |
| 199 |
DocRef::Kind::DST, "RAYQUERY_WRBK", "70491", |
| 200 |
DocRef::Kind::SRC0, "TRACE_RAY_GRP_PAYLOAD", "73256", |
| 201 |
DocRef::Kind::IND0, "TraceRayIndDesc0", "73321", |
| 202 |
DocRef::Kind::IND1, "TraceRayIndDesc1", "74327"); |
| 203 |
enum { |
| 204 |
OP_TRACE_RAY_ASYNC = 0x0, |
| 205 |
OP_TRACE_RAY_SYNC = 0x1, |
| 206 |
OP_TRACE_BOX_SYNC = 0x2, |
| 207 |
OP_RAYQUERY_CHECK = 0x3, |
| 208 |
OP_RAYQUERY_RELEASE = 0x4 |
| 209 |
}; |
| 210 |
|
| 211 |
const auto famBits = getDescBits(4, 2); |
| 212 |
if (famBits != 0) { |
| 213 |
error(4, 2, "op family must be 0"); |
| 214 |
return; |
| 215 |
} |
| 216 |
addField("OpFamily", 4, 2, famBits, ""); |
| 217 |
|
| 218 |
const auto &sOpInfo = lookupSendOp(SendOp::TRACE_RAY); |
| 219 |
result.info.description = sOpInfo.description; |
| 220 |
result.info.symbol = sOpInfo.mnemonic; |
| 221 |
result.info.op = SendOp::TRACE_RAY; |
| 222 |
|
| 223 |
const auto opBits = getDescBits(0, 4); |
| 224 |
switch (opBits) { |
| 225 |
case OP_TRACE_RAY_ASYNC: result.info.symbol += ".async"; break; |
| 226 |
case OP_TRACE_RAY_SYNC: result.info.symbol += ".sync"; break; |
| 227 |
case OP_TRACE_BOX_SYNC: result.info.symbol += ".box_sync"; break; |
| 228 |
case OP_RAYQUERY_CHECK: result.info.symbol += ".ray_query_check"; break; |
| 229 |
case OP_RAYQUERY_RELEASE: result.info.symbol += ".ray_query_release"; break; |
| 230 |
default: result.info.symbol += ".???"; |
| 231 |
} |
| 232 |
addField("Opcode", 0, 4, opBits, result.info.description); |
| 233 |
addReserved(6, 6); |
| 234 |
decodeField("Spawn Type", 12, 2, [](uint32_t enc, std::stringstream &ss) { |
| 235 |
if (enc == 0) |
| 236 |
ss << "Ordinary Spawn"; |
| 237 |
else |
| 238 |
ss << "?"; |
| 239 |
}); |
| 240 |
addReserved(14, 46 - 14 + 1); |
| 241 |
|
| 242 |
bool isSimd32 = execSize == ExecSize::INVALID || execSize == ExecSize::SIMD32; |
| 243 |
result.info.dstLenBytes = BYTES_PER_REGISTER; |
| 244 |
result.info.src0LenBytes = (isSimd32 ? 3 : 2) * BYTES_PER_REGISTER; |
| 245 |
} |
| 246 |
|
| 247 |
void MessageDecoderOtherE64::decodeBTD() { |
| 248 |
addDocs(DocRef::Kind::MSGOP, "BTD_OPCODE", "72483", |
| 249 |
DocRef::Kind::DESC, "BTD_SPAWN_MSD_SIMPLE", "72133", |
| 250 |
DocRef::Kind::SRC0, "BTD_SPAWN_PAYLOAD", "73257", |
| 251 |
DocRef::Kind::IND0, "BTDInd0Desc", "73359", |
| 252 |
DocRef::Kind::IND1, "BTDInd1Desc", "72112"); |
| 253 |
enum { |
| 254 |
BTD_OPCODE_NORMAL = 0x1, |
| 255 |
BTD_OPCODE_OVERDISPATCH = 0x2, |
| 256 |
}; |
| 257 |
|
| 258 |
const auto opBits = getDescBits(0, 6); |
| 259 |
switch (opBits) { |
| 260 |
case BTD_OPCODE_NORMAL: |
| 261 |
case BTD_OPCODE_OVERDISPATCH: { |
| 262 |
const auto &sOpInfo = lookupSendOp(SendOp::SPAWN); |
| 263 |
result.info.description = sOpInfo.description; |
| 264 |
result.info.symbol = sOpInfo.mnemonic; |
| 265 |
result.info.op = SendOp::SPAWN; |
| 266 |
if (opBits == BTD_OPCODE_OVERDISPATCH) { |
| 267 |
result.info.description += " (with overdispatch)"; |
| 268 |
} |
| 269 |
break; |
| 270 |
} |
| 271 |
default: |
| 272 |
result.info.description = "?"; |
| 273 |
break; |
| 274 |
} |
| 275 |
addField("Opcode", 0, 6, opBits, result.info.description); |
| 276 |
addReserved(6, 8); |
| 277 |
addReserved(14, 46 - 14 + 1); |
| 278 |
|
| 279 |
bool isSimd32 = execSize == ExecSize::INVALID || execSize == ExecSize::SIMD32; |
| 280 |
result.info.dstLenBytes = 0; |
| 281 |
result.info.src0LenBytes = (isSimd32 ? 5 : 3) * BYTES_PER_REGISTER; |
| 282 |
} |
| 283 |
|
| 284 |
void MessageDecoderOtherE64::decodeRC() { |
| 285 |
enum { |
| 286 |
RT_READ = 0x2, |
| 287 |
RT_WRITE_DUAL = 0x5, |
| 288 |
RT_WRITE = 0x6, |
| 289 |
}; |
| 290 |
bool isSimd32 = execSize == ExecSize::INVALID || execSize == ExecSize::SIMD32; |
| 291 |
addDoc(DocRef::Kind::DESC, "DESCRIPTOR_RENDER_TARGET_MESSAGE", "71862"); |
| 292 |
|
| 293 |
const auto opBits = getDescBits(0, 6); |
| 294 |
switch (opBits) { |
| 295 |
case RT_READ: { |
| 296 |
const auto &sOpInfo = lookupSendOp(SendOp::RENDER_READ); |
| 297 |
result.info.op = sOpInfo.op; |
| 298 |
result.info.description = sOpInfo.description; |
| 299 |
result.info.symbol = sOpInfo.mnemonic; |
| 300 |
// result.info.dstLen = ??; |
| 301 |
break; |
| 302 |
} |
| 303 |
case RT_WRITE: |
| 304 |
case RT_WRITE_DUAL: { |
| 305 |
if (opBits == RT_WRITE) { |
| 306 |
if (isSimd32) { |
| 307 |
addDoc(DocRef::Kind::SRC0, "MDP_RTW_SIMD32", "65198"); |
| 308 |
} else { |
| 309 |
addDoc(DocRef::Kind::SRC0, "MDP_RTW", "63902"); |
| 310 |
} |
| 311 |
} else { |
| 312 |
addDoc(DocRef::Kind::SRC0, "MDP_RTW_DS", "63914"); |
| 313 |
|
| 314 |
} |
| 315 |
const auto &sOpInfo = lookupSendOp(SendOp::RENDER_WRITE); |
| 316 |
result.info.op = sOpInfo.op; |
| 317 |
result.info.description = sOpInfo.description; |
| 318 |
result.info.symbol = sOpInfo.mnemonic; |
| 319 |
if (opBits == 0x5) { |
| 320 |
result.info.description += " (dual source write)"; |
| 321 |
} |
| 322 |
result.info.dstLenBytes = 0; |
| 323 |
break; |
| 324 |
} |
| 325 |
default: |
| 326 |
result.info.description = "?"; |
| 327 |
break; |
| 328 |
} |
| 329 |
|
| 330 |
addField("Opcode", 0, 6, opBits, result.info.description); |
| 331 |
addReserved(6, 1); |
| 332 |
auto cm = decodeVectorSizeCmask("xyzw"); |
| 333 |
result.info.symbol += cm; |
| 334 |
result.info.description += " of " + cm; |
| 335 |
addReserved(11, 3); |
| 336 |
decodeField("Last Render Target Select", 14, 1, |
| 337 |
[&](uint32_t enc, std::stringstream &ss) { |
| 338 |
if (enc) { |
| 339 |
result.info.description += " with last render target select"; |
| 340 |
ss << "last render target select"; |
| 341 |
} |
| 342 |
}); |
| 343 |
addReserved(15, 6); |
| 344 |
decodeField("Null Render Target", 21, 1, |
| 345 |
[&](uint32_t enc, std::stringstream &ss) { |
| 346 |
if (enc) { |
| 347 |
result.info.description += " with null target"; |
| 348 |
ss << "null render target"; |
| 349 |
} |
| 350 |
}); |
| 351 |
addReserved(22, 33 - 22 + 1); |
| 352 |
static const char *HDR_REDUCTION_FIELDS[] = { |
| 353 |
"Output Mask to Render Target", "Source Depth Present", "Stencil Present", |
| 354 |
"Src0 Alpha Present"}; |
| 355 |
static const char *HDR_REDUCTION_FIELDS_SHORT[] = {"output mask", "depth", |
| 356 |
"stencil", "alpha"}; |
| 357 |
bool first = true; |
| 358 |
int extraCoords = 0; |
| 359 |
std::stringstream sso; |
| 360 |
for (int i = 0; |
| 361 |
i < sizeof(HDR_REDUCTION_FIELDS) / sizeof(HDR_REDUCTION_FIELDS[0]); |
| 362 |
i++) { |
| 363 |
extraCoords += decodeField<int>(HDR_REDUCTION_FIELDS[i], 34 + i, 1, |
| 364 |
[&](uint32_t enc, std::stringstream &ss) { |
| 365 |
if (enc) { |
| 366 |
if (first) { |
| 367 |
result.info.description += " with "; |
| 368 |
first = false; |
| 369 |
} else { |
| 370 |
result.info.description += ", "; |
| 371 |
} |
| 372 |
ss << HDR_REDUCTION_FIELDS_SHORT[i] |
| 373 |
<< " present in message"; |
| 374 |
result.info.description += |
| 375 |
HDR_REDUCTION_FIELDS_SHORT[i]; |
| 376 |
} |
| 377 |
return enc ? 1 : 0; |
| 378 |
}); |
| 379 |
} |
| 380 |
// (could be split between src0 and src1....) ick... (no idea how to solve) |
| 381 |
if (opBits == RT_READ) { |
| 382 |
int regsPerCoord = execSize == ExecSize::SIMD32 ? 2 : 1; |
| 383 |
// R?, G?, B?, A? |
| 384 |
result.info.dstLenBytes = BYTES_PER_REGISTER * regsPerCoord * |
| 385 |
(result.info.elemsPerAddr + extraCoords); |
| 386 |
result.info.src0LenBytes = BYTES_PER_REGISTER; |
| 387 |
} |
| 388 |
|
| 389 |
addReserved(38, 46 - 38 + 1); |
| 390 |
} |
| 391 |
|
| 392 |
void iga::DecodeMessageOtherE64(Platform p, SFID sfid, ExecSize execSize, |
| 393 |
int src0Len, int src1Len, uint64_t desc, |
| 394 |
RegRef id0, RegRef id1, DecodeResult &result) { |
| 395 |
MessageDecoderOtherE64 mduo(p, sfid, execSize, src0Len, src1Len, desc, |
| 396 |
id0, id1, result); |
| 397 |
|
| 398 |
if (sfid == SFID::GTWY) { |
| 399 |
mduo.decodeGTWY(); |
| 400 |
} else if (sfid == SFID::RTA) { |
| 401 |
mduo.decodeRTA(); |
| 402 |
} else if (sfid == SFID::RC) { |
| 403 |
mduo.decodeRC(); |
| 404 |
} else if (sfid == SFID::BTD) { |
| 405 |
mduo.decodeBTD(); |
| 406 |
} else { |
| 407 |
mduo.error(0, 0, "unsupported SFID"); |
| 408 |
} |
| 409 |
|
| 410 |
if (result.errors.empty()) { |
| 411 |
mduo.checkBytesLen("src0", result.info.src0LenBytes, src0Len); |
| 412 |
mduo.checkBytesLen("src1", result.info.src1LenBytes, src1Len); |
| 413 |
} |
| 414 |
} |