NAMD
DumpBench.C
Go to the documentation of this file.
1 
2 #include <stdio.h>
3 #include "InfoStream.h"
4 #include "DumpBench.h"
5 #include "SimParameters.h"
6 #include "ComputeNonbondedUtil.h"
7 #include "LJTable.h"
8 #include "Molecule.h"
9 #include "Node.h"
10 #include "PatchMap.h"
11 #include "HomePatch.h"
12 #include "NamdState.h"
13 #include "ComputeMap.h"
14 
15 inline void dump_param(FILE *file, const char *name, int value) {
16  fprintf(file,"%s %d\n",name,value);
17 }
18 
19 inline void dump_param(FILE *file, const char *name, double value) {
20  fprintf(file,"%s %g\n",name,value);
21 }
22 
23 inline void dump_param(FILE *file, const char *name, Vector value) {
24  fprintf(file,"%s %f %f %f\n",name,value.x,value.y,value.z);
25 }
26 
27 int dumpbench(FILE *file) {
28 
29  Node *node = Node::Object();
30 
31  fprintf(file,"SIMPARAMETERS_BEGIN\n");
32 
34 
35 #define SIMPARAM(T,N,V) dump_param(file,#N,simParams->N)
36 #include "DumpBenchParams.h"
37 #undef SIMPARAM
38 
39  fprintf(file,"SIMPARAMETERS_END\n");
40 
41  fprintf(file,"LJTABLE_BEGIN\n");
42 
43  const LJTable *ljTable = ComputeNonbondedUtil::ljTable;
44 
45  int table_dim = ljTable->get_table_dim();
46  fprintf(file,"%d\n",table_dim);
47 
48  const LJTable::TableEntry *table = ljTable->get_table();
49  int i,j;
50  for ( i=0; i < table_dim; ++i) {
51  for ( j=i; j < table_dim; ++j)
52  {
53  const LJTable::TableEntry *curij = &(table[2*(i*table_dim+j)]);
54  fprintf(file,"%g %g %g %g\n",curij->A,curij->B,
55  (curij+1)->A,(curij+1)->B);
56  }
57  }
58 
59  fprintf(file,"LJTABLE_END\n");
60 
61  fprintf(file,"MOLECULE_BEGIN\n");
62 
63  const Molecule *mol = node->molecule;
64 
65  fprintf(file,"%d %ld\n",mol->numAtoms,mol->numCalcExclusions);
66 
67  for ( i=0; i<mol->numAtoms; ++i) {
68  int vdw = mol->atomvdwtype(i);
69  #ifdef MEM_OPT_VERSION
70  Index exclIdx = mol->getAtomExclSigId(i);
71  const ExclusionCheck *excl = mol->get_excl_check_for_idx(exclIdx);
72  //if(excl->flags==NULL || excl->flags == (char *)-1){
73  // fprintf(file,"%d: %d ====\n",i, vdw);
74  // continue;
75  //}
76  int min = i+excl->min;
77  int max = i+excl->max;
78  #else
79  const ExclusionCheck *excl = mol->get_excl_check_for_atom(i);
80  //if(excl->flags==NULL || excl->flags == (char *)-1){
81  // fprintf(file,"%d: %d ====\n",i, vdw);
82  // continue;
83  //}
84  int min = excl->min;
85  int max = excl->max;
86  #endif
87  // fprintf(file,"%d: %d %d %d |",i,vdw,min,max);
88  fprintf(file,"%d %d %d",vdw,min,max);
89  if ( min <= max ) {
90  int s = max - min + 1;
91  const char *f = excl->flags;
92  for ( int k=0; k<s; ++k ) {
93  int fk = f[k];
94  fprintf(file," %d",fk);
95  }
96  }
97  fprintf(file,"\n");
98  }
99 
100  fprintf(file,"MOLECULE_END\n");
101 
102 #if 0
103  fprintf(file, "BONDS_BEGIN\n");
104  fprintf(file, "%d %d\n", mol->numBonds, mol->numCalcBonds);
105 #ifdef MEM_OPT_VERSION
106  for(i=0; i<mol->numAtoms; i++){
107  int sigId = node->molecule->getAtomSigId(i);
108  AtomSignature *sig = &(mol->atomSigPool[sigId]);
109  if(sig->bondCnt==0){
110  fprintf(file, "%d: ===\n", i);
111  continue;
112  }
113  fprintf(file, "%d:", i);
114  for(j=0; j<sig->bondCnt; j++){
115  fprintf(file, " (%d | %d)", (sig->bondSigs[j]).offset[0], sig->bondSigs[j].tupleParamType);
116  }
117  fprintf(file, "\n");
118  }
119 #else
120  for(i=0; i<mol->numAtoms; i++){
121  int *p = node->molecule->get_bonds_for_atom(i);
122  if(*p==-1){
123  fprintf(file, "%d: ===\n", i);
124  continue;
125  }
126  fprintf(file, "%d:", i);
127  for(; *p!=-1;p++){
128  Bond *t = mol->get_bond(*p);
129  fprintf(file, " (%d | %d)", t->atom2-i, t->bond_type);
130  }
131  fprintf(file, "\n");
132  }
133 #endif
134  fprintf(file, "BONDS_END\n");
135 
136  fprintf(file, "ANGLES_BEGIN\n");
137  fprintf(file, "%d %d\n", mol->numAngles, mol->numCalcAngles);
138 #ifdef MEM_OPT_VERSION
139  for(i=0; i<mol->numAtoms; i++){
140  int sigId = node->molecule->getAtomSigId(i);
141  AtomSignature *sig = &(mol->atomSigPool[sigId]);
142  if(sig->angleCnt==0){
143  fprintf(file, "%d: ===\n", i);
144  continue;
145  }
146  fprintf(file, "%d:", i);
147  for(j=0; j<sig->angleCnt; j++){
148  int offset0 = (sig->angleSigs[j]).offset[0];
149  int offset1 = (sig->angleSigs[j]).offset[1];
150  fprintf(file, " (%d, %d | %d)", offset0, offset1, sig->angleSigs[j].tupleParamType);
151  }
152  fprintf(file, "\n");
153  }
154 #else
155  for(i=0; i<mol->numAtoms; i++){
156  int *p = node->molecule->get_angles_for_atom(i);
157  if(*p==-1){
158  fprintf(file, "%d: ===\n", i);
159  continue;
160  }
161  fprintf(file, "%d:", i);
162  for(; *p!=-1;p++){
163  Angle *t = mol->get_angle(*p);
164  int offset0 = t->atom2 - i;
165  int offset1 = t->atom3 - i;
166  fprintf(file, " (%d, %d | %d)", offset0, offset1, t->angle_type);
167  }
168  fprintf(file, "\n");
169  }
170 #endif
171  fprintf(file, "ANGLES_END\n");
172 
173  fprintf(file, "DIHEDRALS_BEGIN\n");
174  fprintf(file, "%d %d\n", mol->numDihedrals, mol->numCalcDihedrals);
175 #ifdef MEM_OPT_VERSION
176  for(i=0; i<mol->numAtoms; i++){
177  int sigId = node->molecule->getAtomSigId(i);
178  AtomSignature *sig = &(mol->atomSigPool[sigId]);
179  if(sig->dihedralCnt==0){
180  fprintf(file, "%d: ===\n", i);
181  continue;
182  }
183  fprintf(file, "%d:", i);
184  for(j=0; j<sig->dihedralCnt; j++){
185  int offset0 = (sig->dihedralSigs[j]).offset[0];
186  int offset1 = (sig->dihedralSigs[j]).offset[1];
187  int offset2 = (sig->dihedralSigs[j]).offset[2];
188  fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, sig->dihedralSigs[j].tupleParamType);
189  }
190  fprintf(file, "\n");
191  }
192 #else
193  for(i=0; i<mol->numAtoms; i++){
194  int *p = node->molecule->get_dihedrals_for_atom(i);
195  if(*p==-1){
196  fprintf(file, "%d: ===\n", i);
197  continue;
198  }
199  fprintf(file, "%d:", i);
200  for(; *p!=-1;p++){
201  Dihedral *t = mol->get_dihedral(*p);
202  int offset0 = t->atom2 - i;
203  int offset1 = t->atom3 - i;
204  int offset2 = t->atom4 - i;
205  fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, t->dihedral_type);
206  }
207  fprintf(file, "\n");
208  }
209 #endif
210  fprintf(file, "DIHEDRALS_END\n");
211 
212  fprintf(file, "IMPROPERS_BEGIN\n");
213  fprintf(file, "%d %d\n", mol->numImpropers, mol->numCalcImpropers);
214 #ifdef MEM_OPT_VERSION
215  for(i=0; i<mol->numAtoms; i++){
216  int sigId = node->molecule->getAtomSigId(i);
217  AtomSignature *sig = &(mol->atomSigPool[sigId]);
218  if(sig->improperCnt==0){
219  fprintf(file, "%d: ===\n", i);
220  continue;
221  }
222  fprintf(file, "%d:", i);
223  for(j=0; j<sig->improperCnt; j++){
224  int offset0 = (sig->improperSigs[j]).offset[0];
225  int offset1 = (sig->improperSigs[j]).offset[1];
226  int offset2 = (sig->improperSigs[j]).offset[2];
227  fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, sig->improperSigs[j].tupleParamType);
228  }
229  fprintf(file, "\n");
230  }
231 #else
232  for(i=0; i<mol->numAtoms; i++){
233  int *p = node->molecule->get_impropers_for_atom(i);
234  if(*p==-1){
235  fprintf(file, "%d: ===\n", i);
236  continue;
237  }
238  fprintf(file, "%d:", i);
239  for(; *p!=-1;p++){
240  Improper *t = mol->get_improper(*p);
241  int offset0 = t->atom2 - i;
242  int offset1 = t->atom3 - i;
243  int offset2 = t->atom4 - i;
244  fprintf(file, " (%d, %d, %d | %d)", offset0, offset1, offset2, t->improper_type);
245  }
246  fprintf(file, "\n");
247  }
248 #endif
249  fprintf(file, "IMPROPERS_END\n");
250 #endif
251 
252  fprintf(file,"PATCHLIST_BEGIN\n");
253 
254  PatchMap *patchMap = PatchMap::Object();
255  int numPatches = patchMap->numPatches();
256  fprintf(file,"%d\n",numPatches);
257 
258  for ( i=0; i<numPatches; ++i) {
259  HomePatch *patch = patchMap->homePatch(i);
260  fprintf(file,"PATCH_BEGIN\n");
261  int numAtoms = patch->getNumAtoms();
262  fprintf(file,"%d\n",numAtoms);
263  FullAtomList &atoms = patch->getAtomList();
264  for ( j=0; j<numAtoms; ++j) {
265  FullAtom &a = atoms[j];
266  double x,y,z,q;
267  int id,hgs,ngia,af,gf,part;
268  x = a.position.x;
269  y = a.position.y;
270  z = a.position.z;
271  q = a.charge;
272  id = a.id;
273  hgs = a.hydrogenGroupSize;
274  ngia = ( hgs != 1 && a.nonbondedGroupSize == 1 ) ? 1 : 0;
275  af = a.atomFixed;
276  gf = a.groupFixed;
277  part = a.partition;
278  fprintf(file,"%f %f %f %f %d %d %d %d %d %d\n",
279  x,y,z,q,id,hgs,ngia,af,gf,part);
280  }
281  fprintf(file,"PATCH_END\n");
282  }
283 
284  fprintf(file,"PATCHLIST_END\n");
285 
286  fprintf(file,"COMPUTEPAIR_BEGIN\n");
287 
288  ComputeMap *computeMap = ComputeMap::Object();
289  int numComputes = computeMap->numComputes();
290  int numPairComputes = 0;
291  for ( i=0; i<numComputes; ++i) {
292  if ( computeMap->type(i) == computeNonbondedPairType
293  && computeMap->partition(i) == 0 ) ++numPairComputes;
294  }
295  fprintf(file,"%d\n",numPairComputes);
296  for ( i=0; i<numComputes; ++i) {
297  if ( computeMap->type(i) == computeNonbondedPairType
298  && computeMap->partition(i) == 0 ) {
299  int pid1 = computeMap->pid(i,0);
300  int trans1 = computeMap->trans(i,0);
301  int pid2 = computeMap->pid(i,1);
302  int trans2 = computeMap->trans(i,1);
303  fprintf(file,"%d %d %d %d\n",pid1,trans1,pid2,trans2);
304  }
305  }
306 
307  fprintf(file,"COMPUTEPAIR_END\n");
308 
309  return 0;
310 }
311 
static Node * Object()
Definition: Node.h:86
unsigned char partition
Definition: NamdTypes.h:56
int32 atom4
Definition: structures.h:75
Index improper_type
Definition: structures.h:76
int32 * get_dihedrals_for_atom(int anum)
Definition: Molecule.h:1149
int numCalcBonds
Definition: Molecule.h:621
int numBonds
Definition: Molecule.h:559
int numComputes(void)
Definition: ComputeMap.h:101
unsigned int hydrogenGroupSize
Definition: NamdTypes.h:58
Definition: Node.h:78
unsigned int atomFixed
Definition: NamdTypes.h:96
int32 atom3
Definition: structures.h:65
static PatchMap * Object()
Definition: PatchMap.h:27
TupleSignature * improperSigs
Definition: structures.h:336
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t cudaTextureObject_t const int const float const PatchPairRecord *__restrict__ const int *__restrict__ const int2 *__restrict__ const unsigned int *__restrict__ unsigned int *__restrict__ int *__restrict__ int *__restrict__ TileListStat *__restrict__ const BoundingBox *__restrict__ float4 *__restrict__ float4 *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ float *__restrict__ const int numPatches
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
Improper * get_improper(int inum) const
Definition: Molecule.h:1071
static __thread atom * atoms
TupleSignature * dihedralSigs
Definition: structures.h:335
char * flags
Definition: Molecule.h:71
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
int get_table_dim() const
Definition: LJTable.h:44
HomePatch * homePatch(PatchID pid)
Definition: PatchMap.h:240
unsigned int groupFixed
Definition: NamdTypes.h:97
int32 * get_angles_for_atom(int anum)
Definition: Molecule.h:1147
Charge charge
Definition: NamdTypes.h:54
int32 atom4
Definition: structures.h:66
int Index
Definition: structures.h:26
FullAtomList & getAtomList()
Definition: HomePatch.h:455
Dihedral * get_dihedral(int dnum) const
Definition: Molecule.h:1074
Index dihedral_type
Definition: structures.h:67
int32 * get_impropers_for_atom(int anum)
Definition: Molecule.h:1151
ComputeType type(ComputeID cid)
Definition: ComputeMap.C:120
int32 atom2
Definition: structures.h:56
gridSize z
int32 * get_bonds_for_atom(int anum)
Definition: Molecule.h:1145
int numCalcDihedrals
Definition: Molecule.h:623
int32 atom3
Definition: structures.h:57
BigReal x
Definition: Vector.h:66
Bond * get_bond(int bnum) const
Definition: Molecule.h:1065
int numCalcImpropers
Definition: Molecule.h:624
int numAngles
Definition: Molecule.h:560
int numAtoms
Definition: Molecule.h:556
TupleSignature * bondSigs
Definition: structures.h:333
int partition(ComputeID cid)
Definition: ComputeMap.C:128
const TableEntry * get_table() const
Definition: LJTable.h:43
Index angle_type
Definition: structures.h:58
int numDihedrals
Definition: Molecule.h:561
int32 atom2
Definition: structures.h:64
int numImpropers
Definition: Molecule.h:566
int64 numCalcExclusions
Definition: Molecule.h:626
#define simParams
Definition: Output.C:127
Index atomvdwtype(int anum) const
Definition: Molecule.h:1058
int numPatches(void) const
Definition: PatchMap.h:59
static ComputeMap * Object()
Definition: ComputeMap.h:89
BigReal y
Definition: Vector.h:66
int getNumAtoms()
Definition: Patch.h:105
static const LJTable * ljTable
Index tupleParamType
Definition: structures.h:202
int32 atom2
Definition: structures.h:73
const ExclusionCheck * get_excl_check_for_atom(int anum) const
Definition: Molecule.h:1173
int dumpbench(FILE *file)
Definition: DumpBench.C:27
gridSize y
int pid(ComputeID cid, int i)
Definition: ComputeMap.C:109
unsigned int nonbondedGroupSize
Definition: NamdTypes.h:57
Index bond_type
Definition: structures.h:50
gridSize x
int trans(ComputeID cid, int i)
Definition: ComputeMap.C:114
Angle * get_angle(int anum) const
Definition: Molecule.h:1068
Molecule * molecule
Definition: Node.h:176
int32 atom3
Definition: structures.h:74
TupleSignature * angleSigs
Definition: structures.h:334
int numCalcAngles
Definition: Molecule.h:622
int32 atom2
Definition: structures.h:49
void dump_param(FILE *file, const char *name, int value)
Definition: DumpBench.C:15