Skip to content

Commit 4aa87d7

Browse files
committed
Added template function
1 parent 5b0d655 commit 4aa87d7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tlm3_dihedral/Dihed.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ void sinNPhiCosNPhi(int n, float* sinNPhi, float* cosNPhi,
2424

2525
template <int N>
2626
struct SinCos {
27-
static void sinNPhiCosNPhi(double& sinNPhi, double& cosNPhi,
28-
double sinPhi, double cosPhi ) {
27+
static void sinNPhiCosNPhi(float& sinNPhi, float& cosNPhi,
28+
float sinPhi, float cosPhi ) {
2929
float sinNm1Phi;
3030
float cosNm1Phi;
31-
sinNPhiCosNPhi<N-1>(sinNm1Phi,cosNm1Phi,sinPhi,cosPhi);
31+
SinCos<N-1>::sinNPhiCosNPhi(sinNm1Phi,cosNm1Phi,sinPhi,cosPhi);
3232
sinNPhi = cosPhi*sinNm1Phi+sinPhi*cosNm1Phi;
3333
cosNPhi = cosPhi*cosNm1Phi-sinPhi*sinNm1Phi;
3434
}
3535
};
3636

3737
template <>
3838
struct SinCos<1> {
39-
static void sinNPhiCosNPhi(double& sinNPhi, double& cosNPhi,
40-
double sinPhi, double cosPhi ) {
39+
static void sinNPhiCosNPhi(float& sinNPhi, float& cosNPhi,
40+
float sinPhi, float cosPhi ) {
4141
sinNPhi = sinPhi;
4242
cosNPhi = cosPhi;
4343
}
@@ -83,7 +83,7 @@ float dihedral_energy(Dihedral* dihedral_begin, Dihedral* dihedral_end, float* p
8383
float cosPhase;
8484
float V;
8585
float DN;
86-
float IN;
86+
int IN;
8787
float x1, y1, z1;
8888
float x2, y2, z2;
8989
float x3, y3, z3;
@@ -150,7 +150,7 @@ float old_dihedral_energy(Dihedral* dihedral_begin, Dihedral*dihedral_end, float
150150
float cosPhase;
151151
float V;
152152
float DN;
153-
float IN;
153+
int IN;
154154
float x1, y1, z1;
155155
float x2, y2, z2;
156156
float x3, y3, z3;

tlm3_dihedral/makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
ENZYME_so=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
33

4+
45
all-Dihed: cmp-Dihed ad-Dihed opt-Dihed lower-Dihed
56
echo done
67

78
cmp-Dihed:
8-
clang Dihed.cc -S -emit-llvm -o Dihed-cmp.ll -O2 -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
9+
clangi-15 Dihed.cc -S -emit-llvm -o Dihed-cmp.ll -O2 -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
910

1011
ad-Dihed:
1112
opt-15 Dihed-cmp.ll -enable-new-pm=0 -load=$(ENZYME_so) --enzyme -o Dihed-ad.ll -S

0 commit comments

Comments
 (0)