From 462a775ec3b96aaa91fa40b0888627f65f99b698 Mon Sep 17 00:00:00 2001 From: Harish Kasiviswanathan Date: Wed, 14 Oct 2015 13:29:33 -0400 Subject: [PATCH] Fix hard-coded usage of Node 0 Use appropriate NodeId instead Change-Id: I46af93b76978fea7bedb34457fcc0864ed4fe2d4 [ROCm/ROCR-Runtime commit: b6c6f791434586e3963cfb16aabe639f336ccc32] --- projects/rocr-runtime/src/events.c | 5 ++++- projects/rocr-runtime/src/libhsakmt.h | 2 +- projects/rocr-runtime/src/queues.c | 29 ++++++++++++++++++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/projects/rocr-runtime/src/events.c b/projects/rocr-runtime/src/events.c index 22949d595d..046d02765e 100644 --- a/projects/rocr-runtime/src/events.c +++ b/projects/rocr-runtime/src/events.c @@ -70,11 +70,14 @@ hsaKmtCreateEvent( memset(&args, 0, sizeof(args)); args.event_type = EventDesc->EventType; + args.node_id = EventDesc->NodeId; args.auto_reset = !ManualReset; /* dGPU code */ if (is_dgpu && events_page == NULL) { - events_page = allocate_exec_aligned_memory_gpu(KFD_SIGNAL_EVENT_LIMIT * 8, TONGA_PAGE_SIZE); + events_page = allocate_exec_aligned_memory_gpu(KFD_SIGNAL_EVENT_LIMIT * 8, + TONGA_PAGE_SIZE, + args.node_id); if (!events_page) { return HSAKMT_STATUS_ERROR; } diff --git a/projects/rocr-runtime/src/libhsakmt.h b/projects/rocr-runtime/src/libhsakmt.h index 1ceb583923..64ac2650bc 100644 --- a/projects/rocr-runtime/src/libhsakmt.h +++ b/projects/rocr-runtime/src/libhsakmt.h @@ -76,7 +76,7 @@ bool topology_is_dgpu(uint16_t gpu_id); HSAuint32 PageSizeFromFlags(unsigned int pageSizeFlags); -void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align); +void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align, uint32_t NodeId); void free_exec_aligned_memory_gpu(void *addr, uint32_t size, uint32_t align); extern int kmtIoctl(int fd, unsigned long request, void *arg); diff --git a/projects/rocr-runtime/src/queues.c b/projects/rocr-runtime/src/queues.c index 7c7c446b81..6604f02889 100644 --- a/projects/rocr-runtime/src/queues.c +++ b/projects/rocr-runtime/src/queues.c @@ -187,7 +187,7 @@ static void* allocate_exec_aligned_memory_cpu(uint32_t size, uint32_t align) return ptr; } -void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align) +void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align, uint32_t NodeId) { void *mem; HSAuint64 gpu_va; @@ -201,7 +201,7 @@ void* allocate_exec_aligned_memory_gpu(uint32_t size, uint32_t align) size = ALIGN_UP(size, align); - ret = hsaKmtAllocMemory(0, size, flags, &mem); + ret = hsaKmtAllocMemory(NodeId, size, flags, &mem); if (ret != HSAKMT_STATUS_SUCCESS) { return NULL; } @@ -222,10 +222,13 @@ void free_exec_aligned_memory_gpu(void *addr, uint32_t size, uint32_t align) } } -static void* allocate_exec_aligned_memory(uint32_t size, uint32_t align, enum asic_family_type type) +static void* allocate_exec_aligned_memory(uint32_t size, + uint32_t align, + enum asic_family_type type, + uint32_t NodeId) { if (IS_DGPU(type)) - return allocate_exec_aligned_memory_gpu(size, TONGA_PAGE_SIZE); + return allocate_exec_aligned_memory_gpu(size, TONGA_PAGE_SIZE, NodeId); return allocate_exec_aligned_memory_cpu(size, align); } @@ -264,12 +267,16 @@ static void free_queue(struct queue *q, enum asic_family_type type) } static int handle_concrete_asic(struct device_info *dev_info, struct queue *q, - struct kfd_ioctl_create_queue_args *args) + struct kfd_ioctl_create_queue_args *args, + uint32_t NodeId) { if (dev_info) { if (dev_info->eop_buffer_size > 0) { q->eop_buffer = - allocate_exec_aligned_memory(dev_info->eop_buffer_size, PAGE_SIZE, dev_info->asic_family); + allocate_exec_aligned_memory(dev_info->eop_buffer_size, + PAGE_SIZE, + dev_info->asic_family, + NodeId); if (q->eop_buffer == NULL) { return HSAKMT_STATUS_NO_MEMORY; } @@ -280,7 +287,10 @@ static int handle_concrete_asic(struct device_info *dev_info, struct queue *q, args->ctx_save_restore_size = dev_info->ctx_save_restore_size; args->ctl_stack_size = dev_info->ctl_stack_size; q->ctx_save_restore = - allocate_exec_aligned_memory(dev_info->ctx_save_restore_size, PAGE_SIZE, dev_info->asic_family); + allocate_exec_aligned_memory(dev_info->ctx_save_restore_size, + PAGE_SIZE, + dev_info->asic_family, + NodeId); if (q->ctx_save_restore == NULL) {; return HSAKMT_STATUS_NO_MEMORY; } @@ -320,7 +330,8 @@ hsaKmtCreateQueue( dev_info = get_device_info_by_dev_id(dev_id); struct queue *q = allocate_exec_aligned_memory(sizeof (*q), - PAGE_SIZE, dev_info->asic_family); + PAGE_SIZE, dev_info->asic_family, + NodeId); if (q == NULL) return HSAKMT_STATUS_NO_MEMORY; @@ -333,7 +344,7 @@ hsaKmtCreateQueue( q->type = dev_info->asic_family; - err = handle_concrete_asic(dev_info, q, &args); + err = handle_concrete_asic(dev_info, q, &args, NodeId); if (err != HSAKMT_STATUS_SUCCESS) { free_queue(q, dev_info->asic_family); return err;