コード例 #1
0
ファイル: MeshConvDriver.C プロジェクト: gitter-badger/quinoa
void
MeshConvDriver::execute() const
//******************************************************************************
//  Execute: Convert mesh file
//! \author J. Bakosi
//******************************************************************************
{
  std::pair< std::string, tk::real > rtime, wtime;
  tk::writeUnsMesh( m_output, tk::readUnsMesh(m_input,rtime), wtime );
  mainProxy.timestamp( { rtime, wtime } );
  mainProxy.finalize();
}
コード例 #2
0
ファイル: broadcast.C プロジェクト: davidheryanto/sc14
  void receive(broadcastMessage* m) {

    CkPrintf("Message: %s arrived at element %d\n", m->msg, CkMyPe());
    assert(strcmp(m->msg,"|This is a short broadcast message|") == 0);
    mainProxy.exit();
  
  }
コード例 #3
0
ファイル: RegSuite.C プロジェクト: gitter-badger/quinoa
void
RegSuite::evaluate( std::vector< std::string > status )
//******************************************************************************
// Evaluate a unit test
//! \param[in] status Vector strings containing the test results.
//! \author J. Bakosi
//******************************************************************************
{
  // Increase number of tests run
  ++m_nrun;

  // Evaluate test
  evaluate( status, m_ncomplete, m_nwarn, m_nskip, m_nexcp, m_nfail );

  // Echo one-liner info on result of test
  m_print.test( m_ncomplete, m_nfail, status );

  // Wait for all tests to finish, then quit
  if (m_nrun == m_ntest)
  {
//     assess( m_print, "serial and Charm++", m_nfail, m_nwarn, m_nskip, m_nexcp,
//             m_ncomplete );
    // Quit
    mainProxy.finalize( true );
  }
}
コード例 #4
0
ファイル: TestU01Suite.C プロジェクト: gitter-badger/quinoa
void
TestU01Suite::assess()
//******************************************************************************
// Output final assessment
//! \author  J. Bakosi
//******************************************************************************
{
  // Output summary of failed tests for all RNGs tested
  if ( !m_failed.empty() ) {
    const auto rngs = g_inputdeck.get< tag::selected, tag::rng >();
    m_print.failed( "Failed statistics", m_npval*rngs.size(), m_failed );
  } else m_print.note< tk::QUIET >( "All tests passed" );

  // Cost and quality assessment only for more than one RNG
  if (m_time.size() > 1) {
    // Output measured times per RNG in order of computational cost
    m_print.cost( "Generator cost",
                  "Measured times in seconds in increasing order (low is good)",
                  m_time );
    // Output number of failed tests per RNG in order of decreasing quality
    m_print.rank( "Generator quality",
                  "Number of failed tests in increasing order (low is good)",
                  m_nfail );
  }

  // Quit
  mainProxy.finalize();
}
コード例 #5
0
ファイル: parallelJacobi.C プロジェクト: luyukunphy/namd
void Chunk::testEnd(){

    if(iterations == ITER)  {
        globalMainProxy.finished();
    }

}
コード例 #6
0
ファイル: broadcast.C プロジェクト: davidheryanto/sc14
  void IntermediateCall() {

    CkPrintf("Intermediate %d of %d \n", CkMyPe(), CkNumPes());
    //CkPrintf("Message: %s arrived at element %d\n", m->msg, CkMyPe());
   // assert(strcmp(m->msg,"|This is a short broadcast message|") == 0);
    mainProxy.Intermediate();
  }
コード例 #7
0
ファイル: test_alltoall.C プロジェクト: DISLab/xcharm
		void reportInitializationCompletion() {
			if (++completed == N_uChareSets) {
				CkPrintf("Main: initialization completed (distributed graph created)\n");
				CkPrintf("Main: run calculations...\n");
				completed = 0;
				mainProxy.run();
			}
		}
コード例 #8
0
ファイル: test_alltoall.C プロジェクト: DISLab/xcharm
		void ping(int callee) { 
			//CkPrintf("[chare=%d,pe=%d]: %d: ping called by %d\n", 
			//		getuChareSet()->getId(), getuChareSet()->getPe(), getId(), callee);
			if (++counter == N_uChares) {
				//CkPrintf("[chare=%d,pe=%d]: %d: alltoall done\n", 
				//		getuChareSet()->getId(), getuChareSet()->getPe(), getId());
				mainProxy.done();
			}
		}
