diff --git a/src/runner.c b/src/runner.c
index f5efc99d492be837509e50bd2674ab6923404446..aaec28e2e6f924f7e912f8156520fac9647bccfe 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -1231,7 +1231,9 @@ void *runner_main(void *data) {
       /* Get the cells. */
       struct cell *ci = t->ci;
       struct cell *cj = t->cj;
+#ifdef SWIFT_DEBUG_TASKS
       t->rid = r->cpuid;
+#endif
 
 /* Check that we haven't scheduled an inactive task */
 #ifdef SWIFT_DEBUG_CHECKS