示例#1
0
void
ComputeMgr::createComputes(ComputeMap *map)
{
    Node *node = Node::Object();
    SimParameters *simParams = node->simParameters;
    int myNode = node->myid();

    ComputeNonbondedUtil::select();

    if ( simParams->globalForcesOn && !myNode )
    {
        DebugM(4,"Mgr running on Node "<<CkMyPe()<<"\n");
        /* create a master server to allow multiple masters */
        masterServerObject = new GlobalMasterServer(this,
                PatchMap::Object()->numNodesWithPatches());

        /* create the individual global masters */
        // masterServerObject->addClient(new GlobalMasterTest());
        if (simParams->tclForcesOn)
            masterServerObject->addClient(new GlobalMasterTcl());
        if (simParams->IMDon && ! simParams->IMDignore)
            masterServerObject->addClient(new GlobalMasterIMD());

        if (simParams->SMDOn)
            masterServerObject->addClient(
                new GlobalMasterSMD(simParams->SMDk, simParams->SMDk2,
				    simParams->SMDVel,
                                    simParams->SMDDir, simParams->SMDOutputFreq,
                                    simParams->firstTimestep, simParams->SMDFile,
                                    node->molecule->numAtoms)
            );
            
        if (simParams->symmetryOn && 
          (simParams->firstTimestep < simParams->symmetryLastStep || 
          simParams->symmetryLastStep == -1))
            masterServerObject->addClient(new GlobalMasterSymmetry());    
        if (simParams->TMDOn)
            masterServerObject->addClient(new GlobalMasterTMD());
        if (simParams->miscForcesOn)
            masterServerObject->addClient(new GlobalMasterMisc());
        if ( simParams->freeEnergyOn )
            masterServerObject->addClient(new GlobalMasterFreeEnergy());
		if ( simParams->colvarsOn )
			masterServerObject->addClient(new GlobalMasterColvars());

    }

    if ( !myNode && simParams->IMDon && simParams->IMDignore ) {
      // GlobalMasterIMD constructor saves pointer to node->IMDOutput object
      new GlobalMasterIMD();
    }

#ifdef NAMD_CUDA
    bool deviceIsMine = ( cuda_device_pe() == CkMyPe() );
#endif

    // If there is a MIC device, then loop through the computes, flagging each one
    //   to be excuted on either a host or on a device
    #ifdef NAMD_MIC
      bool deviceIsMine = ( mic_device_pe() == CkMyPe() );
      /*
      #if MIC_SPLIT_WITH_HOST != 0
        PatchMap *patchMap = PatchMap::Object();
        int deviceThreshold = (patchMap->numaway_a() + patchMap->numaway_b() + patchMap->numaway_c()) - 2;
        for (int i = 0; i < map->nComputes; i++) {
          switch (map->type(i)) {

            case computeNonbondedSelfType:
              // Direct all non-bonded self computes to the device
              map->setDirectToDevice(i, 1);
              break;

            case computeNonbondedPairType:
              // Direct some non-bonded pair computes to the device, based on the manhattan distance
              {
                int pid0 = map->pid(i, 0);
                int pid1 = map->pid(i, 1);
                int index_a0 = patchMap->index_a(pid0);
                int index_b0 = patchMap->index_b(pid0);
                int index_c0 = patchMap->index_c(pid0);
                int index_a1 = patchMap->index_a(pid1);
                int index_b1 = patchMap->index_b(pid1);
                int index_c1 = patchMap->index_c(pid1);
                int da = index_a0 - index_a1; da *= ((da < 0) ? (-1) : (1));
                int db = index_b0 - index_b1; db *= ((db < 0) ? (-1) : (1));
                int dc = index_c0 - index_c1; dc *= ((dc < 0) ? (-1) : (1));
                int manDist = da + db + dc;
                map->setDirectToDevice(i, ((manDist <= deviceThreshold) ? (1) : (0)));
              }
              break;

            default:
              // All other computes should be directed to the host (flag is ignored, but set it)
              map->setDirectToDevice(i, 0);
              break;

          } // end switch (map->type(i))
        } // end for (i < map->nComputes)
      #endif // MIC_SPLIT_WITH_HOST != 0
      */
    #endif // NAMD_MIC

    for (int i=0; i < map->nComputes; i++)
    {
        if ( ! ( i % 100 ) )
        {
        }
#if defined(NAMD_CUDA) || defined(NAMD_MIC)
        switch ( map->type(i) )
        {
#ifdef NAMD_CUDA
          case computeNonbondedSelfType:
          case computeNonbondedPairType:
            if ( ! deviceIsMine ) continue;
            if ( ! cuda_device_shared_with_pe(map->computeData[i].node) ) continue;
          break;
#endif
#ifdef NAMD_MIC

	  case computeNonbondedSelfType:
            #if MIC_SPLIT_WITH_HOST != 0
              if (map->directToDevice(i)) { // If should be directed to the device...
            #endif
                if ( ! deviceIsMine ) continue;
                if ( ! mic_device_shared_with_pe(map->computeData[i].node) ) continue;
            #if MIC_SPLIT_WITH_HOST != 0
              } else { // ... otherwise, direct to host...
                if (map->computeData[i].node != myNode) { continue; }
	      }
            #endif
            break;

	  case computeNonbondedPairType:
            #if MIC_SPLIT_WITH_HOST != 0
              if (map->directToDevice(i)) { // If should be directed to the device...
            #endif
                if ( ! deviceIsMine ) continue;
                if ( ! mic_device_shared_with_pe(map->computeData[i].node) ) continue;
            #if MIC_SPLIT_WITH_HOST != 0
              } else { // ... otherwise, direct to host...
                if (map->computeData[i].node != myNode) { continue; }
	      }
            #endif
            break;

#endif
          case computeNonbondedCUDAType:
          case computeNonbondedMICType:
            if ( ! deviceIsMine ) continue;
          default:
            if ( map->computeData[i].node != myNode ) continue;
        }
#else
        if ( map->computeData[i].node != myNode ) continue;
#endif
        DebugM(1,"Compute " << i << '\n');
        DebugM(1,"  node = " << map->computeData[i].node << '\n');
        DebugM(1,"  type = " << map->computeData[i].type << '\n');
        DebugM(1,"  numPids = " << map->computeData[i].numPids << '\n');
        DebugM(1,"  numPidsAllocated = " << map->computeData[i].numPidsAllocated << '\n');
        for (int j=0; j < map->computeData[i].numPids; j++)
        {
            //      DebugM(1,"  pid " << map->computeData[i].pids[j] << '\n');
            if (!((j+1) % 6))
                DebugM(1,'\n');
        }
        DebugM(1,"\n---------------------------------------");
        DebugM(1,"---------------------------------------\n");

        createCompute(i, map);

    }

#ifdef NAMD_CUDA
    if ( computeNonbondedCUDAObject ) {
      computeNonbondedCUDAObject->assignPatches();
    }
#endif
#ifdef NAMD_MIC
    if ( computeNonbondedMICObject ) {
      computeNonbondedMICObject->assignPatches();
    }
#endif

}
示例#2
0
void
ComputeMgr::createComputes(ComputeMap *map)
{
    Node *node = Node::Object();
    SimParameters *simParams = node->simParameters;
    int myNode = node->myid();

    ComputeNonbondedUtil::select();

    if ( simParams->globalForcesOn && !myNode )
    {
        DebugM(4,"Mgr running on Node "<<CkMyPe()<<"\n");
        /* create a master server to allow multiple masters */
        masterServerObject = new GlobalMasterServer(this,
                PatchMap::Object()->numNodesWithPatches());

        /* create the individual global masters */
        // masterServerObject->addClient(new GlobalMasterTest());
        if (simParams->tclForcesOn)
            masterServerObject->addClient(new GlobalMasterTcl());
        if (simParams->IMDon && ! simParams->IMDignore)
            masterServerObject->addClient(new GlobalMasterIMD());

        if (simParams->SMDOn)
            masterServerObject->addClient(
                new GlobalMasterSMD(simParams->SMDk, simParams->SMDk2,
				    simParams->SMDVel,
                                    simParams->SMDDir, simParams->SMDOutputFreq,
                                    simParams->firstTimestep, simParams->SMDFile,
                                    node->molecule->numAtoms)
            );
            
        if (simParams->symmetryOn && 
          (simParams->firstTimestep < simParams->symmetryLastStep || 
          simParams->symmetryLastStep == -1))
            masterServerObject->addClient(new GlobalMasterSymmetry());    
        if (simParams->TMDOn)
            masterServerObject->addClient(new GlobalMasterTMD());
        if (simParams->miscForcesOn)
            masterServerObject->addClient(new GlobalMasterMisc());
        if ( simParams->freeEnergyOn )
            masterServerObject->addClient(new GlobalMasterFreeEnergy());
		if ( simParams->colvarsOn )
			masterServerObject->addClient(new GlobalMasterColvars());

    }

    if ( !myNode && simParams->IMDon && simParams->IMDignore ) {
      // GlobalMasterIMD constructor saves pointer to node->IMDOutput object
      new GlobalMasterIMD();
    }

#ifdef NAMD_CUDA
    bool deviceIsMine = ( cuda_device_pe() == CkMyPe() );
#endif

    for (int i=0; i < map->nComputes; i++)
    {
        if ( ! ( i % 100 ) )
        {
        }
#ifdef NAMD_CUDA
        switch ( map->type(i) )
        {
          case computeNonbondedSelfType:
          case computeNonbondedPairType:
            if ( ! deviceIsMine ) continue;
            if ( ! cuda_device_shared_with_pe(map->computeData[i].node) ) continue;
          break;
          case computeNonbondedCUDAType:
            if ( ! deviceIsMine ) continue;
          default:
            if ( map->computeData[i].node != myNode ) continue;
        }
#else
        if ( map->computeData[i].node != myNode ) continue;
#endif
        DebugM(1,"Compute " << i << '\n');
        DebugM(1,"  node = " << map->computeData[i].node << '\n');
        DebugM(1,"  type = " << map->computeData[i].type << '\n');
        DebugM(1,"  numPids = " << map->computeData[i].numPids << '\n');
        DebugM(1,"  numPidsAllocated = " << map->computeData[i].numPidsAllocated << '\n');
        for (int j=0; j < map->computeData[i].numPids; j++)
        {
            //      DebugM(1,"  pid " << map->computeData[i].pids[j] << '\n');
            if (!((j+1) % 6))
                DebugM(1,'\n');
        }
        DebugM(1,"\n---------------------------------------");
        DebugM(1,"---------------------------------------\n");

        createCompute(i, map);

    }

#ifdef NAMD_CUDA
    if ( computeNonbondedCUDAObject ) {
      computeNonbondedCUDAObject->assignPatches();
    }
#endif

}