Skip to content

Commit

Permalink
addcomments
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelhc13 committed Jan 14, 2024
1 parent e17395a commit 22d8066
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
9 changes: 8 additions & 1 deletion src/c/backend/include/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class InnerTask {
/* Task Assigned Device Set*/
std::vector<Device *> assigned_devices;

/*Resource Requirements for each assigned device*/
/* Resource Requirements for each assigned device*/
std::unordered_map<int, ResourcePool_t> device_constraints;

/* Task is data movement task */
Expand All @@ -293,6 +293,13 @@ class InnerTask {
std::vector<std::vector<std::pair<parray::InnerPArray *, AccessMode>>>
parray_list;

/* A list of dependency tasks of a parray for this task's dependent tasks.
To be specific, a task sets dependencies of a parray for dependent tasks.
If this task's access permission to a parray includes write, it sets
itself as the dependency of the parray.
If this task's access permission to the parray is read-only, it pulls
this list of the dependencies to this map.
*/
std::unordered_map<uint64_t, std::vector<InnerTask*>> parray_dependencies_map;

InnerTask();
Expand Down
22 changes: 10 additions & 12 deletions src/c/backend/phases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ void MemoryReserver::create_datamove_tasks(InnerTask *task) {




// TODO(hc): need to think about better naming before it is merged.
// first, need peer-review on this.
void MemoryReserver::create_datamove_tasks2(InnerTask *task) {
// Get a list of the parrays the current task holds.
const std::vector<std::vector<std::pair<parray::InnerPArray *, AccessMode>>>
Expand All @@ -258,38 +259,35 @@ void MemoryReserver::create_datamove_tasks2(InnerTask *task) {
task_base_name + ".dm." + std::to_string(i), 0, parray, access_mode,
i);
uint64_t parray_parent_id = parray->get_parent_parray()->id;
// Find dependency intersection between compute and data movement tasks.

// TODO(hc): This is not the complete implementation.
// We will use a concurrent map for parray's
// task list as an optimization.

// Get dependencies
std::vector<void *> compute_task_dependencies = task->get_dependencies();
std::vector<InnerTask *> data_task_dependencies;
for (size_t k = 0; k < compute_task_dependencies.size(); ++k) {
InnerTask *parray_dependency =
static_cast<InnerTask *>(compute_task_dependencies[k]);
// Get dependencies of a parray having `parray_parent_id` that have
// registered to the traversed dependency task
std::vector<InnerTask*>& dep_parray_dependencies =
parray_dependency->get_parray_dependencies(parray_parent_id);

std::cout << parray_dependency->name << " is being traversed\n";
//std::cout << parray_dependency->name << " is being traversed\n";
for (size_t t = 0; t < dep_parray_dependencies.size(); ++t) {
data_task_dependencies.push_back(parray_dependency);
// If the current processing parray's access mode is READ ONLY,
// add this dependency as a dependency for this parray.
std::cout << "access mode:" << int(access_mode) << "\n";
//std::cout << "access mode:" << int(access_mode) << "\n";
if (access_mode == AccessMode::IN) {
std::cout << "IN parray is added:" << parray_parent_id << "\n";
//std::cout << "IN parray is added:" << parray_parent_id << "\n";
task->get_parray_dependencies(parray_parent_id).push_back(parray_dependency);
}
}
}

// If the current processing parray's access mode is not READ ONLY,
// add itself as a dependency for this parray.
std::cout << task->name << " is being traversed access id :" << int(access_mode) << "\n";
//std::cout << task->name << " is being traversed access id :" << int(access_mode) << "\n";
if (access_mode != AccessMode::IN) {
std::cout << "IN/OUT OUT parray is added:" << parray_parent_id << "\n";
//std::cout << "IN/OUT OUT parray is added:" << parray_parent_id << "\n";
task->get_parray_dependencies(parray_parent_id).push_back(task);
}

Expand Down

0 comments on commit 22d8066

Please sign in to comment.