BrookBonded.h 17.4 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
#ifndef OPENMM_BROOK_BONDED_H_
#define OPENMM_BROOK_BONDED_H_
Mark Friedrichs's avatar
Mark Friedrichs committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Peter Eastman, Mark Friedrichs                                    *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include <vector>

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
37
#include "BrookStreamImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
38
#include "BrookCommon.h"
39
#include "openmm/OpenMMContext.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
40
#include "BrookBondParameters.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
41
42
43
44

namespace OpenMM {

/**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
45
 * Calculate Brook bonded forces
Mark Friedrichs's avatar
Mark Friedrichs committed
46
47
48
49
50
 */
class BrookBonded : public BrookCommon {

   public:
  
Mark Friedrichs's avatar
Mark Friedrichs committed
51
52
53
54
55
56
      /** 
       *
       * BrookBonded constructor
       * 
       */
      
Mark Friedrichs's avatar
Mark Friedrichs committed
57
58
      BrookBonded( );
  
Mark Friedrichs's avatar
Mark Friedrichs committed
59
60
61
62
63
64
65
      /** 
       *
       * BrookBonded desstructor
       * 
       */
      
      ~BrookBonded( );
Mark Friedrichs's avatar
Mark Friedrichs committed
66
67
68
69
  
      /**
       * Initialize the kernel, setting up the values of all the force field parameters.
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
70
71
72
73
74
75
76
77
       * @param numberOfParticles                   numberOfParticles
       * @param harmonicBondBrookBondParameters     force parameters (length, k) for each bond term
       * @param harmonicAngleBrookBondParameters    force parameters (angle, k) for each angle term
       * @param periodicTorsionBrookBondParameters  force parameters (k, phase, periodicity) for each periodic torsion term
       * @param rbTorsionBrookBondParameters        coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
       * @param nonBonded14ForceParameters          nonbonded 14 force parameters (charge, sigma, epsilon) for each particle
       * @param particleStreamWidth                 stream width
       * @param particleStreamSize                  stream size
Mark Friedrichs's avatar
Mark Friedrichs committed
78
79
80
81
82
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
83
84
85
86
87
      int setup( int numberOfParticles,
                 BrookBondParameters* harmonicBondBrookBondParameters,
                 BrookBondParameters* harmonicAngleBrookBondParameters,
                 BrookBondParameters* periodicTorsionBrookBondParameters,
                 BrookBondParameters* rbTorsionBrookBondParameters,
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
88
                 BrookBondParameters* nonBonded14ForceParameters,  int particleStreamWidth, int particleStreamSize );
Mark Friedrichs's avatar
Mark Friedrichs committed
89

Mark Friedrichs's avatar
Mark Friedrichs committed
90
91
92
93
94
95
96
97
98
      /**
       * Get inverse map stream width
       * 
       * @return stream width
       *
       */

      int getInverseMapStreamWidth( void ) const;
      
Mark Friedrichs's avatar
Mark Friedrichs committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      /**
       * Return number of parameter streams
       * 
       * @return number of parameter streams
       *
       */

      int getNumberOfParameterStreams( void ) const; 

      /**
       * Return number of force streams
       * 
       * @return number of force streams
       *
       */

      int getNumberOfForceStreams( void ) const; 

      /**
       * Return stream count for specifed index (i, j, k, l)
       * 
       * @return stream count for specifed index
       *
       * @throw throws OpenMMException if index out of range
       */

      int getInverseMapStreamCount( int index ) const; 

      /**
       * Return max stream count
       * 
       * @return max stream count
       */

      int getMaxInverseMapStreamCount( void ) const; 

Mark Friedrichs's avatar
Mark Friedrichs committed
135
136
137
138
139
140
141
142
143
144
145
      /**
       * Return max stream count for specified index
       * 
       * @param index index of force stream
       *
       * @return max stream count
       *
       */

      int getMaxInverseMapStreamCount( int index ) const; 

Mark Friedrichs's avatar
Mark Friedrichs committed
146
147
148
149
150
151
      /**
       * Return Brook stream handle
       * 
       * @return 
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
152
      BrookFloatStreamInternal* getBrookParticleIndices( void ) const; 
Mark Friedrichs's avatar
Mark Friedrichs committed
153
154
155
156
157
158
159
160
161
162
163

      /** 
       * Get Coulomb factor
       * 
       * @return Coulomb factor
       *
       */
      
