From 6e9ee08606f84421d78f91eaedb61c501983905d Mon Sep 17 00:00:00 2001
From: James Wilson <wilsja@wirelessprv-10-192-250-37.near.illinois.edu>
Date: Fri, 11 Nov 2016 16:05:16 -0600
Subject: [PATCH] Cleaned up assertion

---
 src/ComputeForce.cuh     |  4 ++--
 src/RigidBodyType.cu     |  4 ++--
 src/TabulatedMethods.cuh | 10 +++++-----
 src/myAssert.cu          |  8 ++++++++
 src/myAssert.h           |  4 ++++
 5 files changed, 21 insertions(+), 9 deletions(-)
 create mode 100644 src/myAssert.cu
 create mode 100644 src/myAssert.h

diff --git a/src/ComputeForce.cuh b/src/ComputeForce.cuh
index 6a7e4fe..b2bab6e 100644
--- a/src/ComputeForce.cuh
+++ b/src/ComputeForce.cuh
@@ -3,7 +3,7 @@
 // Terrance Howard <heyterrance@gmail.com>
 
 #pragma once
-#include <assert.h>
+#include "myAssert.h"
 #include "CudaUtil.cuh"
 #include "TabulatedMethods.cuh"
 
@@ -268,7 +268,7 @@ void createPairlists(Vector3* __restrict__ pos, const int num, const int numRepl
 								
 								// Skip excludes
 								//   Implementation requires that aj increases monotonically
-								assert( ajLast < aj ); ajLast = aj; // TODO: remove this sanity check
+								myAssert( ajLast < aj ); ajLast = aj; // TODO: remove this sanity check
 									
 								if (nextEx == (aj - repID * num)) {
 									nextEx = (currEx < ex_end - 1) ? excludes[++currEx].ind2 : -1;
diff --git a/src/RigidBodyType.cu b/src/RigidBodyType.cu
index 838e9cc..5d4d3a4 100644
--- a/src/RigidBodyType.cu
+++ b/src/RigidBodyType.cu
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "myAssert.h"
 #include "Configuration.h"
 #include "RigidBodyType.h"
 #include "Reservoir.h"
@@ -298,7 +298,7 @@ void RigidBodyType::initializeParticleLists() {
 				if (gridNames[k] == gridName) {
 					// Copy type j particles to particles[i]
 					memcpy( &(particles[i][pid]), tmp, sizeof(int)*currId );
-					assert(currId == conf->numPartsOfType[j]);
+					myAssert(currId == conf->numPartsOfType[j]);
 					pid += conf->numPartsOfType[j];
 				}
 			}
diff --git a/src/TabulatedMethods.cuh b/src/TabulatedMethods.cuh
index 84965ed..c298ab3 100644
--- a/src/TabulatedMethods.cuh
+++ b/src/TabulatedMethods.cuh
@@ -43,8 +43,8 @@ __device__ inline void computeAngle(const TabulatedAnglePotential* __restrict__
 	// tableAngle[1] stores the potential at angle_step * 2, etc.
 	// 'home' is the index after which 'convertedAngle' would appear if it were stored in the table	
 	int home = int(floor(angle));
-	assert(home >= 0);
-	assert(home < a->size);
+	myAssert(home >= 0);
+	myAssert(home < a->size);
 
 	// // Make angle the distance from [0,1) from the first index in the potential array index
 	// angle -= home;
@@ -111,8 +111,8 @@ __device__ inline void computeDihedral(const TabulatedDihedralPotential* __restr
 	int home = (int) floorf(t);
 	t = t - home;
 
-	assert(home >= 0);
-	assert(home < d->size);
+	myAssert(home >= 0);
+	myAssert(home < d->size);
 	// home = home % size;
 	int home1 = (home + 1) >= d->size ? (home+1-d->size) : home+1;
 
@@ -126,7 +126,7 @@ __device__ inline void computeDihedral(const TabulatedDihedralPotential* __restr
 
 	// avoid singularity when one angle is straight 
 	force = (crossABC.rLength() > 1.0f || crossBCD.rLength() > 1.0f) ? 0.0f : force;
-	assert( force < 10000.0f );
+	myAssert( force < 10000.0f );
 	f1 *= force;
 	f2 *= force;
 	f3 *= force;
diff --git a/src/myAssert.cu b/src/myAssert.cu
new file mode 100644
index 0000000..99f57d2
--- /dev/null
+++ b/src/myAssert.cu
@@ -0,0 +1,8 @@
+#include "myAssert.h"
+
+#ifdef __APPLE__
+__host__ __device__ void myAssert(bool statement) {  }
+#else
+#include <assert.h>
+__host__ __device__ void myAssert(bool statement) { assert(statement); }
+#endif
\ No newline at end of file
diff --git a/src/myAssert.h b/src/myAssert.h
new file mode 100644
index 0000000..a50c1ce
--- /dev/null
+++ b/src/myAssert.h
@@ -0,0 +1,4 @@
+#pragma once
+// #include <assert.h>
+
+__host__ __device__ void myAssert(bool statement);
-- 
GitLab