[Pkg-ofed-commits] [fabtests] 01/05: New upstream version 1.4.0

Ana Beatriz Guerrero López ana at moszumanska.debian.org
Sat Nov 5 15:39:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

ana pushed a commit to branch master
in repository fabtests.

commit 3e72aa4de3e29e6b3665503d92a3c73e1877daa8
Author: Ana Guerrero López <ana at ekaia.org>
Date:   Sat Nov 5 15:43:30 2016 +0100

    New upstream version 1.4.0
---
 AUTHORS                                           |  48 +-
 COPYING                                           |   2 +-
 Makefile.am                                       |  47 +-
 Makefile.in                                       | 193 ++++--
 aclocal.m4                                        | 159 ++---
 benchmarks/benchmark_shared.c                     | 199 ++++--
 benchmarks/benchmark_shared.h                     |  10 +-
 benchmarks/dgram_pingpong.c                       |  45 +-
 benchmarks/{rdm_tagged_bw.c => msg_bw.c}          |  56 +-
 benchmarks/msg_pingpong.c                         | 124 +---
 benchmarks/rdm_cntr_pingpong.c                    |  45 +-
 benchmarks/rdm_pingpong.c                         |  45 +-
 benchmarks/rdm_tagged_bw.c                        |  49 +-
 benchmarks/rdm_tagged_pingpong.c                  |  48 +-
 benchmarks/{rdm_tagged_bw.c => rma_bw.c}          |  74 +--
 common/osx/osd.c                                  |  13 +-
 common/shared.c                                   | 704 ++++++++++++++++++----
 complex/fabtest.h                                 |   2 +-
 complex/ft_comm.c                                 |   4 +-
 complex/ft_main.c                                 | 172 +-----
 complex/ft_test.c                                 |  21 +-
 config.h.in                                       |   9 +
 config/config.guess                               |   8 +-
 config/config.sub                                 |  13 +-
 config/libtool.m4                                 |  79 +--
 config/ltmain.sh                                  |  32 +-
 config/missing                                    |   4 +-
 configure                                         | 510 +++++++++-------
 configure.ac                                      |  33 +-
 fabtests.spec                                     |   4 +-
 fabtests.spec.in                                  |   2 +-
 include/osx/osd.h                                 |   4 +
 include/shared.h                                  | 131 ++--
 include/unit_common.h                             |   8 +-
 ported/libibverbs/rc_pingpong.c                   |  23 +-
 ported/librdmacm/cmatose.c                        |  10 +-
 scripts/runfabtests.sh                            | 147 +++--
 simple/cm_data.c                                  | 484 +++++++++++++++
 simple/cq_data.c                                  | 131 +---
 simple/dgram.c                                    |  49 +-
 simple/dgram_waitset.c                            |  20 +-
 simple/msg.c                                      | 125 +---
 simple/msg_epoll.c                                | 141 +----
 simple/msg_sockets.c                              |  10 +-
 simple/poll.c                                     |  93 +--
 simple/rdm.c                                      |  49 +-
 simple/rdm_rma_simple.c                           |  47 +-
 simple/rdm_rma_trigger.c                          |  97 +--
 simple/rdm_shared_av.c                            |  49 +-
 simple/rdm_shared_ctx.c                           | 444 --------------
 simple/rdm_tagged_peek.c                          |  48 +-
 simple/scalable_ep.c                              |  32 +-
 simple/shared_ctx.c                               | 694 +++++++++++++++++++++
 benchmarks/rdm_cntr_pingpong.c => streaming/msg.c |  79 +--
 streaming/msg_rma.c                               | 198 +-----
 streaming/rdm_atomic.c                            |  32 +-
 streaming/rdm_multi_recv.c                        |  28 +-
 streaming/rdm_rma.c                               | 131 +---
 unit/av_test.c                                    | 112 ++--
 unit/common.c                                     |  25 +-
 unit/cq_test.c                                    | 203 +++++++
 unit/dom_test.c                                   |  49 +-
 unit/eq_test.c                                    |  62 +-
 unit/getinfo_test.c                               | 223 +++++++
 unit/size_left_test.c                             | 363 ++++++-----
 65 files changed, 3843 insertions(+), 3252 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 74af225..5cc4779 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,20 +1,28 @@
-Sean Hefty		<sean.hefty at intel.com>
-Shantonu Hossain	<shantonu.hossain at intel.com>
-Arun C Ilango		<arun.ilango at intel.com>
-Jeff Squyres		<jsquyres at cisco.com>
-Patrick McCormick	<patrick.m.mccormick at intel.com>
-Reese Faucette		<rfaucett at cisco.com>
-Dave Goodell		<dgoodell at cisco.com>
-Jithin Jose		<jithin.jose at intel.com>
-Ben Turrubiates		<bturrubi at cisco.com>
-Sayantan Sur		<sayantan.sur at intel.com>
-Howard Pritchard	<howardp at lanl.gov>
-Stan Smith		<stan.smith at intel.com>
-Chen Zhao		<soniczhao at gmail.com>
-Charles J Archer	<charles.j.archer at intel.com>
-Patrick MacArthur	<pmacarth at iol.unh.edu>
-Xuyang Wang		<xuywang at cisco.com>
-Miao Luo		<miao.luo at intel.com>
-Prankur Gupta		<prankgup at cisco.com>
-Serge A. Zaitsev	<zaitsev.serge at gmail.com>
-Sung-Eun Choi		<sungeun at cray.com>
+Arun C Ilango <arun.ilango at intel.com>
+arun ilango <a-ilango at users.noreply.github.com>
+Arun Ilango <arun.ilango at intel.com>
+Ben Turrubiates <bturrubiates at lanl.gov>
+Ben Turrubiates <bturrubi at cisco.com>
+Charles J Archer <charles.j.archer at intel.com>
+Chen Zhao <soniczhao at gmail.com>
+Dardo D Kleiner <dkleiner at cmf.nrl.navy.mil>
+Dave Goodell <dgoodell at cisco.com>
+Evgeny Leksikov <evgeny.leksikov at intel.com>
+Howard Pritchard <howardp at lanl.gov>
+Jeff Squyres <jsquyres at cisco.com>
+Jithin Jose <jithin.jose at intel.com>
+jose <jose at cst-fs.(none)>
+jose <jose at cstnh-8.(none)>
+Ken Raffenetti <raffenet at mcs.anl.gov>
+Miao Luo <miao.luo at intel.com>
+Paolo Inaudi <p91paul at gmail.com>
+Patrick MacArthur <pmacarth at iol.unh.edu>
+Patrick McCormick <patrick.m.mccormick at intel.com>
+Prankur Gupta <prankgup at cisco.com>
+Reese Faucette <rfaucett at cisco.com>
+Sayantan Sur <sayantan.sur at intel.com>
+Sean Hefty <sean.hefty at intel.com>
+Shantonu Hossain <shantonu.hossain at intel.com>
+Stan Smith <stan.smith at intel.com>
+Sung-Eun Choi <sungeunchoi at users.noreply.github.com>
+Xuyang Wang <xuywang at cisco.com>
diff --git a/COPYING b/COPYING
index 1a353a4..504aaed 100644
--- a/COPYING
+++ b/COPYING
@@ -7,7 +7,7 @@ Some parts of the source are 3rd party code which uses MIT license.
 The description and requirements of the license are available in
 later part of this file.
 
-Copyright (c) 2015 Intel Corporation.  All rights reserved.
+Copyright (c) 2015-2016 Intel Corporation.  All rights reserved.
 Copyright (c) 2016-2016 Cisco Systems, Inc.  All rights reserved.
 
 ==================================================================
diff --git a/Makefile.am b/Makefile.am
index 47160d2..de5dbee 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,23 +14,29 @@ bin_PROGRAMS = \
 	simple/fi_cq_data \
 	simple/fi_poll \
 	simple/fi_scalable_ep \
-	simple/fi_rdm_shared_ctx \
+	simple/fi_shared_ctx \
 	simple/fi_msg_epoll \
 	simple/fi_rdm_shared_av \
+	simple/fi_cm_data \
 	streaming/fi_msg_rma \
 	streaming/fi_rdm_atomic \
 	streaming/fi_rdm_multi_recv \
 	streaming/fi_rdm_rma \
+	streaming/fi_msg_stream \
 	benchmarks/fi_msg_pingpong \
+	benchmarks/fi_msg_bw \
+	benchmarks/fi_rma_bw \
 	benchmarks/fi_rdm_cntr_pingpong \
 	benchmarks/fi_dgram_pingpong \
 	benchmarks/fi_rdm_pingpong \
 	benchmarks/fi_rdm_tagged_pingpong \
 	benchmarks/fi_rdm_tagged_bw \
 	unit/fi_eq_test \
+	unit/fi_cq_test \
 	unit/fi_av_test \
 	unit/fi_size_left_test \
 	unit/fi_dom_test \
+	unit/fi_getinfo_test \
 	ported/libibverbs/fi_rc_pingpong \
 	ported/librdmacm/fi_cmatose \
 	complex/fi_ubertest
@@ -63,8 +69,11 @@ libfabtests_la_SOURCES = \
 
 if MACOS
 libfabtests_la_SOURCES += include/osx/osd.h
+
+if !HAVE_CLOCK_GETTIME
 libfabtests_la_SOURCES += common/osx/osd.c
 endif
+endif
 
 simple_fi_msg_sockets_SOURCES = \
 	simple/msg_sockets.c
@@ -110,13 +119,17 @@ simple_fi_cq_data_SOURCES = \
 	simple/cq_data.c
 simple_fi_cq_data_LDADD = libfabtests.la
 
+simple_fi_cm_data_SOURCES = \
+	simple/cm_data.c
+simple_fi_cm_data_LDADD = libfabtests.la
+
 simple_fi_scalable_ep_SOURCES = \
 	simple/scalable_ep.c
 simple_fi_scalable_ep_LDADD = libfabtests.la
 
-simple_fi_rdm_shared_ctx_SOURCES = \
-	simple/rdm_shared_ctx.c
-simple_fi_rdm_shared_ctx_LDADD = libfabtests.la
+simple_fi_shared_ctx_SOURCES = \
+	simple/shared_ctx.c
+simple_fi_shared_ctx_LDADD = libfabtests.la
 
 simple_fi_poll_SOURCES = \
 	simple/poll.c
@@ -126,6 +139,10 @@ streaming_fi_msg_rma_SOURCES = \
 	streaming/msg_rma.c
 streaming_fi_msg_rma_LDADD = libfabtests.la
 
+streaming_fi_msg_stream_SOURCES = \
+	streaming/msg.c
+streaming_fi_msg_stream_LDADD = libfabtests.la
+
 streaming_fi_rdm_atomic_SOURCES = \
 	streaming/rdm_atomic.c
 streaming_fi_rdm_atomic_LDADD = libfabtests.la
@@ -144,6 +161,18 @@ benchmarks_fi_msg_pingpong_SOURCES = \
 	benchmarks/benchmark_shared.c
 benchmarks_fi_msg_pingpong_LDADD = libfabtests.la
 
+benchmarks_fi_msg_bw_SOURCES = \
+	benchmarks/msg_bw.c \
+	benchmarks/benchmark_shared.h \
+	benchmarks/benchmark_shared.c
+benchmarks_fi_msg_bw_LDADD = libfabtests.la
+
+benchmarks_fi_rma_bw_SOURCES = \
+	benchmarks/rma_bw.c \
+	benchmarks/benchmark_shared.h \
+	benchmarks/benchmark_shared.c
+benchmarks_fi_rma_bw_LDADD = libfabtests.la
+
 benchmarks_fi_dgram_pingpong_SOURCES = \
 	benchmarks/dgram_pingpong.c \
 	benchmarks/benchmark_shared.h \
@@ -180,6 +209,11 @@ unit_fi_eq_test_SOURCES = \
 	unit/common.c
 unit_fi_eq_test_LDADD = libfabtests.la
 
+unit_fi_cq_test_SOURCES = \
+	unit/cq_test.c \
+	unit/common.c
+unit_fi_cq_test_LDADD = libfabtests.la
+
 unit_fi_av_test_SOURCES = \
 	unit/av_test.c \
 	unit/common.c
@@ -195,6 +229,11 @@ unit_fi_dom_test_SOURCES = \
 	unit/common.c
 unit_fi_dom_test_LDADD = libfabtests.la
 
+unit_fi_getinfo_test_SOURCES = \
+	unit/getinfo_test.c \
+	unit/common.c
+unit_fi_getinfo_test_LDADD = libfabtests.la
+
 ported_libibverbs_fi_rc_pingpong_SOURCES = \
 	ported/libibverbs/rc_pingpong.c
 ported_libibverbs_fi_rc_pingpong_LDADD = libfabtests.la
diff --git a/Makefile.in b/Makefile.in
index 22f08eb..beaceaa 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.3 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -87,23 +87,26 @@ bin_PROGRAMS = simple/fi_msg$(EXEEXT) simple/fi_msg_sockets$(EXEEXT) \
 	simple/fi_dgram_waitset$(EXEEXT) \
 	simple/fi_rdm_tagged_peek$(EXEEXT) simple/fi_cq_data$(EXEEXT) \
 	simple/fi_poll$(EXEEXT) simple/fi_scalable_ep$(EXEEXT) \
-	simple/fi_rdm_shared_ctx$(EXEEXT) simple/fi_msg_epoll$(EXEEXT) \
-	simple/fi_rdm_shared_av$(EXEEXT) streaming/fi_msg_rma$(EXEEXT) \
-	streaming/fi_rdm_atomic$(EXEEXT) \
+	simple/fi_shared_ctx$(EXEEXT) simple/fi_msg_epoll$(EXEEXT) \
+	simple/fi_rdm_shared_av$(EXEEXT) simple/fi_cm_data$(EXEEXT) \
+	streaming/fi_msg_rma$(EXEEXT) streaming/fi_rdm_atomic$(EXEEXT) \
 	streaming/fi_rdm_multi_recv$(EXEEXT) \
-	streaming/fi_rdm_rma$(EXEEXT) \
+	streaming/fi_rdm_rma$(EXEEXT) streaming/fi_msg_stream$(EXEEXT) \
 	benchmarks/fi_msg_pingpong$(EXEEXT) \
+	benchmarks/fi_msg_bw$(EXEEXT) benchmarks/fi_rma_bw$(EXEEXT) \
 	benchmarks/fi_rdm_cntr_pingpong$(EXEEXT) \
 	benchmarks/fi_dgram_pingpong$(EXEEXT) \
 	benchmarks/fi_rdm_pingpong$(EXEEXT) \
 	benchmarks/fi_rdm_tagged_pingpong$(EXEEXT) \
 	benchmarks/fi_rdm_tagged_bw$(EXEEXT) unit/fi_eq_test$(EXEEXT) \
-	unit/fi_av_test$(EXEEXT) unit/fi_size_left_test$(EXEEXT) \
-	unit/fi_dom_test$(EXEEXT) \
+	unit/fi_cq_test$(EXEEXT) unit/fi_av_test$(EXEEXT) \
+	unit/fi_size_left_test$(EXEEXT) unit/fi_dom_test$(EXEEXT) \
+	unit/fi_getinfo_test$(EXEEXT) \
 	ported/libibverbs/fi_rc_pingpong$(EXEEXT) \
 	ported/librdmacm/fi_cmatose$(EXEEXT) \
 	complex/fi_ubertest$(EXEEXT)
- at MACOS_TRUE@am__append_1 = include/osx/osd.h common/osx/osd.c
+ at MACOS_TRUE@am__append_1 = include/osx/osd.h
+ at HAVE_CLOCK_GETTIME_FALSE@@MACOS_TRUE at am__append_2 = common/osx/osd.c
 subdir = .
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
@@ -137,9 +140,11 @@ libfabtests_la_LIBADD =
 am__libfabtests_la_SOURCES_DIST = common/shared.c common/jsmn.c \
 	include/osx/osd.h common/osx/osd.c
 am__dirstamp = $(am__leading_dot)dirstamp
- at MACOS_TRUE@am__objects_1 = common/osx/osd.lo
+am__objects_1 =
+ at HAVE_CLOCK_GETTIME_FALSE@@MACOS_TRUE at am__objects_2 =  \
+ at HAVE_CLOCK_GETTIME_FALSE@@MACOS_TRUE@	common/osx/osd.lo
 am_libfabtests_la_OBJECTS = common/shared.lo common/jsmn.lo \
-	$(am__objects_1)
+	$(am__objects_1) $(am__objects_2)
 libfabtests_la_OBJECTS = $(am_libfabtests_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
@@ -154,6 +159,10 @@ am_benchmarks_fi_dgram_pingpong_OBJECTS =  \
 benchmarks_fi_dgram_pingpong_OBJECTS =  \
 	$(am_benchmarks_fi_dgram_pingpong_OBJECTS)
 benchmarks_fi_dgram_pingpong_DEPENDENCIES = libfabtests.la
+am_benchmarks_fi_msg_bw_OBJECTS = benchmarks/msg_bw.$(OBJEXT) \
+	benchmarks/benchmark_shared.$(OBJEXT)
+benchmarks_fi_msg_bw_OBJECTS = $(am_benchmarks_fi_msg_bw_OBJECTS)
+benchmarks_fi_msg_bw_DEPENDENCIES = libfabtests.la
 am_benchmarks_fi_msg_pingpong_OBJECTS =  \
 	benchmarks/msg_pingpong.$(OBJEXT) \
 	benchmarks/benchmark_shared.$(OBJEXT)
@@ -184,6 +193,10 @@ am_benchmarks_fi_rdm_tagged_pingpong_OBJECTS =  \
 benchmarks_fi_rdm_tagged_pingpong_OBJECTS =  \
 	$(am_benchmarks_fi_rdm_tagged_pingpong_OBJECTS)
 benchmarks_fi_rdm_tagged_pingpong_DEPENDENCIES = libfabtests.la
+am_benchmarks_fi_rma_bw_OBJECTS = benchmarks/rma_bw.$(OBJEXT) \
+	benchmarks/benchmark_shared.$(OBJEXT)
+benchmarks_fi_rma_bw_OBJECTS = $(am_benchmarks_fi_rma_bw_OBJECTS)
+benchmarks_fi_rma_bw_DEPENDENCIES = libfabtests.la
 am_complex_fi_ubertest_OBJECTS = complex/ft_main.$(OBJEXT) \
 	complex/ft_comm.$(OBJEXT) complex/ft_comp.$(OBJEXT) \
 	complex/ft_config.$(OBJEXT) complex/ft_domain.$(OBJEXT) \
@@ -201,6 +214,9 @@ am_ported_librdmacm_fi_cmatose_OBJECTS =  \
 ported_librdmacm_fi_cmatose_OBJECTS =  \
 	$(am_ported_librdmacm_fi_cmatose_OBJECTS)
 ported_librdmacm_fi_cmatose_DEPENDENCIES = libfabtests.la
+am_simple_fi_cm_data_OBJECTS = simple/cm_data.$(OBJEXT)
+simple_fi_cm_data_OBJECTS = $(am_simple_fi_cm_data_OBJECTS)
+simple_fi_cm_data_DEPENDENCIES = libfabtests.la
 am_simple_fi_cq_data_OBJECTS = simple/cq_data.$(OBJEXT)
 simple_fi_cq_data_OBJECTS = $(am_simple_fi_cq_data_OBJECTS)
 simple_fi_cq_data_DEPENDENCIES = libfabtests.la
@@ -239,10 +255,6 @@ am_simple_fi_rdm_shared_av_OBJECTS = simple/rdm_shared_av.$(OBJEXT)
 simple_fi_rdm_shared_av_OBJECTS =  \
 	$(am_simple_fi_rdm_shared_av_OBJECTS)
 simple_fi_rdm_shared_av_DEPENDENCIES = libfabtests.la
-am_simple_fi_rdm_shared_ctx_OBJECTS = simple/rdm_shared_ctx.$(OBJEXT)
-simple_fi_rdm_shared_ctx_OBJECTS =  \
-	$(am_simple_fi_rdm_shared_ctx_OBJECTS)
-simple_fi_rdm_shared_ctx_DEPENDENCIES = libfabtests.la
 am_simple_fi_rdm_tagged_peek_OBJECTS =  \
 	simple/rdm_tagged_peek.$(OBJEXT)
 simple_fi_rdm_tagged_peek_OBJECTS =  \
@@ -251,9 +263,16 @@ simple_fi_rdm_tagged_peek_DEPENDENCIES = libfabtests.la
 am_simple_fi_scalable_ep_OBJECTS = simple/scalable_ep.$(OBJEXT)
 simple_fi_scalable_ep_OBJECTS = $(am_simple_fi_scalable_ep_OBJECTS)
 simple_fi_scalable_ep_DEPENDENCIES = libfabtests.la
+am_simple_fi_shared_ctx_OBJECTS = simple/shared_ctx.$(OBJEXT)
+simple_fi_shared_ctx_OBJECTS = $(am_simple_fi_shared_ctx_OBJECTS)
+simple_fi_shared_ctx_DEPENDENCIES = libfabtests.la
 am_streaming_fi_msg_rma_OBJECTS = streaming/msg_rma.$(OBJEXT)
 streaming_fi_msg_rma_OBJECTS = $(am_streaming_fi_msg_rma_OBJECTS)
 streaming_fi_msg_rma_DEPENDENCIES = libfabtests.la
+am_streaming_fi_msg_stream_OBJECTS = streaming/msg.$(OBJEXT)
+streaming_fi_msg_stream_OBJECTS =  \
+	$(am_streaming_fi_msg_stream_OBJECTS)
+streaming_fi_msg_stream_DEPENDENCIES = libfabtests.la
 am_streaming_fi_rdm_atomic_OBJECTS = streaming/rdm_atomic.$(OBJEXT)
 streaming_fi_rdm_atomic_OBJECTS =  \
 	$(am_streaming_fi_rdm_atomic_OBJECTS)
@@ -270,6 +289,10 @@ am_unit_fi_av_test_OBJECTS = unit/av_test.$(OBJEXT) \
 	unit/common.$(OBJEXT)
 unit_fi_av_test_OBJECTS = $(am_unit_fi_av_test_OBJECTS)
 unit_fi_av_test_DEPENDENCIES = libfabtests.la
+am_unit_fi_cq_test_OBJECTS = unit/cq_test.$(OBJEXT) \
+	unit/common.$(OBJEXT)
+unit_fi_cq_test_OBJECTS = $(am_unit_fi_cq_test_OBJECTS)
+unit_fi_cq_test_DEPENDENCIES = libfabtests.la
 am_unit_fi_dom_test_OBJECTS = unit/dom_test.$(OBJEXT) \
 	unit/common.$(OBJEXT)
 unit_fi_dom_test_OBJECTS = $(am_unit_fi_dom_test_OBJECTS)
@@ -278,6 +301,10 @@ am_unit_fi_eq_test_OBJECTS = unit/eq_test.$(OBJEXT) \
 	unit/common.$(OBJEXT)
 unit_fi_eq_test_OBJECTS = $(am_unit_fi_eq_test_OBJECTS)
 unit_fi_eq_test_DEPENDENCIES = libfabtests.la
+am_unit_fi_getinfo_test_OBJECTS = unit/getinfo_test.$(OBJEXT) \
+	unit/common.$(OBJEXT)
+unit_fi_getinfo_test_OBJECTS = $(am_unit_fi_getinfo_test_OBJECTS)
+unit_fi_getinfo_test_DEPENDENCIES = libfabtests.la
 am_unit_fi_size_left_test_OBJECTS = unit/size_left_test.$(OBJEXT) \
 	unit/common.$(OBJEXT)
 unit_fi_size_left_test_OBJECTS = $(am_unit_fi_size_left_test_OBJECTS)
@@ -346,55 +373,61 @@ am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libfabtests_la_SOURCES) \
 	$(benchmarks_fi_dgram_pingpong_SOURCES) \
+	$(benchmarks_fi_msg_bw_SOURCES) \
 	$(benchmarks_fi_msg_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_cntr_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_tagged_bw_SOURCES) \
 	$(benchmarks_fi_rdm_tagged_pingpong_SOURCES) \
-	$(complex_fi_ubertest_SOURCES) \
+	$(benchmarks_fi_rma_bw_SOURCES) $(complex_fi_ubertest_SOURCES) \
 	$(ported_libibverbs_fi_rc_pingpong_SOURCES) \
 	$(ported_librdmacm_fi_cmatose_SOURCES) \
-	$(simple_fi_cq_data_SOURCES) $(simple_fi_dgram_SOURCES) \
-	$(simple_fi_dgram_waitset_SOURCES) $(simple_fi_msg_SOURCES) \
-	$(simple_fi_msg_epoll_SOURCES) \
+	$(simple_fi_cm_data_SOURCES) $(simple_fi_cq_data_SOURCES) \
+	$(simple_fi_dgram_SOURCES) $(simple_fi_dgram_waitset_SOURCES) \
+	$(simple_fi_msg_SOURCES) $(simple_fi_msg_epoll_SOURCES) \
 	$(simple_fi_msg_sockets_SOURCES) $(simple_fi_poll_SOURCES) \
 	$(simple_fi_rdm_SOURCES) $(simple_fi_rdm_rma_simple_SOURCES) \
 	$(simple_fi_rdm_rma_trigger_SOURCES) \
 	$(simple_fi_rdm_shared_av_SOURCES) \
-	$(simple_fi_rdm_shared_ctx_SOURCES) \
 	$(simple_fi_rdm_tagged_peek_SOURCES) \
 	$(simple_fi_scalable_ep_SOURCES) \
+	$(simple_fi_shared_ctx_SOURCES) \
 	$(streaming_fi_msg_rma_SOURCES) \
+	$(streaming_fi_msg_stream_SOURCES) \
 	$(streaming_fi_rdm_atomic_SOURCES) \
 	$(streaming_fi_rdm_multi_recv_SOURCES) \
 	$(streaming_fi_rdm_rma_SOURCES) $(unit_fi_av_test_SOURCES) \
-	$(unit_fi_dom_test_SOURCES) $(unit_fi_eq_test_SOURCES) \
+	$(unit_fi_cq_test_SOURCES) $(unit_fi_dom_test_SOURCES) \
+	$(unit_fi_eq_test_SOURCES) $(unit_fi_getinfo_test_SOURCES) \
 	$(unit_fi_size_left_test_SOURCES)
 DIST_SOURCES = $(am__libfabtests_la_SOURCES_DIST) \
 	$(benchmarks_fi_dgram_pingpong_SOURCES) \
+	$(benchmarks_fi_msg_bw_SOURCES) \
 	$(benchmarks_fi_msg_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_cntr_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_pingpong_SOURCES) \
 	$(benchmarks_fi_rdm_tagged_bw_SOURCES) \
 	$(benchmarks_fi_rdm_tagged_pingpong_SOURCES) \
-	$(complex_fi_ubertest_SOURCES) \
+	$(benchmarks_fi_rma_bw_SOURCES) $(complex_fi_ubertest_SOURCES) \
 	$(ported_libibverbs_fi_rc_pingpong_SOURCES) \
 	$(ported_librdmacm_fi_cmatose_SOURCES) \
-	$(simple_fi_cq_data_SOURCES) $(simple_fi_dgram_SOURCES) \
-	$(simple_fi_dgram_waitset_SOURCES) $(simple_fi_msg_SOURCES) \
-	$(simple_fi_msg_epoll_SOURCES) \
+	$(simple_fi_cm_data_SOURCES) $(simple_fi_cq_data_SOURCES) \
+	$(simple_fi_dgram_SOURCES) $(simple_fi_dgram_waitset_SOURCES) \
+	$(simple_fi_msg_SOURCES) $(simple_fi_msg_epoll_SOURCES) \
 	$(simple_fi_msg_sockets_SOURCES) $(simple_fi_poll_SOURCES) \
 	$(simple_fi_rdm_SOURCES) $(simple_fi_rdm_rma_simple_SOURCES) \
 	$(simple_fi_rdm_rma_trigger_SOURCES) \
 	$(simple_fi_rdm_shared_av_SOURCES) \
-	$(simple_fi_rdm_shared_ctx_SOURCES) \
 	$(simple_fi_rdm_tagged_peek_SOURCES) \
 	$(simple_fi_scalable_ep_SOURCES) \
+	$(simple_fi_shared_ctx_SOURCES) \
 	$(streaming_fi_msg_rma_SOURCES) \
+	$(streaming_fi_msg_stream_SOURCES) \
 	$(streaming_fi_rdm_atomic_SOURCES) \
 	$(streaming_fi_rdm_multi_recv_SOURCES) \
 	$(streaming_fi_rdm_rma_SOURCES) $(unit_fi_av_test_SOURCES) \
-	$(unit_fi_dom_test_SOURCES) $(unit_fi_eq_test_SOURCES) \
+	$(unit_fi_cq_test_SOURCES) $(unit_fi_dom_test_SOURCES) \
+	$(unit_fi_eq_test_SOURCES) $(unit_fi_getinfo_test_SOURCES) \
 	$(unit_fi_size_left_test_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -583,7 +616,8 @@ nobase_dist_config_DATA = \
 	test_configs/usnic/quick.test
 
 noinst_LTLIBRARIES = libfabtests.la
-libfabtests_la_SOURCES = common/shared.c common/jsmn.c $(am__append_1)
+libfabtests_la_SOURCES = common/shared.c common/jsmn.c $(am__append_1) \
+	$(am__append_2)
 simple_fi_msg_sockets_SOURCES = \
 	simple/msg_sockets.c
 
@@ -628,14 +662,18 @@ simple_fi_cq_data_SOURCES = \
 	simple/cq_data.c
 
 simple_fi_cq_data_LDADD = libfabtests.la
+simple_fi_cm_data_SOURCES = \
+	simple/cm_data.c
+
+simple_fi_cm_data_LDADD = libfabtests.la
 simple_fi_scalable_ep_SOURCES = \
 	simple/scalable_ep.c
 
 simple_fi_scalable_ep_LDADD = libfabtests.la
-simple_fi_rdm_shared_ctx_SOURCES = \
-	simple/rdm_shared_ctx.c
+simple_fi_shared_ctx_SOURCES = \
+	simple/shared_ctx.c
 
-simple_fi_rdm_shared_ctx_LDADD = libfabtests.la
+simple_fi_shared_ctx_LDADD = libfabtests.la
 simple_fi_poll_SOURCES = \
 	simple/poll.c
 
@@ -644,6 +682,10 @@ streaming_fi_msg_rma_SOURCES = \
 	streaming/msg_rma.c
 
 streaming_fi_msg_rma_LDADD = libfabtests.la
+streaming_fi_msg_stream_SOURCES = \
+	streaming/msg.c
+
+streaming_fi_msg_stream_LDADD = libfabtests.la
 streaming_fi_rdm_atomic_SOURCES = \
 	streaming/rdm_atomic.c
 
@@ -662,6 +704,18 @@ benchmarks_fi_msg_pingpong_SOURCES = \
 	benchmarks/benchmark_shared.c
 
 benchmarks_fi_msg_pingpong_LDADD = libfabtests.la
+benchmarks_fi_msg_bw_SOURCES = \
+	benchmarks/msg_bw.c \
+	benchmarks/benchmark_shared.h \
+	benchmarks/benchmark_shared.c
+
+benchmarks_fi_msg_bw_LDADD = libfabtests.la
+benchmarks_fi_rma_bw_SOURCES = \
+	benchmarks/rma_bw.c \
+	benchmarks/benchmark_shared.h \
+	benchmarks/benchmark_shared.c
+
+benchmarks_fi_rma_bw_LDADD = libfabtests.la
 benchmarks_fi_dgram_pingpong_SOURCES = \
 	benchmarks/dgram_pingpong.c \
 	benchmarks/benchmark_shared.h \
@@ -697,6 +751,11 @@ unit_fi_eq_test_SOURCES = \
 	unit/common.c
 
 unit_fi_eq_test_LDADD = libfabtests.la
+unit_fi_cq_test_SOURCES = \
+	unit/cq_test.c \
+	unit/common.c
+
+unit_fi_cq_test_LDADD = libfabtests.la
 unit_fi_av_test_SOURCES = \
 	unit/av_test.c \
 	unit/common.c
@@ -712,6 +771,11 @@ unit_fi_dom_test_SOURCES = \
 	unit/common.c
 
 unit_fi_dom_test_LDADD = libfabtests.la
+unit_fi_getinfo_test_SOURCES = \
+	unit/getinfo_test.c \
+	unit/common.c
+
+unit_fi_getinfo_test_LDADD = libfabtests.la
 ported_libibverbs_fi_rc_pingpong_SOURCES = \
 	ported/libibverbs/rc_pingpong.c
 
@@ -780,8 +844,8 @@ $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 $(am__aclocal_m4_deps):
 
 config.h: stamp-h1
-	@test -f $@ || rm -f stamp-h1
-	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+	@if test ! -f $@; then rm -f stamp-h1; else :; fi
+	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
 
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
@@ -890,6 +954,12 @@ benchmarks/benchmark_shared.$(OBJEXT): benchmarks/$(am__dirstamp) \
 benchmarks/fi_dgram_pingpong$(EXEEXT): $(benchmarks_fi_dgram_pingpong_OBJECTS) $(benchmarks_fi_dgram_pingpong_DEPENDENCIES) $(EXTRA_benchmarks_fi_dgram_pingpong_DEPENDENCIES) benchmarks/$(am__dirstamp)
 	@rm -f benchmarks/fi_dgram_pingpong$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(benchmarks_fi_dgram_pingpong_OBJECTS) $(benchmarks_fi_dgram_pingpong_LDADD) $(LIBS)
+benchmarks/msg_bw.$(OBJEXT): benchmarks/$(am__dirstamp) \
+	benchmarks/$(DEPDIR)/$(am__dirstamp)
+
+benchmarks/fi_msg_bw$(EXEEXT): $(benchmarks_fi_msg_bw_OBJECTS) $(benchmarks_fi_msg_bw_DEPENDENCIES) $(EXTRA_benchmarks_fi_msg_bw_DEPENDENCIES) benchmarks/$(am__dirstamp)
+	@rm -f benchmarks/fi_msg_bw$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(benchmarks_fi_msg_bw_OBJECTS) $(benchmarks_fi_msg_bw_LDADD) $(LIBS)
 benchmarks/msg_pingpong.$(OBJEXT): benchmarks/$(am__dirstamp) \
 	benchmarks/$(DEPDIR)/$(am__dirstamp)
 
@@ -920,6 +990,12 @@ benchmarks/rdm_tagged_pingpong.$(OBJEXT): benchmarks/$(am__dirstamp) \
 benchmarks/fi_rdm_tagged_pingpong$(EXEEXT): $(benchmarks_fi_rdm_tagged_pingpong_OBJECTS) $(benchmarks_fi_rdm_tagged_pingpong_DEPENDENCIES) $(EXTRA_benchmarks_fi_rdm_tagged_pingpong_DEPENDENCIES) benchmarks/$(am__dirstamp)
 	@rm -f benchmarks/fi_rdm_tagged_pingpong$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(benchmarks_fi_rdm_tagged_pingpong_OBJECTS) $(benchmarks_fi_rdm_tagged_pingpong_LDADD) $(LIBS)
+benchmarks/rma_bw.$(OBJEXT): benchmarks/$(am__dirstamp) \
+	benchmarks/$(DEPDIR)/$(am__dirstamp)
+
+benchmarks/fi_rma_bw$(EXEEXT): $(benchmarks_fi_rma_bw_OBJECTS) $(benchmarks_fi_rma_bw_DEPENDENCIES) $(EXTRA_benchmarks_fi_rma_bw_DEPENDENCIES) benchmarks/$(am__dirstamp)
+	@rm -f benchmarks/fi_rma_bw$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(benchmarks_fi_rma_bw_OBJECTS) $(benchmarks_fi_rma_bw_LDADD) $(LIBS)
 complex/$(am__dirstamp):
 	@$(MKDIR_P) complex
 	@: > complex/$(am__dirstamp)
@@ -977,6 +1053,12 @@ simple/$(am__dirstamp):
 simple/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) simple/$(DEPDIR)
 	@: > simple/$(DEPDIR)/$(am__dirstamp)
+simple/cm_data.$(OBJEXT): simple/$(am__dirstamp) \
+	simple/$(DEPDIR)/$(am__dirstamp)
+
+simple/fi_cm_data$(EXEEXT): $(simple_fi_cm_data_OBJECTS) $(simple_fi_cm_data_DEPENDENCIES) $(EXTRA_simple_fi_cm_data_DEPENDENCIES) simple/$(am__dirstamp)
+	@rm -f simple/fi_cm_data$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(simple_fi_cm_data_OBJECTS) $(simple_fi_cm_data_LDADD) $(LIBS)
 simple/cq_data.$(OBJEXT): simple/$(am__dirstamp) \
 	simple/$(DEPDIR)/$(am__dirstamp)
 
@@ -1043,12 +1125,6 @@ simple/rdm_shared_av.$(OBJEXT): simple/$(am__dirstamp) \
 simple/fi_rdm_shared_av$(EXEEXT): $(simple_fi_rdm_shared_av_OBJECTS) $(simple_fi_rdm_shared_av_DEPENDENCIES) $(EXTRA_simple_fi_rdm_shared_av_DEPENDENCIES) simple/$(am__dirstamp)
 	@rm -f simple/fi_rdm_shared_av$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(simple_fi_rdm_shared_av_OBJECTS) $(simple_fi_rdm_shared_av_LDADD) $(LIBS)
-simple/rdm_shared_ctx.$(OBJEXT): simple/$(am__dirstamp) \
-	simple/$(DEPDIR)/$(am__dirstamp)
-
-simple/fi_rdm_shared_ctx$(EXEEXT): $(simple_fi_rdm_shared_ctx_OBJECTS) $(simple_fi_rdm_shared_ctx_DEPENDENCIES) $(EXTRA_simple_fi_rdm_shared_ctx_DEPENDENCIES) simple/$(am__dirstamp)
-	@rm -f simple/fi_rdm_shared_ctx$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(simple_fi_rdm_shared_ctx_OBJECTS) $(simple_fi_rdm_shared_ctx_LDADD) $(LIBS)
 simple/rdm_tagged_peek.$(OBJEXT): simple/$(am__dirstamp) \
 	simple/$(DEPDIR)/$(am__dirstamp)
 
