コード例 #1
0
ファイル: RaceTaskOOB.java プロジェクト: RB-DPR/RB-DPR
  @Override
  public void taskFork2(int thrdId, int child, int itrNum) {
    RaceTaskOOB async = null;
    RaceTaskOOB step1 = null;
    RaceTaskOOB temp = null;

    RaceTaskOOB currTask = (RaceTaskOOB) threadTasks.get(thrdId);
    RaceTaskOOB parentTask = (RaceTaskOOB) currTask.parent;
    if (parentTask == null) {
      System.out.println("[race]fork:can not find the parent task in the tree!");
      print(root, false);
      System.exit(-1);
    }
    // there should one finish node at the right most
    parentTask = (RaceTaskOOB) (parentTask.children.get(parentTask.children.size() - 1));
    // async node
    async = new RaceTaskOOB(child, RaceTask.RACE_TASK_ASYNC, parentTask.depth + 1, parentTask);
    // step node under the async node
    step1 = new RaceTaskOOB(child + 2, RaceTask.RACE_TASK_STEP, parentTask.depth + 2, async);
    parentTask.children.add(async);
    async.children.add(step1);
    async.asyncItrNum = itrNum;

    this.taskHt.put(child, async);
    this.taskHt.put(child + 2, step1);
  }
コード例 #2
0
ファイル: RaceTaskOOB.java プロジェクト: RB-DPR/RB-DPR
  @Override
  public void taskJoin(int thrdId, int taskId) {
    RaceTask task = lookup2(root, taskId);
    RaceTaskOOB taskOOB = (RaceTaskOOB) task;
    if (taskOOB == null) {
      System.out.println("[race]join:can not find the child task in the tree!");
      print(root, false);
      System.exit(-1);
    }

    // print(task, false);
    if (!(RaceDetector.itrOn && taskOOB.parent.type == RaceTask.RACE_TASK_DOTALL)) {
      for (int i = 0; i < task.children.size(); i++) {
        RaceTaskOOB right = (RaceTaskOOB) task.children.get(i);
        if (right.type == RaceTask.RACE_TASK_STEP) {
          right.set.setMergeNum(1);
          if (right.set instanceof AccessSetList) {
            taskOOB.set = taskOOB.set.merge(right.set);
          } else {
            right.set.setTaskId(AccessSet.LOG_WORK_MERGE);
            taskOOB.pushSet(right.set);
          }
        }
        right.set = null;
      }
    }
    // push the local set to the pending list
    if (taskOOB.set.getMergeNum() > 0) {
      taskOOB.set.setWorkType(AccessSet.LOG_WORK_HYBRID);
      taskOOB.pushSet(taskOOB.set);
    }
    taskOOB.asyncJoined = true;
    threadTasks.set(thrdId, null);
  }
コード例 #3
0
ファイル: RaceTaskOOB.java プロジェクト: RB-DPR/RB-DPR
  // public static long[] itrNum = new long[1024];
  // private RaceSet preItrSet = null;
  @Override
  public void startNewItr(long itr) {

    if (!RaceDetector.itrOn) return;

    int thrdId = Scheduler.getCurrThId();
    // itrNum[thrdId * 16]++;
    RaceTask step = threadTasks.get(thrdId);

    if (step == null) {
      System.out.println("[race]startNewItr:can not find the child task in the tree!");
      print(root, false);
      System.exit(-1);
    }
    RaceTaskOOB async = (RaceTaskOOB) step.parent;
    if (async == null) {
      System.out.println("[race]startNewItr:can not find the parent task in the tree!");
      print(root, false);
    }

    // async.asyncItrNum++;

    // if the async node has only one child
    if (async.children.size() - async.delayedNum == 1) {
      // step.set.print();
      step.set.setMergeNum(1);
      // if it is a list set, then we perform intersection and merge
      // immediately using current thread
      if (step.set instanceof AccessSetList) {
        async.set = async.set.intersectAndMerge(step.set, RaceTask.RACE_TASK_ASYNC);
        step.set.clear();
      } else {
        step.set.setWorkType(AccessSet.LOG_WORK_HYBRID);
        async.pushSet(step.set);
        step.reAllocaLog();
        taskMap(Scheduler.getCurrThId(), step);
      }
    } else {
      // System.out.println("new created");
      // create a new asyn node to hold all the children and sets of
      // current iteration
      RaceTaskOOB newAsync =
          new RaceTaskOOB(async.id, RaceTask.RACE_TASK_ASYNC, async.depth + 1, async);
      // set the asyncItrNum, so that newAsync when all the logs are merged together
      newAsync.asyncItrNum = async.children.size() - async.delayedNum;
      // add newAsync as one of the child of async
      async.children.add((int) async.delayedNum, newAsync);
      // remeber how many iterations are delayed for async
      async.delayedNum++;
      // post all sets of step nodes to newAsync
      // add all the finish children of current iteration to newAsync
      for (int i = async.delayedNum; i < async.children.size(); i++) {
        // newAsync.asyncItrNum++;
        RaceTaskOOB bgTask = (RaceTaskOOB) async.children.get(i);
        if (bgTask.type == RaceTask.RACE_TASK_STEP) {
          bgTask.set.setMergeNum(1);
          // if it is a list set, intersection and merge are performed
          // immediately by current thread
          if (bgTask.set instanceof AccessSetList) {
            newAsync.set = newAsync.set.merge(bgTask.set);
          } else {
            bgTask.set.setWorkType(AccessSet.LOG_WORK_MERGE);
            newAsync.pushSet(bgTask.set);
          }
          bgTask.set = null;
        } else {
          newAsync.children.add(bgTask);
          bgTask.parent = newAsync;
          bgTask.depth = newAsync.depth + 1;
        }
      }
      // push itself into the pending queue
      if (newAsync.set.getMergeNum() > 0) {
        newAsync.pushSet(newAsync.set);
      }
      // remove all the children of current iteration from async
      while (async.children.size() - async.delayedNum > 0)
        async.children.remove(async.children.size() - 1);
      // init the first step node for next iteration

      if (step.set instanceof AccessSetList) {
        step.set.clear();
      } else {
        step.reAllocaLog();
      }
      async.children.add(step);
      taskMap(Scheduler.getCurrThId(), step);
    }
  }