}
/* check the given model before running */
- if (!model->finalize ()) {
+ if (model != nullptr && !model->finalize ()) {
logerr (TAG, "Failed to finalize the model. Please see the log messages\n");
return -EINVAL;
}
}
/* check the given model before running */
- if (!model->finalize ()) {
+ if (model != nullptr && !model->finalize ()) {
logerr (TAG, "Failed to finalize the model. Please see the log messages\n");
return -EINVAL;
}
return 0;
free_buffer:
- for (idx = idx - 1; idx >= 0; idx--) {
- deallocGenericBuffer (&buffers->bufs[idx]);
+ while (idx != 0) {
+ deallocGenericBuffer (&buffers->bufs[--idx]);
}
return status;
if (!initialized())
return -EPERM;
- if (model_config == nullptr)
+ if (model_config == nullptr || model_config->dbuf_fd < 0)
return -EINVAL;
EmulElement *elem = elem_map_.find (model_config->dbuf_fd);
model_config_t * config = new model_config_t;
+ uint32_t dbuf_fd_unsigned = model_config->dbuf_fd;
uint64_t internal_id = global_internal_id.fetch_add (1);
uint64_t max_internal_id = 1ULL << TRINITY_SHIFT_MODEL_ID;
internal_id = internal_id % max_internal_id;
- model_config->id = model_config->dbuf_fd;
+ model_config->id = dbuf_fd_unsigned;
model_config->id <<= TRINITY_SHIFT_MODEL_ID;
model_config->id |= internal_id;
EmulTask *task = new EmulTask;
status = task_map_.insert (taskid, task);
- if (status != 0)
+ if (status != 0) {
+ delete [] segment_table;
return status;
+ }
auto func = std::bind (&EmulTask::run_emul, task,
prog, prog_size, segment_table, num_segs);
std::unique_lock<std::mutex> lock (m_);
- char log_msg[MAX_LOG_MSG];
- size_t log_len;
-
time_t ltime = time (nullptr);
char* time_str;
va_list args;
time_str = asctime (localtime (<ime));
time_str[strcspn (time_str, "\n")] = '\x00';
- log_len = snprintf (log_msg, MAX_LOG_MSG,
+ char log_msg[MAX_LOG_MSG];
+ int log_len = snprintf (log_msg, MAX_LOG_MSG,
"[%s][%s][%s] ", loglevelstr[l], modulestr[m], time_str);
va_start (args, format);
model_config_t model;
std::future<int> f_ret;
input_config_t input;
- int *buf;
- int buffer_dmabuf;
int seg_dmabuf;
int model_dmabuf;
int num_devices;
EXPECT_EQ (api->registerModel (&model), 0);
+ int *buf = nullptr;
+ int buffer_dmabuf = -1;
+
f_ret = std::async(std::launch::async,
[&] () -> int {
/** allocate input data */