@@ -1061,6 +1137,12 @@ simple/scalable_ep.$(OBJEXT): simple/$(am__dirstamp) \
 simple/fi_scalable_ep$(EXEEXT): $(simple_fi_scalable_ep_OBJECTS) $(simple_fi_scalable_ep_DEPENDENCIES) $(EXTRA_simple_fi_scalable_ep_DEPENDENCIES) simple/$(am__dirstamp)
 	@rm -f simple/fi_scalable_ep$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(simple_fi_scalable_ep_OBJECTS) $(simple_fi_scalable_ep_LDADD) $(LIBS)
+simple/shared_ctx.$(OBJEXT): simple/$(am__dirstamp) \
+	simple/$(DEPDIR)/$(am__dirstamp)
+
+simple/fi_shared_ctx$(EXEEXT): $(simple_fi_shared_ctx_OBJECTS) $(simple_fi_shared_ctx_DEPENDENCIES) $(EXTRA_simple_fi_shared_ctx_DEPENDENCIES) simple/$(am__dirstamp)
+	@rm -f simple/fi_shared_ctx$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(simple_fi_shared_ctx_OBJECTS) $(simple_fi_shared_ctx_LDADD) $(LIBS)
 streaming/$(am__dirstamp):
 	@$(MKDIR_P) streaming
 	@: > streaming/$(am__dirstamp)
@@ -1073,6 +1155,12 @@ streaming/msg_rma.$(OBJEXT): streaming/$(am__dirstamp) \
 streaming/fi_msg_rma$(EXEEXT): $(streaming_fi_msg_rma_OBJECTS) $(streaming_fi_msg_rma_DEPENDENCIES) $(EXTRA_streaming_fi_msg_rma_DEPENDENCIES) streaming/$(am__dirstamp)
 	@rm -f streaming/fi_msg_rma$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(streaming_fi_msg_rma_OBJECTS) $(streaming_fi_msg_rma_LDADD) $(LIBS)
+streaming/msg.$(OBJEXT): streaming/$(am__dirstamp) \
+	streaming/$(DEPDIR)/$(am__dirstamp)
+
+streaming/fi_msg_stream$(EXEEXT): $(streaming_fi_msg_stream_OBJECTS) $(streaming_fi_msg_stream_DEPENDENCIES) $(EXTRA_streaming_fi_msg_stream_DEPENDENCIES) streaming/$(am__dirstamp)
+	@rm -f streaming/fi_msg_stream$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(streaming_fi_msg_stream_OBJECTS) $(streaming_fi_msg_stream_LDADD) $(LIBS)
 streaming/rdm_atomic.$(OBJEXT): streaming/$(am__dirstamp) \
 	streaming/$(DEPDIR)/$(am__dirstamp)
 
@@ -1105,6 +1193,12 @@ unit/common.$(OBJEXT): unit/$(am__dirstamp) \
 unit/fi_av_test$(EXEEXT): $(unit_fi_av_test_OBJECTS) $(unit_fi_av_test_DEPENDENCIES) $(EXTRA_unit_fi_av_test_DEPENDENCIES) unit/$(am__dirstamp)
 	@rm -f unit/fi_av_test$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(unit_fi_av_test_OBJECTS) $(unit_fi_av_test_LDADD) $(LIBS)
+unit/cq_test.$(OBJEXT): unit/$(am__dirstamp) \
+	unit/$(DEPDIR)/$(am__dirstamp)
+
+unit/fi_cq_test$(EXEEXT): $(unit_fi_cq_test_OBJECTS) $(unit_fi_cq_test_DEPENDENCIES) $(EXTRA_unit_fi_cq_test_DEPENDENCIES) unit/$(am__dirstamp)
+	@rm -f unit/fi_cq_test$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(unit_fi_cq_test_OBJECTS) $(unit_fi_cq_test_LDADD) $(LIBS)
 unit/dom_test.$(OBJEXT): unit/$(am__dirstamp) \
 	unit/$(DEPDIR)/$(am__dirstamp)
 
@@ -1117,6 +1211,12 @@ unit/eq_test.$(OBJEXT): unit/$(am__dirstamp) \
 unit/fi_eq_test$(EXEEXT): $(unit_fi_eq_test_OBJECTS) $(unit_fi_eq_test_DEPENDENCIES) $(EXTRA_unit_fi_eq_test_DEPENDENCIES) unit/$(am__dirstamp)
 	@rm -f unit/fi_eq_test$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(unit_fi_eq_test_OBJECTS) $(unit_fi_eq_test_LDADD) $(LIBS)
+unit/getinfo_test.$(OBJEXT): unit/$(am__dirstamp) \
+	unit/$(DEPDIR)/$(am__dirstamp)
+
+unit/fi_getinfo_test$(EXEEXT): $(unit_fi_getinfo_test_OBJECTS) $(unit_fi_getinfo_test_DEPENDENCIES) $(EXTRA_unit_fi_getinfo_test_DEPENDENCIES) unit/$(am__dirstamp)
+	@rm -f unit/fi_getinfo_test$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(unit_fi_getinfo_test_OBJECTS) $(unit_fi_getinfo_test_LDADD) $(LIBS)
 unit/size_left_test.$(OBJEXT): unit/$(am__dirstamp) \
 	unit/$(DEPDIR)/$(am__dirstamp)
 
@@ -1178,11 +1278,13 @@ distclean-compile:
 
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/benchmark_shared.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/dgram_pingpong.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/msg_bw.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/msg_pingpong.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/rdm_cntr_pingpong.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/rdm_pingpong.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/rdm_tagged_bw.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/rdm_tagged_pingpong.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at benchmarks/$(DEPDIR)/rma_bw.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/jsmn.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/$(DEPDIR)/shared.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at common/osx/$(DEPDIR)/osd.Plo at am__quote@
@@ -1196,6 +1298,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at complex/$(DEPDIR)/ft_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ported/libibverbs/$(DEPDIR)/rc_pingpong.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ported/librdmacm/$(DEPDIR)/cmatose.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/cm_data.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/cq_data.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/dgram.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/dgram_waitset.Po at am__quote@
@@ -1207,17 +1310,20 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/rdm_rma_simple.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/rdm_rma_trigger.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/rdm_shared_av.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/rdm_shared_ctx.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/rdm_tagged_peek.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/scalable_ep.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at simple/$(DEPDIR)/shared_ctx.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at streaming/$(DEPDIR)/msg.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at streaming/$(DEPDIR)/msg_rma.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at streaming/$(DEPDIR)/rdm_atomic.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at streaming/$(DEPDIR)/rdm_multi_recv.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at streaming/$(DEPDIR)/rdm_rma.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/av_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/common.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/cq_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/dom_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/eq_test.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/getinfo_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at unit/$(DEPDIR)/size_left_test.Po at am__quote@
 
 .c.o:
@@ -1446,16 +1552,10 @@ dist-xz: distdir
 	$(am__post_remove_distdir)
 
 dist-tarZ: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
-	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 	$(am__post_remove_distdir)
 
 dist-shar: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
-	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
 	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
 
@@ -1497,10 +1597,9 @@ distcheck: dist
 	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 	  && am__cwd=`pwd` \
 	  && $(am__cd) $(distdir)/_build \
-	  && ../configure \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
 	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
diff --git a/aclocal.m4 b/aclocal.m4
index 4aee5bc..bbefa4a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.13.3 -*- Autoconf -*-
 
 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.14'
+[am__api_version='1.13'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.14.1], [],
+m4_if([$1], [1.13.3], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.14.1])dnl
+[AM_AUTOMAKE_VERSION([1.13.3])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
@@ -76,8 +76,7 @@ AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
 : ${AR=ar}
 
 AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
-  [AC_LANG_PUSH([C])
-   am_cv_ar_interface=ar
+  [am_cv_ar_interface=ar
    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
      [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
       AC_TRY_EVAL([am_ar_try])
@@ -94,7 +93,7 @@ AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
       fi
       rm -f conftest.lib libconftest.a
      ])
-   AC_LANG_POP([C])])
+   ])
 
 case $am_cv_ar_interface in
 ar)
@@ -478,12 +477,6 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
 
-dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
-m4_define([AC_PROG_CC],
-m4_defn([AC_PROG_CC])
-[_AM_PROG_CC_C_O
-])
-
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
 # -----------------------------------------------
@@ -592,48 +585,7 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-
-# POSIX will say in a future version that running "rm -f" with no argument
-# is OK; and we want to be able to make that assumption in our Makefile
-# recipes.  So use an aggressive probe to check that the usage we want is
-# actually supported "in the wild" to an acceptable degree.
-# See automake bug#10828.
-# To make any issue more visible, cause the running configure to be aborted
-# by default if the 'rm' program in use doesn't match our expectations; the
-# user can still override this though.
-if rm -f && rm -fr && rm -rf; then : OK; else
-  cat >&2 <<'END'
-Oops!
-
-Your 'rm' program seems unable to run without file operands specified
-on the command line, even when the '-f' option is present.  This is contrary
-to the behaviour of most rm programs out there, and not conforming with
-the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
-
-Please tell bug-automake at gnu.org about your system, including the value
-of your $PATH and any error possibly output before this message.  This
-can help us improve future automake versions.
-
-END
-  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
-    echo 'Configuration will proceed anyway, since you have set the' >&2
-    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
-    echo >&2
-  else
-    cat >&2 <<'END'
-Aborting the configuration process, to ensure you take notice of the issue.
-
-You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <http://www.gnu.org/software/coreutils/>.
-
-If you want to complete the configuration process using your problematic
-'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
-to "yes", and re-run configure.
-
-END
-    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
-  fi
-fi])
+])
 
 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
@@ -641,6 +593,7 @@ dnl mangled by Autoconf and run in a shell conditional statement.
 m4_define([_AC_COMPILER_EXEEXT],
 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
 
+
 # When config.status generates a header, we must update the stamp-h file.
 # This file resides in the same directory as the config header
 # that is generated.  The stamp files are numbered to have different names.
@@ -752,6 +705,38 @@ AC_MSG_RESULT([$_am_result])
 rm -f confinc confmf
 ])
 
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+          [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
 # Copyright (C) 1997-2013 Free Software Foundation, Inc.
@@ -822,70 +807,6 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# _AM_PROG_CC_C_O
-# ---------------
-# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC
-# to automatically call this.
-AC_DEFUN([_AM_PROG_CC_C_O],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-AC_REQUIRE_AUX_FILE([compile])dnl
-AC_LANG_PUSH([C])dnl
-AC_CACHE_CHECK(
-  [whether $CC understands -c and -o together],
-  [am_cv_prog_cc_c_o],
-  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
-  # Make sure it works both with $CC and with simple cc.
-  # Following AC_PROG_CC_C_O, we do the test twice because some
-  # compilers refuse to overwrite an existing .o file with -o,
-  # though they will create one.
-  am_cv_prog_cc_c_o=yes
-  for am_i in 1 2; do
-    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
-         && test -f conftest2.$ac_objext; then
-      : OK
-    else
-      am_cv_prog_cc_c_o=no
-      break
-    fi
-  done
-  rm -f core conftest*
-  unset am_i])
-if test "$am_cv_prog_cc_c_o" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-AC_LANG_POP([C])])
-
-# For backward compatibility.
-AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
-
-# Copyright (C) 2001-2013 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_RUN_LOG(COMMAND)
-# -------------------
-# Run COMMAND, save the exit status in ac_status, and log it.
-# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
-AC_DEFUN([AM_RUN_LOG],
-[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
-   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
-   ac_status=$?
-   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
-   (exit $ac_status); }])
-
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
diff --git a/benchmarks/benchmark_shared.c b/benchmarks/benchmark_shared.c
index bb9c9aa..b2bfaea 100644
--- a/benchmarks/benchmark_shared.c
+++ b/benchmarks/benchmark_shared.c
@@ -34,10 +34,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "benchmark_shared.h"
@@ -48,7 +45,7 @@ void ft_parse_benchmark_opts(int op, char *optarg)
 	case 'v':
 		opts.options |= FT_OPT_VERIFY_DATA;
 		break;
-	case 'P':
+	case 'k':
 		hints->mode |= FI_MSG_PREFIX;
 		break;
 	case 'j':
@@ -65,9 +62,22 @@ void ft_parse_benchmark_opts(int op, char *optarg)
 void ft_benchmark_usage(void)
 {
 	FT_PRINT_OPTS_USAGE("-v", "enables data_integrity checks");
-	FT_PRINT_OPTS_USAGE("-P", "enable prefix mode");
+	FT_PRINT_OPTS_USAGE("-k", "enable prefix mode");
 	FT_PRINT_OPTS_USAGE("-j", "maximum inject message size");
-	FT_PRINT_OPTS_USAGE("-W", "window size (for bandwidth tests)");
+	FT_PRINT_OPTS_USAGE("-W", "window size* (for bandwidth tests)\n\n"
+			"* The following condition is required to have at least "
+			"one window\nsize # of messsages to be sent: "
+			"# of iterations > window size");
+}
+
+int ft_bw_init(void)
+{
+	if (opts.window_size > 0) {
+		tx_ctx_arr = calloc(opts.window_size, sizeof(struct fi_context));
+		if (!tx_ctx_arr)
+			return -FI_ENOMEM;
+	}
+	return 0;
 }
 
 int pingpong(void)
@@ -84,13 +94,13 @@ int pingpong(void)
 				ft_start();
 
 			if (opts.transfer_size < fi->tx_attr->inject_size)
-				ret = ft_inject(opts.transfer_size);
+				ret = ft_inject(ep, opts.transfer_size);
 			else
-				ret = ft_tx(opts.transfer_size);
+				ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
 			if (ret)
 				return ret;
 
-			ret = ft_rx(opts.transfer_size);
+			ret = ft_rx(ep, opts.transfer_size);
 			if (ret)
 				return ret;
 		}
@@ -99,14 +109,14 @@ int pingpong(void)
 			if (i == opts.warmup_iterations)
 				ft_start();
 
-			ret = ft_rx(opts.transfer_size);
+			ret = ft_rx(ep, opts.transfer_size);
 			if (ret)
 				return ret;
 
 			if (opts.transfer_size < fi->tx_attr->inject_size)
-				ret = ft_inject(opts.transfer_size);
+				ret = ft_inject(ep, opts.transfer_size);
 			else
-				ret = ft_tx(opts.transfer_size);
+				ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
 			if (ret)
 				return ret;
 		}
@@ -114,13 +124,35 @@ int pingpong(void)
 	ft_stop();
 
 	if (opts.machr)
-		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 2, opts.argc, opts.argv);
+		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 2,
+				opts.argc, opts.argv);
 	else
 		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 2);
 
 	return 0;
 }
 
+static int bw_tx_comp()
+{
+	int ret;
+
+	ret = ft_get_tx_comp(tx_seq);
+	if (ret)
+		return ret;
+	return ft_rx(ep, 4);
+}
+
+static int bw_rx_comp()
+{
+	int ret;
+
+	/* rx_seq is always one ahead */
+	ret = ft_get_rx_comp(rx_seq - 1);
+	if (ret)
+		return ret;
+	return ft_tx(ep, remote_fi_addr, 4, &tx_ctx);
+}
+
 int bandwidth(void)
 {
 	int ret, i, j;
@@ -137,51 +169,144 @@ int bandwidth(void)
 	 * bandwidth.  */
 
 	if (opts.dst_addr) {
-		for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) {
+		for (i = j = 0; i < opts.iterations + opts.warmup_iterations; i++) {
 			if (i == opts.warmup_iterations)
 				ft_start();
 
-			for(j = 0; j < opts.window_size; j++) {
-				if (opts.transfer_size < fi->tx_attr->inject_size)
-					ret = ft_inject(opts.transfer_size);
-				else
-					ret = ft_post_tx(opts.transfer_size);
+			if (opts.transfer_size < fi->tx_attr->inject_size)
+				ret = ft_inject(ep, opts.transfer_size);
+			else
+				ret = ft_post_tx(ep, remote_fi_addr, opts.transfer_size,
+						 &tx_ctx_arr[j]);
+			if (ret)
+				return ret;
+
+			if (++j == opts.window_size) {
+				ret = bw_tx_comp();
 				if (ret)
 					return ret;
+				j = 0;
 			}
-			ret = ft_get_tx_comp(tx_seq);
-			if (ret)
-				return ret;
-			ret = ft_rx(4);
-			if (ret)
-				return ret;
 		}
+		ret = bw_tx_comp();
+		if (ret)
+			return ret;
 	} else {
-		for (i = 0; i < opts.iterations + opts.warmup_iterations; i++) {
+		for (i = j = 0; i < opts.iterations + opts.warmup_iterations; i++) {
 			if (i == opts.warmup_iterations)
 				ft_start();
 
-			for(j = 0; j < opts.window_size; j++) {
-				ret = ft_post_rx(opts.transfer_size);
+			ret = ft_post_rx(ep, opts.transfer_size, &tx_ctx_arr[j]);
+			if (ret)
+				return ret;
+
+			if (++j == opts.window_size) {
+				ret = bw_rx_comp();
 				if (ret)
 					return ret;
+				j = 0;
 			}
-			ret = ft_get_rx_comp(rx_seq-1); /* rx_seq is always one ahead */
-			if (ret)
-				return ret;
-			ret = ft_tx(4);
+		}
+		ret = bw_rx_comp();
+		if (ret)
+			return ret;
+	}
+	ft_stop();
+
+	if (opts.machr)
+		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 1,
+				opts.argc, opts.argv);
+	else
+		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 1);
+
+	return 0;
+}
+
+static int bw_rma_comp(enum ft_rma_opcodes rma_op)
+{
+	int ret;
+
+	if (rma_op == FT_RMA_WRITEDATA) {
+		if (opts.dst_addr) {
+			ret = bw_tx_comp();
+		} else {
+			ret = bw_rx_comp();
+		}
+	} else {
+		ret = ft_get_tx_comp(tx_seq);
+	}
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+int bandwidth_rma(enum ft_rma_opcodes rma_op, struct fi_rma_iov *remote)
+{
+	int ret, i, j;
+
+	ret = ft_sync();
+	if (ret)
+		return ret;
+
+	for (i = j = 0; i < opts.iterations + opts.warmup_iterations; i++) {
+		if (i == opts.warmup_iterations)
+			ft_start();
+
+		switch (rma_op) {
+		case FT_RMA_WRITE:
+			if (opts.transfer_size < fi->tx_attr->inject_size) {
+				ret = ft_post_rma_inject(FT_RMA_WRITE, ep,
+						opts.transfer_size, remote);
+			} else {
+				ret = ft_post_rma(rma_op, ep, opts.transfer_size,
+						remote,	&tx_ctx_arr[j]);
+			}
+			break;
+		case FT_RMA_WRITEDATA:
+			if (!opts.dst_addr) {
+				ret = ft_post_rx(ep, 0, &tx_ctx_arr[j]);
+			} else {
+				if (opts.transfer_size < fi->tx_attr->inject_size) {
+					ret = ft_post_rma_inject(FT_RMA_WRITEDATA,
+							ep,
+							opts.transfer_size,
+							remote);
+				} else {
+					ret = ft_post_rma(FT_RMA_WRITEDATA,
+							ep,
+							opts.transfer_size,
+							remote,	&tx_ctx_arr[j]);
+				}
+			}
+			break;
+		case FT_RMA_READ:
+			ret = ft_post_rma(FT_RMA_READ, ep, opts.transfer_size,
+					remote,	&tx_ctx_arr[j]);
+			break;
+		default:
+			FT_ERR("Unknown RMA op type\n");
+			return EXIT_FAILURE;
+		}
+		if (ret)
+			return ret;
+
+		if (++j == opts.window_size) {
+			ret = bw_rma_comp(rma_op);
 			if (ret)
 				return ret;
+			j = 0;
 		}
 	}
+	ret = bw_rma_comp(rma_op);
+	if (ret)
+		return ret;
 	ft_stop();
 
 	if (opts.machr)
-		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end,
-				opts.window_size, opts.argc, opts.argv);
+		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end,	1,
+				opts.argc, opts.argv);
 	else
-		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end,
-				opts.window_size);
-
+		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 1);
 	return 0;
 }
diff --git a/benchmarks/benchmark_shared.h b/benchmarks/benchmark_shared.h
index dbe1d55..6ce273f 100644
--- a/benchmarks/benchmark_shared.h
+++ b/benchmarks/benchmark_shared.h
@@ -38,15 +38,17 @@
 extern "C" {
 #endif
 
-#include <stdbool.h>
+#include <rdma/fi_rma.h>
 
-#define BENCHMARK_OPTS "vPj:W:"
+#define BENCHMARK_OPTS "vkj:W:"
 #define FT_BENCHMARK_MAX_MSG_SIZE (test_size[TEST_CNT - 1].size)
 
 void ft_parse_benchmark_opts(int op, char *optarg);
 void ft_benchmark_usage(void);
-int pingpong();
-int bandwidth();
+int ft_bw_init(void);
+int pingpong(void);
+int bandwidth(void);
+int bandwidth_rma(enum ft_rma_opcodes op, struct fi_rma_iov *remote);
 
 #ifdef __cplusplus
 }
diff --git a/benchmarks/dgram_pingpong.c b/benchmarks/dgram_pingpong.c
index 449c187..d0bdf9f 100644
--- a/benchmarks/dgram_pingpong.c
+++ b/benchmarks/dgram_pingpong.c
@@ -33,62 +33,19 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <arpa/inet.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "benchmark_shared.h"
 
-
-static int common_setup(void)
-{
-	int ret;
-	uint64_t flags = 0;
-	char *node, *service;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret;
 
-	ret = common_setup();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
diff --git a/benchmarks/rdm_tagged_bw.c b/benchmarks/msg_bw.c
similarity index 74%
copy from benchmarks/rdm_tagged_bw.c
copy to benchmarks/msg_bw.c
index 0c4753a..66dbd53 100644
--- a/benchmarks/rdm_tagged_bw.c
+++ b/benchmarks/msg_bw.c
@@ -29,63 +29,32 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include <shared.h>
 #include "benchmark_shared.h"
 
-static int init_fabric(void)
+static int run(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
+	int i, ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
+	if (!opts.dst_addr) {
+		ret = ft_start_server();
+		if (ret)
+			return ret;
+	}
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
 		return ret;
 	}
 
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
+	ret = ft_bw_init();
 	if (ret)
 		return ret;
 
-	return 0;
-}
-
-static int run(void)
-{
-	int i, ret = 0;
-
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
-	if (ret)
-		goto out;
-
 	if (!(opts.options & FT_OPT_SIZE)) {
 		for (i = 0; i < TEST_CNT; i++) {
 			if (!ft_use_size(i, opts.sizes_enabled))
@@ -113,6 +82,7 @@ int main(int argc, char **argv)
 	int op, ret;
 
 	opts = INIT_OPTS;
+	opts.options |= FT_OPT_BW;
 
 	hints = fi_allocinfo();
 	if (!hints)
@@ -127,7 +97,7 @@ int main(int argc, char **argv)
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using tagged messages.");
+			ft_csusage(argv[0], "Bandwidth test for MSG endpoints.");
 			ft_benchmark_usage();
 			return EXIT_FAILURE;
 		}
@@ -136,9 +106,9 @@ int main(int argc, char **argv)
 	if (optind < argc)
 		opts.dst_addr = argv[optind];
 
-	hints->ep_attr->type = FI_EP_RDM;
+	hints->ep_attr->type = FI_EP_MSG;
+	hints->caps = FI_MSG;
 	hints->domain_attr->resource_mgmt = FI_RM_ENABLED;
-	hints->caps = FI_TAGGED;
 	hints->mode = FI_LOCAL_MR;
 
 	ret = run();
diff --git a/benchmarks/msg_pingpong.c b/benchmarks/msg_pingpong.c
index ea814bf..ec68abe 100644
--- a/benchmarks/msg_pingpong.c
+++ b/benchmarks/msg_pingpong.c
@@ -28,147 +28,25 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "benchmark_shared.h"
 
-
-static int server_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
-		return (int) rd;
-	}
-
-	fi = entry.info;
-	if (event != FI_CONNREQ) {
-		fprintf(stderr, "Unexpected CM event %d\n", event);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	ret = fi_domain(fabric, fi, &domain, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_domain", ret);
-		goto err;
-	}
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		 goto err;
-
-	ret = ft_init_ep();
-	if (ret)
-		goto err;
-
-	ret = fi_accept(ep, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_accept", ret);
-		goto err;
-	}
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
-		ret = (int) rd;
-		goto err;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	return 0;
-
-err:
-	fi_reject(pep, fi->handle, NULL, 0);
-	return ret;
-}
-
-static int client_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_connect", ret);
-		return ret;
-	}
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
-		ret = (int) rd;
-		return ret;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		return ret;
-	}
-
-	return 0;
-}
-
 static int run(void)
 {
-	char *node, *service;
-	uint64_t flags;
 	int i, ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
 	if (!opts.dst_addr) {
 		ret = ft_start_server();
 		if (ret)
 			return ret;
 	}
 
-	ret = opts.dst_addr ? client_connect() : server_connect();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret) {
 		return ret;
 	}
diff --git a/benchmarks/rdm_cntr_pingpong.c b/benchmarks/rdm_cntr_pingpong.c
index cf65f34..d789904 100644
--- a/benchmarks/rdm_cntr_pingpong.c
+++ b/benchmarks/rdm_cntr_pingpong.c
@@ -29,64 +29,21 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include <shared.h>
 #include "benchmark_shared.h"
 
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret = 0;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
-	if (ret)
-		goto out;
-
 	if (!(opts.options & FT_OPT_SIZE)) {
 		for (i = 0; i < TEST_CNT; i++) {
 			if (!ft_use_size(i, opts.sizes_enabled))
diff --git a/benchmarks/rdm_pingpong.c b/benchmarks/rdm_pingpong.c
index 1556ebd..e5c3c50 100644
--- a/benchmarks/rdm_pingpong.c
+++ b/benchmarks/rdm_pingpong.c
@@ -29,61 +29,18 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "benchmark_shared.h"
 
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret = 0;
 
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
diff --git a/benchmarks/rdm_tagged_bw.c b/benchmarks/rdm_tagged_bw.c
index 0c4753a..f4b232e 100644
--- a/benchmarks/rdm_tagged_bw.c
+++ b/benchmarks/rdm_tagged_bw.c
@@ -29,62 +29,24 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include <shared.h>
 #include "benchmark_shared.h"
 
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret = 0;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
+	ret = ft_bw_init();
 	if (ret)
-		goto out;
+		return ret;
 
 	if (!(opts.options & FT_OPT_SIZE)) {
 		for (i = 0; i < TEST_CNT; i++) {
@@ -113,6 +75,7 @@ int main(int argc, char **argv)
 	int op, ret;
 
 	opts = INIT_OPTS;
+	opts.options |= FT_OPT_BW;
 
 	hints = fi_allocinfo();
 	if (!hints)
@@ -127,7 +90,7 @@ int main(int argc, char **argv)
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using tagged messages.");
+			ft_csusage(argv[0], "Bandwidth test for RDM endpoints using tagged messages.");
 			ft_benchmark_usage();
 			return EXIT_FAILURE;
 		}
@@ -139,7 +102,7 @@ int main(int argc, char **argv)
 	hints->ep_attr->type = FI_EP_RDM;
 	hints->domain_attr->resource_mgmt = FI_RM_ENABLED;
 	hints->caps = FI_TAGGED;
-	hints->mode = FI_LOCAL_MR;
+	hints->mode = FI_LOCAL_MR | FI_CONTEXT;
 
 	ret = run();
 
diff --git a/benchmarks/rdm_tagged_pingpong.c b/benchmarks/rdm_tagged_pingpong.c
index df105e5..c77c35d 100644
--- a/benchmarks/rdm_tagged_pingpong.c
+++ b/benchmarks/rdm_tagged_pingpong.c
@@ -29,62 +29,18 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
-#include <rdma/fi_tagged.h>
 
 #include <shared.h>
 #include "benchmark_shared.h"
 
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret = 0;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
@@ -140,7 +96,7 @@ int main(int argc, char **argv)
 
 	hints->ep_attr->type = FI_EP_RDM;
 	hints->caps = FI_TAGGED;
-	hints->mode = FI_LOCAL_MR;
+	hints->mode = FI_LOCAL_MR | FI_CONTEXT;
 
 	ret = run();
 
diff --git a/benchmarks/rdm_tagged_bw.c b/benchmarks/rma_bw.c
similarity index 70%
copy from benchmarks/rdm_tagged_bw.c
copy to benchmarks/rma_bw.c
index 0c4753a..ddef90a 100644
--- a/benchmarks/rdm_tagged_bw.c
+++ b/benchmarks/rma_bw.c
@@ -29,76 +29,54 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include <shared.h>
 #include "benchmark_shared.h"
 
-static int init_fabric(void)
+static struct fi_rma_iov remote;
+
+static int run(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
+	int i, ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
+	if (hints->ep_attr->type == FI_EP_MSG) {
+		if (!opts.dst_addr) {
+			ret = ft_start_server();
+			if (ret)
+				return ret;
+		}
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
+		ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
+	} else {
+		ret = ft_init_fabric();
 	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
 	if (ret)
 		return ret;
 
-	ret = ft_init_ep();
+	ret = ft_bw_init();
 	if (ret)
 		return ret;
 
-	return 0;
-}
-
-static int run(void)
-{
-	int i, ret = 0;
-
-	ret = init_fabric();
+	ret = ft_exchange_keys(&remote);
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
-	if (ret)
-		goto out;
-
 	if (!(opts.options & FT_OPT_SIZE)) {
 		for (i = 0; i < TEST_CNT; i++) {
 			if (!ft_use_size(i, opts.sizes_enabled))
 				continue;
 			opts.transfer_size = test_size[i].size;
 			init_test(&opts, test_name, sizeof(test_name));
-			ret = bandwidth();
+			ret = bandwidth_rma(opts.rma_op, &remote);
 			if (ret)
 				goto out;
 		}
 	} else {
 		init_test(&opts, test_name, sizeof(test_name));
-		ret = bandwidth();
+		ret = bandwidth_rma(opts.rma_op, &remote);
 		if (ret)
 			goto out;
 	}
@@ -113,22 +91,31 @@ int main(int argc, char **argv)
 	int op, ret;
 
 	opts = INIT_OPTS;
+	opts.options |= FT_OPT_BW;
 
 	hints = fi_allocinfo();
 	if (!hints)
 		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "h" CS_OPTS INFO_OPTS BENCHMARK_OPTS)) != -1) {
+	while ((op = getopt(argc, argv, "ho:" CS_OPTS INFO_OPTS BENCHMARK_OPTS)) != -1) {
 		switch (op) {
 		default:
 			ft_parse_benchmark_opts(op, optarg);
 			ft_parseinfo(op, optarg, hints);
 			ft_parsecsopts(op, optarg, &opts);
+			ret = ft_parse_rma_opts(op, optarg, &opts);
+			if (ret)
+				return ret;
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using tagged messages.");
+			ft_csusage(argv[0], "Bandwidth test using RMA operations.");
 			ft_benchmark_usage();
+			FT_PRINT_OPTS_USAGE("-o <op>", "rma op type: read|write|"
+					"writedata (default: write)\n");
+			fprintf(stderr, "Note: read/write bw tests are bidirectional.\n"
+					"      writedata bw test is unidirectional"
+					" from the client side.\n");
 			return EXIT_FAILURE;
 		}
 	}
@@ -136,10 +123,9 @@ int main(int argc, char **argv)
 	if (optind < argc)
 		opts.dst_addr = argv[optind];
 
-	hints->ep_attr->type = FI_EP_RDM;
+	hints->caps = FI_MSG | FI_RMA;
 	hints->domain_attr->resource_mgmt = FI_RM_ENABLED;
-	hints->caps = FI_TAGGED;
-	hints->mode = FI_LOCAL_MR;
+	hints->mode = FI_LOCAL_MR | FI_RX_CQ_DATA;
 
 	ret = run();
 
diff --git a/common/osx/osd.c b/common/osx/osd.c
index 705bca3..009c06a 100644
--- a/common/osx/osd.c
+++ b/common/osx/osd.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2016, Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2015 Los Alamos Nat. Security, LLC. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -31,11 +32,14 @@
  */
 
 #include "osx/osd.h"
+#include "config.h"
 
-// clock_gettime() does not exist on OS X.  Instead, simply use
-// gettimeofday(), which is apparently fairly efficient on OS X (i.e.,
-// ignore the clk_id that is passed in and always return the system
-// clock time).
+/* clock_gettime() does not exist on OS X before the mac OS Sierra release. If
+ * the symbol is not already defined, then define a workaround using
+ * gettimeofday. Ignore the clk_id that is passed in and always return the
+ * system clock time.
+ */
+#if !HAVE_CLOCK_GETTIME
 int clock_gettime(clockid_t clk_id, struct timespec *tp) {
 	int retval;
 	struct timeval tv;
@@ -47,3 +51,4 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp) {
 
 	return retval;
 }
+#endif
diff --git a/common/shared.c b/common/shared.c
index 3cc26cd..eedeada 100644
--- a/common/shared.c
+++ b/common/shared.c
@@ -52,7 +52,7 @@ struct fid_wait *waitset;
 struct fid_domain *domain;
 struct fid_poll *pollset;
 struct fid_pep *pep;
-struct fid_ep *ep;
+struct fid_ep *ep, *alias_ep;
 struct fid_cq *txcq, *rxcq;
 struct fid_cntr *txcntr, *rxcntr;
 struct fid_mr *mr;
@@ -61,6 +61,8 @@ struct fid_eq *eq;
 
 struct fid_mr no_mr;
 struct fi_context tx_ctx, rx_ctx;
+struct fi_context *tx_ctx_arr = NULL, *rx_ctx_arr = NULL;
+uint64_t remote_cq_data = 0;
 
 uint64_t tx_seq, rx_seq, tx_cq_cntr, rx_cq_cntr;
 int ft_skip_mr = 0;
@@ -69,7 +71,7 @@ pid_t ft_child_pid = 0;
 int ft_socket_pair[2];
 
 fi_addr_t remote_fi_addr = FI_ADDR_UNSPEC;
-void *buf, *tx_buf, *rx_buf;
+char *buf, *tx_buf, *rx_buf;
 size_t buf_size, tx_size, rx_size;
 int rx_fd = -1, tx_fd = -1;
 char default_port[8] = "9228";
@@ -78,6 +80,9 @@ char test_name[50] = "custom";
 int timeout = -1;
 struct timespec start, end;
 
+int listen_sock = -1;
+int sock = -1;
+
 struct fi_av_attr av_attr = {
 	.type = FI_AV_MAP,
 	.count = 1
@@ -255,7 +260,8 @@ int ft_alloc_msgs(void)
 			return -errno;
 		buf_size += alignment;
 
-		ret = posix_memalign(&buf, (size_t) alignment, buf_size);
+		ret = posix_memalign((void **) &buf, (size_t) alignment,
+				buf_size);
 		if (ret) {
 			FT_PRINTERR("posix_memalign", ret);
 			return ret;
@@ -273,6 +279,8 @@ int ft_alloc_msgs(void)
 	tx_buf = (void *) (((uintptr_t) tx_buf + alignment - 1) &
 			   ~(alignment - 1));
 
+	remote_cq_data = ft_init_cq_data(fi);
+
 	if (!ft_skip_mr && ((fi->mode & FI_LOCAL_MR) ||
 				(fi->caps & (FI_RMA | FI_ATOMIC)))) {
 		ret = fi_mr_reg(domain, buf, buf_size, ft_caps_to_mr_access(fi->caps),
@@ -313,10 +321,16 @@ int ft_open_fabric_res(void)
 	return 0;
 }
 
-int ft_alloc_active_res(struct fi_info *fi)
+int ft_alloc_ep_res(struct fi_info *fi)
 {
 	int ret;
 
+	if (hints->caps & FI_RMA) {
+		ret = ft_set_rma_caps(fi, opts.rma_op);
+		if (ret)
+			return ret;
+	}
+
 	ret = ft_alloc_msgs();
 	if (ret)
 		return ret;
@@ -379,6 +393,16 @@ int ft_alloc_active_res(struct fi_info *fi)
 			return ret;
 		}
 	}
+	return 0;
+}
+
+int ft_alloc_active_res(struct fi_info *fi)
+{
+	int ret;
+
+	ret = ft_alloc_ep_res(fi);
+	if (ret)
+		return ret;
 
 	ret = fi_endpoint(domain, fi, &ep, NULL);
 	if (ret) {
@@ -389,16 +413,55 @@ int ft_alloc_active_res(struct fi_info *fi)
 	return 0;
 }
 
-int ft_start_server(void)
+int ft_set_rma_caps(struct fi_info *fi, enum ft_rma_opcodes rma_op)
+{
+	switch (rma_op) {
+	case FT_RMA_READ:
+		fi->caps |= FI_REMOTE_READ;
+		if (fi->mode & FI_LOCAL_MR)
+			fi->caps |= FI_READ;
+		break;
+	case FT_RMA_WRITE:
+	case FT_RMA_WRITEDATA:
+		fi->caps |= FI_REMOTE_WRITE;
+		if (fi->mode & FI_LOCAL_MR)
+			fi->caps |= FI_WRITE;
+		break;
+	default:
+		FT_ERR("Invalid rma op type\n");
+		return -FI_EINVAL;
+	}
+	return 0;
+}
+
+int ft_getinfo(struct fi_info *hints, struct fi_info **info)
 {
+	char *node, *service;
+	uint64_t flags = 0;
 	int ret;
 
-	ret = fi_getinfo(FT_FIVERSION, opts.src_addr, opts.src_port, FI_SOURCE,
-			 hints, &fi_pep);
+	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	if (ret)
+		return ret;
+
+	if (!hints->ep_attr->type)
+		hints->ep_attr->type = FI_EP_RDM;
+
+	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, info);
 	if (ret) {
 		FT_PRINTERR("fi_getinfo", ret);
 		return ret;
 	}
+	return 0;
+}
+
+int ft_start_server(void)
+{
+	int ret;
+
+	ret = ft_getinfo(hints, &fi_pep);
+	if (ret)
+		return ret;
 
 	ret = fi_fabric(fi_pep->fabric_attr, &fabric, NULL);
 	if (ret) {
@@ -433,17 +496,145 @@ int ft_start_server(void)
 	return 0;
 }
 
-#define FT_EP_BIND(ep, fd, flags)					\
-	do {								\
-		int ret;						\
-		if ((fd)) {						\
-			ret = fi_ep_bind((ep), &(fd)->fid, (flags));	\
-			if (ret) {					\
-				FT_PRINTERR("fi_ep_bind", ret);		\
-				return ret;				\
-			}						\
-		}							\
-	} while (0)
+int ft_server_connect(void)
+{
+	struct fi_eq_cm_entry entry;
+	uint32_t event;
+	ssize_t rd;
+	int ret;
+
+	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
+	if (rd != sizeof entry) {
+		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
+		return (int) rd;
+	}
+
+	fi = entry.info;
+	if (event != FI_CONNREQ) {
+		fprintf(stderr, "Unexpected CM event %d\n", event);
+		ret = -FI_EOTHER;
+		goto err;
+	}
+
+	ret = fi_domain(fabric, fi, &domain, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_domain", ret);
+		goto err;
+	}
+
+	ret = ft_alloc_active_res(fi);
+	if (ret)
+		goto err;
+
+	ret = ft_init_ep();
+	if (ret)
+		goto err;
+
+	ret = fi_accept(ep, NULL, 0);
+	if (ret) {
+		FT_PRINTERR("fi_accept", ret);
+		goto err;
+	}
+
+	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
+	if (rd != sizeof entry) {
+		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
+		ret = (int) rd;
+		goto err;
+	}
+
+	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
+		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
+			event, entry.fid, ep);
+		ret = -FI_EOTHER;
+		goto err;
+	}
+
+	return 0;
+
+err:
+	fi_reject(pep, fi->handle, NULL, 0);
+	return ret;
+}
+
+int ft_client_connect(void)
+{
+	struct fi_eq_cm_entry entry;
+	uint32_t event;
+	ssize_t rd;
+	int ret;
+
+	ret = ft_getinfo(hints, &fi);
+	if (ret)
+		return ret;
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		return ret;
+
+	ret = ft_alloc_active_res(fi);
+	if (ret)
+		return ret;
+
+	ret = ft_init_ep();
+	if (ret)
+		return ret;
+
+	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
+	if (ret) {
+		FT_PRINTERR("fi_connect", ret);
+		return ret;
+	}
+
+	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
+	if (rd != sizeof entry) {
+		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
+		ret = (int) rd;
+		return ret;
+	}
+
+	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
+		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
+			event, entry.fid, ep);
+		ret = -FI_EOTHER;
+		return ret;
+	}
+
+	return 0;
+}
+
+int ft_init_fabric(void)
+{
+	int ret;
+
+	ret = ft_getinfo(hints, &fi);
+	if (ret)
+		return ret;
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		return ret;
+
+	if (hints->caps & FI_RMA) {
+		ret = ft_set_rma_caps(fi, opts.rma_op);
+		if (ret)
+			return ret;
+	}
+
+	ret = ft_alloc_active_res(fi);
+	if (ret)
+		return ret;
+
+	ret = ft_init_ep();
+	if (ret)
+		return ret;
+
+	ret = ft_init_av();
+	if (ret)
+		return ret;
+
+	return 0;
+}
 
 int ft_get_cq_fd(struct fid_cq *cq, int *fd)
 {
@@ -458,6 +649,17 @@ int ft_get_cq_fd(struct fid_cq *cq, int *fd)
 	return ret;
 }
 
+int ft_init_alias_ep(uint64_t flags)
+{
+	int ret;
+	ret = fi_ep_alias(ep, &alias_ep, flags);
+	if (ret) {
+		FT_PRINTERR("fi_ep_alias", ret);
+		return ret;
+	}
+	return 0;
+}
+
 int ft_init_ep(void)
 {
 	int flags, ret;
@@ -498,7 +700,7 @@ int ft_init_ep(void)
 
 	if (fi->rx_attr->op_flags != FI_MULTI_RECV) {
 		/* Initial receive will get remote address for unconnected EPs */
-		ret = ft_post_rx(MAX(rx_size, FT_MAX_CTRL_MSG));
+		ret = ft_post_rx(ep, MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
 		if (ret)
 			return ret;
 	}
@@ -543,13 +745,13 @@ int ft_init_av(void)
 			return ret;
 		}
 
-		ret = (int) ft_tx(addrlen);
+		ret = (int) ft_tx(ep, remote_fi_addr, addrlen, &tx_ctx);
 		if (ret)
 			return ret;
 
-		ret = ft_rx(1);
+		ret = ft_rx(ep, 1);
 	} else {
-		ret = (int) ft_rx(FT_MAX_CTRL_MSG);
+		ret = (int) ft_rx(ep, FT_MAX_CTRL_MSG);
 		if (ret)
 			return ret;
 
@@ -558,7 +760,7 @@ int ft_init_av(void)
 		if (ret)
 			return ret;
 
-		ret = (int) ft_tx(1);
+		ret = (int) ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
 	}
 
 	return ret;
@@ -570,11 +772,11 @@ int ft_exchange_keys(struct fi_rma_iov *peer_iov)
 	int ret;
 
 	if (opts.dst_addr) {
-		rma_iov = tx_buf + ft_tx_prefix_size();
+		rma_iov = (struct fi_rma_iov *) (tx_buf + ft_tx_prefix_size());
 		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
 				0 : (uintptr_t) rx_buf + ft_rx_prefix_size();
 		rma_iov->key = fi_mr_key(mr);
-		ret = ft_tx(sizeof *rma_iov);
+		ret = ft_tx(ep, remote_fi_addr, sizeof *rma_iov, &tx_ctx);
 		if (ret)
 			return ret;
 
@@ -582,25 +784,25 @@ int ft_exchange_keys(struct fi_rma_iov *peer_iov)
 		if (ret)
 			return ret;
 
-		rma_iov = rx_buf + ft_rx_prefix_size();
+		rma_iov = (struct fi_rma_iov *) (rx_buf + ft_rx_prefix_size());
 		*peer_iov = *rma_iov;
-		ret = ft_post_rx(rx_size);
+		ret = ft_post_rx(ep, rx_size, &rx_ctx);
 	} else {
 		ret = ft_get_rx_comp(rx_seq);
 		if (ret)
 			return ret;
 
-		rma_iov = rx_buf + ft_rx_prefix_size();
+		rma_iov = (struct fi_rma_iov *) (rx_buf + ft_rx_prefix_size());
 		*peer_iov = *rma_iov;
-		ret = ft_post_rx(rx_size);
+		ret = ft_post_rx(ep, rx_size, &rx_ctx);
 		if (ret)
 			return ret;
 
-		rma_iov = tx_buf + ft_tx_prefix_size();
+		rma_iov = (struct fi_rma_iov *) (tx_buf + ft_tx_prefix_size());
 		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
 				0 : (uintptr_t) rx_buf + ft_rx_prefix_size();
 		rma_iov->key = fi_mr_key(mr);
-		ret = ft_tx(sizeof *rma_iov);
+		ret = ft_tx(ep, remote_fi_addr, sizeof *rma_iov, &tx_ctx);
 	}
 
 	return ret;
@@ -610,6 +812,7 @@ static void ft_close_fids(void)
 {
 	if (mr != &no_mr)
 		FT_CLOSE_FID(mr);
+	FT_CLOSE_FID(alias_ep);
 	FT_CLOSE_FID(ep);
 	FT_CLOSE_FID(pep);
 	FT_CLOSE_FID(pollset);
@@ -627,6 +830,12 @@ static void ft_close_fids(void)
 void ft_free_res(void)
 {
 	ft_close_fids();
+
+	free(tx_ctx_arr);
+	free(rx_ctx_arr);
+	tx_ctx_arr = NULL;
+	rx_ctx_arr = NULL;
+
 	if (buf) {
 		free(buf);
 		buf = rx_buf = tx_buf = NULL;
@@ -775,11 +984,11 @@ char *cnt_str(char str[FT_STR_LEN], long long cnt)
 int size_to_count(int size)
 {
 	if (size >= (1 << 20))
-		return 100;
+		return (opts.options & FT_OPT_BW) ? 200 : 100;
 	else if (size >= (1 << 16))
-		return 1000;
+		return (opts.options & FT_OPT_BW) ? 2000 : 1000;
 	else
-		return 10000;
+		return (opts.options & FT_OPT_BW) ? 20000: 10000;
 }
 
 void init_test(struct ft_opts *opts, char *test_name, size_t test_name_len)
@@ -793,34 +1002,55 @@ void init_test(struct ft_opts *opts, char *test_name, size_t test_name_len)
 		opts->iterations = size_to_count(opts->transfer_size);
 }
 
-ssize_t ft_post_tx(size_t size)
-{
-	ssize_t ret;
+#define FT_POST(post_fn, comp_fn, seq, op_str, ...)				\
+	do {									\
+		int timeout_save;						\
+		int ret, rc;							\
+										\
+		while (1) {							\
+			ret = post_fn(__VA_ARGS__);				\
+			if (!ret)						\
+				break;						\
+										\
+			if (ret != -FI_EAGAIN) {				\
+				FT_PRINTERR(op_str, ret);			\
+				return ret;					\
+			}							\
+										\
+			timeout_save = timeout;					\
+			timeout = 0;						\
+			rc = comp_fn(seq);					\
+			if (rc && rc != -FI_EAGAIN) {				\
+				FT_ERR("Failed to get " op_str " completion");	\
+				return rc;					\
+			}							\
+			timeout = timeout_save;					\
+		}								\
+		seq++;								\
+	} while (0)
 
+ssize_t ft_post_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size, struct fi_context* ctx)
+{
 	if (hints->caps & FI_TAGGED) {
-		ret = fi_tsend(ep, tx_buf, size + ft_tx_prefix_size(),
-				fi_mr_desc(mr), remote_fi_addr, tx_seq, &tx_ctx);
+		FT_POST(fi_tsend, ft_get_tx_comp, tx_seq, "transmit", ep,
+				tx_buf, size + ft_tx_prefix_size(), fi_mr_desc(mr),
+				fi_addr, tx_seq, ctx);
 	} else {
-		ret = fi_send(ep, tx_buf, size + ft_tx_prefix_size(),
-				fi_mr_desc(mr), remote_fi_addr, &tx_ctx);
-	}
-	if (ret) {
-		FT_PRINTERR("transmit", ret);
-		return ret;
+		FT_POST(fi_send, ft_get_tx_comp, tx_seq, "transmit", ep,
+				tx_buf,	size + ft_tx_prefix_size(), fi_mr_desc(mr),
+				fi_addr, ctx);
 	}
-
-	tx_seq++;
 	return 0;
 }
 
-ssize_t ft_tx(size_t size)
+ssize_t ft_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size, struct fi_context *ctx)
 {
 	ssize_t ret;
 
 	if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE))
 		ft_fill_buf((char *) tx_buf + ft_tx_prefix_size(), size);
 
-	ret = ft_post_tx(size);
+	ret = ft_post_tx(ep, fi_addr, size, ctx);
 	if (ret)
 		return ret;
 
@@ -828,62 +1058,125 @@ ssize_t ft_tx(size_t size)
 	return ret;
 }
 
