This patch renames npu schduler device and other kernel enum types.
Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
return -EINVAL;
device_state_t state = api->isReady ();
- if (state == device_state_t::STATE_READY) {
+ if (state == device_state_t::TRINITY_STATE_READY) {
*num_requests = api->numRequests ();
if (*num_requests > 0)
*status = NPU_READY;
int ret = -EINVAL;
state = api->isReady ();
- if (state != device_state_t::STATE_READY) {
+ if (state != device_state_t::TRINITY_STATE_READY) {
logerr (TAG, "device is not available to run inference %d\n", state);
goto handle_callback;
}
int ret = -EINVAL;
state = api->isReady ();
- if (state != device_state_t::STATE_READY) {
+ if (state != device_state_t::TRINITY_STATE_READY) {
logerr (TAG, "device is not available to run inference %d\n", state);
goto handle_callback;
}
input_config.priority = constraint.priority;
/** input handling by CPU. host inputservice only supports CPU mode */
- input_config.input_mode = INPUT_CPU;
+ input_config.input_mode = TRINITY_INPUT_CPU;
/** output handling by CPU, host inputservice only supports either interrupt or polling */
if (constraint.notimode == NPU_POLLING) {
- input_config.output_mode = OUTPUT_CPU_POLL;
+ input_config.output_mode = TRINITY_OUTPUT_CPU_POLL;
} else { /** default mode is interrupt */
- input_config.output_mode = OUTPUT_CPU_INTR;
+ input_config.output_mode = TRINITY_OUTPUT_CPU_INTR;
}
input_config.req_id = req_id;
int ret = -EINVAL;
state = api->isReady ();
- if (state != device_state_t::STATE_READY) {
+ if (state != device_state_t::TRINITY_STATE_READY) {
logerr (TAG, "device is not available to run inference %d\n", state);
goto handle_callback;
}
constraint = model->getConstraint ();
input_config.timeout_ms = 0; /* immediatedly handled */
input_config.priority = NPU_PRIORITY_HIGH;
- input_config.input_mode = INPUT_HW;
- input_config.output_mode = OUTPUT_HW;
+ input_config.input_mode = TRINITY_INPUT_HW;
+ input_config.output_mode = TRINITY_OUTPUT_HW;
/** Assumption: only a sigle pair of input/output segments in HW input service */
input_config.hw_input_seg = model->getMetadata ()->getInputSegmentIndex (0);
/** The below requires initialized device */
/** @brief check whether the device is ready (true) or busy (false) */
virtual device_state_t isReady () const {
- return device_state_t::STATE_UNKNOWN;
+ return device_state_t::TRINITY_STATE_UNKNOWN;
}
/** @brief return a number of requests submitted */
/**
* @brief get the state of device. always available.
- * @return STATE_READY if no error. otherwise STATE_END.
+ * @return TRINITY_STATE_READY if no error. otherwise STATE_END.
*/
device_state_t
TrinityEmulAPI::isReady () const {
if (!initialized ())
- return device_state_t::STATE_UNKNOWN;
+ return device_state_t::TRINITY_STATE_UNKNOWN;
- return STATE_READY;
+ return device_state_t::TRINITY_STATE_READY;
}
/**
req->run (func);
status = req_id;
- if (input_config->input_mode != INPUT_HW)
+ if (input_config->input_mode != TRINITY_INPUT_HW)
req->stop ();
}
*/
#include <misc/trinity.h>
-#include <misc/npu_sched.h>
+#include <misc/npu_sched_ioctl.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
}
/* Try to open a scheduler device */
- this->sched_dev_fd_ = ::open ("/dev/npu_sched", O_RDWR);
+ this->sched_dev_fd_ = ::open ("/dev/npusched", O_RDWR);
}
/** @brief destructor of emulation API driver */
int ret;
if (!this->initialized ())
- return device_state_t::STATE_UNKNOWN;
+ return device_state_t::TRINITY_STATE_UNKNOWN;
ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_GET_STATE, &state);
if (ret != 0)
- return device_state_t::STATE_UNKNOWN;
+ return device_state_t::TRINITY_STATE_UNKNOWN;
return state;
}
if (size == 0 || size > UINT32_MAX)
return -EINVAL;
- hwmem.type = contiguous ? HWMEM_DMA_CONT : HWMEM_DMA_IOMMU;
+ hwmem.type = contiguous ? TRINITY_HWMEM_DMA_CONT : TRINITY_HWMEM_DMA_IOMMU;
hwmem.size = size;
ret = ioctl (this->getDeviceFD (), TRINITY_IOCTL_HWMEM_ALLOC, &hwmem);
if (!this->initialized ())
return -EPERM;
- hwmem.type = contiguous ? HWMEM_DMA_CONT : HWMEM_DMA_IOMMU;
+ hwmem.type = contiguous ? TRINITY_HWMEM_DMA_CONT : TRINITY_HWMEM_DMA_IOMMU;
/* translate dmabuf FDs to cuse-compatible ones */
if (is_cuse_) {
return -EINVAL;
if (sched_dev_fd_ >= 0) {
- struct npu_sched_create_task val;
- struct npu_sched_activate_task val2;
- uint32_t subtask_id;
-
- val.task_id = getpid ();
- val.task_is_rt = false;
- val.nice_value = input_config->priority;
- val.num_subtasks = 1; /* FIXME */
- val.subtask_ids = &subtask_id;
- subtask_id = input_config->req_id;
-
- ret = ioctl (sched_dev_fd_, NPU_SCHED_CREATE_TASK, &val);
+ struct npu_sched_ioctl_create_param param;
+ struct npu_sched_ioctl_task_attribute task_attrib;
+ struct npu_sched_ioctl_task_id task_id;
+
+ param.id = getpid ();
+ param.is_rt = false;
+ param.nice_value = input_config->priority;
+ param.num_subtasks = 1; /* FIXME */
+
+ ret = ioctl (sched_dev_fd_, NPU_SCHED_CREATE_TASK, ¶m);
+ if (ret != 0)
+ return -errno;
+
+ task_attrib.task_handle = param.handle;
+ task_attrib.subtask_idx = 0;
+ /* reference attributes from VD */
+ task_attrib.wcet = 420000; /* worst-case execution time */
+ task_attrib.deadline = 8000000;
+ task_attrib.period = 32000000;
+ task_attrib.yield = 10250000;
+ ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ATTRIB, &task_attrib);
+ if (ret != 0)
+ return -errno;
+
+ task_id.task_handle = param.handle;
+ task_id.subtask_idx = 0;
+ task_id.id = 0x0; /* FIXME */
+ ret = ioctl (sched_dev_fd_, NPU_SCHED_SET_TASK_ID, &task_id);
if (ret != 0)
return -errno;
- val2.task_handle = val.task_handle;
- ret = ioctl (sched_dev_fd_, NPU_SCHED_ACTIVATE_TASK, &val2);
+ ret = ioctl (sched_dev_fd_, NPU_SCHED_ACTIVATE_TASK, ¶m.handle);
if (ret != 0)
return -errno;
- input_config->task_handle = val.task_handle;
+ input_config->task_handle = param.handle;
}
/* translate dmabuf FDs to cuse-compatible ones */
EXPECT_NE (api.get (), nullptr);
EXPECT_GE (api->getDeviceFD (), 0);
EXPECT_EQ (api->getDeviceID (), 0);
- EXPECT_EQ (api->isReady (), device_state_t::STATE_READY);
+ EXPECT_EQ (api->isReady (), device_state_t::TRINITY_STATE_READY);
/** open same device */
std::unique_ptr<DriverAPI> api2;
EXPECT_NE (api2.get (), nullptr);
EXPECT_GE (api2->getDeviceFD (), 0);
EXPECT_EQ (api2->getDeviceID (), 0);
- EXPECT_EQ (api2->isReady (), device_state_t::STATE_READY);
+ EXPECT_EQ (api2->isReady (), device_state_t::TRINITY_STATE_READY);
EXPECT_EQ (api->getDeviceID (), api2->getDeviceID ());
/** file descriptors should be different */
EXPECT_NE (api->open (), 0);
- EXPECT_EQ (api->isReady (), device_state_t::STATE_UNKNOWN);
+ EXPECT_EQ (api->isReady (), device_state_t::TRINITY_STATE_UNKNOWN);
EXPECT_EQ (api->alloc (size), -EPERM);
EXPECT_EQ (api->dealloc (0), -EPERM);
EXPECT_EQ (api->mmap (0, size), nullptr);
EXPECT_NE (api->open (), 0);
/** but, not initialized */
- EXPECT_EQ (api->isReady (), device_state_t::STATE_UNKNOWN);
+ EXPECT_EQ (api->isReady (), device_state_t::TRINITY_STATE_UNKNOWN);
EXPECT_EQ (api->alloc (size), -EPERM);
EXPECT_EQ (api->dealloc (0), -EPERM);
EXPECT_EQ (api->mmap (0, size), nullptr);
input.dbuf_fd = buffer_dmabuf;
input.model_id = model.id;
input.num_segments = 1;
- input.input_mode = INPUT_CPU;
- input.output_mode = OUTPUT_CPU_INTR;
+ input.input_mode = TRINITY_INPUT_CPU;
+ input.output_mode = TRINITY_OUTPUT_CPU_INTR;
input.timeout_ms = 100;
EXPECT_GE (api->runInput (&input), 0);
input.dbuf_fd = buffer_dmabuf;
input.model_id = model.id;
input.num_segments = 1;
- input.input_mode = INPUT_CPU;
- input.output_mode = OUTPUT_CPU_INTR;
+ input.input_mode = TRINITY_INPUT_CPU;
+ input.output_mode = TRINITY_OUTPUT_CPU_INTR;
input.timeout_ms = 100;
return api->runInput (&input);
ASSERT_GE (model.dbuf_fd, 0);
input.model_id = model.id;
input.num_segments = 1;
- input.input_mode = INPUT_CPU;
- input.output_mode = OUTPUT_CPU_INTR;
+ input.input_mode = TRINITY_INPUT_CPU;
+ input.output_mode = TRINITY_OUTPUT_CPU_INTR;
input.timeout_ms = 100;
EXPECT_GE (api->runInput (&input), 0);
input.model_id = model.id;
/** failure case: segments information is not properly set */
input.num_segments = 0;
- input.input_mode = INPUT_CPU;
- input.output_mode = OUTPUT_CPU_INTR;
+ input.input_mode = TRINITY_INPUT_CPU;
+ input.output_mode = TRINITY_OUTPUT_CPU_INTR;
input.timeout_ms = 100;
EXPECT_EQ (api->runInput (&input), -EINVAL);
*/
static int
triv2_get_state (trinity_cuse_context *ctx, uint32_t *state) {
- *state = STATE_READY;
+ *state = TRINITY_STATE_READY;
return 0;
}
return -EINVAL;
switch (hwmem->type) {
- case HWMEM_DMA_CONT:
- case HWMEM_DMA_IOMMU:
+ case TRINITY_HWMEM_DMA_CONT:
+ case TRINITY_HWMEM_DMA_IOMMU:
dmabuf = new EmulDmabuf (ctx->app_id);
if (dmabuf->setSize (size) != 0) {
delete dmabuf;