Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change constants in BHive conversion script #39

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions gematria/datasets/convert_bhive_to_llvm_exegesis_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@
#include "gematria/llvm/llvm_architecture_support.h"
#include "gematria/utils/string.h"

constexpr uint64_t kInitialRegVal = 0x10000;
constexpr uint64_t kInitialMemVal = 0x7FFFFFFF;
// Use the constants from the BHive paper for setting initial register and
// memory values. These constants are set to a high enough value to avoid
// underflow and accesses within the first page, but low enough to avoid
// exceeding the virtual address space ceiling in most cases.
constexpr uint64_t kInitialRegVal = 0x12345600;
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved
constexpr uint64_t kInitialMemVal = 0x12345600;
constexpr unsigned kInitialMemValBitWidth = 64;
constexpr std::string_view kRegDefPrefix = "# LLVM-EXEGESIS-DEFREG ";
constexpr std::string_view kMemDefPrefix = "# LLVM-EXEGESIS-MEM-DEF ";
constexpr std::string_view kMemMapPrefix = "# LLVM-EXEGESIS-MEM-MAP ";
Expand Down Expand Up @@ -64,6 +69,14 @@ int main(int argc, char* argv[]) {
gematria::ConvertHexToString(kInitialRegVal);
std::string initial_mem_val_str =
gematria::ConvertHexToString(kInitialMemVal);
// Prefix the string with zeroes as llvm-exegesis assumes the bit width
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unrelated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly unrelated, but necessary to make this patch work properly. We're assuming the memory value has a width of 64 bits, but only setting the first x bits. Exegesis determines the width of the value based on how many characters are in the string, so we need to explicitly print out the leading zeros.

// of the memory value based on the number of characters in the string.
if (kInitialMemValBitWidth > initial_mem_val_str.size() * 4)
initial_mem_val_str =
std::string(
(kInitialMemValBitWidth - initial_mem_val_str.size() * 4) / 4,
'0') +
initial_mem_val_str;
std::string register_defs_lines;
const std::unique_ptr<gematria::LlvmArchitectureSupport> llvm_support =
gematria::LlvmArchitectureSupport::X86_64();
Expand Down Expand Up @@ -173,4 +186,4 @@ int main(int argc, char* argv[]) {

file_counter++;
}
}
}
Loading