-ssize_t ft_post_inject(size_t size)
+ssize_t ft_post_inject(struct fid_ep *ep, size_t size)
 {
-	ssize_t ret;
-
 	if (hints->caps & FI_TAGGED) {
-		ret = fi_tinject(ep, tx_buf, size + ft_tx_prefix_size(),
+		FT_POST(fi_tinject, ft_get_tx_comp, tx_seq, "inject",
+				ep, tx_buf, size + ft_tx_prefix_size(),
 				remote_fi_addr, tx_seq);
 	} else {
-		ret = fi_inject(ep, tx_buf, size + ft_tx_prefix_size(),
+		FT_POST(fi_inject, ft_get_tx_comp, tx_seq, "inject",
+				ep, tx_buf, size + ft_tx_prefix_size(),
 				remote_fi_addr);
 	}
-	if (ret) {
-		FT_PRINTERR("transmit", ret);
-		return ret;
-	}
 
-	tx_seq++;
 	tx_cq_cntr++;
 	return 0;
 }
 
-ssize_t ft_inject(size_t size)
+ssize_t ft_inject(struct fid_ep *ep, size_t size)
 {
 	ssize_t ret;
 
 	if (ft_check_opts(FT_OPT_VERIFY_DATA | FT_OPT_ACTIVE))
 		ft_fill_buf((char *) tx_buf + ft_tx_prefix_size(), size);
 
-	ret = ft_post_inject(size);
+	ret = ft_post_inject(ep, size);
 	if (ret)
 		return ret;
 
 	return ret;
 }
 
-ssize_t ft_post_rx(size_t size)
+ssize_t ft_post_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote, void *context)
 {
-	ssize_t ret;
+	switch (op) {
+	case FT_RMA_WRITE:
+		FT_POST(fi_write, ft_get_tx_comp, tx_seq, "fi_write", ep, tx_buf,
+				opts.transfer_size, fi_mr_desc(mr), remote_fi_addr,
+				remote->addr, remote->key, context);
+		break;
+	case FT_RMA_WRITEDATA:
+		FT_POST(fi_writedata, ft_get_tx_comp, tx_seq, "fi_writedata", ep,
+				tx_buf, opts.transfer_size, fi_mr_desc(mr),
+				remote_cq_data,	remote_fi_addr,	remote->addr,
+				remote->key, context);
+		break;
+	case FT_RMA_READ:
+		FT_POST(fi_read, ft_get_tx_comp, tx_seq, "fi_read", ep, rx_buf,
+				opts.transfer_size, fi_mr_desc(mr), remote_fi_addr,
+				remote->addr, remote->key, context);
+		break;
+	default:
+		FT_ERR("Unknown RMA op type\n");
+		return EXIT_FAILURE;
+	}
 
-	if (hints->caps & FI_TAGGED) {
-		ret = fi_trecv(ep, rx_buf, size + ft_rx_prefix_size(), fi_mr_desc(mr),
-				0, rx_seq, 0, &rx_ctx);
-	} else {
-		ret = fi_recv(ep, rx_buf, size + ft_rx_prefix_size(), fi_mr_desc(mr),
-				0, &rx_ctx);
+	return 0;
+}
+
+ssize_t ft_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote, void *context)
+{
+	int ret;
+
+	ret = ft_post_rma(op, ep, size, remote, context);
+	if (ret)
+		return ret;
+
+	if (op == FT_RMA_WRITEDATA) {
+		ret = ft_rx(ep, 0);
+		if (ret)
+			return ret;
 	}
-	if (ret) {
-		FT_PRINTERR("receive", ret);
+
+	ret = ft_get_tx_comp(tx_seq);
+	if (ret)
 		return ret;
+
+	return 0;
+}
+
+ssize_t ft_post_rma_inject(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote)
+{
+	switch (op) {
+	case FT_RMA_WRITE:
+		FT_POST(fi_inject_write, ft_get_tx_comp, tx_seq, "fi_inject_write",
+				ep, tx_buf, opts.transfer_size, remote_fi_addr,
+				remote->addr, remote->key);
+		break;
+	case FT_RMA_WRITEDATA:
+		FT_POST(fi_inject_writedata, ft_get_tx_comp, tx_seq,
+				"fi_inject_writedata", ep, tx_buf, opts.transfer_size,
+				remote_cq_data, remote_fi_addr, remote->addr,
+				remote->key);
+		break;
+	default:
+		FT_ERR("Unknown RMA inject op type\n");
+		return EXIT_FAILURE;
 	}
 
-	rx_seq++;
+	tx_cq_cntr++;
 	return 0;
 }
 
-ssize_t ft_rx(size_t size)
+ssize_t ft_post_rx(struct fid_ep *ep, size_t size, struct fi_context* ctx)
+{
+	if (hints->caps & FI_TAGGED) {
+		FT_POST(fi_trecv, ft_get_rx_comp, rx_seq, "receive", ep, rx_buf,
+				MAX(size, FT_MAX_CTRL_MSG) + ft_rx_prefix_size(),
+				fi_mr_desc(mr), 0, rx_seq, 0, ctx);
+	} else {
+		FT_POST(fi_recv, ft_get_rx_comp, rx_seq, "receive", ep, rx_buf,
+				MAX(size, FT_MAX_CTRL_MSG) + ft_rx_prefix_size(),
+				fi_mr_desc(mr),	0, ctx);
+	}
+	return 0;
+}
+
+ssize_t ft_rx(struct fid_ep *ep, size_t size)
 {
 	ssize_t ret;
 
@@ -898,7 +1191,11 @@ ssize_t ft_rx(size_t size)
 	}
 	/* TODO: verify CQ data, if available */
 
-	ret = ft_post_rx(rx_size);
+	/* Ignore the size arg. Post a buffer large enough to handle all message
+	 * sizes. ft_sync() makes use of ft_rx() and gets called in tests just before
+	 * message size is updated. The recvs posted are always for the next incoming
+	 * message */
+	ret = ft_post_rx(ep, rx_size, &rx_ctx);
 	return ret;
 }
 
@@ -1087,17 +1384,17 @@ int ft_sync()
 	int ret;
 
 	if (opts.dst_addr) {
-		ret = ft_tx(1);
+		ret = ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
 		if (ret)
 			return ret;
 
-		ret = ft_rx(1);
+		ret = ft_rx(ep, 1);
 	} else {
-		ret = ft_rx(1);
+		ret = ft_rx(ep, 1);
 		if (ret)
 			return ret;
 
-		ret = ft_tx(1);
+		ret = ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
 	}
 
 	return ret;
@@ -1189,6 +1486,8 @@ int ft_finalize(void)
 {
 	struct iovec iov;
 	int ret;
+	struct fi_context ctx;
+	void *desc = fi_mr_desc(mr);
 
 	strcpy(tx_buf + ft_tx_prefix_size(), "fin");
 	iov.iov_base = tx_buf;
@@ -1199,10 +1498,12 @@ int ft_finalize(void)
 
 		memset(&tmsg, 0, sizeof tmsg);
 		tmsg.msg_iov = &iov;
+		tmsg.desc = &desc;
 		tmsg.iov_count = 1;
 		tmsg.addr = remote_fi_addr;
 		tmsg.tag = tx_seq;
 		tmsg.ignore = 0;
+		tmsg.context = &ctx;
 
 		ret = fi_tsendmsg(ep, &tmsg, FI_INJECT | FI_TRANSMIT_COMPLETE);
 	} else {
@@ -1210,8 +1511,10 @@ int ft_finalize(void)
 
 		memset(&msg, 0, sizeof msg);
 		msg.msg_iov = &iov;
+		msg.desc = &desc;
 		msg.iov_count = 1;
 		msg.addr = remote_fi_addr;
+		msg.context = &ctx;
 
 		ret = fi_sendmsg(ep, &msg, FI_INJECT | FI_TRANSMIT_COMPLETE);
 	}
@@ -1315,6 +1618,13 @@ void show_perf_mr(int tsize, int iters, struct timespec *start,
 	printf(" }\n");
 }
 
+void ft_addr_usage()
+{
+	FT_PRINT_OPTS_USAGE("-B <src_port>", "non default source port number");
+	FT_PRINT_OPTS_USAGE("-P <dst_port>", "non default destination port number");
+	FT_PRINT_OPTS_USAGE("-s <address>", "source address");
+}
+
 void ft_usage(char *name, char *desc)
 {
 	fprintf(stderr, "Usage:\n");
@@ -1325,11 +1635,13 @@ void ft_usage(char *name, char *desc)
 		fprintf(stderr, "\n%s\n", desc);
 
 	fprintf(stderr, "\nOptions:\n");
-	FT_PRINT_OPTS_USAGE("-n <domain>", "domain name");
-	FT_PRINT_OPTS_USAGE("-b <src_port>", "non default source port number");
-	FT_PRINT_OPTS_USAGE("-p <dst_port>", "non default destination port number");
-	FT_PRINT_OPTS_USAGE("-f <provider>", "specific provider name eg sockets, verbs");
-	FT_PRINT_OPTS_USAGE("-s <address>", "source address");
+	ft_addr_usage();
+	FT_PRINT_OPTS_USAGE("-d <domain>", "domain name");
+	FT_PRINT_OPTS_USAGE("-p <provider>", "specific provider name eg sockets, verbs");
+	FT_PRINT_OPTS_USAGE("-e <ep_type>", "Endpoint type: msg|rdm|dgram (default:rdm)");
+	FT_PRINT_OPTS_USAGE("", "Only the following tests support this option for now:");
+	FT_PRINT_OPTS_USAGE("", "fi_rma_bw");
+	FT_PRINT_OPTS_USAGE("", "fi_shared_ctx");
 	FT_PRINT_OPTS_USAGE("-a <address vector name>", "name of address vector");
 	FT_PRINT_OPTS_USAGE("-h", "display this help output");
 
@@ -1338,19 +1650,7 @@ void ft_usage(char *name, char *desc)
 
 void ft_csusage(char *name, char *desc)
 {
-	fprintf(stderr, "Usage:\n");
-	fprintf(stderr, "  %s [OPTIONS]\t\tstart server\n", name);
-	fprintf(stderr, "  %s [OPTIONS] <host>\tconnect to server\n", name);
-
-	if (desc)
-		fprintf(stderr, "\n%s\n", desc);
-
-	fprintf(stderr, "\nOptions:\n");
-	FT_PRINT_OPTS_USAGE("-n <domain>", "domain name");
-	FT_PRINT_OPTS_USAGE("-b <src_port>", "non default source port number");
-	FT_PRINT_OPTS_USAGE("-p <dst_port>", "non default destination port number");
-	FT_PRINT_OPTS_USAGE("-f <provider>", "specific provider name eg sockets, verbs");
-	FT_PRINT_OPTS_USAGE("-s <address>", "source address");
+	ft_usage(name, desc);
 	FT_PRINT_OPTS_USAGE("-I <number>", "number of iterations");
 	FT_PRINT_OPTS_USAGE("-w <number>", "number of warmup iterations");
 	FT_PRINT_OPTS_USAGE("-S <size>", "specific transfer size or 'all'");
@@ -1366,7 +1666,17 @@ void ft_csusage(char *name, char *desc)
 void ft_parseinfo(int op, char *optarg, struct fi_info *hints)
 {
 	switch (op) {
-	case 'n':
+	case 'f':
+		if (!hints->fabric_attr) {
+			hints->fabric_attr = malloc(sizeof *(hints->fabric_attr));
+			if (!hints->fabric_attr) {
+				perror("malloc");
+				exit(EXIT_FAILURE);
+			}
+		}
+		hints->fabric_attr->name = strdup(optarg);
+		break;
+	case 'd':
 		if (!hints->domain_attr) {
 			hints->domain_attr = malloc(sizeof *(hints->domain_attr));
 			if (!hints->domain_attr) {
@@ -1376,7 +1686,7 @@ void ft_parseinfo(int op, char *optarg, struct fi_info *hints)
 		}
 		hints->domain_attr->name = strdup(optarg);
 		break;
-	case 'f':
+	case 'p':
 		if (!hints->fabric_attr) {
 			hints->fabric_attr = malloc(sizeof *(hints->fabric_attr));
 			if (!hints->fabric_attr) {
@@ -1386,6 +1696,14 @@ void ft_parseinfo(int op, char *optarg, struct fi_info *hints)
 		}
 		hints->fabric_attr->prov_name = strdup(optarg);
 		break;
+	case 'e':
+		if (!strncasecmp("msg", optarg, 3))
+			hints->ep_attr->type = FI_EP_MSG;
+		if (!strncasecmp("rdm", optarg, 3))
+			hints->ep_attr->type = FI_EP_RDM;
+		if (!strncasecmp("dgram", optarg, 5))
+			hints->ep_attr->type = FI_EP_DGRAM;
+		break;
 	default:
 		/* let getopt handle unknown opts*/
 		break;
@@ -1399,10 +1717,10 @@ void ft_parse_addr_opts(int op, char *optarg, struct ft_opts *opts)
 	case 's':
 		opts->src_addr = optarg;
 		break;
-	case 'b':
+	case 'B':
 		opts->src_port = optarg;
 		break;
-	case 'p':
+	case 'P':
 		opts->dst_port = optarg;
 		break;
 	default:
@@ -1458,6 +1776,31 @@ void ft_parsecsopts(int op, char *optarg, struct ft_opts *opts)
 	}
 }
 
+int ft_parse_rma_opts(int op, char *optarg, struct ft_opts *opts)
+{
+	switch (op) {
+	case 'o':
+		if (!strcmp(optarg, "read")) {
+			opts->rma_op = FT_RMA_READ;
+		} else if (!strcmp(optarg, "writedata")) {
+			opts->rma_op = FT_RMA_WRITEDATA;
+			cq_attr.format = FI_CQ_FORMAT_DATA;
+		} else if (!strcmp(optarg, "write")) {
+			opts->rma_op = FT_RMA_WRITE;
+		} else {
+			fprintf(stderr, "Invalid operation type: \"%s\". Usage:\n"
+					"-o <op>\trma op type: read|write|writedata "
+				       "(default:write)\n", optarg);
+			return EXIT_FAILURE;
+		}
+		break;
+	default:
+		/* let getopt handle unknown opts*/
+		break;
+	}
+	return 0;
+}
+
 void ft_fill_buf(void *buf, int size)
 {
 	char *msg_buf;
@@ -1531,7 +1874,7 @@ int check_recv_msg(const char *message)
 	return 0;
 }
 
-int send_recv_greeting(void)
+int send_recv_greeting(struct fid_ep *ep)
 {
 	int ret;
 	const char *message = "Hello from Client!";
@@ -1544,7 +1887,7 @@ int send_recv_greeting(void)
 			return -FI_ETOOSMALL;
 		}
 
-		ret = ft_tx(message_len);
+		ret = ft_tx(ep, remote_fi_addr, message_len, &tx_ctx);
 		if (ret)
 			return ret;
 
@@ -1565,3 +1908,160 @@ int send_recv_greeting(void)
 
 	return 0;
 }
+
+int ft_sock_listen(char *service)
+{
+	struct addrinfo *ai, hints;
+	int val, ret;
+
+	memset(&hints, 0, sizeof hints);
+	hints.ai_flags = AI_PASSIVE;
+	hints.ai_family = AF_INET;
+
+	ret = getaddrinfo(NULL, service, &hints, &ai);
+	if (ret) {
+		fprintf(stderr, "getaddrinfo() %s\n", gai_strerror(ret));
+		return ret;
+	}
+
+	listen_sock = socket(ai->ai_family, SOCK_STREAM, 0);
+	if (listen_sock < 0) {
+		perror("socket");
+		ret = listen_sock;
+		goto out;
+	}
+
+	val = 1;
+	ret = setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
+	if (ret) {
+		perror("setsockopt SO_REUSEADDR");
+		goto out;
+	}
+
+	ret = bind(listen_sock, ai->ai_addr, ai->ai_addrlen);
+	if (ret) {
+		perror("bind");
+		goto out;
+	}
+
+	ret = listen(listen_sock, 0);
+	if (ret)
+		perror("listen");
+
+out:
+	if (ret && listen_sock >= 0)
+		close(listen_sock);
+	freeaddrinfo(ai);
+	return ret;
+}
+
+int ft_sock_connect(char *node, char *service)
+{
+	struct addrinfo *ai;
+	int ret;
+
+	ret = getaddrinfo(node, service, NULL, &ai);
+	if (ret) {
+		perror("getaddrinfo");
+		return ret;
+	}
+
+	sock = socket(ai->ai_family, SOCK_STREAM, 0);
+	if (sock < 0) {
+		perror("socket");
+		ret = sock;
+		goto free;
+	}
+
+	ret = 1;
+	ret = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &ret, sizeof(ret));
+	if (ret)
+		perror("setsockopt");
+
+	ret = connect(sock, ai->ai_addr, ai->ai_addrlen);
+	if (ret) {
+		perror("connect");
+		close(sock);
+	}
+
+free:
+	freeaddrinfo(ai);
+	return ret;
+}
+
+int ft_sock_accept()
+{
+	int ret, op;
+
+	sock = accept(listen_sock, NULL, 0);
+        if (sock < 0) {
+		ret = sock;
+		perror("accept");
+		return ret;
+	}
+
+	op = 1;
+	ret = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+			  (void *) &op, sizeof(op));
+	if (ret)
+		perror("setsockopt");
+
+	return 0;
+}
+
+int ft_sock_send(int fd, void *msg, size_t len)
+{
+	int ret;
+
+	ret = send(fd, msg, len, 0);
+	if (ret == len) {
+		return 0;
+	} else if (ret < 0) {
+		perror("send");
+		return -errno;
+	} else {
+		perror("send aborted");
+		return -FI_ECONNABORTED;
+	}
+}
+
+int ft_sock_recv(int fd, void *msg, size_t len)
+{
+	int ret;
+
+	ret = recv(fd, msg, len, MSG_WAITALL);
+	if (ret == len) {
+		return 0;
+	} else if (ret == 0) {
+		return -FI_ENOTCONN;
+	} else if (ret < 0) {
+		FT_PRINTERR("ft_fw_recv", ret);
+		perror("recv");
+		return -errno;
+	} else {
+		perror("recv aborted");
+		return -FI_ECONNABORTED;
+	}
+}
+
+int ft_sock_sync(int value)
+{
+	int result = -FI_EOTHER;
+
+	if (listen_sock < 0) {
+		ft_sock_send(sock, &value,  sizeof value);
+		ft_sock_recv(sock, &result, sizeof result);
+	} else {
+		ft_sock_recv(sock, &result, sizeof result);
+		ft_sock_send(sock, &value,  sizeof value);
+	}
+
+	return result;
+}
+
+void ft_sock_shutdown(int fd)
+{
+	shutdown(fd, SHUT_RDWR);
+	close(fd);
+}
+
diff --git a/complex/fabtest.h b/complex/fabtest.h
index 2ea2a6e..440a569 100644
--- a/complex/fabtest.h
+++ b/complex/fabtest.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under the BSD license below:
  *
@@ -38,7 +39,6 @@
 #include <rdma/fi_endpoint.h>
 #include <rdma/fi_eq.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_prov.h>
 #include <rdma/fi_rma.h>
 #include <rdma/fi_tagged.h>
 #include <shared.h>
diff --git a/complex/ft_comm.c b/complex/ft_comm.c
index 526a41e..038bb97 100644
--- a/complex/ft_comm.c
+++ b/complex/ft_comm.c
@@ -98,11 +98,11 @@ static int ft_load_av(void)
 	}
 
 	msg.len = (uint32_t) len;
-	ret = ft_fw_send(sock, &msg, sizeof msg);
+	ret = ft_sock_send(sock, &msg, sizeof msg);
 	if (ret)
 		return ret;
 
-	ret = ft_fw_recv(sock, &msg, sizeof msg);
+	ret = ft_sock_recv(sock, &msg, sizeof msg);
 	if (ret)
 		return ret;
 
diff --git a/complex/ft_main.c b/complex/ft_main.c
index 0692957..5a49917 100644
--- a/complex/ft_main.c
+++ b/complex/ft_main.c
@@ -33,17 +33,12 @@
 #include <time.h>
 #include <netdb.h>
 #include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
 
 #include <limits.h>
 #include <shared.h>
 
 #include "fabtest.h"
 
-int listen_sock = -1;
-int sock = -1;
 static int persistent = 1;
 
 //static struct timespec start, end;
@@ -137,7 +132,7 @@ static void ft_show_test_info(void)
 	printf(" %s,", fi_tostr(&test_info.ep_type, FI_TYPE_EP_TYPE));
 	printf(" %s,", fi_tostr(&test_info.av_type, FI_TYPE_AV_TYPE));
 	printf(" eq_%s,", ft_wait_obj_str(test_info.eq_wait_obj));
-	printf(" cq_%s,", ft_wait_obj_str(test_info.eq_wait_obj));
+	printf(" cq_%s,", ft_wait_obj_str(test_info.cq_wait_obj));
 	printf(" [%s],", fi_tostr(&test_info.mode, FI_TYPE_MODE));
 	printf(" [%s]]\n", fi_tostr(&test_info.caps, FI_TYPE_CAPS));
 }
@@ -156,126 +151,6 @@ static int ft_check_info(struct fi_info *hints, struct fi_info *info)
 	return 0;
 }
 
-static int ft_fw_listen(char *service)
-{
-	struct addrinfo *ai, hints;
-	int val, ret;
-
-	memset(&hints, 0, sizeof hints);
-	hints.ai_flags = AI_PASSIVE;
-
-	ret = getaddrinfo(NULL, service, &hints, &ai);
-	if (ret) {
-		fprintf(stderr, "getaddrinfo() %s\n", gai_strerror(ret));
-		return ret;
-	}
-
-	listen_sock = socket(ai->ai_family, SOCK_STREAM, 0);
-	if (listen_sock < 0) {
-		perror("socket");
-		ret = listen_sock;
-		goto out;
-	}
-
-	val = 1;
-	ret = setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
-	if (ret) {
-		perror("setsockopt SO_REUSEADDR");
-		goto out;
-	}
-
-	ret = bind(listen_sock, ai->ai_addr, ai->ai_addrlen);
-	if (ret) {
-		perror("bind");
-		goto out;
-	}
-
-	ret = listen(listen_sock, 0);
-	if (ret)
-		perror("listen");
-
-out:
-	if (ret && listen_sock >= 0)
-		close(listen_sock);
-	freeaddrinfo(ai);
-	return ret;
-}
-
-static int ft_fw_connect(char *node, char *service)
-{
-	struct addrinfo *ai;
-	int ret;
-
-	ret = getaddrinfo(node, service, NULL, &ai);
-	if (ret) {
-		perror("getaddrinfo");
-		return ret;
-	}
-
-	sock = socket(ai->ai_family, SOCK_STREAM, 0);
-	if (sock < 0) {
-		perror("socket");
-		ret = sock;
-		goto free;
-	}
-
-	ret = 1;
-	ret = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *) &ret, sizeof(ret));
-	if (ret)
-		perror("setsockopt");
-
-	ret = connect(sock, ai->ai_addr, ai->ai_addrlen);
-	if (ret) {
-		perror("connect");
-		close(sock);
-	}
-
-free:
-	freeaddrinfo(ai);
-	return ret;
-}
-
-static void ft_fw_shutdown(int fd)
-{
-	shutdown(fd, SHUT_RDWR);
-	close(fd);
-}
-
-int ft_fw_send(int fd, void *msg, size_t len)
-{
-	int ret;
-
-	ret = send(fd, msg, len, 0);
-	if (ret == len) {
-		return 0;
-	} else if (ret < 0) {
-		perror("send");
-		return -errno;
-	} else {
-		perror("send aborted");
-		return -FI_ECONNABORTED;
-	}
-}
-
-int ft_fw_recv(int fd, void *msg, size_t len)
-{
-	int ret;
-
-	ret = recv(fd, msg, len, MSG_WAITALL);
-	if (ret == len) {
-		return 0;
-	} else if (ret == 0) {
-		return -FI_ENOTCONN;
-	} else if (ret < 0) {
-		FT_PRINTERR("ft_fw_recv", ret);
-		perror("recv");
-		return -errno;
-	} else {
-		perror("recv aborted");
-		return -FI_ECONNABORTED;
-	}
-}
-
 static void ft_fw_convert_info(struct fi_info *info, struct ft_info *test_info)
 {
 	info->caps = test_info->caps;
@@ -340,7 +215,7 @@ static int ft_fw_server(void)
 
 
 	do {
-		ret = ft_fw_recv(sock, &test_info, sizeof test_info);
+		ret = ft_sock_recv(sock, &test_info, sizeof test_info);
 		if (ret) {
 			if (ret == -FI_ENOTCONN)
 				ret = 0;
@@ -393,9 +268,9 @@ static int ft_fw_server(void)
 		printf("Ending test %d-%d, result: %s\n", test_info.test_index,
 			test_info.test_subindex, fi_strerror(-ret));
 		results[ft_fw_result_index(-ret)]++;
-		ret = ft_fw_send(sock, &ret, sizeof ret);
+		ret = ft_sock_send(sock, &ret, sizeof ret);
 		if (ret)
-			FT_PRINTERR("ft_fw_send", ret);
+			FT_PRINTERR("ft_sock_send", ret);
 	} while (!ret);
 
 	return ret;
@@ -415,21 +290,21 @@ static int ft_fw_process_list(struct fi_info *hints, struct fi_info *info)
 			return ret;
 
 		ft_fw_update_info(&test_info, fabric_info, subindex);
-		ret = ft_fw_send(sock, &test_info, sizeof test_info);
+		ret = ft_sock_send(sock, &test_info, sizeof test_info);
 		if (ret) {
-			FT_PRINTERR("ft_fw_send", ret);
+			FT_PRINTERR("ft_sock_send", ret);
 			return ret;
 		}
 
 		result = ft_run_test();
 
-		ret = ft_fw_recv(sock, &sresult, sizeof sresult);
+		ret = ft_sock_recv(sock, &sresult, sizeof sresult);
 		if (result) {
 			FT_PRINTERR("ft_run_test", result);
 			return result;
 		}
 		else if (ret) {
-			FT_PRINTERR("ft_fw_recv", ret);
+			FT_PRINTERR("ft_sock_recv", ret);
 			return ret;
 		}
 		else if (sresult)
@@ -505,13 +380,13 @@ static void ft_fw_usage(char *program)
 	FT_PRINT_OPTS_USAGE("-x", "exit after test run");
 	fprintf(stderr, "\nClient only options:\n");
 	FT_PRINT_OPTS_USAGE("-u <test_config_file>", "config file path (Either config file path or both provider and test config name are required)");
-	FT_PRINT_OPTS_USAGE("-f <provider_name>", " provider name");
+	FT_PRINT_OPTS_USAGE("-p <provider_name>", " provider name");
 	FT_PRINT_OPTS_USAGE("-t <test_config_name>", "test config name");
 	FT_PRINT_OPTS_USAGE("-y <start_test_index>", "");
 	FT_PRINT_OPTS_USAGE("-z <end_test_index>", "");
 	FT_PRINT_OPTS_USAGE("-s <address>", "source address");
-	FT_PRINT_OPTS_USAGE("-b <src_port>", "non default source port number");
-	FT_PRINT_OPTS_USAGE("-p <dst_port>", "non default destination port number"
+	FT_PRINT_OPTS_USAGE("-B <src_port>", "non default source port number");
+	FT_PRINT_OPTS_USAGE("-P <dst_port>", "non default destination port number"
 		       " (config file service parameter will override this)");
 }
 
@@ -531,12 +406,12 @@ int main(int argc, char **argv)
 	opts = INIT_OPTS;
 	int ret, op;
 
-	while ((op = getopt(argc, argv, "f:u:t:q:xy:z:h" ADDR_OPTS)) != -1) {
+	while ((op = getopt(argc, argv, "p:u:t:q:xy:z:h" ADDR_OPTS)) != -1) {
 		switch (op) {
 		case 'u':
 			filename = strdup(optarg);
 			break;
-		case 'f':
+		case 'p':
 			provname = strdup(optarg);
 			break;
 		case 't':
@@ -600,37 +475,28 @@ int main(int argc, char **argv)
 			exit(1);
 		}
 
-		ret = ft_fw_connect(opts.dst_addr, service);
+		ret = ft_sock_connect(opts.dst_addr, service);
 		if (ret)
 			goto out;
 
 		ret = ft_fw_client();
 		if (ret)
 			FT_PRINTERR("ft_fw_client", ret);
-		ft_fw_shutdown(sock);
+		ft_sock_shutdown(sock);
 	} else {
-		ret = ft_fw_listen(service);
+		ret = ft_sock_listen(service);
 		if (ret)
 			goto out;
 
 		do {
-			sock = accept(listen_sock, NULL, 0);
-			if (sock < 0) {
-				ret = sock;
-				perror("accept");
-				goto out;
-			}
-
-			op = 1;
-			ret = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
-					 (void *) &op, sizeof(op));
+			ret = ft_sock_accept();
 			if (ret)
-				perror("setsockopt");
+				goto out;
 
 			ret = ft_fw_server();
 			if (ret)
 				FT_PRINTERR("ft_fw_server", ret);
-			ft_fw_shutdown(sock);
+			ft_sock_shutdown(sock);
 		} while (persistent);
 	}
 
diff --git a/complex/ft_test.c b/complex/ft_test.c
index c7d713f..c5b6b53 100644
--- a/complex/ft_test.c
+++ b/complex/ft_test.c
@@ -29,12 +29,10 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <time.h>
 #include <stdlib.h>
 
 #include "fabtest.h"
 
-
 void ft_record_error(int error)
 {
 	if (!ft_ctrl.error) {
@@ -247,21 +245,6 @@ void ft_next_iov_cnt(struct ft_xcontrol *ctrl, size_t max_iov_cnt)
 		ctrl->iov_iter = 0;
 }
 
-static int ft_fw_sync(int value)
-{
-	int result = -FI_EOTHER;
-
-	if (listen_sock < 0) {
-		ft_fw_send(sock, &value,  sizeof value);
-		ft_fw_recv(sock, &result, sizeof result);
-	} else {
-		ft_fw_recv(sock, &result, sizeof result);
-		ft_fw_send(sock, &value,  sizeof value);
-	}
-
-	return result;
-}
-
 static int ft_sync_test(int value)
 {
 	int ret;
@@ -270,7 +253,7 @@ static int ft_sync_test(int value)
 	if (ret)
 		return ret;
 
-	return ft_fw_sync(value);
+	return ft_sock_sync(value);
 }
 
 static int ft_pingpong(void)
@@ -542,7 +525,7 @@ int ft_run_test()
 		}
 	}
 
-	ft_fw_sync(0);
+	ft_sock_sync(0);
 
 	ret = ft_enable_comm();
 	if (ret) {
diff --git a/config.h.in b/config.h.in
index c4e110f..ffe63be 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,11 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* defined to 1 if configured with --enable-debug */
+#undef ENABLE_DEBUG
+
+/* Define to 1 if clock_gettime is available. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
@@ -43,6 +49,9 @@
    */
 #undef LT_OBJDIR
 
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
 /* Name of package */
 #undef PACKAGE
 
diff --git a/config/config.guess b/config/config.guess
index b79252d..120cc0d 100755
--- a/config/config.guess
+++ b/config/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2013-06-10'
+timestamp='2013-05-16'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -995,12 +995,6 @@ EOF
     ppc:Linux:*:*)
 	echo powerpc-unknown-linux-${LIBC}
 	exit ;;
-    ppc64le:Linux:*:*)
-	echo powerpc64le-unknown-linux-${LIBC}
-	exit ;;
-    ppcle:Linux:*:*)
-	echo powerpcle-unknown-linux-${LIBC}
-	exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
 	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 	exit ;;
