Skip to content

Commit

Permalink
Fixing small issues regarding task infos
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsala committed Jan 9, 2024
1 parent 6a4ecc2 commit e5752e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
8 changes: 2 additions & 6 deletions src/tasks/TaskInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This file is part of NODES and is licensed under the terms contained in the COPYING file.
Copyright (C) 2021-2023 Barcelona Supercomputing Center (BSC)
Copyright (C) 2021-2024 Barcelona Supercomputing Center (BSC)
*/

#include <cassert>
Expand Down Expand Up @@ -29,11 +29,7 @@ void TaskInfo::registerTaskInfo(nanos6_task_info_t *taskInfo)
_lock.lock();

if (_initialized) {
// Save a nOS-V type link in the task info
nosv_task_type_t type = initNosvType(taskInfo);
taskInfo->task_type_data = (void *) type;

_taskTypes.push_back(type);
createTaskType(taskInfo);
} else {
_taskInfos.push_back(taskInfo);
}
Expand Down
30 changes: 17 additions & 13 deletions src/tasks/TaskInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This file is part of NODES and is licensed under the terms contained in the COPYING file.
Copyright (C) 2021-2023 Barcelona Supercomputing Center (BSC)
Copyright (C) 2021-2024 Barcelona Supercomputing Center (BSC)
*/

#ifndef TASK_INFO_HPP
Expand Down Expand Up @@ -147,12 +147,7 @@ class TaskInfo {
_lock.lock();

for (size_t i = 0; i < _taskInfos.size(); ++i) {
nanos6_task_info_t *taskInfo = _taskInfos[i];

nosv_task_type_t type = initNosvType(taskInfo);
taskInfo->task_type_data = (void *) type;

_taskTypes.push_back(type);
createTaskType(_taskInfos[i]);
}

_lock.unlock();
Expand Down Expand Up @@ -188,13 +183,16 @@ class TaskInfo {
//! \brief Unregister all the registered taskinfos
static void shutdown();

static nosv_task_type_t initNosvType(nanos6_task_info_t *taskInfo)
//! \brief Create a nOS-V task type from a taskinfo and link them
//!
//! \param[in] taskInfo A pointer to the taskinfo
static inline nosv_task_type_t createTaskType(nanos6_task_info_t *taskInfo)
{
std::string task_type_label;
std::string label;
if (taskInfo->implementations->task_type_label) {
task_type_label = taskInfo->implementations->task_type_label;
label = taskInfo->implementations->task_type_label;
} else {
task_type_label = "Unlabeled" + std::to_string(unlabeledTaskInfos++);
label = "Unlabeled" + std::to_string(unlabeledTaskInfos++);
}

// Create the task type
Expand All @@ -204,15 +202,21 @@ class TaskInfo {
&(TaskInfo::runWrapper), /* Run callback wrapper for the tasks */
&(TaskFinalization::taskEndedCallback), /* End callback for when a task completes user code execution */
&(TaskFinalization::taskCompletedCallback), /* Completed callback for when a task completely finishes */
task_type_label.c_str(), /* Task type label */
label.c_str(), /* Task type label */
(void *) taskInfo, /* Metadata: Link to NODES' taskinfo */
&(TaskInfo::getCostWrapper),
NOSV_TYPE_INIT_NONE
);
if (err)
ErrorHandler::fail("nosv_type_init failed: ", nosv_get_error_string(err));
return type;

// Link the taskinfo to the task type
taskInfo->task_type_data = (void *) type;

// Save the task type to destroy during the finalization
_taskTypes.push_back(type);

return type;
}

};
Expand Down

0 comments on commit e5752e5

Please sign in to comment.