Skip to content

Commit 51181c6

Browse files
author
Christian Schafmeisterr
committed
Added code to use new mathkernel generated kernels.
1 parent b8a75cc commit 51181c6

File tree

13 files changed

+787
-184
lines changed

13 files changed

+787
-184
lines changed

include/cando/chem/energyAngle.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ THE SOFTWARE.
2323
This is an open source license for the CANDO software from Temple University, but it is not the only one. Contact Temple University at mailto:[email protected] if you would like a different license.
2424
*/
2525
/* -^- */
26-
27-
2826

2927
//
3028
// (C) 2004 Christian E. Schafmeister
@@ -232,6 +230,9 @@ class EnergyAngle_O : public EnergyComponent_O
232230

233231
EnergyAngle_sp copyFilter(core::T_sp keepInteractionFactory);
234232

233+
virtual void emitTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
234+
virtual void runTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
235+
235236
EnergyAngle_O( const EnergyAngle_O& ss ); //!< Copy constructor
236237

237238
EnergyAngle_O() : EnergyComponent_O() {};

include/cando/chem/energyComponent.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,36 @@ inline string atomLabel(Atom_sp a)
208208
}
209209

210210

211+
// ----------------------------------------------------------------------
212+
// New kernel function accumulators
213+
// ----------------------------------------------------------------------
214+
215+
216+
#define KernelGradientAcc(ii1,oo1,vv1) force[ii1+oo1] += (-vv1)
217+
218+
//
219+
// Accumulate an off diagonal Hessian element
220+
//
221+
#define KernelOffDiagHessAcc(i1,o1,i2,o2,v) {\
222+
auto v22 = v*dvec[i2+o2];\
223+
auto v11 = v*dvec[i1+o1];\
224+
hdvec[i1+o1] += v22; \
225+
hdvec[i2+o2] += v11; \
226+
}
227+
228+
//
229+
// Accumulate a diagonal Hessian element
230+
//
231+
#define KernelDiagHessAcc(i1,o1,i2,o2,v) {\
232+
auto vd = v*dvec[i1+o1];\
233+
hdvec[i1+o1] += vd; \
234+
}
235+
236+
237+
// ----------------------------------------------------------------------
238+
// Old accumulators
239+
// ----------------------------------------------------------------------
240+
211241
#define ForceAcc(i,o,v) {\
212242
if ( hasForce ) {\
213243
force->setElement((i)+(o),(v)+force->getElement((i)+(o)));\
@@ -325,6 +355,9 @@ class EnergyComponent_O : public core::CxxObject_O
325355
CL_LISPIFY_NAME("energy-component-evaluations");
326356
CL_DEFMETHOD size_t evaluations() const { return this->_Evaluations; };
327357

358+
CL_DEFMETHOD virtual void emitTestCalls(core::T_sp stream, chem::NVector_sp pos) const {SUBCLASS_MUST_IMPLEMENT(); };
359+
CL_DEFMETHOD virtual void runTestCalls(core::T_sp stream, chem::NVector_sp pos) const {SUBCLASS_MUST_IMPLEMENT(); };
360+
328361
CL_DEFMETHOD virtual core::List_sp extract_vectors_as_alist() const { SUBCLASS_MUST_IMPLEMENT(); };
329362

330363
string enabledAsString();
@@ -373,5 +406,22 @@ void copyEnergyComponent(EnergyComponent_sp newComponent, EnergyComponent_sp ori
373406
;
374407
};
375408

409+
namespace chem {
410+
411+
void test_zero( size_t num,
412+
double* force_new, double* force_ground,
413+
double* hessian_new, double* hessian_ground,
414+
double* dvec_new, double* dvec_ground,
415+
double* hdvec_new, double* hdvec_ground );
416+
417+
bool test_match( core::T_sp stream, const char* label, size_t num,
418+
double* force_new, double* force_ground,
419+
double* hessian_new, double* hessian_ground,
420+
double* hdvec_new, double* hdvec_ground );
421+
422+
void test_position(core::T_sp stream, size_t pos_size, double* position );
423+
424+
425+
};
376426

377427
#endif

include/cando/chem/energyDihedral.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class EnergyDihedral_O : public EnergyComponent_O
317317

318318
core::List_sp lookupDihedralTerms(AtomTable_sp at, Atom_sp a1, Atom_sp a2, Atom_sp a3, Atom_sp a4, core::HashTable_sp atomTypes );
319319

320+
virtual void emitTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
321+
320322
EnergyDihedral_sp copyFilter(core::T_sp keepInteractionFactory);
321323

322324
public:

include/cando/chem/energyNonbond.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ class EnergyNonbond_O : public EnergyComponent_O
166166
public: // instance variables
167167
double _EnergyElectrostatic;
168168
bool _UsesExcludedAtoms;
169+
double _Nonbond_r_switch;
170+
double _Nonbond_r_cut;
171+
double _Nonbond_invdd; // Distance dependent dielectric reciprocal
169172
size_t _NonbondsKept;
170173
size_t _NonbondsDiscarded;
171174
// Original way of defining nonbonds with list of nonbond terms
@@ -194,6 +197,7 @@ class EnergyNonbond_O : public EnergyComponent_O
194197
core::SimpleVector_int32_t_sp _ExcludedAtomIndexes;
195198
size_t _InteractionsKept;
196199
size_t _InteractionsDiscarded;
200+
197201
public:
198202
typedef gctools::Vec0<TermType>::iterator iterator;
199203
iterator begin() { return this->_Terms.begin(); };
@@ -205,6 +209,9 @@ class EnergyNonbond_O : public EnergyComponent_O
205209
void callForEachTerm(core::Function_sp callback);
206210
public:
207211

212+
void runTestCalls(core::T_sp stream, chem::NVector_sp coords) const;
213+
void set_nonbond_pairlist_parameters(double r_switch, double r_cut, double distance_dielectric);
214+
208215
CL_DEFMETHOD core::SimpleVector_int32_t_sp number_excluded_atoms() const { return this->_NumberOfExcludedAtomIndexes;}
209216
CL_DEFMETHOD core::SimpleVector_int32_t_sp excluded_atom_list() const { return this->_ExcludedAtomIndexes;}
210217
public:
@@ -275,11 +282,17 @@ class EnergyNonbond_O : public EnergyComponent_O
275282
void setNonbondExcludedAtomInfo(AtomTable_sp atom_table, core::SimpleVector_int32_t_sp excluded_atoms_list, core::SimpleVector_int32_t_sp number_excluded_atoms);
276283
void checkEnergyNonbond();
277284
EnergyNonbond_sp copyFilter(core::T_sp keepInteractionFactory);
285+
286+
virtual void emitTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
287+
278288
public:
279289
EnergyNonbond_O( const EnergyNonbond_O& ss ); //!< Copy constructor
280290

281291
EnergyNonbond_O() :
282292
_UsesExcludedAtoms(true),
293+
_Nonbond_r_switch(10.0),
294+
_Nonbond_r_cut(12.0),
295+
_Nonbond_invdd(1.0),
283296
_FFNonbondDb(nil<core::T_O>()),
284297
_InteractionsKept(0),
285298
_InteractionsDiscarded(0)

include/cando/chem/energyStretch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ class EnergyStretch_O : public EnergyComponent_O
192192
virtual void setupHessianPreconditioner(NVector_sp nvPosition,
193193
AbstractLargeSquareMatrix_sp m,
194194
core::T_sp activeAtomMask);
195+
virtual void emitTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
196+
virtual void runTestCalls(core::T_sp stream, chem::NVector_sp pos) const;
195197
virtual double evaluateAllComponent( ScoringFunction_sp scorer,
196198
NVector_sp pos,
197199
core::T_sp energyScale,

include/cando/chem/energy_functions/_Angle_termCode.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
tx149 = tx143 + tx145 + tx146; /* rule 282 */
284284
tx150 = power2(tx67); /* rule 283 */
285285
tx151 = tx102 + tx142 + tx144 + tx147 + tx148 + tzz548; /* rule 284 */
286-
tx152 = tx151*tzz471; /* rule 285 */
286+
tx152 = 3.0*tx151*tzz471; /* rule 285 */
287287
tzz518 = tx67*tzz470; /* rule 286 */
288288
tx153 = tx149*tzz518; /* rule 287 */
289289
tx154 = tx150*tzz473; /* rule 288 */

0 commit comments

Comments
 (0)