NAMD
Macros | Functions | Variables
ProxyMgr.C File Reference
#include "InfoStream.h"
#include "main.h"
#include "BOCgroup.h"
#include "ProxyMgr.decl.h"
#include "ProxyMgr.h"
#include "PatchMap.inl"
#include "ProxyPatch.h"
#include "ComputeMap.h"
#include "HomePatch.h"
#include <string.h>
#include "ProcessorPrivate.h"
#include "packmsg.h"
#include "Priorities.h"
#include <alloca.h>
#include <malloc.h>
#include <map>
#include <vector>
#include <algorithm>
#include "SimParameters.h"
#include "Node.h"
#include "Debug.h"
#include "ProxyMgr.def.h"

Go to the source code of this file.

Macros

#define MIN_DEBUG_LEVEL   2
 
#define ALLOCA(TYPE, NAME, SIZE)   TYPE *NAME = (TYPE *) alloca((SIZE)*sizeof(TYPE))
 
#define MAX_INTERNODE   1
 
#define HOMEPATCH_TREE_BRFACTOR   2
 

Functions

 PACK_MSG (ProxySpanningTreeMsg, PACK(patch);PACK(node);PACK_RESIZE(tree);)
 
static void outputProxyTree (ProxyTree &ptree, int np)
 
static int compLoad (const void *a, const void *b)
 
static void processCpuLoad ()
 
static int noInterNode (int p)
 

Variables

int proxySendSpanning = 0
 
int proxyRecvSpanning = 0
 
int proxySpanDim = 4
 
int inNodeProxySpanDim = 16
 
double * cpuloads
 
static int * procidx = NULL
 
static double averageLoad = 0.0
 

Macro Definition Documentation

◆ ALLOCA

#define ALLOCA (   TYPE,
  NAME,
  SIZE 
)    TYPE *NAME = (TYPE *) alloca((SIZE)*sizeof(TYPE))

Definition at line 42 of file ProxyMgr.C.

Referenced by ProxyMgr::recvNodeAwareSpanningTree().

◆ HOMEPATCH_TREE_BRFACTOR

#define HOMEPATCH_TREE_BRFACTOR   2

Definition at line 1920 of file ProxyMgr.C.

Referenced by NodeProxyMgr::createSTForHomePatches().

◆ MAX_INTERNODE

#define MAX_INTERNODE   1

Definition at line 608 of file ProxyMgr.C.

Referenced by ProxyMgr::buildSpanningTree0().

◆ MIN_DEBUG_LEVEL

#define MIN_DEBUG_LEVEL   2

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 39 of file ProxyMgr.C.

Function Documentation

◆ compLoad()

static int compLoad ( const void *  a,
const void *  b 
)
static

Definition at line 697 of file ProxyMgr.C.

References cpuloads.

Referenced by processCpuLoad().

698 {
699  int i1 = *(int *)a;
700  int i2 = *(int *)b;
701  double d1 = cpuloads[i1];
702  double d2 = cpuloads[i2];
703  if (d1 < d2)
704  return 1;
705  else if (d1 == d2)
706  return 0;
707  else
708  return -1;
709  // sort from high to low
710 }
double * cpuloads
Definition: NamdCentLB.C:24

◆ noInterNode()

static int noInterNode ( int  p)
static

Definition at line 728 of file ProxyMgr.C.

References procidx.

Referenced by ProxyMgr::buildSpanningTree0().

729 {
730  int exclude = 0;
731  if(CkNumPes()<1025)
732  exclude = 5;
733  else if(CkNumPes()<4097)
734  exclude = 10;
735  else if(CkNumPes()<8193)
736  exclude = 40;
737  else if(CkNumPes()<16385)
738  exclude = 40;
739  else
740  exclude = 80;
741  for (int i=0; i<exclude; i++) if (procidx[i] == p) return 1;
742 // if (cpuloads[p] > averageLoad) return 1;
743  return 0;
744 }
static int * procidx
Definition: ProxyMgr.C:694

◆ outputProxyTree()

static void outputProxyTree ( ProxyTree ptree,
int  np 
)
static

Definition at line 611 of file ProxyMgr.C.

References ProxyTree::proxylist, and ResizeArray< Elem >::size().

611  {
612  FILE *ofp = fopen("patch_proxylist.txt", "w");
613  std::vector<int> plist;
614  for(int i=0; i<np; i++) {
615  fprintf(ofp, "%d: ", i);
616  int listlen = ptree.proxylist[i].size();
617  fprintf(ofp, "#%d ", listlen);
618  plist.clear();
619  for(int j=0; j<listlen; j++) {
620  plist.push_back(ptree.proxylist[i][j]);
621  }
622  std::sort(plist.begin(), plist.end());
623  for(int j=0; j<listlen; j++) {
624  fprintf(ofp, "%d ", plist[j]);
625  }
626  fprintf(ofp, "\n");
627  }
628  fclose(ofp);
629 }
int size(void) const
Definition: ResizeArray.h:131
NodeIDList * proxylist
Definition: ProxyMgr.h:291

