int main(int argc, char* argv[])
{
   ossimString tempString;
   ossimArgumentParser::ossimParameter stringParam(tempString);
   ossimArgumentParser argumentParser(&argc, argv);
   //ossimInit::instance()->addOptions(argumentParser);
   ossimInit::instance()->initialize(argumentParser);
   ossim_uint32 threads = 10;
   ossim_uint32 nvalues = 10;
   ossim_uint32 randomSeed = 0;

   argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
   argumentParser.getApplicationUsage()->addCommandLineOption("--threads","Specify the number of threads to test simultaneus access to elevation");
   argumentParser.getApplicationUsage()->addCommandLineOption("--nvalues","Specify the number of random values");
   if (argumentParser.read("-h") ||
       argumentParser.read("--help"))
   {
      argumentParser.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_WARN));
      exit(0);
   }
   if(argumentParser.read("--threads", stringParam))
   {
      threads = tempString.toUInt32();
   }
   if(argumentParser.read("--nvalues", stringParam))
   {
      nvalues = tempString.toUInt32();
   }

   std::vector<Polyarea2dThread*> threadList(threads);
   startBarrier = new OpenThreads::Barrier(threads); // include the main thread for synching
   endBarrier   = new OpenThreads::Barrier(threads+1); //   include main thread for syncing end 
   ossim_uint32 idx = 0;
   for(idx = 0; idx < threads; ++ idx)
   {
      threadList[idx] = new Polyarea2dThread("Thread " + ossimString::toString(idx));
      threadList[idx]->setNumberOfPointsToQuery(nvalues);
      threadList[idx]->start();
   }
   ossimTimer::Timer_t t1 = ossimTimer::instance()->tick();
   // synch all threads to start at the same time
   std::cout << "Number of threads:         " << threads      << "\n";
//   startBarrier->block();
   endBarrier->block();
   std::cout << "All threads finished\n";
   ossimTimer::Timer_t t2 = ossimTimer::instance()->tick();
   std::cout << "Time elapsed:              " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n";
   delete startBarrier;
   delete endBarrier;
   return 0;
}
Beispiel #2
0
void Concentration::diffuseThreaded(int num)
{
	std::vector<std::thread> threadList(num);
	for (int i = 0; i < num; i++)
	{
		int len = gridLength / num;
		threadList[i] = std::thread(&Concentration::diffuseWorker, this, i*len, len);
	}

	for (int i = 0; i < num; i++)
	{
		threadList[i].join();
	}

	switchGrids();
}
Beispiel #3
0
std::string gdbmiThreadList(CIDebugSystemObjects *debugSystemObjects,
                            CIDebugSymbols *debugSymbols,
                            CIDebugControl *debugControl,
                            CIDebugAdvanced *debugAdvanced,
                            std::string *errorMessage)
{
    Threads threads;
    ULONG currentThreadId;
    if (!threadList(debugSystemObjects, debugSymbols, debugControl,
                    debugAdvanced, &threads, &currentThreadId, errorMessage))
        return std::string();
    std::ostringstream str;
    str << "{threads=[";
    const Threads::const_iterator cend = threads.end();
    for (Threads::const_iterator it = threads.begin(); it != cend; ++it)
        it->formatGDBMI(str);
    str << "],current-thread-id=\"" << currentThreadId << "\"}";
    return str.str();
}