コード例 #9
0
ファイル: hello.C プロジェクト: davidheryanto/sc14
 void SayHi(int hiNo)
 {
   CkPrintf("Hi[%d] from element %d\n",hiNo,thisIndex);
   if (thisIndex < nElements-1)
     //Pass the hello on:
     thisProxy[thisIndex+1].SayHi(hiNo+1);
   else 
     //We've been around once-- we're done.
     mainProxy.done();
 }
コード例 #10
0
ファイル: RegSuite.C プロジェクト: gitter-badger/quinoa
RegSuite::RegSuite( const ctr::CmdLine& cmdline ) :
  m_print( cmdline.get< tag::verbose >() ? std::cout : std::clog ),
  m_ntest( 0 ),
  m_nrun( 0 ),
  m_ncomplete( 0 ),
  m_nfail( 0 ),
  m_nskip( 0 ),
  m_nwarn( 0 ),
  m_nexcp( 0 )
//******************************************************************************
// Constructor
//! \param[in] cmdline Data structure storing data from the command-line parser
//! \author J. Bakosi
//******************************************************************************
{
  // Get group name string passed in by -g
  const auto grp = cmdline.get< tag::group >();

  // If only select groups to be run, see if there is any that will run
  bool work = false;
  if (grp.empty())
    work = true;
  else
    work = true;        // for now there is always work

  // Quit if there is no work to be done
  if (!work) {

    m_print.note( "\nNo regression test groups to be executed because no test "
                  "group names match '" + grp + "'.\n" );
    mainProxy.finalize( false );

  } else {

    m_print.endpart();
    m_print.part( "Regression test suite" );
    m_print.reghead( "Regression tests computed", grp );

    // Fire up all tests using the Charm++ runtime system
    const std::vector< std::string > tests {
      "./charmrun +p1 Main/unittest -g Exc",
      "./charmrun +p2 Main/unittest -g MKL",
      "./charmrun +p3 Main/unittest -g MPI",
      "./charmrun +p4 Main/unittest"
    };
    for (const auto& t : tests)
      if (grp.empty()) {                        // consider all test groups
        spawntest( t );
      } else if (t.find(grp) != std::string::npos) {
        // spawn only the tests that match the string specified via -g string
        spawntest( t );
      }

  }
}
コード例 #11
0
ファイル: hello.C プロジェクト: davidheryanto/sc14
 void SayHi(int hiNo)
 {
   CkPrintf("Hi[%d] from element %d\n",hiNo,thisIndex);
   CProxy_Hello delArr=arr;
   delArr.ckDelegate(delMgr.ckLocalBranch());
   if (thisIndex < nElements-1)
     //Pass the hello on:
     delArr[thisIndex+1].SayHi(hiNo+1);
   else 
     //We've been around once-- we're done.
     mainProxy.done();
 }
コード例 #12
0
ファイル: hello.C プロジェクト: brog2610/quinoa
  void SayHi2(int hiNo)
  {
    CkPrintf("Hi 2 [%d] from element (%d,%d,%d)\n",hiNo,
	thisIndex.x,thisIndex.y,thisIndex.z);
    int y=thisIndex.y+1;
    if (y < nElements) {
      //Pass the hello on:
      thisProxy(37,y,2*y+1).SayHi2(hiNo+1);
    }
    else 
      //We've been around once-- we're done.
      mainProxy.done();
  }