◆ PACK_MSG()

PACK_MSG ( ProxySpanningTreeMsg  ,
PACK(patch);PACK(node);PACK_RESIZE(tree);   
)

Definition at line 50 of file ProxyMgr.C.

56  {
57 
58  int msg_size = 0;
59  msg_size += sizeof(msg->node);
60  msg_size += sizeof(msg->patch);
61 
62  int j;
63  for ( j = 0; j < Results::maxNumForces; ++j ) {
64  int array_size = msg->forceList[j]->size();
65  msg_size += sizeof(array_size);
66  msg_size += array_size * sizeof(char);
67  msg_size = ALIGN_8 (msg_size);
68  Force* f = msg->forceList[j]->begin();
69  int nonzero_count = 0;
70  for ( int i = 0; i < array_size; ++i ) {
71  if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) { ++nonzero_count; }
72  }
73  msg_size += nonzero_count * sizeof(Vector);
74  }
75 
76  void *msg_buf = CkAllocBuffer(msg,msg_size);
77  char *msg_cur = (char *)msg_buf;
78 
79  CmiMemcpy((void*)msg_cur,(void*)(&(msg->node)),sizeof(msg->node));
80  msg_cur += sizeof(msg->node);
81  CmiMemcpy((void*)msg_cur,(void*)(&(msg->patch)),sizeof(msg->patch));
82  msg_cur += sizeof(msg->patch);
83  for ( j = 0; j < Results::maxNumForces; ++j ) {
84  int array_size = msg->forceList[j]->size();
85  *(int *) msg_cur = array_size;
86  msg_cur += sizeof(int);
87  char *nonzero = msg_cur;
88  msg_cur += array_size * sizeof(char);
89  msg_cur = (char *)ALIGN_8 (msg_cur);
90  Vector *farr = (Vector *)msg_cur;
91  Force* f = msg->forceList[j]->begin();
92 
93  for ( int i = 0; i < array_size; ++i ) {
94  if ( f[i].x != 0. || f[i].y != 0. || f[i].z != 0. ) {
95  nonzero[i] = 1;
96  farr->x = f[i].x;
97  farr->y = f[i].y;
98  farr->z = f[i].z;
99  farr ++;
100  } else {
101  nonzero[i] = 0;
102  }
103  }
104  msg_cur = (char *) farr;
105  }
106 
107  delete msg;
108  return msg_buf;
109 }
Definition: Vector.h:72
BigReal z
Definition: Vector.h:74
BigReal x
Definition: Vector.h:74
#define ALIGN_8(x)
Definition: packmsg.h:25
BigReal y
Definition: Vector.h:74

◆ processCpuLoad()

static void processCpuLoad ( )
static

Definition at line 712 of file ProxyMgr.C.

References averageLoad, compLoad(), cpuloads, and procidx.

Referenced by ProxyMgr::buildSpanningTree0().

713 {
714  int i;
715  if (!procidx) {
716  procidx = new int[CkNumPes()];
717  }
718  for (i=0; i<CkNumPes(); i++) procidx[i] = i;
719  qsort(procidx, CkNumPes(), sizeof(int), compLoad);
720 
721  double averageLoad = 0.0;
722  for (i=0; i<CkNumPes(); i++) averageLoad += cpuloads[i];
723  averageLoad /= CkNumPes();
724 // iout << "buildSpanningTree1: no intermediate node on " << procidx[0] << " " << procidx[1] << endi;
725 
726 }
double * cpuloads
Definition: NamdCentLB.C:24
static int * procidx
Definition: ProxyMgr.C:694
static double averageLoad
Definition: ProxyMgr.C:695
static int compLoad(const void *a, const void *b)
Definition: ProxyMgr.C:697

Variable Documentation

◆ averageLoad

double averageLoad = 0.0
static

Definition at line 695 of file ProxyMgr.C.

Referenced by processCpuLoad(), NamdHybridLB::splitComputes(), and NamdCentLB::Strategy().

◆ cpuloads

double* cpuloads

Definition at line 24 of file NamdCentLB.C.

Referenced by compLoad(), CreateNamdCentLB(), processCpuLoad(), and NamdCentLB::Strategy().

◆ inNodeProxySpanDim

int inNodeProxySpanDim = 16

Definition at line 48 of file ProxyMgr.C.

◆ procidx

int* procidx = NULL
static

Definition at line 694 of file ProxyMgr.C.

Referenced by noInterNode(), and processCpuLoad().

◆ proxyRecvSpanning

int proxyRecvSpanning = 0

◆ proxySendSpanning

int proxySendSpanning = 0

◆ proxySpanDim

int proxySpanDim = 4