From 099b9e8da116fc2b1b25274f7003411744d5834b Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Tue, 16 Mar 2021 13:36:28 +0000
Subject: [PATCH] Fixes for RoCE support and rockport

---
 Makefile                         | 5 ++---
 infinity_wrapper.c               | 8 ++++----
 swiftmpirdmaonestepsim_wrapper.c | 6 +++---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 3a5d360..3c51e4e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,10 @@
-CFLAGS = -g -O0 -Wall -Iinfinity/include -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -DINFINITY_DEBUG_ON -DINFINITY_ASSERT_ON
-#CFLAGS = -g -O3 -Wall -Iinfinity/include
+CFLAGS = -g -O3 -Wall -Iinfinity/include
 #CFLAGS = -g -O3 -Wall -Iinfinity/include -DINFINITY_DEBUG_ON -DINFINITY_ASSERT_ON
 #CFLAGS = -g -O0 -Wall -Iinfinity/include -fsanitize=thread
 
 INCLUDES = mpiuse.h atomic.h cycle.h clocks.h error.h
 SOURCES = mpiuse.c clocks.c
-DEPS = Makefile $(SOURCES) $(INCLUDES)
+DEPS = Makefile $(SOURCES) $(INCLUDES) infinity/libinfinity.a
 
 INFINITY = -Linfinity -linfinity -libverbs
 
diff --git a/infinity_wrapper.c b/infinity_wrapper.c
index 105a476..7a5af58 100644
--- a/infinity_wrapper.c
+++ b/infinity_wrapper.c
@@ -225,10 +225,6 @@ void infinity_clients_free(void *qphandle) {
 
 #ifdef HAVE_INFINITY
   struct qps_data *cqps = (struct qps_data *)qphandle;
-  for (int k = 0; k < cqps->nr_qps; k++) delete cqps->qps[k];
-  free(cqps->qps);
-  delete cqps->factory;
-  delete cqps->context;
   free(cqps->receive_buffers);
   free(cqps->remote_buffers);
   if (cqps->readwrite_buffers != NULL) {
@@ -239,6 +235,10 @@ void infinity_clients_free(void *qphandle) {
     for (int k = 0; k < cqps->nr_qps; k++) delete cqps->token_buffers[k];
     free(cqps->token_buffers);
   }
+  for (int k = 0; k < cqps->nr_qps; k++) delete cqps->qps[k];
+  free(cqps->qps);
+  delete cqps->factory;
+  delete cqps->context;
   free(cqps);
 #endif
   return;
diff --git a/swiftmpirdmaonestepsim_wrapper.c b/swiftmpirdmaonestepsim_wrapper.c
index 9fd9a49..784af9c 100644
--- a/swiftmpirdmaonestepsim_wrapper.c
+++ b/swiftmpirdmaonestepsim_wrapper.c
@@ -68,8 +68,8 @@ static float messagescale = 1.0;
 static int datacheck = 0;
 
 /* Integer types of send and recv tasks, must match log. */
-static const int task_type_send = 22;
-static const int task_type_recv = 23;
+static const int task_type_send = 24;
+static const int task_type_recv = 25;
 
 /* 3D index of array. */
 #define INDEX3(nx, ny, x, y, z) (nx * ny * z + nx * y + x)
@@ -133,7 +133,7 @@ static size_t toranktag(int subtype, int sendrank, int recvrank, int tag) {
 
 static char *toipaddr(char *hostname) {
 
-  struct hostent *hostent = gethostbyname(hostname);
+  struct hostent *hostent = gethostbyname(hostname); // local rockport interface
   if (hostent == NULL) {
     error("Failed to convert hostname '%s' to an IP address", hostname);
   }
-- 
GitLab