diff --git a/config/config.sub b/config/config.sub
index 9633db7..8b612ab 100755
--- a/config/config.sub
+++ b/config/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2013-08-10'
+timestamp='2013-04-24'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -257,7 +257,7 @@ case $basic_machine in
 	| avr | avr32 \
 	| be32 | be64 \
 	| bfin \
-	| c4x | c8051 | clipper \
+	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| epiphany \
 	| fido | fr30 | frv \
@@ -372,7 +372,7 @@ case $basic_machine in
 	| be32-* | be64-* \
 	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* \
-	| c8051-* | clipper-* | craynv-* | cydra-* \
+	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -794,7 +794,7 @@ case $basic_machine in
 		os=-mingw64
 		;;
 	mingw32)
-		basic_machine=i686-pc
+		basic_machine=i386-pc
 		os=-mingw32
 		;;
 	mingw32ce)
@@ -830,7 +830,7 @@ case $basic_machine in
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
 	msys)
-		basic_machine=i686-pc
+		basic_machine=i386-pc
 		os=-msys
 		;;
 	mvs)
@@ -1546,9 +1546,6 @@ case $basic_machine in
 	c4x-* | tic4x-*)
 		os=-coff
 		;;
-	c8051-*)
-		os=-elf
-		;;
 	hexagon-*)
 		os=-elf
 		;;
diff --git a/config/libtool.m4 b/config/libtool.m4
index d7c043f..44e0ecf 100644
--- a/config/libtool.m4
+++ b/config/libtool.m4
@@ -1312,7 +1312,7 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -1324,19 +1324,9 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	    LD="${LD-ld} -m elf_i386_fbsd"
 	    ;;
 	  x86_64-*linux*)
-	    case `/usr/bin/file conftest.o` in
-	      *x86-64*)
-		LD="${LD-ld} -m elf32_x86_64"
-		;;
-	      *)
-		LD="${LD-ld} -m elf_i386"
-		;;
-	    esac
-	    ;;
-	  powerpc64le-*)
-	    LD="${LD-ld} -m elf32lppclinux"
+	    LD="${LD-ld} -m elf_i386"
 	    ;;
-	  powerpc64-*)
+	  ppc64-*linux*|powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -1355,10 +1345,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*)
+	  ppc*-*linux*|powerpc*-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -1701,8 +1688,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
     ;;
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+    if test -n "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
@@ -2526,6 +2512,17 @@ freebsd* | dragonfly*)
   esac
   ;;
 
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 haiku*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
@@ -2642,7 +2639,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
@@ -2687,18 +2684,6 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -3258,6 +3243,10 @@ freebsd* | dragonfly*)
   fi
   ;;
 
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
 haiku*)
   lt_cv_deplibs_check_method=pass_all
   ;;
@@ -3296,11 +3285,11 @@ irix5* | irix6* | nonstopux*)
   ;;
 
 # This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
   else
@@ -4048,7 +4037,7 @@ m4_if([$1], [CXX], [
 	    ;;
 	esac
 	;;
-      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
 	case $cc_basename in
 	  KCC*)
 	    # KAI C++ Compiler
@@ -4112,7 +4101,7 @@ m4_if([$1], [CXX], [
 	    ;;
 	esac
 	;;
-      netbsd* | netbsdelf*-gnu)
+      netbsd*)
 	;;
       *qnx* | *nto*)
         # QNX uses GNU C++, but need to define -shared option too, otherwise
@@ -4347,7 +4336,7 @@ m4_if([$1], [CXX], [
       _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
       ;;
 
-    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
       case $cc_basename in
       # old Intel for x86_64 which still supported -KPIC.
       ecc*)
@@ -4589,9 +4578,6 @@ m4_if([$1], [CXX], [
       ;;
     esac
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   *)
     _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
     ;;
@@ -4654,9 +4640,6 @@ dnl Note also adjust exclude_expsyms for C++ above.
   openbsd*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    _LT_TAGVAR(link_all_deplibs, $1)=no
-    ;;
   esac
 
   _LT_TAGVAR(ld_shlibs, $1)=yes
@@ -4878,7 +4861,7 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
@@ -5055,7 +5038,6 @@ _LT_EOF
 	if test "$aix_use_runtimelinking" = yes; then
 	  shared_flag="$shared_flag "'${wl}-G'
 	fi
-	_LT_TAGVAR(link_all_deplibs, $1)=no
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -5360,7 +5342,7 @@ _LT_EOF
       _LT_TAGVAR(link_all_deplibs, $1)=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -6240,6 +6222,9 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(ld_shlibs, $1)=yes
         ;;
 
+      gnu*)
+        ;;
+
       haiku*)
         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         _LT_TAGVAR(link_all_deplibs, $1)=yes
@@ -6401,7 +6386,7 @@ if test "$_lt_caught_CXX_error" != yes; then
         _LT_TAGVAR(inherit_rpath, $1)=yes
         ;;
 
-      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
         case $cc_basename in
           KCC*)
 	    # Kuck and Associates, Inc. (KAI) C++ Compiler
diff --git a/config/ltmain.sh b/config/ltmain.sh
index a356aca..63ae69d 100644
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -70,7 +70,7 @@
 #         compiler:		$LTCC
 #         compiler flags:		$LTCFLAGS
 #         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
+#         $progname:	(GNU libtool) 2.4.2
 #         automake:	$automake_version
 #         autoconf:	$autoconf_version
 #
@@ -80,7 +80,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
+VERSION=2.4.2
 TIMESTAMP=""
 package_revision=1.3337
 
@@ -6124,10 +6124,7 @@ func_mode_link ()
 	case $pass in
 	dlopen) libs="$dlfiles" ;;
 	dlpreopen) libs="$dlprefiles" ;;
-	link)
-	  libs="$deplibs %DEPLIBS%"
-	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
-	  ;;
+	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
 	esac
       fi
       if test "$linkmode,$pass" = "lib,dlpreopen"; then
@@ -6447,19 +6444,19 @@ func_mode_link ()
 	    # It is a libtool convenience library, so add in its objects.
 	    func_append convenience " $ladir/$objdir/$old_library"
 	    func_append old_convenience " $ladir/$objdir/$old_library"
-	    tmp_libs=
-	    for deplib in $dependency_libs; do
-	      deplibs="$deplib $deplibs"
-	      if $opt_preserve_dup_deps ; then
-		case "$tmp_libs " in
-		*" $deplib "*) func_append specialdeplibs " $deplib" ;;
-		esac
-	      fi
-	      func_append tmp_libs " $deplib"
-	    done
 	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
 	    func_fatal_error "\`$lib' is not a convenience library"
 	  fi
+	  tmp_libs=
+	  for deplib in $dependency_libs; do
+	    deplibs="$deplib $deplibs"
+	    if $opt_preserve_dup_deps ; then
+	      case "$tmp_libs " in
+	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+	      esac
+	    fi
+	    func_append tmp_libs " $deplib"
+	  done
 	  continue
 	fi # $pass = conv
 
@@ -7352,9 +7349,6 @@ func_mode_link ()
 	    revision="$number_minor"
 	    lt_irix_increment=no
 	    ;;
-	  *)
-	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
-	    ;;
 	  esac
 	  ;;
 	no)
diff --git a/config/missing b/config/missing
index db98974..cdea514 100755
--- a/config/missing
+++ b/config/missing
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2012-06-26.16; # UTC
 
 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
@@ -160,7 +160,7 @@ give_advice ()
       ;;
    autom4te*)
       echo "You might have modified some maintainer files that require"
-      echo "the 'autom4te' program to be rebuilt."
+      echo "the 'automa4te' program to be rebuilt."
       program_details 'autom4te'
       ;;
     bison*|yacc*)
diff --git a/configure b/configure
index f5cc054..e021be0 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for fabtests 1.3.0.
+# Generated by GNU Autoconf 2.69 for fabtests 1.4.0.
 #
 # Report bugs to <ofiwg at lists.openfabrics.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='fabtests'
 PACKAGE_TARNAME='fabtests'
-PACKAGE_VERSION='1.3.0'
-PACKAGE_STRING='fabtests 1.3.0'
+PACKAGE_VERSION='1.4.0'
+PACKAGE_STRING='fabtests 1.4.0'
 PACKAGE_BUGREPORT='ofiwg at lists.openfabrics.org'
 PACKAGE_URL=''
 
@@ -635,6 +635,8 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+HAVE_CLOCK_GETTIME_FALSE
+HAVE_CLOCK_GETTIME_TRUE
 CPP
 OTOOL64
 OTOOL
@@ -757,6 +759,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_silent_rules
+enable_debug
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1317,7 +1320,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures fabtests 1.3.0 to adapt to many kinds of systems.
+\`configure' configures fabtests 1.4.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1387,7 +1390,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of fabtests 1.3.0:";;
+     short | recursive ) echo "Configuration of fabtests 1.4.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1397,6 +1400,7 @@ Optional Features:
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-silent-rules   less verbose build output (undo: "make V=1")
   --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-debug          Enable debugging - default NO
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
@@ -1494,7 +1498,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-fabtests configure 1.3.0
+fabtests configure 1.4.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1863,7 +1867,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by fabtests $as_me 1.3.0, which was
+It was created by fabtests $as_me 1.4.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2243,7 +2247,7 @@ ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
 
 ac_config_headers="$ac_config_headers config.h"
 
-am__api_version='1.14'
+am__api_version='1.13'
 
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
@@ -2729,7 +2733,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='fabtests'
- VERSION='1.3.0'
+ VERSION='1.4.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2780,47 +2784,6 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
-# POSIX will say in a future version that running "rm -f" with no argument
-# is OK; and we want to be able to make that assumption in our Makefile
-# recipes.  So use an aggressive probe to check that the usage we want is
-# actually supported "in the wild" to an acceptable degree.
-# See automake bug#10828.
-# To make any issue more visible, cause the running configure to be aborted
-# by default if the 'rm' program in use doesn't match our expectations; the
-# user can still override this though.
-if rm -f && rm -fr && rm -rf; then : OK; else
-  cat >&2 <<'END'
-Oops!
-
-Your 'rm' program seems unable to run without file operands specified
-on the command line, even when the '-f' option is present.  This is contrary
-to the behaviour of most rm programs out there, and not conforming with
-the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
-
-Please tell bug-automake at gnu.org about your system, including the value
-of your $PATH and any error possibly output before this message.  This
-can help us improve future automake versions.
-
-END
-  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
-    echo 'Configuration will proceed anyway, since you have set the' >&2
-    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
-    echo >&2
-  else
-    cat >&2 <<'END'
-Aborting the configuration process, to ensure you take notice of the issue.
-
-You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <http://www.gnu.org/software/coreutils/>.
-
-If you want to complete the configuration process using your problematic
-'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
-to "yes", and re-run configure.
-
-END
-    as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
-  fi
-fi
 # Check whether --enable-silent-rules was given.
 if test "${enable_silent_rules+set}" = set; then :
   enableval=$enable_silent_rules;
@@ -2977,8 +2940,25 @@ else
 fi
 
 
+base_c_warn_flags="-Wall -Wundef -Wpointer-arith"
+
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then :
+  enableval=$enable_debug; CFLAGS="-g -O0 ${base_c_warn_flags} -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers $CFLAGS"
+	 dbg=1
+else
+  dbg=0
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define ENABLE_DEBUG $dbg
+_ACEOF
+
+
 if test -z "$CFLAGS"; then :
-  CFLAGS='-O2 -DNDEBUG -Wall'
+  CFLAGS="-O2 -DNDEBUG ${base_c_warn_flags}"
 fi
 
 # AM PROG_AR did not exist pre AM 1.11.x (where x is somewhere >0 and
@@ -3835,65 +3815,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
-$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
-if ${am_cv_prog_cc_c_o+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-  # Make sure it works both with $CC and with simple cc.
-  # Following AC_PROG_CC_C_O, we do the test twice because some
-  # compilers refuse to overwrite an existing .o file with -o,
-  # though they will create one.
-  am_cv_prog_cc_c_o=yes
-  for am_i in 1 2; do
-    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
-   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
-   ac_status=$?
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   (exit $ac_status); } \
-         && test -f conftest2.$ac_objext; then
-      : OK
-    else
-      am_cv_prog_cc_c_o=no
-      break
-    fi
-  done
-  rm -f core conftest*
-  unset am_i
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
-$as_echo "$am_cv_prog_cc_c_o" >&6; }
-if test "$am_cv_prog_cc_c_o" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
 depcc="$CC"   am_compiler_list=
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -4130,13 +4051,7 @@ $as_echo_n "checking the archiver ($AR) interface... " >&6; }
 if ${am_cv_ar_interface+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-   am_cv_ar_interface=ar
+  am_cv_ar_interface=ar
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 int some_variable = 0;
@@ -4167,11 +4082,6 @@ if ac_fn_c_try_compile "$LINENO"; then :
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
@@ -5009,8 +4919,7 @@ else
     ;;
   *)
     lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len" && \
-	test undefined != "$lt_cv_sys_max_cmd_len"; then
+    if test -n "$lt_cv_sys_max_cmd_len"; then
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
       lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
     else
@@ -5411,6 +5320,10 @@ freebsd* | dragonfly*)
   fi
   ;;
 
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
 haiku*)
   lt_cv_deplibs_check_method=pass_all
   ;;
@@ -5449,11 +5362,11 @@ irix5* | irix6* | nonstopux*)
   ;;
 
 # This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
+netbsd*)
   if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
     lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   else
@@ -6530,7 +6443,7 @@ ia64-*-hpux*)
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -6546,19 +6459,9 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	    LD="${LD-ld} -m elf_i386_fbsd"
 	    ;;
 	  x86_64-*linux*)
-	    case `/usr/bin/file conftest.o` in
-	      *x86-64*)
-		LD="${LD-ld} -m elf32_x86_64"
-		;;
-	      *)
-		LD="${LD-ld} -m elf_i386"
-		;;
-	    esac
-	    ;;
-	  powerpc64le-*)
-	    LD="${LD-ld} -m elf32lppclinux"
+	    LD="${LD-ld} -m elf_i386"
 	    ;;
-	  powerpc64-*)
+	  ppc64-*linux*|powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -6577,10 +6480,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  powerpcle-*)
-	    LD="${LD-ld} -m elf64lppc"
-	    ;;
-	  powerpc-*)
+	  ppc*-*linux*|powerpc*-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -8388,7 +8288,7 @@ lt_prog_compiler_static=
       lt_prog_compiler_static='-non_shared'
       ;;
 
-    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
       case $cc_basename in
       # old Intel for x86_64 which still supported -KPIC.
       ecc*)
@@ -8866,9 +8766,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
   openbsd*)
     with_gnu_ld=no
     ;;
-  linux* | k*bsd*-gnu | gnu*)
-    link_all_deplibs=no
-    ;;
   esac
 
   ld_shlibs=yes
@@ -9090,7 +8987,7 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
 	wlarc=
@@ -9267,7 +9164,6 @@ _LT_EOF
 	if test "$aix_use_runtimelinking" = yes; then
 	  shared_flag="$shared_flag "'${wl}-G'
 	fi
-	link_all_deplibs=no
       else
 	# not using gcc
 	if test "$host_cpu" = ia64; then
@@ -9721,7 +9617,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       link_all_deplibs=yes
       ;;
 
-    netbsd* | netbsdelf*-gnu)
+    netbsd*)
       if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
 	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
       else
@@ -10558,6 +10454,17 @@ freebsd* | dragonfly*)
   esac
   ;;
 
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
 haiku*)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
@@ -10674,7 +10581,7 @@ linux*oldld* | linux*aout* | linux*coff*)
   ;;
 
 # This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
   version_type=linux # correct to gnu/linux during the next big refactor
   need_lib_prefix=no
   need_version=no
@@ -10738,18 +10645,6 @@ fi
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
-netbsdelf*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='NetBSD ld.elf_so'
-  ;;
-
 netbsd*)
   version_type=sunos
   need_lib_prefix=no
@@ -12276,65 +12171,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
-$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
-if ${am_cv_prog_cc_c_o+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-  # Make sure it works both with $CC and with simple cc.
-  # Following AC_PROG_CC_C_O, we do the test twice because some
-  # compilers refuse to overwrite an existing .o file with -o,
-  # though they will create one.
-  am_cv_prog_cc_c_o=yes
-  for am_i in 1 2; do
-    if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
-   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
-   ac_status=$?
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   (exit $ac_status); } \
-         && test -f conftest2.$ac_objext; then
-      : OK
-    else
-      am_cv_prog_cc_c_o=no
-      break
-    fi
-  done
-  rm -f core conftest*
-  unset am_i
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
-$as_echo "$am_cv_prog_cc_c_o" >&6; }
-if test "$am_cv_prog_cc_c_o" != yes; then
-   # Losing compiler, so override with the script.
-   # FIXME: It is wrong to rewrite CC.
-   # But if we don't then we get into trouble of one sort or another.
-   # A longer-term fix would be to have automake use am__CC in this case,
-   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
-   CC="$am_aux_dir/compile $CC"
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
 depcc="$CC"   am_compiler_list=
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -12463,8 +12299,206 @@ else
 fi
 
 
+if test "x$CC" != xcc; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
+$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
+$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
+fi
+set dummy $CC; ac_cc=`$as_echo "$2" |
+		      sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } &&
+   test -f conftest2.$ac_objext && { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; };
+then
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+  if test "x$CC" != xcc; then
+    # Test first that cc exists at all.
+    if { ac_try='cc -c conftest.$ac_ext >&5'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+      rm -f conftest2.*
+      if { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } &&
+	 test -f conftest2.$ac_objext && { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; };
+      then
+	# cc works too.
+	:
+      else
+	# cc exists but doesn't like -o.
+	eval ac_cv_prog_cc_${ac_cc}_c_o=no
+      fi
+    fi
+  fi
+else
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+
+
+
+
+
+have_clock_gettime=0
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
+$as_echo_n "checking for library containing clock_gettime... " >&6; }
+if ${ac_cv_search_clock_gettime+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' rt; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_clock_gettime=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if ${ac_cv_search_clock_gettime+:} false; then :
+  break
+fi
+done
+if ${ac_cv_search_clock_gettime+:} false; then :
+
+else
+  ac_cv_search_clock_gettime=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
+$as_echo "$ac_cv_search_clock_gettime" >&6; }
+ac_res=$ac_cv_search_clock_gettime
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+  have_clock_gettime=1
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_CLOCK_GETTIME $have_clock_gettime
+_ACEOF
+
+ if test $have_clock_gettime -eq 1; then
+  HAVE_CLOCK_GETTIME_TRUE=
+  HAVE_CLOCK_GETTIME_FALSE='#'
+else
+  HAVE_CLOCK_GETTIME_TRUE='#'
+  HAVE_CLOCK_GETTIME_FALSE=
+fi
 
 
 
@@ -12649,6 +12683,30 @@ fi
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fi_trywait support" >&5
+$as_echo_n "checking for fi_trywait support... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <rdma/fi_eq.h>
+int
+main ()
+{
+fi_trywait(NULL, NULL, 0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+	        as_fn_error $? "fabtests requires fi_trywait support. Cannot continue" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
 if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
 ac_fn_c_check_header_mongrel "$LINENO" "valgrind/memcheck.h" "ac_cv_header_valgrind_memcheck_h" "$ac_includes_default"
 if test "x$ac_cv_header_valgrind_memcheck_h" = xyes; then :
@@ -12824,6 +12882,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
   as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_CLOCK_GETTIME_TRUE}" && test -z "${HAVE_CLOCK_GETTIME_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_CLOCK_GETTIME\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 
 : "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
@@ -13221,7 +13283,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by fabtests $as_me 1.3.0, which was
+This file was extended by fabtests $as_me 1.4.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13287,7 +13349,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-fabtests config.status 1.3.0
+fabtests config.status 1.4.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 2d7bd41..2c04053 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT([fabtests], [1.3.0], [ofiwg at lists.openfabrics.org])
+AC_INIT([fabtests], [1.4.0], [ofiwg at lists.openfabrics.org])
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_MACRO_DIR(config)
 AC_CONFIG_HEADERS(config.h)
@@ -36,9 +36,21 @@ AM_CONDITIONAL([MACOS], [test $macos -eq 1])
 AM_CONDITIONAL([LINUX], [test $linux -eq 1])
 AM_CONDITIONAL([FREEBSD], [test $freebsd -eq 1])
 
+base_c_warn_flags="-Wall -Wundef -Wpointer-arith"
+
+AC_ARG_ENABLE([debug],
+	[AS_HELP_STRING([--enable-debug],
+			[Enable debugging - default NO])],
+	[CFLAGS="-g -O0 ${base_c_warn_flags} -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers $CFLAGS"
+	 dbg=1],
+	[dbg=0])
+
+AC_DEFINE_UNQUOTED([ENABLE_DEBUG], [$dbg],
+	[defined to 1 if configured with --enable-debug])
+
 dnl Fix autoconf's habit of adding -g -O2 by default
 AS_IF([test -z "$CFLAGS"],
-      [CFLAGS='-O2 -DNDEBUG -Wall'])
+      [CFLAGS="-O2 -DNDEBUG ${base_c_warn_flags}"])
 
 # AM PROG_AR did not exist pre AM 1.11.x (where x is somewhere >0 and
 # <3), but it is necessary in AM 1.12.x.
@@ -64,6 +76,16 @@ AM_PROG_CC_C_O
 
 LT_INIT
 
+have_clock_gettime=0
+
+AC_SEARCH_LIBS([clock_gettime],[rt],
+	       [have_clock_gettime=1],
+	       [])
+
+AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME, [$have_clock_gettime],
+		   [Define to 1 if clock_gettime is available.])
+AM_CONDITIONAL(HAVE_CLOCK_GETTIME, [test $have_clock_gettime -eq 1])
+
 AC_ARG_WITH([libfabric],
             AC_HELP_STRING([--with-libfabric], [Use non-default libfabric location - default NO]),
             [AS_IF([test -d $withval/lib64], [fab_libdir="lib64"], [fab_libdir="lib"])
@@ -80,6 +102,13 @@ AC_HEADER_STDC
 AC_CHECK_HEADER([rdma/fabric.h], [],
     [AC_MSG_ERROR([<rdma/fabric.h> not found.  fabtests requires libfabric.])])
 
+AC_MSG_CHECKING([for fi_trywait support])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <rdma/fi_eq.h>]],
+	       [[fi_trywait(NULL, NULL, 0);]])],
+	       [AC_MSG_RESULT([yes])],
+	       [AC_MSG_RESULT([no])
+	        AC_MSG_ERROR([fabtests requires fi_trywait support. Cannot continue])])
+
 if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
 AC_CHECK_HEADER(valgrind/memcheck.h, [],
     AC_MSG_ERROR([valgrind requested but <valgrind/memcheck.h> not found.]))
diff --git a/fabtests.spec b/fabtests.spec
index d5b5911..79a73ba 100644
--- a/fabtests.spec
+++ b/fabtests.spec
@@ -1,11 +1,11 @@
 Name: fabtests
-Version: 1.3.0
+Version: 1.4.0
 Release: 1%{?dist}
 Summary: Test suite for libfabric API
 Group: System Environment/Libraries
 License: GPLv2 or BSD
 Url: http://www.github.com/ofiwg/fabtests
-Source: http://www.openfabrics.org/downloads/ofi/%{name}-%{version}.tar.bz2
+Source: http://www.github.org/ofiwg/%{name}/releases/download/v{%version}/%{name}-%{version}.tar.bz2
 Requires: libfabric
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
diff --git a/fabtests.spec.in b/fabtests.spec.in
index 08f640b..6252fd3 100644
--- a/fabtests.spec.in
+++ b/fabtests.spec.in
@@ -5,7 +5,7 @@ Summary: Test suite for libfabric API
 Group: System Environment/Libraries
 License: GPLv2 or BSD
 Url: http://www.github.com/ofiwg/fabtests
-Source: http://www.openfabrics.org/downloads/ofi/%{name}-%{version}.tar.bz2
+Source: http://www.github.org/ofiwg/%{name}/releases/download/v{%version}/%{name}-%{version}.tar.bz2
 Requires: libfabric
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
diff --git a/include/osx/osd.h b/include/osx/osd.h
index 552b420..5c425d3 100644
--- a/include/osx/osd.h
+++ b/include/osx/osd.h
@@ -33,9 +33,12 @@
 #ifndef _FABTESTS_OSX_OSD_H_
 #define _FABTESTS_OSX_OSD_H_
 
+#include <config.h>
+
 #include <sys/time.h>
 #include <time.h>
 
+#if !HAVE_CLOCK_GETTIME
 #define CLOCK_REALTIME 0
 #define CLOCK_REALTIME_COARSE 0
 #define CLOCK_MONOTONIC 0
@@ -51,5 +54,6 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp);
 #ifdef __cplusplus
 }
 #endif
+#endif // !HAVE_CLOCK_GETTIME
 
 #endif // FABTESTS_OSX_OSD_H
diff --git a/include/shared.h b/include/shared.h
index 8cffa19..22e81ef 100644
--- a/include/shared.h
+++ b/include/shared.h
@@ -34,15 +34,13 @@
 #  include <config.h>
 #endif /* HAVE_CONFIG_H */
 
-#include <sys/socket.h>
-#include <sys/types.h>
 #include <inttypes.h>
+#include <netinet/tcp.h>
+#include <sys/uio.h>
 
 #include <rdma/fabric.h>
-#include <rdma/fi_eq.h>
 #include <rdma/fi_rma.h>
-
-#include <time.h>
+#include <rdma/fi_domain.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -59,13 +57,18 @@ extern "C" {
 #endif
 
 
+#define ft_foreach_info(fi, info) \
+	for (fi = info; fi; fi = fi->next)
+
+#define ft_sa_family(addr) (((struct sockaddr *)(addr))->sa_family)
+
 struct test_size_param {
 	int size;
 	int enable_flags;
 };
 
 extern struct test_size_param test_size[];
-const unsigned int test_cnt;
+extern const unsigned int test_cnt;
 #define TEST_CNT test_cnt
 
 #define FT_ENABLE_ALL		(~0)
@@ -101,6 +104,15 @@ enum {
 	FT_OPT_TX_CNTR		= 1 << 6,
 	FT_OPT_VERIFY_DATA	= 1 << 7,
 	FT_OPT_ALIGN		= 1 << 8,
+	FT_OPT_BW		= 1 << 9,
+};
+
+/* for RMA tests --- we want to be able to select fi_writedata, but there is no
+ * constant in libfabric for this */
+enum ft_rma_opcodes {
+	FT_RMA_READ = 1,
+	FT_RMA_WRITE,
+	FT_RMA_WRITEDATA,
 };
 
 struct ft_opts {
@@ -117,6 +129,7 @@ struct ft_opts {
 	int options;
 	enum ft_comp_method comp_method;
 	int machr;
+	enum ft_rma_opcodes rma_op;
 	int argc;
 	char **argv;
 };
@@ -127,7 +140,7 @@ extern struct fid_wait *waitset;
 extern struct fid_domain *domain;
 extern struct fid_poll *pollset;
 extern struct fid_pep *pep;
-extern struct fid_ep *ep;
+extern struct fid_ep *ep, *alias_ep;
 extern struct fid_cq *txcq, *rxcq;
 extern struct fid_cntr *txcntr, *rxcntr;
 extern struct fid_mr *mr, no_mr;
@@ -135,12 +148,14 @@ extern struct fid_av *av;
 extern struct fid_eq *eq;
 
 extern fi_addr_t remote_fi_addr;
-extern void *buf, *tx_buf, *rx_buf;
+extern char *buf, *tx_buf, *rx_buf;
 extern size_t buf_size, tx_size, rx_size;
 extern int tx_fd, rx_fd;
 extern int timeout;
 
 extern struct fi_context tx_ctx, rx_ctx;
+extern struct fi_context *tx_ctx_arr, *rx_ctx_arr;
+extern uint64_t remote_cq_data;
 
 extern uint64_t tx_seq, rx_seq, tx_cq_cntr, rx_cq_cntr;
 extern struct fi_av_attr av_attr;
@@ -155,16 +170,28 @@ extern struct ft_opts opts;
 void ft_parseinfo(int op, char *optarg, struct fi_info *hints);
 void ft_parse_addr_opts(int op, char *optarg, struct ft_opts *opts);
 void ft_parsecsopts(int op, char *optarg, struct ft_opts *opts);
+int ft_parse_rma_opts(int op, char *optarg, struct ft_opts *opts);
+void ft_addr_usage();
 void ft_usage(char *name, char *desc);
 void ft_csusage(char *name, char *desc);
 void ft_fill_buf(void *buf, int size);
 int ft_check_buf(void *buf, int size);
 uint64_t ft_init_cq_data(struct fi_info *info);
+int ft_sock_listen(char *service);
+int ft_sock_connect(char *node, char *service);
+int ft_sock_accept();
+int ft_sock_send(int fd, void *msg, size_t len);
+int ft_sock_recv(int fd, void *msg, size_t len);
+int ft_sock_sync(int value);
+void ft_sock_shutdown(int fd);
 extern int ft_skip_mr;
 extern int ft_parent_proc;
 extern int ft_socket_pair[2];
-#define ADDR_OPTS "b:p:s:a:"
-#define INFO_OPTS "n:f:"
+extern int sock;
+extern int listen_sock;
+#define ADDR_OPTS "B:P:s:a:"
+#define FAB_OPTS "f:d:p:"
+#define INFO_OPTS FAB_OPTS "e:"
 #define CS_OPTS ADDR_OPTS "I:S:mc:t:w:l"
 
 extern char default_port[8];
@@ -176,6 +203,7 @@ extern char default_port[8];
 		.transfer_size = 1024, \
 		.window_size = 64, \
 		.sizes_enabled = FT_DEFAULT_SIZE, \
+		.rma_op = FT_RMA_WRITE, \
 		.argc = argc, .argv = argv \
 	}
 
@@ -204,6 +232,12 @@ int size_to_count(int size);
 #define FT_ERR(fmt, ...) FT_LOG("error", fmt, ##__VA_ARGS__)
 #define FT_WARN(fmt, ...) FT_LOG("warn", fmt, ##__VA_ARGS__)
 
+#if ENABLE_DEBUG
+#define FT_DEBUG(fmt, ...) FT_LOG("debug", fmt, ##__VA_ARGS__)
+#else
+#define FT_DEBUG(fmt, ...)
+#endif
+
 #define FT_EQ_ERR(eq, entry, buf, len) \
 	FT_ERR("eq_readerr: %s", fi_eq_strerror(eq, entry.prov_errno, \
 				entry.err_data, buf, len))
@@ -212,16 +246,18 @@ int size_to_count(int size);
 	FT_ERR("cq_readerr: %s", fi_cq_strerror(cq, entry.prov_errno, \
 				entry.err_data, buf, len))
 
-#define FT_CLOSE_FID(fd)					\
-	do {							\
-		int ret;					\
-		if ((fd)) {					\
-			ret = fi_close(&(fd)->fid);		\
-			if (ret)				\
-				FT_ERR("fi_close (%d) fid %d",	\
-					ret, (int) (fd)->fid.fclass);	\
-			fd = NULL;				\
-		}						\
+#define FT_CLOSE_FID(fd)						\
+	do {								\
+		int ret;						\
+		if ((fd)) {						\
+			ret = fi_close(&(fd)->fid);			\
+			if (ret)					\
+				FT_ERR("fi_close: %s(%d) fid %d",	\
+					fi_strerror(-ret), 		\
+					ret,				\
+					(int) (fd)->fid.fclass);	\
+			fd = NULL;					\
+		}							\
 	} while (0)
 
 #define FT_CLOSEV_FID(fd, cnt)			\
@@ -234,14 +270,33 @@ int size_to_count(int size);
 		}				\
 	} while (0)
 
+#define FT_EP_BIND(ep, fd, flags)					\
+	do {								\
+		int ret;						\
+		if ((fd)) {						\
+			ret = fi_ep_bind((ep), &(fd)->fid, (flags));	\
+			if (ret) {					\
+				FT_PRINTERR("fi_ep_bind", ret);		\
+				return ret;				\
+			}						\
+		}							\
+	} while (0)
+
 int ft_alloc_bufs();
 int ft_open_fabric_res();
+int ft_set_rma_caps(struct fi_info *fi, enum ft_rma_opcodes rma_op);
+int ft_getinfo(struct fi_info *hints, struct fi_info **info);
+int ft_init_fabric();
 int ft_start_server();
+int ft_server_connect();
+int ft_client_connect();
+int ft_alloc_ep_res(struct fi_info *fi);
 int ft_alloc_active_res(struct fi_info *fi);
-int ft_init_ep();
+int ft_init_ep(void);
+int ft_init_alias_ep(uint64_t flags);
 int ft_av_insert(struct fid_av *av, void *addr, size_t count, fi_addr_t *fi_addr,
 		uint64_t flags, void *context);
-int ft_init_av();
+int ft_init_av(void);
 int ft_exchange_keys(struct fi_rma_iov *peer_iov);
 void ft_free_res();
 void init_test(struct ft_opts *opts, char *test_name, size_t test_name_len);
@@ -260,15 +315,22 @@ int ft_sync();
 int ft_sync_pair(int status);
 int ft_fork_and_pair();
 int ft_wait_child();
-int ft_finalize();
+int ft_finalize(void);
 
 size_t ft_rx_prefix_size();
 size_t ft_tx_prefix_size();
-ssize_t ft_post_rx(size_t size);
-ssize_t ft_post_tx(size_t size);
-ssize_t ft_rx(size_t size);
-ssize_t ft_tx(size_t size);
-ssize_t ft_inject(size_t size);
+ssize_t ft_post_rx(struct fid_ep *ep, size_t size, struct fi_context* ctx);
+ssize_t ft_post_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size,
+		struct fi_context* ctx);
+ssize_t ft_rx(struct fid_ep *ep, size_t size);
+ssize_t ft_tx(struct fid_ep *ep, fi_addr_t fi_addr, size_t size, struct fi_context *ctx);
+ssize_t ft_inject(struct fid_ep *ep, size_t size);
+ssize_t ft_post_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote, void *context);
+ssize_t ft_rma(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote, void *context);
+ssize_t ft_post_rma_inject(enum ft_rma_opcodes op, struct fid_ep *ep, size_t size,
+		struct fi_rma_iov *remote);
 
 int ft_cq_readerr(struct fid_cq *cq);
 int ft_get_rx_comp(uint64_t total);
