int main ( int argc, char **argv )
{
   int i;
   bool check = true;

   main__loop_1_data_t _loop_data;

   A = 0;

   WD *wg = getMyThreadSafe()->getCurrentWD(); 
   for ( i = 0; i < NUM_ITERS; i++ ) {
      
      // If we're done processing half of the dataset
      if ( i == NUM_ITERS/2 ) {
         // Stop scheduler
         sys.stopScheduler();
      }
      
      // Work descriptor creation
      WD * wd = new WD( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t), ( void * ) &_loop_data );
      wd->setPriority( 100 );

      // Work Group affiliation
      wg->addWork( *wd );

      // Work submission
      sys.submit( *wd );
      
      if ( i == ( NUM_ITERS/2 + 5 ) ){
         // Keep going
         sys.startScheduler();
      }
   }
   // barrier (kind of)
   wg->waitCompletion();
   

   /*
    * How can we be sure the test passed? Each task increments A. If we run N
    * tasks, A should be equal to N.
    * If it's less than N, that'd mean the scheduler lost something.
    */
   if ( A.value() != NUM_ITERS ) check = false;

   if ( check ) {
      fprintf(stderr, "%s : %s\n", argv[0], "successful");
      return 0;
   }
   else {
      fprintf(stderr, "%s: %s\n", argv[0], "unsuccessful");
      return -1;
   }
}
Example #2
0
int main ( int argc, char **argv )
{
   int i;
   bool check = true;

   main__loop_1_data_t _loop_data;

   // Repeat the test NUM_RUNS times
   for ( int testNumber = 0; testNumber < NUM_RUNS; ++testNumber ) {
      A = 0;
   
      WD *wg = getMyThreadSafe()->getCurrentWD();   
      // Stop scheduler
      sys.stopScheduler();
      // increment variable
      for ( i = 0; i < NUM_ITERS; i++ ) {
         // Work descriptor creation
         WD * wd = new WD( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t), ( void * ) &_loop_data );
         wd->setPriority( 100 );
   
         // Work Group affiliation
         wg->addWork( *wd );
   
         // Work submission
         sys.submit( *wd );
      }
      // Re-enable the scheduler
      sys.startScheduler();
      // barrier (kind of)
      wg->waitCompletion();
      
   
      /*
       * The verification criteria is that A is equal to the number of tasks
       * run. Should A be lower, that would indicate that not all tasks
       * successfuly finished.
       */
      if ( A.value() != NUM_ITERS ) check = false;
   }

   if ( check ) {
      fprintf(stderr, "%s : %s\n", argv[0], "successful");
      return 0;
   }
   else {
      fprintf(stderr, "%s: %s\n", argv[0], "unsuccessful");
      return -1;
   }
}