@@ -96,7 +96,7 @@ namespace {
96
96
FailureOr<std::string> getTargetDir (const std::string &npuVersion) {
97
97
if (npuVersion == " npu1" ) return std::string{" target_aie_ml" };
98
98
if (npuVersion == " npu4" ) return std::string{" target_aie2p" };
99
- llvm::errs () << " unsupported NPUVersion: " << npuVersion;
99
+ llvm::errs () << " unsupported NPUVersion: " << npuVersion << " \n " ;
100
100
return failure ();
101
101
}
102
102
@@ -152,7 +152,8 @@ FailureOr<Path> findVitis(std::optional<Path> &vitisDir,
152
152
return failure ();
153
153
}
154
154
if (!std::filesystem::exists (licenseFile)) {
155
- llvm::errs () << " ERROR: license file" << licenseFile << " does not exist" ;
155
+ llvm::errs () << " ERROR: license file" << licenseFile << " does not exist"
156
+ << " \n " ;
156
157
return failure ();
157
158
}
158
159
}
@@ -215,7 +216,7 @@ std::pair<std::string, std::vector<std::string>> makeChessArgs(
215
216
archVersion = " 21" ;
216
217
modelDir = " aie2p" ;
217
218
} else {
218
- llvm::errs () << " unsupported NPU version: " << npuVersion;
219
+ llvm::errs () << " unsupported NPU version: " << npuVersion << " \n " ;
219
220
llvm::report_fatal_error (" unsupported NPU version" );
220
221
}
221
222
@@ -475,7 +476,7 @@ static FailureOr<Path> assembleStringUsing(
475
476
if (auto maybeErr = dumpStrToDisk (inputFileStr, inputFile.string ());
476
477
maybeErr.has_value ()) {
477
478
llvm::errs () << " Failed to dump to disk " << inputFile.string ()
478
- << " because: " << maybeErr;
479
+ << " because: " << maybeErr << " \n " ;
479
480
return failure ();
480
481
}
481
482
@@ -487,7 +488,8 @@ static FailureOr<Path> assembleStringUsing(
487
488
}
488
489
if (failed (assembler (inputFile.string (), outputFile.string (), extraArgs,
489
490
workDir, toolDir, npuVersion, verbose))) {
490
- llvm::errs () << " Failed to assemble " << outputFileName << " .o" ;
491
+ llvm::errs () << " Failed to assemble " << outputFileName << " .o"
492
+ << " \n " ;
491
493
return failure ();
492
494
}
493
495
return outputFile;
@@ -532,22 +534,31 @@ static LogicalResult generateCoreElfFiles(
532
534
Path cwd = std::filesystem::current_path ();
533
535
FailureOr<Path> mmObjectFilePath;
534
536
if (ukernel && (ukernel == " mm" || ukernel == " all" )) {
535
- FailureOr<Path> maybeVitisDir = findVitis (vitisDir, npuVersion);
536
- if (failed (maybeVitisDir)) {
537
- llvm::errs () << " compiling ukernels currently requires chess (even if "
538
- " you're using peano)" ;
539
- return failure ();
540
- }
541
537
if (!std::filesystem::exists (cwd / " mm.o" )) {
542
- mmObjectFilePath = assembleStringUsingChess (
543
- /* inputFileStr=*/ _MM_CC,
544
- /* inputFileName=*/ " mm.cc" ,
545
- /* outputFileName=*/ " mm.o" ,
546
- /* outputDir=*/ cwd,
547
- /* extraArgs*/ std::vector<std::string>{},
548
- /* workDir=*/ tempDir,
549
- /* vitisDir=*/ *maybeVitisDir,
550
- /* npuVersion*/ npuVersion, verbose);
538
+ if (useChess) {
539
+ if (verbose) llvm::outs () << " using chess for ukernel codegen\n " ;
540
+ FailureOr<Path> maybeVitisDir = findVitis (vitisDir, npuVersion);
541
+ mmObjectFilePath = assembleStringUsingChess (
542
+ /* inputFileStr=*/ _MM_CC,
543
+ /* inputFileName=*/ " mm.cc" ,
544
+ /* outputFileName=*/ " mm.o" ,
545
+ /* outputDir=*/ cwd,
546
+ /* extraArgs*/ std::vector<std::string>{},
547
+ /* workDir=*/ tempDir,
548
+ /* vitisDir=*/ *maybeVitisDir,
549
+ /* npuVersion*/ npuVersion, verbose);
550
+ } else {
551
+ if (verbose) llvm::outs () << " using peano for ukernel codegen\n " ;
552
+ mmObjectFilePath = assembleStringUsingPeano (
553
+ /* inputFileStr=*/ _MM_CC,
554
+ /* inputFileName=*/ " mm.cc" ,
555
+ /* outputFileName=*/ " mm.o" ,
556
+ /* outputDir=*/ cwd,
557
+ /* extraArgs*/ std::vector<std::string>{},
558
+ /* workDir=*/ tempDir,
559
+ /* peanoDir=*/ peanoDir,
560
+ /* npuVersion*/ npuVersion, verbose);
561
+ }
551
562
if (failed (mmObjectFilePath)) return failure ();
552
563
} else {
553
564
mmObjectFilePath = cwd / " mm.o" ;
@@ -579,13 +590,14 @@ static LogicalResult generateCoreElfFiles(
579
590
{
580
591
auto bcfOutput = openOutputFile (bcfPath.string (), &errorMessage);
581
592
if (!bcfOutput) {
582
- llvm::errs () << " failed to open bcf file because: " << errorMessage;
593
+ llvm::errs () << " failed to open bcf file because: " << errorMessage
594
+ << " \n " ;
583
595
return failure ();
584
596
}
585
597
586
598
if (failed (mlir::iree_compiler::AMDAIE::AIETranslateToBCF (
587
599
deviceOp, bcfOutput->os (), col, row))) {
588
- llvm::errs () << " Failed to generate BCF" ;
600
+ llvm::errs () << " Failed to generate BCF\n " ;
589
601
return failure ();
590
602
}
591
603
bcfOutput->keep ();
@@ -614,7 +626,7 @@ static LogicalResult generateCoreElfFiles(
614
626
openOutputFile (ldscriptPath.string (), &errorMessage);
615
627
if (!ldscriptOutput) {
616
628
llvm::errs () << " Failed to open ldscript file because: "
617
- << errorMessage;
629
+ << errorMessage << " \n " ;
618
630
return failure ();
619
631
}
620
632
if (failed (mlir::iree_compiler::AMDAIE::AIETranslateToLdScript (
@@ -654,7 +666,7 @@ static LogicalResult generateCDO(MLIRContext *context, AIE::DeviceOp deviceOp,
654
666
deviceOp = *copy.getOps <AIE::DeviceOp>().begin ();
655
667
if (failed (mlir::iree_compiler::AMDAIE::AIETranslateToCDODirect (
656
668
deviceOp, tempDir.string ()))) {
657
- llvm::errs () << " failed to emit CDO" ;
669
+ llvm::errs () << " failed to emit CDO\n " ;
658
670
return failure ();
659
671
}
660
672
copy->erase ();
@@ -750,7 +762,7 @@ static LogicalResult generateXCLBin(
750
762
dumpStrToDisk (memTopologyData, memTopologyJsonFile.string ());
751
763
maybeErr.has_value ()) {
752
764
llvm::errs () << " failed to dump to disk mem_topology.json because: "
753
- << *maybeErr;
765
+ << *maybeErr << " \n " ;
754
766
return failure ();
755
767
}
756
768
}
@@ -797,7 +809,7 @@ static LogicalResult generateXCLBin(
797
809
dumpStrToDisk (aiePartitionJsonData, aiePartitionJsonFile.string ());
798
810
maybeErr.has_value ()) {
799
811
llvm::errs () << " failed to dump to disk aie_partition.json because: "
800
- << *maybeErr;
812
+ << *maybeErr << " \n " ;
801
813
return failure ();
802
814
}
803
815
}
@@ -816,7 +828,7 @@ static LogicalResult generateXCLBin(
816
828
if (auto maybeErr = dumpStrToDisk (kernelStr, kernelsJsonFile.string ());
817
829
maybeErr.has_value ()) {
818
830
llvm::errs () << " failed to dump to disk kernels.json because: "
819
- << *maybeErr;
831
+ << *maybeErr << " \n " ;
820
832
return failure ();
821
833
}
822
834
}
@@ -825,7 +837,8 @@ static LogicalResult generateXCLBin(
825
837
{
826
838
auto designBifOut = openOutputFile (designBifFile.string (), &errorMessage);
827
839
if (!designBifOut) {
828
- llvm::errs () << " failed to open design.bif because: " << errorMessage;
840
+ llvm::errs () << " failed to open design.bif because: " << errorMessage
841
+ << " \n " ;
829
842
return failure ();
830
843
}
831
844
@@ -868,7 +881,7 @@ static LogicalResult generateXCLBin(
868
881
}
869
882
if (iree_aie_bootgen_main (cstrings.size (),
870
883
const_cast <const char **>(&cstrings[0 ]))) {
871
- llvm::errs () << " failed to execute bootgen" ;
884
+ llvm::errs () << " failed to execute bootgen\n " ;
872
885
return failure ();
873
886
}
874
887
}
@@ -892,14 +905,14 @@ static LogicalResult generateXCLBin(
892
905
" --force" , " --input" , *inputXclbin};
893
906
894
907
if (failed (runTool (xclbinutilBin.value ().string (), inputFlags, verbose))) {
895
- llvm::errs () << " failed to execute xclbinutil" ;
908
+ llvm::errs () << " failed to execute xclbinutil\n " ;
896
909
return failure ();
897
910
}
898
911
auto aieInputPartitionOut =
899
912
openInputFile (aieInputPartitionJsonFile.string (), &errorMessage);
900
913
if (!aieInputPartitionOut) {
901
914
llvm::errs () << " failed to open aie_input_partition.json because: "
902
- << errorMessage;
915
+ << errorMessage << " \n " ;
903
916
return failure ();
904
917
}
905
918
Expected<json::Value> aieInputPartitionOutValue =
@@ -913,7 +926,7 @@ static LogicalResult generateXCLBin(
913
926
if (!aiePartitionOut) {
914
927
llvm::errs () << " failed to open aie aie_input_partition.json for "
915
928
" output because: "
916
- << errorMessage;
929
+ << errorMessage << " \n " ;
917
930
return failure ();
918
931
}
919
932
llvm::Expected<llvm::json::Value> aiePartitionOutValue =
@@ -931,7 +944,7 @@ static LogicalResult generateXCLBin(
931
944
maybeErr.has_value ()) {
932
945
llvm::errs ()
933
946
<< " failed to dump to disk aie_input_partition.json because: "
934
- << errorMessage;
947
+ << errorMessage << " \n " ;
935
948
return failure ();
936
949
}
937
950
flags.insert (flags.end (), {" --input" , *inputXclbin});
@@ -1040,14 +1053,14 @@ static LogicalResult generateUnifiedObject(
1040
1053
}
1041
1054
1042
1055
if (failed (pm.run (moduleOpCopy))) {
1043
- llvm::errs () << " Failed to lower to LLVM" ;
1056
+ llvm::errs () << " Failed to lower to LLVM\n " ;
1044
1057
return failure ();
1045
1058
}
1046
1059
1047
1060
llvm::LLVMContext llvmContext;
1048
1061
auto llvmModule = translateModuleToLLVMIR (moduleOpCopy, llvmContext);
1049
1062
if (!llvmModule) {
1050
- llvm::errs () << " Failed to translate module to LLVMIR" ;
1063
+ llvm::errs () << " Failed to translate module to LLVMIR\n " ;
1051
1064
return failure ();
1052
1065
}
1053
1066
@@ -1081,7 +1094,7 @@ static LogicalResult generateUnifiedObject(
1081
1094
if (auto maybeErr = dumpStrToDisk (inputLLStr, LLVMIRFile.string ());
1082
1095
maybeErr.has_value ()) {
1083
1096
llvm::errs () << " Failed to dump to disk input.ll"
1084
- << " because: " << maybeErr;
1097
+ << " because: " << maybeErr << " \n " ;
1085
1098
return failure ();
1086
1099
}
1087
1100
Path peanoOptBin = peanoDir / " bin" / " opt" ;
@@ -1096,7 +1109,7 @@ static LogicalResult generateUnifiedObject(
1096
1109
args.reserve (args.size () + peanoArgs.size ());
1097
1110
args.insert (args.end (), peanoArgs.begin (), peanoArgs.end ());
1098
1111
if (failed (runTool (peanoOptBin.string (), args, verbose))) {
1099
- llvm::errs () << " Failed to optimize ll with peano" ;
1112
+ llvm::errs () << " Failed to optimize ll with peano\n " ;
1100
1113
return failure ();
1101
1114
}
1102
1115
0 commit comments