Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 4fa3bbb

Browse files
Fix MappingOptionsPrinter
This PR addresses #294 by making the base mapping printer not print a newline This is safe only if one cannot print the base class so this changeset also: 1. drops the operator<< functions that operate on the base class; 2. adds a pure virtual destructor to the base class; 3. implements CudaMappingOptionsCppPrinter in terms of the parent print function We now correctly see entries such as: ``` [TUNER][GENERATION LOG] best option so far: tc::MappingOptions::makeNaiveMappingOptions() .outerScheduleFusionStrategy(tc::FusionStrategy::Max) .outerScheduleAllowSkewing(false) .outerSchedulePositiveOrthant(true) .intraTileScheduleFusionStrategy(tc::FusionStrategy::Min) .intraTileScheduleAllowSkewing(false) .intraTileSchedulePositiveOrthant(true) .tile(256, 13) .unroll(64) .tileImperfectlyNested(false) .matchLibraryCalls(true) .mapToThreads(25, 7) .mapToBlocks(128) .useSharedMemory(true) .usePrivateMemory(true) .unrollCopyShared(true); ```
1 parent 3e097e0 commit 4fa3bbb

File tree

5 files changed

+16
-48
lines changed

5 files changed

+16
-48
lines changed

tc/core/cuda/cuda_mapping_options_cpp_printer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ namespace tc {
2222
CudaMappingOptionsCppPrinter& operator<<(
2323
CudaMappingOptionsCppPrinter& prn,
2424
const CudaMappingOptions& cudaOptions) {
25-
std::stringstream ss;
26-
ss << cudaOptions.generic;
27-
prn.printString(ss.str());
25+
prn.print(cudaOptions.generic);
2826
prn.printListOption("mapToThreads", cudaOptions.block.extractVector());
2927
prn.printListOption("mapToBlocks", cudaOptions.grid.extractVector());
3028
prn.printBooleanOption(

tc/core/cuda/cuda_mapping_options_cpp_printer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class CudaMappingOptionsCppPrinter : public MappingOptionsCppPrinter {
3838
CudaMappingOptionsCppPrinter(std::ostream& out, size_t ws = 0)
3939
: MappingOptionsCppPrinter(out, ws) {}
4040

41+
~CudaMappingOptionsCppPrinter() = default;
42+
4143
friend CudaMappingOptionsCppPrinter& operator<<(
4244
CudaMappingOptionsCppPrinter& prn,
4345
const CudaMappingOptions& options);

tc/core/mapping_options.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ std::ostream& operator<<(
6060
return os;
6161
}
6262

63-
std::ostream& operator<<(std::ostream& os, const MappingOptions& options) {
64-
OstreamBoolalphaScope scope(os);
65-
tc::MappingOptionsAsCpp cpp(options);
66-
os << cpp;
67-
return os;
68-
}
69-
70-
std::ostream& operator<<(std::ostream& os, const MappingOptionsView& view) {
71-
os << MappingOptions(view);
72-
return os;
73-
}
74-
7563
MappingOptionsView& MappingOptionsView::tile(
7664
const std::string& commaSeparatedSizes) {
7765
return tile(parseCommaSeparatedIntegers<uint64_t>(commaSeparatedSizes));

tc/core/mapping_options_cpp_printer.cc

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
namespace tc {
2121

22+
MappingOptionsCppPrinter::~MappingOptionsCppPrinter() = default;
23+
2224
MappingOptionsCppPrinter& MappingOptionsCppPrinter::printSchedulerOptions(
2325
const SchedulerOptionsView& schedulerOptions,
2426
const std::string& prefix) {
@@ -28,38 +30,28 @@ MappingOptionsCppPrinter& MappingOptionsCppPrinter::printSchedulerOptions(
2830
"tc::FusionStrategy::" + FusionStrategy_Name(proto.fusion_strategy()));
2931
printBooleanOption(prefix + "AllowSkewing", proto.allow_skewing());
3032
printBooleanOption(prefix + "PositiveOrthant", proto.positive_orthant());
31-
3233
return *this;
3334
}
3435

35-
MappingOptionsCppPrinter& operator<<(
36-
MappingOptionsCppPrinter& prn,
37-
const std::string& str) {
38-
prn.printString(str);
39-
return prn;
40-
}
41-
42-
MappingOptionsCppPrinter& operator<<(
43-
MappingOptionsCppPrinter& prn,
36+
MappingOptionsCppPrinter& MappingOptionsCppPrinter::print(
4437
const MappingOptions& options) {
45-
prn.printString("tc::MappingOptions::makeNaiveMappingOptions()")
38+
printString("tc::MappingOptions::makeNaiveMappingOptions()")
4639
.printSchedulerOptions(
4740
options.view.outerScheduleOptions, "outerSchedule");
4841
if (options.view.proto.has_intra_tile_schedule_options()) {
49-
prn.printSchedulerOptions(
42+
printSchedulerOptions(
5043
options.view.intraTileScheduleOptions, "intraTileSchedule");
5144
}
5245
if (options.view.proto.has_tiling()) {
53-
prn.printListOption("tile", options.view.tiling.extractVector());
46+
printListOption("tile", options.view.tiling.extractVector());
5447
}
5548
if (options.view.proto.has_unroll()) {
56-
prn.printValueOption("unroll", options.view.proto.unroll());
49+
printValueOption("unroll", options.view.proto.unroll());
5750
}
58-
prn.printBooleanOption(
51+
printBooleanOption(
5952
"tileImperfectlyNested", options.view.proto.tile_imperfectly_nested());
60-
prn.printBooleanOption(
53+
printBooleanOption(
6154
"matchLibraryCalls", options.view.proto.match_library_calls());
62-
prn.endStmt();
63-
return prn;
55+
return *this;
6456
}
6557
} // namespace tc

tc/core/mapping_options_cpp_printer.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ class MappingOptionsCppPrinter {
3737
MappingOptionsCppPrinter(std::ostream& out, size_t ws = 0)
3838
: out_(out), ws_(ws) {}
3939

40-
friend MappingOptionsCppPrinter& operator<<(
41-
MappingOptionsCppPrinter& prn,
42-
const std::string& str);
43-
44-
friend MappingOptionsCppPrinter& operator<<(
45-
MappingOptionsCppPrinter& prn,
46-
const MappingOptions& options);
40+
virtual ~MappingOptionsCppPrinter() = 0;
4741

4842
protected:
4943
inline MappingOptionsCppPrinter& tab();
@@ -71,19 +65,13 @@ class MappingOptionsCppPrinter {
7165
const SchedulerOptionsView& schedulerOptions,
7266
const std::string& prefix);
7367

68+
MappingOptionsCppPrinter& print(const MappingOptions& options);
69+
7470
std::ostream& out_;
7571
size_t ws_;
7672
bool lineContinuation_ = false;
7773
};
7874

79-
inline std::ostream& operator<<(
80-
std::ostream& out,
81-
const MappingOptionsAsCpp& mo) {
82-
auto prn = MappingOptionsCppPrinter(out, mo.indent);
83-
prn << mo.options;
84-
return out;
85-
}
86-
8775
MappingOptionsCppPrinter& MappingOptionsCppPrinter::tab() {
8876
for (size_t i = 0; i < ws_; ++i) {
8977
out_ << " ";

0 commit comments

Comments
 (0)