Commit 52db7e2
authored
[mlir][nvgpu] Improve
`WarpgroupAccumulator` (or `!nvgpu.warpgroup.accumulator`) is a type
that keeps the accumulator matrix that is used by warp-group level
matrix multiplication. It is handy to have a special type for that as
the matrix is distributed among the threads of the warp-group. However,
current transformations requires to create and use multiple
`WarpgroupAccumulator` if the shape of GEMM is larger than the supported
shape of `wgmma.mma_async` instruction. This makes IR looks dense.
This PR improves the transformation of `WarpgroupAccumulator` type in
every nvgpu Op that uses it.
**Example: Current GEMM in NVGPU-IR**
```
// Init
%m1, %m2 = nvgpu.warpgroup.mma.init.accumulator ->
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>
// GEMM
%r1, %r2 = nvgpu.warpgroup.mma %descA, %descB, %m1, %m2 {transposeB}:
!nvgpu.warpgroup.descriptor<tensor = memref<128x64xf16, 3>>,
!nvgpu.warpgroup.descriptor<tensor = memref<64x128xf16, 3>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>
->
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>
// Epilogue
nvgpu.warpgroup.mma.store [%r1, %r2] to %sharedMemoryBuffer
: !nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>
into memref<128x128xf32,3>
```
**Example: This PR simplifies the IR as below:**
```
// Init
%m = nvgpu.warpgroup.mma.init.accumulator ->
!nvgpu.warpgroup.accumulator<fragmented = vector<128x128xf32>>
// GEMM
%r1 = nvgpu.warpgroup.mma %descA, %descB, %m1 {transposeB}:
!nvgpu.warpgroup.descriptor<tensor = memref<128x64xf16, 3>>,
!nvgpu.warpgroup.descriptor<tensor = memref<64x128xf16, 3>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<128x128xf32>>
->
!nvgpu.warpgroup.accumulator<fragmented = vector<128x128xf32>>
// Epilogue
nvgpu.warpgroup.mma.store [%matrixD1, %matrixD2] to %sharedMemoryBuffer
: !nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>,
!nvgpu.warpgroup.accumulator<fragmented = vector<64x128xf32>>
into memref<128x128xf32,3>
```WarpgroupAccumulator type to simplify IR (llvm#68728)1 parent 838f289 commit 52db7e2
File tree
7 files changed
+177
-158
lines changed- mlir
- include/mlir/Dialect/NVGPU/IR
- lib
- Conversion/NVGPUToNVVM
- Dialect/NVGPU
- IR
- TransformOps
- test
- Conversion/NVGPUToNVVM
- Dialect/NVGPU
7 files changed
+177
-158
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | | - | |
723 | | - | |
| 722 | + | |
| 723 | + | |
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | | - | |
| 742 | + | |
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
| 746 | + | |
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
758 | | - | |
| 758 | + | |
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
416 | 433 | | |
417 | | - | |
418 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
419 | 437 | | |
420 | 438 | | |
421 | 439 | | |
| |||
1186 | 1204 | | |
1187 | 1205 | | |
1188 | 1206 | | |
1189 | | - | |
1190 | 1207 | | |
1191 | 1208 | | |
1192 | 1209 | | |
| |||
1330 | 1347 | | |
1331 | 1348 | | |
1332 | 1349 | | |
1333 | | - | |
| 1350 | + | |
1334 | 1351 | | |
1335 | 1352 | | |
1336 | 1353 | | |
| |||
1359 | 1376 | | |
1360 | 1377 | | |
1361 | 1378 | | |
1362 | | - | |
1363 | | - | |
1364 | 1379 | | |
1365 | | - | |
| 1380 | + | |
1366 | 1381 | | |
1367 | 1382 | | |
1368 | 1383 | | |
1369 | 1384 | | |
1370 | | - | |
1371 | | - | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
1372 | 1388 | | |
1373 | 1389 | | |
| 1390 | + | |
1374 | 1391 | | |
1375 | | - | |
1376 | | - | |
| 1392 | + | |
1377 | 1393 | | |
1378 | 1394 | | |
1379 | | - | |
| 1395 | + | |
1380 | 1396 | | |
1381 | 1397 | | |
1382 | | - | |
1383 | | - | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
1384 | 1403 | | |
1385 | 1404 | | |
1386 | 1405 | | |
1387 | 1406 | | |
1388 | | - | |
1389 | | - | |
| 1407 | + | |
| 1408 | + | |
1390 | 1409 | | |
1391 | 1410 | | |
1392 | 1411 | | |
| |||
1411 | 1430 | | |
1412 | 1431 | | |
1413 | 1432 | | |
1414 | | - | |
| 1433 | + | |
1415 | 1434 | | |
1416 | | - | |
| 1435 | + | |
1417 | 1436 | | |
1418 | 1437 | | |
1419 | | - | |
| 1438 | + | |
1420 | 1439 | | |
1421 | 1440 | | |
1422 | | - | |
1423 | 1441 | | |
1424 | 1442 | | |
1425 | 1443 | | |
1426 | 1444 | | |
| 1445 | + | |
1427 | 1446 | | |
1428 | | - | |
| 1447 | + | |
1429 | 1448 | | |
1430 | 1449 | | |
1431 | | - | |
| 1450 | + | |
1432 | 1451 | | |
1433 | 1452 | | |
1434 | | - | |
| 1453 | + | |
1435 | 1454 | | |
1436 | 1455 | | |
1437 | 1456 | | |
| |||
1535 | 1554 | | |
1536 | 1555 | | |
1537 | 1556 | | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
1542 | 1564 | | |
1543 | 1565 | | |
1544 | 1566 | | |
| |||
1554 | 1576 | | |
1555 | 1577 | | |
1556 | 1578 | | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
1570 | 1597 | | |
1571 | | - | |
1572 | 1598 | | |
1573 | | - | |
| 1599 | + | |
1574 | 1600 | | |
1575 | 1601 | | |
1576 | 1602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
439 | 443 | | |
440 | 444 | | |
441 | 445 | | |
| |||
458 | 462 | | |
459 | 463 | | |
460 | 464 | | |
461 | | - | |
462 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
463 | 468 | | |
464 | 469 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
490 | 475 | | |
491 | 476 | | |
492 | 477 | | |
| |||
498 | 483 | | |
499 | 484 | | |
500 | 485 | | |
501 | | - | |
| 486 | + | |
502 | 487 | | |
503 | 488 | | |
504 | 489 | | |
| |||
534 | 519 | | |
535 | 520 | | |
536 | 521 | | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
555 | 528 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
560 | 532 | | |
561 | 533 | | |
562 | 534 | | |
| |||
570 | 542 | | |
571 | 543 | | |
572 | 544 | | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
586 | 557 | | |
587 | 558 | | |
588 | 559 | | |
| |||
0 commit comments