From 7cfdd47f92f1d64f2f40e317916de93c46536338 Mon Sep 17 00:00:00 2001
From: Chris Maffeo <cmaffeo2@illinois.edu>
Date: Wed, 2 Nov 2022 11:53:01 -0500
Subject: [PATCH] Use constexpr in a few instances instead of #define

---
 src/ComputeForce.cuh     | 2 +-
 src/TabulatedDihedral.cu | 1 -
 src/TabulatedDihedral.h  | 2 +-
 src/TabulatedMethods.cuh | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/ComputeForce.cuh b/src/ComputeForce.cuh
index b92feea..eb619c9 100644
--- a/src/ComputeForce.cuh
+++ b/src/ComputeForce.cuh
@@ -6,7 +6,7 @@
 #include "CudaUtil.cuh"
 #include "TabulatedMethods.cuh"
 
-constexpr float BD_PI = 3.1415927f;
+// From TabulatedMethods.cuh: constexpr float BD_PI = 3.1415927f; 
 constexpr size_t MAX_CELLS_FOR_CELLNEIGHBORLIST = 1<<25;
 constexpr size_t MAX_NLIST_PAIRS = 1<<27; // Reduce if ARBD crashes immediately with GPU memory allocation error
 
diff --git a/src/TabulatedDihedral.cu b/src/TabulatedDihedral.cu
index c182482..c70008d 100644
--- a/src/TabulatedDihedral.cu
+++ b/src/TabulatedDihedral.cu
@@ -3,7 +3,6 @@
 
 #include "TabulatedDihedral.h"
 #include <cassert>
-#define BD_PI 3.1415927f
 
 TabulatedDihedralPotential::TabulatedDihedralPotential() :
 		pot(NULL), size(0), fileName("") {}
diff --git a/src/TabulatedDihedral.h b/src/TabulatedDihedral.h
index 1defc9d..e806e2d 100644
--- a/src/TabulatedDihedral.h
+++ b/src/TabulatedDihedral.h
@@ -13,7 +13,7 @@
 // #include <math.h>
 // #define _USING_MATH_DEFINES
 
-#define BD_PI 3.1415927f
+constexpr float BD_PI = 3.1415927f;
 
 class TabulatedDihedralPotential {
 public:
diff --git a/src/TabulatedMethods.cuh b/src/TabulatedMethods.cuh
index ef4665c..d92809c 100644
--- a/src/TabulatedMethods.cuh
+++ b/src/TabulatedMethods.cuh
@@ -1,6 +1,6 @@
 #pragma once
 
-#define BD_PI 3.1415927f
+// Defined elsewhere: constexpr float BD_PI = 3.1415927f;
 
 __device__ inline void computeAngle(const TabulatedAnglePotential* __restrict__ a, const BaseGrid* __restrict__ sys, Vector3* force, const Vector3* __restrict__ pos,
 				const int& i, const int& j, const int& k, float* energy, bool get_energy) {
-- 
GitLab