示例#1
0
//Called whenever a key on the keyboard was pressed.
//The key is given by the ''key'' parameter, which is in ASCII.
//It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to
//exit the program.
void myKeyboard(unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27:
            exit(0);
            break;
        case ' ':
            currentTaskNumber = (currentTaskNumber + 1) % tasks.size();
            ITask* currentTask = tasks[currentTaskNumber];
            if (currentTask != NULL)
            {
                currentTask->InitializeProgram();
                printf("Current Task = %s\n", currentTask->ToString());
            }
            break;
    }
    glutPostRedisplay();  // Nutno, kdybychom nevolali prekresleni casovacem ci Idle
}
void test_region(int level, int maxLevel, int* threadNums, TaskVector parents){
  #pragma omp parallel num_threads(threadNums[level-1]) 
  {
    TaskVector taskIDs;
    #ifdef OMPT_DEBUG
      // Critical section around get_task_id for easier debugging
      #pragma omp critical
    #endif
    for(int i=0; i<=level; i++){
        taskIDs.push_back(ompt_get_task_id(i));
    }
    #pragma omp critical
    {
      #ifdef OMPT_DEBUG
        std::cout <<"(Level " << level << ") implicit_task=" << taskIDs[0] << " enclosing_task=" << taskIDs[1] << std::endl;
      #endif
      is_task_unique( map_taskID, taskIDs[0], taskIDs[1]);
      for(int i=1; i<=level; i++){
        std::stringstream sMsg;
        sMsg << "Parent task ID level " << level << " -> " << level - i << " mismatch";
        assertEqual(taskIDs[i], parents[parents.size()-i], sMsg.str().c_str());
      }
    }
    if(level<maxLevel){
      // Do not modify outer vector as it is used by other threads!
      TaskVector newParents = parents;
      newParents.push_back(taskIDs[0]);
      test_region(level+1, maxLevel, threadNums, newParents);
      // Make sure the task ids did not change
      for(int i=0; i<=level; i++){
        std::stringstream sMsg;
        sMsg << "Task ID level " << level << " -> " << level - i << " changed after nested region";
        assertEqual(ompt_get_task_id(i), taskIDs[i], sMsg.str().c_str());
      }
    }
  }
}