From 6c1bd8034c0e58a5e54d8bd0765bd9e2a1433117 Mon Sep 17 00:00:00 2001 From: ozeng Date: Tue, 31 Jan 2017 17:40:50 -0600 Subject: [PATCH] libkmt: Misc fixes in thunk 1. Translate thunk queue priority to kfd priority 2. Initialize event SyncVar 3. Added HSAint32 data type Change-Id: I7decc1be7cbe9c84cb670d9a7c99050b62ba98f3 [ROCm/ROCR-Runtime commit: cb0f851560b0fd1152674295eabcc7a629168262] --- projects/rocr-runtime/include/hsakmttypes.h | 2 ++ projects/rocr-runtime/src/events.c | 4 ++++ projects/rocr-runtime/src/queues.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) mode change 100644 => 100755 projects/rocr-runtime/src/events.c mode change 100644 => 100755 projects/rocr-runtime/src/queues.c diff --git a/projects/rocr-runtime/include/hsakmttypes.h b/projects/rocr-runtime/include/hsakmttypes.h index 2d29a7083c..80c1b29fa3 100644 --- a/projects/rocr-runtime/include/hsakmttypes.h +++ b/projects/rocr-runtime/include/hsakmttypes.h @@ -48,6 +48,7 @@ extern "C" { typedef unsigned short HSAuint16; typedef signed short HSAint16; typedef unsigned __int32 HSAuint32; + typedef signed __int32 HSAint32; typedef signed __int64 HSAint64; typedef unsigned __int64 HSAuint64; @@ -63,6 +64,7 @@ extern "C" { typedef uint16_t HSAuint16; typedef int16_t HSAint16; typedef uint32_t HSAuint32; + typedef int32_t HSAint32; typedef int64_t HSAint64; typedef uint64_t HSAuint64; diff --git a/projects/rocr-runtime/src/events.c b/projects/rocr-runtime/src/events.c old mode 100644 new mode 100755 index 8908817116..b65ea96e71 --- a/projects/rocr-runtime/src/events.c +++ b/projects/rocr-runtime/src/events.c @@ -120,6 +120,10 @@ hsaKmtCreateEvent( e->EventData.HWData1 = args.event_id; e->EventData.HWData3 = args.event_trigger_data; + e->EventData.EventData.SyncVar.SyncVar.UserData = + EventDesc->SyncVar.SyncVar.UserData; + e->EventData.EventData.SyncVar.SyncVarSize = + EventDesc->SyncVar.SyncVarSize; if (IsSignaled && !IsSystemEventType(e->EventData.EventType)) { struct kfd_ioctl_set_event_args set_args; diff --git a/projects/rocr-runtime/src/queues.c b/projects/rocr-runtime/src/queues.c old mode 100644 new mode 100755 index a6c9527b01..6a4636a2b1 --- a/projects/rocr-runtime/src/queues.c +++ b/projects/rocr-runtime/src/queues.c @@ -513,6 +513,12 @@ static int handle_concrete_asic(struct queue *q, return HSAKMT_STATUS_SUCCESS; } +/* A map to translate thunk queue priority (-3 to +3) + * to KFD queue priority (0 to 15) + * Indexed by thunk_queue_priority+3 + */ +static uint32_t priority_map[] = {0,3,5,7,9,11,15}; + HSAKMT_STATUS HSAKMTAPI hsaKmtCreateQueue( @@ -533,6 +539,10 @@ hsaKmtCreateQueue( int err; CHECK_KFD_OPEN(); + if (Priority < HSA_QUEUE_PRIORITY_MINIMUM || + Priority > HSA_QUEUE_PRIORITY_MAXIMUM) + return HSAKMT_STATUS_INVALID_PARAMETER; + result = validate_nodeid(NodeId, &gpu_id); if (result != HSAKMT_STATUS_SUCCESS) return result; @@ -581,7 +591,7 @@ hsaKmtCreateQueue( args.ring_base_address = (uintptr_t)QueueAddress; args.ring_size = QueueSizeInBytes; args.queue_percentage = QueuePercentage; - args.queue_priority = Priority; + args.queue_priority = priority_map[Priority+3]; err = kmtIoctl(kfd_fd, AMDKFD_IOC_CREATE_QUEUE, &args); @@ -623,13 +633,17 @@ hsaKmtUpdateQueue( CHECK_KFD_OPEN(); + if (Priority < HSA_QUEUE_PRIORITY_MINIMUM || + Priority > HSA_QUEUE_PRIORITY_MAXIMUM) + return HSAKMT_STATUS_INVALID_PARAMETER; + if (q == NULL) return (HSAKMT_STATUS_INVALID_PARAMETER); arg.queue_id = (HSAuint32)q->queue_id; arg.ring_base_address = (uintptr_t)QueueAddress; arg.ring_size = QueueSize; arg.queue_percentage = QueuePercentage; - arg.queue_priority = Priority; + arg.queue_priority = priority_map[Priority+3]; int err = kmtIoctl(kfd_fd, AMDKFD_IOC_UPDATE_QUEUE, &arg); if (err == -1)