コード例 #13
0
ファイル: MeshConvDriver.C プロジェクト: brog2610/quinoa
void
MeshConvDriver::execute() const
// *****************************************************************************
//  Execute: Convert mesh file
//! \author J. Bakosi
// *****************************************************************************
{
  m_print.endsubsection();

  std::vector< std::pair< std::string, tk::real > > times( 1 );

  auto mesh = tk::readUnsMesh( m_print, m_input, times[0] );
  auto wtimes = tk::writeUnsMesh( m_print,
                                  m_output,
                                  mesh,
                                  m_reorder );

  times.insert( end(times), begin(wtimes), end(wtimes) );
  mainProxy.timestamp( times );

  mainProxy.finalize();
}
コード例 #14
0
    void check_and_compute() {
	    float timeToCompute = CmiWallTimer();
       if (messages_due == 0 && hasSent) {
          messages_due = 4;
          hasSent=false;
          compute();
          int currPe = CkMyPe();
          //ckout << "iter=" << itercnt << ": (" << thisIndex.x << "," << thisIndex.y << ") reporting pe " << CkMyPe() << endl;
          mainProxy.report(thisIndex.x, thisIndex.y, CkMyPe(), CmiWallTimer()-timeToCompute);
          if (itercnt == LDB_ITER) {
            //ckout << "iter=" << itercnt << ": AtSync reported from " << CkMyPe() << endl;
            AtSync();
          }
        }
    }
コード例 #15
0
Slave::Slave() {
	/* ==> read-only variables set by the main chare
	k = kInput;
	thresh = threshInput;
	max_level = 30;

	*/
	CkPrintf("Constructor of the Slave chare # %d is called on processor %d.\n", thisIndex, CkMyPe());

	int n = (int) log2(numProcesses);
	int l = thisIndex;

	Function *function = new Function(n, l, k, thresh, test1);

	mainProxy.done_refine();
}
コード例 #16
0
ファイル: Conductor.C プロジェクト: brog2610/quinoa
void
Conductor::finish()
// *****************************************************************************
// Normal finish of time stepping
//! \author J. Bakosi
// *****************************************************************************
{
  // Print out reason for stopping
  const auto nstep = g_inputdeck.get< tag::discr, tag::nstep >();
  m_print.endsubsection();
  if (m_it >= nstep)
     m_print.note( "Normal finish, maximum number of iterations reached: " +
                   std::to_string( nstep ) );
   else
     m_print.note( "Normal finish, maximum time reached: " +
                   std::to_string( g_inputdeck.get<tag::discr,tag::term>() ) );

  // Quit
  mainProxy.finalize();
}
コード例 #17
0
ファイル: eachtomany.C プロジェクト: davidheryanto/sc14
 void receive(eachToManyMessage* m) {
   assert(strcmp(m->msg,"|This is a short each-to-many array message|") == 0);
   delete m;
   mainProxy.exit();
 }