@@ -282,7 +344,7 @@ void show_perf(char *name, int tsize, int iters, struct timespec *start,
 		struct timespec *end, int xfers_per_iter);
 void show_perf_mr(int tsize, int iters, struct timespec *start,
 		struct timespec *end, int xfers_per_iter, int argc, char *argv[]);
-int send_recv_greeting(void);
+int send_recv_greeting(struct fid_ep *ep);
 int check_recv_msg(const char *message);
 
 #define FT_PROCESS_QUEUE_ERR(readerr, rd, queue, fn, str)	\
@@ -297,7 +359,8 @@ int check_recv_msg(const char *message);
 #define FT_PROCESS_EQ_ERR(rd, eq, fn, str) \
 	FT_PROCESS_QUEUE_ERR(eq_readerr, rd, eq, fn, str)
 
-#define FT_PRINT_OPTS_USAGE(opt, desc) fprintf(stderr, " %-20s %s\n", opt, desc)
+#define FT_OPTS_USAGE_FORMAT "%-30s %s"
+#define FT_PRINT_OPTS_USAGE(opt, desc) fprintf(stderr, FT_OPTS_USAGE_FORMAT "\n", opt, desc)
 
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define MAX(a,b) (((a)>(b))?(a):(b))
@@ -314,14 +377,6 @@ int check_recv_msg(const char *message);
 		}						\
 	} while (0)
 
-/* for RMA tests --- we want to be able to select fi_writedata, but there is no
- * constant in libfabric for this */
-enum ft_rma_opcodes {
-	FT_RMA_READ = 1,
-	FT_RMA_WRITE,
-	FT_RMA_WRITEDATA,
-};
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/unit_common.h b/include/unit_common.h
index 27fed84..7a823e4 100644
--- a/include/unit_common.h
+++ b/include/unit_common.h
@@ -34,17 +34,21 @@
 #ifndef _UNIT_COMMON_H_
 #define _UNIT_COMMON_H_
 
+#include <shared.h>
+
 enum { PASS, FAIL, NOTSUPP, SKIPPED };
-#define TEST_ENTRY(NAME) { NAME, #NAME }
+#define TEST_ENTRY(NAME, DESC) { NAME, #NAME, DESC}
 
 #define TEST_RET_VAL(_ret, _testret) \
-	(_ret == -FI_ENOSYS || -ret == -FI_ENODATA) ? SKIPPED : (_testret)
+	(_ret == -FI_ENOSYS || _ret == -FI_ENODATA) ? SKIPPED : (_testret)
 
 struct test_entry {
 	int (*test)();
 	char *name;
+	char *desc;
 };
 
+void ft_unit_usage(char *name, char *desc);
 int run_tests(struct test_entry *test_array, char *err_buf);
 
 #endif /* _UNIT_COMMON_H_ */
diff --git a/ported/libibverbs/rc_pingpong.c b/ported/libibverbs/rc_pingpong.c
index ee3249a..b51e5e8 100644
--- a/ported/libibverbs/rc_pingpong.c
+++ b/ported/libibverbs/rc_pingpong.c
@@ -46,15 +46,12 @@
 #include <string.h>
 #include <sys/time.h>
 #include <getopt.h>
-#include <time.h>
 #include <limits.h>
-#include <errno.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_endpoint.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_cm.h>
 #include <rdma/fi_errno.h>
+
 #include <shared.h>
 
 #define FT_CLOSE(DESC, STR) 				\
@@ -117,7 +114,7 @@ static int pp_eq_create(struct pingpong_context *ctx)
 	int rc;
 
 	memset(&cm_attr, 0, sizeof cm_attr);
-	cm_attr.wait_obj 	= FI_WAIT_FD;				
+	cm_attr.wait_obj 	= FI_WAIT_FD;
 
 	rc = fi_eq_open(ctx->fabric, &cm_attr, &ctx->eq, NULL);
 	if (rc)
@@ -134,7 +131,7 @@ static int pp_cq_create(struct pingpong_context *ctx)
 	memset(&cq_attr, 0, sizeof cq_attr);
 	cq_attr.format 		= FI_CQ_FORMAT_CONTEXT;
 	if (ctx->use_event)
-		cq_attr.wait_obj = FI_WAIT_FD;				
+		cq_attr.wait_obj = FI_WAIT_FD;
 	else
 		cq_attr.wait_obj = FI_WAIT_UNSPEC;
 	cq_attr.size 		= ctx->rx_depth + 1;
@@ -217,6 +214,7 @@ static int pp_accept_ctx(struct pingpong_context *ctx)
 		FT_PRINTERR("fi_endpoint", rc);
 		return 1;
 	}
+	fi_freeinfo(entry.info);
 
 	/* Create event queue */
 	if (pp_cq_create(ctx)) {
@@ -266,7 +264,6 @@ static int pp_accept_ctx(struct pingpong_context *ctx)
 	}
 	printf("Connection accepted\n");
 
-	fi_freeinfo(entry.info);
 	return 0;
 }
 
@@ -288,7 +285,7 @@ static int pp_connect_ctx(struct pingpong_context *ctx)
 		fprintf(stderr, "Unable to create event queue\n");
 		return 1;
 	}
-	
+
 	rc = fi_mr_reg(ctx->dom, ctx->buf, ctx->size, FI_SEND | FI_RECV, 0, 0, 0, &ctx->mr, NULL);
 	if (rc) {
 		FT_PRINTERR("fi_mr_reg", rc);
@@ -301,19 +298,19 @@ static int pp_connect_ctx(struct pingpong_context *ctx)
 		FT_PRINTERR("fi_endpoint", rc);
 		return 1;
 	}
-	
+
 	/* Create event queue */
 	if (pp_cq_create(ctx)) {
 		fprintf(stderr, "Unable to create event queue\n");
 		return 1;
 	}
