libhsakmt: Update context save handling for multi XCC
Allocate debug area big enough for all XCCs in the partition. Also, fix
the cu_num calculations as driver now reports cu_num as the total number
of CUs in the partition.
Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
Change-Id: I6e80d57196b770bb3c2506bc58cb366c0046084b
[ROCm/ROCR-Runtime commit: 97a669a979]
Αυτή η υποβολή περιλαμβάνεται σε:
υποβλήθηκε από
Graham Sider
γονέας
ea4e2a82bb
υποβολή
0f7cfe5e4b
@@ -329,10 +329,10 @@ typedef struct _HsaNodeProperties
|
||||
HSAuint32 VGPRSizePerCU; // VGPR size in bytes per CU
|
||||
HSAuint32 SGPRSizePerCU; // SGPR size in bytes per CU
|
||||
|
||||
HSAuint32 NumXcc; // Number of XCC
|
||||
HSAuint32 KFDGpuID; // GPU Hash ID generated by KFD
|
||||
|
||||
HSAuint32 FamilyID; // GPU family id
|
||||
HSAuint8 Reserved[4];
|
||||
} HsaNodeProperties;
|
||||
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ static bool update_ctx_save_restore_size(uint32_t nodeid, struct queue *q)
|
||||
return false;
|
||||
if (node.NumFComputeCores && node.NumSIMDPerCU) {
|
||||
uint32_t ctl_stack_size, wg_data_size;
|
||||
uint32_t cu_num = node.NumFComputeCores / node.NumSIMDPerCU;
|
||||
uint32_t cu_num = node.NumFComputeCores / node.NumSIMDPerCU / node.NumXcc;
|
||||
uint32_t wave_num = (q->gfxv < GFX_VERSION_NAVI10)
|
||||
? MIN(cu_num * 40, node.NumShaderBanks / node.NumArrays * 512)
|
||||
: cu_num * 32;
|
||||
@@ -459,17 +459,21 @@ static void free_queue(struct queue *q)
|
||||
}
|
||||
|
||||
static inline void fill_cwsr_header(struct queue *q, void *addr,
|
||||
HsaEvent *Event, volatile HSAint64 *ErrPayload)
|
||||
HsaEvent *Event, volatile HSAint64 *ErrPayload, HSAuint32 NumXcc)
|
||||
{
|
||||
HsaUserContextSaveAreaHeader *header =
|
||||
(HsaUserContextSaveAreaHeader *)addr;
|
||||
uint32_t i;
|
||||
HsaUserContextSaveAreaHeader *header;
|
||||
|
||||
header->ErrorEventId = 0;
|
||||
if (Event)
|
||||
header->ErrorEventId = Event->EventId;
|
||||
header->ErrorReason = ErrPayload;
|
||||
header->DebugOffset = q->ctx_save_restore_size;
|
||||
header->DebugSize = q->debug_memory_size;
|
||||
for (i = 0; i < NumXcc; i++) {
|
||||
header = (HsaUserContextSaveAreaHeader *)
|
||||
((uintptr_t)addr + (i * q->ctx_save_restore_size));
|
||||
header->ErrorEventId = 0;
|
||||
if (Event)
|
||||
header->ErrorEventId = Event->EventId;
|
||||
header->ErrorReason = ErrPayload;
|
||||
header->DebugOffset = (NumXcc - i) * q->ctx_save_restore_size;
|
||||
header->DebugSize = q->debug_memory_size * NumXcc;
|
||||
}
|
||||
}
|
||||
|
||||
static int handle_concrete_asic(struct queue *q,
|
||||
@@ -502,19 +506,20 @@ static int handle_concrete_asic(struct queue *q,
|
||||
HsaNodeProperties node;
|
||||
bool svm_api;
|
||||
|
||||
if (hsaKmtGetNodeProperties(NodeId, &node))
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
|
||||
args->ctx_save_restore_size = q->ctx_save_restore_size;
|
||||
args->ctl_stack_size = q->ctl_stack_size;
|
||||
|
||||
/* Total memory to be allocated is =
|
||||
* (Control Stack size + WG size) + Debug memory area size
|
||||
* (Control Stack size + WG size) per XCC * num_xcc +
|
||||
* Debug memory area size
|
||||
*/
|
||||
total_mem_alloc_size = q->ctx_save_restore_size +
|
||||
q->debug_memory_size;
|
||||
total_mem_alloc_size = (q->ctx_save_restore_size +
|
||||
q->debug_memory_size) * node.NumXcc;
|
||||
|
||||
if (hsaKmtGetNodeProperties(NodeId, &node))
|
||||
svm_api = false;
|
||||
else
|
||||
svm_api = node.Capability.ui32.SVMAPISupported;
|
||||
svm_api = node.Capability.ui32.SVMAPISupported;
|
||||
|
||||
/* Allocate unified memory for context save restore
|
||||
* area on dGPU.
|
||||
@@ -539,7 +544,7 @@ static int handle_concrete_asic(struct queue *q,
|
||||
if (madvise(addr, size, MADV_DONTFORK))
|
||||
pr_err("madvise failed -%d\n", errno);
|
||||
|
||||
fill_cwsr_header(q, addr, Event, ErrPayload);
|
||||
fill_cwsr_header(q, addr, Event, ErrPayload, node.NumXcc);
|
||||
|
||||
r = register_svm_range(addr, size,
|
||||
NodeId, NodeId, 0, true);
|
||||
@@ -562,7 +567,7 @@ static int handle_concrete_asic(struct queue *q,
|
||||
if (!q->ctx_save_restore)
|
||||
return HSAKMT_STATUS_NO_MEMORY;
|
||||
|
||||
fill_cwsr_header(q, q->ctx_save_restore, Event, ErrPayload);
|
||||
fill_cwsr_header(q, q->ctx_save_restore, Event, ErrPayload, node.NumXcc);
|
||||
}
|
||||
|
||||
args->ctx_save_restore_address = (uintptr_t)q->ctx_save_restore;
|
||||
|
||||
@@ -1186,6 +1186,8 @@ static HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id,
|
||||
props->NumSdmaQueuesPerEngine = prop_val;
|
||||
else if (strcmp(prop_name, "num_cp_queues") == 0)
|
||||
props->NumCpQueues = prop_val;
|
||||
else if (strcmp(prop_name, "num_xcc") == 0)
|
||||
props->NumXcc = prop_val;
|
||||
else if (strcmp(prop_name, "gfx_target_version") == 0)
|
||||
gfxv = (uint32_t)prop_val;
|
||||
}
|
||||
@@ -1255,6 +1257,12 @@ static HSAKMT_STATUS topology_sysfs_get_node_props(uint32_t node_id,
|
||||
if (props->NumFComputeCores)
|
||||
assert(props->EngineId.ui32.Major && "HSA_OVERRIDE_GFX_VERSION may be needed");
|
||||
|
||||
/* On Older kernels, num_xcc may not be present in system properties.
|
||||
* Set it to 1 if system properties do not report num_xcc.
|
||||
*/
|
||||
if (!props->NumXcc)
|
||||
props->NumXcc = 1;
|
||||
|
||||
err:
|
||||
free(read_buf);
|
||||
fclose(fd);
|
||||
|
||||
Αναφορά σε νέο ζήτημα
Block a user