コード例 #18
0
ファイル: RegTest.C プロジェクト: gitter-badger/quinoa
//! \brief Charm++ chare execute
//! \details By the time this object is constructed, the Charm++ runtime system
//!    has finished migrating all global-scoped read-only objects which happens
//!    after the main chare constructor has finished.
//! \author J. Bakosi
struct execute : CBase_execute { execute() { mainProxy.execute(); } };
コード例 #19
0
ファイル: main.C プロジェクト: earlofgrey91091/RTCharm
Main::Main(CkArgMsg* arg) 
{
    __sdag_init();
    iterations = 0;
    //Process command-line arguments
    if( arg->argc == 5 )
    { 
        image_w = atoi(arg->argv[1]);
        image_h = atoi(arg->argv[2]);
        chareDimension = atoi(arg->argv[3]);
        numShapes = atoi(arg->argv[4]);
        
        //force fit inputs
        image_w -= image_w % chareDimension;
        image_h -= image_h % chareDimension;
        if(image_w == 0 || image_h == 0)
        {
            CkPrintf("Invalid image size\n");
            CkExit();
        }

        CkPrintf("\npicture will be %d pixels in height,\n", image_h);
        CkPrintf("picture will be %d pixels in width,\n", image_w);
        CkPrintf("there will be %d cells\n", chareDimension * chareDimension);
        CkPrintf("there will be %d shapes\n", numShapes);
    }
    else
    {
        image_w = LIMIT;
        image_h = LIMIT;
        chareDimension = DEFAULT_CHAREDIM;
        numShapes = DEFAULT_SHAPES; //misnameed need fix
        CkPrintf("\npicture will be %d pixels in height,\n", image_h);
        CkPrintf("picture will be %d pixels in width,\n", image_w);
        CkPrintf("there will be %d cells\n", chareDimension * chareDimension);
        CkPrintf("there will be %d shapes\n", numShapes);
    }
    delete arg;

    CkArrayOptions opts(chareDimension, chareDimension);
    myOpts = opts;
    

    lightSrc l(1.0, 1.0, 1.0, 0.0, image_h/2, -100.0);
    lightSrc l1(1.0, 0.5, 0.5, image_w/2, 0.0, -10000.0);
    myLights.push_back(l);
    myLights.push_back(l1);
    //positive z is going twards the viewer
    // positive x is 
    float zdiff = 0; //70
    //vec3d v0(268.0, 178.0, 276.0), v1( 178.0,268.0, 276.0 - zdiff), v2(268.0,268.0, 276.0 - zdiff*1.5), mod(-50, -50, 90);
    //vec3d v0(0.0, 0.0, 0), v1( -100.0,0.0, 0 -zdiff), v2(0.0,100.0, 0 - zdiff*1.5), 
    vec3d mod(-50, -50, 90);

    vec3d v0(-1.000000, -1.000000, 1.000000);
    vec3d v1(-1.000000, 1.000000, 1.000000);
    vec3d v2(1.000000, 1.000000, 1.000000);
    vec3d v3(1.000000, -1.000000, 1.000000);
    vec3d v4(-1.000000, -1.000000, -1.000000);
    vec3d v5(-1.000000, 1.000000, -1.000000);
    vec3d v6(1.000000, 1.000000, -1.000000);
    vec3d v7(1.000000, -1.000000, -1.000000);

    double rx = 0.75000;
    double ry = -0.5000;
    double rz = 0.0000; 

    // < numShapes
    for(int i = 0; i < 1 ; i++) //numShapes
    {
        
	    //Shape s(v0, v1, v2, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
	    //myShapes.push_back(s);
            //Shape s = Shape(v4, v7, v6, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    	    //s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); myShapes.push_back(s);
	    //s = Shape(v6, v5, v4, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
            //s.rot_x(rx); s.rot_y(ry); myShapes.push_back(s);
	    // v0+=mod; v1+=mod; v2+=mod;
	    //break;
	            
    }
    

   /*
    vec3d v0(-1.000000, -1.000000, 1.000000);
    vec3d v1(-1.000000, 1.000000, 1.000000);
    vec3d v2(1.000000, 1.000000, 1.000000);
    vec3d v3(1.000000, -1.000000, 1.000000);
    vec3d v4(-1.000000, -1.000000, -1.000000);
    vec3d v5(-1.000000, 1.000000, -1.000000);
    vec3d v6(1.000000, 1.000000, -1.000000);
    vec3d v7(1.000000, -1.000000, -1.000000);
    
    double rx = 0.75000;
    double ry = -0.5000;
    double rz = 0.0000;
    */
    //Shape s; 
    Shape s = Shape(v4, v7, v6, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    /*s = Shape(v6, v5, v4, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v0, v3, v2, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v2, v1, v0, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v4, v0, v1, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v1, v5, v4, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v7, v3, v2, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v2, v6, v7, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v7, v3, v0, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v0, v4, v7, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v6, v2, v1, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    s = Shape(v1, v5, v6, vec3d(0.3, 0.4, 0.5), vec3d(0.3775, 0.3775, 0.5775), vec3d(0.911, 0.911, 0.911), 0.0);
    s.rot_x(rx); s.rot_y(ry); s.rot_z(rz); 
    myShapes.push_back(s);
    */

    /*
    if(MOVE_SHAPE)
    {
        for (int i=0; i<myShapes.size(); i++)
        {
            vec3d d(drand48()*10*pow(-1.0, i));
            shapeDirection.push_back(d);
        }
    }*/
    //Create the image pixel chares based on image size
    pixel = CProxy_PixelChare::ckNew(image_w/chareDimension, 
                                        image_h/chareDimension, opts);
    CkPrintf("\nEach chare will have (%d * %d) pixels \n", 
                image_w/chareDimension, image_h/chareDimension);
    CkPrintf("MyShapes.size() = %d", myShapes.size());
    startVis();
    pixel.startStep(myShapes, myLights);
    mainProxy.run();
}
コード例 #20
0
ファイル: par_Solver.C プロジェクト: brog2610/quinoa
bool mySolver::seq_solve(par_SolverState* state_msg)
{
    /* Which variable get assigned  */
    par_Lit lit = state_msg->assigned_lit;
       
#ifdef DEBUG
    CkPrintf("\n\n Computes=%d Sequential SAT New chare: literal = %d,  level=%d, unsolved clauses=%d\n", computes++, toInt(assigned_var), state_msg->level, state_msg->clauses.size());
    //CkPrintf("\n\n Computes=%d Sequential SAT New chare: literal = %d, occurrence size=%d, level=%d \n", computes++, toInt(assigned_var), state_msg->occurrence.size(), state_msg->level);
#endif
    par_SolverState *next_state = copy_solverstate(state_msg);
    
    //Unit clauses
    /* use this value to propagate the clauses */
#ifdef DEBUG
    CkPrintf(" remainning clause size is %d\n", (state_msg->clauses).size());
#endif

    int _unit_ = -1;
    while(1){
    int pp_ = 1;
    int pp_i_ = 2;
    int pp_j_ = 1;

    if(toInt(lit) < 0)
    {
        pp_ = -1;
        pp_i_ = 1;
        pp_j_ = 2;
    }

    next_state->occurrence[pp_*toInt(lit)-1] = -pp_i_;
    
    map_int_int &inClauses = next_state->whichClauses[pp_*2*toInt(lit)-pp_i_];
    map_int_int &inClauses_opposite = next_state->whichClauses[pp_*2*toInt(lit)-pp_j_];

    // literal with same sign, remove all these clauses
    
    for( map_int_int::iterator iter = inClauses.begin(); iter!=inClauses.end(); iter++)
    {
        int cl_index = (*iter).first;
        par_Clause& cl_ = next_state->clauses[cl_index];
        //for all the literals in this clauses, the occurrence decreases by 1
        for(int k=0; k< cl_.size(); k++)
        {
            par_Lit lit_ = cl_[k];
            if(toInt(lit_) == toInt(lit))
                continue;
            next_state->occurrence[abs(toInt(lit_)) - 1]--;
            if(toInt(lit_) > 0)
            {
                next_state->positive_occurrence[toInt(lit_)-1]--;
                map_int_int::iterator one_it = next_state->whichClauses[2*toInt(lit_)-2].find(cl_index);
                next_state->whichClauses[2*toInt(lit_)-2].erase(one_it);
            }else
            {
                map_int_int::iterator one_it = next_state->whichClauses[-2*toInt(lit_)-1].find(cl_index);
                next_state->whichClauses[-2*toInt(lit_)-1].erase(one_it);
            }

        }
        next_state->clauses[cl_index].resize(0);
    }
   
    for(map_int_int::iterator iter= inClauses_opposite.begin(); iter!=inClauses_opposite.end(); iter++)
    {
        int cl_index_ = (*iter).first;
        par_Clause& cl_neg = next_state->clauses[cl_index_];
        cl_neg.remove(-toInt(lit));
            //becomes a unit clause
         if(cl_neg.size() == 1)
         {
             next_state->unit_clause_index.push_back(cl_index_);
         }else if (cl_neg.size() == 0)
         {
                return false;
         }
    }
   
    _unit_++;
    if(_unit_ == next_state->unit_clause_index.size())
        break;
    par_Clause cl = next_state->clauses[next_state->unit_clause_index[_unit_]];
    
    while(cl.size() == 0){
        _unit_++;
        if(_unit_ == next_state->unit_clause_index.size())
            break;
        cl = next_state->clauses[next_state->unit_clause_index[_unit_]];
        
    };

    if(_unit_ == next_state->unit_clause_index.size())
        break;
    
    lit = cl[0];
    }
   
    int unsolved = next_state->unsolvedClauses();
    if(unsolved == 0)
    {
        CkPrintf("One solution found in sequential processing, check the output file for assignment\n");
        mainProxy.done(next_state->occurrence);
        return true;
    }
    
    /**********************/
    
        /* it would be better to insert the unit literal in order of their occurrence */
        /* make a decision and then fire new tasks */
        /* if there is unit clause, should choose these first??? TODO */
        /* TODO which variable to pick up */
        /*unit clause literal and also which occurrs most times */
        int max_index =  get_max_element(next_state->occurrence);
#ifdef DEBUG
        CkPrintf("max index = %d\n", max_index);
#endif
        next_state->level = state_msg->level+1;

        par_SolverState *new_msg2 = copy_solverstate(next_state);;
        
        int positive_max = next_state->positive_occurrence[max_index];
        if(positive_max >= next_state->occurrence[max_index] - positive_max)
        {
            next_state->occurrence[max_index] = -2;
            next_state->assigned_lit = par_Lit(max_index+1);
        }
        else
        {
            next_state->occurrence[max_index] = -1;
            next_state->assigned_lit = par_Lit(-max_index-1);
        } 

        bool   satisfiable_1 = seq_solve(next_state);
        if(satisfiable_1)
        {
            return true;
        }
        
        new_msg2->level = state_msg->level+1;
       
        if(positive_max >= next_state->occurrence[max_index] - positive_max)
        {
            new_msg2->occurrence[max_index] = -1;
            new_msg2->assigned_lit = par_Lit(-max_index-1);
        }
        else
        {
            new_msg2->occurrence[max_index] = -2;
            new_msg2->assigned_lit = par_Lit(max_index+1);
        } 
            
        bool satisfiable_0 = seq_solve(new_msg2);
        if(satisfiable_0)
        {
            return true;
        }

        //CkPrintf("Unsatisfiable through sequential\n");
        return false;

}
コード例 #21
0
ファイル: par_Solver.C プロジェクト: brog2610/quinoa
mySolver::mySolver(par_SolverState* state_msg)
{

    /* Which variable get assigned  */
    par_Lit lit = state_msg->assigned_lit;
#ifdef DEBUG    
    CkPrintf("\n\nNew chare: literal = %d, occurrence size=%d, level=%d \n", toInt(lit), state_msg->occurrence.size(), state_msg->level);
#endif    
    par_SolverState *next_state = copy_solverstate(state_msg);

    //Unit clauses
    /* use this value to propagate the clauses */
    // deal with the clauses where this literal is
    int _unit_ = -1;
    while(1){
        int pp_ = 1;
        int pp_i_ = 2;
        int pp_j_ = 1;

        if(toInt(lit) < 0)
        {
            pp_ = -1;
            pp_i_ = 1;
            pp_j_ = 2;
        }

        next_state->occurrence[pp_*toInt(lit)-1] = -pp_i_;
    

        map_int_int &inClauses = next_state->whichClauses[pp_*2*toInt(lit)-pp_i_];
        map_int_int  &inClauses_opposite = next_state->whichClauses[pp_*2*toInt(lit)-pp_j_];

    // literal with same sign, remove all these clauses
       for( map_int_int::iterator iter = inClauses.begin(); iter!=inClauses.end(); iter++)
       {
           int cl_index = (*iter).first;

           par_Clause& cl_ = next_state->clauses[cl_index];
           //for all the literals in this clauses, the occurrence decreases by 1
           for(int k=0; k< cl_.size(); k++)
           {
               par_Lit lit_ = cl_[k];
               if(toInt(lit_) == toInt(lit))
                   continue;
               next_state->occurrence[abs(toInt(lit_)) - 1]--;
               if(toInt(lit_) > 0)
               {
                   next_state->positive_occurrence[toInt(lit_)-1]--;
                   map_int_int::iterator one_it = next_state->whichClauses[2*toInt(lit_)-2].find(cl_index);
                   next_state->whichClauses[2*toInt(lit_)-2].erase(one_it);
               }else
               {
                   map_int_int::iterator one_it = next_state->whichClauses[-2*toInt(lit_)-1].find(cl_index);
                   next_state->whichClauses[-2*toInt(lit_)-1].erase(one_it);
               }
               
           } //finish dealing with all literal in the clause
           next_state->clauses[cl_index].resize(0);
       } //finish dealing with clauses where the literal occur the same
       /* opposite to the literal */
       for(map_int_int::iterator iter= inClauses_opposite.begin(); iter!=inClauses_opposite.end(); iter++)
       {
           int cl_index_ = (*iter).first;
           par_Clause& cl_neg = next_state->clauses[cl_index_];
           cl_neg.remove(-toInt(lit));

           /*becomes a unit clause */
           if(cl_neg.size() == 1)
           {
               next_state->unit_clause_index.push_back(cl_index_);
           }else if (cl_neg.size() == 0)
           {
               return;
           }
       }

       _unit_++;
       if(_unit_ == next_state->unit_clause_index.size())
           break;
       par_Clause cl = next_state->clauses[next_state->unit_clause_index[_unit_]];

       while(cl.size() == 0){
           _unit_++;
           if(_unit_ == next_state->unit_clause_index.size())
               break;
           cl = next_state->clauses[next_state->unit_clause_index[_unit_]];
       };

       if(_unit_ == next_state->unit_clause_index.size())
           break;
       lit = cl[0];


    }
    /***************/

    int unsolved = next_state->unsolvedClauses();
    if(unsolved == 0)
    {
        CkPrintf("One solution found in parallel processing \n");
        //next_state->printSolution();
        mainProxy.done(next_state->occurrence);
        return;
    }
    int max_index = get_max_element(next_state->occurrence);
#ifdef DEBUG
    CkPrintf("max index = %d\n", max_index);
#endif
    //if() left literal unassigned is larger than a grain size, parallel 
    ///* When we start sequential 3SAT Grainsize problem*/
   
    /* the other branch */
    par_SolverState *new_msg2 = copy_solverstate(next_state);;

    next_state->level = state_msg->level+1;

    int lower = state_msg->lower;
    int higher = state_msg->higher;
    int middle = (lower+higher)/2;
    int positive_max = next_state->positive_occurrence[max_index];
    if(positive_max >= next_state->occurrence[max_index] - positive_max)
    {
        next_state->assigned_lit = par_Lit(max_index+1);
        next_state->occurrence[max_index] = -2;
    }
    else
    {
        next_state->assigned_lit = par_Lit(-max_index-1);
        next_state->occurrence[max_index] = -1;
    }
    bool satisfiable_1 = true;

    if(unsolved > grainsize)
    {
        next_state->lower = lower + 1;
        next_state->higher = middle;
        *((int *)CkPriorityPtr(next_state)) = lower+1;
        CkSetQueueing(next_state, CK_QUEUEING_IFIFO);
        CProxy_mySolver::ckNew(next_state);
    }
    else //sequential
    {
        /* This code is urgly. Need to revise it later. Convert par data structure to sequential 
         */
        vector< vector<int> > seq_clauses;
        //seq_clauses.resize(next_state->clauses.size());
        for(int _i_=0; _i_<next_state->clauses.size(); _i_++)
        {
            if(next_state->clauses[_i_].size() > 0)
            {
                vector<int> unsolvedclaus;
                par_Clause& cl = next_state->clauses[_i_];
                unsolvedclaus.resize(cl.size());
                for(int _j_=0; _j_<cl.size(); _j_++)
                {
                    unsolvedclaus[_j_] = toInt(cl[_j_]);
                }
                seq_clauses.push_back(unsolvedclaus);
            }
        }
        satisfiable_1 = seq_processing(next_state->var_size, seq_clauses);//seq_solve(next_state);
        if(satisfiable_1)
        {
            CkPrintf("One solution found by sequential processing \n");
            mainProxy.done(next_state->occurrence);
            return;
        }
    }

    new_msg2->level = state_msg->level+1;
    if(positive_max >= new_msg2->occurrence[max_index] - positive_max)
    {
        new_msg2->assigned_lit = par_Lit(-max_index-1);
        new_msg2->occurrence[max_index] = -1;
    }
    else
    {
        new_msg2->assigned_lit = par_Lit(max_index+1);
        new_msg2->occurrence[max_index] = -2;
    }
    unsolved = new_msg2->unsolvedClauses();
    if(unsolved > grainsize)
    {
        new_msg2->lower = middle + 1;
        new_msg2->higher = higher-1;
        *((int *)CkPriorityPtr(new_msg2)) = middle+1;
        CkSetQueueing(new_msg2, CK_QUEUEING_IFIFO);
        CProxy_mySolver::ckNew(new_msg2);
    }
    else
    {
       
        vector< vector<int> > seq_clauses;
        for(int _i_=0; _i_<new_msg2->clauses.size(); _i_++)
        {
            par_Clause& cl = new_msg2->clauses[_i_];
            if(cl.size() > 0)
            {
                vector<int> unsolvedclaus;
                unsolvedclaus.resize(cl.size());
                for(int _j_=0; _j_<cl.size(); _j_++)
                {
                    unsolvedclaus[_j_] = toInt(cl[_j_]);
                }
                seq_clauses.push_back(unsolvedclaus);
            }
        }

        bool ret = seq_processing(new_msg2->var_size,  seq_clauses);//seq_solve(next_state);
        //bool ret = Solver::seq_processing(new_msg2->clauses);//seq_solve(new_msg2);
        if(ret)
        {
            CkPrintf("One solution found by sequential processing \n");
            mainProxy.done(new_msg2->occurrence);
        }
        return;
    }

}
コード例 #22
0
ファイル: Inciter.C プロジェクト: quinoacomputing/quinoa
 execute() {
     mainProxy.execute();
 }
コード例 #23
0
ファイル: RNGTest.C プロジェクト: brog2610/quinoa
 public: execute() { mainProxy.execute(); }
コード例 #24
0
ファイル: jacobi2d.C プロジェクト: gitter-badger/quinoa
  // Each worker reports back to here when it completes an iteration
  void report (CkReductionMsg *msg)
  {
    recieve_count++;
    double totaltime = CkWallTimer () - startTime;
//    printf("coming in report--------------------------------------------- rec=%d\n",recieve_count);
    if (2 == recieve_count)
//      if(minElements+1 == recieve_count)
      {
	if (iterations == total_iterations)
	  {
	    CkPrintf
	      ("Completed %d iterations; last iteration time: %.6lf total time=%f\n",
	       iterations, totaltime, CkWallTimer () - start);
//	    CkExit ();
		mainProxy.exiting();
	  }
	else
	  {
if(iterations==1) useThisCriticalPathForPriorities();
	    if (iterations % 1 == 0)
	      {
		char tempArr[50];
		for (int x = 0; x < 50; x++)
		  tempArr[x] = 0;
		float avg = 0;
		for (int pe = 0; pe < CkNumPes (); pe++)
		  {
		    sprintf (tempArr + strlen (tempArr), "%d ",
			     (int) getTemp (pe));
		    avg += getTemp (pe);
		    //if(gmaxTemp<stats->procs[pe].pe_temp) gmaxTemp=stats->procs[pe].pe_temp;
		  }
		avg /= CkNumPes ();
		CkPrintf
		  ("starting new iteration; iteration %d time: %.6lf AVG=%.6lf\n",
		   iterations, totaltime, avg);
		//printf("********* iteration=%d AVG temp=%f **********\n",iterations,avg);
//                      sprintf(tempArr,"%d %f",iterations,avg);
		// printf("temps=%s\n",tempArr);
		writeTemps (f, tempArr);
//		if (CkMyPe () == 0)
		  freqProxy.measureFreq (iterations, total_iterations);
	      }

//                CkPrintf("starting new iteration; iteration %d time: %.6lf\n", iterations, totaltime);
	    recieve_count = 0;
	    iterations++;
	    // Call begin_iteration on all worker chares in array
	    startTime = CkWallTimer ();
#ifdef PRIOR
	    opts = new CkEntryOptions ();
	    opts1 = new CkEntryOptions ();
	    opts->setPriority (-100);
	    opts1->setPriority (100);

	    array[0].begin_iteration (1, opts);
                for(int i=0;i<7;i++)
                        arrayMin[i].begin_iteration(1,opts1);
//              arrayMin.begin_iteration(1,opts1);              
#else
	    array[0].begin_iteration (1);
	    for (int i = 0; i < 7; i++)
	      arrayMin[i].begin_iteration (1);
#endif

	  }
      }
  }
コード例 #25
0
ファイル: hello.C プロジェクト: luyukunphy/namd
 void SayHi(int hiNo)
 {
   CkPrintf("Hi [%d] from element %d %d %d\n", hiNo, thisIndex.x, thisIndex.y, thisIndex.z);
   mainProxy.done();
 }