      BrookOpenMMFloat getCoulombFactor( void ) const;

      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
164
       * Get bonded particle indices stream
Mark Friedrichs's avatar
Mark Friedrichs committed
165
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
166
       * @return  particle indices stream
Mark Friedrichs's avatar
Mark Friedrichs committed
167
168
169
       *
       */
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
170
      BrookFloatStreamInternal* getParticleIndicesStream( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
171
      
172
173
174
175
176
177
178
179
180
      /** 
       * Get bonded charge stream
       * 
       * @return  charge stream
       *
       */
      
      BrookFloatStreamInternal* getChargeStream( void ) const;
      
Mark Friedrichs's avatar
Mark Friedrichs committed
181
182
183
184
185
186
187
      /** 
       * Get array of bonded parameter streams
       * 
       * @return  array of bonded parameter streams
       *
       */
      
Mark Friedrichs's avatar
Mark Friedrichs committed
188
      BrookFloatStreamInternal** getBondedParameterStreams( void );
Mark Friedrichs's avatar
Mark Friedrichs committed
189
190
191
192
193
194
195
196
      
      /** 
       * Get array of force streams
       * 
       * @return  array
       *
       */
      
Mark Friedrichs's avatar
Mark Friedrichs committed
197
      BrookFloatStreamInternal** getBondedForceStreams( void );
Mark Friedrichs's avatar
Mark Friedrichs committed
198
199
200
201
202
203
204
205
206
207
      
      /** 
       * Get array of inverse map streams
       * 
       * @param index  array index 
       *
       * @return  array inverse map streams
       *
       */
      
Mark Friedrichs's avatar
Mark Friedrichs committed
208
      BrookFloatStreamInternal** getInverseStreamMapsStreams( int index );
Mark Friedrichs's avatar
Mark Friedrichs committed
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
      
      /** 
       * Return true if force[index] stream is set
       *
       * @param    index into force stream
       * @return   true if index is valid && force[index] stream is set; else false
       *
       */
      
      int isForceStreamSet( int index ) const;
       
      /** 
       * Return true if paramsterSet[index] stream is set
       *
       * @param    index into parameter stream
       *
       * @return   true if index is valid && paramsterSet[index] stream is set; else false
       *
       */
      
      int isParameterStreamSet( int index ) const;
          
      /** 
       * Return string showing if all inverse map streams are set
       *
       * @param    index into inverse map stream array
       *
       * @return   informative string
       *
       */
      
      std::string checkInverseMapStream( int index ) const;

      /* 
       * Get contents of object
       *
       *
       * @param level   level of dump
       *
       * @return string containing contents
       *
       * */
      
Mark Friedrichs's avatar
Mark Friedrichs committed
252
      std::string getContentsString( int level = 0 ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
253

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
254
255
256
257
258
259
260
      /** 
       * Compute forces
       * 
       */
      
      void computeForces( BrookStreamImpl& positionStream, BrookStreamImpl& forceStream );
   
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
261
262
263
264
265
266
267
      /** 
       * Return SetupCompleted flag
       *
       * @return SetupCompleted flag
       */
      
      int isSetupCompleted( void ) const;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
268
   
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
269
270
271
272
273
274
275
276
277
278
      /** 
       * Set SetupCompleted flag
       *
       * @param SetupCompleted flag
       *
       * @return SetupCompleted flag
       */
      
      int setupCompleted( int isSetupCompleted );
   
Mark Friedrichs's avatar
Mark Friedrichs committed
279
280
281
282
283
284
285
286
   private:
   
      static const int NumberOfParameterStreams = 5;
      static const int NumberOfForceStreams     = 4;
      static const int MaxNumberOfInverseMaps   = 9;

      enum { StreamI, StreamJ, StreamK, StreamL, StreamMax };

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
287
288
      int _setupCompleted;

Mark Friedrichs's avatar
Mark Friedrichs committed
289
290
      // inverse map stream width

Mark Friedrichs's avatar
Mark Friedrichs committed
291
      int _inverseMapStreamWidth;
Mark Friedrichs's avatar
Mark Friedrichs committed
292
293
294
295
296
297
298
299
300
301
302

      // actual max number of inverse maps 

      int _maxNumberOfInverseMaps;

      // scale factors for 1-4 ixn

      BrookOpenMMFloat _coulombFactor;

      // streams

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
303
      BrookFloatStreamInternal* _particleIndicesStream;
Mark Friedrichs's avatar
Mark Friedrichs committed
304
305
306
307
      BrookFloatStreamInternal* _bondedParameters[NumberOfParameterStreams];
      BrookFloatStreamInternal* _bondedForceStreams[NumberOfForceStreams];
      BrookFloatStreamInternal* _chargeStream;
      BrookFloatStreamInternal* _inverseStreamMaps[NumberOfForceStreams][MaxNumberOfInverseMaps];
Mark Friedrichs's avatar
Mark Friedrichs committed
308
309
310
311
312
313

      int _maxInverseMapStreamCount[NumberOfForceStreams];
      int _inverseMapStreamCount[NumberOfForceStreams];

      // helper methods in setup of parameters

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
314
315
316
317
318
319
      void _flipQuartet( int ibonded, int *particles );

      int _matchTorsion( int i, int j, int k, int l, int nbondeds, int *particles );
      int _matchAngle(   int i, int j, int k, int nbondeds, int *particles, int *flag );
      int _matchBond(    int i, int j, int nbondeds, int *particles, int *flag );
      int _matchPair(    int i, int j, int nbondeds, int *particles );
Mark Friedrichs's avatar
Mark Friedrichs committed
320
321

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
322
       * Setup Ryckaert-Bellemans parameters/particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
323
324
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
325
       * @param particles                     array of particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
326
       * @param params                    arrays of bond parameters
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
327
       * @param rbTorsionIndices          the four particles connected by each Ryckaert-Bellemans torsion term
Mark Friedrichs's avatar
Mark Friedrichs committed
328
329
330
331
332
333
       * @param rbTorsionParameters       the coefficients (in order of increasing powers) for each Ryckaert-Bellemans torsion term
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
334
      int _addRBTorsions( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& rbTorsionIndices,  
Mark Friedrichs's avatar
Mark Friedrichs committed
335
336
337
                          const std::vector<std::vector<double> >& rbTorsionParameters );

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
338
       * Setup periodic torsion parameters/particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
339
340
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
341
       * @param particles                     array of particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
342
       * @param params                    arrays of bond parameters
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
343
       * @param periodicTorsionIndices    the four particles connected by each periodic torsion term
Mark Friedrichs's avatar
Mark Friedrichs committed
344
345
346
347
348
349
       * @param periodicTorsionParameters the force parameters (k, phase, periodicity) for each periodic torsion term
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
350
      int _addPTorsions( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& periodicTorsionIndices,  
Mark Friedrichs's avatar
Mark Friedrichs committed
351
352
353
                          const std::vector<std::vector<double> >& periodicTorsionParameters );

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
354
       * Setup angle bond parameters/particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
355
356
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
357
       * @param particles                     array of particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
358
       * @param params                    arrays of bond parameters
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
359
       * @param angleIndices              the angle bond particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
360
361
362
363
364
365
       * @param angleParameters           the angle parameters (angle in radians, force constant)
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
366
367
      int _addAngles( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& angleIndices,
                      const std::vector<std::vector<double> >& angleParameters );
Mark Friedrichs's avatar
Mark Friedrichs committed
368
369

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
370
       * Setup harmonic bond parameters/particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
371
372
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
373
       * @param particles                     array of particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
374
       * @param params                    arrays of bond parameters
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
375
       * @param bondIndices               two harmonic bond particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
376
377
378
379
380
381
       * @param bondParameters            the force parameters (distance, k)
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
382
383
      int  _addBonds( int *nbondeds, int *particles, BrookOpenMMFloat* params[], const std::vector<std::vector<int> >& bondIndices,
                     const std::vector<std::vector<double> >& bondParameters );
Mark Friedrichs's avatar
Mark Friedrichs committed
384
385

      /**
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
386
       * Setup LJ/Coulomb 1-4 parameters/particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
387
388
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
389
       * @param particles                     array of particle indices
Mark Friedrichs's avatar
Mark Friedrichs committed
390
391
       * @param params                    arrays of bond parameters
       * @param charges                   array of charges
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
392
       * @param bonded14Indices           each element contains the indices of two particles whose nonbonded interactions should be reduced since
Mark Friedrichs's avatar
Mark Friedrichs committed
393
       *                                  they form a bonded 1-4 pair
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
394
       * @param nonbondedParameters       the nonbonded force parameters (charge, sigma, epsilon) for each particle
Mark Friedrichs's avatar
Mark Friedrichs committed
395
396
397
398
399
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
400
401
      int _addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* params[], BrookOpenMMFloat* charges,
                     const std::vector<std::vector<int> >& bonded14Indices, const std::vector<std::vector<double> >& nonbondedParameters );
Mark Friedrichs's avatar
Mark Friedrichs committed
402
403
404
405
406
      
      /**
       * Create and load inverse maps for bonded ixns
       * 
       * @param nbondeds                  number of bonded entries
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
407
408
       * @param nparticles                    number of particles
       * @param particles                     arrays of particle indices (particles[numberOfBonds][4])
Mark Friedrichs's avatar
Mark Friedrichs committed
409
410
411
412
413
414
415
       * @param platform                  BrookPlatform reference
       * @param log                       log file reference (optional)
       *
       * @return nonzero value if error
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
416
      //int loadInvMaps( int nbondeds, int nparticles, int *particles, const BrookPlatform& platform );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
417
      int _loadInvMaps( int nbondeds, int nparticles, int *particles, int particleStreamWidth, int particleStreamSize );
Mark Friedrichs's avatar
Mark Friedrichs committed
418
419
420
421
422
423
424
425
426
427
428
429
430
      
      /**
       * Validate inverse map count
       * 
       * @param index index to check (1-4) 
       * @param count count for index
       *
       * @return -1 if count invalid
       *
       * @tthrow OpenMMException exeception if count invalid
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
431
      int _validateInverseMapStreamCount( int index, int count ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
432
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
433
434
435
436
      /*
       * Helper functions for building inverse maps for 
       * torsions, impropers and angles.
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
437
       * For each particle, calculates the positions at which it's
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
438
439
440
       * forces are to be picked up from and stores the position
       * in the appropriate index.
       *
Mark Friedrichs's avatar
Mark Friedrichs committed
441
       * Input: number of torsions, the particle indices, and a flag indicating
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
442
       *        whether we're doing i(0), j(1), k(2) or l(3)
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
443
       * Output: an array of counts per particle
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
444
445
446
       *         arrays of inversemaps
       *         nimaps - the number of invmaps actually used.
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
447
448
       * @param posflag       0-niparticles-1
       * @param niparticles       3 for angles, 4 for torsions, impropers
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
449
       * @param nints         number of interactions
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
450
451
       * @param nparticles        number of particles
       * @param *particles        gromacs interaction list
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
452
       * @param nmaps         maximum number of inverse maps
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
453
       * @param   counts[]    output counts of how many places each particle occurs
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
454
455
456
457
458
459
460
       * @param *invmaps[]    output array of nmaps inverse maps
       * @param *nimaps,      output max number of inverse maps actually used
       *
       * @return DefaultReturnValue, unless error in which case exits w/ OpenMM exception
       *
       **/
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
461
462
      int _gpuCalcInvMap( int posflag, int niparticles, int nints, int nparticles,
                          int *particles, int nmaps, int counts[], float4 *invmaps[], int *nimaps );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
463
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
464
      void _gpuPrintInvMaps( int nmaps, int nparticles, int counts[], float4 *invmap[], FILE* logFile );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
465
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
466
467
      /* 
       * We are still plagued by kernel call overheads. This is for a big fat
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
468
469
470
471
472
473
       * merged inverse gather kernel:
       * Since we have 32 bit floats, we have 23 bits of mantissa or the largest
       * integer we can represent is 2^23. So it should be quite safe to add 
       * 100000 * n to the index where n is the stream in which we should do the
       * lookup. This assumes that nints < 100000, preferably nints << 100000
       * which should always be true
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
474
475
476
       *
       **/
      int _gpuCalcInvMap_merged( int nints, int nparticles, int *particles, int nmaps, int counts[], float4 *invmaps[], int *nimaps );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
477
      
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
478
479
      /* 
       * Repacks the invmap streams for more efficient access in the
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
480
481
       * merged inverse gather kernel
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
482
       * buf should be nimaps * nparticles large.
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
483
484
485
       *
       **/
      int _gpuRepackInvMap_merged( int nparticles, int nmaps, int *counts, float4 *invmaps[], float4 *buf );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
486
      
Mark Friedrichs's avatar
Mark Friedrichs committed
487
488
489
490
};

} // namespace OpenMM

Mark Friedrichs's avatar
Mark Friedrichs committed
491
#endif /* OPENMM_BROOK_BONDED_H_ */