NAMD
Node.C
Go to the documentation of this file.
1 
7 /*
8  Toplevel routines for initializing a Node for a simulation
9  one Node per Pe (processor element).
10 */
11 
12 #if !defined(WIN32) || defined(__CYGWIN__)
13 #include <unistd.h>
14 #endif
15 #include "InfoStream.h"
16 #include "Node.decl.h"
17 #include "Node.h"
18 #ifdef DPMTA
19 #include <pvm3.h>
20 #endif
21 
22 #include "ProcessorPrivate.h"
23 
24 #define MIN_DEBUG_LEVEL 3
25 //#define DEBUGM
26 #include "Debug.h"
27 
28 #include <stdio.h>
29 #include <converse.h>
30 #include "memusage.h"
31 #include "IMDOutput.h"
32 #include "Lattice.h"
33 #include "ComputeMsmMsa.h" // needed for MsmMsaData definition
34 #include "ComputeMsm.h" // needed for MsmInitMsg definition
35 #include "main.decl.h"
36 #include "main.h"
37 #include "WorkDistrib.h"
38 #include "PatchMgr.h"
39 #include "Patch.h"
40 #include "Compute.h"
41 #include "ComputeMap.h"
42 #include "ComputeMgr.h"
43 #include "Molecule.h"
44 #include "HomePatchList.h"
45 #include "AtomMap.h"
46 #include "Sequencer.h"
47 #include "Controller.h"
48 #include "NamdState.h"
49 #include "Output.h"
50 #include "ProxyMgr.h"
51 #include "PatchMap.h"
52 #include "PatchMap.inl"
53 #include "Parameters.h"
54 #include "SimParameters.h"
55 #include "Communicate.h"
56 #include "LdbCoordinator.h"
57 #include "ScriptTcl.h"
58 #include "ComputeMgr.decl.h"
59 #include "ComputePmeMgr.decl.h"
60 // #ifdef NAMD_CUDA
61 #include "ComputeCUDAMgr.decl.h"
62 #include "ComputeCUDAMgr.h"
63 #include "ComputePmeCUDAMgr.decl.h"
64 #include "ComputePmeCUDAMgr.h"
65 // #endif
66 #include "ComputeGridForceMgr.decl.h"
67 #include "Sync.h"
68 #include "BackEnd.h"
69 #include "PDB.h"
70 #include "packmsg.h"
71 #include "CollectionMgr.decl.h"
72 #include "ParallelIOMgr.decl.h"
73 #include "Vector.h"
74 // BEGIN LA
75 #include "Random.h"
76 // END LA
77 #include "PatchData.h"
78 #include "DeviceCUDA.h"
79 #include "Thread.h"
80 #include "GlobalGPUMgr.h"
81 #include "SynchronousCollectives.h"
82 
83 #include "NamdEventsProfiling.h"
84 
85 #if(CMK_CCS_AVAILABLE && CMK_WEB_MODE)
86 extern "C" void CApplicationInit();
87 #endif
88 
89 #include "DumpBench.h"
90 
91 #ifdef NAMD_CUDA
92 #if !defined(WIN64)
93 extern __thread DeviceCUDA *deviceCUDA;
94 #else
95 extern __declspec(thread) DeviceCUDA *deviceCUDA;
96 #endif
97 #endif
98 class CheckpointMsg : public CMessage_CheckpointMsg {
99 public:
100  int task;
101  int replica;
103  char *key;
104 };
105 
106 extern "C" {
107  void recvCheckpointCReq_handler(envelope*);
108  void recvCheckpointCAck_handler(envelope*);
109 }
110 
111 #if defined(CMK_BALANCED_INJECTION_API) && CMK_BALANCED_INJECTION_API != 0
112 #include "ckBIconfig.h"
113 #endif
114 
115 #include "CollectionMgr.h"
116 #include "CollectionMaster.h"
117 #include "CollectionMgr.decl.h"
118 #include "CollectionMaster.decl.h"
119 
120 #if USE_HPM
121 extern "C" void HPM_Init(int);
122 extern "C" void HPM_Start(char *label, int);
123 extern "C" void HPM_Stop(char *label, int);
124 extern "C" void HPM_Print(int, int);
125 #endif
126 
127 #if defined(NAMD_MIC)
128  extern void mic_dumpHostDeviceComputeMap();
129  extern void mic_initHostDeviceLDB();
130 #endif
131 
132 #ifdef MEASURE_NAMD_WITH_PAPI
133 #include "papi.h"
134 #if CMK_SMP
135 #include <pthread.h>
136 #endif
137 #define NUM_PAPI_EVENTS 6
138 CkpvDeclare(int *, papiEvents);
139 
140 #define MEASURE_PAPI_SPP 1
141 #define MEASURE_PAPI_CACHE 0
142 #define MEASURE_PAPI_FLOPS 0
143 
144 static void namdInitPapiCounters(){
145  if(CkMyRank()==0){
146  //only initialize per OS process (i.e. a charm node)
147  int retval = PAPI_library_init(PAPI_VER_CURRENT);
148  if(retval != PAPI_VER_CURRENT) {
149  if(CkMyPe()==0){
150  NAMD_die("PAPI library is not compatitible!");
151  }
152  }
153  #if CMK_SMP
154  //now only consider systems that are compatible with POSIX
155  if(PAPI_thread_init(pthread_self)!=PAPI_OK) {
156  if(CkMyPe()==0){
157  NAMD_die("Multi-thread mode in PAPI could not be initialized!");
158  }
159  }
160  #endif
161  }
162  CkpvInitialize(int *, papiEvents);
163  CkpvAccess(papiEvents) = new int[NUM_PAPI_EVENTS+1];
164 
165 #if MEASURE_PAPI_CACHE
166  if(PAPI_query_event(PAPI_L1_DCM)==PAPI_OK) {
167  CkpvAccess(papiEvents)[0] = PAPI_L1_DCM;
168  }else{
169  if(CkMyPe()==0){
170  CkPrintf("WARNING: PAPI_L1_DCM doesn't exsit on this platform!\n");
171  }
172  //if not default to PAPI_TOT_INS
173  CkpvAccess(papiEvents)[0] = PAPI_TOT_INS;
174  }
175 
176  if(PAPI_query_event(PAPI_L2_DCM)==PAPI_OK) {
177  CkpvAccess(papiEvents)[1] = PAPI_L2_DCM;
178  }else{
179  //if not default to PAPI_TOT_CYC
180  CkpvAccess(papiEvents)[1] = PAPI_TOT_CYC;
181  }
182 #elif MEASURE_PAPI_FLOPS
183  if(PAPI_query_event(PAPI_FP_INS)==PAPI_OK) {
184  CkpvAccess(papiEvents)[0] = PAPI_FP_INS;
185  }else{
186  if(CkMyPe()==0){
187  CkPrintf("WARNING: PAPI_FP_INS doesn't exsit on this platform!\n");
188  }
189  //if not default to PAPI_TOT_INS
190  CkpvAccess(papiEvents)[0] = PAPI_TOT_INS;
191  }
192 
193  if(PAPI_query_event(PAPI_FMA_INS)==PAPI_OK) {
194  CkpvAccess(papiEvents)[1] = PAPI_FMA_INS;
195  }else{
196  //if not default to PAPI_TOT_CYC
197  CkpvAccess(papiEvents)[1] = PAPI_TOT_CYC;
198  }
199 #elif MEASURE_PAPI_SPP
200 /* for SPP we record these
201 1) PAPI_FP_OPS
202 2) PAPI_TOT_INS
203 3) perf::PERF_COUNT_HW_CACHE_LL:MISS
204 4) DATA_PREFETCHER:ALL
205 5) PAPI_L1_DCA
206 6) INSTRUCTION_FETCH_STALL
207 7) PAPI_TOT_CYC, and
208 8) real (wall) time
209 */
210  int papiEventSet = PAPI_NULL;
211  if (PAPI_create_eventset(&papiEventSet) != PAPI_OK) {
212  CmiAbort("PAPI failed to create event set!\n");
213  }
214 
215  if(PAPI_query_event(PAPI_FP_OPS)==PAPI_OK) {
216  CkpvAccess(papiEvents)[0] = PAPI_FP_OPS;
217  }else{
218  if(CkMyPe()==0){
219  CkAbort("WARNING: PAPI_FP_OPS doesn't exist on this platform!");
220  }
221  }
222  if(PAPI_query_event(PAPI_TOT_INS)==PAPI_OK) {
223  CkpvAccess(papiEvents)[1] = PAPI_TOT_INS;
224  }else{
225  if(CkMyPe()==0){
226  CkAbort("WARNING: PAPI_TOT_INS doesn't exist on this platform!");
227  }
228  }
229  int EventCode;
230  int ret;
231  ret=PAPI_event_name_to_code("perf::PERF_COUNT_HW_CACHE_LL:MISS",&EventCode);
232  if(ret==PAPI_OK && PAPI_query_event(EventCode)==PAPI_OK) {
233  CkpvAccess(papiEvents)[2] = EventCode;
234  }else{
235  if(CkMyPe()==0){
236  CkAbort("WARNING: perf::PERF_COUNT_HW_CACHE_LL:MISS doesn't exist on this platform!");
237  }
238  }
239  ret=PAPI_event_name_to_code("DATA_PREFETCHER:ALL",&EventCode);
240  if(ret==PAPI_OK && PAPI_query_event(EventCode)==PAPI_OK) {
241  CkpvAccess(papiEvents)[3] = EventCode;
242  }else{
243  if(CkMyPe()==0){
244  CkAbort("WARNING: DATA_PREFETCHER:ALL doesn't exist on this platform!");
245  }
246  }
247  if(PAPI_query_event(PAPI_L1_DCA)==PAPI_OK) {
248  CkpvAccess(papiEvents)[4] = PAPI_L1_DCA;
249  }else{
250  if(CkMyPe()==0){
251  CkAbort("WARNING: PAPI_L1_DCA doesn't exist on this platform!");
252  }
253  }
254  /* ret=PAPI_event_name_to_code("INSTRUCTION_FETCH_STALL",&EventCode);
255  if(ret==PAPI_OK && PAPI_query_event(EventCode)==PAPI_OK) {
256  CkpvAccess(papiEvents)[5] = EventCode;
257  }else{
258  if(CkMyPe()==0){
259  CkAbort("WARNING: INSTRUCTION_FETCH_STALL doesn't exist on this platform!");
260  }
261  }
262  */
263  if(PAPI_query_event(PAPI_TOT_CYC)==PAPI_OK) {
264  CkpvAccess(papiEvents)[5] = PAPI_TOT_CYC;
265  }else{
266  if(CkMyPe()==0){
267  CkAbort("WARNING: PAPI_TOT_CYC doesn't exist on this platform!");
268  }
269  }
270  for(int i=0;i<NUM_PAPI_EVENTS;i++)
271  {
272  int papiRetValue=PAPI_add_events(papiEventSet, &CkpvAccess(papiEvents)[i],1);
273  if (papiRetValue != PAPI_OK) {
274  CkPrintf("failure for event %d\n",i);
275  if (papiRetValue == PAPI_ECNFLCT) {
276  CmiAbort("PAPI events conflict! Please re-assign event types!\n");
277  } else {
278  CmiAbort("PAPI failed to add designated events!\n");
279  }
280  }
281 
282  }
283 #endif
284 }
285 #endif
286 
287 #ifdef OPENATOM_VERSION
288 static void startOA(){(char inDriverFile[1024], char inPhysicsFile[1024], CkCallback doneCB)
289 {
290  CProxy_oaSetup moaInstance = CProxy_oaSetup::ckNew(inDriverFile, inPhysicsFile, doneCB);
291 }
292 #endif //OPENATOM_VERSION
293 
294 //======================================================================
295 // Public Functions
296 
297 //----------------------------------------------------------------------
298 
300 double startupTime;
301 
302 //----------------------------------------------------------------------
303 // BOC constructor
305 {
306  DebugM(4,"Creating Node\n");
307 #if(CMK_CCS_AVAILABLE && CMK_WEB_MODE)
308  CApplicationInit();
309 #endif
310  if (CkpvAccess(Node_instance) == 0) {
311  CkpvAccess(Node_instance) = this;
312  eventEndOfTimeStep = traceRegisterUserEvent("EndOfTimeStep", 135);
313  } else {
314  NAMD_bug("Node::Node() - another instance of Node exists!");
315  }
316 
317  CkpvAccess(BOCclass_group) = msg->group;
318  delete msg;
319 
320  CkpvAccess(BOCclass_group).node = thisgroup;
321 
322  recvCheckpointCReq_index = CmiRegisterHandler((CmiHandler)recvCheckpointCReq_handler);
323  recvCheckpointCAck_index = CmiRegisterHandler((CmiHandler)recvCheckpointCAck_handler);
324 
325  startupPhase = 0;
326 
327  molecule = NULL;
328  parameters = NULL;
329  simParameters = NULL;
330  configList = NULL;
331  pdb = NULL;
332  state = NULL;
333  output = NULL;
334  imd = new IMDOutput;
335  colvars = 0;
336 
337 #if USE_HPM
338  // assumes that this will be done only on BG/P
339  TopoManager *tmgr = new TopoManager();
340  int x, y, z;
341  tmgr->rankToCoordinates(CkMyPe(), x, y, z, localRankOnNode);
342  delete tmgr;
343 #endif
344 
345  specialTracing = traceAvailable() && (traceIsOn()==0);
346 
347  DebugM(4,"Creating PatchMap, AtomMap, ComputeMap\n");
350  if ( CkMyRank() == 0 ) ComputeMap::Instance();
351 
352  //Note: Binding BOC vars such as workDistrib has been moved
353  //to the 1st phase of startup because the in-order message delivery
354  //is not always guaranteed --Chao Mei
355 #if defined(CMK_BALANCED_INJECTION_API) && CMK_BALANCED_INJECTION_API != 0
356  if(CkMyRank() == 0){
357  balancedInjectionLevel=ck_get_GNI_BIConfig();
358  // CkPrintf("[%d] get retrieved BI=%d\n",CkMyPe(),balancedInjectionLevel);
359  ck_set_GNI_BIConfig(20);
360  // CkPrintf("[%d] set retrieved BI=%d\n",CkMyPe(),ck_get_GNI_BIConfig());
361  }
362 #endif
363 
364 }
365 
366 //----------------------------------------------------------------------
367 // ~Node(void) needs to clean up everything.
368 
370 {
371  delete imd;
372  delete output;
373  delete computeMap;
374  delete atomMap;
375  delete patchMap;
376  delete CkpvAccess(comm);
377  // BEGIN LA
378  delete rand;
379  // END LA
380 #ifdef MEASURE_NAMD_WITH_PAPI
381  delete CkpvAccess(papiEvents);
382 #endif
383 }
384 
385 void Node::bindBocVars(){
386  DebugM(4,"Binding to BOC's\n");
387  CProxy_PatchMgr pm(CkpvAccess(BOCclass_group).patchMgr);
388  patchMgr = pm.ckLocalBranch();
389  CProxy_ProxyMgr prm(CkpvAccess(BOCclass_group).proxyMgr);
390  proxyMgr = prm.ckLocalBranch();
391  CProxy_WorkDistrib wd(CkpvAccess(BOCclass_group).workDistrib);
392  workDistrib = wd.ckLocalBranch();
393  CProxy_ComputeMgr cm(CkpvAccess(BOCclass_group).computeMgr);
394  computeMgr = cm.ckLocalBranch();
395  CProxy_LdbCoordinator lc(CkpvAccess(BOCclass_group).ldbCoordinator);
396  ldbCoordinator = lc.ckLocalBranch();
397  #ifdef MEM_OPT_VERSION
398  CProxy_ParallelIOMgr io(CkpvAccess(BOCclass_group).ioMgr);
399  ioMgr = io.ckLocalBranch();
400  #endif
401 
402 }
403 
404 //----------------------------------------------------------------------
405 // Malloc Test Sequence
406 void Node::mallocTest(int step) {
407  int MB = 1024*1024;
408  int size = 100;
409  char* foo = (char*) malloc(size*MB);
410  if ( ! foo ) {
411  char buf[256];
412  sprintf(buf,"Malloc fails on Pe %d at %d MB.\n",CkMyPe(),step*size);
413  NAMD_die(buf);
414  }
415  memset(foo,0,size*MB*sizeof(char));
416 }
417 
419  if ( mallocTest_size ) {
420  CkPrintf("All PEs successfully allocated %d MB.\n", 100*mallocTest_size);
421  } else {
422  CkPrintf("Starting malloc test on all PEs.\n");
423  }
424  fflush(stdout);
425  ++mallocTest_size;
426  CkStartQD(CkIndex_Node::mallocTestQd(), &thishandle);
427  (CProxy_Node(CkpvAccess(BOCclass_group).node)).mallocTest(mallocTest_size);
428 }
429 
430 //----------------------------------------------------------------------
431 // Startup Sequence
432 
434  (CProxy_Node(CkpvAccess(BOCclass_group).node)).startup();
435 }
436 
440 
441 extern void registerUserEventsForAllComputeObjs(void);
442 
443 
444 /*
445  * This function will initialize the GlobalGPUMgr and finish the initialization
446  * process for SynchronousCollectives. This is executed in a separate converse
447  * thread with high priority and default strategy to avoid hanging
448  */
449 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
452  GlobalGPUMgr* globalGPUMgr = GlobalGPUMgr::Object();
453  syncColl->forceBarrierAll();
454  globalGPUMgr->initialize();
455  syncColl->initMasterScope(
456  globalGPUMgr->getIsMasterPe(), globalGPUMgr->getIsMasterDevice(),
457  globalGPUMgr->getNumDevices(), globalGPUMgr->getDeviceIndex(),
458  globalGPUMgr->getDeviceIndexToPeMap()
459  );
460  globalGPUMgr->initializeBackends();
461  CthFree(CthSelf());
462 }
463 #endif /* defined(NAMD_CUDA) || defined(NAMD_HIP) */
464 
466  NAMD_EVENT_START(1, NamdProfileEvent::NAMD_STARTUP);
467 
468  int gotoRun = false;
469  double newTime;
470 
471  if (!CkMyPe()) {
472  if (!startupPhase) {
473  iout << iINFO << "\n";
474  startupTime = CmiWallTimer();
475  iout << iINFO << "Entering startup at " << startupTime << " s, ";
476  } else {
477  newTime = CmiWallTimer();
478  iout << iINFO << "Startup phase " << startupPhase-1 << " took "
479  << newTime - startupTime << " s, ";
480  startupTime = newTime;
481  }
482  iout << memusage_MB() << " MB of memory in use\n" << endi;
483  fflush(stdout);
484  }
485  switch (startupPhase) {
486 
487  case 0:
489  namdOneCommInit(); // Namd1.X style
490  break;
491 
492  case 1:
493  bindBocVars();
494 
495  // send & receive molecule, simparameters... (Namd1.X style)
496  if (CkMyPe()) {
497  namdOneRecv();
498  } else {
499  namdOneSend();
500  }
501  break;
502 
503  case 2:
504  // fix up one-per-node objects (for SMP version)
508 
511 
512  #if !CMK_SMP || ! USE_CKLOOP
513  //the CkLoop library should be only used in SMP mode
515  #else
516  if ( CkNumPes() < 2 * CkNumNodes() ) simParameters->useCkLoop = 0;
517  #endif
518 
519 
520  if ( simParameters->mallocTest ) {
521  if (!CkMyPe()) {
522  mallocTest_size = 0;
523  CkStartQD(CkIndex_Node::mallocTestQd(), &thishandle);
524  }
525  return;
526  }
527 
528 
529  #ifdef MEASURE_NAMD_WITH_PAPI
530  if(simParameters->papiMeasure) namdInitPapiCounters();
531  #endif
532 
533  #ifdef MEM_OPT_VERSION
534  //At this point, each Node object has received the simParameters,
535  //parameters and the atom signatures info from the master Node
536  //(proc 0). It's time to initialize the parallel IO manager and
537  //read the binary per-atom file --Chao Mei
538 
539  //Step 1: initialize the parallel IO manager per Node
540  ioMgr->initialize(this);
541  #endif
542 
543  break;
544 
545  case 3:
546 
547  #ifdef MEM_OPT_VERSION
548  //Step 2: read the binary per-atom files (signater index, coordinates etc.)
549  ioMgr->readPerAtomInfo();
551  if(!CkMyPe())
552  ioMgr->sendDcdParams();
553  #endif
554 
555  break;
556 
557  case 4:
558 
559  #ifdef MEM_OPT_VERSION
560  //Step 3: update counters of tuples and exclusions inside Molecule object
561  ioMgr->updateMolInfo();
562 
563  //Step 4: prepare distributing the atoms to neighboring procs if necessary
564  ioMgr->migrateAtomsMGrp();
565 
566  //step 5: initialize patchMap and send it to every other processors
567  //to decide atoms to patch distribution on every input processor
568  if(!CkMyPe()) {
569  workDistrib->patchMapInit(); // create space division
571  }
572  #endif
573 
574  #if USE_HPM
575  HPM_Init(localRankOnNode);
576  #endif
577 
578  // take care of inital thread setting
579  threadInit();
580 
581  // create blank AtomMap
583 
584  if (!CkMyPe()) {
585 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
586  if (simParameters->usePMECUDA) {
587  // computePmeCUDAMgr was created in BackEnd.C
588  // This empty branch is to avoid initializing ComputePmeMgr
589  } else
590 #endif
591  if (simParameters->PMEOn) {
592  CkpvAccess(BOCclass_group).computePmeMgr = CProxy_ComputePmeMgr::ckNew();
593  }
594  #ifdef OPENATOM_VERSION
595  if ( simParameters->openatomOn ) {
596  CkpvAccess(BOCclass_group).computeMoaMgr = CProxy_ComputeMoaMgr::ckNew();
597  }
598  #endif // OPENATOM_VERSION
599 
600  }
601 
602  #ifdef OPENATOM_VERSION
603  if ( simParameters->openatomOn ) {
604  // if ( ! CkMyPe() ) {
605  CkCallback doneMoaStart(CkIndexmain::doneMoaSetup(), thishandle);
606  startOA(simParameters->moaDriverFile, simParameters->moaPhysicsFile, doneMoaStart);
607  // }
608  }
609  #endif // OPENATOM_VERSION
610 
611  // BEGIN LA
613  rand->split(CkMyPe(), CkNumPes());
614  // END LA
615 
616  break;
617 
618  case 5:
619  #ifdef MEM_OPT_VERSION
620  //Now, every input proc has received all the atoms necessary
621  //to decide the patches those atoms belong to
622 
623  //step 1: integrate the migrated atoms into the atom list that
624  //contains the initally distributed atoms, and sort the atoms
625  //based on hydrogenList value
626  ioMgr->integrateMigratedAtoms();
627 
628  //step 2: integrate the cluster size of each atom on each output proc
629  ioMgr->integrateClusterSize();
630 
631  //step 3: calculate the number of atoms in each patch on every
632  //input procs (atoms belonging to a patch may lie on different
633  //procs), and reduce such info on proc 0. Such info is required
634  //for determing which node a particular patch is assigned to.
635  ioMgr->calcAtomsInEachPatch();
636 
637  //set to false to re-send PatchMap later
639  #endif
640  break;
641  case 6:
644  }
647  }
650  }
651  #ifdef PROCTRACE_DEBUG
652  DebugFileTrace::Instance("procTrace");
653  #endif
654 
655  if (!CkMyPe()) {
656  output = new Output; // create output object just on PE(0)
657 
658  #ifndef MEM_OPT_VERSION
659  workDistrib->patchMapInit(); // create space division
660  workDistrib->createHomePatches(); // load atoms into HomePatch(es)
661  #endif
662 
665  //ComputeMap::Object()->printComputeMap();
666 
667  // For MIC runs, take the additional step after the compute map has been created to
668  // assign the various computes to either the host or the device. This info will
669  // be distributed across the PEs.
670  #if defined(NAMD_MIC)
671  mic_initHostDeviceLDB();
672  #endif
673 
675  iout << iINFO << "Simulating initial mapping with " << simParameters->simulatedPEs
676  << " PEs with " << simParameters->simulatedNodeSize << " PEs per node\n" << endi;
677  outputPatchComputeMaps("init_mapping", 0);
678  iout << iINFO << "Simulating initial mapping is done, now NAMD exits\n" << endi;
679  BackEnd::exit();
680  }
681 
683 
684  //in MEM_OPT_VERSION, patchMap is resent
685  //because they have been updated since creation including
686  //#atoms per patch, the proc a patch should stay etc. --Chao Mei
688  #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
689  CProxy_NodeProxyMgr npm(CkpvAccess(BOCclass_group).nodeProxyMgr);
690  //a node broadcast
691  npm.createProxyInfo(PatchMap::Object()->numPatches());
692  #endif
693  }
694  {
695  #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
696  CProxy_NodeProxyMgr npm(CkpvAccess(BOCclass_group).nodeProxyMgr);
697  if(CkMyRank()==0) {
698  //just need to register once
699  npm[CkMyNode()].ckLocalBranch()->registerLocalProxyMgr(CkpvAccess(BOCclass_group).proxyMgr);
700  }
701  npm[CkMyNode()].ckLocalBranch()->registerLocalPatchMap(CkMyRank(), PatchMap::Object());
702  #endif
703  }
704  break;
705 
706  case 7:
707 #ifdef CHARM_HAS_MSA
709  CProxy_ComputeMsmMsaMgr msm(CkpvAccess(BOCclass_group).computeMsmMsaMgr);
710  msm[CkMyPe()].initialize(new CkQdMsg);
711  }
712 #else
714  CProxy_ComputeMsmMgr msm(CkpvAccess(BOCclass_group).computeMsmMgr);
715  MsmInitMsg *msg = new MsmInitMsg;
716  Lattice lattice = simParameters->lattice; // system lattice vectors
717  ScaledPosition smin=0, smax=0;
718  if (lattice.a_p() && lattice.b_p() && lattice.c_p()) {
719  msg->smin = smin;
720  msg->smax = smax;
721  msm[CkMyPe()].initialize(msg); // call from my own PE
722  }
723  else if ( ! CkMyPe() ) {
724  pdb->get_extremes(smin, smax); // only available on PE 0
725  msg->smin = smin;
726  msg->smax = smax;
727  msm.initialize(msg); // broadcast to chare group
728  }
729 
730  /*
731  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
732  Node *node = nd.ckLocalBranch();
733  ScaledPosition smin, smax;
734  node->pdb->get_extremes(smin, smax);
735  msg->smin = smin; // extreme positions in system
736  msg->smax = smax;
737  msm[CkMyPe()].initialize(msg);
738  */
739  }
740 #endif
741 
742  if ( simParameters->PMEOn ) {
743  #ifdef OPENATOM_VERSION
744  if ( simParameters->openatomOn ) {
745  CProxy_ComputeMoaMgr moa(CkpvAccess(BOCclass_group).computeMoaMgr);
746  moa[CkMyPe()].initialize(new CkQdMsg);
747  }
748  #endif // OPENATOM_VERSION
749 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
750  if ( simParameters->usePMECUDA ) {
751  if(CkMyRank()==0) {
752  CProxy_ComputePmeCUDAMgr pme(CkpvAccess(BOCclass_group).computePmeCUDAMgr);
753  pme.ckLocalBranch()->initialize(new CkQdMsg); // must run on pe 0 to call ckNew
754  }
755  } else
756 #endif
757  {
758  CProxy_ComputePmeMgr pme(CkpvAccess(BOCclass_group).computePmeMgr);
759  pme[CkMyPe()].initialize(new CkQdMsg);
760  }
761  }
762  break;
763 
764  case 8:
765 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
766  if ( CkMyRank()==0 ) {
767  CProxy_ComputeCUDAMgr nb(CkpvAccess(BOCclass_group).computeCUDAMgr);
768  nb.ckLocalBranch()->initialize(new CkQdMsg);
769  }
770 #endif
771  break;
772 
773  case 9:
775  break;
776 
777  case 10:
778  #ifdef MEM_OPT_VERSION
779  //migrate atoms to HomePatch processors
780  ioMgr->sendAtomsToHomePatchProcs();
781  #endif
782  break;
783 
784  case 11:
785  // part 2 of MSM init
787  CProxy_ComputeMsmMgr msm(CkpvAccess(BOCclass_group).computeMsmMgr);
788  msm[CkMyPe()].initialize_create(); // call from my own PE
789  }
790 
791  if ( simParameters->PMEOn ) {
792  #ifdef OPENATOM_VERSION
793  if ( simParameters->openatomOn ) {
794  CProxy_ComputeMoaMgr moa(CkpvAccess(BOCclass_group).computeMoaMgr);
795  moa[CkMyPe()].initWorkers(new CkQdMsg);
796  }
797  #endif // OPENATOM_VERSION
798 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
799  if ( simParameters->usePMECUDA ) {
800  if(CkMyRank()==0) {
801  CProxy_ComputePmeCUDAMgr pme(CkpvAccess(BOCclass_group).computePmeCUDAMgr);
802  pme[CkMyNode()].initialize_pencils(new CkQdMsg);
803  }
804  } else
805 #endif
806  {
807  CProxy_ComputePmeMgr pme(CkpvAccess(BOCclass_group).computePmeMgr);
808  pme[CkMyPe()].initialize_pencils(new CkQdMsg);
809  }
810  }
811 #ifdef CHARM_HAS_MSA
812  else if ( simParameters->MSMOn && ! simParameters->MsmSerialOn ) {
813  CProxy_ComputeMsmMsaMgr msm(CkpvAccess(BOCclass_group).computeMsmMsaMgr);
814  msm[CkMyPe()].initWorkers(new CkQdMsg);
815  }
816 #else
817  else if ( simParameters->MSMOn && ! simParameters->MsmSerialOn ) {
818  CProxy_ComputeMsmMgr msm(CkpvAccess(BOCclass_group).computeMsmMgr);
819  msm[CkMyPe()].update(new CkQdMsg);
820  }
821 #endif
822 
823  #ifdef MEM_OPT_VERSION
824  //Now every processor has all the atoms it needs to create the HomePatches.
825  //The HomePatches are created in parallel on every home patch procs.
826  ioMgr->createHomePatches();
827  #else
828  if (!CkMyPe()) {
830  }
831  #endif
832  break;
833 
834  case 12:
835  if ( simParameters->PMEOn ) {
836  #ifdef OPENATOM_VERSION
837  if ( simParameters->openatomOn ) {
838  CProxy_ComputeMoaMgr moa(CkpvAccess(BOCclass_group).computeMoaMgr);
839  moa[CkMyPe()].startWorkers(new CkQdMsg);
840  }
841  #endif // OPENATOM_VERSION
842 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
843  if ( simParameters->usePMECUDA ) {
844  if(CkMyRank()==0) {
845  CProxy_ComputePmeCUDAMgr pme(CkpvAccess(BOCclass_group).computePmeCUDAMgr);
846  pme[CkMyNode()].activate_pencils(new CkQdMsg);
847  }
848  } else
849 #endif
850  {
851  CProxy_ComputePmeMgr pme(CkpvAccess(BOCclass_group).computePmeMgr);
852  pme[CkMyPe()].activate_pencils(new CkQdMsg);
853  }
854  }
855 #ifdef CHARM_HAS_MSA
856  else if ( simParameters->MSMOn && ! simParameters->MsmSerialOn ) {
857  CProxy_ComputeMsmMsaMgr msm(CkpvAccess(BOCclass_group).computeMsmMsaMgr);
858  msm[CkMyPe()].startWorkers(new CkQdMsg);
859  }
860 #else
861  /*
862  else if ( simParameters->MSMOn && ! simParameters->MsmSerialOn ) {
863  CProxy_ComputeMsmMgr msm(CkpvAccess(BOCclass_group).computeMsmMgr);
864  //msm[CkMyPe()].startWorkers(new CkQdMsg);
865  }
866  */
867 #endif
868 
869  proxyMgr->createProxies(); // need Home patches before this
870  if (!CkMyPe()) LdbCoordinator::Object()->createLoadBalancer();
871 
872 #ifdef NAMD_TCL
873  // TclInitSubsystems() has a race condition so we create one interp per node here
874  if (CkMyPe() && CkMyNodeSize() > 1 && ! CkMyRank()) Tcl_DeleteInterp(Tcl_CreateInterp());
875 #endif
876 
877 #ifdef USE_NODEPATCHMGR
878  //at this point, PatchMap info has been recved on PEs. It is time to create
879  //the home patch spanning tree for receiving proxy list info
880  if(proxyMgr->getSendSpanning() || proxyMgr->getRecvSpanning()) {
881  if(CkMyRank()==0) {
882  CProxy_NodeProxyMgr npm(CkpvAccess(BOCclass_group).nodeProxyMgr);
883  npm[CkMyNode()].ckLocalBranch()->createSTForHomePatches(PatchMap::Object());
884  }
885  }
886 #endif
887 
888  break;
889 
890  case 13:
891 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
892  // Initialize the collective synchronization object before the sequencers are created
895  syncColl->initAllScope();
896  // Sync between all PEs so that expectedBarrierAll and currentBarrierAll are set
897  }
898 #endif
899  break;
900 
901  case 14:
902 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
904  gpuResInitThread = CthCreate((CthVoidFn) &(initializeGPUResident), nullptr, SEQ_STK_SZ);
905  gpuResInitThreadPriority = 0;
906  CthSetStrategyDefault(gpuResInitThread);
907  CthAwakenPrio(gpuResInitThread, CK_QUEUEING_IFIFO, PRIORITY_SIZE, &gpuResInitThreadPriority);
908  CthSuspend();
909  }
910 #endif
911  break;
912 
913  case 15:
914  // Make sure that the GPU resident initialization threads have finished
915  break;
916 
917  case 16:
918 
919  // DMK - DEBUG - If, in MIC runs, the debug option to dump all the compute maps to files
920  // for debugging/verification purposes has been enabled, have each PE do so now.
921  #if defined(NAMD_MIC)
922  mic_dumpHostDeviceComputeMap();
923  #endif
924 
925  if (!CkMyPe()) {
926  iout << iINFO << "CREATING " << ComputeMap::Object()->numComputes()
927  << " COMPUTE OBJECTS\n" << endi;
928  }
929  DebugM(4,"Creating Computes\n");
931  DebugM(4,"Building Sequencers\n");
932  buildSequencers();
933  DebugM(4,"Initializing LDB\n");
935  break;
936 
937  case 17:
938  // computes may create proxies on the fly so put these in separate phase
939  Sync::Object()->openSync(); // decide if to open local Sync
941 #if defined(CMK_BALANCED_INJECTION_API) && CMK_BALANCED_INJECTION_API != 0
942  if(CkMyRank() == 0){
943  // CkPrintf("[%d] get retrieved BI=%d\n",CkMyPe(),balancedInjectionLevel);
944  ck_set_GNI_BIConfig(balancedInjectionLevel);
945  // CkPrintf("[%d] set retrieved BI=%d\n",CkMyPe(),ck_get_GNI_BIConfig());
946  }
947 #endif
948 
949  break;
950 
951  case 18:
952  {
953  //For debugging
954  /*if(!CkMyPe()){
955  FILE *dumpFile = fopen("/tmp/NAMD_Bench.dump", "w");
956  dumpbench(dumpFile);
957  NAMD_die("Normal execution\n");
958  }*/
959  }
960  #ifdef MEM_OPT_VERSION
962  ioMgr->readInfoForParOutDcdSelection();
963  //free space in the Molecule object that are not used anymore
964  ioMgr->freeMolSpace();
965  #endif
966  gotoRun = true;
967  break;
968 
969  default:
970  NAMD_bug("Startup Phase has a bug - check case statement");
971  break;
972 
973  }
974 
975  startupPhase++;
976  if (!CkMyPe()) {
977  if (!gotoRun) {
978  CkStartQD(CkCallback(CkIndex_Node::startup(), thisgroup));
979  } else {
981  }
982  }
983 
984  NAMD_EVENT_STOP(1, NamdProfileEvent::NAMD_STARTUP);
985 }
986 
987 #ifdef OPENATOM_VERSION
988 void Node::doneMoaStart()
989 {
990 #ifdef OPENATOM_VERSION_DEBUG
991  CkPrintf("doneMoaStart executed on processor %d.\n", CkMyPe() );
992 #endif //OPENATOM_VERSION_DEBUG
993 }
994 #endif //OPENATOM_VERSION
995 
996 void Node::namdOneCommInit()
997 {
998  if (CkpvAccess(comm) == NULL) {
999  CkpvAccess(comm) = new Communicate();
1000 #ifdef DPMTA
1001  pvmc_init();
1002 #endif
1003  }
1004 }
1005 
1006 // Namd 1.X style Send/Recv of simulation information
1007 
1008 void Node::namdOneRecv() {
1009  if ( CmiMyRank() ) return;
1010 
1011  MIStream *conv_msg;
1012 
1013  // Receive molecule and simulation parameter information
1015  //****** BEGIN CHARMM/XPLOR type changes
1017  //****** END CHARMM/XPLOR type changes
1019 
1020  DebugM(4, "Getting SimParameters\n");
1021  conv_msg = CkpvAccess(comm)->newInputStream(0, SIMPARAMSTAG);
1023 
1024  DebugM(4, "Getting Parameters\n");
1025  conv_msg = CkpvAccess(comm)->newInputStream(0, STATICPARAMSTAG);
1026  parameters->receive_Parameters(conv_msg);
1027 
1028  DebugM(4, "Getting Molecule\n");
1029  conv_msg = CkpvAccess(comm)->newInputStream(0, MOLECULETAG);
1030  // Modified by JLai -- 10.21.11
1031  molecule->receive_Molecule(conv_msg);
1032  if(simParameters->goForcesOn) {
1033  iout << iINFO << "Compute Nodes receiving GoMolecule Information" << "\n" << endi;
1034  conv_msg = CkpvAccess(comm)->newInputStream(0, MOLECULETAG);
1035  molecule->receive_GoMolecule(conv_msg);
1036  }
1037  // End of modification
1038  DebugM(4, "Done Receiving\n");
1039 }
1040 
1041 void Node::namdOneSend() {
1045 
1046  MOStream *conv_msg;
1047  // I'm Pe(0) so I send what I know
1048  DebugM(4, "Sending SimParameters\n");
1049  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, SIMPARAMSTAG, BUFSIZE);
1050  simParameters->send_SimParameters(conv_msg);
1051 
1052  DebugM(4, "Sending Parameters\n");
1053  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, STATICPARAMSTAG, BUFSIZE);
1054  parameters->send_Parameters(conv_msg);
1055 
1056  DebugM(4, "Sending Molecule\n");
1057  int bufSize = BUFSIZE;
1058  if(molecule->numAtoms>=1000000) bufSize = 16*BUFSIZE;
1059  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, MOLECULETAG, bufSize);
1060  // Modified by JLai -- 10.21.11
1061  molecule->send_Molecule(conv_msg);
1062 
1063  if(simParameters->goForcesOn) {
1064  iout << iINFO << "Master Node sending GoMolecule Information" << "\n" << endi;
1065  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, MOLECULETAG, bufSize);
1066  molecule->send_GoMolecule(conv_msg);
1067  } // End of modification
1068 }
1069 
1070 
1071 void Node::reloadStructure(const char *fname, const char *pdbname) {
1072  delete molecule;
1073  molecule = state->molecule = 0;
1074  delete pdb;
1075  pdb = state->pdb = 0;
1076  state->loadStructure(fname,pdbname,1);
1077  this->molecule = state->molecule;
1078  this->pdb = state->pdb;
1079  CProxy_Node nodeProxy(thisgroup);
1080  nodeProxy.resendMolecule();
1081 }
1082 
1083 
1085  if ( CmiMyRank() ) {
1086  return;
1087  }
1088  if ( CmiMyPe() == 0 ) {
1089  int bufSize = BUFSIZE;
1090  MOStream *conv_msg;
1091  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, STATICPARAMSTAG, bufSize);
1092  parameters->send_Parameters(conv_msg);
1093  if(molecule->numAtoms>=1000000) bufSize = 16*BUFSIZE;
1094  conv_msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, MOLECULETAG, bufSize);
1095  molecule->send_Molecule(conv_msg);
1096  } else {
1097  MIStream *conv_msg;
1098  delete parameters;
1099  parameters = new Parameters;
1100  conv_msg = CkpvAccess(comm)->newInputStream(0, STATICPARAMSTAG);
1101  parameters->receive_Parameters(conv_msg);
1102  delete molecule;
1104  conv_msg = CkpvAccess(comm)->newInputStream(0, MOLECULETAG);
1105  molecule->receive_Molecule(conv_msg);
1106  }
1111  CProxy_Node nodeProxy(thisgroup);
1112  for ( int i=0; i<CmiMyNodeSize(); ++i ) {
1113  nodeProxy[CmiMyPe()+i].resendMolecule2();
1114  }
1115 }
1116 
1121 }
1122 
1123 
1124 // Initial thread setup
1125 
1126 void Node::threadInit() {
1127  // Thread initialization
1128  if (CthImplemented()) {
1129  CthSetStrategyDefault(CthSelf());
1130  } else {
1131  NAMD_bug("Node::startup() Oh no, tiny elvis, threads not implemented");
1132  }
1133 }
1134 
1135 //
1136 void Node::buildSequencers() {
1139 
1140  // Controller object is only on Pe(0)
1141  if ( ! CkMyPe() ) {
1142  Controller *controller = new Controller(state);
1143  state->useController(controller);
1144 #ifdef NODEGROUP_FORCE_REGISTER
1145  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1146  PatchData *pdata = cpdata.ckLocalBranch();
1147  // OK so I need to wait out here if I want to invoke c_out cm
1148  pdata->c_out = controller;
1149 #endif
1150  }
1151 
1152  CmiNodeBarrier();
1153 
1154  // Assign Sequencer to all HomePatch(es)
1155  for (ai=ai.begin(); ai != ai.end(); ai++) {
1156  HomePatch *patch = (*ai).patch;
1157  Sequencer *sequencer = new Sequencer(patch);
1158  patch->useSequencer(sequencer);
1159  }
1160 }
1161 
1162 
1163 
1164 //-----------------------------------------------------------------------
1165 // Node run() - broadcast to all nodes
1166 //-----------------------------------------------------------------------
1168  (CProxy_Node(CkpvAccess(BOCclass_group).node)).run();
1169 }
1170 
1171 
1172 //-----------------------------------------------------------------------
1173 // run(void) runs the specified simulation for the specified number of
1174 // steps, overriding the contents of the configuration file
1175 //-----------------------------------------------------------------------
1177 {
1178 // NAMD_EVENT_START(1, NamdProfileEvent::NODE_RUN);
1179 
1180  // Start Controller (aka scalar Sequencer) on Pe(0)
1181 // printf("\n\n I am in Node.C in run method about to call state->runController\n\n");
1182  if ( ! CkMyPe() ) {
1183  state->runController();
1184  }
1185 
1186  DebugM(4, "Starting Sequencers\n");
1187  // Run Sequencer on each HomePatch - i.e. start simulation
1190  for (ai=ai.begin(); ai != ai.end(); ai++) {
1191  HomePatch *patch = (*ai).patch;
1192 //CkPrintf("Proc#%d in Node calling Sequencer ",CkMyPe());
1193  patch->runSequencer();
1194  }
1195 
1196  if (!CkMyPe()) {
1197  double newTime = CmiWallTimer();
1198  iout << iINFO << "Startup phase " << startupPhase-1 << " took "
1199  << newTime - startupTime << " s, "
1200  << memusage_MB() << " MB of memory in use\n";
1201  iout << iINFO << "Finished startup at " << newTime << " s, "
1202  << memusage_MB() << " MB of memory in use\n\n" << endi;
1203  fflush(stdout);
1204  }
1205 
1206 // NAMD_EVENT_STOP(1, NamdProfileEvent::NODE_RUN);
1207 }
1208 
1209 
1210 //-----------------------------------------------------------------------
1211 // Node scriptBarrier() - twiddle parameters with simulation halted
1212 //-----------------------------------------------------------------------
1213 
1215  CkStartQD(CkIndex_Node::scriptBarrier(), &thishandle);
1216 }
1217 
1219  //script->awaken();
1220 }
1221 
1223  simParameters->scriptSet(msg->param,msg->value);
1224  delete msg;
1225 }
1226 
1227 void Node::reloadCharges(const char *filename) {
1228  FILE *file = fopen(filename,"r");
1229  if ( ! file ) NAMD_die("node::reloadCharges():Error opening charge file.");
1230 
1231  int n = molecule->numAtoms;
1232  float *charge = new float[n];
1233 
1234  for ( int i = 0; i < n; ++i ) {
1235  if ( ! fscanf(file,"%f",&charge[i]) )
1236  NAMD_die("Node::reloadCharges():Not enough numbers in charge file.");
1237  }
1238 
1239  fclose(file);
1240  CProxy_Node(thisgroup).reloadCharges(charge,n);
1241 #ifdef NODEGROUP_FORCE_REGISTER
1242  if(CkMyPe()==0)
1243  {
1244  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1245  cpdata.setDeviceKernelUpdateCounter();
1246  }
1247 #endif
1248  delete [] charge;
1249 }
1250 
1251 void Node::reloadCharges(float charge[], int n) {
1252  molecule->reloadCharges(charge,n);
1253 }
1254 
1255 
1256 // BEGIN gf
1257 void Node::reloadGridforceGrid(const char * key) {
1258  DebugM(4, "reloadGridforceGrid(const char*) called on node " << CkMyPe() << "\n" << endi);
1259 
1260  int gridnum;
1261  MGridforceParams *mgridParams;
1262  if (key == NULL) {
1265  } else {
1266  gridnum = simParameters->mgridforcelist.index_for_key(key);
1267  mgridParams = simParameters->mgridforcelist.find_key(key);
1268  }
1269 
1270  if (gridnum < 0 || mgridParams == NULL) {
1271  NAMD_die("Node::reloadGridforceGrid(const char*):Could not find grid.");
1272  }
1273 
1274  GridforceGrid *grid = molecule->get_gridfrc_grid(gridnum);
1275  if (grid == NULL) {
1276  NAMD_bug("Node::reloadGridforceGrid(const char*):grid not found");
1277  }
1278  grid->reinitialize(simParameters, mgridParams);
1279 
1280  CProxy_Node(thisgroup).reloadGridforceGrid(gridnum);
1281 #ifdef NODEGROUP_FORCE_REGISTER
1282  if(CkMyPe()==0)
1283  {
1284  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1285  cpdata.setDeviceKernelUpdateCounter();
1286  }
1287 #endif
1288  DebugM(4, "reloadGridforceGrid(const char*) finished\n" << endi);
1289 }
1290 
1291 void Node::updateGridScale(const char* key, Vector scale) {
1292  DebugM(4, "updateGridScale(char*, Vector) called on node " << CkMyPe() << "\n" << endi);
1293 
1294  int gridnum;
1295  MGridforceParams* mgridParams;
1296  if (key == NULL) {
1299  } else {
1300  gridnum = simParameters->mgridforcelist.index_for_key(key);
1301  mgridParams = simParameters->mgridforcelist.find_key(key);
1302  }
1303 
1304  if (gridnum < 0 || mgridParams == NULL) {
1305  NAMD_die("Node::updateGridScale(char*, Vector): Could not find grid.");
1306  }
1307 
1308  GridforceGrid* grid = molecule->get_gridfrc_grid(gridnum);
1309  if (grid == NULL) {
1310  NAMD_bug("Node::updateGridScale(char*, Vector): grid not found");
1311  }
1312  CProxy_Node(thisgroup).updateGridScale(gridnum, scale.x, scale.y, scale.z);
1313 
1314  DebugM(4, "updateGridScale(char*, Vector) finished\n" << endi);
1315 }
1316 void Node::updateGridScale(int gridnum, float sx, float sy, float sz) {
1317  if (CmiMyRank()) return;
1318  DebugM(4, "updateGridScale(char*, int, float, float, float) called on node " << CkMyPe() << "\n" << endi);
1319 
1320  GridforceGrid *grid = molecule->get_gridfrc_grid(gridnum);
1321  if (grid == NULL) {
1322  NAMD_bug("Node::updateGridScale(char*, int, float, float, float):grid not found");
1323  }
1324 
1325  Vector scale(sx,sy,sz);
1327  grid->set_scale( scale );
1328 #ifdef NODEGROUP_FORCE_REGISTER
1329  if(CkMyPe()==0)
1330  {
1331  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1332  cpdata.setDeviceKernelUpdateCounter();
1333  }
1334 #endif
1335  DebugM(4, "updateGridScale(char*, int, float, float, float) finished\n" << endi);
1336 }
1337 
1338 void Node::reloadGridforceGrid(int gridnum) {
1339  if (CmiMyRank()) return;
1340  DebugM(4, "reloadGridforceGrid(int) called on node " << CkMyPe() << "\n" << endi);
1341 
1342  GridforceGrid *grid = molecule->get_gridfrc_grid(gridnum);
1343  if (grid == NULL) {
1344  NAMD_bug("Node::reloadGridforceGrid(int):grid not found");
1345  }
1346 
1347  if (CkMyPe()) {
1348  // not node 0 -> receive grid
1349  DebugM(4, "Receiving grid\n");
1350 
1351  delete grid;
1352 
1353  MIStream *msg = CkpvAccess(comm)->newInputStream(0, GRIDFORCEGRIDTAG);
1354  grid = GridforceGrid::unpack_grid(gridnum, msg);
1355  molecule->set_gridfrc_grid(gridnum, grid);
1356  delete msg;
1357  } else {
1358  // node 0 -> send grid
1359  DebugM(4, "Sending grid\n");
1360 
1361  MOStream *msg = CkpvAccess(comm)->newOutputStream(ALLBUTME, GRIDFORCEGRIDTAG, BUFSIZE);
1362  GridforceGrid::pack_grid(grid, msg);
1363  msg->end();
1364  delete msg;
1365  }
1366 #ifdef NODEGROUP_FORCE_REGISTER
1367  if(CkMyPe()==0)
1368  {
1369  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1370  cpdata.setDeviceKernelUpdateCounter();
1371  }
1372 #endif
1373  DebugM(4, "reloadGridforceGrid(int) finished\n" << endi);
1374 }
1375 // END gf
1376 
1377 
1378 // initiating replica
1379 void Node::sendCheckpointReq(int remote, const char *key, int task, Lattice &lat, ControllerState &cs) {
1380  CheckpointMsg *msg = new (1+strlen(key),0) CheckpointMsg;
1381  msg->replica = CmiMyPartition();
1382  msg->task = task;
1383  msg->checkpoint.lattice = lat;
1384  msg->checkpoint.state = cs;
1385  strcpy(msg->key,key);
1386  envelope *env = UsrToEnv(CheckpointMsg::pack(msg));
1387  CmiSetHandler(env,recvCheckpointCReq_index);
1388 #if CMK_HAS_PARTITION
1389  CmiInterSyncSendAndFree(CkMyPe(),remote,env->getTotalsize(),(char*)env);
1390 #else
1391  CmiSyncSendAndFree(CkMyPe(),env->getTotalsize(),(char*)env);
1392 #endif
1393 }
1394 
1395 // responding replica
1396 extern "C" {
1397  void recvCheckpointCReq_handler(envelope *env) {
1398  Node::Object()->recvCheckpointReq(CheckpointMsg::unpack(EnvToUsr(env)));
1399  }
1400 }
1401 
1402 // responding replica
1404  state->controller->recvCheckpointReq(msg->key,msg->task,msg->checkpoint);
1405 
1406  int remote = msg->replica;
1407  msg->replica = CmiMyPartition();
1408  envelope *env = UsrToEnv(CheckpointMsg::pack(msg));
1409  CmiSetHandler(env,recvCheckpointCAck_index);
1410 #if CMK_HAS_PARTITION
1411  CmiInterSyncSendAndFree(CkMyPe(),remote,env->getTotalsize(),(char*)env);
1412 #else
1413  CmiSyncSendAndFree(CkMyPe(),env->getTotalsize(),(char*)env);
1414 #endif
1415 }
1416 
1417 // initiating replica
1418 extern "C" {
1419  void recvCheckpointCAck_handler(envelope *env) {
1420  Node::Object()->recvCheckpointAck(CheckpointMsg::unpack(EnvToUsr(env)));
1421  }
1422 }
1423 
1424 // initiating replica
1426  state->controller->recvCheckpointAck(msg->checkpoint);
1427  delete msg;
1428 }
1429 
1430 
1432  //CmiPrintf("sendEnableExitScheduler\n");
1433  CProxy_Node nodeProxy(thisgroup);
1434  nodeProxy[0].recvEnableExitScheduler();
1435 }
1436 
1438  //CmiPrintf("recvEnableExitScheduler\n");
1440 }
1441 
1443  if ( CkMyPe() ) {
1445  } else {
1446  CkStartQD(CkIndex_Node::exitScheduler(), &thishandle);
1447  }
1448 }
1449 
1451  //CmiPrintf("exitScheduler %d\n",CkMyPe());
1452  CsdExitScheduler();
1453 }
1454 
1456  CProxy_Node nodeProxy(thisgroup);
1457  nodeProxy[0].recvEnableEarlyExit();
1458 }
1459 
1461  enableEarlyExit();
1462 }
1463 
1465  if ( CkMyPe() ) {
1467  } else {
1468  CkStartQD(CkIndex_Node::earlyExit(),&thishandle);
1469  }
1470 }
1471 
1472 void Node::earlyExit(void) {
1473  NAMD_die("Exiting prematurely; see error messages above.");
1474 }
1475 
1476 
1477 //------------------------------------------------------------------------
1478 // Some odd utilities
1479 //------------------------------------------------------------------------
1481 {
1482  this->molecule = state->molecule;
1483  this->parameters = state->parameters;
1484  this->simParameters = state->simParameters;
1485  this->configList = state->configList;
1486  this->pdb = state->pdb;
1487  this->state = state;
1488 }
1489 
1490 // entry methods for BG/P HPM (performance counters) library
1492 #if USE_HPM
1493  HPM_Start("500 steps", localRankOnNode);
1494 #endif
1495 }
1496 
1498 #if USE_HPM
1499  HPM_Stop("500 steps", localRankOnNode);
1500  HPM_Print(CkMyPe(), localRankOnNode);
1501 #endif
1502 }
1503 
1504 void Node::traceBarrier(int turnOnTrace, int step){
1505  curTimeStep = step;
1506  if(turnOnTrace) traceBegin();
1507  else traceEnd();
1508 
1509  if(turnOnTrace) CmiTurnOnStats();
1510  else CmiTurnOffStats();
1511 
1512  //CkPrintf("traceBarrier (%d) at step %d called on proc %d\n", turnOnTrace, step, CkMyPe());
1513  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1514  CkCallback cb(CkIndex_Node::resumeAfterTraceBarrier(NULL), nd[0]);
1515  contribute(0, NULL, CkReduction::sum_int, cb);
1516 
1517 }
1518 
1519 void Node::resumeAfterTraceBarrier(CkReductionMsg *msg){
1520  CmiAssert(CmiMyPe()==0);
1521  delete msg;
1523 }
1524 
1525 void Node::papiMeasureBarrier(int turnOnMeasure, int step){
1526 #ifdef MEASURE_NAMD_WITH_PAPI
1527  curMFlopStep = step;
1528  double results[NUM_PAPI_EVENTS+1];
1529 
1530  if(turnOnMeasure){
1531  CkpvAccess(papiEvents)[NUM_PAPI_EVENTS]=CmiWallTimer();
1532 
1533  long long counters[NUM_PAPI_EVENTS+1];
1534  int ret=PAPI_start_counters(CkpvAccess(papiEvents), NUM_PAPI_EVENTS);
1535  if(ret==PAPI_OK)
1536  {
1537  // CkPrintf("traceBarrier start counters (%d) at step %d called on proc %d\n", turnOnMeasure, step, CkMyPe());
1538  }
1539  else
1540  {
1541  CkPrintf("error PAPI_start_counters (%d) at step %d called on proc %d\n",ret , step, CkMyPe());
1542  }
1543  if(PAPI_read_counters(counters, NUM_PAPI_EVENTS)!=PAPI_OK)
1544  {
1545  CkPrintf("error PAPI_read_counters %d\n",PAPI_read_counters(counters, NUM_PAPI_EVENTS));
1546  };
1547  }else{
1548  long long counters[NUM_PAPI_EVENTS+1];
1549  for(int i=0;i<NUM_PAPI_EVENTS;i++) counters[i]=0LL;
1550  if(PAPI_read_counters(counters, NUM_PAPI_EVENTS)==PAPI_OK)
1551  {
1552 #if !MEASURE_PAPI_SPP
1553  results[0] = (double)counters[0]/1e6;
1554  results[1] = (double)counters[1]/1e6;
1555 #else
1556  for(int i=0;i<NUM_PAPI_EVENTS;i++) results[i] = counters[i]/1e6;
1557 #endif
1558  // for(int i=0;i<NUM_PAPI_EVENTS;i++) CkPrintf("[%d] counter %d is %ld\n",CkMyPe(),i,counters[i]);
1559  }
1560  else
1561  {
1562  // CkPrintf("error PAPI_read_counters %d\n",PAPI_read_counters(counters, NUM_PAPI_EVENTS));
1563  }
1564  // CkPrintf("traceBarrier stop counters (%d) at step %d called on proc %d\n", turnOnMeasure, step, CkMyPe());
1565 
1566  PAPI_stop_counters(counters, NUM_PAPI_EVENTS);
1567  }
1568  if(CkMyPe()==0)
1569  // CkPrintf("traceBarrier (%d) at step %d called on proc %d\n", turnOnMeasure, step, CkMyPe());
1570  results[NUM_PAPI_EVENTS]=CkpvAccess(papiEvents)[NUM_PAPI_EVENTS]; //starttime
1571  CProxy_Node nd(CkpvAccess(BOCclass_group).node);
1572  CkCallback cb(CkIndex_Node::resumeAfterPapiMeasureBarrier(NULL), nd[0]);
1573  contribute(sizeof(double)*(NUM_PAPI_EVENTS+1), &results, CkReduction::sum_double, cb);
1574 #endif
1575 }
1576 
1577 void Node::resumeAfterPapiMeasureBarrier(CkReductionMsg *msg){
1578 #ifdef MEASURE_NAMD_WITH_PAPI
1579 
1580  if(simParameters->papiMeasureStartStep != curMFlopStep) {
1581  double *results = (double *)msg->getData();
1582  double endtime=CmiWallTimer();
1583  int bstep = simParameters->papiMeasureStartStep;
1584  int estep = bstep + simParameters->numPapiMeasureSteps;
1585 #if MEASURE_PAPI_SPP
1586  CkPrintf("SPP INFO: PAPI_FP_OPS timestep %d to %d is %lf(1e6)\n", bstep,estep,results[0]);
1587  CkPrintf("SPP INFO: PAPI_TOT_INS timestep %d to %d is %lf(1e6)\n", bstep,estep,results[1]);
1588  CkPrintf("SPP INFO: perf::PERF_COUNT_HW_CACHE_LL:MISS timestep %d to %d is %lf(1e6)\n", bstep,estep,results[2]);
1589  CkPrintf("SPP INFO: DATA_PREFETCHER:ALL timestep %d to %d is %lf(1e6)\n", bstep,estep,results[3]);
1590  CkPrintf("SPP INFO: PAPI_L1_DCA timestep %d to %d is %lf(1e6)\n", bstep,estep,results[4]);
1591  CkPrintf("SPP INFO: PAPI_TOT_CYC timestep %d to % is %lf(1e6)\n", bstep,estep,results[5]);
1592  // CkPrintf("SPP INFO: INSTRUCTION_FETCH_STALL timestep %d to %d is %lf(1e6)\n", bstep,estep,results[6]);
1593  // CkPrintf("SPP INFO: WALLtime timestep %d to %d is %lf\n", bstep,estep,endtime-results[NUM_PAPI_EVENTS]/CkNumPes());
1594  CkPrintf("SPP INFO: WALLtime timestep %d to %d is %lf\n", bstep,estep,endtime-results[NUM_PAPI_EVENTS]);
1595  CkPrintf("SPP INFO: endtime %lf avgtime %lf tottime %lf\n", endtime,results[NUM_PAPI_EVENTS]/CkNumPes(),results[NUM_PAPI_EVENTS] );
1596 #else
1597  if(CkpvAccess(papiEvents)[0] == PAPI_FP_INS){
1598  double totalFPIns = results[0];
1599  if(CkpvAccess(papiEvents)[1] == PAPI_FMA_INS) totalFPIns += (results[1]*2);
1600  CkPrintf("FLOPS INFO: from timestep %d to %d, the total FP instruction of NAMD is %lf(x1e6) per processor\n",
1601  bstep, estep, totalFPIns/CkNumPes());
1602  }else{
1603  char nameBuf[PAPI_MAX_STR_LEN];
1604  CkPrintf("PAPI COUNTERS INFO: from timestep %d to %d, ",
1605  bstep, estep);
1606  for(int i=0; i<NUM_PAPI_EVENTS; i++) {
1607  PAPI_event_code_to_name(CkpvAccess(papiEvents)[i], nameBuf);
1608  CkPrintf("%s is %lf(x1e6), ", nameBuf, results[i]/CkNumPes());
1609  }
1610  CkPrintf("per processor\n");
1611  }
1612 #endif
1613  }
1614  delete msg;
1615  state->controller->resumeAfterPapiMeasureBarrier(curMFlopStep);
1616 #endif
1617 }
1618 
1619 extern char *gNAMDBinaryName;
1620 void Node::outputPatchComputeMaps(const char *filename, int tag){
1622 
1623  int numpes = CkNumPes();
1624  int nodesize = CkMyNodeSize();
1626  numpes = simParameters->simulatedPEs;
1627  nodesize = simParameters->simulatedNodeSize;
1628  }
1629 
1630  char fname[128];
1631  sprintf(fname, "mapdump_%s.%d_%d_%d_%s", filename, numpes, nodesize, tag, gNAMDBinaryName);
1632 
1633  FILE *fp = fopen(fname, "w");
1634  if(fp == NULL) {
1635  NAMD_die("Error in outputing PatchMap and ComputeMap info!\n");
1636  return;
1637  }
1638  PatchMap *pMap = PatchMap::Object();
1639  ComputeMap *cMap = ComputeMap::Object();
1640  int numPatches = pMap->numPatches();
1641  int numComputes = cMap->numComputes();
1642  fprintf(fp, "%d %d %d %d %d %d %d\n", numpes, nodesize, numPatches, numComputes,
1643  pMap->gridsize_a(), pMap->gridsize_b(), pMap->gridsize_c());
1644  //output PatchMap info
1645  for(int i=0; i<numPatches; i++) {
1646  #ifdef MEM_OPT_VERSION
1647  fprintf(fp, "%d %d\n", pMap->numAtoms(i), pMap->node(i));
1648  #else
1649  fprintf(fp, "%d %d\n", pMap->patch(i)->getNumAtoms(), pMap->node(i));
1650  #endif
1651  }
1652 
1653  //output ComputeMap info
1654  for(int i=0; i<numComputes; i++) {
1655  fprintf(fp, "%d %d %d %d\n", cMap->node(i), cMap->type(i), cMap->pid(i,0), cMap->pid(i,1));
1656  }
1657 }
1658 
1660 #ifndef NODEGROUP_FORCE_REGISTER
1661  return script;
1662 #else
1663  if(script == NULL){
1664  CProxy_PatchData cpdata(CkpvAccess(BOCclass_group).patchData);
1665  PatchData* patchData = cpdata.ckLocalBranch();
1666  return patchData->script;
1667  }else{
1668  return script;
1669  }
1670 #endif
1671 }
1672 
1673 
1674 //======================================================================
1675 // Private functions
1676 
1677 #include "Node.def.h"
1678 
static Node * Object()
Definition: Node.h:86
#define GRIDFORCEGRIDTAG
Definition: common.h:183
void allocateMap(int nAtomIDs)
Definition: AtomMap.C:161
#define NAMD_EVENT_STOP(eon, id)
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
bool specialTracing
Definition: Node.h:166
Bool simulateInitialMapping
void recvCheckpointReq(const char *key, int task, checkpoint &cp)
Definition: Controller.C:4946
int getNumAtoms() const
Definition: Patch.h:105
void recvCheckpointCReq_handler(envelope *)
Definition: Node.C:1397
void setPatchMapArrived(bool s)
Definition: WorkDistrib.h:108
void runSequencer(void)
Definition: HomePatch.C:305
void createProxies(void)
Definition: ProxyMgr.C:416
GridforceGrid * get_gridfrc_grid(int gridnum) const
Definition: Molecule.h:1368
void end(void)
Definition: MStream.C:176
ControllerState state
Definition: Controller.h:388
bool getIsMasterDevice()
Definition: GlobalGPUMgr.h:124
void setRecvSpanning()
Definition: ProxyMgr.C:370
void receive_SimParameters(MIStream *)
int proxyRecvSpanning
Definition: ProxyMgr.C:45
BOCgroup group
Definition: Node.h:68
int numComputes(void)
Definition: ComputeMap.h:103
int getRecvSpanning()
Definition: ProxyMgr.C:375
int curTimeStep
Definition: Node.h:152
void send_GoMolecule(MOStream *)
Definition: GoMolecule.C:1636
void mallocTest(int)
Definition: Node.C:406
void startHPM()
Definition: Node.C:1491
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
NAMD_HOST_DEVICE int c_p() const
Definition: Lattice.h:291
void exitScheduler(void)
Definition: Node.C:1450
IMDOutput * imd
Definition: Node.h:186
void saveMolDataPointers(NamdState *)
Definition: Node.C:1480
void receive_GoMolecule(MIStream *)
Definition: GoMolecule.C:1745
LdbCoordinator * ldbCoordinator
Definition: Node.h:205
static PatchMap * Object()
Definition: PatchMap.h:27
void sendEnableEarlyExit(void)
Definition: Node.C:1455
void send_Molecule(MOStream *)
Definition: Molecule.C:5665
static void exit(int status=0)
Definition: BackEnd.C:284
Definition: Vector.h:72
static AtomMap * Instance()
Definition: AtomMap.C:125
Output * output
Definition: Node.h:185
SimParameters * simParameters
Definition: Node.h:181
int task
Definition: Node.C:100
void setSendSpanning()
Definition: ProxyMgr.C:361
static void pack_grid(GridforceGrid *grid, MOStream *msg)
Definition: GridForceGrid.C:50
#define DebugM(x, y)
Definition: Debug.h:75
void createLoadBalancer()
Controller * c_out
Definition: PatchData.h:147
double startupTime
Definition: Node.C:300
HomePatchList * homePatchList()
Definition: PatchMap.C:438
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
#define ALLBUTME
Definition: Communicate.h:14
BigReal z
Definition: Vector.h:74
void enableScriptBarrier()
Definition: Node.C:1214
int getSendSpanning()
Definition: ProxyMgr.C:366
void initMasterScope(const int isMasterPe, const int isMasterDevice, const int numDevices, const int deviceIndex, const std::vector< int > &masterPeList)
void initializeGPUResident()
Definition: Node.C:450
void initialize()
Definition: GlobalGPUMgr.C:58
void scriptSet(const char *, const char *)
char value[MAX_SCRIPT_PARAM_SIZE]
Definition: Node.h:75
void sendEnableExitScheduler(void)
Definition: Node.C:1431
void recvCheckpointReq(CheckpointMsg *)
Definition: Node.C:1403
static void messageStartUp()
Definition: Node.C:433
ResizeArrayIter< T > begin(void) const
void stopHPM()
Definition: Node.C:1497
void reloadCharges(float charge[], int n)
#define iout
Definition: InfoStream.h:51
Patch * patch(PatchID pid)
Definition: PatchMap.h:244
int curMFlopStep
Definition: Node.h:157
#define STATICPARAMSTAG
Definition: common.h:178
Molecule * node_molecule
Definition: Node.C:439
void outputPatchComputeMaps(const char *filename, int tag)
Definition: Node.C:1620
int loadStructure(const char *, const char *, int)
Definition: NamdState.C:165
void createComputes(ComputeMap *map)
Definition: ComputeMgr.C:1037
Molecule stores the structural information for the system.
Definition: Molecule.h:174
NAMD_HOST_DEVICE int b_p() const
Definition: Lattice.h:290
int replica
Definition: Node.C:101
void split(int iStream, int numStreams)
Definition: Random.h:77
void recvCheckpointAck(CheckpointMsg *)
Definition: Node.C:1425
void patchMapInit(void)
Definition: WorkDistrib.C:1238
void openSync()
Definition: Sync.C:63
ComputeMap * computeMap
Definition: Node.h:204
int gridsize_c(void) const
Definition: PatchMap.h:66
void runController(void)
Definition: NamdState.C:83
double memusage_MB()
Definition: memusage.h:13
virtual void reinitialize(SimParameters *simParams, MGridforceParams *mgridParams)=0
#define SEQ_STK_SZ
Definition: Thread.h:11
void sendComputeMap(void)
Definition: WorkDistrib.C:1211
#define PRIORITY_SIZE
Definition: Priorities.h:13
Definition: Output.h:35
int gridsize_a(void) const
Definition: PatchMap.h:64
int getDeviceIndex()
Definition: GlobalGPUMgr.h:101
void resumeAfterPapiMeasureBarrier(CkReductionMsg *msg)
Definition: Node.C:1577
void initialize(PatchMap *pmap, ComputeMap *cmap, int reinit=0)
void scriptParam(ScriptParamMsg *)
Definition: Node.C:1222
Definition: Random.h:37
int index_for_key(const char *key)
void run()
Definition: Node.C:1176
int numPatches(void) const
Definition: PatchMap.h:59
#define NAMD_EVENT_START(eon, id)
void enableExitScheduler(void)
Definition: Node.C:1442
void buildProxySpanningTree()
Definition: ProxyMgr.C:558
void createHomePatches(void)
Definition: WorkDistrib.C:989
void NAMD_bug(const char *err_msg)
Definition: common.C:196
char * gNAMDBinaryName
Definition: BackEnd.C:247
ComputeType type(ComputeID cid)
Definition: ComputeMap.C:118
ScaledPosition smax
Definition: ComputeMsm.h:21
Controller::checkpoint checkpoint
Definition: Node.C:102
NamdState * state
Definition: Node.h:184
#define MGRIDFORCEPARAMS_DEFAULTKEY
MGridforceParams * find_key(const char *key)
void traceBarrier(int turnOnTrace, int step)
Definition: Node.C:1504
ScriptTcl * script
Definition: PatchData.h:160
void updateGridScale(const char *key, Vector scale)
Definition: Node.C:1291
static void pme_select()
static void messageRun()
Definition: Node.C:1167
void scriptBarrier(void)
Definition: Node.C:1218
static Sync * Object()
Definition: Sync.h:52
void recvCheckpointAck(checkpoint &cp)
Definition: Controller.C:4976
void reloadStructure(const char *, const char *)
Definition: Node.C:1071
BigReal x
Definition: Vector.h:74
AtomMap * atomMap
Definition: Node.h:202
void recvEnableExitScheduler(void)
Definition: Node.C:1437
void get_extremes(ScaledPosition &xmin, ScaledPosition &xmax) const
Definition: PDB.h:104
NAMD_HOST_DEVICE int a_p() const
Definition: Lattice.h:289
int numAtoms
Definition: Molecule.h:586
void NAMD_die(const char *err_msg)
Definition: common.C:148
PDB * pdb
Definition: Node.h:183
static LdbCoordinator * Object()
void initializeBackends()
Definition: GlobalGPUMgr.C:94
int getNumDevices()
Definition: GlobalGPUMgr.h:96
ConfigList * configList
Definition: Node.h:182
const std::vector< int > & getDeviceIndexToPeMap() const
Definition: GlobalGPUMgr.h:116
static AtomMap * Object()
Definition: AtomMap.h:37
#define BUFSIZE
Definition: Communicate.h:15
MGridforceParamsList mgridforcelist
static void nonbonded_select()
void recvEnableEarlyExit(void)
Definition: Node.C:1460
void sendPatchMap(void)
Definition: WorkDistrib.C:1111
void send_Parameters(MOStream *)
Definition: Parameters.C:6560
int isRecvSpanningTreeOn()
Parameters * parameters
Definition: Node.h:180
static ComputeMap * Instance()
Definition: ComputeMap.C:24
void resumeAfterTraceBarrier(CkReductionMsg *msg)
Definition: Node.C:1519
unsigned int randomSeed
CkpvDeclare(AtomMap *, AtomMap_instance)
WorkDistrib * workDistrib
Definition: Node.h:169
~Node(void)
Definition: Node.C:369
Parameters * node_parameters
Definition: Node.C:438
static GridforceGrid * unpack_grid(int gridnum, MIStream *msg)
Definition: GridForceGrid.C:60
#define SIMPARAMSTAG
Definition: common.h:177
SimParameters * node_simParameters
Definition: Node.C:437
Random * rand
Definition: Node.h:175
void mallocTestQd(void)
Definition: Node.C:418
void mapComputes(void)
Definition: WorkDistrib.C:2407
void recvCheckpointCAck_handler(envelope *)
Definition: Node.C:1419
void registerUserEventsForAllComputeObjs(void)
Definition: ComputeMgr.C:853
static ComputeMap * Object()
Definition: ComputeMap.h:91
PatchMap * patchMap
Definition: Node.h:203
ScaledPosition smin
Definition: ComputeMsm.h:21
void useController(Controller *controllerPtr)
Definition: NamdState.C:78
void papiMeasureBarrier(int turnOnMeasure, int step)
Definition: Node.C:1525
BigReal y
Definition: Vector.h:74
void resendMolecule2()
Definition: Node.C:1117
ScriptTcl * getScript()
Definition: Node.C:1659
void resendMolecule()
Definition: Node.C:1084
void distributeHomePatches(void)
Definition: WorkDistrib.C:1063
void setProxyTreeBranchFactor(int dim)
Definition: ProxyMgr.C:379
colvarmodule * colvars
Definition: Node.h:187
int eventEndOfTimeStep
Definition: Node.C:299
void startup()
Definition: Node.C:465
int node(ComputeID cid)
Definition: ComputeMap.h:108
int gridsize_b(void) const
Definition: PatchMap.h:65
int set_gridfrc_grid(int gridnum, GridforceGrid *grid)
Definition: Molecule.h:1377
__thread DeviceCUDA * deviceCUDA
Definition: DeviceCUDA.C:23
int pid(ComputeID cid, int i)
Definition: ComputeMap.C:107
#define MOLECULETAG
Definition: common.h:179
int isSendSpanningTreeOn()
Node(GroupInitMsg *msg)
Definition: Node.C:304
void resumeAfterTraceBarrier(int)
Definition: Controller.C:5016
void sendCheckpointReq(int remote, const char *key, int task, Lattice &lat, ControllerState &cs)
Definition: Node.C:1379
ComputeMgr * computeMgr
Definition: Node.h:172
int node(int pid) const
Definition: PatchMap.h:114
int mallocTest_size
Definition: Node.h:130
static GlobalGPUMgr * Object()
Definition: GlobalGPUMgr.h:61
void enableEarlyExit(void)
Definition: Node.C:1464
void receive_Molecule(MIStream *)
Definition: Molecule.C:6031
void earlyExit(void)
Definition: Node.C:1472
MGridforceParams * at_index(int idx)
ResizeArrayIter< T > end(void) const
static PatchMap * Instance()
Definition: PatchMap.C:32
Molecule * molecule
Definition: Node.h:179
int getIsMasterPe()
Definition: GlobalGPUMgr.h:106
void useSequencer(Sequencer *sequencerPtr)
Definition: HomePatch.C:301
char param[MAX_SCRIPT_PARAM_SIZE]
Definition: Node.h:74
void receive_Parameters(MIStream *)
Definition: Parameters.C:6936
static SynchronousCollectives * Object()
virtual void set_scale(Vector s)=0
void reloadCharges(const char *filename)
Definition: Node.C:1227
void send_SimParameters(MOStream *)
void reloadGridforceGrid(const char *key)
Definition: Node.C:1257
void assignNodeToPatch(void)
Definition: WorkDistrib.C:1456
char * key
Definition: Node.C:103
int proxySendSpanning
Definition: ProxyMgr.C:44