Esempio n. 1
0
inline bool CompoundTester<Scalar>
::scaledTest() const 
{
  if (scaledSpec_.doTest())
  {
    Out::root() << "running operator scaling test..." << std::endl;
    Scalar alpha = sqrt(2.0);
    LinearOperator<Scalar> scaled = alpha*A_;

    Vector<Scalar> x = A_.domain().createMember();
    randomizeVec(x);
    Out::root() << "computing y1 = (alpha*A)*x..." << std::endl;
    Vector<Scalar> y1 = scaled*x;
    Out::root() << "computing y2 = A*x..." << std::endl;
    Vector<Scalar> y2 = A_*x;
    Out::root() << "computing y3 = alpha*y2..." << std::endl;
    Vector<Scalar> y3 = alpha*y2;

    ScalarMag err = (y1 - y3).norm2();

    Out::root() << "|y1-y3| = " << err << std::endl;
    return checkTest(composedSpec_, err, "operator scaling");
  }
  Out::root() << "skipping operator scaling test..." << std::endl;
  return true;
}
Esempio n. 2
0
bool SundanceGlobal:: passFailTest(const std::string& statusMsg,
  bool status, double error, double tol)
{
  MPIComm::world().synchronize();
  bool pass;
  if (MPIComm::world().getRank()==0)
  {

    cout << statusMsg << ": ";
    if (status) cout << "true" << std::endl;
    else cout << "false" << std::endl;
    cout << "error norm = " << error << std::endl;
    cout << "tolerance = " << tol << std::endl;
  }
  pass = checkTest(error, tol);
  if (MPIComm::world().getRank()==0)
  {
    if (status && pass)
    {
      cout << "test PASSED" << std::endl;
    }
    else
    {
      cout << "test FAILED" << std::endl;
    }
  }
  testStatus() = pass!=true;
  return pass;
}
Esempio n. 3
0
inline bool CompoundTester<Scalar>
::diagTest() const 
{
  if (diagSpec_.doTest())
  {
    Out::root() << "running diagonal operator test..." << std::endl;

    Vector<Scalar> x = A_.domain().createMember();
    randomizeVec(x);

    Vector<Scalar> d = A_.domain().createMember();
    randomizeVec(d);
        
    LinearOperator<Scalar> D = diagonalOperator(d);

    Out::root() << "computing y1 = D*x..." << std::endl;
    Vector<Scalar> y1 = D*x;
    Out::root() << "computing y2 = d .* x..." << std::endl;
    Vector<Scalar> y2 = x.dotStar(d);

    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;
    return checkTest(diagSpec_, err, "diagonal operator");
  }
  Out::root() << "skipping diagonal operator test..." << std::endl;
  return true;
}
Esempio n. 4
0
inline bool MatrixMatrixTester<Scalar>
::diagRightProdTest() const 
{
  if (diagRightProdSpec_.doTest())
  {
    Out::root() << "running diagonal*matrix multiplication test..." << std::endl;

    Vector<Scalar> x = A_.domain().createMember();
    randomizeVec(x);

    Vector<Scalar> d = A_.domain().createMember();
    randomizeVec(d);
        
    LinearOperator<Scalar> D = diagonalOperator(d);
    LinearOperator<Scalar> AD = epetraRightScale(A_, d);

    Out::root() << "computing implicit y1 = A*D*x..." << std::endl;
    Vector<Scalar> y1 = A_*D*x;
    Out::root() << "computing explicit y2 = A*D*x..." << std::endl;
    Vector<Scalar> y2 = AD*x;

    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;

    return checkTest(diagLeftProdSpec_, err, "matrix*diagonal multiplication");
  }
  Out::root() << "skipping diagonal matrix-matrix test..." << std::endl;
  return true;
}
Esempio n. 5
0
inline bool CompoundTester<Scalar>
::composedTest() const 
{
  if (composedSpec_.doTest())
  {
    Out::root() << "running operator composition test..." << std::endl;
    LinearOperator<Scalar> composed = A_ * B_;

    Vector<Scalar> x = B_.domain().createMember();
    randomizeVec(x);
    Out::root() << "computing y1 = (A*B)*x..." << std::endl;
    Vector<Scalar> y1 = composed*x;
    Out::root() << "computing y2 = B*x..." << std::endl;
    Vector<Scalar> y2 = B_*x;
    Out::root() << "computing y3 = A*y2..." << std::endl;
    Vector<Scalar> y3 = A_*y2;

    ScalarMag err = (y1 - y3).norm2();

    Out::root() << "|y1-y3| = " << err << std::endl;
    return checkTest(composedSpec_, err, "operator composition");
  }
  Out::root() << "skipping operator composition test..." << std::endl;
  return true;
}
Esempio n. 6
0
inline bool MatrixMatrixTester<Scalar>
::sumTest() const 
{
  if (sumSpec_.doTest())
  {
    /* skip incompatible matrices. This will occur when we're testing
     * multiplication of rectangular matrices */
    if (A_.range() != B_.range() || A_.domain() != B_.domain())
    {
      Out::root() << "skipping sum on incompatible matrices" << std::endl;
      return true;
    }
    /* If here, the sum should work */
    Out::root() << "running matrix-matrix multiply test..." << std::endl;
    LinearOperator<Scalar> implicitAdd = A_ + B_;
    LinearOperator<Scalar> explicitAdd = epetraMatrixMatrixSum(A_, B_);

    Vector<Scalar> x = B_.domain().createMember();
    randomizeVec(x);
    Out::root() << "computing implicit sum y1 = (A+B)*x..." << std::endl;
    Vector<Scalar> y1 = implicitAdd*x;
    Out::root() << "computing explicit sum y2 = (A+B)*x..." << std::endl;
    Vector<Scalar> y2 = explicitAdd*x;

    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;
    return checkTest(prodSpec_, err, "matrix-matrix multiply");
    
  }
  Out::root() << "skipping matrix-matrix multiply test..." << std::endl;
  return true;
}
Esempio n. 7
0
inline bool MatrixMatrixTester<Scalar>
::diagTest() const 
{
  if (diagSpec_.doTest())
  {
    Vector<Scalar> x = B_.domain().createMember();
    Vector<Scalar> d = B_.domain().createMember();
    randomizeVec(x);
    randomizeVec(d);
    LinearOperator<Scalar> D0 = diagonalOperator(d);
    LinearOperator<Scalar> D = makeEpetraDiagonalMatrix(d);
    Vector<Scalar> d1 = getEpetraDiagonal(D);

    Out::root() << "computing implicit product y1 = D*x..." << std::endl;
    Vector<Scalar> y1 = D0*x;
    Out::root() << "computing explicit product y2 = D*x..." << std::endl;
    Vector<Scalar> y2 = D*x;

    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;
    
    Out::root() << "comparing recovered and original diagonals" << std::endl;
    ScalarMag err2 = (d - d1).norm2();
    Out::root() << "|d1-d2| = " << err2 << std::endl;
    
    return checkTest(prodSpec_, err+err2, "matrix-matrix multiply");
    
  }
  Out::root() << "skipping matrix-matrix multiply test..." << std::endl;
  return true;
}
Esempio n. 8
0
void various_tests() {
	printf("Finished initializing\n");
		checkTest();
		illegal_move_test();
		test_get_legal_moves();
		 make_test_suite();
		see_test_suite();

		check_test();
		isLegal_test();
		eval_test();

		run_perft_test();
	    check_evasion_test();
	    hash_test();

		do_eval();

		//bookTest();

}
Esempio n. 9
0
bool SundanceGlobal:: passFailTest(double error, double tol)
{
  MPIComm::world().synchronize();
  bool pass;
  if (MPIComm::world().getRank()==0)
  {
    cout << "error norm = " << error << std::endl;
    cout << "tolerance = " << tol << std::endl;
  }
  pass = checkTest(error, tol);
  if (MPIComm::world().getRank()==0)
  {
    if (pass)
    {
      cout << "test PASSED" << std::endl;
    }
    else
    {
      cout << "test FAILED" << std::endl;
    }
  }
  testStatus() = pass!=true;
  return pass;
}
Esempio n. 10
0
inline bool CompoundTester<Scalar>
::sumTest() const 
{
  if (sumSpec_.doTest())
  {
    Out::root() << "running operator addition test..." << std::endl;
    LinearOperator<Scalar> sum = A_ + B_;

    Vector<Scalar> x = A_.domain().createMember();
    randomizeVec(x);
    Out::root() << "computing y1 = (A+B)*x..." << std::endl;
    Vector<Scalar> y1 = sum*x;
    Out::root() << "computing y2 = A*x + B*x..." << std::endl;
    Vector<Scalar> y2 = A_*x + B_*x;
    
    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;
        
    return checkTest(sumSpec_, err, "operator addition");
  }
  Out::root() << "skipping operator addition test..." << std::endl;
  return true;
}
Esempio n. 11
0
inline bool MatrixMatrixTester<Scalar>
::prodTest() const 
{
  if (prodSpec_.doTest())
  {
    Out::root() << "running matrix-matrix multiply test..." << std::endl;
    LinearOperator<Scalar> composed = A_ * B_;
    LinearOperator<Scalar> multiplied = epetraMatrixMatrixProduct(A_, B_);

    Vector<Scalar> x = B_.domain().createMember();
    randomizeVec(x);
    Out::root() << "computing implicit product y1 = (A*B)*x..." << std::endl;
    Vector<Scalar> y1 = composed*x;
    Out::root() << "computing explicit product y2 = (A*B)*x..." << std::endl;
    Vector<Scalar> y2 = multiplied*x;

    ScalarMag err = (y1 - y2).norm2();

    Out::root() << "|y1-y2| = " << err << std::endl;
    return checkTest(prodSpec_, err, "matrix-matrix multiply");
  }
  Out::root() << "skipping matrix-matrix multiply test..." << std::endl;
  return true;
}
Esempio n. 12
0
void TestController::traverseTestSuite(TestSuite* testSuite)
{
    auto scheduler = _director->getScheduler();
    int testIndex = 0;
    float testCaseDuration = 0.0f;
    _logIndentation += LOG_INDENTATION;
    logEx("%s%sBegin traverse TestSuite:%s", LOG_TAG, _logIndentation.c_str(), testSuite->getTestName().c_str());

    _logIndentation += LOG_INDENTATION;
    testSuite->_currTestIndex = -1;

    auto logIndentation = _logIndentation;
    for (auto& callback : testSuite->_testCallbacks)
    {
        auto testName = testSuite->_childTestNames[testIndex++];
        
        Scene* testScene = nullptr;
        TestCase* testCase = nullptr;
        TransitionScene* transitionScene = nullptr;

        if (_stopAutoTest) break;

        while (_isRunInBackground)
        {
            logEx("_director is paused");
            _sleepCondition.wait_for(*_sleepUniqueLock, std::chrono::milliseconds(500));
        }
        //Run test case in the cocos[GL] thread.
        scheduler->performFunctionInCocosThread([&, logIndentation, testName](){
            if (_stopAutoTest) return;
            logEx("%s%sRun test:%s.", LOG_TAG, logIndentation.c_str(), testName.c_str());

            auto scene = callback();
            if (_stopAutoTest) return;

            if (scene)
            {
                transitionScene = dynamic_cast<TransitionScene*>(scene);
                if (transitionScene)
                {
                    testCase = (TestCase*)transitionScene->getInScene();
                    testCaseDuration = transitionScene->getDuration() + 0.5f;
                }
                else
                {
                    testCase = (TestCase*)scene;
                    testCaseDuration = testCase->getDuration();
                }
                testSuite->_currTestIndex++;
                testCase->setTestSuite(testSuite);
                testCase->setTestCaseName(testName);
                testCase->setAutoTesting(true);
                _director->replaceScene(scene);

                testScene = scene;
            }
        });

        if (_stopAutoTest) break;

        //Wait for the test case be created.
        float waitTime = 0.0f;
        while (!testScene && !_stopAutoTest)
        {
            _sleepCondition.wait_for(*_sleepUniqueLock, std::chrono::milliseconds(50));
            if (!_isRunInBackground)
            {
                waitTime += 0.05f;
            }

            if (waitTime > CREATE_TIME_OUT)
            {
                logEx("%sCreate test %s time out", LOG_TAG, testName.c_str());
                _stopAutoTest = true;
                break;
            }
        }

        if (_stopAutoTest) break;

        //Wait for test completed.
        _sleepCondition.wait_for(*_sleepUniqueLock, std::chrono::milliseconds(int(1000 * testCaseDuration)));

        if (transitionScene == nullptr)
        {
            waitTime = 0.0f;
            while (!_stopAutoTest && testCase->isAutoTesting())
            {
                _sleepCondition.wait_for(*_sleepUniqueLock, std::chrono::milliseconds(50));
                if (!_isRunInBackground)
                {
                    waitTime += 0.05f;
                }

                if (waitTime > TEST_TIME_OUT)
                {
                    logEx("%sRun test %s time out", LOG_TAG, testName.c_str());
                    _stopAutoTest = true;
                    break;
                }
            }

            if (!_stopAutoTest)
            {
                //Check the result of test.
                checkTest(testCase);
            }
        }
    }

    if (!_stopAutoTest)
    {
        //Backs up one level and release TestSuite object.
        auto parentTest = testSuite->_parentTest;
        scheduler->performFunctionInCocosThread([parentTest](){
            parentTest->runThisTest();
        });

        _sleepCondition.wait_for(*_sleepUniqueLock, std::chrono::milliseconds(1000));
        testSuite->release();
    }

    _logIndentation.erase(_logIndentation.rfind(LOG_INDENTATION));
    _logIndentation.erase(_logIndentation.rfind(LOG_INDENTATION));
}
Esempio n. 13
0
File: sim.c Progetto: seth4618/bbsim
int main(int argc, char** argv)
{
   // save argv, argc for initialization of GLUT
   char** orig_argv = argv;
   int    orig_argc = argc;
   bool   configured = false;
   bool   graphics = true;
   char* port = "5000";

   --argc;
   progname = *argv++;
   while (argc > 0 && (argv[0][0] == '-')) {
      switch (argv[0][1]) {
      case 'c':
    	  if (configured)
    		  help();
	  configFile = argv[1];
    	  argc--;  argv++;
    	  configured = true;
    	  break;
      case 'p':
	port = argv[1];
    	  argc--;  argv++;
	  break;

      case 'i':
	stopwhenidle = atoi(argv[1]);
    	  argc--;  argv++;
          break;
      case 'd':
    	  debug = true;
          break;
      case 't':
	graphics = false;
	testfile = argv[1];
    	  argc--;  argv++;
          break;
      case 'n':
   	  graphics = false;
    	  break;
      case 'D':
   	  vmUseThreads = false;
    	  break;
      case 'r':
    	  if (configured) help();
	  configCount = 0;
    	  configured = true;
    	  break;
      case 'R':
    	  if (configured) help();
	  configCount = atoi(argv[1]);
    	  argc--;  argv++;
    	  configured = true;
    	  break;
      default:
    	  help();
      }
      argc--; argv++;
   }

   if (debug) fprintf(stdout, "initial configuration\n");

   // start timer
   
   initTimeKeeping();

   // vm initialization
   vmInit(port);
   fprintf(stderr, "Listening on %s\n", port);
   if (vmUseThreads) msg2vm(NULL, CMD_MODE_ND, 0);

   // create blocklist and initialize mutex
   initBlockList();

   // see if we are running a test
   if (testfile) configured = configtest(testfile);

   if (!configured) {
     help();
   } else {
     if (configFile != NULL)
       readConfig(configFile);
     else
       randomConfig(configCount);
   }

   if (graphics) {
     // initialize viewer
     viewer_init(orig_argc, orig_argv);

     // GL loop indefinitely
     event_loop();
   } else {
     fprintf(stderr, "Running without graphics\n");
     int idle = 0;
     while (1) {
       Block *block;
       sleep(1);
       int changes = 0;
       ForEachBlock(block) {
	 if (block->msgTargetsDelta > 0) changes++;
       }
       if (changes == 0) {
	 idle++;
	 if ((stopwhenidle > 0) && (idle > stopwhenidle)) {
	   printf("All Done\n");
	   msg2vm(NULL, STOP, 0);
	 }
	 continue;
       }
       idle = 0;
       fprintf(stderr, "\n---- %d\n", changes);

       // something changed
       ForEachBlock(block) {
	 if (block->msgTargetsDelta > 0) {
	   block->msgTargets += block->msgTargetsDelta;
	   block->msgTargetsDelta = 0;
	   showBlock(stderr, block);
	 }
	 if (checkTest(0)) {
	   msg2vm(NULL, STOP, 0);
	 }
       }
       fprintf(stderr, "\n");
     }
   }

   // we are all done
   return 0;
}
Esempio n. 14
0
QueryToolBar::QueryToolBar(QWidget *parent)
	: QToolBar(parent)
{
    m_levels = QtLog::All;

	m_offButton = new QToolButton(this);
	this->addWidget(m_offButton);
    m_offButton->setIcon(QIcon(":/level_off.png"));
	connect(m_offButton, SIGNAL(clicked()), this, SLOT(setLevelOff()));

	this->addSeparator();

	m_fatalButton = new QToolButton(this);
	m_fatalButton->setCheckable(true);
	m_fatalButton->setChecked(true);
	this->addWidget(m_fatalButton);
    m_fatalButton->setIcon(QIcon(":/level_fatal.png"));
	connect(m_fatalButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	m_errorButton = new QToolButton(this);
	m_errorButton->setCheckable(true);
	m_errorButton->setChecked(true);
	this->addWidget(m_errorButton);
    m_errorButton->setIcon(QIcon(":/level_error.png"));
	connect(m_errorButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	m_warnButton = new QToolButton(this);
	m_warnButton->setCheckable(true);
	m_warnButton->setChecked(true);
	this->addWidget(m_warnButton);
    m_warnButton->setIcon(QIcon(":/level_warn.png"));
	connect(m_warnButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	m_infoButton = new QToolButton(this);
	m_infoButton->setCheckable(true);
	m_infoButton->setChecked(true);
	this->addWidget(m_infoButton);
    m_infoButton->setIcon(QIcon(":/level_info.png"));
	connect(m_infoButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	m_debugButton = new QToolButton(this);
	m_debugButton->setCheckable(true);
	m_debugButton->setChecked(true);
	this->addWidget(m_debugButton);
    m_debugButton->setIcon(QIcon(":/level_debug.png"));
	connect(m_debugButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	m_traceButton = new QToolButton(this);
	m_traceButton->setCheckable(true);
	m_traceButton->setChecked(true);
	this->addWidget(m_traceButton);
    m_traceButton->setIcon(QIcon(":/level_trace.png"));
	connect(m_traceButton, SIGNAL(clicked()), this, SLOT(checkTest()));

	this->addSeparator();

	m_allButton = new QToolButton(this);
	this->addWidget(m_allButton);
    m_allButton->setIcon(QIcon(":/level_all.png"));
	connect(m_allButton, SIGNAL(clicked()), this, SLOT(setLevelAll()));

	this->addSeparator();

	m_executeButton = new QToolButton(this);
	this->addWidget(m_executeButton);
    m_executeButton->setIcon(QIcon(":/execute.png"));
    connect(m_executeButton, SIGNAL(clicked()), this, SLOT(execute()));
}