MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / get_schedule

Method get_schedule

include/core/solver.h:519–575  ·  view source on GitHub ↗

Determine the schedule of partitions */

Source from the content-addressed store, hash-verified

517
518 /** Determine the schedule of partitions */
519 virtual std::vector<std::vector<std::pair<int, int>>> get_schedule() const {
520 std::vector<std::vector<std::pair<int, int>>> schedule;
521 std::vector<std::pair<int, int>> assignment(num_worker);
522
523 if (num_partition == 1)
524 return {{{0, 0}}};
525
526 if (naive_parallel) {
527 for (int i = 0; i < num_worker; i++)
528 assignment[i] = {i, 0};
529 return {assignment};
530 }
531
532 if (tied_weights)
533 for (int x = 0; x < num_partition; x += num_worker * 2)
534 for (int y = 0; y < num_partition; y += num_worker * 2) {
535 // diagonal
536 for (int i = 0; i < num_worker; i++) {
537 int head_partition_id = x + i;
538 int tail_partition_id = y + i;
539 assignment[i] = {head_partition_id, tail_partition_id};
540 }
541 schedule.push_back(assignment);
542 for (int i = 0; i < num_worker; i++) {
543 int head_partition_id = x + num_worker + i;
544 int tail_partition_id = y + num_worker + i;
545 assignment[i] = {head_partition_id, tail_partition_id};
546 }
547 schedule.push_back(assignment);
548 for (int group_size = 1; group_size <= num_worker; group_size *= 2)
549 for (int offset = 0; offset < group_size; offset++) {
550 for (int i = 0; i < num_worker; i++) {
551 int head_partition_id = x + (i / group_size * 2) * group_size + i % group_size;
552 int tail_partition_id = y + (i / group_size * 2 + 1) * group_size
553 + (i + offset) % group_size;
554 assignment[i] = {head_partition_id, tail_partition_id};
555 }
556 schedule.push_back(assignment);
557 for (int i = 0; i < num_worker; i++)
558 std::swap(assignment[i].first, assignment[i].second);
559 schedule.push_back(assignment);
560 }
561 }
562 else
563 for (int x = 0; x < num_partition; x += num_worker)
564 for (int y = 0; y < num_partition; y += num_worker)
565 for (int offset = 0; offset < num_worker; offset++) {
566 for (int i = 0; i < num_worker; i++) {
567 int head_partition_id = x + (i + offset) % num_worker;
568 int tail_partition_id = y + i;
569 assignment[i] = {head_partition_id, tail_partition_id};
570 }
571 schedule.push_back(assignment);
572 }
573
574 return schedule;
575 }
576

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected