diff --git a/include/hsakmt.h b/include/hsakmt.h index fd2788803d..bdb8f2bdd3 100644 --- a/include/hsakmt.h +++ b/include/hsakmt.h @@ -318,6 +318,18 @@ hsaKmtDestroyQueue( HSA_QUEUEID QueueId //IN ); +/** + Set cu mask for a queue +*/ + +HSAKMT_STATUS +HSAKMTAPI +hsaKmtSetQueueCUMask( + HSA_QUEUEID QueueId, //IN + HSAuint32 CUMaskCount, //IN + HSAuint32* QueueCUMask //IN + ); + /** Allows an HSA process to set/change the default and alternate memory coherency, before starting to dispatch. */ diff --git a/include/linux/kfd_ioctl.h b/include/linux/kfd_ioctl.h index 3f9807eb3c..91aa69a345 100644 --- a/include/linux/kfd_ioctl.h +++ b/include/linux/kfd_ioctl.h @@ -75,6 +75,12 @@ struct kfd_ioctl_update_queue_args { uint32_t queue_priority; /* to KFD */ }; +struct kfd_ioctl_set_cu_mask_args { + uint32_t queue_id; /* to KFD */ + uint32_t num_cu_mask; /* to KFD */ + uint64_t cu_mask_ptr; /* to KFD */ +}; + /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */ #define KFD_IOC_CACHE_POLICY_COHERENT 0 #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1 @@ -339,8 +345,10 @@ struct kfd_ioctl_open_graphic_handle_args { #define AMDKFD_IOC_ALLOC_MEMORY_OF_SCRATCH \ AMDKFD_IOWR(0x16, struct kfd_ioctl_alloc_memory_of_gpu_args) +#define AMDKFD_IOC_SET_CU_MASK \ + AMDKFD_IOW(0x17, struct kfd_ioctl_set_cu_mask_args) #define AMDKFD_COMMAND_START 0x01 -#define AMDKFD_COMMAND_END 0x17 +#define AMDKFD_COMMAND_END 0x18 #endif diff --git a/src/libhsakmt.ver b/src/libhsakmt.ver index 72917e16af..3c8064d43c 100644 --- a/src/libhsakmt.ver +++ b/src/libhsakmt.ver @@ -20,6 +20,7 @@ hsaKmtWaitOnMultipleEvents; hsaKmtCreateQueue; hsaKmtUpdateQueue; hsaKmtDestroyQueue; +hsaKmtSetQueueCUMask; hsaKmtSetMemoryPolicy; hsaKmtAllocMemory; hsaKmtFreeMemory; diff --git a/src/queues.c b/src/queues.c index b25a7d503c..e720220b95 100644 --- a/src/queues.c +++ b/src/queues.c @@ -339,3 +339,33 @@ hsaKmtDestroyQueue( return HSAKMT_STATUS_SUCCESS; } } + +HSAKMT_STATUS +HSAKMTAPI +hsaKmtSetQueueCUMask( + HSA_QUEUEID QueueId, //IN + HSAuint32 CUMaskCount, //IN + HSAuint32* QueueCUMask //IN + ) +{ + struct queue *q = PORT_UINT64_TO_VPTR(QueueId); + struct kfd_ioctl_set_cu_mask_args args; + + CHECK_KFD_OPEN(); + + if (CUMaskCount == 0 || QueueCUMask == NULL) + return HSAKMT_STATUS_INVALID_PARAMETER; + + memset(&args, 0, sizeof(args)); + args.queue_id = q->queue_id; + args.num_cu_mask = CUMaskCount; + args.cu_mask_ptr = (uintptr_t)QueueCUMask; + + int err = kmtIoctl(kfd_fd, AMDKFD_IOC_SET_CU_MASK, &args); + if (err == -1) + { + return HSAKMT_STATUS_ERROR; + } + + return HSAKMT_STATUS_SUCCESS; +}