Exemple #1
0
  public void runSections(int sectionsId, int threadNum, ParallelTask[] tasks, boolean nowait) {
    if (!active) {
      throw new IllegalStateException("Unable to run a sections construct in inactive state");
    }

    Sections sections = sectionsMap.get(sectionsId);
    if (sections == null) {
      sectionsLock.lock();
      try {
        sections = sectionsMap.get(sectionsId);
        if (sections == null) {
          sections = new Sections(tasks);
          sectionsMap.put(sectionsId, sections);
        }
      } finally {
        sectionsLock.unlock();
      }
    }
    ParallelTask toRun = sections.getNextTask();
    if (toRun != null) {
      LoggingUtils.debug(
          log, "OMP Thread " + threadNum + " executing section from sections " + sectionsId);
      toRun.execute();
    }
    if (!nowait) {
      team[threadNum].getActiveTask().barrier(team[threadNum].getLevel());
    }
  }
Exemple #2
0
  public void runSingle(int singleId, int threadNum, ParallelTask task, boolean nowait) {
    if (!active) {
      throw new IllegalStateException("Unable to run a single construct in inactive state");
    }

    if (!singles.contains(singleId)) {

      singleLock.lock();
      try {
        if (!singles.contains(singleId)) {
          singles.add(singleId);
          LoggingUtils.debug(log, "OMP Thread " + threadNum + " executing single task " + singleId);
          task.execute();
        }
      } finally {
        singleLock.unlock();
      }
    }
    if (!nowait) {
      team[threadNum].getActiveTask().barrier(team[threadNum].getLevel());
    }
  }