diff --git a/gematria/basic_block/basic_block.cc b/gematria/basic_block/basic_block.cc index 161dd067..2f818d3c 100644 --- a/gematria/basic_block/basic_block.cc +++ b/gematria/basic_block/basic_block.cc @@ -229,21 +229,21 @@ std::ostream& operator<<(std::ostream& os, const InstructionOperand& operand) { return os; } -RuntimeAnnotation::RuntimeAnnotation(std::string pmu_event, double value) - : pmu_event(std::move(pmu_event)), value(value) {} +Annotation::Annotation(const std::string &name, double value) + : name(std::move(name)), value(value) {} -bool RuntimeAnnotation::operator==(const RuntimeAnnotation& other) const { - const auto as_tuple = [](const RuntimeAnnotation& annotation) { - return std::tie(annotation.pmu_event, annotation.value); +bool Annotation::operator==(const Annotation& other) const { + const auto as_tuple = [](const Annotation& annotation) { + return std::tie(annotation.name, annotation.value); }; return as_tuple(*this) == as_tuple(other); } -std::string RuntimeAnnotation::ToString() const { +std::string Annotation::ToString() const { std::stringstream buffer; - buffer << "RuntimeAnnotation("; - if (!pmu_event.empty()) { - buffer << "pmu_event='" << pmu_event << "', "; + buffer << "Annotation("; + if (!name.empty()) { + buffer << "name='" << name << "', "; } if (value != -1) { buffer << "value=" << value << ", "; @@ -258,7 +258,7 @@ std::string RuntimeAnnotation::ToString() const { } std::ostream& operator<<(std::ostream& os, - const RuntimeAnnotation& annotation) { + const Annotation& annotation) { os << annotation.ToString(); return os; } @@ -270,7 +270,7 @@ Instruction::Instruction( std::vector implicit_input_operands, std::vector output_operands, std::vector implicit_output_operands, - RuntimeAnnotation cache_miss_frequency) + std::vector instruction_annotations) : mnemonic(std::move(mnemonic)), llvm_mnemonic(std::move(llvm_mnemonic)), prefixes(std::move(prefixes)), @@ -278,7 +278,7 @@ Instruction::Instruction( implicit_input_operands(std::move(implicit_input_operands)), output_operands(std::move(output_operands)), implicit_output_operands(std::move(implicit_output_operands)), - cache_miss_frequency(std::move(cache_miss_frequency)) {} + instruction_annotations(std::move(instruction_annotations)) {} bool Instruction::operator==(const Instruction& other) const { const auto as_tuple = [](const Instruction& instruction) { @@ -286,7 +286,7 @@ bool Instruction::operator==(const Instruction& other) const { instruction.mnemonic, instruction.llvm_mnemonic, instruction.prefixes, instruction.input_operands, instruction.implicit_input_operands, instruction.output_operands, instruction.implicit_output_operands, - instruction.cache_miss_frequency); + instruction.instruction_annotations); }; return as_tuple(*this) == as_tuple(other); } @@ -329,7 +329,7 @@ std::string Instruction::ToString() const { add_operand_list("output_operands", output_operands); add_operand_list("implicit_output_operands", implicit_output_operands); - // TODO(virajbshah): Include cache_miss_frequency at the end of the string. + // TODO(virajbshah): Include instruction annotations at the end of the string. auto msg = buffer.str(); assert(msg.size() >= 2); diff --git a/gematria/basic_block/basic_block.h b/gematria/basic_block/basic_block.h index 26ce3a1b..2413d985 100644 --- a/gematria/basic_block/basic_block.h +++ b/gematria/basic_block/basic_block.h @@ -218,27 +218,28 @@ class InstructionOperand { std::ostream& operator<<(std::ostream& os, const InstructionOperand& operand); -// Represents a runtime-related measure/statistic paired with the instruction. -struct RuntimeAnnotation { - RuntimeAnnotation() : value(-1){}; +// Represents an annotation holding a value such as some measure/statistic +// paired with the instruction. +struct Annotation { + Annotation() : value(-1){}; // Initializes all fields of the annotation. - RuntimeAnnotation(std::string pmu_event, double value); + Annotation(const std::string &name, double value); - RuntimeAnnotation(const RuntimeAnnotation&) = default; - RuntimeAnnotation(RuntimeAnnotation&&) = default; + Annotation(const Annotation&) = default; + Annotation(Annotation&&) = default; - RuntimeAnnotation& operator=(const RuntimeAnnotation&) = default; - RuntimeAnnotation& operator=(RuntimeAnnotation&&) = default; + Annotation& operator=(const Annotation&) = default; + Annotation& operator=(Annotation&&) = default; - bool operator==(const RuntimeAnnotation& other) const; - bool operator!=(const RuntimeAnnotation& other) const { + bool operator==(const Annotation& other) const; + bool operator!=(const Annotation& other) const { return !(*this == other); } std::string ToString() const; - std::string pmu_event; + std::string name; double value; }; @@ -254,7 +255,8 @@ struct Instruction { std::vector implicit_input_operands, std::vector output_operands, std::vector implicit_output_operands, - RuntimeAnnotation cache_miss_frequency = RuntimeAnnotation()); + std::vector instruction_annotations = + std::vector{Annotation()}); Instruction(const Instruction&) = default; Instruction(Instruction&&) = default; @@ -305,9 +307,10 @@ struct Instruction { // to the ML models explicitly. std::vector implicit_output_operands; - // The cache miss frequency of the instruction. Used to better model the - // overhead coming from LLC misses. - RuntimeAnnotation cache_miss_frequency; + // The list of instruction level annotations used to supply additional + // information to the model. Currently includes the cache miss frequency of + // the instruction. Used to better model the overhead coming from LLC misses. + std::vector instruction_annotations; // The address of the instruction. uint64_t address = 0; diff --git a/gematria/basic_block/basic_block_protos.cc b/gematria/basic_block/basic_block_protos.cc index 384a208e..e9853b7e 100644 --- a/gematria/basic_block/basic_block_protos.cc +++ b/gematria/basic_block/basic_block_protos.cc @@ -21,6 +21,7 @@ #include "gematria/basic_block/basic_block.h" #include "gematria/proto/canonicalized_instruction.pb.h" +#include "gematria/proto/annotation.pb.h" #include "google/protobuf/repeated_ptr_field.h" namespace gematria { @@ -112,20 +113,35 @@ void ToRepeatedPtrField( ProtoFromInstructionOperand); } +std::vector ToVector( + const google::protobuf::RepeatedPtrField& protos) { + std::vector result(protos.size()); + std::transform(protos.begin(), protos.end(), result.begin(), + AnnotationFromProto); + return result; +} + +void ToRepeatedPtrField( + const std::vector& annotations, + google::protobuf::RepeatedPtrField* repeated_field) { + repeated_field->Reserve(annotations.size()); + std::transform(annotations.begin(), annotations.end(), + google::protobuf::RepeatedFieldBackInserter(repeated_field), + ProtoFromAnnotation); +} + } // namespace -RuntimeAnnotation RuntimeAnnotationFromProto( - const CanonicalizedInstructionProto::RuntimeAnnotation& proto) { - return RuntimeAnnotation( - /* pmu_event = */ proto.pmu_event(), +Annotation AnnotationFromProto(const AnnotationProto& proto) { + return Annotation( + /* name = */ proto.name(), /* value = */ proto.value()); } -CanonicalizedInstructionProto::RuntimeAnnotation ProtoFromRuntimeAnnotation( - const RuntimeAnnotation& runtime_annotation) { - CanonicalizedInstructionProto::RuntimeAnnotation proto; - proto.set_pmu_event(runtime_annotation.pmu_event); - proto.set_value(runtime_annotation.value); +AnnotationProto ProtoFromAnnotation(const Annotation& annotation) { + AnnotationProto proto; + proto.set_name(annotation.name); + proto.set_value(annotation.value); return proto; } @@ -141,8 +157,8 @@ Instruction InstructionFromProto(const CanonicalizedInstructionProto& proto) { /* output_operands = */ ToVector(proto.output_operands()), /* implicit_output_operands = */ ToVector(proto.implicit_output_operands()), - /* cache_miss_frequency = */ - RuntimeAnnotationFromProto(proto.cache_miss_frequency())); + /* instruction_annotations = */ + ToVector(proto.instruction_annotations())); } CanonicalizedInstructionProto ProtoFromInstruction( @@ -160,6 +176,8 @@ CanonicalizedInstructionProto ProtoFromInstruction( proto.mutable_output_operands()); ToRepeatedPtrField(instruction.implicit_output_operands, proto.mutable_implicit_output_operands()); + ToRepeatedPtrField(instruction.instruction_annotations, + proto.mutable_instruction_annotations()); return proto; } diff --git a/gematria/basic_block/basic_block_protos.h b/gematria/basic_block/basic_block_protos.h index a662f9a3..6b8be4db 100644 --- a/gematria/basic_block/basic_block_protos.h +++ b/gematria/basic_block/basic_block_protos.h @@ -41,13 +41,11 @@ InstructionOperand InstructionOperandFromProto( CanonicalizedOperandProto ProtoFromInstructionOperand( const InstructionOperand& operand); -// Creates a runtime annotation data structure from a proto. -RuntimeAnnotation RuntimeAnnotationFromProto( - const CanonicalizedInstructionProto::RuntimeAnnotation& proto); +// Creates a annotation data structure from a proto. +Annotation AnnotationFromProto(const AnnotationProto& proto); -// Creates a proto representing the given runtime annotation. -CanonicalizedInstructionProto::RuntimeAnnotation ProtoFromRuntimeAnnotation( - const RuntimeAnnotation& runtime_annotation); +// Creates a proto representing the given annotation. +AnnotationProto ProtoFromAnnotation(const Annotation& annotation); // Creates an instruction data structure from a proto. Instruction InstructionFromProto(const CanonicalizedInstructionProto& proto); diff --git a/gematria/basic_block/basic_block_test.cc b/gematria/basic_block/basic_block_test.cc index bee6c2f1..49121965 100644 --- a/gematria/basic_block/basic_block_test.cc +++ b/gematria/basic_block/basic_block_test.cc @@ -318,7 +318,7 @@ TEST(InstructionOperandTest, AsTokenList) { } } -// TODO(virajbshah): Add tests for RuntimeAnnotation. +// TODO(virajbshah): Add tests for Annotation. TEST(InstructionTest, Constructor) { constexpr char kMnemonic[] = "MOV"; @@ -332,7 +332,8 @@ TEST(InstructionTest, Constructor) { InstructionOperand::MemoryLocation(3)}; const std::vector kImplicitOutputOperands = { InstructionOperand::Register("EFLAGS")}; - const RuntimeAnnotation kCacheMissFrequency("r20d1", 0.875); + const std::vector kInstructionAnnotations = { + Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)}; const Instruction instruction( /* mnemonic = */ kMnemonic, @@ -342,7 +343,7 @@ TEST(InstructionTest, Constructor) { /* implicit_input_operands = */ kImplicitInputOperands, /* output_operands = */ kOutputOperands, /* implicit_output_operands = */ kImplicitOutputOperands, - /* cache_miss_frequency = */ kCacheMissFrequency); + /* instruction_annotations = */ kInstructionAnnotations); EXPECT_EQ(instruction.mnemonic, kMnemonic); EXPECT_EQ(instruction.llvm_mnemonic, kLlvmMnemonic); EXPECT_EQ(instruction.prefixes, kPrefixes); @@ -350,7 +351,7 @@ TEST(InstructionTest, Constructor) { EXPECT_EQ(instruction.implicit_input_operands, kImplicitInputOperands); EXPECT_EQ(instruction.output_operands, kOutputOperands); EXPECT_EQ(instruction.implicit_output_operands, kImplicitOutputOperands); - EXPECT_EQ(instruction.cache_miss_frequency, kCacheMissFrequency); + EXPECT_EQ(instruction.instruction_annotations, kInstructionAnnotations); } TEST(InstructionTest, AsTokenList) { @@ -365,7 +366,8 @@ TEST(InstructionTest, AsTokenList) { InstructionOperand::MemoryLocation(3)}; const std::vector kImplicitOutputOperands = { InstructionOperand::Register("EFLAGS")}; - const RuntimeAnnotation kCacheMissFrequency("r20d1", 0.875); + const std::vector kInstructionAnnotations = { + Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)}; const Instruction instruction( /* mnemonic = */ kMnemonic, @@ -375,7 +377,7 @@ TEST(InstructionTest, AsTokenList) { /* implicit_input_operands = */ kImplicitInputOperands, /* output_operands = */ kOutputOperands, /* implicit_output_operands = */ kImplicitOutputOperands, - /* cache_miss_frequency = */ kCacheMissFrequency); + /* instruction_annotations = */ kInstructionAnnotations); EXPECT_THAT(instruction.AsTokenList(), ElementsAre(kPrefixes[0], kPrefixes[1], kMnemonic, @@ -395,7 +397,8 @@ TEST(InstructionTest, ToString) { /* output_operands = */ {InstructionOperand::Register("RAX")}, /* implicit_output_operands = */ {InstructionOperand::Register("EFLAGS")}, - RuntimeAnnotation("r20d1", 0.875)); + /* instruction_annotations = */ + {Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)}); constexpr char kExpectedString[] = "Instruction(mnemonic='ADC', llvm_mnemonic='ADC32rr', " "prefixes=('LOCK',), " @@ -501,7 +504,9 @@ TEST(BasicBlockTest, Constructor) { /* output_operands = */ {InstructionOperand::Register("RAX")}, /* implicit_output_operands = */ {InstructionOperand::Register("EFLAGS")}, - RuntimeAnnotation("r20d1", 0.875)); + /* instruction_annotations = */ + {Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)}); + const BasicBlock block({instruction}); EXPECT_THAT(block.instructions, ElementsAre(instruction)); } @@ -525,7 +530,9 @@ TEST(BasicBlockTest, Equality) { /* output_operands = */ {InstructionOperand::Register("RAX")}, /* implicit_output_operands = */ {InstructionOperand::Register("EFLAGS")}, - RuntimeAnnotation("r20d1", 0.875))); + /* instruction_annotations = */ + {Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)})); + EXPECT_NE(block_1, block_2); EXPECT_FALSE(block_1 == block_2); @@ -541,7 +548,9 @@ TEST(BasicBlockTest, Equality) { /* output_operands = */ {InstructionOperand::Register("RAX")}, /* implicit_output_operands = */ {InstructionOperand::Register("EFLAGS")}, - RuntimeAnnotation("r20d1", 0.875))); + /* instruction_annotations = */ + {Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)})); + EXPECT_EQ(block_1, block_2); EXPECT_FALSE(block_1 != block_2); @@ -563,7 +572,9 @@ TEST(BasicBlockTest, ToString) { /* output_operands = */ {InstructionOperand::Register("RAX")}, /* implicit_output_operands = */ {InstructionOperand::Register("EFLAGS")}, - RuntimeAnnotation("r20d1", 0.875)); + /* instruction_annotations = */ + {Annotation("MEM_LOAD_RETIRED:L3_MISS", 0.875)}); + BasicBlock block({instruction}); constexpr char kExpectedString[] = "BasicBlock(instructions=InstructionList((Instruction(mnemonic='ADC', " diff --git a/gematria/basic_block/python/basic_block.cc b/gematria/basic_block/python/basic_block.cc index a0a7eea1..fcdc9c1b 100644 --- a/gematria/basic_block/python/basic_block.cc +++ b/gematria/basic_block/python/basic_block.cc @@ -185,23 +185,25 @@ PYBIND11_MODULE(basic_block, m) { py::bind_vector>(m, "InstructionOperandList"); - py::class_(m, "RuntimeAnnotation") - .def(py::init(), - py::arg("pmu_event") = std::string(), + py::class_(m, "Annotation") + .def(py::init(), + py::arg("name") = std::string(), py::arg("value") = 0) - .def("__repr__", &RuntimeAnnotation::ToString) - .def("__eq__", &RuntimeAnnotation::operator==) + .def("__repr__", &Annotation::ToString) + .def("__eq__", &Annotation::operator==) .def("__copy__", - [](const RuntimeAnnotation& annotation) { - return RuntimeAnnotation(annotation); + [](const Annotation& annotation) { + return Annotation(annotation); }) .def("__deepcopy__", - [](const RuntimeAnnotation& annotation, py::dict) { - return RuntimeAnnotation(annotation); + [](const Annotation& annotation, py::dict) { + return Annotation(annotation); }, py::arg("memo")) - .def_readonly("pmu_event", &RuntimeAnnotation::pmu_event) - .def_readonly("value", &RuntimeAnnotation::value); + .def_readonly("name", &Annotation::name) + .def_readonly("value", &Annotation::value); + + py::bind_vector>(m, "AnnotationList"); py::class_(m, "Instruction") .def( @@ -212,7 +214,7 @@ PYBIND11_MODULE(basic_block, m) { std::vector /* implicit_input_operands */, std::vector /* output_operands */, std::vector /* implicit_output_operands */, - RuntimeAnnotation /* cache_miss_frequency */>(), + std::vector /* instruction_annotations */>(), py::arg("mnemonic") = std::string(), py::arg("llvm_mnemonic") = std::string(), py::arg("prefixes") = std::vector(), @@ -222,7 +224,7 @@ PYBIND11_MODULE(basic_block, m) { py::arg("output_operands") = std::vector(), py::arg("implicit_output_operands") = std::vector(), - py::arg("cache_miss_frequency") = RuntimeAnnotation()) + py::arg("instruction_annotations") = std::vector()) .def("__str__", &Instruction::ToString) .def("__repr__", &Instruction::ToString) .def("__eq__", &Instruction::operator==) @@ -245,7 +247,9 @@ PYBIND11_MODULE(basic_block, m) { &Instruction::implicit_input_operands) .def_readwrite("output_operands", &Instruction::output_operands) .def_readwrite("implicit_output_operands", - &Instruction::implicit_output_operands); + &Instruction::implicit_output_operands) + .def_readwrite("instruction_annotations", + &Instruction::instruction_annotations); py::bind_vector>(m, "InstructionList"); diff --git a/gematria/basic_block/python/basic_block_protos.cc b/gematria/basic_block/python/basic_block_protos.cc index 3eeea82b..1115a53a 100644 --- a/gematria/basic_block/python/basic_block_protos.cc +++ b/gematria/basic_block/python/basic_block_protos.cc @@ -34,7 +34,7 @@ PYBIND11_MODULE(basic_block_protos, m) { m.def("instruction_operand_from_proto", InstructionOperandFromProto, py::arg("proto")); m.def("address_tuple_from_proto", AddressTupleFromProto, py::arg("proto")); - m.def("runtime_annotation_from_proto", RuntimeAnnotationFromProto, + m.def("annotation_from_proto", AnnotationFromProto, py::arg("proto")); } diff --git a/gematria/basic_block/python/basic_block_protos_test.py b/gematria/basic_block/python/basic_block_protos_test.py index b6538bb8..1a22dd9b 100644 --- a/gematria/basic_block/python/basic_block_protos_test.py +++ b/gematria/basic_block/python/basic_block_protos_test.py @@ -17,6 +17,7 @@ from absl.testing import absltest from gematria.basic_block.python import basic_block from gematria.basic_block.python import basic_block_protos +from gematria.proto import annotation_pb2 from gematria.proto import basic_block_pb2 from gematria.proto import canonicalized_instruction_pb2 @@ -26,7 +27,9 @@ _CanonicalizedInstructionProto = ( canonicalized_instruction_pb2.CanonicalizedInstructionProto ) - +_Annotation = ( + annotation_pb2.Annotation +) class AddressTupleTest(absltest.TestCase): @@ -174,11 +177,11 @@ def test_initialize_from_proto(self): output_operands=( _CanonicalizedOperandProto(register_name='RCX'), ), - cache_miss_frequency=( - _CanonicalizedInstructionProto.RuntimeAnnotation( - pmu_event='r20d1', + instruction_annotations=( + _Annotation( + name='MEM_LOAD_RETIRED:L3_MISS', value=0.875, - ) + ), ), ), _CanonicalizedInstructionProto( @@ -203,11 +206,11 @@ def test_initialize_from_proto(self): ) ), ), - cache_miss_frequency=( - _CanonicalizedInstructionProto.RuntimeAnnotation( - pmu_event='r20d1', - value=0.5, - ) + instruction_annotations=( + _Annotation( + name='MEM_LOAD_RETIRED:L3_MISS', + value=0.95, + ), ), ), ) @@ -224,10 +227,12 @@ def test_initialize_from_proto(self): output_operands=basic_block.InstructionOperandList(( basic_block.InstructionOperand.from_register('RCX'), )), - cache_miss_frequency=basic_block.RuntimeAnnotation( - pmu_event='r20d1', - value=0.875, - ), + instruction_annotations=basic_block.AnnotationList(( + basic_block.Annotation( + name='MEM_LOAD_RETIRED:L3_MISS', + value=0.875, + ), + )), ), basic_block.Instruction( mnemonic='MOVSB', @@ -243,10 +248,12 @@ def test_initialize_from_proto(self): basic_block.InstructionOperand.from_register('RDI'), basic_block.InstructionOperand.from_memory(2), )), - cache_miss_frequency=basic_block.RuntimeAnnotation( - pmu_event='r20d1', - value=0.5, - ), + instruction_annotations=basic_block.AnnotationList(( + basic_block.Annotation( + name='MEM_LOAD_RETIRED:L3_MISS', + value=0.95, + ), + )), ), ) self.assertSequenceEqual(block.instructions, expected) diff --git a/gematria/granite/graph_builder.cc b/gematria/granite/graph_builder.cc index f9173de4..9858fc94 100644 --- a/gematria/granite/graph_builder.cc +++ b/gematria/granite/graph_builder.cc @@ -193,10 +193,14 @@ bool BasicBlockGraphBuilder::AddBasicBlockFromInstructions( // Store the annotation within the instruction annotations vector for later // use (inclusion in embeddings). - // TODO(virajbshah): Annotations are better stored on `Instruction`s as - // lists. Update this appropriately once that change is made. - instruction_annotations_.push_back( - std::vector{instruction.cache_miss_frequency.value}); + std::vector instruction_annotation_values; + instruction_annotation_values.reserve( + instruction.instruction_annotations.size()); + std::transform(instruction.instruction_annotations.begin(), + instruction.instruction_annotations.end(), + instruction_annotation_values, + [](Annotation annotation) { return annotation.value; }); + instruction_annotations_.push_back(instruction_annotation_values); // Add nodes for prefixes of the instruction. for (const std::string& prefix : instruction.prefixes) { diff --git a/gematria/proto/BUILD b/gematria/proto/BUILD index 88aa97b0..0a366b81 100644 --- a/gematria/proto/BUILD +++ b/gematria/proto/BUILD @@ -15,6 +15,9 @@ gematria_proto_library( gematria_proto_library( name = "canonicalized_instruction_proto", srcs = ["canonicalized_instruction.proto"], + deps = [ + ":annotation_proto", + ], ) gematria_proto_library( @@ -24,3 +27,8 @@ gematria_proto_library( ":basic_block_proto", ], ) + +gematria_proto_library( + name = "annotation_proto", + srcs = ["annotation.proto"], +) diff --git a/gematria/proto/annotation.proto b/gematria/proto/annotation.proto new file mode 100644 index 00000000..a6be6588 --- /dev/null +++ b/gematria/proto/annotation.proto @@ -0,0 +1,27 @@ +// Copyright 2023 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package gematria; + +// Contains annotations to supply additional information to the model, such as +// cache-miss frequencies, or branching related statistics. +message AnnotationProto { + // A name or label for the annotation. + string name = 1; + // The annotation value, holding information such as measurements or + // statistics like event frequency or rate. + double value = 2; +} \ No newline at end of file diff --git a/gematria/proto/canonicalized_instruction.proto b/gematria/proto/canonicalized_instruction.proto index 89c55180..d2ca5c35 100644 --- a/gematria/proto/canonicalized_instruction.proto +++ b/gematria/proto/canonicalized_instruction.proto @@ -18,6 +18,8 @@ syntax = "proto3"; package gematria; +import "gematria/proto/annotation.proto"; + // Contains information about an instruction and all its inputs and outputs. // This proto can be used to create the embedding of the instruction as // described in the Ithemal [1] and Granite [2] papers. @@ -52,18 +54,8 @@ message CanonicalizedInstructionProto { // The list of implicit input operands of the instruction. repeated CanonicalizedOperandProto implicit_input_operands = 7; - // Contains annotations to supply instruction level runtime-related - // information, such as cache-miss frequencies, or branching related - // statistics. - message RuntimeAnnotation { - // The name of the event whose measure is being annotated. - string pmu_event = 1; - // The measurement or statistic, such as event frequency or rate. - double value = 2; - } - - // Optional. The cache miss frequency of the instruction. - optional RuntimeAnnotation cache_miss_frequency = 8; + // Runtime related instruction level annotations. + repeated AnnotationProto instruction_annotations = 8; } // Contains information about a single operand in the canonicalized instruction.