From c4df98e7a8930bddd6039a82abf7a3b2521341be Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Fri, 6 Jan 2017 15:14:52 +0000
Subject: [PATCH] Only call the vectorized SEFL routine for Gadget-2 SPH.
---
src/cache.h | 4 ++++
src/runner.c | 2 +-
src/tools.c | 10 ++++++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/cache.h b/src/cache.h
index a6a7090806..6332f14705 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -143,6 +143,8 @@ __attribute__((always_inline)) INLINE void cache_init(struct cache *c,
__attribute__((always_inline)) INLINE void cache_read_particles(
const struct cell *const ci, struct cache *const ci_cache) {
+#if defined(GADGET2_SPH)
+
/* Shift the particles positions to a local frame so single precision can be
* used instead of double precision. */
for (int i = 0; i < ci->count; i++) {
@@ -156,6 +158,8 @@ __attribute__((always_inline)) INLINE void cache_read_particles(
ci_cache->vy[i] = ci->parts[i].v[1];
ci_cache->vz[i] = ci->parts[i].v[2];
}
+
+#endif
}
#endif /* SWIFT_CACHE_H */
diff --git a/src/runner.c b/src/runner.c
index 23e5c8d2d9..466fab4c5a 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1095,7 +1095,7 @@ void *runner_main(void *data) {
switch (t->type) {
case task_type_self:
if (t->subtype == task_subtype_density) {
-#ifdef WITH_VECTORIZATION
+#if defined(WITH_VECTORIZATION) && defined(GADGET2_SPH)
runner_doself1_density_vec(r, ci);
#else
runner_doself1_density(r, ci);
diff --git a/src/tools.c b/src/tools.c
index f4cb867443..ab11d1f593 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -600,6 +600,9 @@ int compare_values(double a, double b, double threshold, double *absDiff,
* @return 1 if difference found, 0 otherwise
*/
int compare_particles(struct part a, struct part b, double threshold) {
+
+#ifdef GADGET2_SPH
+
int result = 0;
double absDiff = 0.0, absSum = 0.0, relDiff = 0.0;
@@ -720,6 +723,13 @@ int compare_particles(struct part a, struct part b, double threshold) {
}
return result;
+
+#else
+
+ error("Function not supported for this flavour of SPH");
+ return 0;
+
+#endif
}
/** @brief Computes the forces between all g-particles using the N^2 algorithm
--
GitLab