-	
+
 	/* Bind eq to ep */
 	rc = fi_ep_bind(ctx->ep, &ctx->cq->fid, FI_SEND | FI_RECV);
 	if (rc) {
 		FT_PRINTERR("fi_ep_bind", rc);
 		return 1;
-	}	
+	}
 
 	rc = fi_ep_bind(ctx->ep, &ctx->eq->fid, 0);
 	if (rc) {
@@ -415,7 +412,7 @@ static int pp_post_send(struct pingpong_context *ctx)
 {
 	int rc = 0;
 
-	rc = fi_send(ctx->ep, ctx->buf, ctx->size, fi_mr_desc(ctx->mr), 
+	rc = fi_send(ctx->ep, ctx->buf, ctx->size, fi_mr_desc(ctx->mr),
 		     0, (void *)(uintptr_t)PINGPONG_SEND_WCID);
 	if (rc) {
 		FT_PRINTERR("fi_send", rc);
@@ -531,7 +528,7 @@ int main(int argc, char *argv[])
 	rc = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
 	if (rc)
 		return -rc;
-	
+
 	rc = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
 	if (rc) {
 		FT_PRINTERR("fi_getinfo", rc);
diff --git a/ported/librdmacm/cmatose.c b/ported/librdmacm/cmatose.c
index 31516ad..8badcd2 100644
--- a/ported/librdmacm/cmatose.c
+++ b/ported/librdmacm/cmatose.c
@@ -33,21 +33,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <netdb.h>
 #include <getopt.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_cm.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_endpoint.h>
-#include <rdma/fi_eq.h>
 #include <rdma/fi_errno.h>
-#include <shared.h>
 
+#include <shared.h>
 
 struct cma_node {
 	int			id;
diff --git a/scripts/runfabtests.sh b/scripts/runfabtests.sh
index a73340c..5706e7a 100755
--- a/scripts/runfabtests.sh
+++ b/scripts/runfabtests.sh
@@ -2,6 +2,7 @@
 
 #
 # Copyright (c) 2016, Cisco Systems, Inc. All rights reserved.
+# Copyright (c) 2016, Cray, Inc. All rights reserved.
 #
 # This software is available to you under a choice of one of two
 # licenses.  You may choose to be licensed under the terms of the GNU
@@ -59,33 +60,41 @@ declare -i skip_count=0
 declare -i pass_count=0
 declare -i fail_count=0
 
-# OS X defines NODATA differently than Linux, this
-# is a hack to work around that.
-function no_data_num {
-	if [[ "$(uname)" == "Linux" ]]; then
-		echo 61
-	elif [[ "$(uname)" == "FreeBSD" ]]; then
-		echo 83
-	elif [[ "$(uname)" == "Darwin" ]]; then
-		echo 96
-	else
-		echo 61
-	fi
-}
-declare -ri FI_ENODATA=$(no_data_num)
+if [[ "$(uname)" == "FreeBSD" ]]; then
+    declare -ri FI_ENODATA=$(python -c 'import errno; print(errno.ENOMSG)')
+else
+    declare -ri FI_ENODATA=$(python -c 'import errno; print(errno.ENODATA)')
+fi
+declare -ri FI_ENOSYS=$(python -c 'import errno; print(errno.ENOSYS)')
+
+neg_unit_tests=(
+	"dgram g00n13s"
+	"rdm g00n13s"
+	"msg g00n13s"
+)
 
 simple_tests=(
+	"cm_data"
 	"cq_data"
 	"dgram"
 	"dgram_waitset"
 	"msg"
 	"msg_epoll"
 	"msg_sockets"
-	"poll"
+	"poll -t queue"
+	"poll -t counter"
 	"rdm"
 	"rdm_rma_simple"
 	"rdm_rma_trigger"
-	"rdm_shared_ctx"
+	"shared_ctx"
+	"shared_ctx --no-tx-shared-ctx"
+	"shared_ctx --no-rx-shared-ctx"
+	"shared_ctx -e msg"
+	"shared_ctx -e msg --no-tx-shared-ctx"
+	"shared_ctx -e msg --no-rx-shared-ctx"
+	"shared_ctx -e dgram"
+	"shared_ctx -e dgram --no-tx-shared-ctx"
+	"shared_ctx -e dgram --no-rx-shared-ctx"
 	"rdm_tagged_peek"
 	"scalable_ep"
 	"cmatose"
@@ -94,9 +103,17 @@ simple_tests=(
 
 short_tests=(
 	"msg_pingpong -I 5"
+	"msg_bw -I 5"
+	"rma_bw -e msg -o write -I 5"
+	"rma_bw -e msg -o read -I 5"
+	"rma_bw -e msg -o writedata -I 5"
+	"rma_bw -e rdm -o write -I 5"
+	"rma_bw -e rdm -o read -I 5"
+	"rma_bw -e rdm -o writedata -I 5"
 	"msg_rma -o write -I 5"
 	"msg_rma -o read -I 5"
 	"msg_rma -o writedata -I 5"
+	"msg_stream -I 5"
 	"rdm_atomic -I 5 -o all"
 	"rdm_cntr_pingpong -I 5"
 	"rdm_multi_recv -I 5"
@@ -114,18 +131,26 @@ short_tests=(
 standard_tests=(
 	"msg_pingpong"
 	"msg_pingpong -v"
-	"msg_pingpong -P"
-	"msg_pingpong -P -v"
+	"msg_pingpong -k"
+	"msg_pingpong -k -v"
+	"msg_bw"
+	"rma_bw -e msg -o write"
+	"rma_bw -e msg -o read"
+	"rma_bw -e msg -o writedata"
+	"rma_bw -e rdm -o write"
+	"rma_bw -e rdm -o read"
+	"rma_bw -e rdm -o writedata"
 	"msg_rma -o write"
 	"msg_rma -o read"
 	"msg_rma -o writedata"
+	"msg_stream"
 	"rdm_atomic -o all -I 1000"
 	"rdm_cntr_pingpong"
 	"rdm_multi_recv"
 	"rdm_pingpong"
 	"rdm_pingpong -v"
-	"rdm_pingpong -P"
-	"rdm_pingpong -P -v"
+	"rdm_pingpong -k"
+	"rdm_pingpong -k -v"
 	"rdm_rma -o write"
 	"rdm_rma -o read"
 	"rdm_rma -o writedata"
@@ -133,15 +158,17 @@ standard_tests=(
 	"rdm_tagged_bw"
 	"dgram_pingpong"
 	"dgram_pingpong -v"
-	"dgram_pingpong -P"
-	"dgram_pingpong -P -v"
+	"dgram_pingpong -k"
+	"dgram_pingpong -k -v"
 	"rc_pingpong"
 )
 
 unit_tests=(
-	"av_test -d GOOD_ADDR -n 1 -s SERVER_ADDR"
+	"getinfo_test"
+	"av_test -g GOOD_ADDR -n 1 -s SERVER_ADDR"
 	"dom_test -n 2"
 	"eq_test"
+	"cq_test"
 	"size_left_test"
 )
 
@@ -162,7 +189,9 @@ function print_results {
 	local test_result=$2
 	local test_time=$3
 	local server_out_file=$4
-	local client_out_file=$5
+	local server_cmd=$5
+	local client_out_file=$6
+	local client_cmd=$7
 
 	if [ $VERBOSE -eq 0 ] ; then
 		# print a simple, single-line format that is still valid YAML
@@ -188,10 +217,16 @@ function print_results {
 		printf -- "  result: %s\n" "$test_result"
 		printf -- "  time:   %s\n" "$test_time"
 		if [ $emit_stdout -eq 1 -a "$server_out_file" != "" ] ; then
+			if [ "$server_cmd" != "" ] ; then
+				printf -- "  server_cmd: %s\n" "$server_cmd"
+			fi
 			printf -- "  server_stdout: |\n"
 			sed -e 's/^/    /' < $server_out_file
 		fi
 		if [ $emit_stdout -eq 1 -a "$client_out_file" != "" ] ; then
+			if [ "$client_cmd" != "" ] ; then
+				printf -- "  client_cmd: %s\n" "$client_cmd"
+			fi
 			printf -- "  client_stdout: |\n"
 			sed -e 's/^/    /' < $client_out_file
 		fi
@@ -230,8 +265,9 @@ function is_excluded {
 
 function unit_test {
 	local test=$1
+	local is_neg=$2
 	local ret1=0
-	local test_exe=$(echo "fi_${test} -f $PROV" | \
+	local test_exe=$(echo "fi_${test} -p $PROV" | \
 	    sed -e "s/GOOD_ADDR/$GOOD_ADDR/g" -e "s/SERVER_ADDR/${S_INTERFACE}/g")
 	local start_time
 	local end_time
@@ -246,26 +282,34 @@ function unit_test {
 
 	start_time=$(date '+%s')
 
-	${SERVER_CMD} "${BIN_PATH}${test_exe}" &> $s_outp &
+	cmd="${BIN_PATH}${test_exe}"
+	${SERVER_CMD} "$cmd" &> $s_outp &
 	p1=$!
 
 	wait $p1
-	ret1=$?
+	ret=$?
 
 	end_time=$(date '+%s')
 	test_time=$(compute_duration "$start_time" "$end_time")
 
-	if [ $ret1 -eq $FI_ENODATA ]; then
-		print_results "$test_exe" "Notrun" "$test_time" "$s_outp"
+	if [ $is_neg -eq 1 -a $ret -eq $FI_ENODATA ]; then
+		# negative test passed
+		ret=0
+	elif [ $is_neg -eq 1 ]; then
+		# negative test failed
+		ret=1
+	fi
+	if [[ $ret -eq $FI_ENODATA || $ret -eq $FI_ENOSYS ]]; then
+		print_results "$test_exe" "Notrun" "$test_time" "$s_outp" "$cmd"
 		skip_count+=1
-	elif [ $ret1 -ne 0 ]; then
-		print_results "$test_exe" "Fail" "$test_time" "$s_outp"
-		if [ $ret1 -eq 124 ]; then
+	elif [ $ret -ne 0 ]; then
+		print_results "$test_exe" "Fail" "$test_time" "$s_outp" "$cmd"
+		if [ $ret -eq 124 ]; then
 			cleanup
 		fi
 		fail_count+=1
 	else
-		print_results "$test_exe" "Pass" "$test_time" "$s_outp"
+		print_results "$test_exe" "Pass" "$test_time" "$s_outp" "$cmd"
 		pass_count+=1
 	fi
 }
@@ -274,7 +318,7 @@ function cs_test {
 	local test=$1
 	local ret1=0
 	local ret2=0
-	local test_exe="fi_${test} -f ${PROV}"
+	local test_exe="fi_${test} -p ${PROV}"
 	local start_time
 	local end_time
 	local test_time
@@ -288,11 +332,13 @@ function cs_test {
 
 	start_time=$(date '+%s')
 
-	${SERVER_CMD} "${BIN_PATH}${test_exe} -s $S_INTERFACE" &> $s_outp &
+	s_cmd="${BIN_PATH}${test_exe} -s $S_INTERFACE"
+	${SERVER_CMD} "$s_cmd" &> $s_outp &
 	p1=$!
 	sleep 1
 
-	${CLIENT_CMD} "${BIN_PATH}${test_exe} -s $C_INTERFACE $S_INTERFACE" &> $c_outp &
+	c_cmd="${BIN_PATH}${test_exe} -s $C_INTERFACE $S_INTERFACE"
+	${CLIENT_CMD} "$c_cmd" &> $c_outp &
 	p2=$!
 
 	wait $p1
@@ -304,17 +350,18 @@ function cs_test {
 	end_time=$(date '+%s')
 	test_time=$(compute_duration "$start_time" "$end_time")
 
-	if [ $ret1 -eq $FI_ENODATA -a $ret2 -eq $FI_ENODATA ]; then
-		print_results "$test_exe" "Notrun" "$test_time" "$s_outp" "$c_outp"
+	if [[ $ret1 -eq $FI_ENODATA && $ret2 -eq $FI_ENODATA ]] ||
+	   [[ $ret1 -eq $FI_ENOSYS && $ret2 -eq $FI_ENOSYS ]]; then
+		print_results "$test_exe" "Notrun" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 		skip_count+=1
 	elif [ $ret1 -ne 0 -o $ret2 -ne 0 ]; then
-		print_results "$test_exe" "Fail" "$test_time" "$s_outp" "$c_outp"
+		print_results "$test_exe" "Fail" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 		if [ $ret1 -eq 124 -o $ret2 -eq 124 ]; then
 			cleanup
 		fi
 		fail_count+=1
 	else
-		print_results "$test_exe" "Pass" "$test_time" "$s_outp" "$c_outp"
+		print_results "$test_exe" "Pass" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 		pass_count+=1
 	fi
 }
@@ -338,11 +385,13 @@ function complex_test {
 
 	start_time=$(date '+%s')
 
-	FI_LOG_LEVEL=error ${SERVER_CMD} "${BIN_PATH}${test_exe} -s $S_INTERFACE -x" &> $s_outp &
+	s_cmd="${BIN_PATH}${test_exe} -s $S_INTERFACE -x"
+	FI_LOG_LEVEL=error ${SERVER_CMD} "$s_cmd" &> $s_outp &
 	p1=$!
 	sleep 1
 
-	FI_LOG_LEVEL=error ${CLIENT_CMD} "${BIN_PATH}${test_exe} -s $C_INTERFACE -f ${PROV} -t $config $S_INTERFACE" &> $c_outp &
+	c_cmd="${BIN_PATH}${test_exe} -s $C_INTERFACE -p ${PROV} -t $config $S_INTERFACE"
+	FI_LOG_LEVEL=error ${CLIENT_CMD} "$c_cmd" &> $c_outp &
 	p2=$!
 
 	wait $p2
@@ -356,14 +405,14 @@ function complex_test {
 
 	# case: config file doesn't exist or invalid option provided
 	if [ $ret1 -eq 1 -o $ret2 -eq 1 ]; then
-		print_results "$test_exe" "Notrun" "0" "$s_outp" "$c_outp"
+		print_results "$test_exe" "Notrun" "0" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 		cleanup
 		skip_count+=1
 		return
 	# case: test didn't run becasue some error occured
 	elif [ $ret1 -ne 0 -o $ret2 -ne 0 ]; then
 		printf "%-50s%s\n" "$test_exe:" "Server returns $ret1, client returns $ret2"
-		print_results "$test_exe" "Fail [$f_cnt/$total]" "$test_time" "$s_outp" "$c_outp"
+		print_results "$test_exe" "Fail [$f_cnt/$total]" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
                 cleanup
                 fail_count+=1
 	else
@@ -371,10 +420,10 @@ function complex_test {
 		local s_cnt=$(cat $c_outp | awk -F': ' '/Success/ {total += $2} END {print total}')
 		local total=$(cat $c_outp | awk -F': ' '/Success|ENODATA|ENOSYS|ERROR/ {total += $2} END {print total}')
 		if [ $f_cnt -eq 0 ]; then
-			print_results "$test_exe" "Pass [$s_cnt/$total]" "$test_time" "$s_outp" "$c_outp"
+			print_results "$test_exe" "Pass [$s_cnt/$total]" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 			pass_count+=1
 		else
-			print_results "$test_exe" "Fail [$f_cnt/$total]" "$test_time" "$s_outp" "$c_outp"
+			print_results "$test_exe" "Fail [$f_cnt/$total]" "$test_time" "$s_outp" "$s_cmd" "$c_outp" "$c_cmd"
 			cleanup
 			fail_count+=1
 		fi
@@ -406,7 +455,11 @@ function main {
 	case ${ts} in
 		unit)
 			for test in "${unit_tests[@]}"; do
-				unit_test "$test"
+				unit_test "$test" "0"
+			done
+
+			for test in "${neg_unit_tests[@]}"; do
+				unit_test "$test" "1"
 			done
 		;;
 		simple)
diff --git a/simple/cm_data.c b/simple/cm_data.c
new file mode 100644
index 0000000..b94a66d
--- /dev/null
+++ b/simple/cm_data.c
@@ -0,0 +1,484 @@
+/*
+ * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2014-2016, Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under the BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+
+#include <rdma/fi_errno.h>
+#include <rdma/fi_endpoint.h>
+#include <rdma/fi_cm.h>
+
+#include "shared.h"
+
+static char *cm_data;
+static size_t cm_data_size;
+static struct fi_eq_cm_entry *entry;
+static struct fi_eq_err_entry err_entry;
+
+char *sock_service = "2710";
+
+static int read_shutdown_event()
+{
+	int ret;
+	uint32_t event;
+
+	memset(entry, 0, sizeof(*entry));
+	ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0);
+	if (ret < 0) {
+		FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "shutdown");
+		return ret;
+	}
+	if (event != FI_SHUTDOWN || entry->fid != &ep->fid) {
+		FT_ERR("Unexpected CM event %d fid %p (ep %p)", event,
+			entry->fid, ep);
+		ret = -FI_EOTHER;
+		return ret;
+	}
+	return 0;
+}
+
+static int server_setup(void)
+{
+	size_t opt_size;
+	int ret;
+
+	ret = ft_start_server();
+	if (ret)
+		return ret;
+
+	/* Get the maximum cm_size supported in all domains */
+	opt_size = sizeof(cm_data_size);
+	return fi_getopt(&pep->fid, FI_OPT_ENDPOINT, FI_OPT_CM_DATA_SIZE,
+		&cm_data_size, &opt_size);
+}
+
+static int client_setup(void)
+{
+	size_t opt_size;
+	int ret;
+
+	/* Get fabric info */
+	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints,
+			&fi);
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
+		return ret;
+	}
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		return ret;
+
+	ret = ft_alloc_active_res(fi);
+	if (ret)
+		return ret;
+
+	ret = ft_init_ep();
+	if (ret)
+		return ret;
+
+	/* Get the maximum cm_size for this domain + endpoint combination */
+	opt_size = sizeof(opt_size);
+	return fi_getopt(&ep->fid, FI_OPT_ENDPOINT, FI_OPT_CM_DATA_SIZE,
+		&cm_data_size, &opt_size);
+}
+
+static int server_listen(size_t paramlen)
+{
+	size_t expected;
+	uint32_t event;
+	int ret;
+
+	expected = paramlen + sizeof(*entry);
+	memset(entry, 0, expected);
+
+	ret = fi_eq_sread(eq, &event, entry, expected, -1, 0);
+	if (ret != expected) {
+		FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "listen");
+		return ret;
+	}
+
+	if (event != FI_CONNREQ) {
+		FT_ERR("Unexpected CM event %d", event);
+		return -FI_EOTHER;
+	}
+
+	ret = ft_check_buf(entry->data, paramlen);
+	if (ret)
+		return ret;
+
+	fi = entry->info;
+
+	return 0;
+}
+
+static int server_reject(size_t paramlen)
+{
+	int ret;
+
+	ret = server_listen(paramlen);
+	if (ret)
+		return ret;
+
+	/* Data will appear in error event generated on remote end. */
+	ft_fill_buf(cm_data, paramlen);
+	ret = fi_reject(pep, fi->handle, cm_data, paramlen);
+	if (ret)
+		FT_PRINTERR("fi_reject", ret);
+
+	return ret;
+}
+
+static int server_accept(size_t paramlen)
+{
+	uint32_t event;
+	int ret;
+
+	ret = server_listen(paramlen);
+	if (ret)
+		return ret;
+
+	ret = fi_domain(fabric, fi, &domain, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_domain", ret);
+		goto err;
+	}
+
+	ret = ft_alloc_active_res(fi);
+	if (ret) {
+		FT_PRINTERR("alloc_active_res", ret);
+		goto err;
+	}
+
+	ret = ft_init_ep();
+	if (ret) {
+		FT_PRINTERR("init_ep", ret);
+		goto err;
+	}
+	/* Data will apppear on accept event on remote end. */
+	ft_fill_buf(cm_data, paramlen);
+
+	/* Accept the incoming connection. Also transitions endpoint to active
+	 * state.
+	 */
+	ret = fi_accept(ep, cm_data, paramlen);
+	if (ret) {
+		FT_PRINTERR("fi_accept", ret);
+		goto err;
+	}
+
+	/* Local FI_CONNECTED event does not have data associated. */
+	memset(entry, 0, sizeof(*entry));
+	ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0);
+	if (ret != sizeof(*entry)) {
+		FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "accept");
+		goto err;
+	}
+
+	if (event != FI_CONNECTED || entry->fid != &ep->fid) {
+		FT_ERR("Unexpected CM event %d fid %p (ep %p)", event,
+				entry->fid, ep);
+		ret = -FI_EOTHER;
+		goto err;
+	}
+
+	fi_shutdown(ep, 0);
+	ret = read_shutdown_event();
+	if (ret)
+		goto err;
+
+	FT_CLOSE_FID(ep);
+	FT_CLOSE_FID(rxcq);
+	FT_CLOSE_FID(txcq);
+	FT_CLOSE_FID(rxcntr);
+	FT_CLOSE_FID(txcntr);
+	FT_CLOSE_FID(av);
+	FT_CLOSE_FID(domain);
+
+	return 0;
+
+err:
+	fi_reject(pep, fi->handle, NULL, 0);
+	return ret;
+}
+
+static int server(size_t paramlen)
+{
+	int ret;
+
+	ret = server_reject(paramlen);
+	if (ret)
+		return ret;
+
+	return server_accept(paramlen);
+}
+
+static int client_connect(size_t paramlen)
+{
+	ft_fill_buf(cm_data, paramlen);
+
+	/* Connect to server */
+	return fi_connect(ep, fi->dest_addr, cm_data, paramlen);
+}
+
+static int client_open_new_ep()
+{
+	size_t opt_size;
+	int ret;
+
+	FT_CLOSE_FID(ep);
+
+	ret = fi_endpoint(domain, fi, &ep, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_endpoint", ret);
+		return ret;
+	}
+
+	ret = ft_init_ep();
+	if (ret)
+		return ret;
+
+	/* Get the maximum cm_size for this domain + endpoint combination */
+	opt_size = sizeof(opt_size);
+	return fi_getopt(&ep->fid, FI_OPT_ENDPOINT, FI_OPT_CM_DATA_SIZE,
+		&cm_data_size, &opt_size);
+}
+
+static int client_expect_reject(size_t paramlen)
+{
+	uint32_t event;
+	int ret;
+
+	ret = client_connect(paramlen);
+	if (ret) {
+		FT_PRINTERR("fi_connect", ret);
+		return ret;
+	}
+
+	ret = fi_eq_sread(eq, &event, entry, sizeof(*entry), -1, 0);
+	if (ret != -FI_EAVAIL) {
+		FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "connect");
+		return ret;
+	}
+
+	ret = fi_eq_readerr(eq, &err_entry, 0);
+	if (ret != sizeof(err_entry)) {
+		FT_EQ_ERR(eq, err_entry, NULL, 0);
+		return err_entry.err;
+	}
+
+	if (err_entry.err != FI_ECONNREFUSED)
+		return err_entry.err;
+
+	/* Check data on FI_ECONNREFUSED error event. */
+	return ft_check_buf(err_entry.err_data, err_entry.err_data_size);
+}
+
+static int client_expect_accept(size_t paramlen)
+{
+	size_t expected;
+	uint32_t event;
+	int ret;
+
+	expected = paramlen + sizeof(*entry);
+
+	ret = client_connect(paramlen);
+	if (ret) {
+		FT_PRINTERR("fi_connect", ret);
+		return ret;
+	}
+
+	ret = fi_eq_sread(eq, &event, entry, expected, -1, 0);
+	if (ret != expected) {
+		FT_PROCESS_EQ_ERR(ret, eq, "fi_eq_sread", "connect");
+		return ret;
+	}
+
+	if (event != FI_CONNECTED || entry->fid != &ep->fid) {
+		FT_ERR("Unexpected CM event %d fid %p (ep %p)", event,
+				entry->fid, ep);
+		return -FI_EOTHER;
+	}
+
+	/* Check data on FI_CONNECTED event. */
+	ret = ft_check_buf(entry->data, paramlen);
+	if (ret)
+		return ret;
+
+	fi_shutdown(ep, 0);
+	return read_shutdown_event();
+}
+
+/*
+ * After each reject and accept of a connection request we close the endpoint and
+ * open a new one since fi_connect can be called only once in a connected
+ * endpoint's lifetime.
+ */
+static int client(size_t paramlen)
+{
+	int ret;
+
+	ret = client_expect_reject(paramlen);
+	if (ret)
+		return ret;
+
+	ret = client_open_new_ep();
+	if (ret)
+		return ret;
+
+	ret = client_expect_accept(paramlen);
+	if (ret)
+		return ret;
+
+	return client_open_new_ep();
+}
+
+static int run(void)
+{
+	char *node, *service;
+	uint64_t flags;
+	int ret;
+	size_t i;
+
+	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	if (ret)
+		return ret;
+
+	ret = opts.dst_addr ? client_setup() : server_setup();
+	if (ret) {
+		fprintf(stderr, "error: %s\n", fi_strerror(-ret));
+		return ret;
+	}
+
+	/* Leave extra space for invalid size test */
+	cm_data = calloc(1, cm_data_size + 1);
+	if (!cm_data)
+		return -FI_ENOMEM;
+
+	entry = calloc(1, sizeof(*entry) + cm_data_size);
+	if (!entry)
+		return -FI_ENOMEM;
+
+	if (opts.dst_addr) {
+		ret = ft_sock_connect(opts.dst_addr, sock_service);
+		if (ret)
+			goto err2;
+	} else {
+		ret = ft_sock_listen(sock_service);
+		if (ret)
+			goto err2;
+		ret = ft_sock_accept();
+		if (ret)
+			goto err1;
+	}
+
+	for (i = 1; i <= cm_data_size; i <<= 1) {
+		printf("trying with data size: %zu\n", i);
+
+		if (opts.dst_addr)
+			ret = client(i);
+		else
+			ret = server(i);
+
+		if (ret)
+			goto err1;
+
+		ret = ft_sock_sync(0);
+		if (ret)
+			goto err1;
+	}
+
+	/* Despite server not being setup to handle this, the client should fail
+	 * with -FI_EINVAL since this exceeds its max data size.
+	 */
+	if (opts.dst_addr) {
+		printf("trying with data size exceeding maximum: %zu\n",
+				cm_data_size + 1);
+		/* Don't call client since it produces an error message. */
+		ret = client_connect(cm_data_size + 1);
+		if (ret != -FI_EINVAL) {
+			FT_ERR("expected -FI_EINVAL, got: [%d]:%s\n", ret,
+				fi_strerror(-ret));
+		} else {
+			ret = FI_SUCCESS;
+		}
+	}
+
+err1:
+	ft_sock_shutdown(sock);
+err2:
+	free(entry);
+	return ret;
+}
+
+int main(int argc, char **argv)
+{
+	int op, ret;
+
+	opts = INIT_OPTS;
+	opts.options |= FT_OPT_SIZE;
+
+	hints = fi_allocinfo();
+	if (!hints)
+		return EXIT_FAILURE;
+
+	while ((op = getopt(argc, argv, "q:h" ADDR_OPTS INFO_OPTS)) != -1) {
+		switch (op) {
+		case 'q':
+			sock_service = optarg;
+			break;
+		default:
+			ft_parse_addr_opts(op, optarg, &opts);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			ft_usage(argv[0],
+					"A MSG client-sever example that uses CM data.");
+			FT_PRINT_OPTS_USAGE("-q <service_port>", "management port");
+			return EXIT_FAILURE;
+		}
+	}
+
+	if (optind < argc)
+		opts.dst_addr = argv[optind];
+
+	hints->ep_attr->type	= FI_EP_MSG;
+	hints->caps		= FI_MSG;
+	hints->mode		= FI_LOCAL_MR;
+	ft_skip_mr = 1;
+
+	ret = run();
+
+	ft_free_res();
+	return -ret;
+}
diff --git a/simple/cq_data.c b/simple/cq_data.c
index 8e54097..ffbd012 100644
--- a/simple/cq_data.c
+++ b/simple/cq_data.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2016, Cisco Systems, Inc. All rights reserved.
  *
  * This software is available to you under the BSD license below:
  *
@@ -28,140 +29,20 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <inttypes.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
-#include <shared.h>
-
-
-static int server_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
-		return (int) rd;
-	}
-
-	fi = entry.info;
-	if (event != FI_CONNREQ) {
-		fprintf(stderr, "Unexpected CM event %d\n", event);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	ret = fi_domain(fabric, fi, &domain, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_domain", ret);
-		goto err;
-	}
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		 goto err;
-
-	ret = ft_init_ep();
-	if (ret)
-		goto err;
 
-	ret = fi_accept(ep, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_accept", ret);
-		goto err;
-	}
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
-		ret = (int) rd;
-		goto err;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	return 0;
-
-err:
-	fi_reject(pep, fi->handle, NULL, 0);
-	return ret;
-}
-
-static int client_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	ret = ft_getsrcaddr(opts.src_addr, opts.src_port, hints);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_connect", ret);
-		return ret;
-	}
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
-		return (int) rd;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		return -FI_EOTHER;
-	}
-
-	return 0;
-}
+#include <shared.h>
 
 static int run_test()
 {
 	int ret;
 	size_t size = 1000;
-	uint64_t remote_cq_data;
 	struct fi_cq_data_entry comp;
 
-	remote_cq_data = ft_init_cq_data(fi);
-
 	if (opts.dst_addr) {
 		fprintf(stdout,
 			"Posting send with CQ data: 0x%" PRIx64 "\n",
@@ -208,21 +89,15 @@ static int run_test()
 
 static int run(void)
 {
-	char *node, *service;
-	uint64_t flags;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
 	if (!opts.dst_addr) {
 		ret = ft_start_server();
 		if (ret)
 			return ret;
 	}
 
-	ret = opts.dst_addr ? client_connect() : server_connect();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret) {
 		return ret;
 	}
diff --git a/simple/dgram.c b/simple/dgram.c
index e10992c..00b91dd 100644
--- a/simple/dgram.c
+++ b/simple/dgram.c
@@ -30,64 +30,19 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 #include <shared.h>
 
-
-static int init_fabric(void)
-{
-	char *node, *service;
-	uint64_t flags = 0;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	/* Get fabric info */
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int ret;
 
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	return send_recv_greeting();
+	return send_recv_greeting(ep);
 }
 
 int main(int argc, char **argv)
diff --git a/simple/dgram_waitset.c b/simple/dgram_waitset.c
index d09436a..b075206 100644
--- a/simple/dgram_waitset.c
+++ b/simple/dgram_waitset.c
@@ -31,16 +31,10 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
-#include <shared.h>
 
+#include <shared.h>
 
 static int alloc_ep_res(struct fi_info *fi)
 {
@@ -64,20 +58,12 @@ static int alloc_ep_res(struct fi_info *fi)
 
 static int init_fabric(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	ret = ft_open_fabric_res();
 	if (ret)
 		return ret;
@@ -99,7 +85,7 @@ static int send_recv()
 	int ret;
 
 	fprintf(stdout, "Posting a send...\n");
-	ret = ft_post_tx(tx_size);
+	ret = ft_post_tx(ep, remote_fi_addr, tx_size, &tx_ctx);
 	if (ret)
 		return ret;
 
diff --git a/simple/msg.c b/simple/msg.c
index 00859fb..095be6e 100644
--- a/simple/msg.c
+++ b/simple/msg.c
@@ -31,148 +31,27 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <getopt.h>
-#include <string.h>
 
-#include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
 
 #include "shared.h"
 
-
-static int server_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	/* Wait for connection request from client */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
-		return (int) rd;
-	}
-
-	fi = entry.info;
-	if (event != FI_CONNREQ) {
-		FT_ERR("Unexpected CM event %d", event);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	ret = fi_domain(fabric, fi, &domain, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_domain", ret);
-		goto err;
-	}
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		 goto err;
-
-	ret = ft_init_ep();
-	if (ret)
-		goto err;
-
-	/* Accept the incoming connection. Also transitions endpoint to active state */
-	ret = fi_accept(ep, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_accept", ret);
-		goto err;
-	}
-
-	/* Wait for the connection to be established */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
-		ret = (int) rd;
-		goto err;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		FT_ERR("Unexpected CM event %d fid %p (ep %p)", event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	return 0;
-
-err:
-	fi_reject(pep, fi->handle, NULL, 0);
-	return ret;
-}
-
-static int client_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	/* Get fabric info */
-	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	/* Connect to server */
-	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_connect", ret);
-		return ret;
-	}
-
-	/* Wait for the connection to be established */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
-		return (int) rd;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		FT_ERR("Unexpected CM event %d fid %p (ep %p)", event, entry.fid, ep);
-		return -FI_EOTHER;
-	}
-
-	return 0;
-}
-
 static int run(void)
 {
-	char *node, *service;
-	uint64_t flags;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
 	if (!opts.dst_addr) {
 		ret = ft_start_server();
 		if (ret)
 			return ret;
 	}
 
-	ret = opts.dst_addr ? client_connect() : server_connect();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret) {
 		return ret;
 	}
 
-	ret = send_recv_greeting();
+	ret = send_recv_greeting(ep);
 
 	fi_shutdown(ep, 0);
 	return ret;
diff --git a/simple/msg_epoll.c b/simple/msg_epoll.c
index 8f624b4..ce7d53a 100644
--- a/simple/msg_epoll.c
+++ b/simple/msg_epoll.c
@@ -40,14 +40,10 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
 #include <unistd.h>
 #include <sys/epoll.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
 
 static int epfd;
@@ -84,129 +80,6 @@ static int alloc_epoll_res(void)
 	return 0;
 }
 
-static int server_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	/* Wait for connection request from client */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
-		return (int) rd;
-	}
-
-	fi = entry.info;
-	if (event != FI_CONNREQ) {
-		fprintf(stderr, "Unexpected CM event %d\n", event);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	ret = fi_domain(fabric, fi, &domain, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_domain", ret);
-		goto err;
-	}
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		goto err;
-
-	ret = ft_init_ep();
-	if (ret)
-		goto err;
-
-	ret = alloc_epoll_res();
-	if (ret)
-		goto err;
-
-	/* Accept the incoming connection. Also transitions endpoint to active state */
-	ret = fi_accept(ep, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_accept", ret);
-		goto err;
-	}
-
-	/* Wait for the connection to be established */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
-		ret = (int) rd;
-		goto err;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	return 0;
-
-err:
-	fi_reject(pep, fi->handle, NULL, 0);
-	return ret;
-}
-
-static int client_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	/* Get fabric info */
-	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = alloc_epoll_res();
-	if (ret)
-		return ret;
-
-	/* Connect to server */
-	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_connect", ret);
-		return ret;
-	}
-
-	/* Wait for the connection to be established */
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
-		ret = (int) rd;
-		return ret;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
-		ret = -FI_EOTHER;
-		return ret;
-	}
-
-	return 0;
-}
-
 static int send_recv()
 {
 	struct fi_cq_entry comp;
@@ -222,7 +95,7 @@ static int send_recv()
 			fprintf(stderr, "Transmit buffer too small.\n");
 			return -FI_ETOOSMALL;
 		}
-		ret = ft_post_tx(message_len);
+		ret = ft_post_tx(ep, remote_fi_addr, message_len, &tx_ctx);
 		if (ret)
 			return ret;
 
@@ -291,25 +164,23 @@ static int send_recv()
 
 static int run(void)
 {
-	char *node, *service;
-	uint64_t flags;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
 	if (!opts.dst_addr) {
 		ret = ft_start_server();
 		if (ret)
 			return ret;
 	}
 
-	ret = opts.dst_addr ? client_connect() : server_connect();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret) {
 		return ret;
 	}
 
+	ret = alloc_epoll_res();
+	if (ret)
+		return ret;
+
 	ret = send_recv();
 
 	fi_shutdown(ep, 0);
diff --git a/simple/msg_sockets.c b/simple/msg_sockets.c
index 6331783..ccf2227 100644
--- a/simple/msg_sockets.c
+++ b/simple/msg_sockets.c
@@ -33,7 +33,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <unistd.h>
 #include <netdb.h>
 #include <netinet/in.h>
 
@@ -43,7 +42,6 @@
 
 #include "shared.h"
 
-
 union sockaddr_any {
 	struct sockaddr		sa;
 	struct sockaddr_in	sin;
@@ -265,11 +263,11 @@ static int client_connect(void)
 	 * from */
 	FT_CLOSE_FID(pep);
 
-	ret = check_address(&ep->fid, "fi_endpoint (ep)");
+	ret = ft_init_ep();
 	if (ret)
 		return ret;
 
-	ret = ft_init_ep();
+	ret = check_address(&ep->fid, "fi_endpoint (ep)");
 	if (ret)
 		return ret;
 
@@ -283,7 +281,7 @@ static int client_connect(void)
 	/* Wait for the connection to be established */
 	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
 	if (rd != sizeof entry) {
-		FT_PRINTERR("fi_eq_sread", rd);
+		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
 		return (int) rd;
 	}
 
@@ -434,7 +432,7 @@ static int run(void)
 		return ret;
 	}
 
-	ret = send_recv_greeting();
+	ret = send_recv_greeting(ep);
 
 	fi_shutdown(ep, 0);
 	return ret;
diff --git a/simple/poll.c b/simple/poll.c
index e7ea995..47c22f2 100644
--- a/simple/poll.c
+++ b/simple/poll.c
@@ -31,20 +31,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
 #include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
-#include <shared.h>
 
+#include <shared.h>
 
 #define MAX_POLL_CNT 10
 
-
 static int alloc_ep_res(struct fi_info *fi)
 {
 	struct fi_poll_attr poll_attr;
@@ -61,37 +56,44 @@ static int alloc_ep_res(struct fi_info *fi)
 		return ret;
 	}
 
-	ret = fi_poll_add(pollset, &txcq->fid, 0);
-	if (ret) {
-		FT_PRINTERR("fi_poll_add", ret);
-		return ret;
+	if (txcq) {
+		ret = fi_poll_add(pollset, &txcq->fid, 0);
+		if (ret)
+			goto err;
 	}
 
-	ret = fi_poll_add(pollset, &rxcq->fid, 0);
-	if (ret) {
-		FT_PRINTERR("fi_poll_add", ret);
-		return ret;
+	if (rxcq) {
+		ret = fi_poll_add(pollset, &rxcq->fid, 0);
+		if (ret)
+			goto err;
+	}
+
+	if (txcntr) {
+		ret = fi_poll_add(pollset, &txcntr->fid, 0);
+		if (ret)
+			goto err;
+	}
+
+	if (rxcntr) {
+		ret = fi_poll_add(pollset, &rxcntr->fid, 0);
+		if (ret)
+			goto err;
 	}
 
 	return 0;
+err:
+	FT_PRINTERR("fi_poll_add", ret);
+	return ret;
 }
 
 static int init_fabric(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	ret = ft_open_fabric_res();
 	if (ret)
 		return ret;
@@ -103,32 +105,27 @@ static int init_fabric(void)
 	ret = ft_init_ep();
 	if (ret)
 		return ret;
-
 	return 0;
 }
 
 static int send_recv()
 {
+	struct fid_cq *cq;
 	void *context[MAX_POLL_CNT];
 	struct fi_cq_entry comp;
 	int ret;
 	int ret_count = 0;
-	int i;
-
-//	fprintf(stdout, "Posting a recv...\n");
-//	ret = ft_post_rx(rx_size);
-//	if (ret)
-//		return ret;
+	int i, tx_cntr_done = 0, rx_cntr_done = 0;
 
 	fprintf(stdout, "Posting a send...\n");
-	ret = ft_post_tx(tx_size);
+	ret = ft_post_tx(ep, remote_fi_addr, tx_size, &tx_ctx);
 	if (ret)
 		return ret;
 
-	while ((tx_cq_cntr < tx_seq) || (rx_cq_cntr < rx_seq)) {
-		struct fid_cq *cq;
+	while ((txcq && (tx_cq_cntr < tx_seq)) || (rxcq && (rx_cq_cntr < rx_seq)) ||
+	       (txcntr && !tx_cntr_done) || (rxcntr && !rx_cntr_done)) {
 
-		/* Poll send and recv CQs */
+		/* Poll send and recv CQs/Cntrs */
 		do {
 			ret_count = fi_poll(pollset, context, MAX_POLL_CNT);
 			if (ret_count < 0) {
@@ -148,6 +145,30 @@ static int send_recv()
 				printf("Recv completion received\n");
 				cq = rxcq;
 				rx_cq_cntr++;
+			} else if (context[i] == &txcntr) {
+				printf("Send counter poll-event\n");
+				if (tx_cntr_done) {
+					printf("Invalid tx counter event\n");
+					return -1;
+				}
+
+				if (tx_seq == fi_cntr_read(txcntr)) {
+					printf("Send counter done\n");
+					tx_cntr_done = 1;
+				}
+				continue;
+			} else if (context[i] == &rxcntr) {
+				printf("Recv counter poll-event\n");
+				if (rx_cntr_done) {
+					printf("Invalid rx counter event\n");
+					return -1;
+				}
+
+				if (rx_seq == fi_cntr_read(rxcntr)) {
+					printf("Receive counter done\n");
+					rx_cntr_done = 1;
+				}
+				continue;
 			} else {
 				printf("Unknown completion received\n");
 				return -1;
@@ -195,15 +216,17 @@ int main(int argc, char **argv)
 	if (!hints)
 		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
+	while ((op = getopt(argc, argv, "h" ADDR_OPTS CS_OPTS INFO_OPTS)) != -1) {
 		switch (op) {
 		default:
 			ft_parse_addr_opts(op, optarg, &opts);
 			ft_parseinfo(op, optarg, hints);
+			ft_parsecsopts(op, optarg, &opts);
 			break;
 		case '?':
 		case 'h':
 			ft_usage(argv[0], "A client-server example that uses poll.\n");
+			FT_PRINT_OPTS_USAGE("-t <type>", "completion type [queue, counter]");
 			return EXIT_FAILURE;
 		}
 	}
diff --git a/simple/rdm.c b/simple/rdm.c
index b4bf98a..78959e5 100644
--- a/simple/rdm.c
+++ b/simple/rdm.c
@@ -30,64 +30,19 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 #include <shared.h>
 
-
-static int init_fabric(void)
-{
-	char *node, *service;
-	uint64_t flags = 0;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	/* Get fabric info */
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int ret;
 
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	return send_recv_greeting();
+	return send_recv_greeting(ep);
 }
 
 int main(int argc, char **argv)
diff --git a/simple/rdm_rma_simple.c b/simple/rdm_rma_simple.c
index ad4d2fc..fe0e106 100644
--- a/simple/rdm_rma_simple.c
+++ b/simple/rdm_rma_simple.c
@@ -31,67 +31,26 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <rdma/fabric.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_rma.h>
-#include <rdma/fi_cm.h>
+
 #include <rdma/fi_errno.h>
-#include <shared.h>
 
+#include <shared.h>
 
 struct fi_rma_iov local, remote;
 
 struct fi_context fi_ctx_write;
 struct fi_context fi_ctx_read;
 
-static int init_fabric(void)
-{
-	char *node, *service;
-	uint64_t flags = 0;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run_test(void)
 {
 	int ret = 0;
 	const char *message = "Hello from Client!";
 	size_t message_len = strlen(message) + 1;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
-	if (ret)
-		return ret;
 	if (opts.dst_addr) {
 		fprintf(stdout, "RMA write to server\n");
 		if (snprintf(tx_buf, tx_size, "%s", message) >= tx_size) {
diff --git a/simple/rdm_rma_trigger.c b/simple/rdm_rma_trigger.c
index e8f9529..ad3f9cd 100644
--- a/simple/rdm_rma_trigger.c
+++ b/simple/rdm_rma_trigger.c
@@ -31,93 +31,30 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <rdma/fabric.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_rma.h>
-#include <rdma/fi_cm.h>
+
 #include <rdma/fi_errno.h>
 #include <rdma/fi_trigger.h>
-#include <shared.h>
 
+#include <shared.h>
 
 struct fi_triggered_context triggered_ctx;
 
 static char *welcome_text1 = "Hello1 from Client!";
 static char *welcome_text2 = "Hello2 from Client!";
 
-static int rma_write(void *src, size_t size,
-		     void *context, uint64_t flags)
-{
-	int ret;
-	struct fi_msg_rma msg;
-	struct iovec msg_iov;
-	struct fi_rma_iov rma_iov;
-	void *desc = fi_mr_desc(mr);
-
-	msg_iov.iov_base = src;
-	msg_iov.iov_len = size;
-
-	rma_iov.addr = 0;
-	rma_iov.len = size;
-	rma_iov.key = FT_MR_KEY;
-
-	msg.msg_iov = &msg_iov;
-	msg.desc = &desc;
-	msg.iov_count = 1;
-	msg.rma_iov_count = 1;
-	msg.addr = remote_fi_addr;
-	msg.rma_iov = &rma_iov;
-	msg.context = context;
-
-	ret = fi_writemsg(ep, &msg, flags);
- 	if (ret){
- 		FT_PRINTERR("fi_write", ret);
- 		return ret;
-	}
-	return 0;
- }
-
 static int rma_write_trigger(void *src, size_t size,
 			     struct fid_cntr *cntr, size_t threshold)
 {
+	int ret;
 	triggered_ctx.event_type = FI_TRIGGER_THRESHOLD;
 	triggered_ctx.trigger.threshold.cntr = cntr;
 	triggered_ctx.trigger.threshold.threshold = threshold;
-	return rma_write(src, size, &triggered_ctx, FI_TRIGGER);
-}
-
-static int init_fabric(void)
-{
-	char *node, *service;
-	uint64_t flags = 0;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
+	ret = fi_write(alias_ep, src, size, fi_mr_desc(mr), remote_fi_addr, 0,
+			FT_MR_KEY, &triggered_ctx);
+ 	if (ret){
+ 		FT_PRINTERR("fi_write", ret);
+ 		return ret;
 	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
 	return 0;
 }
 
@@ -125,11 +62,11 @@ static int run_test(void)
 {
 	int ret = 0;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
+	ret = ft_init_alias_ep(FI_TRANSMIT | FI_TRIGGER);
 	if (ret)
 		return ret;
 
@@ -143,10 +80,13 @@ static int run_test(void)
 			goto out;
 
 		fprintf(stdout, "RMA write to server\n");
-		ret = rma_write(tx_buf, strlen(welcome_text1), &tx_ctx, 0);
-		if (ret)
-			goto out;
-
+		ret = fi_write(ep, tx_buf, strlen(welcome_text1), fi_mr_desc(mr),
+				remote_fi_addr, 0, FT_MR_KEY, &tx_ctx);
+ 		if (ret){
+ 			FT_PRINTERR("fi_write", ret);
+ 			goto out;
+		}
+		/* The value of the counter is 3 including a transfer during init_av */
 		ret = fi_cntr_wait(txcntr, 3, -1);
 		if (ret < 0) {
 			FT_PRINTERR("fi_cntr_wait", ret);
@@ -155,6 +95,7 @@ static int run_test(void)
 
 		fprintf(stdout, "Received completion events for RMA write operations\n");
 	} else {
+		/* The value of the counter is 3 including a transfer during init_av */
 		ret = fi_cntr_wait(rxcntr, 3, -1);
 		if (ret < 0) {
 			FT_PRINTERR("fi_cntr_wait", ret);
@@ -191,7 +132,7 @@ int main(int argc, char **argv)
 			break;
 		case '?':
 		case 'h':
-			ft_usage(argv[0], "A simple RDM client-sever Triggered RMA example.");
+			ft_usage(argv[0], "A simple RDM client-sever triggered RMA example with alias ep.");
 			return EXIT_FAILURE;
 		}
 	}
diff --git a/simple/rdm_shared_av.c b/simple/rdm_shared_av.c
index 80313c5..09d59e5 100644
--- a/simple/rdm_shared_av.c
+++ b/simple/rdm_shared_av.c
@@ -32,51 +32,41 @@
 #include <stdlib.h>
 #include <getopt.h>
 #include <unistd.h>
-#include <sys/types.h>
 #include <string.h>
 
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 
 static int init_fabric(void)
 {
-	char *node, *service;
-	uint64_t flags = 0;
 	int ret;
+	int ret2;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	/* Get fabric info */
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	ret = ft_open_fabric_res();
 	if (ret)
 		return ret;
 
 	if (opts.dst_addr && !ft_parent_proc) {
 		/* child waits until parent is done creating AV */
-		ret = ft_sync_pair(FI_SUCCESS);
-
-		if (ret)
-			return ret;
+		ret2 = ft_sync_pair(FI_SUCCESS);
+		if (ret2)
+			return ret2;
 
 		/* child needs to open AV in read only mode */
 		av_attr.flags = FI_READ;
 	}
-	ret = ft_alloc_active_res(fi);
 
+	ret = ft_alloc_active_res(fi);
 	if (opts.dst_addr && ft_parent_proc) {
 		/* parent lets the child know its status */
-		ret = ft_sync_pair(ret);
+		ret2 = ft_sync_pair(ret);
+		if (ret2)
+			return ret2;
 	}
 
 	/* handle the failed alloc_active_res call */
@@ -99,7 +89,7 @@ static int send_recv()
 			return -FI_ETOOSMALL;
 		}
 
-		ret = ft_tx(message_len);
+		ret = ft_tx(ep, remote_fi_addr, message_len, &tx_ctx);
 		if (ret)
 			return ret;
 
@@ -124,6 +114,7 @@ static int send_recv()
 static int run(void)
 {
 	int ret;
+	int ret2;
 
 	ret = init_fabric();
 	if (ret)
@@ -134,17 +125,18 @@ static int run(void)
 			/* parent inits AV and lets child proceed,
 			 * and itself returns without sending a message */
 			ret = ft_init_av();
-
-			ret = ft_sync_pair(ret);
+			ret2 = ft_sync_pair(ret);
+			if (ret2)
+				return ret2;
 
 			/* parent doesn't run the send_recv loop,
 			 * it waits for the child until it is done
 			 * with send_recv */
 			return ret;
 		} else {
-			ret = ft_sync_pair(FI_SUCCESS);
-			if (ret)
-				return ret;
+			ret2 = ft_sync_pair(FI_SUCCESS);
+			if (ret2)
+				return ret2;
 
 			remote_fi_addr = ((fi_addr_t *)av_attr.map_addr)[0];
 		}
@@ -186,12 +178,15 @@ int main(int argc, char **argv)
 		opts.dst_addr = argv[optind];
 
 	if (opts.dst_addr) {
+		if (!opts.av_name)
+			opts.av_name = "client_av";
+
 		ret = ft_fork_and_pair();
 		if (ret)
 			return ret;
-
+	} else {
 		if (!opts.av_name)
-			opts.av_name = "foo";
+			opts.av_name = "server_av";
 	}
 
 	hints->ep_attr->type	= FI_EP_RDM;
diff --git a/simple/rdm_shared_ctx.c b/simple/rdm_shared_ctx.c
deleted file mode 100644
index b00c15f..0000000
--- a/simple/rdm_shared_ctx.c
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
- *
- * This software is available to you under the BSD license
- * below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <rdma/fabric.h>
-#include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
-#include <shared.h>
-
-
-static int ep_cnt = 2;
-static struct fid_ep **ep_array, *srx_ctx;
-static struct fid_stx *stx_ctx;
-static void *local_addr, *remote_addr;
-static size_t addrlen = 0;
-static fi_addr_t *addr_array;
-
-
-static int send_msg(int size)
-{
-	int ret;
-
-	ret = fi_send(ep_array[0], buf, (size_t) size, fi_mr_desc(mr),
-			addr_array[0], &tx_ctx);
-	if (ret) {
-		FT_PRINTERR("fi_send", ret);
-		return ret;
-	}
-
-	ret = ft_get_tx_comp(++tx_seq);
-	return ret;
-}
-
-static int recv_msg(void)
-{
-	int ret;
-
-	ret = fi_recv(srx_ctx, buf, rx_size, fi_mr_desc(mr), 0, &rx_ctx);
-	if (ret) {
-		FT_PRINTERR("fi_recv", ret);
-		return ret;
-	}
-
-	ret = ft_get_rx_comp(++rx_seq);
-	return ret;
-}
-
-static int alloc_ep_res(struct fi_info *fi)
-{
-	struct fi_rx_attr rx_attr;
-	struct fi_tx_attr tx_attr;
-	int i, ret = 0;
-
-	addr_array = calloc(ep_cnt, sizeof(*addr_array));
-	if (!addr_array) {
-		perror("malloc");
-		return -FI_ENOMEM;
-	}
-
-	av_attr.count = ep_cnt;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	/* TODO: avoid allocating EP when EP array is used. */
-	FT_CLOSE_FID(ep);
-
-	memset(&tx_attr, 0, sizeof tx_attr);
-	memset(&rx_attr, 0, sizeof rx_attr);
-
-	ret = fi_stx_context(domain, &tx_attr, &stx_ctx, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_stx_context", ret);
-		return ret;
-	}
-
-	ret = fi_srx_context(domain, &rx_attr, &srx_ctx, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_srx_context", ret);
-		return ret;
-	}
-
-	ep_array = calloc(ep_cnt, sizeof(*ep_array));
-	if (!ep_array) {
-		perror("malloc");
-		return ret;
-	}
-	for (i = 0; i < ep_cnt; i++) {
-		ret = fi_endpoint(domain, fi, &ep_array[i], NULL);
-		if (ret) {
-			FT_PRINTERR("fi_endpoint", ret);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int bind_ep_res(void)
-{
-	int i, ret = 0;
-
-	for (i = 0; i < ep_cnt; i++) {
-		ret = fi_ep_bind(ep_array[i], &stx_ctx->fid, 0);
-		if (ret) {
-			FT_PRINTERR("fi_ep_bind", ret);
-			return ret;
-		}
-
-		ret = fi_ep_bind(ep_array[i], &srx_ctx->fid, 0);
-		if (ret) {
-			FT_PRINTERR("fi_ep_bind", ret);
-			return ret;
-		}
-
-		ret = fi_ep_bind(ep_array[i], &txcq->fid, FI_SEND);
-		if (ret) {
-			FT_PRINTERR("fi_ep_bind", ret);
-			return ret;
-		}
-
-		ret = fi_ep_bind(ep_array[i], &rxcq->fid, FI_RECV);
-		if (ret) {
-			FT_PRINTERR("fi_ep_bind", ret);
-			return ret;
-		}
-
-		ret = fi_ep_bind(ep_array[i], &av->fid, 0);
-		if (ret) {
-			FT_PRINTERR("fi_ep_bind", ret);
-			return ret;
-		}
-
-		ret = fi_enable(ep_array[i]);
-		if (ret) {
-			FT_PRINTERR("fi_enable", ret);
-			return ret;
-		}
-	}
-
-	return ret;
-}
-
-static int run_test()
-{
-	int ret, i;
-
-	/* Post recvs */
-	for (i = 0; i < ep_cnt; i++) {
-		fprintf(stdout, "Posting recv for ctx: %d\n", i);
-		ret = fi_recv(srx_ctx, rx_buf, rx_size, fi_mr_desc(mr),
-				FI_ADDR_UNSPEC, NULL);
-		if (ret) {
-			FT_PRINTERR("fi_recv", ret);
-			return ret;
-		}
-		rx_seq++;
-	}
-
-	if (opts.dst_addr) {
-		/* Post sends addressed to remote EPs */
-		for (i = 0; i < ep_cnt; i++) {
-			fprintf(stdout, "Posting send to remote ctx: %d\n", i);
-			ret = fi_send(ep_array[i], tx_buf, tx_size, fi_mr_desc(mr),
-					addr_array[i], NULL);
-			if (ret) {
-				FT_PRINTERR("fi_send", ret);
-				return ret;
-			}
-
-			ret = ft_get_tx_comp(++tx_seq);
-			if (ret)
-				return ret;
-		}
-	}
-
-	/* Wait for recv completions */
-	ret = ft_get_rx_comp(rx_seq);
-	if (ret)
-		return ret;
-
-	if (!opts.dst_addr) {
-		/* Post sends addressed to remote EPs */
-		for (i = 0; i < ep_cnt; i++) {
-			fprintf(stdout, "Posting send to remote ctx: %d\n", i);
-			ret = fi_send(ep_array[i], tx_buf, tx_size, fi_mr_desc(mr),
-					addr_array[i], NULL);
-			if (ret) {
-				FT_PRINTERR("fi_send", ret);
-				return ret;
-			}
-
-			ret = ft_get_tx_comp(++tx_seq);
-			if (ret)
-				return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	/* Check the number of EPs supported by the provider */
-	if (ep_cnt > fi->domain_attr->ep_cnt) {
-		ep_cnt = fi->domain_attr->ep_cnt;
-		fprintf(stderr, "Provider can support only %d of EPs\n", ep_cnt);
-	}
-
-	/* Get remote address */
-	if (opts.dst_addr) {
-		addrlen = fi->dest_addrlen;
-		remote_addr = malloc(addrlen * ep_cnt);
-		memcpy(remote_addr, fi->dest_addr, addrlen);
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	fi->ep_attr->tx_ctx_cnt = FI_SHARED_CONTEXT;
-	fi->ep_attr->rx_ctx_cnt = FI_SHARED_CONTEXT;
-
-	ret = alloc_ep_res(fi);
-	if (ret)
-		return ret;
-
-	ret = bind_ep_res();
-	if (ret)
-		return ret;
-
-	/* Post recv */
-	ret = fi_recv(srx_ctx, buf, rx_size, fi_mr_desc(mr), 0, &rx_ctx);
-	if (ret) {
-		FT_PRINTERR("fi_recv", ret);
-		return ret;
-	}
-
-	return 0;
-}
-
-static int init_av(void)
-{
-	int ret;
-	int i;
-
-	/* Get local address blob. Find the addrlen first. We set addrlen
-	 * as 0 and fi_getname will return the actual addrlen. */
-	addrlen = 0;
-	ret = fi_getname(&ep_array[0]->fid, local_addr, &addrlen);
-	if (ret != -FI_ETOOSMALL) {
-		FT_PRINTERR("fi_getname", ret);
-		return ret;
-	}
-
-	if (ep_cnt <= 0) {
-		fprintf(stderr, "ep_cnt needs to be greater than 0\n");
-		return -EXIT_FAILURE;
-	}
-	local_addr = malloc(addrlen * ep_cnt);
-
-	/* Get local addresses for all EPs */
-	for (i = 0; i < ep_cnt; i++) {
-		ret = fi_getname(&ep_array[i]->fid, local_addr + addrlen * i, &addrlen);
-		if (ret) {
-			FT_PRINTERR("fi_getname", ret);
-			return ret;
-		}
-	}
-
-	if (opts.dst_addr) {
-		ret = ft_av_insert(av, remote_addr, 1, &addr_array[0], 0, NULL);
-		if (ret)
-			return ret;
-
-		/* Send local EP addresses to one of the remote endpoints */
-		memcpy(buf, &addrlen, sizeof(size_t));
-		memcpy(buf + sizeof(size_t), local_addr, addrlen * ep_cnt);
-		ret = send_msg(sizeof(size_t) + addrlen * ep_cnt);
-		if (ret)
-			return ret;
-
-		/* Get remote EP addresses */
-		ret = recv_msg();
-		if (ret)
-			return ret;
-
-		memcpy(&addrlen, buf, sizeof(size_t));
-		memcpy(remote_addr, buf + sizeof(size_t), addrlen * ep_cnt);
-
-		/* Insert remote addresses into AV
-		 * Skip the first address since we already have it in AV */
-		ret = ft_av_insert(av, remote_addr + addrlen, ep_cnt - 1,
-				addr_array + 1, 0, NULL);
-		if (ret)
-			return ret;
-
-		/* Send ACK */
-		ret = send_msg(16);
-		if (ret)
-			return ret;
-
-	} else {
-		/* Get remote EP addresses */
-		ret = recv_msg();
-		if (ret)
-			return ret;
-
-		memcpy(&addrlen, buf, sizeof(size_t));
-		remote_addr = malloc(addrlen * ep_cnt);
-		memcpy(remote_addr, buf + sizeof(size_t), addrlen * ep_cnt);
-
-		/* Insert remote addresses into AV */
-		ret = ft_av_insert(av, remote_addr, ep_cnt, addr_array, 0, NULL);
-		if (ret)
-			return ret;
-
-		/* Send local EP addresses to one of the remote endpoints */
-		memcpy(buf, &addrlen, sizeof(size_t));
-		memcpy(buf + sizeof(size_t), local_addr, addrlen * ep_cnt);
-		ret = send_msg(sizeof(size_t) + addrlen * ep_cnt);
-		if (ret)
-			return ret;
-
-		/* Receive ACK from client */
-		ret = recv_msg();
-		if (ret)
-			return ret;
-	}
-
-	free(local_addr);
-	free(remote_addr);
-	return 0;
-}
-
-static int run(void)
-{
-	int ret = 0;
-
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = init_av();
-	if (ret)
-		goto out;
-
-	ret = run_test();
-
-	/* TODO: Add a local finalize applicable to shared ctx */
-	//ft_finalize(fi, ep_array[0], txcq, rxcq, addr_array[0]);
-out:
-	return ret;
-}
-
-int main(int argc, char **argv)
-{
-	int op, ret;
-
-	opts = INIT_OPTS;
-	opts.options |= FT_OPT_SIZE;
-
-	hints = fi_allocinfo();
-	if (!hints)
-		return EXIT_FAILURE;
-
-	while ((op = getopt(argc, argv, "h" ADDR_OPTS INFO_OPTS)) != -1) {
-		switch (op) {
-		default:
-			ft_parse_addr_opts(op, optarg, &opts);
-			ft_parseinfo(op, optarg, hints);
-			break;
-		case '?':
-		case 'h':
-			ft_usage(argv[0], "An RDM client-server example that uses shared context.\n");
-			return EXIT_FAILURE;
-		}
-	}
-
-	if (optind < argc)
-		opts.dst_addr = argv[optind];
-
-	hints->ep_attr->type = FI_EP_RDM;
-	hints->caps = FI_MSG | FI_NAMED_RX_CTX;
-	hints->mode = FI_CONTEXT | FI_LOCAL_MR;
-
-	ret = run();
-
-	FT_CLOSEV_FID(ep_array, ep_cnt);
-	FT_CLOSE_FID(srx_ctx);
-	FT_CLOSE_FID(stx_ctx);
-	ft_free_res();
-	free(addr_array);
-	free(ep_array);
-	return -ret;
-}
diff --git a/simple/rdm_tagged_peek.c b/simple/rdm_tagged_peek.c
index 5521396..ca33c24 100644
--- a/simple/rdm_tagged_peek.c
+++ b/simple/rdm_tagged_peek.c
@@ -31,49 +31,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <inttypes.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 #include <rdma/fi_tagged.h>
-#include <shared.h>
-
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
+#include <shared.h>
 
 static int tagged_peek(uint64_t tag)
 {
@@ -105,11 +67,7 @@ static int run(void)
 {
 	int ret;
 
-	ret = init_fabric();
-	if (ret)
-		return ret;
-
-	ret = ft_init_av();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
@@ -200,7 +158,7 @@ int main(int argc, char **argv)
 
 	hints->rx_attr->total_buffered_recv = 1024;
 	hints->ep_attr->type = FI_EP_RDM;
-	hints->caps = FI_MSG | FI_TAGGED;
+	hints->caps = FI_TAGGED;
 	hints->mode = FI_CONTEXT | FI_LOCAL_MR;
 
 	ret = run();
diff --git a/simple/scalable_ep.c b/simple/scalable_ep.c
index b6d1979..77b2e83 100644
--- a/simple/scalable_ep.c
+++ b/simple/scalable_ep.c
@@ -29,19 +29,13 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
-#include <shared.h>
-#include <math.h>
 
+#include <shared.h>
 
 static int ctx_cnt = 2;
 static int rx_ctx_bits = 0;
@@ -51,7 +45,6 @@ static struct fid_cq **txcq_array;
 static struct fid_cq **rxcq_array;
 static fi_addr_t *remote_rx_addr;
 
-
 static void free_res(void)
 {
 	if (rx_ep) {
@@ -81,8 +74,7 @@ static int alloc_ep_res(struct fid_ep *sep)
 	int i, ret;
 
 	/* Get number of bits needed to represent ctx_cnt */
-	while (ctx_cnt >> ++rx_ctx_bits)
-		;
+	while (ctx_cnt >> ++rx_ctx_bits);
 
 	av_attr.rx_ctx_bits = rx_ctx_bits;
 
@@ -118,7 +110,7 @@ static int alloc_ep_res(struct fid_ep *sep)
 
 		ret = fi_rx_context(sep, i, NULL, &rx_ep[i], NULL);
 		if (ret) {
-			FT_PRINTERR("fi_tx_context", ret);
+			FT_PRINTERR("fi_rx_context", ret);
 			return ret;
 		}
 
@@ -138,7 +130,7 @@ static int bind_ep_res(void)
 
 	ret = fi_scalable_ep_bind(sep, &av->fid, 0);
 	if (ret) {
-		FT_PRINTERR("fi_ep_bind", ret);
+		FT_PRINTERR("fi_scalable_ep_bind", ret);
 		return ret;
 	}
 
@@ -177,6 +169,12 @@ static int bind_ep_res(void)
 		}
 	}
 
+	ret = fi_enable(sep);
+	if (ret) {
+		FT_PRINTERR("fi_enable", ret);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -225,20 +223,12 @@ static int run_test()
 
 static int init_fabric(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	/* Check the optimal number of TX and RX contexts supported by the provider */
 	ctx_cnt = MIN(ctx_cnt, fi->domain_attr->tx_ctx_cnt);
 	ctx_cnt = MIN(ctx_cnt, fi->domain_attr->rx_ctx_cnt);
diff --git a/simple/shared_ctx.c b/simple/shared_ctx.c
new file mode 100644
index 0000000..7a121c3
--- /dev/null
+++ b/simple/shared_ctx.c
@@ -0,0 +1,694 @@
+/*
+ * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This software is available to you under the BSD license
+ * below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#include <rdma/fi_errno.h>
+#include <rdma/fi_endpoint.h>
+#include <rdma/fi_cm.h>
+
+#include <shared.h>
+
+enum {
+	FT_UNSPEC,
+	FT_EP_CNT,
+};
+
+enum ft_ep_state {
+	FT_EP_STATE_INIT,
+	FT_EP_CONNECT_RCVD,
+	FT_EP_CONNECTING,
+	FT_EP_CONNECTED,
+};
+
+struct ep_info {
+	struct fid_ep *ep;
+	struct fi_info *fi;
+	enum ft_ep_state state;
+};
+
+static struct fi_info *fi_dup;
+static int tx_shared_ctx = 1;
+static int rx_shared_ctx = 1;
+static int ep_cnt = 4;
+static struct fid_ep **ep_array, *srx_ctx;
+static struct fid_stx *stx_ctx;
+static char *local_addr, *remote_addr;
+static size_t addrlen = 0;
+static fi_addr_t *addr_array;
+
+static int get_dupinfo(void)
+{
+	struct fi_info *hints_dup;
+	int ret;
+
+       /* Get a fi_info corresponding to a wild card port. The first endpoint
+	* should use default/given port since that is what is known to both
+	* client and server. For other endpoints we should use addresses with
+	* random ports to avoid collision. fi_getinfo should return a random
+	* port if we don't specify it in the service arg or the hints. This
+	* is used only for non-MSG endpoints. */
+
+	hints_dup = fi_dupinfo(hints);
+	if (!hints_dup)
+		return -FI_ENOMEM;
+
+	free(hints_dup->src_addr);
+	free(hints_dup->dest_addr);
+	hints_dup->src_addr = NULL;
+	hints_dup->dest_addr = NULL;
+	hints_dup->src_addrlen = 0;
+	hints_dup->dest_addrlen = 0;
+
+	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints_dup, &fi_dup);
+	if (ret)
+		FT_PRINTERR("fi_getinfo", ret);
+	fi_freeinfo(hints_dup);
+	return ret;
+}
+
+static int alloc_ep(void)
+{
+	int i, ret;
+
+	ep_array = calloc(ep_cnt, sizeof(*ep_array));
+	if (!ep_array)
+		return -FI_ENOMEM;
+
+	ret = fi_endpoint(domain, fi, &ep_array[0], NULL);
+	if (ret) {
+		FT_PRINTERR("fi_endpoint", ret);
+		return ret;
+	}
+
+	for (i = 1; i < ep_cnt; i++) {
+		if (hints->ep_attr->type == FI_EP_MSG)
+			ret = fi_endpoint(domain, fi, &ep_array[i], NULL);
+		else
+			ret = fi_endpoint(domain, fi_dup, &ep_array[i], NULL);
+		if (ret) {
+			FT_PRINTERR("fi_endpoint", ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int alloc_ep_res(struct fi_info *fi)
+{
+	int ret;
+
+	ret = ft_alloc_active_res(fi);
+	if (ret)
+		return ret;
+
+	if (tx_shared_ctx) {
+		ret = fi_stx_context(domain, fi->tx_attr, &stx_ctx, NULL);
+		if (ret) {
+			FT_PRINTERR("fi_stx_context", ret);
+			return ret;
+		}
+	}
+
+	if (rx_shared_ctx) {
+		ret = fi_srx_context(domain, fi->rx_attr, &srx_ctx, NULL);
+		if (ret) {
+			FT_PRINTERR("fi_srx_context", ret);
+			return ret;
+		}
+	}
+	return 0;
+}
+
+static int bind_ep_res(struct fid_ep *ep)
+{
+	int ret;
+
+	if (hints->ep_attr->type == FI_EP_MSG)
+		FT_EP_BIND(ep, eq, 0);
+
+	if (tx_shared_ctx)
+		FT_EP_BIND(ep, stx_ctx, 0);
+
+	if (rx_shared_ctx)
+		FT_EP_BIND(ep, srx_ctx, 0);
+
+	FT_EP_BIND(ep, txcq, FI_SEND);
+	FT_EP_BIND(ep, rxcq, FI_RECV);
+	FT_EP_BIND(ep, av, 0);
+
+	ret = fi_enable(ep);
+	if (ret) {
+		FT_PRINTERR("fi_enable", ret);
+		return ret;
+	}
+	return 0;
+}
+
+static int bind_ep_array_res(void)
+{
+	int i, ret;
+	for (i = 0; i < ep_cnt; i++) {
+		ret = bind_ep_res(ep_array[i]);
+		if (ret)
+			return ret;
+	}
+	return 0;
+}
+
+static int run_test()
+{
+	int ret, i;
+
+	if (!(tx_ctx_arr = calloc(ep_cnt, sizeof *tx_ctx_arr)))
+		return -FI_ENOMEM;
+
+	if (!(rx_ctx_arr = calloc(ep_cnt, sizeof *rx_ctx_arr)))
+		return -FI_ENOMEM;
+
+	/* Post recvs */
+	for (i = 0; i < ep_cnt; i++) {
+		if (rx_shared_ctx) {
+			fprintf(stdout, "Posting recv #%d for shared rx ctx\n", i);
+			ret = ft_post_rx(srx_ctx, rx_size, &rx_ctx_arr[i]);
+		 } else {
+			fprintf(stdout, "Posting recv for endpoint #%d\n", i);
+			ret = ft_post_rx(ep_array[i], rx_size, &rx_ctx_arr[i]);
+		 }
+		if (ret)
+			return ret;
+	}
+
+	if (opts.dst_addr) {
+		/* Post sends addressed to remote EPs */
+		for (i = 0; i < ep_cnt; i++) {
+			if (tx_shared_ctx)
+				fprintf(stdout, "Posting send #%d to shared tx ctx\n", i);
+			else
+				fprintf(stdout, "Posting send to endpoint #%d\n", i);
+			ret = ft_tx(ep_array[i], addr_array[i], tx_size, &tx_ctx_arr[i]);
+			if (ret)
+				return ret;
+		}
+	}
+
+	/* Wait for recv completions */
+	ret = ft_get_rx_comp(rx_seq - 1);
+	if (ret)
+		return ret;
+
+	if (!opts.dst_addr) {
+		/* Post sends addressed to remote EPs */
+		for (i = 0; i < ep_cnt; i++) {
+			if (tx_shared_ctx)
+				fprintf(stdout, "Posting send #%d to shared tx ctx\n", i);
+			else
+				fprintf(stdout, "Posting send to endpoint #%d\n", i);
+			ret = ft_tx(ep_array[i], addr_array[i], tx_size, &tx_ctx_arr[i]);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int init_av(void)
+{
+	int ret;
+	int i;
+
+	/* Get local address blob. Find the addrlen first. We set addrlen
+	 * as 0 and fi_getname will return the actual addrlen. */
+	addrlen = 0;
+	ret = fi_getname(&ep_array[0]->fid, local_addr, &addrlen);
+	if (ret != -FI_ETOOSMALL) {
+		FT_PRINTERR("fi_getname", ret);
+		return ret;
+	}
+
+	local_addr = malloc(addrlen * ep_cnt);
+	remote_addr = malloc(addrlen * ep_cnt);
+
+	/* Get local addresses for all EPs */
+	for (i = 0; i < ep_cnt; i++) {
+		ret = fi_getname(&ep_array[i]->fid, local_addr + addrlen * i, &addrlen);
+		if (ret) {
+			FT_PRINTERR("fi_getname", ret);
+			return ret;
+		}
+	}
+
+	if (opts.dst_addr) {
+		memcpy(remote_addr, fi->dest_addr, addrlen);
+
+		ret = ft_av_insert(av, remote_addr, 1, &addr_array[0], 0, NULL);
+		if (ret)
+			return ret;
+
+		/* Send local EP addresses to one of the remote endpoints */
+		memcpy(tx_buf + ft_tx_prefix_size(), &addrlen, sizeof(size_t));
+		memcpy(tx_buf + ft_tx_prefix_size() + sizeof(size_t),
+				local_addr, addrlen * ep_cnt);
+		ret = ft_tx(ep_array[0], addr_array[0],
+				sizeof(size_t) + addrlen * ep_cnt, &tx_ctx);
+		if (ret)
+			return ret;
+
+		/* Get remote EP addresses */
+		if (rx_shared_ctx)
+			ret = ft_rx(srx_ctx, rx_size);
+		else
+			ret = ft_rx(ep_array[0], rx_size);
+		if (ret)
+			return ret;
+
+		memcpy(&addrlen, rx_buf + ft_rx_prefix_size(), sizeof(size_t));
+		memcpy(remote_addr, rx_buf + ft_rx_prefix_size() + sizeof(size_t),
+				addrlen * ep_cnt);
+
+		/* Insert remote addresses into AV
+		 * Skip the first address since we already have it in AV */
+		ret = ft_av_insert(av, remote_addr + addrlen, ep_cnt - 1,
+				addr_array + 1, 0, NULL);
+		if (ret)
+			return ret;
+
+		/* Send ACK */
+		ret = ft_tx(ep_array[0], addr_array[0], 1, &tx_ctx);
+		if (ret)
+			return ret;
+
+	} else {
+		/* Get remote EP addresses */
+		if (rx_shared_ctx)
+			ret = ft_rx(srx_ctx, rx_size);
+		else
+			ret = ft_rx(ep_array[0], rx_size);
+		if (ret)
+			return ret;
+
+		memcpy(&addrlen, rx_buf + ft_rx_prefix_size(), sizeof(size_t));
+		remote_addr = malloc(addrlen * ep_cnt);
+		memcpy(remote_addr, rx_buf + ft_rx_prefix_size() + sizeof(size_t),
+				addrlen * ep_cnt);
+
+		/* Insert remote addresses into AV */
+		ret = ft_av_insert(av, remote_addr, ep_cnt, addr_array, 0, NULL);
+		if (ret)
+			return ret;
+
+		/* Send local EP addresses to one of the remote endpoints */
+		memcpy(tx_buf + ft_tx_prefix_size(), &addrlen, sizeof(size_t));
+		memcpy(tx_buf + ft_tx_prefix_size() + sizeof(size_t),
+				local_addr, addrlen * ep_cnt);
+		ret = ft_tx(ep_array[0], addr_array[0],
+				sizeof(size_t) + addrlen * ep_cnt, &tx_ctx);
+		if (ret)
+			return ret;
+
+		/* Receive ACK from client */
+		if (rx_shared_ctx)
+			ret = ft_rx(srx_ctx, rx_size);
+		else
+			ret = ft_rx(ep_array[0], rx_size);
+		if (ret)
+			return ret;
+	}
+
+	free(local_addr);
+	free(remote_addr);
+	return 0;
+}
+
+static int init_fabric(void)
+{
+	int ret;
+
+	ret = ft_getinfo(hints, &fi);
+	if (ret)
+		return ret;
+
+	ret = get_dupinfo();
+	if (ret)
+		return ret;
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		return ret;
+
+	av_attr.count = ep_cnt;
+
+	ret = alloc_ep_res(fi);
+	if (ret)
+		return ret;
+
+	ret = alloc_ep();
+	if (ret)
+		return ret;
+
+	ret = bind_ep_array_res();
+	if (ret)
+		return ret;
+
+	/* Post recv */
+	if (rx_shared_ctx)
+		ret = ft_post_rx(srx_ctx, MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	else
+		ret = ft_post_rx(ep_array[0], MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	if (ret)
+		return ret;
+
+	ret = init_av();
+	return ret;
+}
+
+static int client_connect(void)
+{
+	struct fi_eq_cm_entry entry;
+	uint32_t event;
+	ssize_t rd;
+	int i, ret;
+
+	ret = ft_getinfo(hints, &fi);
+	if (ret)
+		return ret;
+
+	ret = get_dupinfo();
+	if (ret)
+		return ret;
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		return ret;
+
+	ret = alloc_ep_res(fi);
+	if (ret)
+		return ret;
+
+	ret = alloc_ep();
+	if (ret)
+		return ret;
+
+	ret = bind_ep_array_res();
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ep_cnt; i++) {
+		ret = fi_connect(ep_array[i], fi->dest_addr, NULL, 0);
+		if (ret) {
+			FT_PRINTERR("fi_connect", ret);
+			return ret;
+		}
+
+		rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
+		if (rd != sizeof entry) {
+			FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
+			ret = (int) rd;
+			return ret;
+		}
+
+		if (event != FI_CONNECTED || entry.fid != &ep_array[i]->fid) {
+			fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
+				event, entry.fid, ep);
+			ret = -FI_EOTHER;
+			return ret;
+		}
+	}
+
+	/* Post recv */
+	if (rx_shared_ctx)
+		ret = ft_post_rx(srx_ctx, MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	else
+		ret = ft_post_rx(ep_array[0], MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static int server_connect(void)
+{
+	struct fi_eq_cm_entry entry;
+	uint32_t event;
+	ssize_t rd;
+	int ret, k;
+	int num_conn_reqs = 0, num_connected = 0;
+	struct ep_info *ep_state_array = NULL;
+
+	ep_array = calloc(ep_cnt, sizeof(*ep_array));
+	if (!ep_array)
+		return -FI_ENOMEM;
+
+	ep_state_array = calloc(ep_cnt, sizeof(*ep_state_array));
+	if (!ep_state_array)
+		return -FI_ENOMEM;
+
+	while (num_connected != ep_cnt) {
+		rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
+		if (rd != sizeof entry) {
+			FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "cm-event");
+			ret = (int) rd;
+			goto err;
+		}
+
+		switch(event) {
+		case FI_CONNREQ:
+			if (num_conn_reqs == ep_cnt) {
+				fprintf(stderr, "Unexpected CM event %d\n", event);
+				ret = -FI_EOTHER;
+				goto err;
+			}
+			fi = ep_state_array[num_conn_reqs].fi = entry.info;
+			ep_state_array[num_conn_reqs].state = FT_EP_CONNECT_RCVD;
+
+			if (num_conn_reqs == 0) {
+				ret = fi_domain(fabric, fi, &domain, NULL);
+				if (ret) {
+					FT_PRINTERR("fi_domain", ret);
+					goto err;
+				}
+
+				ret = alloc_ep_res(fi);
+				if (ret)
+					goto err;
+			}
+
+			ret = fi_endpoint(domain, fi, &ep_array[num_conn_reqs], NULL);
+			if (ret) {
+				FT_PRINTERR("fi_endpoint", ret);
+				goto err;
+			}
+
+			ep_state_array[num_conn_reqs].ep = ep_array[num_conn_reqs];
+			ret = bind_ep_res(ep_array[num_conn_reqs]);
+			if (ret)
+				goto err;
+
+			ret = fi_accept(ep_array[num_conn_reqs], NULL, 0);
+			if (ret) {
+				FT_PRINTERR("fi_accept", ret);
+				goto err;
+			}
+
+			ep_state_array[num_conn_reqs].state = FT_EP_CONNECTING;
+			num_conn_reqs++;
+			break;
+
+		case FI_CONNECTED:
+			if (num_conn_reqs <= num_connected) {
+				ret = -FI_EOTHER;
+				goto err;
+			}
+
+			for (k = 0; k < num_conn_reqs; k++) {
+				if (ep_state_array[k].state != FT_EP_CONNECTING)
+					continue;
+				if (&ep_state_array[k].ep->fid == entry.fid) {
+					ep_state_array[k].state = FT_EP_CONNECTED;
+					num_connected++;
+					if (num_connected != ep_cnt)
+						fi_freeinfo(ep_state_array[k].fi);
+					break;
+				}
+			}
+
+			if (k == num_conn_reqs) {
+				fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
+					event, entry.fid, ep);
+				ret = -FI_EOTHER;
+				goto err;
+			}
+			break;
+
+		default:
+			ret = -FI_EOTHER;
+			goto err;
+		}
+	}
+
+	/* Post recv */
+	if (rx_shared_ctx)
+		ret = ft_post_rx(srx_ctx, MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	else
+		ret = ft_post_rx(ep_array[0], MAX(rx_size, FT_MAX_CTRL_MSG), &rx_ctx);
+	if (ret)
+		goto err;
+
+	free(ep_state_array);
+	return 0;
+err:
+	for (k = 0; k < ep_cnt; k++) {
+		switch(ep_state_array[k].state) {
+		case FT_EP_CONNECT_RCVD:
+			fi_reject(pep, ep_state_array[k].fi->handle, NULL, 0);
+			break;
+
+		case FT_EP_CONNECTING:
+		case FT_EP_CONNECTED:
+			fi_shutdown(ep_state_array[k].ep, 0);
+			break;
+
+		case FT_EP_STATE_INIT:
+		default:
+			break;
+		}
+	}
+
+	free(ep_state_array);
+	return ret;
+}
+
+static int run(void)
+{
+	int ret = 0;
+
+	addr_array = calloc(ep_cnt, sizeof(*addr_array));
+	if (!addr_array) {
+		perror("malloc");
+		return -FI_ENOMEM;
+	}
+
+	if (hints->ep_attr->type == FI_EP_MSG) {
+		if (!opts.dst_addr) {
+			ret = ft_start_server();
+			if (ret)
+				return ret;
+		}
+
+		ret = opts.dst_addr ? client_connect() : server_connect();
+	} else {
+		ret = init_fabric();
+	}
+	if (ret)
+		return ret;
+
+	ret = run_test();
+
+	/* TODO: Add a local finalize applicable to shared ctx */
+	//ft_finalize(fi, ep_array[0], txcq, rxcq, addr_array[0]);
+	return ret;
+}
+
+int main(int argc, char **argv)
+{
+	int op, ret;
+	int option_index = 0;
+
+	struct option long_options[] = {
+		{"no-tx-shared-ctx", no_argument, &tx_shared_ctx, 0},
+		{"no-rx-shared-ctx", no_argument, &rx_shared_ctx, 0},
+		{"ep-count", required_argument, 0, FT_EP_CNT},
+		{0, 0, 0, 0},
+	};
+
+	opts = INIT_OPTS;
+	opts.options |= FT_OPT_SIZE;
+
+	hints = fi_allocinfo();
+	if (!hints)
+		return EXIT_FAILURE;
+
+	while ((op = getopt_long(argc, argv, "h" ADDR_OPTS INFO_OPTS,
+					long_options, &option_index)) != -1) {
+		switch (op) {
+		case FT_EP_CNT:
+			ep_cnt = atoi(optarg);
+			if (ep_cnt <= 0) {
+				FT_ERR("ep_count needs to be greater than 0\n");
+				return EXIT_FAILURE;
+			}
+			hints->domain_attr->ep_cnt = ep_cnt;
+			break;
+		default:
+			ft_parse_addr_opts(op, optarg, &opts);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			ft_usage(argv[0], "An RDM client-server example that uses"
+				       " shared context.\n");
+			FT_PRINT_OPTS_USAGE("--no-tx-shared-ctx",
+					"Disable shared context for TX");
+			FT_PRINT_OPTS_USAGE("--no-rx-shared-ctx",
+					"Disable shared context for RX");
+			FT_PRINT_OPTS_USAGE("--ep-count <count> (default: 4)",
+					"# of endpoints to be opened");
+			return EXIT_FAILURE;
+		}
+	}
+
+	if (optind < argc)
+		opts.dst_addr = argv[optind];
+
+	hints->caps = FI_MSG;
+	hints->mode = FI_CONTEXT | FI_LOCAL_MR;
+	if (tx_shared_ctx)
+		hints->ep_attr->tx_ctx_cnt = FI_SHARED_CONTEXT;
+	if (rx_shared_ctx)
+		hints->ep_attr->rx_ctx_cnt = FI_SHARED_CONTEXT;
+
+	ret = run();
+
+	FT_CLOSEV_FID(ep_array, ep_cnt);
+	if (rx_shared_ctx)
+		FT_CLOSE_FID(srx_ctx);
+	if (tx_shared_ctx)
+		FT_CLOSE_FID(stx_ctx);
+	ft_free_res();
+	free(addr_array);
+	free(ep_array);
+	free(fi_dup);
+	return -ret;
+}
diff --git a/benchmarks/rdm_cntr_pingpong.c b/streaming/msg.c
similarity index 64%
copy from benchmarks/rdm_cntr_pingpong.c
copy to streaming/msg.c
index cf65f34..9a93ac5 100644
--- a/benchmarks/rdm_cntr_pingpong.c
+++ b/streaming/msg.c
@@ -1,8 +1,7 @@
 /*
  * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
  *
- * This software is available to you under the BSD license
- * below:
+ * This software is available to you under the BSD license below:
  *
  *     Redistribution and use in source and binary forms, with or
  *     without modification, are permitted provided that the following
@@ -29,83 +28,73 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
 
-#include <shared.h>
-#include "benchmark_shared.h"
+#include "shared.h"
 
-
-static int init_fabric(void)
+static int stream(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
+	int ret, i;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_sync();
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
+	ft_start();
+	for (i = 0; i < opts.iterations; i++) {
+		ret = opts.dst_addr ?
+			ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx) : ft_rx(ep, opts.transfer_size);
+		if (ret)
+			return ret;
 	}
+	ft_stop();
 
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
+	if (opts.machr)
+		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end, 1,
+			     opts.argc, opts.argv);
+	else
+		show_perf(NULL, opts.transfer_size, opts.iterations, &start, &end, 1);
 
 	return 0;
 }
 
 static int run(void)
 {
-	int i, ret = 0;
+	int i, ret;
 
-	ret = init_fabric();
-	if (ret)
-		return ret;
+	if (!opts.dst_addr) {
+		ret = ft_start_server();
+		if (ret)
+			return ret;
+	}
 
-	ret = ft_init_av();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret)
-		goto out;
+		return ret;
 
 	if (!(opts.options & FT_OPT_SIZE)) {
 		for (i = 0; i < TEST_CNT; i++) {
-			if (!ft_use_size(i, opts.sizes_enabled))
+			if (!ft_use_size(i,opts.sizes_enabled))
 				continue;
 			opts.transfer_size = test_size[i].size;
 			init_test(&opts, test_name, sizeof(test_name));
-			ret = pingpong();
+			ret = stream();
 			if (ret)
 				goto out;
 		}
 	} else {
 		init_test(&opts, test_name, sizeof(test_name));
-		ret = pingpong();
+		ret = stream();
 		if (ret)
 			goto out;
 	}
 
 	ft_finalize();
 out:
+	fi_shutdown(ep, 0);
 	return ret;
 }
 
@@ -114,23 +103,21 @@ int main(int argc, char **argv)
 	int op, ret;
 
 	opts = INIT_OPTS;
-	opts.options = FT_OPT_RX_CNTR | FT_OPT_TX_CNTR;
 
 	hints = fi_allocinfo();
 	if (!hints)
 		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "h" CS_OPTS INFO_OPTS BENCHMARK_OPTS)) != -1) {
+	while ((op = getopt(argc, argv, "h" CS_OPTS INFO_OPTS)) !=
+			-1) {
 		switch (op) {
 		default:
-			ft_parse_benchmark_opts(op, optarg);
 			ft_parseinfo(op, optarg, hints);
 			ft_parsecsopts(op, optarg, &opts);
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using counters.");
-			ft_benchmark_usage();
+			ft_csusage(argv[0], "Simple streaming client and server using MSG endpoints.");
 			return EXIT_FAILURE;
 		}
 	}
@@ -138,7 +125,7 @@ int main(int argc, char **argv)
 	if (optind < argc)
 		opts.dst_addr = argv[optind];
 
-	hints->ep_attr->type = FI_EP_RDM;
+	hints->ep_attr->type = FI_EP_MSG;
 	hints->caps = FI_MSG;
 	hints->mode = FI_LOCAL_MR;
 
diff --git a/streaming/msg_rma.c b/streaming/msg_rma.c
index 1094742..403696e 100644
--- a/streaming/msg_rma.c
+++ b/streaming/msg_rma.c
@@ -26,26 +26,16 @@
  * SOFTWARE.
  */
 
-#include <assert.h>
-#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_rma.h>
 #include <rdma/fi_cm.h>
 #include <rdma/fi_errno.h>
-#include <shared.h>
 
-static enum ft_rma_opcodes op_type = FT_RMA_WRITE;
-struct fi_rma_iov remote;
-static uint64_t cq_data = 1;
+#include <shared.h>
 
+static struct fi_rma_iov remote;
 
 static int run_test(void)
 {
@@ -57,32 +47,7 @@ static int run_test(void)
 
 	ft_start();
 	for (i = 0; i < opts.iterations; i++) {
-		switch (op_type) {
-		case FT_RMA_WRITE:
-			ret = fi_write(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				       0, remote.addr, remote.key, ep);
-			if (ret)
-				FT_PRINTERR("fi_write", ret);
-			break;
-		case FT_RMA_WRITEDATA:
-			ret = fi_writedata(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				       cq_data, 0, remote.addr, remote.key, ep);
-			if (ret)
-				FT_PRINTERR("fi_writedata", ret);
-
-			ret = ft_rx(0);
-			break;
-		case FT_RMA_READ:
-			ret = fi_read(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				      0, remote.addr, remote.key, ep);
-			if (ret)
-				FT_PRINTERR("fi_read", ret);
-			break;
-		}
-		if (ret)
-			return ret;
-
-		ret = ft_get_tx_comp(++tx_seq);
+		ret = ft_rma(opts.rma_op, ep, opts.transfer_size, &remote, ep);
 		if (ret)
 			return ret;
 	}
@@ -92,157 +57,23 @@ static int run_test(void)
 		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end,
 				1, opts.argc, opts.argv);
 	else
-		show_perf(test_name, opts.transfer_size, opts.iterations,
+		show_perf(NULL, opts.transfer_size, opts.iterations,
 				&start, &end, 1);
 
 	return 0;
 }
 
-static int alloc_ep_res(struct fi_info *fi)
-{
-	switch (op_type) {
-	case FT_RMA_READ:
-		fi->caps |= FI_REMOTE_READ;
-		if (fi->mode & FI_LOCAL_MR)
-			fi->caps |= FI_READ;
-		break;
-	case FT_RMA_WRITE:
-	case FT_RMA_WRITEDATA:
-		fi->caps |= FI_REMOTE_WRITE;
-		if (fi->mode & FI_LOCAL_MR)
-			fi->caps |= FI_WRITE;
-		break;
-	default:
-		assert(0);
-	}
-
-	return ft_alloc_active_res(fi);
-}
-
-static int server_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "listen");
-		return (int) rd;
-	}
-
-	fi = entry.info;
-	if (event != FI_CONNREQ) {
-		fprintf(stderr, "Unexpected CM event %d\n", event);
-		ret = -FI_EOTHER;
-		goto err;
-	}
-
-	ret = fi_domain(fabric, fi, &domain, NULL);
-	if (ret) {
-		FT_PRINTERR("fi_domain", ret);
-		goto err;
-	}
-
-	ret = alloc_ep_res(fi);
-	if (ret)
-		 goto err;
-
-	ret = ft_init_ep();
-	if (ret)
-		goto err;
-
-	ret = fi_accept(ep, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_accept", ret);
-		goto err;
-	}
-
-	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "accept");
-		ret = (int) rd;
-		goto err;
-	}
-
-	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
-		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
-			event, entry.fid, ep);
- 		ret = -FI_EOTHER;
- 		goto err;
- 	}
-
- 	return 0;
-
-err:
-	fi_reject(pep, fi->handle, NULL, 0);
- 	return ret;
-}
-
-static int client_connect(void)
-{
-	struct fi_eq_cm_entry entry;
-	uint32_t event;
-	ssize_t rd;
-	int ret;
-
-	ret = fi_getinfo(FT_FIVERSION, opts.dst_addr, opts.dst_port, 0, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = alloc_ep_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	ret = fi_connect(ep, fi->dest_addr, NULL, 0);
-	if (ret) {
-		FT_PRINTERR("fi_connect", ret);
-		return ret;
-	}
-
- 	rd = fi_eq_sread(eq, &event, &entry, sizeof entry, -1, 0);
-	if (rd != sizeof entry) {
-		FT_PROCESS_EQ_ERR(rd, eq, "fi_eq_sread", "connect");
-		return (int) rd;
-	}
-
- 	if (event != FI_CONNECTED || entry.fid != &ep->fid) {
- 		fprintf(stderr, "Unexpected CM event %d fid %p (ep %p)\n",
- 			event, entry.fid, ep);
- 		return -FI_EOTHER;
- 	}
-
-	return 0;
-}
-
 static int run(void)
 {
-	char *node, *service;
-	uint64_t flags;
 	int i, ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
 	if (!opts.dst_addr) {
 		ret = ft_start_server();
 		if (ret)
 			return ret;
 	}
 
-	ret = opts.dst_addr ? client_connect() : server_connect();
+	ret = opts.dst_addr ? ft_client_connect() : ft_server_connect();
 	if (ret)
 		return ret;
 
@@ -286,27 +117,16 @@ int main(int argc, char **argv)
 
 	while ((op = getopt(argc, argv, "ho:" CS_OPTS INFO_OPTS)) != -1) {
 		switch (op) {
-		case 'o':
-			if (!strcmp(optarg, "read")) {
-				op_type = FT_RMA_READ;
-			} else if (!strcmp(optarg, "writedata")) {
-				op_type = FT_RMA_WRITEDATA;
-				cq_attr.format = FI_CQ_FORMAT_DATA;
-			} else if (!strcmp(optarg, "write")) {
-				op_type = FT_RMA_WRITE;
-			} else {
-				ft_csusage(argv[0], NULL);
-				fprintf(stderr, "  -o <op>\tselect operation type (read or write)\n");
-				return EXIT_FAILURE;
-			}
-			break;
 		default:
 			ft_parseinfo(op, optarg, hints);
 			ft_parsecsopts(op, optarg, &opts);
+			ret = ft_parse_rma_opts(op, optarg, &opts);
+			if (ret)
+				return ret;
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using message RMA.");
+			ft_csusage(argv[0], "Streaming client-server using RMA operations between MSG endpoints.");
 			fprintf(stderr, "  -o <op>\trma op type: read|write|writedata (default: write)]\n");
 			return EXIT_FAILURE;
 		}
diff --git a/streaming/rdm_atomic.c b/streaming/rdm_atomic.c
index afafbbe..708a4a0 100644
--- a/streaming/rdm_atomic.c
+++ b/streaming/rdm_atomic.c
@@ -29,27 +29,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
-#include <errno.h>
 #include <getopt.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <time.h>
 #include <complex.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_domain.h>
-#include <rdma/fi_tagged.h>
-#include <rdma/fi_rma.h>
-#include <rdma/fi_cm.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_atomic.h>
 
@@ -439,20 +421,12 @@ static int alloc_ep_res(struct fi_info *fi)
 
 static int init_fabric(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	ret = ft_open_fabric_res();
 	if (ret)
 		return ret;
@@ -489,7 +463,7 @@ static int run(void)
 		goto out;
 
 	ft_sync();
-	ft_finalize(fi, ep, txcq, rxcq, remote_fi_addr);
+	ft_finalize();
 out:
 	return ret;
 }
@@ -528,7 +502,7 @@ int main(int argc, char **argv)
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using atomic ops.");
+			ft_csusage(argv[0], "Streaming RDM client-server using atomic operations.");
 			FT_PRINT_OPTS_USAGE("-o <op>", "atomic op type: all|min|max|sum|prod|lor|");
 			FT_PRINT_OPTS_USAGE("", "land|bor|band|lxor|bxor|read|write|cswap|cswap_ne|"
 					"cswap_le|cswap_lt|");
diff --git a/streaming/rdm_multi_recv.c b/streaming/rdm_multi_recv.c
index 514491b..2d3bdb3 100644
--- a/streaming/rdm_multi_recv.c
+++ b/streaming/rdm_multi_recv.c
@@ -29,16 +29,12 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
 
-#include <rdma/fabric.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_endpoint.h>
 #include <rdma/fi_cm.h>
+
 #include <shared.h>
 
 // MULTI_BUF_SIZE_FACTOR defines how large the multi recv buffer will be.
@@ -90,11 +86,11 @@ static int sync_test(void)
 {
 	int ret;
 
-	ret = opts.dst_addr ? ft_tx(1) : wait_for_recv_completion(1);
+	ret = opts.dst_addr ? ft_tx(ep, remote_fi_addr, 1, &tx_ctx) : wait_for_recv_completion(1);
 	if (ret)
 		return ret;
 
-	ret = opts.dst_addr ? wait_for_recv_completion(1) : ft_tx(1);
+	ret = opts.dst_addr ? wait_for_recv_completion(1) : ft_tx(ep, remote_fi_addr, 1, &tx_ctx);
 	return ret;
 }
 
@@ -132,7 +128,7 @@ static int run_test(void)
 	ft_start();
 	if (opts.dst_addr) {
 		for (i = 0; i < opts.iterations; i++) {
-			ret = ft_tx(opts.transfer_size);
+			ret = ft_tx(ep, remote_fi_addr, opts.transfer_size, &tx_ctx);
 			if (ret)
 				goto out;
 		}
@@ -218,20 +214,12 @@ static int alloc_ep_res(struct fi_info *fi)
 
 static int init_fabric(void)
 {
-	uint64_t flags = 0;
-	char *node, *service;
 	int ret;
 
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
+	ret = ft_getinfo(hints, &fi);
 	if (ret)
 		return ret;
 
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
 	// set FI_MULTI_RECV flag for all recv operations
 	fi->rx_attr->op_flags = FI_MULTI_RECV;
 
@@ -273,7 +261,7 @@ static int init_av(void)
 			return ret;
 		}
 
-		ret = ft_tx(addrlen);
+		ret = ft_tx(ep, remote_fi_addr, addrlen, &tx_ctx);
 		if (ret)
 			return ret;
 	} else {
@@ -304,7 +292,7 @@ static int run(void)
 	ret = run_test();
 
 	rx_seq++;
-	ft_finalize(fi, ep, txcq, rxcq, remote_fi_addr);
+	ft_finalize();
 out:
 	return ret;
 }
@@ -328,7 +316,7 @@ int main(int argc, char **argv)
 			break;
 		case '?':
 		case 'h':
-			ft_csusage(argv[0], "Ping pong client and server using message endpoints.");
+			ft_csusage(argv[0], "Streaming RDM client-server using multi recv buffer.");
 			return EXIT_FAILURE;
 		}
 	}
diff --git a/streaming/rdm_rma.c b/streaming/rdm_rma.c
index 34b8d88..071d10a 100644
--- a/streaming/rdm_rma.c
+++ b/streaming/rdm_rma.c
@@ -26,32 +26,15 @@
  * SOFTWARE.
  */
 
-#include <assert.h>
-#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <getopt.h>
-#include <time.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#include <rdma/fabric.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_rma.h>
-#include <rdma/fi_cm.h>
-#include <rdma/fi_errno.h>
-#include <shared.h>
-
 
-static uint64_t op_type = FT_RMA_WRITE;
-struct fi_rma_iov remote;
-static uint64_t cq_data = 1;
+#include <rdma/fi_errno.h>
 
-struct fi_context fi_ctx_write;
-struct fi_context fi_ctx_writedata;
-struct fi_context fi_ctx_read;
+#include <shared.h>
 
+static struct fi_rma_iov remote;
 
 static int run_test(void)
 {
@@ -63,34 +46,7 @@ static int run_test(void)
 
 	ft_start();
 	for (i = 0; i < opts.iterations; i++) {
-		switch (op_type) {
-		case FT_RMA_WRITE:
-			ret = fi_write(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				       remote_fi_addr, remote.addr, remote.key, ep);
-			if (ret)
-				FT_PRINTERR("fi_write", ret);
-			break;
-		case FT_RMA_WRITEDATA:
-			ret = fi_writedata(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				       cq_data, remote_fi_addr, remote.addr, remote.key, ep);
-			if (ret) {
-				FT_PRINTERR("fi_writedata", ret);
-				return ret;
-			}
-
-			ret = ft_rx(0);
-			break;
-		case FT_RMA_READ:
-			ret = fi_read(ep, buf, opts.transfer_size, fi_mr_desc(mr),
-				      remote_fi_addr, remote.addr, remote.key, ep);
-			if (ret)
-				FT_PRINTERR("fi_read", ret);
-			break;
-		}
-		if (ret)
-			return ret;
-
-		ret = ft_get_tx_comp(++tx_seq);
+		ret = ft_rma(opts.rma_op, ep, opts.transfer_size, &remote, ep);
 		if (ret)
 			return ret;
 	}
@@ -100,76 +56,20 @@ static int run_test(void)
 		show_perf_mr(opts.transfer_size, opts.iterations, &start, &end,
 				1, opts.argc, opts.argv);
 	else
-		show_perf(test_name, opts.transfer_size, opts.iterations,
+		show_perf(NULL, opts.transfer_size, opts.iterations,
 				&start, &end, 1);
 
 	return 0;
 }
 
-static int alloc_ep_res(struct fi_info *fi)
-{
-	switch (op_type) {
-	case FT_RMA_READ:
-		fi->caps |= FI_REMOTE_READ;
-		if (fi->mode & FI_LOCAL_MR)
-			fi->caps |= FI_READ;
-		break;
-	case FT_RMA_WRITE:
-	case FT_RMA_WRITEDATA:
-		fi->caps |= FI_REMOTE_WRITE;
-		if (fi->mode & FI_LOCAL_MR)
-			fi->caps |= FI_WRITE;
-		break;
-	default:
-		assert(0);
-	}
-
-	return ft_alloc_active_res(fi);
-}
-
-static int init_fabric(void)
-{
-	uint64_t flags = 0;
-	char *node, *service;
-	int ret;
-
-	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
-	if (ret)
-		return ret;
-
-	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &fi);
-	if (ret) {
-		FT_PRINTERR("fi_getinfo", ret);
-		return ret;
-	}
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	ret = alloc_ep_res(fi);
-	if (ret)
-		return ret;
-
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static int run(void)
 {
 	int i, ret = 0;
 
-	ret = init_fabric();
+	ret = ft_init_fabric();
 	if (ret)
 		return ret;
 
-	ret = ft_init_av();
-	if (ret)
-		goto out;
-
 	ret = ft_exchange_keys(&remote);
 	if (ret)
 		goto out;
@@ -192,7 +92,7 @@ static int run(void)
 	}
 
 	ft_sync();
-	ft_finalize(fi, ep, txcq, rxcq, remote_fi_addr);
+	ft_finalize();
 out:
 	return ret;
 }
@@ -209,23 +109,12 @@ int main(int argc, char **argv)
 
 	while ((op = getopt(argc, argv, "ho:" CS_OPTS INFO_OPTS)) != -1) {
 		switch (op) {
-		case 'o':
-			if (!strcmp(optarg, "read")) {
-				op_type = FT_RMA_READ;
-			} else if (!strcmp(optarg, "writedata")) {
-				op_type = FT_RMA_WRITEDATA;
-				cq_attr.format = FI_CQ_FORMAT_DATA;
-			} else if (!strcmp(optarg, "write")) {
-				op_type = FT_RMA_WRITE;
-			} else {
-				ft_csusage(argv[0], "Ping pong client and server using rma.");
-				fprintf(stderr, "  -o <op>\trma op type: read|write (default: write)]\n");
-				return EXIT_FAILURE;
-			}
-			break;
 		default:
 			ft_parseinfo(op, optarg, hints);
 			ft_parsecsopts(op, optarg, &opts);
+			ret = ft_parse_rma_opts(op, optarg, &opts);
+			if (ret)
+				return ret;
 			break;
 		case '?':
 		case 'h':
diff --git a/unit/av_test.c b/unit/av_test.c
index 50c8308..af40b20 100644
--- a/unit/av_test.c
+++ b/unit/av_test.c
@@ -33,23 +33,11 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <getopt.h>
-#include <poll.h>
-#include <time.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include <netdb.h>
-#include <arpa/inet.h>
-#include <inttypes.h>
-#include <netinet/in.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "unit_common.h"
@@ -59,13 +47,11 @@
 char *good_address;
 int num_good_addr;
 char *bad_address;
-static char *src_addr_str = NULL;
 
 static enum fi_av_type av_type;
 
 static char err_buf[512];
 
-
 static int
 check_eq_readerr(struct fid_eq *eq, fid_t fid, void *context, int index)
 {
@@ -947,19 +933,24 @@ fail:
 }
 
 struct test_entry test_array_good[] = {
-	TEST_ENTRY(av_open_close),
-	TEST_ENTRY(av_good_sync),
-	TEST_ENTRY(av_good_vector_async),
-	TEST_ENTRY(av_zero_async),
-	TEST_ENTRY(av_good_2vector_async),
+	TEST_ENTRY(av_open_close, "Test open and close AVs of varying sizes"),
+	TEST_ENTRY(av_good_sync, "Test sync AV insert with good address"),
+	TEST_ENTRY(av_good_vector_async,
+			"Test async AV insert with vector of good addresses"),
+	TEST_ENTRY(av_zero_async, "Test async insert AV insert of zero addresses"),
+	TEST_ENTRY(av_good_2vector_async,
+			"Test async AV inserts with two address vectors"),
 	{ NULL, "" }
 };
 
 struct test_entry test_array_bad[] = {
-	TEST_ENTRY(av_bad_sync),
-	TEST_ENTRY(av_goodbad_vector_sync),
-	TEST_ENTRY(av_goodbad_vector_async),
-	TEST_ENTRY(av_goodbad_2vector_async),
+	TEST_ENTRY(av_bad_sync, "Test sync AV insert of bad address"),
+	TEST_ENTRY(av_goodbad_vector_sync,
+			"Test sync AV inset of 1 good and 1 bad address"),
+	TEST_ENTRY(av_goodbad_vector_async,
+			"Test async AV insert with good and bad address"),
+	TEST_ENTRY(av_goodbad_2vector_async, "Test async AV insert with two vectors:"
+			" one good and one mix (good + bad)"),
 	{ NULL, "" }
 };
 
@@ -972,63 +963,66 @@ run_test_set()
 
 	failed += run_tests(test_array_good, err_buf);
 	if (bad_address != NULL) {
-		printf("Testing with bad_address = \"%s\"\n", bad_address);
+		printf("\nTesting with bad_address = \"%s\"\n", bad_address);
 		failed += run_tests(test_array_bad, err_buf);
 	}
 
 	bad_address = NULL;
-	printf("Testing with invalid address\n");
+	printf("\nTesting with invalid address\n");
 	failed += run_tests(test_array_bad, err_buf);
 
 	return failed;
 }
 
+static void usage(void)
+{
+	ft_unit_usage("av_test", "Unit test for Address Vector (AV)");
+	FT_PRINT_OPTS_USAGE("-g <good_address>", "");
+	FT_PRINT_OPTS_USAGE("-G <bad_address>]", "");
+	fprintf(stderr, FT_OPTS_USAGE_FORMAT " (max=%d)\n", "-n <num_good_addr>",
+			"Number of good addresses", MAX_ADDR - 1);
+	FT_PRINT_OPTS_USAGE("-s <source_address>", "");
+}
+
 int main(int argc, char **argv)
 {
 	int op, ret;
 	int failed;
 
+	opts = INIT_OPTS;
+	opts.options |= FT_OPT_SIZE;
+
 	hints = fi_allocinfo();
 	if (!hints)
 		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "f:d:D:n:a:s:")) != -1) {
+	while ((op = getopt(argc, argv, FAB_OPTS "g:G:n:s:h")) != -1) {
 		switch (op) {
-		case 'd':
+		case 'g':
 			good_address = optarg;
 			break;
-		case 'D':
+		case 'G':
 			bad_address = optarg;
 			break;
-		case 'a':
-			free(hints->fabric_attr->name);
-			hints->fabric_attr->name = strdup(optarg);
-			break;
 		case 'n':
 			num_good_addr = atoi(optarg);
 			break;
-		case 'f':
-			free(hints->fabric_attr->prov_name);
-			hints->fabric_attr->prov_name = strdup(optarg);
-			break;
 		case 's':
-			src_addr_str = optarg;
+			opts.src_addr = optarg;
 			break;
 		default:
-			printf("usage: %s\n", argv[0]);
-			printf("\t[-d good_address]\n");
-			printf("\t[-D bad_address]\n");
-			printf("\t[-a fabric_name]\n");
-			printf("\t[-n num_good_addr (max=%d)]\n", MAX_ADDR - 1);
-			printf("\t[-f provider_name]\n");
-			printf("\t[-s source_address]\n");
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			usage();
 			return EXIT_FAILURE;
 
 		}
 	}
 
 	if (good_address == NULL ||  num_good_addr == 0) {
-		printf("Test requires -d  and -n\n");
+		printf("Test requires -g and -n\n");
 		return EXIT_FAILURE;
 	}
 
@@ -1041,25 +1035,27 @@ int main(int argc, char **argv)
 	hints->mode = ~0;
 	hints->addr_format = FI_SOCKADDR;
 
+	// TODO make this test accept endpoint type argument
 	hints->ep_attr->type = FI_EP_RDM;
-	ret = fi_getinfo(FT_FIVERSION, src_addr_str, 0, FI_SOURCE, hints, &fi);
-	if (ret != 0 && ret != -FI_ENODATA) {
-		printf("fi_getinfo %s\n", fi_strerror(-ret));
+	ret = fi_getinfo(FT_FIVERSION, opts.src_addr, 0, FI_SOURCE, hints, &fi);
+
+	if (ret && ret != -FI_ENODATA) {
+		FT_PRINTERR("fi_getinfo", ret);
 		goto err;
 	}
 
 	if (ret == -FI_ENODATA) {
 		hints->ep_attr->type = FI_EP_DGRAM;
-		ret = fi_getinfo(FT_FIVERSION, src_addr_str, 0, FI_SOURCE, hints, &fi);
-		if (ret != 0) {
-			printf("fi_getinfo %s\n", fi_strerror(-ret));
+		ret = fi_getinfo(FT_FIVERSION, opts.src_addr, 0, FI_SOURCE, hints, &fi);
+		if (ret) {
+			FT_PRINTERR("fi_getinfo", ret);
 			goto err;
 		}
 	}
 
 	ret = ft_open_fabric_res();
 	if (ret)
-		return ret;
+		goto err;
 
 	printf("Testing AVs on fabric %s\n", fi->fabric_attr->name);
 	failed = 0;
@@ -1067,26 +1063,24 @@ int main(int argc, char **argv)
 	if (fi->domain_attr->av_type == FI_AV_UNSPEC ||
 	    fi->domain_attr->av_type == FI_AV_MAP) {
 		av_type = FI_AV_MAP;
-		printf("Testing with type = FI_AV_MAP\n");
+		printf("\nTesting with type = FI_AV_MAP\n");
 		failed += run_test_set();
 	}
 
 	if (fi->domain_attr->av_type == FI_AV_UNSPEC ||
 	    fi->domain_attr->av_type == FI_AV_TABLE) {
 		av_type = FI_AV_TABLE;
-		printf("Testing with type = FI_AV_TABLE\n");
+		printf("\nTesting with type = FI_AV_TABLE\n");
 		failed += run_test_set();
 	}
 
 	if (failed > 0) {
-		printf("Summary: %d tests failed\n", failed);
+		printf("\nSummary: %d tests failed\n", failed);
 	} else {
-		printf("Summary: all tests passed\n");
+		printf("\nSummary: all tests passed\n");
 	}
 
-	ft_free_res();
-	return (failed > 0);
 err:
 	ft_free_res();
-	return -ret;
+	return ret ? -ret : (failed > 0) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/unit/common.c b/unit/common.c
index 2dfa7a2..7c823fa 100644
--- a/unit/common.c
+++ b/unit/common.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2013-2014 Intel Corporation.  All rights reserved.
- * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
+ * Copyright (c) 2014-2016 Cisco Systems, Inc.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -35,6 +35,21 @@
 
 #include "unit_common.h"
 
+void ft_unit_usage(char *name, char *desc)
+{
+	fprintf(stderr, "Usage:\n");
+	fprintf(stderr, "  %s [OPTIONS]\n", name);
+
+	if (desc)
+		fprintf(stderr, "\n%s\n", desc);
+
+	fprintf(stderr, "\nOptions:\n");
+	FT_PRINT_OPTS_USAGE("-f <fabric_name>", "specific fabric to use");
+	FT_PRINT_OPTS_USAGE("-d <domain>", "domain name");
+	FT_PRINT_OPTS_USAGE("-p <provider_name>", "specific provider name eg sockets, verbs");
+	FT_PRINT_OPTS_USAGE("-h", "display this help output");
+}
+
 int
 run_tests(struct test_entry *test_array, char *err_buf)
 {
@@ -46,7 +61,7 @@ run_tests(struct test_entry *test_array, char *err_buf)
 
 	tep = test_array;
 	while (tep->test != NULL) {
-		printf("Running %s...", tep->name);
+		printf("Running %s [%s]...", tep->name, tep->desc);
 		fflush(stdout);
 		ret = tep->test();
 		switch (ret) {
@@ -54,13 +69,11 @@ run_tests(struct test_entry *test_array, char *err_buf)
 			printf("PASS!\n");
 			break;
 		case FAIL:
-			printf("FAIL\n");
-			printf("  %s\n", err_buf);
+			printf("FAIL: %s\n", err_buf);
 			failed++;
 			break;
 		case SKIPPED:
-			printf("skipped because:\n");
-			printf("  %s\n", err_buf);
+			printf("skipped because: %s\n", err_buf);
 			break;
 		case NOTSUPP:
 			printf("requires unsupported feature: %s\n", err_buf);
diff --git a/unit/cq_test.c b/unit/cq_test.c
new file mode 100644
index 0000000..ec749d8
--- /dev/null
+++ b/unit/cq_test.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2013-2016 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2014-2016 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+
+#include <rdma/fi_errno.h>
+
+#include "unit_common.h"
+#include "shared.h"
+
+static char err_buf[512];
+
+static int
+create_cq(struct fid_cq **cq, size_t size, uint64_t flags,
+		enum fi_cq_format format, enum fi_wait_obj wait_obj)
+{
+	struct fi_cq_attr cq_attr;
+
+	memset(&cq_attr, 0, sizeof(cq_attr));
+	cq_attr.size = size;
+	cq_attr.flags = flags;
+	cq_attr.format = format;
+	cq_attr.wait_obj = wait_obj;
+
+	return fi_cq_open(domain, &cq_attr, cq, NULL);
+}
+
+/* Try opening fi->domain_attr->cq_cnt number of completion queues
+ * simultaneously using a size hint of 0 (indicating the provider should choose
+ * the size)
+ */
+static int cq_open_close_simultaneous(void)
+{
+	int ret;
+	int opened;
+	size_t count;
+	int testret = FAIL;
+	struct fid_cq **cq_array;
+
+	count = fi->domain_attr->cq_cnt;
+	FT_DEBUG("testing creation of up to %zu simultaneous CQs\n", count);
+
+	cq_array = calloc(count, sizeof(*cq_array));
+	if (!cq_array)
+		return -FI_ENOMEM;
+
+	ret = 0;
+	for (opened = 0; opened < count && !ret; opened++) {
+		ret = create_cq(&cq_array[opened], 0, 0, FI_CQ_FORMAT_UNSPEC,
+				FI_WAIT_UNSPEC);
+	}
+	if (ret) {
+		FT_WARN("fi_cq_open failed after %d (cq_cnt: %zu): %s",
+			opened, count, fi_strerror(-ret));
+	}
+
+	testret = PASS;
+
+	FT_CLOSEV_FID(cq_array, opened);
+	free(cq_array);
+
+	return TEST_RET_VAL(ret, testret);
+}
+
+/*
+ * Tests:
+ * - test open and close of CQ over a range of sizes
+ */
+static int
+cq_open_close_sizes()
+{
+	int i;
+	int ret;
+	int size;
+	int testret;
+	struct fid_cq *cq;
+
+	testret = FAIL;
+
+	for (i = -1; i < 17; ++i) {
+		size = (i < 0) ? 0 : 1 << i;
+
+		ret = create_cq(&cq, size, 0, FI_CQ_FORMAT_UNSPEC, FI_WAIT_UNSPEC);
+		if (ret == -FI_EINVAL) {
+			FT_WARN("\nSuccessfully completed %d iterations up to "
+				"size %d before the provider returned "
+				"EINVAL...",
+				i + 1, size >> 1);
+			ret = 0;
+			goto pass;
+		}
+		if (ret != 0) {
+			sprintf(err_buf, "fi_cq_open(%d, 0, FI_CQ_FORMAT_UNSPEC, "
+					"FI_WAIT_UNSPEC) = %d, %s",
+					size, ret, fi_strerror(-ret));
+			goto fail;
+		}
+
+		ret = fi_close(&cq->fid);
+		if (ret != 0) {
+			sprintf(err_buf, "close(cq) = %d, %s", ret, fi_strerror(-ret));
+			goto fail;
+		}
+		cq = NULL;
+	}
+
+pass:
+	testret = PASS;
+fail:
+	cq = NULL;
+	return TEST_RET_VAL(ret, testret);
+}
+
+struct test_entry test_array[] = {
+	TEST_ENTRY(cq_open_close_sizes, "Test open and close of CQ for various sizes"),
+	TEST_ENTRY(cq_open_close_simultaneous, "Test opening several CQs at a time"),
+	{ NULL, "" }
+};
+
+static void usage(void)
+{
+	ft_unit_usage("cq_test", "Unit test for Completion Queue (CQ)");
+}
+
+int main(int argc, char **argv)
+{
+	int op, ret;
+	int failed;
+
+	hints = fi_allocinfo();
+	if (!hints)
+		return EXIT_FAILURE;
+
+	while ((op = getopt(argc, argv, FAB_OPTS "h")) != -1) {
+		switch (op) {
+		default:
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			usage();
+			return EXIT_FAILURE;
+		}
+	}
+
+	hints->mode = ~0;
+
+	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &fi);
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
+		goto err;
+	}
+
+	ret = ft_open_fabric_res();
+	if (ret)
+		goto err;
+
+	printf("Testing CQs on fabric %s\n", fi->fabric_attr->name);
+
+	failed = run_tests(test_array, err_buf);
+	if (failed > 0) {
+		printf("Summary: %d tests failed\n", failed);
+	} else {
+		printf("Summary: all tests passed\n");
+	}
+
+err:
+	ft_free_res();
+	return ret ? -ret : (failed > 0) ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/unit/dom_test.c b/unit/dom_test.c
index 86ed2c1..3ec99da 100644
--- a/unit/dom_test.c
+++ b/unit/dom_test.c
@@ -33,23 +33,10 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <getopt.h>
-#include <poll.h>
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <inttypes.h>
 #include <limits.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "shared.h"
 #include "unit_common.h"
@@ -63,6 +50,12 @@ static struct fid_domain **domain_vec = NULL;
  * - test open and close of a domain
  */
 
+static void usage(void)
+{
+	ft_unit_usage("dom_test", "Unit test for Domain");
+	FT_PRINT_OPTS_USAGE("-n <num_domains>", "num domains to open");
+}
+
 int main(int argc, char **argv)
 {
 	unsigned long i;
@@ -71,15 +64,11 @@ int main(int argc, char **argv)
 	char *ptr;
 
 	hints = fi_allocinfo();
-	if (hints == NULL)
-		exit(EXIT_FAILURE);
+	if (!hints)
+		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "f:a:n:")) != -1) {
+	while ((op = getopt(argc, argv, FAB_OPTS "n:h")) != -1) {
 		switch (op) {
-		case 'a':
-			free(hints->fabric_attr->name);
-			hints->fabric_attr->name = strdup(optarg);
-			break;
 		case 'n':
 			errno = 0;
 			num_domains = strtol(optarg, &ptr, 10);
@@ -89,24 +78,21 @@ int main(int argc, char **argv)
 				goto out;
 			}
 			break;
-		case 'f':
-			free(hints->fabric_attr->prov_name);
-			hints->fabric_attr->prov_name = strdup(optarg);
-			break;
 		default:
-			printf("usage: %s\n", argv[0]);
-			printf("\t[-a fabric_name]\n");
-			printf("\t[-f provider_name]\n");
-			printf("\t[-n num domains to open]\n");
-			exit(EXIT_FAILURE);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			usage();
+			return EXIT_FAILURE;
 		}
 	}
 
 	hints->mode = ~0;
 
 	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &fi);
-	if (ret != 0) {
-		printf("fi_getinfo %s\n", fi_strerror(-ret));
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
 		goto out;
 	}
 
@@ -117,6 +103,7 @@ int main(int argc, char **argv)
 	domain_vec = calloc(num_domains, sizeof(*domain_vec));
 	if (domain_vec == NULL) {
 		perror("malloc");
+		ret = EXIT_FAILURE;
 		goto out;
 	}
 
diff --git a/unit/eq_test.c b/unit/eq_test.c
index f6cd56f..e8e76cf 100644
--- a/unit/eq_test.c
+++ b/unit/eq_test.c
@@ -36,19 +36,13 @@
 #include <errno.h>
 #include <getopt.h>
 #include <poll.h>
-#include <time.h>
 #include <string.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_errno.h>
-#include <rdma/fi_endpoint.h>
-#include <rdma/fi_cm.h>
 
 #include "unit_common.h"
 #include "shared.h"
 
-
 static char err_buf[512];
 
 static int
@@ -547,16 +541,21 @@ fail:
 }
 
 struct test_entry test_array[] = {
-	TEST_ENTRY(eq_open_close),
-	TEST_ENTRY(eq_write_read_self),
-	TEST_ENTRY(eq_write_overflow),
-	TEST_ENTRY(eq_wait_fd_poll),
-	TEST_ENTRY(eq_wait_fd_sread),
-	TEST_ENTRY(eq_wait_read_peek),
-	TEST_ENTRY(eq_wait_sread_peek),
+	TEST_ENTRY(eq_open_close, "Test open and close of EQ for various sizes"),
+	TEST_ENTRY(eq_write_read_self, "Test writing and reading to EQ"),
+	TEST_ENTRY(eq_write_overflow, "Test writing # of entries that exceed EQ size"),
+	TEST_ENTRY(eq_wait_fd_poll, "Test polling on fd extracted from EQ"),
+	TEST_ENTRY(eq_wait_fd_sread, "Test EQ sread"),
+	TEST_ENTRY(eq_wait_read_peek, "Test EQ read with FI_PEEK"),
+	TEST_ENTRY(eq_wait_sread_peek, "Test EQ sread with FI_PEEK"),
 	{ NULL, "" }
 };
 
+static void usage(void)
+{
+	ft_unit_usage("eq_test", "Unit test for Event Queue (EQ)");
+}
+
 int main(int argc, char **argv)
 {
 	int op, ret;
@@ -564,38 +563,32 @@ int main(int argc, char **argv)
 
 	hints = fi_allocinfo();
 	if (!hints)
-		exit(1);
+		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "f:a:")) != -1) {
+	while ((op = getopt(argc, argv, FAB_OPTS "h")) != -1) {
 		switch (op) {
-		case 'a':
-			free(hints->fabric_attr->name);
-			hints->fabric_attr->name = strdup(optarg);
-			break;
-		case 'f':
-			free(hints->fabric_attr->prov_name);
-			hints->fabric_attr->prov_name = strdup(optarg);
-			break;
 		default:
-			printf("usage: %s\n", argv[0]);
-			printf("\t[-a fabric_name]\n");
-			printf("\t[-f provider_name]\n");
-			exit(1);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			usage();
+			return EXIT_FAILURE;
 		}
 	}
 
 	hints->mode = ~0;
 
 	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &fi);
-	if (ret != 0) {
-		printf("fi_getinfo %s\n", fi_strerror(-ret));
-		exit(-ret);
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
+		goto err;
 	}
 
 	ret = fi_fabric(fi->fabric_attr, &fabric, NULL);
-	if (ret != 0) {
-		printf("fi_fabric %s\n", fi_strerror(-ret));
-		exit(1);
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
+		goto err;
 	}
 
 	printf("Testing EQs on fabric %s\n", fi->fabric_attr->name);
@@ -607,6 +600,7 @@ int main(int argc, char **argv)
 		printf("Summary: all tests passed\n");
 	}
 
+err:
 	ft_free_res();
-	exit(failed > 0);
+	return ret ? -ret : (failed > 0) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
diff --git a/unit/getinfo_test.c b/unit/getinfo_test.c
new file mode 100644
index 0000000..d3e2fbf
--- /dev/null
+++ b/unit/getinfo_test.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2013-2015 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *	- Redistributions of source code must retain the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer.
+ *
+ *	- Redistributions in binary form must reproduce the above
+ *	  copyright notice, this list of conditions and the following
+ *	  disclaimer in the documentation and/or other materials
+ *	  provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+
+#include <rdma/fi_errno.h>
+
+#include "shared.h"
+#include "unit_common.h"
+
+typedef int (*ft_getinfo_init)(struct fi_info *);
+typedef int (*ft_getinfo_check)(void *);
+
+static char err_buf[512];
+
+static int check_addr(void *addr, size_t addrlen, char *str)
+{
+	if (!addrlen) {
+		sprintf(err_buf, "%s addrlen not set", str);
+		return EXIT_FAILURE;
+	}
+	if (!addr) {
+		sprintf(err_buf, "%s address not set", str);
+		return EXIT_FAILURE;
+	}
+	return 0;
+}
+
+static int check_srcaddr(void *arg)
+{
+	struct fi_info *info = (struct fi_info *)arg;
+	return check_addr(info->src_addr, info->src_addrlen, "source");
+}
+
+static int check_src_dest_addr(void *arg)
+{
+	struct fi_info *info = (struct fi_info *)arg;
+	int ret;
+
+	ret = check_addr(info->src_addr, info->src_addrlen, "source");
+	if (ret)
+		return ret;
+
+	return check_addr(info->dest_addr, info->dest_addrlen, "destination");
+}
+
+int invalid_dom(struct fi_info *hints)
+{
+	if (hints->domain_attr->name)
+		free(hints->domain_attr->name);
+	hints->domain_attr->name = strdup("invalid_domain");
+	if (!hints->domain_attr->name)
+		return -FI_ENOMEM;
+	return 0;
+}
+
+static int getinfo_unit_test(char *node, char *service, uint64_t flags,
+		struct fi_info *hints, ft_getinfo_init init,
+		ft_getinfo_check check, int ret_exp)
+{
+	struct fi_info *info, *fi;
+	int ret;
+
+	if (init) {
+		ret = init(hints);
+		if (ret)
+			return ret;
+	}
+
+	ret = fi_getinfo(FT_FIVERSION, node, service, flags, hints, &info);
+	if (ret) {
+		if (ret == ret_exp)
+			return 0;
+		sprintf(err_buf, "fi_getinfo failed %s(%d)", fi_strerror(-ret), -ret);
+		return ret;
+	}
+
+	if (!check)
+		goto out;
+
+	ft_foreach_info(fi, info) {
+		FT_DEBUG("\nTesting for fabric: %s, domain: %s, endpoint type: %d",
+				fi->fabric_attr->name, fi->domain_attr->name,
+				fi->ep_attr->type);
+		ret = check(info);
+		if (ret)
+			break;
+	}
+out:
+	fi_freeinfo(info);
+	return ret;
+}
+
+#define getinfo_test(num, desc, node, service, flags, hints, init, check,	\
+		ret_exp)							\
+char *getinfo ## num ## _desc = desc;						\
+static int getinfo ## num(void)							\
+{										\
+	int ret, testret = FAIL;						\
+	ret = getinfo_unit_test(node, service, flags, hints, init, check,	\
+			ret_exp);						\
+	if (ret)								\
+		goto fail;							\
+	testret = PASS;								\
+fail:										\
+	return TEST_RET_VAL(ret, testret);					\
+}
+
+/*
+ * Tests:
+ */
+
+getinfo_test(1, "Test with no node, service or flags",
+		NULL, NULL, 0, hints, NULL, check_srcaddr, 0)
+getinfo_test(2, "Test with no node, valid service and FI_SOURCE flag",
+		NULL, opts.src_port, FI_SOURCE, hints, NULL, check_srcaddr, 0)
+getinfo_test(3, "Test with node, valid service and FI_SOURCE flag",
+		opts.src_addr ? opts.src_addr : "localhost", opts.src_port,
+		FI_SOURCE, hints, NULL, check_srcaddr, 0)
+getinfo_test(4, "Test with node, no service and FI_SOURCE flag",
+		opts.src_addr ? opts.src_addr : "localhost", NULL,
+		FI_SOURCE, hints, NULL, check_srcaddr, 0)
+getinfo_test(5, "Test with node, service and no flags",
+		opts.dst_addr ? opts.dst_addr : "localhost", opts.dst_port,
+		0, hints, NULL, check_src_dest_addr, 0)
+getinfo_test(6, "Test with non-existent domain name",
+		NULL, NULL, 0, hints, invalid_dom, NULL, -FI_ENODATA)
+
+static void usage(void)
+{
+	ft_unit_usage("getinfo_test", "Unit tests for fi_getinfo");
+	FT_PRINT_OPTS_USAGE("-e <ep_type>", "Endpoint type: msg|rdm|dgram (default:rdm)");
+	ft_addr_usage();
+}
+
+int main(int argc, char **argv)
+{
+	int failed;
+	int op;
+
+	struct test_entry test_array[] = {
+		TEST_ENTRY(getinfo1, getinfo1_desc),
+		TEST_ENTRY(getinfo2, getinfo2_desc),
+		TEST_ENTRY(getinfo3, getinfo3_desc),
+		TEST_ENTRY(getinfo4, getinfo4_desc),
+		TEST_ENTRY(getinfo5, getinfo5_desc),
+		TEST_ENTRY(getinfo6, getinfo6_desc),
+		{ NULL, "" }
+	};
+
+	opts = INIT_OPTS;
+
+	hints = fi_allocinfo();
+	if (!hints)
+		return EXIT_FAILURE;
+
+	while ((op = getopt(argc, argv, ADDR_OPTS INFO_OPTS "h")) != -1) {
+		switch (op) {
+		default:
+			ft_parse_addr_opts(op, optarg, &opts);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case 'h':
+			usage();
+			return EXIT_SUCCESS;
+		case '?':
+			usage();
+			return EXIT_FAILURE;
+		}
+	}
+
+	if (optind < argc)
+		opts.dst_addr = argv[optind];
+	if (!opts.dst_port)
+		opts.dst_port = "9228";
+	if (!opts.src_port)
+		opts.src_port = "9228";
+
+	hints->mode = ~0;
+
+	failed = run_tests(test_array, err_buf);
+	if (failed > 0) {
+		printf("\nSummary: %d tests failed\n", failed);
+	} else {
+		printf("\nSummary: all tests passed\n");
+	}
+
+	ft_free_res();
+	return (failed > 0) ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/unit/size_left_test.c b/unit/size_left_test.c
index 4183c70..7f0c249 100644
--- a/unit/size_left_test.c
+++ b/unit/size_left_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc.  All rights reserved.
+ * Copyright (c) 2015-2016 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2015 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -31,244 +31,297 @@
  * SOFTWARE.
  */
 
-#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <getopt.h>
 #include <string.h>
-#include <sys/types.h>
 
-#include <rdma/fabric.h>
-#include <rdma/fi_domain.h>
 #include <rdma/fi_errno.h>
 #include <rdma/fi_endpoint.h>
 
 #include "shared.h"
 #include "unit_common.h"
 
-
-#define DEBUG(...) \
-	if (fabtests_debug) { \
-		fprintf(stderr, __VA_ARGS__); \
-	}
-
-int fabtests_debug = 0;
-
 static char err_buf[512];
 
-
-static void teardown_ep_fixture(void)
+/* Need to define a separate setup function from the ft_* functions defined in
+ * common/shared.c, this is because extra flexibility is needed in this test.
+ * The ft_* functions have a couple of incompatibility issues with this test:
+ *
+ * - ft_free_res always frees the hints
+ * - ft_init_ep posts a recv
+ */
+static void setup_ep_fixture(void)
 {
-	if (mr != &no_mr)
-		FT_CLOSE_FID(mr);
-	FT_CLOSE_FID(ep);
-	FT_CLOSE_FID(txcq);
-	FT_CLOSE_FID(rxcq);
-	FT_CLOSE_FID(av);
-	if (buf) {
-		free(buf);
-		buf = rx_buf = tx_buf = NULL;
-		buf_size = rx_size = tx_size = 0;
+	int ret;
+
+	ret = fi_fabric(fi->fabric_attr, &fabric, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_fabric", ret);
+		exit(EXIT_FAILURE);
 	}
-}
 
-/* returns 0 on success or a negative value that can be stringified with
- * fi_strerror on error */
-static int setup_ep_fixture(void)
-{
-	int ret;
+	ret = fi_domain(fabric, fi, &domain, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_domain", ret);
+		exit(EXIT_FAILURE);
+	}
 
-	ret = ft_alloc_active_res(fi);
-	if (ret)
-		return ret;
+	/* Queues are opened for providers that need a queue bound before
+	 * calling fi_enable. This avoids getting back -FI_ENOCQ.
+	 */
+	cq_attr.format = FI_CQ_FORMAT_CONTEXT;
+	cq_attr.wait_obj = FI_WAIT_NONE;
 
-	ret = ft_init_ep();
-	if (ret)
-		return ret;
+	ret = fi_cq_open(domain, &cq_attr, &txcq, &txcq);
+	if (ret) {
+		FT_PRINTERR("fi_cq_open", ret);
+		exit(EXIT_FAILURE);
+	}
 
-	return 0;
-}
+	ret = fi_cq_open(domain, &cq_attr, &rxcq, &rxcq);
+	if (ret) {
+		FT_PRINTERR("fi_cq_open", ret);
+		exit(EXIT_FAILURE);
+	}
 
-static int
-rx_size_left(void)
-{
-	int ret;
-	int testret;
+	ret = fi_endpoint(domain, fi, &ep, NULL);
+	if (ret) {
+		FT_PRINTERR("fi_endpoint", ret);
+		exit(EXIT_FAILURE);
+	}
 
-	testret = FAIL;
+	/* Some providers require that an endpoint be bound to an AV before
+	 * calling fi_enable on unconnected endpoints.
+	 */
+	if (fi->ep_attr->type == FI_EP_RDM ||
+	    fi->ep_attr->type == FI_EP_DGRAM) {
+		ret = fi_av_open(domain, &av_attr, &av, NULL);
+		if (ret) {
+			FT_PRINTERR("fi_av_open", ret);;
+			exit(EXIT_FAILURE);
+		}
 
-	ret = setup_ep_fixture();
-	if (ret != 0) {
-		printf("failed to setup test fixture: %s\n", fi_strerror(-ret));
-		goto fail;
+		ret = fi_ep_bind(ep, &av->fid, 0);
+		if (ret) {
+			FT_PRINTERR("fi_ep_bind", ret);
+			exit(EXIT_FAILURE);
+		}
 	}
 
-	ret = fi_rx_size_left(ep);
-	if (ret < 0) {
-		printf("fi_rx_size_left returned %d (-%s)\n", ret,
-			fi_strerror(-ret));
-		goto fail;
+	/* MSG endpoints require EQ to be bound to an endpoint */
+	if (fi->ep_attr->type == FI_EP_MSG) {
+		ret = fi_eq_open(fabric, &eq_attr, &eq, NULL);
+		if (ret) {
+			FT_PRINTERR("fi_eq_open", ret);
+			exit(EXIT_FAILURE);
+		}
+		ret = fi_ep_bind(ep, &eq->fid, 0);
+		if (ret) {
+			FT_PRINTERR("fi_ep_bind", ret);
+			exit(EXIT_FAILURE);
+		}
 	}
 
-	/* TODO: add basic sanity checking here */
+	ret = fi_ep_bind(ep, &txcq->fid, FI_TRANSMIT);
+	if (ret) {
+		FT_PRINTERR("fi_ep_bind", ret);
+		exit(EXIT_FAILURE);
+	}
 
-	testret = PASS;
-fail:
-	teardown_ep_fixture();
-	return TEST_RET_VAL(ret, testret);
+	ret = fi_ep_bind(ep, &rxcq->fid, FI_RECV);
+	if (ret) {
+		FT_PRINTERR("fi_ep_bind", ret);
+		exit(EXIT_FAILURE);
+	}
 }
 
-static int
-rx_size_left_err(void)
+/* Teardown after every test. */
+static void teardown_ep_fixture(void)
 {
-	int ret;
-	int testret;
+	FT_CLOSE_FID(ep);
+	FT_CLOSE_FID(av);
+	FT_CLOSE_FID(rxcq);
+	FT_CLOSE_FID(txcq);
+	FT_CLOSE_FID(domain);
+	FT_CLOSE_FID(eq);
+	FT_CLOSE_FID(fabric);
+}
 
-	testret = FAIL;
+/* Test that a provider returns -FI_EOPBADSTATE before an endpoint has been
+ * enabled.
+ */
+static int test_size_left_bad(void)
+{
+	ssize_t ret;
+	int testret;
 
-	/* datapath operation, not expected to be caught by libfabric */
-#if 0
-	ret = fi_rx_size_left(NULL);
-	if (ret != -FI_EINVAL) {
+	FT_DEBUG("testing fi_rx_size_left for -FI_EOPBADSTATE");
+	ret = fi_rx_size_left(ep);
+	if (ret != -FI_EOPBADSTATE)
 		goto fail;
-	}
-#endif
 
-	ret = fi_endpoint(domain, fi, &ep, NULL);
-	if (ret != 0) {
-		printf("fi_endpoint %s\n", fi_strerror(-ret));
+	FT_DEBUG("testing fi_tx_size_left for -FI_EOPBADSTATE");
+	ret = fi_tx_size_left(ep);
+	if (ret != -FI_EOPBADSTATE)
 		goto fail;
-	}
 
-	/* ep starts in a non-enabled state, may fail, should not SEGV */
-	fi_rx_size_left(ep);
+	return PASS;
 
-	testret = PASS;
 fail:
-	FT_CLOSE_FID(ep);
-	return TEST_RET_VAL(ret, testret);
+	testret = TEST_RET_VAL(ret, FAIL);
+	if (testret == SKIPPED)
+		snprintf(err_buf, sizeof(err_buf),
+			 "provider returned: [%zd]: <%s>", ret,
+			 fi_strerror(-ret));
+	else
+		snprintf(err_buf, sizeof(err_buf),
+			 "%zd not equal to -FI_EOPBADSTATE", ret);
+
+	return testret;
 }
 
-static int
-tx_size_left(void)
+/* Test that the initial sizes are equal to the size attribute for the tx and rx
+ * context.
+ */
+static int test_size_left_good(void)
 {
-	int ret;
+	ssize_t expected;
+	ssize_t ret;
 	int testret;
 
-	testret = FAIL;
+	FT_DEBUG("testing fi_rx_size_left for size equal to or greater than fi->rx_attr->size");
+	expected = fi->rx_attr->size;
 
-	ret = setup_ep_fixture();
-	if (ret != 0) {
-		printf("failed to setup test fixture: %s\n", fi_strerror(-ret));
+	ret = fi_rx_size_left(ep);
+	if (ret < expected)
 		goto fail;
-	}
+
+	FT_DEBUG("testing fi_tx_size_left for size equal to or greater than fi->tx_attr->size");
+	expected = fi->tx_attr->size;
 
 	ret = fi_tx_size_left(ep);
-	if (ret < 0) {
-		printf("fi_rx_size_left returned %d (-%s)\n", ret,
-			fi_strerror(-ret));
+	if (ret < expected)
 		goto fail;
-	}
 
-	/* TODO: once fi_tx_attr's size field meaning has been fixed to refer to
-	 * queue depth instead of number of bytes, we can do a little basic
-	 * sanity checking here */
+	return PASS;
 
-	testret = PASS;
 fail:
-	teardown_ep_fixture();
-	return TEST_RET_VAL(ret, testret);
+	testret = TEST_RET_VAL(ret, FAIL);
+	if (testret == SKIPPED)
+		snprintf(err_buf, sizeof(err_buf),
+			 "provider returned: [%zd]: <%s>", ret,
+			 fi_strerror(-ret));
+	else
+		snprintf(err_buf, sizeof(err_buf),
+			 "%zd not greater than or equal to %zd", ret, expected);
+
+	return testret;
 }
 
-struct test_entry test_rx_size_left[] = {
-	TEST_ENTRY(rx_size_left_err),
-	TEST_ENTRY(rx_size_left),
+/* Separate these into separate entries since one of them needs to get run
+ * before the endpoint is enabled, and one needs to be run after the endpoint is
+ * enabled.
+ */
+struct test_entry bad_tests[] = {
+	TEST_ENTRY(test_size_left_bad,
+			"Test if provider returns error when endpoint is not enabled"),
 	{ NULL, "" }
 };
 
-struct test_entry test_tx_size_left[] = {
-	TEST_ENTRY(tx_size_left),
+struct test_entry good_tests[] = {
+	TEST_ENTRY(test_size_left_good,
+			"Test size left after endpoint is enabled"),
 	{ NULL, "" }
 };
 
-/* TODO: Rewrite test to use size_left() during data transfers and check
- * that posted sends complete when indicated and check for proper failures
- * when size_left() returns 0.
- */
-int run_test_set(void)
+int run_test_set(struct fi_info *hints)
 {
-	int failed;
+	struct fi_info *info;
+	int failed = 0;
+	int ep_type;
+	int ret;
+
+	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &info);
+	if (ret) {
+		FT_PRINTERR("fi_getinfo", ret);
+		exit(EXIT_FAILURE);
+	}
+
+	for (ep_type = FI_EP_MSG; ep_type <= FI_EP_RDM; ep_type++) {
+		for (fi = info; fi; fi = fi->next) {
+			if (fi->ep_attr->type == ep_type)
+				break;
+		}
+
+		if (!fi)
+			continue;
 
-	failed = 0;
-	failed += run_tests(test_rx_size_left, err_buf);
-	failed += run_tests(test_tx_size_left, err_buf);
+		setup_ep_fixture();
+
+		printf("Testing provider %s on fabric %s with EP type %s\n",
+				fi->fabric_attr->prov_name,
+				fi->fabric_attr->name,
+				fi_tostr(&ep_type, FI_TYPE_EP_TYPE));
+
+		failed += run_tests(bad_tests, err_buf);
+
+		ret = fi_enable(ep);
+		if (ret) {
+			FT_PRINTERR("fi_enable", ret);
+			exit(EXIT_FAILURE);
+		}
+
+		failed += run_tests(good_tests, err_buf);
+
+		teardown_ep_fixture();
+	}
+
+	fi_freeinfo(info);
 
 	return failed;
 }
 
+static void usage(void)
+{
+	ft_unit_usage("size_left_test", "Unit test for checking TX and RX context sizes");
+}
+
 int main(int argc, char **argv)
 {
-	int op, ret;
+	int op;
 	int failed;
-	char *debug_str;
 
 	opts = INIT_OPTS;
 	opts.options |= FT_OPT_SIZE;
 
-	debug_str = getenv("FABTESTS_DEBUG");
-	if (debug_str) {
-		fabtests_debug = atoi(debug_str);
-	}
-
 	hints = fi_allocinfo();
 	if (!hints)
-		exit(1);
+		return EXIT_FAILURE;
 
-	while ((op = getopt(argc, argv, "f:a:")) != -1) {
+	while ((op = getopt(argc, argv, FAB_OPTS "h")) != -1) {
 		switch (op) {
-		case 'a':
-			free(hints->fabric_attr->name);
-			hints->fabric_attr->name = strdup(optarg);
-			break;
-		case 'f':
-			free(hints->fabric_attr->prov_name);
-			hints->fabric_attr->prov_name = strdup(optarg);
-			break;
 		default:
-			printf("usage: %s\n", argv[0]);
-			printf("\t[-a fabric_name]\n");
-			printf("\t[-f provider_name]\n");
-			exit(1);
+			ft_parseinfo(op, optarg, hints);
+			break;
+		case '?':
+		case 'h':
+			usage();
+			return EXIT_FAILURE;
 		}
 	}
 
 	hints->mode = ~0;
-	hints->ep_attr->type = FI_EP_RDM;
 	hints->caps = FI_MSG;
 
-	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &fi);
-	if (ret != 0) {
-		printf("fi_getinfo %s\n", fi_strerror(-ret));
-		exit(-ret);
-	}
+	failed = run_test_set(hints);
 
-	DEBUG("using provider \"%s\" and fabric \"%s\"\n",
-		fi->fabric_attr->prov_name,
-		fi->fabric_attr->name);
-
-	ret = ft_open_fabric_res();
-	if (ret)
-		return ret;
-
-	failed = run_test_set();
-
-	if (failed > 0) {
+	if (failed)
 		printf("Summary: %d tests failed\n", failed);
-	} else {
-		printf("Summary: all tests passed\n");
-	}
+	else
+		printf("Summary: all tests passed!\n");
+
+	fi_freeinfo(hints);
 
-	ft_free_res();
-	return (failed > 0);
+	return (failed > 0) ? EXIT_FAILURE : EXIT_SUCCESS;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ofed/fabtests.git



More information about the Pkg-ofed-commits mailing list