From e5752e509f9c5a05eff0b726fe1058cf089657bd Mon Sep 17 00:00:00 2001 From: Kevin Sala Date: Tue, 9 Jan 2024 17:56:23 +0100 Subject: [PATCH] Fixing small issues regarding task infos --- src/tasks/TaskInfo.cpp | 8 ++------ src/tasks/TaskInfo.hpp | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/tasks/TaskInfo.cpp b/src/tasks/TaskInfo.cpp index da7fffb..b733492 100644 --- a/src/tasks/TaskInfo.cpp +++ b/src/tasks/TaskInfo.cpp @@ -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 @@ -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); } diff --git a/src/tasks/TaskInfo.hpp b/src/tasks/TaskInfo.hpp index 03185f3..51d5760 100644 --- a/src/tasks/TaskInfo.hpp +++ b/src/tasks/TaskInfo.hpp @@ -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 @@ -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(); @@ -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 @@ -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; } };