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

Adding CERT log_bo metadata #315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 17 additions & 1 deletion src/shim/hwctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,30 @@ delete_ctx_on_device()
fini_log_buf();
}

void
hw_ctx::
set_metadata()
{
m_metadata.magic_no = 0xBAADBEEF;
m_metadata.major = 1;
m_metadata.minor = 4;
m_metadata.num_cols = m_num_cols;
for (int i = 0; i < m_num_cols; i++) {
m_metadata.col_offset[i] = 1024 * i;
m_metadata.col_size[i] = 1024;
}
}

void
hw_ctx::
init_log_buf()
{
auto log_buf_size = m_num_cols * 1024;
set_metadata();
auto log_buf_size = m_num_cols * 1024 + sizeof(m_metadata);
m_log_bo = alloc_bo(nullptr, log_buf_size, XCL_BO_FLAGS_EXECBUF);
m_log_buf = m_log_bo->map(bo::map_type::write);
std::memset(m_log_buf, 0, log_buf_size);
std::memcpy(m_log_buf, &m_metadata, sizeof(m_metadata));
}

void
Expand Down
13 changes: 13 additions & 0 deletions src/shim/hwctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class hw_ctx : public xrt_core::hwctx_handle
std::vector<uint8_t> m_pdi;
};

struct cert_log_metadata {
uint32_t magic_no;
uint8_t major;
uint8_t minor;
uint16_t num_cols; // how many valid cols, up to 8 for now
uint32_t col_offset[8]; // offset array for each valid col
uint32_t col_size[8]; // bo size for each valid col
};

void
set_metadata();

const std::vector<cu_info>&
get_cu_info() const;

Expand All @@ -100,6 +112,7 @@ class hw_ctx : public xrt_core::hwctx_handle
slot_id m_handle = AMDXDNA_INVALID_CTX_HANDLE;
amdxdna_qos_info m_qos = {};
std::vector<cu_info> m_cu_info;
struct cert_log_metadata m_metadata;
std::unique_ptr<hw_q> m_q;
uint32_t m_ops_per_cycle;
uint32_t m_num_cols;
Expand Down