1
1
Этот коммит содержится в:
Jeff Squyres 2015-02-13 14:44:06 -08:00
родитель c203ea29aa
Коммит 3abebe7251
88 изменённых файлов: 1468 добавлений и 962 удалений

Просмотреть файл

@ -4,3 +4,7 @@ Jeff Squyres <jsquyres@cisco.com>
Jianxin Xiong <jianxin.xiong@intel.com>
Sayantan Sur <sayantan.sur@intel.com>
Xuyang Wang <xuywang@cisco.com>
Patrick McCormick <patrick.m.mccormick@intel.com>
Dave Goodell <dgoodell@cisco.com>
Jithin Jose <jithin.jose@intel.com>
Miao Luo <miao.luo@intel.com>

Просмотреть файл

@ -1,3 +1,5 @@
# Makefile.am for libfabric
AM_CPPFLAGS = \
-I$(srcdir)/include \
-D_GNU_SOURCE \
@ -43,6 +45,19 @@ src_libfabric_la_SOURCES = \
src/log.c \
$(common_srcs)
if MACOS
src_libfabric_la_SOURCES += src/osx/osd.c
src_libfabric_la_SOURCES += include/osx/osd.h
endif
if LINUX
src_libfabric_la_SOURCES += include/linux/osd.h
endif
src_libfabric_la_CPPFLAGS = $(AM_CPPFLAGS)
src_libfabric_la_LDFLAGS =
src_libfabric_la_LIBADD =
if HAVE_SOCKETS
_sockets_files = \
prov/sockets/src/sock.h \
@ -66,7 +81,6 @@ _sockets_files = \
prov/sockets/src/sock_msg.c \
prov/sockets/src/sock_rma.c \
prov/sockets/src/sock_atomic.c \
prov/sockets/src/sock_util.c \
prov/sockets/src/sock_util.h \
prov/sockets/src/indexer.c
@ -88,11 +102,20 @@ _verbs_files = prov/verbs/src/fi_verbs.c
if HAVE_VERBS_DL
pkglib_LTLIBRARIES += libverbs-fi.la
libverbs_fi_la_SOURCES = $(_verbs_files) $(common_srcs)
libverbs_fi_la_LIBADD = $(linkback)
libverbs_fi_la_LDFLAGS = -module -avoid-version -shared -export-dynamic
# Technically, verbs_ibverbs_CPPFLAGS and verbs_rdmacm_CPPFLAGS could
# be different, but it is highly unlikely that they ever will be. So
# only list verbs_ibverbs_CPPFLAGS here. Same with verbs_*_LDFLAGS,
# below.
libverbs_fi_la_CPPFLAGS = $(AM_CPPFLAGS) $(verbs_ibverbs_CPPFLAGS)
libverbs_fi_la_LDFLAGS = \
-module -avoid-version -shared -export-dynamic $(verbs_ibverbs_LDFLAGS)
libverbs_fi_la_LIBADD = $(linkback) $(verbs_rdmacm_LIBS) $(verbs_ibverbs_LIBS)
libverbs_fi_la_DEPENDENCIES = $(linkback)
else !HAVE_VERBS_DL
src_libfabric_la_SOURCES += $(_verbs_files)
src_libfabric_la_CPPFLAGS += $(verbs_ibverbs_CPPFLAGS)
src_libfabric_la_LDFLAGS += $(verbs_ibverbs_LDFLAGS)
src_libfabric_la_LIBADD += $(verbs_rdmacm_LIBS) $(verbs_ibverbs_LIBS)
endif !HAVE_VERBS_DL
endif HAVE_VERBS
@ -192,7 +215,7 @@ _usnic_files = \
_usnic_cppflags = \
-D__LIBUSNIC__ \
-DHAVE_LIBNL3=$(HAVE_LIBNL3) $(USNIC_LIBNL_CPPFLAGS) \
-DHAVE_LIBNL3=$(HAVE_LIBNL3) $(usnic_libnl_CPPFLAGS) \
-I$(top_srcdir)/prov/usnic/src/usnic_direct
rdmainclude_HEADERS += \
@ -202,12 +225,13 @@ if HAVE_USNIC_DL
pkglib_LTLIBRARIES += libusnic-fi.la
libusnic_fi_la_CPPFLAGS = $(AM_CPPFLAGS) $(_usnic_cppflags)
libusnic_fi_la_SOURCES = $(_usnic_files) $(common_srcs)
libusnic_fi_la_LIBADD = $(linkback)
libusnic_fi_la_LDFLAGS = -module -avoid-version -shared -export-dynamic
libusnic_fi_la_LIBADD = $(linkback) $(usnic_libnl_LIBS)
libusnic_fi_la_DEPENDENCIES = $(linkback)
else !HAVE_USNIC_DL
AM_CPPFLAGS += $(_usnic_cppflags)
src_libfabric_la_SOURCES += $(_usnic_files)
src_libfabric_la_CPPFLAGS += $(_usnic_cppflags)
src_libfabric_la_LIBADD += $(usnic_libnl_LIBS)
endif !HAVE_USNIC_DL
endif HAVE_USNIC
@ -238,16 +262,21 @@ _psm_files = \
if HAVE_PSM_DL
pkglib_LTLIBRARIES += libpsmx-fi.la
libpsmx_fi_la_SOURCES = $(_psm_files) $(common_srcs)
libpsmx_fi_la_LIBADD = $(linkback)
libpsmx_fi_la_LDFLAGS = -module -avoid-version -shared -export-dynamic
libpsmx_fi_la_CPPFLAGS = $(AM_CPPFLAGS) $(psm_CPPFLAGS)
libpsmx_fi_la_LDFLAGS = \
-module -avoid-version -shared -export-dynamic $(psm_LDFLAGS)
libpsmx_fi_la_LIBADD = $(linkback) $(psm_LIBS)
libpsmx_fi_la_DEPENDENCIES = $(linkback)
else !HAVE_PSM_DL
src_libfabric_la_SOURCES += $(_psm_files)
src_libfabric_la_CPPFLAGS += $(psm_CPPFLAGS)
src_libfabric_la_LDFLAGS += $(psm_LDFLAGS)
src_libfabric_la_LIBADD += $(psm_LIBS)
endif !HAVE_PSM_DL
endif HAVE_PSM
src_libfabric_la_LDFLAGS = -version-info 1 -export-dynamic \
src_libfabric_la_LDFLAGS += -version-info 1 -export-dynamic \
$(libfabric_version_script)
src_libfabric_la_DEPENDENCIES = $(srcdir)/libfabric.map

Просмотреть файл

@ -1,7 +1,7 @@
This README is for userspace RDMA fabric library.
Version Libfabric v1.0.0-rc1
Released on 2015-02-03
Version Libfabric v1.0.0rc1
Released on 2015-02-13
Building
========

Просмотреть файл

@ -4,36 +4,36 @@
*/
#undef ENABLE_DEBUG
/* Define to 1 if the linker supports alias attribute. */
#undef HAVE_ALIAS_ATTRIBUTE
/* Set to 1 to use c11 atomic functions */
#undef HAVE_ATOMICS
/* Define HAVE_CLOCK_GETTIME to 1 if available. */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define HAVE_HOST_GET_CLOCK_SERVICE to 1 if available. */
#undef HAVE_HOST_GET_CLOCK_SERVICE
/* Define to 1 if you have the <infiniband/verbs.h> header file. */
#undef HAVE_INFINIBAND_VERBS_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL
/* Define to 1 if you have the `ibverbs' library (-libverbs). */
#undef HAVE_LIBIBVERBS
/* set to 1 if should use libnl v3, set to 0 for libnl v11 */
#undef HAVE_LIBNL3
/* Define to 1 if you have the `psm_infinipath' library (-lpsm_infinipath). */
#undef HAVE_LIBPSM_INFINIPATH
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `rdmacm' library (-lrdmacm). */
#undef HAVE_LIBRDMACM
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
@ -43,6 +43,12 @@
/* psm provider is built as DSO */
#undef HAVE_PSM_DL
/* Define to 1 if you have the <psm.h> header file. */
#undef HAVE_PSM_H
/* Define to 1 if you have the <rdma/rsocket.h> header file. */
#undef HAVE_RDMA_RSOCKET_H
/* sockets provider is built */
#undef HAVE_SOCKETS

Просмотреть файл

@ -0,0 +1,215 @@
dnl -*- m4 -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
dnl
dnl This file derived from config/opal_check_package.m4 in Open MPI.
dnl
dnl _FI_CHECK_PACKAGE_HEADER(prefix, header, dir-prefix,
dnl [action-if-found], [action-if-not-found],
dnl includes)
dnl --------------------------------------------------------------------
AC_DEFUN([_FI_CHECK_PACKAGE_HEADER], [
# This is stolen from autoconf to peek under the covers to get the
# cache variable for the library check.
AS_VAR_PUSHDEF([fi_Header], [ac_cv_header_$2])
# There's unfortunately no way to get through the progression of
# header includes without killing off the cache variable and
# trying again...
unset fi_Header
fi_check_package_header_happy="no"
AS_IF([test "$3" = "/usr" || test "$3" = "/usr/local"],
[ # try as is...
AC_VERBOSE([looking for header without includes])
AC_CHECK_HEADERS([$2], [fi_check_package_header_happy="yes"], [])
AS_IF([test "$fi_check_package_header_happy" = "no"],
[# no go on the as is - reset the cache and try again
unset fi_Header])])
AS_IF([test "$fi_check_package_header_happy" = "no"],
[AS_IF([test "$3" != ""],
[$1_CPPFLAGS="$$1_CPPFLAGS -I$3/include"
CPPFLAGS="$CPPFLAGS -I$3/include"])
AC_CHECK_HEADERS([$2], [fi_check_package_header_happy="yes"], [], [$6])
AS_IF([test "$fi_check_package_header_happy" = "yes"], [$4], [$5])],
[$4])
unset fi_check_package_header_happy
AS_VAR_POPDEF([fi_Header])dnl
])
dnl _FI_CHECK_PACKAGE_LIB(prefix, library, function, extra-libraries,
dnl dir-prefix, libdir,
dnl [action-if-found], [action-if-not-found]])
dnl --------------------------------------------------------------------
AC_DEFUN([_FI_CHECK_PACKAGE_LIB], [
# This is stolen from autoconf to peek under the covers to get the
# cache variable for the library check.
AS_LITERAL_IF([$2],
[AS_VAR_PUSHDEF([fi_Lib], [ac_cv_lib_$2_$3])],
[AS_VAR_PUSHDEF([fi_Lib], [ac_cv_lib_$2''_$3])])dnl
# See comment above
unset fi_Lib
fi_check_package_lib_happy="no"
AS_IF([test "$6" != ""],
[ # libdir was specified - search only there
$1_LDFLAGS="$$1_LDFLAGS -L$6"
LDFLAGS="$LDFLAGS -L$6"
AC_CHECK_LIB([$2], [$3],
[fi_check_package_lib_happy="yes"],
[fi_check_package_lib_happy="no"], [$4])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[LDFLAGS="$fi_check_package_$1_save_LDFLAGS"
$1_LDFLAGS="$fi_check_package_$1_orig_LDFLAGS"
unset fi_Lib])],
[ # libdir was not specified - go through search path
fi_check_package_libdir="$5"
AS_IF([test "$fi_check_package_libdir" = "" || \
test "$fi_check_package_libdir" = "/usr" || \
test "$fi_check_package_libdir" = "/usr/local"],
[ # try as is...
AC_VERBOSE([looking for library without search path])
AC_CHECK_LIB([$2], [$3],
[fi_check_package_lib_happy="yes"],
[fi_check_package_lib_happy="no"], [$4])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[ # no go on the as is.. see what happens later...
LDFLAGS="$fi_check_package_$1_save_LDFLAGS"
$1_LDFLAGS="$fi_check_package_$1_orig_LDFLAGS"
unset fi_Lib])])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[AS_IF([test "$fi_check_package_libdir" != ""],
[$1_LDFLAGS="$$1_LDFLAGS -L$fi_check_package_libdir/lib"
LDFLAGS="$LDFLAGS -L$fi_check_package_libdir/lib"
AC_VERBOSE([looking for library in lib])
AC_CHECK_LIB([$2], [$3],
[fi_check_package_lib_happy="yes"],
[fi_check_package_lib_happy="no"], [$4])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[ # no go on the as is.. see what happens later...
LDFLAGS="$fi_check_package_$1_save_LDFLAGS"
$1_LDFLAGS="$fi_check_package_$1_orig_LDFLAGS"
unset fi_Lib])])])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[AS_IF([test "$fi_check_package_libdir" != ""],
[$1_LDFLAGS="$$1_LDFLAGS -L$fi_check_package_libdir/lib64"
LDFLAGS="$LDFLAGS -L$fi_check_package_libdir/lib64"
AC_VERBOSE([looking for library in lib64])
AC_CHECK_LIB([$2], [$3],
[fi_check_package_lib_happy="yes"],
[fi_check_package_lib_happy="no"], [$4])
AS_IF([test "$fi_check_package_lib_happy" = "no"],
[ # no go on the as is.. see what happens later...
LDFLAGS="$fi_check_package_$1_save_LDFLAGS"
$1_LDFLAGS="$fi_check_package_$1_orig_LDFLAGS"
unset fi_Lib])])])])
AS_IF([test "$fi_check_package_lib_happy" = "yes"],
[$1_LIBS="-l$2 $4"
$7], [$8])
AS_VAR_POPDEF([fi_Lib])dnl
])
dnl FI_CHECK_PACKAGE(prefix,
dnl header,
dnl library,
dnl function,
dnl extra-libraries,
dnl dir-prefix,
dnl libdir-prefix,
dnl [action-if-found], [action-if-not-found],
dnl includes)
dnl -----------------------------------------------------------
dnl Check for package defined by header and libs, and probably
dnl located in dir-prefix, possibly with libs in libdir-prefix.
dnl Both dir-prefix and libdir-prefix can be empty. Will set
dnl prefix_{CPPFLAGS, LDFLAGS, LIBS} as needed.
dnl
dnl The general intent of this macro is to provide finer-grained scoping
dnl of C preprocessor flags, linker flags, and libraries (as opposed to
dnl unconditionally adding to the top-level CPFLAGS, LDFLAGS, and LIBS,
dnl which get used to compile/link *everything*).
dnl
dnl Here's a breakdown of the parameters:
dnl
dnl * prefix: the macro sets $prefix_CPPFLAGS, $prefix_LDFLAGS, and
dnl $prefix_LIBS (and AC_SUBSTs all of them). For example, if a
dnl provider uses this macro to check for a header/library that it
dnl needs, it might well set prefix to be its provider name.
dnl * header_filename: the foo.h file to check for
dnl * library_name / function_name: check for function function_name in
dnl -llibrary_name. Specifically, for library_name, use the "foo" form,
dnl as opposed to "libfoo".
dnl * extra_libraries: if the library_name you are checking for requires
dnl additonal -l arguments to link successfully, list them here.
dnl * dir_prefix: if the header/library is located in a non-standard
dnl location (e.g., /opt/foo as opposed to /usr), list it here
dnl * libdir_prefix: if the library is not under $dir_prefix/lib or
dnl $dir_prefix/lib64, list it here.
dnl * action_if_found: if both the header and library are found and
dnl usable, execute action_if_found
dnl * action_if_not_found: otherwise, execute action_if_not_found
dnl * extra_includes: if including header_filename requires additional
dnl headers to be included first, list them here
dnl
dnl The output _CPPFLAGS, _LDFLAGS, and _LIBS can be used to limit the
dnl scope various flags in Makefiles.
dnl
AC_DEFUN([FI_CHECK_PACKAGE],[
fi_check_package_$1_save_CPPFLAGS="$CPPFLAGS"
fi_check_package_$1_save_LDFLAGS="$LDFLAGS"
fi_check_package_$1_save_LIBS="$LIBS"
fi_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS"
fi_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS"
fi_check_package_$1_orig_LIBS="$$1_LIBS"
_FI_CHECK_PACKAGE_HEADER([$1], [$2], [$6],
[_FI_CHECK_PACKAGE_LIB([$1], [$3], [$4], [$5], [$6], [$7],
[fi_check_package_happy="yes"],
[fi_check_package_happy="no"])],
[fi_check_package_happy="no"],
[$10])
AS_IF([test "$fi_check_package_happy" = "yes"],
[$8],
[$1_CPPFLAGS="$fi_check_package_$1_orig_CPPFLAGS"
$1_LDFLAGS="$fi_check_package_$1_orig_LDFLAGS"
$1_LIBS="$fi_check_package_$1_orig_LIBS"
$9])
AC_SUBST($1_CPPFLAGS)
AC_SUBST($1_LDFLAGS)
AC_SUBST($1_LIBS)
CPPFLAGS="$fi_check_package_$1_save_CPPFLAGS"
LDFLAGS="$fi_check_package_$1_save_LDFLAGS"
LIBS="$fi_check_package_$1_save_LIBS"
])

Просмотреть файл

@ -9,6 +9,8 @@ AC_DEFUN([FI_PROVIDER_INIT],[
PROVIDERS_DL=
PROVIDERS_STATIC=
PROVIDERS_COUNT=
m4_include(config/fi_check_package.m4)
])
dnl

Просмотреть файл

@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([libfabric], [1.0.0-rc1], [ofiwg@lists.openfabrics.org])
AC_INIT([libfabric], [1.0.0rc1], [ofiwg@lists.openfabrics.org])
AC_CONFIG_SRCDIR([src/fabric.c])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
@ -9,6 +9,26 @@ AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([1.11 dist-bzip2 foreign -Wall -Werror subdir-objects parallel-tests])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CANONICAL_HOST
macos=0
linux=0
case $host_os in
*darwin*)
macos=1
;;
*linux*)
linux=1
;;
*)
AC_MSG_ERROR([libfabric only builds on Linux & OS X])
;;
esac
AM_CONDITIONAL([MACOS], [test "x$macos" = "x1"])
AM_CONDITIONAL([LINUX], [test "x$linux" = "x1"])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable debugging @<:@default=no@:>@])
@ -54,10 +74,6 @@ AC_PROG_CC_C99
dnl Checks for header files.
AC_HEADER_STDC
dnl Only build on Linux
AC_CHECK_HEADER([linux/types.h], [],
[AC_MSG_ERROR([libfabric only builds on Linux])])
LT_INIT
dnl dlopen support is optional
@ -74,8 +90,21 @@ AC_CHECK_LIB(dl, dlopen, [],
dnl Checks for libraries
AC_CHECK_LIB(pthread, pthread_mutex_init, [],
AC_MSG_ERROR([pthread_mutex_init() not found. libfabric requires libpthread.]))
AC_CHECK_LIB(rt, clock_gettime, [],
AC_MSG_ERROR([clock_gettime() not found. libfabric requires librt.]))
have_clock_gettime=0
have_host_get_clock_service=0
AC_SEARCH_LIBS([clock_gettime],[rt],
[have_clock_gettime=1],
[AC_CHECK_FUNCS([host_get_clock_service],
[have_host_get_clock_service=1],
[AC_MSG_ERROR([clock_gettime or host_get_clock_service
not found.])])])
AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME, [$have_clock_gettime],
[Define HAVE_CLOCK_GETTIME to 1 if available.])
AC_DEFINE_UNQUOTED(HAVE_HOST_GET_CLOCK_SERVICE, [$have_host_get_clock_service],
[Define HAVE_HOST_GET_CLOCK_SERVICE to 1 if available.])
dnl Check for gcc atomic intrinsics
AC_MSG_CHECKING(compiler support for c11 atomics)
@ -129,6 +158,18 @@ if test x$ac_cv_asm_symver_support = xyes; then
AC_DEFINE([HAVE_SYMVER_SUPPORT], 1, [assembler has .symver support])
fi
AC_LINK_IFELSE(
[AC_LANG_SOURCE[
int foo(int arg);
int foo(int arg) { return arg + 3; };
int foo2(int arg) __attribute__ (( __alias__("foo")));
]],
[ac_cv_prog_cc_alias_symbols=1],
[ac_cv_prog_cc_alias_symbols=0])
AC_DEFINE_UNQUOTED([HAVE_ALIAS_ATTRIBUTE], [$ac_cv_prog_cc_alias_symbols],
[Define to 1 if the linker supports alias attribute.])
dnl Provider-specific checks
FI_PROVIDER_INIT
FI_PROVIDER_SETUP([psm])
@ -158,21 +199,17 @@ if test "$PROVIDERS_TO_BUILD" = ""; then
exit 1
fi
echo "***"
for i in $PROVIDERS_TO_BUILD; do
v=${i}_dl
if test `eval echo \\$${v}` != "1"; then
builtin="$i ${builtin}"
fi
done
echo -e "*** Built-in providers:\t${builtin}"
echo "***"
for i in $PROVIDERS_TO_BUILD; do
v=${i}_dl
if test `eval echo \\$${v}` == "1"; then
dso="$i ${dso}"
else
builtin="$i ${builtin}"
fi
done
echo -e "*** DSO providers:\t${dso}"
echo "***"
cat <<EOF
***
*** Built-in providers: ${builtin}
*** DSO providers: ${dso}
***
EOF

Просмотреть файл

@ -38,14 +38,18 @@
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <byteswap.h>
#include <endian.h>
#include <pthread.h>
#include <string.h>
#include <rdma/fabric.h>
#include <rdma/fi_prov.h>
#include <rdma/fi_atomic.h>
#ifdef __APPLE__
#include <osx/osd.h>
#else
#include <linux/osd.h>
#endif
#ifdef HAVE_ATOMICS
# include <stdatomic.h>
#endif
@ -66,25 +70,35 @@ extern "C" {
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
#ifndef htonll
static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
#endif
#ifndef ntohll
static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
#endif
#else
#ifndef htonll
static inline uint64_t htonll(uint64_t x) { return x; }
#endif
#ifndef ntohll
static inline uint64_t ntohll(uint64_t x) { return x; }
#endif
#endif
#define sizeof_field(type, field) sizeof(((type *)0)->field)
#define MIN(a, b) ((a) < (b) ? a : b)
#define MAX(a, b) ((a) > (b) ? a : b)
static inline int flsll(long long int i)
/* flsll is defined on BSD systems, but is different. */
static inline int fi_flsll(long long int i)
{
return i ? 65 - ffsll(htonll(i)) : 0;
}
static inline uint64_t roundup_power_of_two(uint64_t n)
{
return 1ULL << flsll(n - 1);
return 1ULL << fi_flsll(n - 1);
}
#define FI_TAG_GENERIC 0xAAAAAAAAAAAAAAAAULL
@ -200,17 +214,27 @@ int fi_rma_target_allowed(uint64_t caps);
#define DEFAULT_ABI "FABRIC_1.0"
#if HAVE_ALIAS_ATTRIBUTE == 1
#define DEFAULT_SYMVER_PRE(a) a##_
#else
#define DEFAULT_SYMVER_PRE(a) a
#endif
/* symbol -> external symbol mappings */
#ifdef HAVE_SYMVER_SUPPORT
# define symver(name, api, ver) \
# define SYMVER(name, api, ver) \
asm(".symver " #name "," #api "@" #ver)
# define default_symver(name, api) \
# define DEFAULT_SYMVER(name, api) \
asm(".symver " #name "," #api "@@" DEFAULT_ABI)
#else
# define symver(name, api, ver)
# define default_symver(name, api) \
extern __typeof(name) api __attribute__((alias(#name)))
# define SYMVER(Name, api, ver)
#if HAVE_ALIAS_ATTRIBUTE == 1
# define DEFAULT_SYMVER(name, api) \
extern typeof (name) api __attribute__((alias(#name)));
#else
# define DEFAULT_SYMVER(name, api)
#endif /* HAVE_ALIAS_ATTRIBUTE == 1*/
#endif /* HAVE_SYMVER_SUPPORT */

Просмотреть файл

@ -91,6 +91,24 @@ static inline void dlist_remove(struct dlist_entry *item)
}
typedef int dlist_match_func_t(struct dlist_entry *item, const void *arg);
static inline struct dlist_entry *
dlist_remove_first_match(struct dlist_entry *head, dlist_match_func_t *match,
const void *arg)
{
struct dlist_entry *item;
for (item = head->next; item != head; item = item->next) {
if (match(item, arg)) {
dlist_remove(item);
return item;
}
}
return NULL;
}
/*
* Single-linked list
*/
@ -145,6 +163,30 @@ static inline struct slist_entry *slist_remove_head(struct slist *list)
return item;
}
typedef int slist_match_func_t(struct slist_entry *item, const void *arg);
static inline struct slist_entry *
slist_remove_first_match(struct slist *list, slist_match_func_t *match, const void *arg)
{
struct slist_entry *item, *prev;
for (prev = NULL, item = list->head; item; prev = item, item = item->next) {
if (match(item, arg)) {
if (prev)
prev->next = item->next;
else
list->head = item->next;
if (!item->next)
list->tail = prev;
return item;
}
}
return NULL;
}
/*
* Double-linked list with blocking wait-until-avail support
*/
@ -197,7 +239,7 @@ static inline int dlistfd_empty(struct dlistfd_head *head)
static inline void dlistfd_signal(struct dlistfd_head *head)
{
if (head->fdwcnt == head->fdrcnt) {
write(head->fd[LIST_WRITE_FD], head, sizeof head);
(void) write(head->fd[LIST_WRITE_FD], head, sizeof head);
head->fdwcnt++;
}
}
@ -206,7 +248,7 @@ static inline void dlistfd_reset(struct dlistfd_head *head)
{
void *buf;
if (dlistfd_empty(head) && (head->fdrcnt < head->fdwcnt)) {
read(head->fd[LIST_READ_FD], &buf, sizeof buf);
(void) read(head->fd[LIST_READ_FD], &buf, sizeof buf);
head->fdrcnt++;
}
}

Просмотреть файл

@ -42,8 +42,9 @@ extern int fi_log_level;
void fi_log_init(void);
void fi_warn_impl(const char *prov, const char *fmt, ...);
void fi_log_impl(int level, const char *prov, const char *fmt, ...);
void fi_debug_impl(const char *prov, const char *fmt, ...);
void fi_log_impl(int level, const char *prov, const char *func, int line,
const char *fmt, ...);
void fi_debug_impl(const char *prov, const char *func, int line, const char *fmt, ...);
/* Callers are responsible for including their own trailing "\n". Non-provider
* code should pass prov=NULL.
@ -53,11 +54,11 @@ void fi_debug_impl(const char *prov, const char *fmt, ...);
#define FI_LOG(level, prov, ...) \
do { \
if ((level) <= fi_log_level) \
fi_log_impl(level, prov, __VA_ARGS__); \
fi_log_impl(level, prov, __func__, __LINE__, __VA_ARGS__); \
} while (0)
#if ENABLE_DEBUG
# define FI_DEBUG(prov, ...) fi_debug_impl(prov, __VA_ARGS__)
# define FI_DEBUG(prov, ...) fi_debug_impl(prov, __func__, __LINE__, __VA_ARGS__)
#else
# define FI_DEBUG(prov, ...) do {} while (0)
#endif

Просмотреть файл

@ -0,0 +1,34 @@
/*
* Copyright (c) 2015 Los Alamos Nat. Security, LLC. 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 AND
* 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 <byteswap.h>
#include <endian.h>

Просмотреть файл

@ -0,0 +1,71 @@
/*
* Copyright (c) 2015 Los Alamos Nat. Security, LLC. 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 AND
* 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.
*/
#ifndef _MACH_CLOCK_GETTIME_H_
#define _MACH_CLOCK_GETTIME_H_
#include <sys/time.h>
#include <time.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>
#include <pthread.h>
#define CLOCK_REALTIME CALENDAR_CLOCK
#define CLOCK_MONOTONIC SYSTEM_CLOCK
#define pthread_yield pthread_yield_np
#define bswap_64 OSSwapInt64
#ifdef _POSIX_HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
#else
#define HOST_NAME_MAX 255
#endif
typedef int clockid_t;
#ifdef __cplusplus
extern "C" {
#endif
int clock_gettime(clockid_t clk_id, struct timespec *tp);
#ifdef __cplusplus
}
#endif
#endif

Просмотреть файл

@ -398,6 +398,7 @@ enum {
*/
FI_ALIAS, /* struct fi_alias * */
FI_GETWAIT, /* void * wait object */
FI_ENABLE, /* NULL */
};
static inline int fi_control(struct fid *fid, int command, void *arg)

Просмотреть файл

@ -65,7 +65,6 @@ enum {
struct fi_ops_ep {
size_t size;
int (*enable)(struct fid_ep *ep);
ssize_t (*cancel)(fid_t fid, void *context);
int (*getopt)(fid_t fid, int level, int optname,
void *optval, size_t *optlen);
@ -179,7 +178,7 @@ static inline int fi_scalable_ep_bind(struct fid_ep *sep, struct fid *bfid, uint
static inline int fi_enable(struct fid_ep *ep)
{
return ep->ops->enable(ep);
return ep->fid.ops->control(&ep->fid, FI_ENABLE, NULL);
}
static inline ssize_t fi_cancel(fid_t fid, void *context)

Просмотреть файл

@ -169,7 +169,7 @@ extern "C" {
//#define FI_ENOMEDIUM ENOMEDIUM /* No medium found */
//#define FI_EMEDIUMTYPE EMEDIUMTYPE /* Wrong medium type */
#define FI_ECANCELED ECANCELED /* Operation Canceled */
#define FI_ENOKEY ENOKEY /* Required key not available */
//#define FI_EKEYEXPIRED EKEYEXPIRED /* Key has expired */
//#define FI_EKEYREVOKED EKEYREVOKED /* Key has been revoked */
#define FI_EKEYREJECTED EKEYREJECTED /* Key was rejected by service */
@ -188,6 +188,7 @@ extern "C" {
#define FI_ENOCQ 263 /* Missing or unavailable completion queue */
#define FI_ECRC 264 /* CRC error */
#define FI_ETRUNC 265 /* Truncation error */
#define FI_ENOKEY 266 /* Required key not available */
const char *fi_strerror(int errnum);

Просмотреть файл

@ -1,6 +1,6 @@
Name: libfabric
Version: 1.0.0-rc1
Release: 1.rc1%{?dist}
Version: 1.0.0rc1
Release: 1%{?dist}
Summary: User-space RDMA Fabric Interfaces
Group: System Environment/Libraries
License: GPLv2 or BSD
@ -8,6 +8,11 @@ Url: http://www.github.com/ofiwg/libfabric
Source: http://www.openfabrics.org/downloads/fabrics/%{name}-%{version}.tar.bz2
Prefix: ${_prefix}
BuildRequires: libnl3-devel
BuildRequires: librdmacm-devel
BuildRequires: libibverbs-devel
BuildRequires: infinipath-psm-devel
%description
libfabric provides a user-space API to access high-performance fabric
services, such as RDMA.
@ -25,7 +30,8 @@ Development files for the libfabric library.
%build
# defaults: with-dlopen and without-valgrind can be over-rode:
%configure %{?_without_dlopen} %{?_with_valgrind}
%configure %{?_without_dlopen} %{?_with_valgrind} \
--enable-sockets --enable-verbs --enable-usnic --enable-psm
make %{?_smp_mflags}
%install

Просмотреть файл

@ -1,6 +1,6 @@
Name: libfabric
Version: @VERSION@
Release: 1.rc1%{?dist}
Release: 1%{?dist}
Summary: User-space RDMA Fabric Interfaces
Group: System Environment/Libraries
License: GPLv2 or BSD
@ -8,6 +8,11 @@ Url: http://www.github.com/ofiwg/libfabric
Source: http://www.openfabrics.org/downloads/fabrics/%{name}-%{version}.tar.bz2
Prefix: ${_prefix}
BuildRequires: libnl3-devel
BuildRequires: librdmacm-devel
BuildRequires: libibverbs-devel
BuildRequires: infinipath-psm-devel
%description
libfabric provides a user-space API to access high-performance fabric
services, such as RDMA.
@ -25,7 +30,8 @@ Development files for the libfabric library.
%build
# defaults: with-dlopen and without-valgrind can be over-rode:
%configure %{?_without_dlopen} %{?_with_valgrind}
%configure %{?_without_dlopen} %{?_with_valgrind} \
--enable-sockets --enable-verbs --enable-usnic --enable-psm
make %{?_smp_mflags}
%install

Просмотреть файл

@ -1,4 +1,4 @@
.TH fabric 7 "2014\-12\-15" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fabric 7 "2014\-12\-15" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
Fabric Interface Library

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_av 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_av 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_av - Address vector operations
@ -247,9 +247,6 @@ The addr parameter references an array of addresses to insert into the
AV.
Addresses inserted into an address vector must be in the same format as
specified in struct fi_info:addr_format for the corresponding domain.
A NULL value for an address may be used to indicate that an entry should
be associated with \[aq]any\[aq] address (similar to the IPv4 address of
0.0.0.0).
.PP
For AV\[aq]s of type FI_AV_MAP, once inserted addresses have been
mapped, the mapped values are written into the buffer referenced by

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cm 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_cm 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_cm - Connection management operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cntr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_cntr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_cntr - Completion and event counter operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_cq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_cq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_cq - Completion queue operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_direct 7 "2014\-11\-21" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_direct 7 "2014\-11\-21" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
Direct fabric provider access

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_domain 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_domain 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_domain - Open a fabric access domain

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_endpoint 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_endpoint 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_endpoint - Fabric endpoint operations
@ -1047,12 +1047,6 @@ The buffer will be returned to the application\[aq]s control, and an
\f[I]FI_MULTI_RECV\f[] completion will be generated, when a message is
received that cannot fit into the remaining free buffer space.
.PP
\f[I]FI_BUFFERED_RECV\f[] : If set, the communication interface
implementation should attempt to queue inbound data that arrives before
a receive buffer has been posted.
In the absence of this flag, any messages that arrive before a receive
is posted are lost.
.PP
\f[I]FI_COMPLETION\f[] : Indicates that a completion entry should be
generated for data transfer operations.
.PP
@ -1073,33 +1067,6 @@ initiator.
For example, if the receive data is truncated at the target because the
provided receive buffer is too small, the initiator will be notified of
the truncation.
.PP
\f[I]FI_READ\f[] : Indicates that the user wants to initiate reads
against remote memory regions.
Remote reads include some RMA and atomic operations.
.PP
\f[I]FI_WRITE\f[] : Indicates that the user wants to initiate writes
against remote memory regions.
Remote writes include some RMA and most atomic operations.
.PP
\f[I]FI_SEND\f[] : Indicates that the endpoint will be used to send
message data transfers.
Message transfers include base message operations as well as tagged
message functionality.
.PP
\f[I]FI_RECV\f[] : Indicates that the endpoint will be used to receive
message data transfers.
Message transfers include base message operations as well as tagged
message functionality.
.PP
\f[I]FI_REMOTE_READ\f[] : Indicates that the endpoint should allow
remote endpoints to read memory regions exposed by this endpoint.
Remote read operations include some RMA and atomic operations.
.PP
\f[I]FI_REMOTE_WRITE\f[] : Indicates that the endpoint should allow
remote endpoints to write to memory regions exposed by this endpoint.
Remote write operations include some RMA operations and most atomic
operations.
.SH NOTES
.PP
Users should call fi_close to release all resources allocated to the

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_eq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_eq 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_eq - Event queue operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_errno 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_errno 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_errno - fabric errors

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_fabric 3 "2015\-01\-24" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_fabric 3 "2015\-01\-24" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_fabric - Fabric domain operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_getinfo 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_getinfo 3 "2015\-02\-11" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_getinfo / fi_freeinfo - Obtain / free fabric interface information
@ -37,6 +37,8 @@ Returns information about available fabric services for reaching the
specified node or service, subject to any provided hints.
Callers must provide at least one of the node, service, or hints
parameters.
If node and service are NULL, then the hints src_addr and/or dest_addr
fields of the fi_info structure must be specified.
If no matching fabric information is available, info will be set to
NULL.
.PP
@ -135,7 +137,8 @@ This field will be ignored in hints if FI_SOURCE is specified.
\f[I]dest_addrlen - destination address length\f[] : Indicates the
length of the destination address (must be specified if
\f[I]dest_addr\f[] is specified).
This field will be ignored in hints unless FI_SOURCE is specified.
This field will be ignored in hints unless the node and service
parameters are NULL or FI_SOURCE is specified.
.PP
\f[I]src_addr - source address\f[] : If specified, indicates the source
address.
@ -143,7 +146,8 @@ This field will be ignored in hints if FI_SOURCE is specified.
.PP
\f[I]dest_addr - destination address\f[] : If specified, indicates the
destination address.
This field will be ignored in hints unless FI_SOURCE is specified.
This field will be ignored in hints unless the node and service
parameters are NULL or FI_SOURCE is specified.
.PP
\f[I]connreq - connection request\f[] : References a specific connection
request, otherwise the field must be NULL.
@ -539,6 +543,7 @@ Use of this flag will suppress any lengthy name resolution protocol.
.PP
\f[I]FI_SOURCE\f[] : Indicates that the node and service parameters
specify the local source address to associate with an endpoint.
If specified, either the node and/or service parameter must be non-NULL.
This flag is often used with passive endpoints.
.SH RETURN VALUE
.PP

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_mr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_mr 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_mr - Memory region operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_msg 3 "2015\-01\-28" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_msg 3 "2015\-02\-06" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_msg - Message data transfer operations
@ -31,8 +31,8 @@ ssize_t\ fi_recvmsg(struct\ fid_ep\ *ep,\ const\ struct\ fi_msg\ *msg,
ssize_t\ fi_send(struct\ fid_ep\ *ep,\ void\ *buf,\ size_t\ len,
\ \ \ \ void\ *desc,\ fi_addr_t\ dest_addr,\ void\ *context);
ssize_t\ fi_sendv(struct\ fid_ep\ *ep,\ const\ void\ *iov,\ void\ *desc,
\ \ \ \ size_t\ count,\ fi_addr_t\ dest_addr,\ void\ *context);
ssize_t\ fi_sendv(struct\ fid_ep\ *ep,\ const\ struct\ iovec\ *iov,
\ \ \ \ void\ **desc,\ size_t\ count,\ fi_addr_t\ dest_addr,\ void\ *context);
ssize_t\ fi_sendmsg(struct\ fid_ep\ *ep,\ const\ struct\ fi_msg\ *msg,
\ \ \ \ uint64_t\ flags);
@ -126,12 +126,12 @@ The fi_sendmsg function takes a \f[C]struct\ fi_msg\f[] as input.
.nf
\f[C]
struct\ fi_msg\ {
\ \ \ \ const\ struct\ iovec\ *msg_iov;/*\ scatter-gather\ array\ */
\ \ \ \ void\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ **desc;\ \ /*\ local\ request\ descriptor\ */
\ \ \ \ const\ struct\ iovec\ *msg_iov;\ /*\ scatter-gather\ array\ */
\ \ \ \ void\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ **desc;\ \ \ /*\ local\ request\ descriptors\ */
\ \ \ \ size_t\ \ \ \ \ \ \ \ \ \ \ \ \ iov_count;/*\ #\ elements\ in\ iov\ */
\ \ \ \ const\ void\ \ \ \ \ \ \ \ \ *addr;\ \ \ /*\ optional\ endpoint\ address\ */
\ \ \ \ void\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *context;/*\ user-defined\ context\ */
\ \ \ \ uint64_t\ \ \ \ \ \ \ \ \ \ \ data;\ \ \ \ /*\ optional\ message\ data\ */
\ \ \ \ fi_addr_t\ \ \ \ \ \ \ \ \ \ addr;\ \ \ \ \ /*\ optional\ endpoint\ address\ */
\ \ \ \ void\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *context;\ /*\ user-defined\ context\ */
\ \ \ \ uint64_t\ \ \ \ \ \ \ \ \ \ \ data;\ \ \ \ \ /*\ optional\ message\ data\ */
};
\f[]
.fi

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_poll 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_poll 3 "2015\-01\-29" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_poll - Polling and wait set operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_rma 3 "2015\-01\-28" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_rma 3 "2015\-01\-28" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_rma - Remote memory access operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_tagged 3 "2015\-02\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_tagged 3 "2015\-02\-12" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_tagged - Tagged data transfer operations
@ -315,15 +315,6 @@ the user.
.PP
\f[I]-FI_EOTHER\f[] : Indicates that an unspecified error occurred.
.SH NOTES
.SS Any source
.PP
The function fi_trecv() may be used to receive a message from a specific
source address.
If the user wishes to receive a message from any source on an
unconnected fabric endpoint the function fi_recv() may be used, or
fi_trecv() may be used with the src_addr set to a wildcard address that
has been inserted into an address vector.
See fi_av.3 for more details.
.SS Ordering
.PP
The order in which tags are matched is only defined for a pair of

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_trigger 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_trigger 3 "2015\-01\-01" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_trigger - Triggered operations

Просмотреть файл

@ -1,4 +1,4 @@
.TH fi_version 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0-rc1"
.TH fi_version 3 "2015\-01\-08" "Libfabric Programmer\[aq]s Manual" "Libfabric v1.0.0rc1"
.SH NAME
.PP
fi_version - Version of the library interfaces

Просмотреть файл

@ -11,9 +11,16 @@ AC_DEFUN([FI_PSM_CONFIGURE],[
# Determine if we can support the psm provider
psm_happy=0
AS_IF([test x"$enable_psm" != x"no"],
[psm_happy=1
AC_CHECK_HEADER([psm.h], [], [psm_happy=0])
AC_CHECK_LIB([psm_infinipath], [psm_init], [], [psm_happy=0])])
[FI_CHECK_PACKAGE([psm],
[psm.h],
[psm_infinipath],
[psm_init],
[],
[],
[],
[psm_happy=1],
[psm_happy=0])
])
AS_IF([test $psm_happy -eq 1], [$1], [$2])
])

Просмотреть файл

@ -34,11 +34,17 @@ extern "C" {
#include <psm.h>
#include <psm_mq.h>
#include "psm_am.h"
#include "fi.h"
#include "fi_enosys.h"
#include "fi_list.h"
#include "fi_log.h"
#define PSM_PFX "libfabric:psm"
#define PSMX_PROVNAME "psm"
#define PSMX_DEFAULT_UUID "0FFF0FFF-0000-0000-0000-0FFF0FFF0FFF"
#define PSMX_DEBUG(...) FI_LOG(2, PSMX_PROVNAME, __VA_ARGS__)
#define PSMX_WARN(...) FI_WARN(PSMX_PROVNAME, __VA_ARGS__)
#define PSMX_TIME_OUT 120
@ -56,6 +62,8 @@ extern "C" {
FI_DYNAMIC_MR | \
PSMX_CAP_EXT)
#define PSMX_CAPS2 ((PSMX_CAPS | FI_DIRECTED_RECV) & ~FI_TAGGED)
#define PSMX_MODE (FI_CONTEXT)
#define PSMX_MAX_MSG_SIZE ((0x1ULL << 32) - 1)
@ -80,8 +88,13 @@ enum psmx_context_type {
PSMX_REMOTE_READ_CONTEXT,
};
union psmx_pi {
void *p;
int i;
};
#define PSMX_CTXT_REQ(fi_context) ((fi_context)->internal[0])
#define PSMX_CTXT_TYPE(fi_context) (*(int *)&(fi_context)->internal[1])
#define PSMX_CTXT_TYPE(fi_context) (((union psmx_pi *)&(fi_context)->internal[1])->i)
#define PSMX_CTXT_USER(fi_context) ((fi_context)->internal[2])
#define PSMX_CTXT_EP(fi_context) ((fi_context)->internal[3])
@ -172,16 +185,24 @@ struct psmx_am_request {
};
struct fi_context fi_context;
struct psmx_fid_ep *ep;
struct psmx_am_request *next;
int state;
int no_event;
int error;
struct slist_entry list_entry;
};
struct psmx_unexp {
psm_epaddr_t sender_addr;
uint64_t sender_context;
uint32_t len_received;
uint32_t done;
struct slist_entry list_entry;
char buf[0];
};
struct psmx_req_queue {
pthread_mutex_t lock;
struct psmx_am_request *head;
struct psmx_am_request *tail;
pthread_mutex_t lock;
struct slist list;
};
struct psmx_multi_recv {
@ -546,7 +567,6 @@ int psmx_errno(int err);
int psmx_epid_to_epaddr(struct psmx_fid_domain *domain,
psm_epid_t epid, psm_epaddr_t *epaddr);
void psmx_query_mpi(void);
void psmx_debug(char *fmt, ...);
void psmx_cq_enqueue_event(struct psmx_fid_cq *cq, struct psmx_cq_event *event);
struct psmx_cq_event *psmx_cq_create_event(struct psmx_fid_cq *cq,
@ -562,17 +582,6 @@ void psmx_wait_signal(struct fid_wait *wait);
int psmx_am_init(struct psmx_fid_domain *domain);
int psmx_am_fini(struct psmx_fid_domain *domain);
int psmx_am_enqueue_recv(struct psmx_fid_domain *domain,
struct psmx_am_request *req);
struct psmx_am_request *
psmx_am_search_and_dequeue_recv(struct psmx_fid_domain *domain,
const void *src_addr);
#if PSMX_AM_USE_SEND_QUEUE
int psmx_am_enqueue_send(struct psmx_fid_domain *domain,
struct psmx_am_request *req);
#endif
int psmx_am_enqueue_rma(struct psmx_fid_domain *domain,
struct psmx_am_request *req);
int psmx_am_progress(struct psmx_fid_domain *domain);
int psmx_am_process_send(struct psmx_fid_domain *domain,
struct psmx_am_request *req);

Просмотреть файл

@ -45,17 +45,14 @@ static int psmx_am_handlers_initialized = 0;
int psmx_am_progress(struct psmx_fid_domain *domain)
{
struct slist_entry *item;
struct psmx_am_request *req;
#if PSMX_AM_USE_SEND_QUEUE
pthread_mutex_lock(&domain->send_queue.lock);
while (domain->send_queue.head) {
req = domain->send_queue.head;
if (req->next)
domain->send_queue.head = req->next;
else
domain->send_queue.head = domain->send_queue.tail = NULL;
while (!slist_empty(&domain->send_queue.list)) {
item = slist_remove_head(&domain->send_queue.list);
req = container_of(item, struct psmx_am_request, list_entry);
if (req->state == PSMX_AM_STATE_DONE)
free(req);
else
@ -66,12 +63,9 @@ int psmx_am_progress(struct psmx_fid_domain *domain)
if (psmx_env.tagged_rma) {
pthread_mutex_lock(&domain->rma_queue.lock);
while (domain->rma_queue.head) {
req = domain->rma_queue.head;
if (req->next)
domain->rma_queue.head = req->next;
else
domain->rma_queue.head = domain->rma_queue.tail = NULL;
while (!slist_empty(&domain->rma_queue.list)) {
item = slist_remove_head(&domain->rma_queue.list);
req = container_of(item, struct psmx_am_request, list_entry);
psmx_am_process_rma(domain, req);
}
pthread_mutex_unlock(&domain->rma_queue.lock);
@ -131,10 +125,14 @@ int psmx_am_init(struct psmx_fid_domain *domain)
psmx_am_handlers_initialized = 1;
}
slist_init(&domain->rma_queue.list);
slist_init(&domain->recv_queue.list);
slist_init(&domain->unexp_queue.list);
pthread_mutex_init(&domain->rma_queue.lock, NULL);
pthread_mutex_init(&domain->recv_queue.lock, NULL);
pthread_mutex_init(&domain->unexp_queue.lock, NULL);
#if PSMX_AM_USE_SEND_QUEUE
slist_init(&domain->send_queue.list);
pthread_mutex_init(&domain->send_queue.lock, NULL);
pthread_mutex_init(&domain->progress_mutex, NULL);
pthread_cond_init(&domain->progress_cond, NULL);
@ -158,78 +156,3 @@ int psmx_am_fini(struct psmx_fid_domain *domain)
return 0;
}
int psmx_am_enqueue_recv(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
if (domain->recv_queue.tail)
domain->recv_queue.tail->next = req;
else
domain->recv_queue.head = req;
domain->recv_queue.tail = req;
return 0;
}
struct psmx_am_request *
psmx_am_search_and_dequeue_recv(struct psmx_fid_domain *domain,
const void *src_addr)
{
struct psmx_am_request *req, *prev = NULL;
req = domain->recv_queue.head;
if (!req)
return NULL;
while (req) {
if (!req->recv.src_addr || req->recv.src_addr == src_addr) {
if (prev)
prev->next = req->next;
else
domain->recv_queue.head = req->next;
if (!req->next)
domain->recv_queue.tail = prev;
req->next = NULL;
return req;
}
prev = req;
req = req->next;
}
return NULL;
}
#if PSMX_AM_USE_SEND_QUEUE
int psmx_am_enqueue_send(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
req->state = PSMX_AM_STATE_QUEUED;
if (domain->send_queue.tail)
domain->send_queue.tail->next = req;
else
domain->send_queue.head = req;
domain->send_queue.tail = req;
return 0;
}
#endif
int psmx_am_enqueue_rma(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
req->state = PSMX_AM_STATE_QUEUED;
if (domain->rma_queue.tail)
domain->rma_queue.tail->next = req;
else
domain->rma_queue.head = req;
domain->rma_queue.tail = req;
return 0;
}

Просмотреть файл

@ -394,7 +394,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)addr, len, FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (!op_error) {
addr += mr->offset;
@ -414,7 +414,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr)
psmx_cntr_inc(mr->cntr);
@ -447,7 +447,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)addr, len, FI_REMOTE_READ|FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (!op_error) {
addr += mr->offset;
@ -456,7 +456,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
psmx_atomic_do_readwrite(addr, src, tmp_buf,
datatype, op, count);
else
err = -ENOMEM;
err = -FI_ENOMEM;
if (op != FI_ATOMIC_READ) {
if (mr->cq) {
event = psmx_cq_create_event(
@ -473,7 +473,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr)
psmx_cntr_inc(mr->cntr);
@ -520,7 +520,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)addr, len, FI_REMOTE_READ|FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (!op_error) {
addr += mr->offset;
@ -529,7 +529,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
psmx_atomic_do_compwrite(addr, src, src + len,
tmp_buf, datatype, op, count);
else
err = -ENOMEM;
err = -FI_ENOMEM;
if (mr->cq) {
event = psmx_cq_create_event(
mr->cq,
@ -545,7 +545,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr)
psmx_cntr_inc(mr->cntr);
@ -587,7 +587,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->write_cntr)
@ -619,7 +619,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->read_cntr)
@ -629,7 +629,7 @@ int psmx_am_atomic_handler(psm_am_token_t token, psm_epaddr_t epaddr,
break;
default:
err = -EINVAL;
err = -FI_EINVAL;
}
return err;
}
@ -661,7 +661,7 @@ static int psmx_atomic_self(int am_cmd,
len = fi_datatype_size(datatype) * count;
mr = psmx_mr_hash_get(key);
op_error = mr ? psmx_mr_validate(mr, addr, len, access) : -EINVAL;
op_error = mr ? psmx_mr_validate(mr, addr, len, access) : -FI_EINVAL;
if (op_error)
goto gen_local_event;
@ -703,7 +703,7 @@ static int psmx_atomic_self(int am_cmd,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr)
psmx_cntr_inc(mr->cntr);
@ -744,7 +744,7 @@ gen_local_event:
if (event)
psmx_cq_enqueue_event(ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
switch (am_cmd) {
@ -778,7 +778,6 @@ ssize_t _psmx_atomic_write(struct fid_ep *ep,
psm_amarg_t args[8];
int am_flags = PSM_AM_FLAG_ASYNC;
int chunk_size, len;
int err;
size_t idx;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
@ -789,7 +788,7 @@ ssize_t _psmx_atomic_write(struct fid_ep *ep,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_ATOMIC_WRITE;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -812,24 +811,24 @@ ssize_t _psmx_atomic_write(struct fid_ep *ep,
}
if (!buf)
return -EINVAL;
return -FI_EINVAL;
if (datatype < 0 || datatype >= FI_DATATYPE_LAST)
return -EINVAL;
return -FI_EINVAL;
if (op < 0 || op >= FI_ATOMIC_OP_LAST)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
dest_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!dest_addr) {
return -EINVAL;
return -FI_EINVAL;
}
epaddr_context = psm_epaddr_getctxt((void *)dest_addr);
@ -855,7 +854,7 @@ ssize_t _psmx_atomic_write(struct fid_ep *ep,
else {
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
if (ep_priv->send_cq_event_flag && !(flags & FI_EVENT))
req->no_event = 1;
@ -876,7 +875,7 @@ ssize_t _psmx_atomic_write(struct fid_ep *ep,
args[3].u64 = key;
args[4].u32w0 = datatype;
args[4].u32w1 = op;
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_ATOMIC_HANDLER, args, 5,
(void *)buf, len, am_flags, NULL, NULL);
@ -904,7 +903,7 @@ static ssize_t psmx_atomic_writemsg(struct fid_ep *ep,
uint64_t flags)
{
if (!msg || msg->iov_count != 1)
return -EINVAL;
return -FI_EINVAL;
return _psmx_atomic_write(ep, msg->msg_iov[0].addr,
msg->msg_iov[0].count,
@ -923,7 +922,7 @@ static ssize_t psmx_atomic_writev(struct fid_ep *ep,
enum fi_op op, void *context)
{
if (!iov || count != 1)
return -EINVAL;
return -FI_EINVAL;
return psmx_atomic_write(ep, iov->addr, iov->count,
desc ? desc[0] : NULL, dest_addr, addr, key,
@ -963,7 +962,6 @@ ssize_t _psmx_atomic_readwrite(struct fid_ep *ep,
psm_amarg_t args[8];
int am_flags = PSM_AM_FLAG_ASYNC;
int chunk_size, len;
int err;
size_t idx;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
@ -974,7 +972,7 @@ ssize_t _psmx_atomic_readwrite(struct fid_ep *ep,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_ATOMIC_READWRITE;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -999,24 +997,24 @@ ssize_t _psmx_atomic_readwrite(struct fid_ep *ep,
}
if (!buf && op != FI_ATOMIC_READ)
return -EINVAL;
return -FI_EINVAL;
if (datatype < 0 || datatype >= FI_DATATYPE_LAST)
return -EINVAL;
return -FI_EINVAL;
if (op < 0 || op >= FI_ATOMIC_OP_LAST)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
dest_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!dest_addr) {
return -EINVAL;
return -FI_EINVAL;
}
epaddr_context = psm_epaddr_getctxt((void *)dest_addr);
@ -1042,7 +1040,7 @@ ssize_t _psmx_atomic_readwrite(struct fid_ep *ep,
else {
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
if (ep_priv->send_cq_event_flag && !(flags & FI_EVENT))
req->no_event = 1;
@ -1064,7 +1062,7 @@ ssize_t _psmx_atomic_readwrite(struct fid_ep *ep,
args[3].u64 = key;
args[4].u32w0 = datatype;
args[4].u32w1 = op;
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_ATOMIC_HANDLER, args, 5,
(void *)buf, (buf?len:0), am_flags, NULL, NULL);
@ -1100,18 +1098,18 @@ static ssize_t psmx_atomic_readwritemsg(struct fid_ep *ep,
size_t count;
if (!msg)
return -EINVAL;
return -FI_EINVAL;
if (msg->op == FI_ATOMIC_READ) {
if (result_count != 1)
return -EINVAL;
return -FI_EINVAL;
buf = NULL;
count = resultv[0].count;
}
else {
if (msg->iov_count != 1)
return -EINVAL;
return -FI_EINVAL;
buf = msg->msg_iov[0].addr;
count = msg->msg_iov[0].count;
@ -1137,7 +1135,7 @@ static ssize_t psmx_atomic_readwritev(struct fid_ep *ep,
enum fi_op op, void *context)
{
if (!iov || count != 1)
return -EINVAL;
return -FI_EINVAL;
return psmx_atomic_readwrite(ep, iov->addr, iov->count,
desc ? desc[0] : NULL,
@ -1164,7 +1162,6 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
psm_amarg_t args[8];
int am_flags = PSM_AM_FLAG_ASYNC;
int chunk_size, len;
int err;
void *tmp_buf = NULL;
size_t idx;
@ -1176,7 +1173,7 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_ATOMIC_COMPWRITE;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -1203,24 +1200,24 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
}
if (!buf)
return -EINVAL;
return -FI_EINVAL;
if (datatype < 0 || datatype >= FI_DATATYPE_LAST)
return -EINVAL;
return -FI_EINVAL;
if (op < 0 || op >= FI_ATOMIC_OP_LAST)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
dest_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!dest_addr) {
return -EINVAL;
return -FI_EINVAL;
}
epaddr_context = psm_epaddr_getctxt((void *)dest_addr);
@ -1249,7 +1246,7 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
else {
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
if (ep_priv->send_cq_event_flag && !(flags & FI_EVENT))
req->no_event = 1;
@ -1257,7 +1254,7 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
if (compare != buf + len) {
tmp_buf = malloc(len * 2);
if (!tmp_buf)
return -ENOMEM;
return -FI_ENOMEM;
memcpy(tmp_buf, buf, len);
memcpy(tmp_buf + len, compare, len);
@ -1280,7 +1277,7 @@ ssize_t _psmx_atomic_compwrite(struct fid_ep *ep,
args[3].u64 = key;
args[4].u32w0 = datatype;
args[4].u32w1 = op;
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_ATOMIC_HANDLER, args, 5,
tmp_buf ? tmp_buf : (void *)buf,
len * 2, am_flags,
@ -1320,7 +1317,7 @@ static ssize_t psmx_atomic_compwritemsg(struct fid_ep *ep,
uint64_t flags)
{
if (!msg || msg->iov_count != 1)
return -EINVAL;
return -FI_EINVAL;
return _psmx_atomic_compwrite(ep, msg->msg_iov[0].addr,
msg->msg_iov[0].count,
@ -1349,7 +1346,7 @@ static ssize_t psmx_atomic_compwritev(struct fid_ep *ep,
enum fi_op op, void *context)
{
if (!iov || count != 1)
return -EINVAL;
return -FI_EINVAL;
return psmx_atomic_compwrite(ep, iov->addr, iov->count,
desc ? desc[0] : NULL,

Просмотреть файл

@ -40,7 +40,7 @@ static void psmx_set_epaddr_context(struct psmx_fid_domain *domain,
context = (void *)psm_epaddr_getctxt(epaddr);
if (context) {
if (context->domain != domain || context->epid != epid) {
fprintf(stderr, "%s: domain or epid doesn't match\n", __func__);
PSMX_WARN("%s: domain or epid doesn't match\n", __func__);
context = NULL;
}
}
@ -50,7 +50,7 @@ static void psmx_set_epaddr_context(struct psmx_fid_domain *domain,
context = malloc(sizeof *context);
if (!context) {
fprintf(stderr, "%s: cannot allocate context\n", __func__);
PSMX_WARN("%s: cannot allocate context\n", __func__);
return;
}
@ -100,13 +100,13 @@ static int psmx_av_check_table_size(struct psmx_fid_av *av, size_t count)
new_psm_epids = realloc(av->psm_epids, new_count * sizeof(*new_psm_epids));
if (!new_psm_epids)
return -ENOMEM;
return -FI_ENOMEM;
av->psm_epids = new_psm_epids;
new_psm_epaddrs = realloc(av->psm_epaddrs, new_count * sizeof(*new_psm_epaddrs));
if (!new_psm_epaddrs)
return -ENOMEM;
return -FI_ENOMEM;
av->psm_epaddrs = new_psm_epaddrs;
av->count = new_count;
@ -120,7 +120,6 @@ static int psmx_av_insert(struct fid_av *av, const void *addr, size_t count,
psm_error_t *errors;
int error_count = 0;
int *mask;
int err;
int i, j;
fi_addr_t *result = NULL;
struct psmx_epaddr_context *epaddr_context;
@ -129,19 +128,19 @@ static int psmx_av_insert(struct fid_av *av, const void *addr, size_t count,
errors = (psm_error_t *) calloc(count, sizeof *errors);
if (!errors)
return -ENOMEM;
return -FI_ENOMEM;
mask = (int *) calloc(count, sizeof *mask);
if (!mask) {
free(errors);
return -ENOMEM;
return -FI_ENOMEM;
}
if (av_priv->type == FI_AV_TABLE) {
if (psmx_av_check_table_size(av_priv, count)) {
free(mask);
free(errors);
return -ENOMEM;
return -FI_ENOMEM;
}
for (i=0; i<count; i++)
@ -155,10 +154,7 @@ static int psmx_av_insert(struct fid_av *av, const void *addr, size_t count,
/* prevent connecting to the same ep twice, which is fatal in PSM */
for (i=0; i<count; i++) {
psm_epconn_t epconn;
if (((psm_epid_t *) addr)[i] == 0) { /* "any source" address */
fi_addr[i] = 0;
}
else if (psm_ep_epid_lookup(((psm_epid_t *) addr)[i], &epconn) == PSM_OK) {
if (psm_ep_epid_lookup(((psm_epid_t *) addr)[i], &epconn) == PSM_OK) {
epaddr_context = psm_epaddr_getctxt(epconn.addr);
if (epaddr_context && epaddr_context->epid == ((psm_epid_t *) addr)[i])
((psm_epaddr_t *) fi_addr)[i] = epconn.addr;
@ -170,7 +166,7 @@ static int psmx_av_insert(struct fid_av *av, const void *addr, size_t count,
}
}
err = psm_ep_connect(av_priv->domain->psm_ep, count,
psm_ep_connect(av_priv->domain->psm_ep, count,
(psm_epid_t *) addr, mask, errors,
(psm_epaddr_t *) fi_addr, 30*1e9);
@ -212,11 +208,8 @@ static int psmx_av_insert(struct fid_av *av, const void *addr, size_t count,
static int psmx_av_remove(struct fid_av *av, fi_addr_t *fi_addr, size_t count,
uint64_t flags)
{
struct psmx_fid_av *av_priv;
int err = PSM_OK;
av_priv = container_of(av, struct psmx_fid_av, av);
return psmx_errno(err);
}
@ -229,14 +222,14 @@ static int psmx_av_lookup(struct fid_av *av, fi_addr_t fi_addr, void *addr,
int idx;
if (!addr || !addrlen)
return -EINVAL;
return -FI_EINVAL;
av_priv = container_of(av, struct psmx_fid_av, av);
if (av_priv->type == FI_AV_TABLE) {
idx = (int)(int64_t)fi_addr;
if (idx >= av_priv->last)
return -EINVAL;
return -FI_EINVAL;
epid = av_priv->psm_epids[idx];
}
@ -315,9 +308,9 @@ int psmx_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
type = attr->type;
break;
default:
psmx_debug("%s: attr->type=%d, supported=%d %d\n",
PSMX_DEBUG("%s: attr->type=%d, supported=%d %d\n",
__func__, attr->type, FI_AV_MAP, FI_AV_TABLE);
return -EINVAL;
return -FI_EINVAL;
}
count = attr->count;
@ -325,7 +318,7 @@ int psmx_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
av_priv = (struct psmx_fid_av *) calloc(1, sizeof *av_priv);
if (!av_priv)
return -ENOMEM;
return -FI_ENOMEM;
av_priv->domain = domain_priv;
av_priv->type = type;

Просмотреть файл

@ -38,7 +38,7 @@ static int psmx_cm_getname(fid_t fid, void *addr, size_t *addrlen)
ep = container_of(fid, struct psmx_fid_ep, ep.fid);
if (!ep->domain)
return -EBADF;
return -FI_EBADF;
if (*addrlen < sizeof(psm_epid_t)) {
*addrlen = sizeof(psm_epid_t);

Просмотреть файл

@ -160,11 +160,12 @@ void psmx_cntr_check_trigger(struct psmx_fid_cntr *cntr)
trigger->atomic_compwrite.flags);
break;
default:
psmx_debug("%s: %d unsupported op\n", __func__, trigger->op);
PSMX_DEBUG("%s: %d unsupported op\n", __func__, trigger->op);
break;
}
free(trigger);
trigger = cntr->trigger;
}
pthread_mutex_unlock(&cntr->trigger_lock);
@ -322,7 +323,7 @@ static int psmx_cntr_control(fid_t fid, int command, void *arg)
case FI_GETOPSFLAG:
if (!arg)
return -EINVAL;
return -FI_EINVAL;
*(uint64_t *)arg = cntr->flags;
break;
@ -331,7 +332,7 @@ static int psmx_cntr_control(fid_t fid, int command, void *arg)
break;
default:
return -ENOSYS;
return -FI_ENOSYS;
}
return ret;
@ -375,9 +376,9 @@ int psmx_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
break;
default:
psmx_debug("%s: attr->events=%d, supported=%d\n", __func__,
PSMX_DEBUG("%s: attr->events=%d, supported=%d\n", __func__,
attr->events, FI_CNTR_EVENTS_COMP);
return -EINVAL;
return -FI_EINVAL;
}
switch (attr->wait_obj) {
@ -387,7 +388,7 @@ int psmx_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
case FI_WAIT_SET:
if (!attr->wait_set) {
psmx_debug("%s: FI_WAIT_SET is specified but attr->wait_set is NULL\n",
PSMX_DEBUG("%s: FI_WAIT_SET is specified but attr->wait_set is NULL\n",
__func__);
return -FI_EINVAL;
}
@ -406,14 +407,14 @@ int psmx_cntr_open(struct fid_domain *domain, struct fi_cntr_attr *attr,
break;
default:
psmx_debug("%s: attr->wait_obj=%d, supported=%d...%d\n", __func__,
PSMX_DEBUG("%s: attr->wait_obj=%d, supported=%d...%d\n", __func__,
attr->wait_obj, FI_WAIT_NONE, FI_WAIT_MUTEX_COND);
return -FI_EINVAL;
}
cntr_priv = (struct psmx_fid_cntr *) calloc(1, sizeof *cntr_priv);
if (!cntr_priv)
return -ENOMEM;
return -FI_ENOMEM;
cntr_priv->domain = domain_priv;
cntr_priv->events = events;

Просмотреть файл

@ -68,7 +68,7 @@ struct psmx_cq_event *psmx_cq_create_event(struct psmx_fid_cq *cq,
else {
event = calloc(1, sizeof(*event));
if (!event) {
fprintf(stderr, "%s: out of memory.\n", __func__);
PSMX_WARN("%s: out of memory.\n", __func__);
exit(-1);
}
}
@ -112,7 +112,7 @@ struct psmx_cq_event *psmx_cq_create_event(struct psmx_fid_cq *cq,
break;
default:
fprintf(stderr, "%s: unsupported CQ format %d\n", __func__, cq->format);
PSMX_WARN("%s: unsupported CQ format %d\n", __func__, cq->format);
return NULL;
}
@ -134,7 +134,7 @@ static struct psmx_cq_event *psmx_cq_create_event_from_status(
void *op_context, *buf;
int is_recv = 0;
switch(PSMX_CTXT_TYPE(fi_context)) {
switch((int)PSMX_CTXT_TYPE(fi_context)) {
case PSMX_SEND_CONTEXT:
op_context = fi_context;
buf = PSMX_CTXT_USER(fi_context);
@ -170,7 +170,7 @@ static struct psmx_cq_event *psmx_cq_create_event_from_status(
else {
event = calloc(1, sizeof(*event));
if (!event) {
fprintf(stderr, "%s: out of memory.\n", __func__);
PSMX_WARN("%s: out of memory.\n", __func__);
exit(-1);
}
}
@ -220,7 +220,7 @@ static struct psmx_cq_event *psmx_cq_create_event_from_status(
break;
default:
fprintf(stderr, "%s: unsupported EQ format %d\n", __func__, cq->format);
PSMX_WARN("%s: unsupported EQ format %d\n", __func__, cq->format);
return NULL;
}
@ -228,7 +228,7 @@ out:
if (is_recv) {
if (event == event_in) {
if (src_addr) {
int err = -ENODATA;
int err = -FI_ENODATA;
if (cq->domain->reserved_tag_bits & PSMX_MSG_BIT & psm_status->msg_tag) {
err = psmx_epid_to_epaddr(cq->domain,
psm_status->msg_tag & ~PSMX_MSG_BIT,
@ -266,7 +266,7 @@ static int psmx_cq_get_event_src_addr(struct psmx_fid_cq *cq,
return 0;
}
return -ENODATA;
return -FI_ENODATA;
}
int psmx_cq_poll_mq(struct psmx_fid_cq *cq, struct psmx_fid_domain *domain,
@ -295,7 +295,7 @@ int psmx_cq_poll_mq(struct psmx_fid_cq *cq, struct psmx_fid_domain *domain,
tmp_cntr = NULL;
multi_recv = 0;
switch (PSMX_CTXT_TYPE(fi_context)) {
switch ((int)PSMX_CTXT_TYPE(fi_context)) {
case PSMX_NOCOMP_SEND_CONTEXT:
tmp_cntr = tmp_ep->send_cntr;
break;
@ -361,7 +361,7 @@ int psmx_cq_poll_mq(struct psmx_fid_cq *cq, struct psmx_fid_domain *domain,
(mr->cq == cq) ? event_in : NULL,
count, src_addr);
if (!event)
return -ENOMEM;
return -FI_ENOMEM;
if (event != event_in)
psmx_cq_enqueue_event(mr->cq, event);
@ -393,7 +393,7 @@ int psmx_cq_poll_mq(struct psmx_fid_cq *cq, struct psmx_fid_domain *domain,
(tmp_cq == cq) ? event_in : NULL, count,
src_addr);
if (!event)
return -ENOMEM;
return -FI_ENOMEM;
if (event != event_in)
psmx_cq_enqueue_event(tmp_cq, event);
@ -432,7 +432,7 @@ int psmx_cq_poll_mq(struct psmx_fid_cq *cq, struct psmx_fid_domain *domain,
0, /* olen */
0); /* err */
if (!event)
return -ENOMEM;
return -FI_ENOMEM;
psmx_cq_enqueue_event(tmp_cq, event);
}
@ -543,8 +543,8 @@ static ssize_t psmx_cq_write(struct fid_cq *cq, const void *buf, size_t len)
while (len >= cq_priv->entry_size) {
event = calloc(1, sizeof(*event));
if (!event) {
fprintf(stderr, "%s: out of memory\n", __func__);
return -ENOMEM;
PSMX_WARN("%s: out of memory\n", __func__);
return -FI_ENOMEM;
}
memcpy((void *)&event->cqe, buf + written_len, cq_priv->entry_size);
@ -568,8 +568,8 @@ static ssize_t psmx_cq_writeerr(struct fid_cq *cq, struct fi_cq_err_entry *buf,
while (len >= sizeof(*buf)) {
event = calloc(1, sizeof(*event));
if (!event) {
fprintf(stderr, "%s: out of memory\n", __func__);
return -ENOMEM;
PSMX_WARN("%s: out of memory\n", __func__);
return -FI_ENOMEM;
}
memcpy((void *)&event->cqe, buf + written_len, sizeof(*buf));
@ -676,7 +676,7 @@ static int psmx_cq_control(struct fid *fid, int command, void *arg)
break;
default:
return -ENOSYS;
return -FI_ENOSYS;
}
return ret;
@ -738,7 +738,7 @@ int psmx_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
break;
default:
psmx_debug("%s: attr->format=%d, supported=%d...%d\n", __func__, attr->format,
PSMX_DEBUG("%s: attr->format=%d, supported=%d...%d\n", __func__, attr->format,
FI_CQ_FORMAT_UNSPEC, FI_CQ_FORMAT_TAGGED);
return -FI_EINVAL;
}
@ -750,7 +750,7 @@ int psmx_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
case FI_WAIT_SET:
if (!attr->wait_set) {
psmx_debug("%s: FI_WAIT_SET is specified but attr->wait_set is NULL\n",
PSMX_DEBUG("%s: FI_WAIT_SET is specified but attr->wait_set is NULL\n",
__func__);
return -FI_EINVAL;
}
@ -769,7 +769,7 @@ int psmx_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
break;
default:
psmx_debug("%s: attr->wait_obj=%d, supported=%d...%d\n", __func__, attr->wait_obj,
PSMX_DEBUG("%s: attr->wait_obj=%d, supported=%d...%d\n", __func__, attr->wait_obj,
FI_WAIT_NONE, FI_WAIT_MUTEX_COND);
return -FI_EINVAL;
}
@ -781,7 +781,7 @@ int psmx_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
break;
default:
psmx_debug("%s: attr->wait_cond=%d, supported=%d...%d\n", __func__,
PSMX_DEBUG("%s: attr->wait_cond=%d, supported=%d...%d\n", __func__,
attr->wait_cond, FI_CQ_COND_NONE, FI_CQ_COND_THRESHOLD);
return -FI_EINVAL;
}
@ -814,7 +814,7 @@ int psmx_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr,
for (i=0; i<PSMX_FREE_LIST_SIZE; i++) {
event = calloc(1, sizeof(*event));
if (!event) {
fprintf(stderr, "%s: out of memory.\n", __func__);
PSMX_WARN("%s: out of memory.\n", __func__);
exit(-1);
}
slist_insert_tail(&event->list_entry, &cq_priv->free_list);

Просмотреть файл

@ -95,18 +95,18 @@ int psmx_domain_open(struct fid_fabric *fabric, struct fi_info *info,
struct psmx_fid_domain *domain_priv;
struct psm_ep_open_opts opts;
psm_uuid_t uuid;
int err = -ENOMEM;
int err = -FI_ENOMEM;
psmx_debug("%s\n", __func__);
PSMX_DEBUG("%s\n", __func__);
fabric_priv = container_of(fabric, struct psmx_fid_fabric, fabric);
if (fabric_priv->active_domain) {
psmx_debug("%s: a domain has been opened for the fabric\n");
return -EBUSY;
PSMX_DEBUG("%s: a domain has been opened for the fabric\n");
return -FI_EBUSY;
}
if (!info->domain_attr->name || strncmp(info->domain_attr->name, "psm", 3))
return -EINVAL;
return -FI_EINVAL;
psmx_query_mpi();
@ -128,7 +128,7 @@ int psmx_domain_open(struct fid_fabric *fabric, struct fi_info *info,
err = psm_ep_open(uuid, &opts,
&domain_priv->psm_ep, &domain_priv->psm_epid);
if (err != PSM_OK) {
fprintf(stderr, "%s: psm_ep_open returns %d, errno=%d\n",
PSMX_WARN("%s: psm_ep_open returns %d, errno=%d\n",
__func__, err, errno);
err = psmx_errno(err);
goto err_out_free_domain;
@ -137,7 +137,7 @@ int psmx_domain_open(struct fid_fabric *fabric, struct fi_info *info,
err = psm_mq_init(domain_priv->psm_ep, PSM_MQ_ORDERMASK_ALL,
NULL, 0, &domain_priv->psm_mq);
if (err != PSM_OK) {
fprintf(stderr, "%s: psm_mq_init returns %d, errno=%d\n",
PSMX_WARN("%s: psm_mq_init returns %d, errno=%d\n",
__func__, err, errno);
err = psmx_errno(err);
goto err_out_close_ep;
@ -180,24 +180,24 @@ err_out:
int psmx_domain_check_features(struct psmx_fid_domain *domain, int ep_cap)
{
int rma_target;
rma_target = fi_rma_target_allowed(ep_cap);
if ((ep_cap & PSMX_CAPS) != ep_cap)
return -EINVAL;
return -FI_EINVAL;
if ((ep_cap & FI_TAGGED) && domain->tagged_ep)
return -EBUSY;
if ((ep_cap & FI_TAGGED) && domain->tagged_ep &&
fi_recv_allowed(ep_cap))
return -FI_EBUSY;
if ((ep_cap & FI_MSG) && domain->msg_ep)
return -EBUSY;
if ((ep_cap & FI_MSG) && domain->msg_ep &&
fi_recv_allowed(ep_cap))
return -FI_EBUSY;
if ((ep_cap & FI_RMA) && rma_target && domain->rma_ep)
return -EBUSY;
if ((ep_cap & FI_RMA) && domain->rma_ep &&
fi_rma_target_allowed(ep_cap))
return -FI_EBUSY;
if ((ep_cap & FI_ATOMICS) && rma_target && domain->atomics_ep)
return -EBUSY;
if ((ep_cap & FI_ATOMICS) && domain->atomics_ep &&
fi_rma_target_allowed(ep_cap))
return -FI_EBUSY;
return 0;
}
@ -205,7 +205,6 @@ int psmx_domain_check_features(struct psmx_fid_domain *domain, int ep_cap)
int psmx_domain_enable_ep(struct psmx_fid_domain *domain, struct psmx_fid_ep *ep)
{
uint64_t ep_cap = 0;
int rma_target;
if (ep)
ep_cap = ep->caps;
@ -228,18 +227,16 @@ int psmx_domain_enable_ep(struct psmx_fid_domain *domain, struct psmx_fid_ep *ep
domain->am_initialized = 1;
}
rma_target = fi_rma_target_allowed(ep_cap);
if ((ep_cap & FI_RMA) && rma_target)
if ((ep_cap & FI_RMA) && fi_rma_target_allowed(ep_cap))
domain->rma_ep = ep;
if ((ep_cap & FI_ATOMICS) && rma_target)
if ((ep_cap & FI_ATOMICS) && fi_rma_target_allowed(ep_cap))
domain->atomics_ep = ep;
if (ep_cap & FI_TAGGED)
if ((ep_cap & FI_TAGGED) && fi_recv_allowed(ep_cap))
domain->tagged_ep = ep;
if (ep_cap & FI_MSG)
if ((ep_cap & FI_MSG) && fi_recv_allowed(ep_cap))
domain->msg_ep = ep;
return 0;

Просмотреть файл

@ -37,35 +37,35 @@ static void psmx_ep_optimize_ops(struct psmx_fid_ep *ep)
if (ep->ep.tagged) {
if (ep->flags) {
ep->ep.tagged = &psmx_tagged_ops;
psmx_debug("%s: generic tagged ops.\n", __func__);
PSMX_DEBUG("%s: generic tagged ops.\n", __func__);
}
else if (ep->send_cq_event_flag && ep->recv_cq_event_flag) {
if (ep->av && ep->av->type == FI_AV_TABLE)
ep->ep.tagged = &psmx_tagged_ops_no_event_av_table;
else
ep->ep.tagged = &psmx_tagged_ops_no_event_av_map;
psmx_debug("%s: tagged ops optimized for op_flags=0 and event suppression\n", __func__);
PSMX_DEBUG("%s: tagged ops optimized for op_flags=0 and event suppression\n", __func__);
}
else if (ep->send_cq_event_flag) {
if (ep->av && ep->av->type == FI_AV_TABLE)
ep->ep.tagged = &psmx_tagged_ops_no_send_event_av_table;
else
ep->ep.tagged = &psmx_tagged_ops_no_send_event_av_map;
psmx_debug("%s: tagged ops optimized for op_flags=0 and send event suppression\n", __func__);
PSMX_DEBUG("%s: tagged ops optimized for op_flags=0 and send event suppression\n", __func__);
}
else if (ep->recv_cq_event_flag) {
if (ep->av && ep->av->type == FI_AV_TABLE)
ep->ep.tagged = &psmx_tagged_ops_no_recv_event_av_table;
else
ep->ep.tagged = &psmx_tagged_ops_no_recv_event_av_map;
psmx_debug("%s: tagged ops optimized for op_flags=0 and recv event suppression\n", __func__);
PSMX_DEBUG("%s: tagged ops optimized for op_flags=0 and recv event suppression\n", __func__);
}
else {
if (ep->av && ep->av->type == FI_AV_TABLE)
ep->ep.tagged = &psmx_tagged_ops_no_flag_av_table;
else
ep->ep.tagged = &psmx_tagged_ops_no_flag_av_map;
psmx_debug("%s: tagged ops optimized for op_flags=0\n", __func__);
PSMX_DEBUG("%s: tagged ops optimized for op_flags=0\n", __func__);
}
}
}
@ -79,10 +79,10 @@ static ssize_t psmx_ep_cancel(fid_t fid, void *context)
ep = container_of(fid, struct psmx_fid_ep, ep.fid);
if (!ep->domain)
return -EBADF;
return -FI_EBADF;
if (!fi_context)
return -EINVAL;
return -FI_EINVAL;
err = psm_mq_cancel((psm_mq_req_t *)&PSMX_CTXT_REQ(fi_context));
if (err == PSM_OK)
@ -99,7 +99,7 @@ static int psmx_ep_getopt(fid_t fid, int level, int optname,
ep = container_of(fid, struct psmx_fid_ep, ep.fid);
if (level != FI_OPT_ENDPOINT)
return -ENOPROTOOPT;
return -FI_ENOPROTOOPT;
switch (optname) {
case FI_OPT_MIN_MULTI_RECV:
@ -108,7 +108,7 @@ static int psmx_ep_getopt(fid_t fid, int level, int optname,
break;
default:
return -ENOPROTOOPT;
return -FI_ENOPROTOOPT;
}
return 0;
@ -122,7 +122,7 @@ static int psmx_ep_setopt(fid_t fid, int level, int optname,
ep = container_of(fid, struct psmx_fid_ep, ep.fid);
if (level != FI_OPT_ENDPOINT)
return -ENOPROTOOPT;
return -FI_ENOPROTOOPT;
switch (optname) {
case FI_OPT_MIN_MULTI_RECV:
@ -130,17 +130,12 @@ static int psmx_ep_setopt(fid_t fid, int level, int optname,
break;
default:
return -ENOPROTOOPT;
return -FI_ENOPROTOOPT;
}
return 0;
}
static int psmx_ep_enable(struct fid_ep *ep)
{
return 0;
}
static int psmx_ep_close(fid_t fid)
{
struct psmx_fid_ep *ep;
@ -166,7 +161,7 @@ static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
ep = container_of(fid, struct psmx_fid_ep, ep.fid);
if (!bfid)
return -EINVAL;
return -FI_EINVAL;
switch (bfid->fclass) {
case FI_CLASS_EQ:
return -FI_ENOSYS;
@ -174,7 +169,7 @@ static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
case FI_CLASS_CQ:
cq = container_of(bfid, struct psmx_fid_cq, cq.fid);
if (ep->domain != cq->domain)
return -EINVAL;
return -FI_EINVAL;
if (flags & FI_SEND) {
ep->send_cq = cq;
if (flags & FI_EVENT)
@ -191,7 +186,7 @@ static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
case FI_CLASS_CNTR:
cntr = container_of(bfid, struct psmx_fid_cntr, cntr.fid);
if (ep->domain != cntr->domain)
return -EINVAL;
return -FI_EINVAL;
if (flags & FI_SEND)
ep->send_cntr = cntr;
if (flags & FI_RECV)
@ -210,14 +205,14 @@ static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
av = container_of(bfid,
struct psmx_fid_av, av.fid);
if (ep->domain != av->domain)
return -EINVAL;
return -FI_EINVAL;
ep->av = av;
psmx_ep_optimize_ops(ep);
break;
case FI_CLASS_MR:
if (!bfid->ops || !bfid->ops->bind)
return -EINVAL;
return -FI_EINVAL;
err = bfid->ops->bind(bfid, fid, flags);
if (err)
return err;
@ -227,11 +222,11 @@ static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
stx = container_of(bfid,
struct psmx_fid_stx, stx.fid);
if (ep->domain != stx->domain)
return -EINVAL;
return -FI_EINVAL;
break;
default:
return -ENOSYS;
return -FI_ENOSYS;
}
return 0;
@ -247,7 +242,7 @@ static int psmx_ep_control(fid_t fid, int command, void *arg)
case FI_ALIAS:
new_ep = (struct psmx_fid_ep *) calloc(1, sizeof *ep);
if (!new_ep)
return -ENOMEM;
return -FI_ENOMEM;
alias = arg;
*new_ep = *ep;
new_ep->flags = alias->flags;
@ -262,12 +257,15 @@ static int psmx_ep_control(fid_t fid, int command, void *arg)
case FI_GETFIDFLAG:
if (!arg)
return -EINVAL;
return -FI_EINVAL;
*(uint64_t *)arg = ep->flags;
break;
case FI_ENABLE:
return 0;
default:
return -ENOSYS;
return -FI_ENOSYS;
}
return 0;
@ -285,7 +283,6 @@ static struct fi_ops_ep psmx_ep_ops = {
.cancel = psmx_ep_cancel,
.getopt = psmx_ep_getopt,
.setopt = psmx_ep_setopt,
.enable = psmx_ep_enable,
.tx_ctx = fi_no_tx_ctx,
.rx_ctx = fi_no_rx_ctx,
.rx_size_left = fi_no_rx_size_left,
@ -307,7 +304,7 @@ int psmx_ep_open(struct fid_domain *domain, struct fi_info *info,
domain_priv = container_of(domain, struct psmx_fid_domain, domain.fid);
if (!domain_priv)
return -EINVAL;
return -FI_EINVAL;
err = psmx_domain_check_features(domain_priv, ep_cap);
if (err)
@ -315,7 +312,7 @@ int psmx_ep_open(struct fid_domain *domain, struct fi_info *info,
ep_priv = (struct psmx_fid_ep *) calloc(1, sizeof *ep_priv);
if (!ep_priv)
return -ENOMEM;
return -FI_ENOMEM;
ep_priv->ep.fid.fclass = FI_CLASS_EP;
ep_priv->ep.fid.context = context;
@ -392,11 +389,11 @@ int psmx_stx_ctx(struct fid_domain *domain, struct fi_tx_attr *attr,
{
struct psmx_fid_stx *stx_priv;
psmx_debug("%s\n", __func__);
PSMX_DEBUG("%s\n", __func__);
stx_priv = (struct psmx_fid_stx *) calloc(1, sizeof *stx_priv);
if (!stx_priv)
return -ENOMEM;
return -FI_ENOMEM;
stx_priv->stx.fid.fclass = FI_CLASS_STX_CTX;
stx_priv->stx.fid.context = context;

Просмотреть файл

@ -50,7 +50,7 @@ static int psmx_reserve_tag_bits(int *caps, uint64_t *max_tag_value)
reserved_bits |= PSMX_MSG_BIT;
}
else if (ask_caps) {
psmx_debug("%s: unable to reserve tag bit for FI_MSG support.\n"
PSMX_DEBUG("%s: unable to reserve tag bit for FI_MSG support.\n"
"ADVICE: please reduce the asked max_tag_value, "
"or remove FI_MSG from the asked capabilities, "
"or set OFI_PSM_AM_MSG=1 to use an alternative (but less "
@ -59,7 +59,7 @@ static int psmx_reserve_tag_bits(int *caps, uint64_t *max_tag_value)
return -1;
}
else {
psmx_debug("%s: unable to reserve tag bit for FI_MSG support. "
PSMX_DEBUG("%s: unable to reserve tag bit for FI_MSG support. "
"FI_MSG is removed from the capabilities.\n"
"ADVICE: please reduce the asked max_tag_value, "
"or set OFI_PSM_AM_MSG=1 to use an alternative (but less "
@ -74,7 +74,7 @@ static int psmx_reserve_tag_bits(int *caps, uint64_t *max_tag_value)
reserved_bits |= PSMX_RMA_BIT;
}
else if (ask_caps) {
psmx_debug("%s: unable to reserve tag bit for tagged RMA acceleration.\n"
PSMX_DEBUG("%s: unable to reserve tag bit for tagged RMA acceleration.\n"
"ADVICE: please reduce the asked max_tag_value, "
"or remove FI_RMA from the asked capabilities, "
"or set OFI_PSM_TAGGED_RMA=0 to disable RMA acceleration.\n",
@ -82,7 +82,7 @@ static int psmx_reserve_tag_bits(int *caps, uint64_t *max_tag_value)
return -1;
}
else {
psmx_debug("%s: unable to reserve tag bit for tagged RMA acceleration. "
PSMX_DEBUG("%s: unable to reserve tag bit for tagged RMA acceleration. "
"FI_RMA is removed from the capabilities.\n"
"ADVICE: please reduce the asked max_tag_value, "
"or set OFI_PSM_TAGGED_RMA=0 to disable RMA acceleration.\n",
@ -109,12 +109,12 @@ static int psmx_getinfo(uint32_t version, const char *node, const char *service,
uint64_t max_tag_value = 0;
int err = -FI_ENODATA;
psmx_debug("%s\n", __func__);
PSMX_DEBUG("%s\n", __func__);
*info = NULL;
if (psm_ep_num_devunits(&cnt) || !cnt) {
psmx_debug("%s: no PSM device is found.\n", __func__);
PSMX_DEBUG("%s: no PSM device is found.\n", __func__);
return -FI_ENODATA;
}
@ -127,7 +127,7 @@ static int psmx_getinfo(uint32_t version, const char *node, const char *service,
case FI_EP_RDM:
break;
default:
psmx_debug("%s: hints->ep_type=%d, supported=%d,%d.\n",
PSMX_DEBUG("%s: hints->ep_type=%d, supported=%d,%d.\n",
__func__, hints->ep_type, FI_EP_UNSPEC,
FI_EP_RDM);
goto err_out;
@ -139,35 +139,36 @@ static int psmx_getinfo(uint32_t version, const char *node, const char *service,
case FI_PROTO_PSMX:
break;
default:
psmx_debug("%s: hints->protocol=%d, supported=%d %d\n",
PSMX_DEBUG("%s: hints->protocol=%d, supported=%d %d\n",
__func__, hints->ep_attr->protocol,
FI_PROTO_UNSPEC, FI_PROTO_PSMX);
goto err_out;
}
if (hints->ep_attr->tx_ctx_cnt > 1) {
psmx_debug("%s: hints->ep_attr->tx_ctx_cnt=%d, supported=0,1\n",
PSMX_DEBUG("%s: hints->ep_attr->tx_ctx_cnt=%d, supported=0,1\n",
__func__, hints->ep_attr->tx_ctx_cnt);
goto err_out;
}
if (hints->ep_attr->rx_ctx_cnt > 1) {
psmx_debug("%s: hints->ep_attr->rx_ctx_cnt=%d, supported=0,1\n",
PSMX_DEBUG("%s: hints->ep_attr->rx_ctx_cnt=%d, supported=0,1\n",
__func__, hints->ep_attr->rx_ctx_cnt);
goto err_out;
}
}
if ((hints->caps & PSMX_CAPS) != hints->caps) {
psmx_debug("%s: hints->caps=0x%llx, supported=0x%llx\n",
__func__, hints->caps, PSMX_CAPS);
if ((hints->caps & PSMX_CAPS) != hints->caps &&
(hints->caps & PSMX_CAPS2) != hints->caps) {
PSMX_DEBUG("%s: hints->caps=0x%llx, supported=0x%llx,0x%llx\n",
__func__, hints->caps, PSMX_CAPS, PSMX_CAPS2);
goto err_out;
}
if (hints->tx_attr &&
(hints->tx_attr->op_flags & PSMX_OP_FLAGS) !=
hints->tx_attr->op_flags) {
psmx_debug("%s: hints->tx->flags=0x%llx, supported=0x%llx\n",
PSMX_DEBUG("%s: hints->tx->flags=0x%llx, supported=0x%llx\n",
__func__, hints->tx_attr->op_flags, PSMX_OP_FLAGS);
goto err_out;
}
@ -175,41 +176,41 @@ static int psmx_getinfo(uint32_t version, const char *node, const char *service,
if (hints->rx_attr &&
(hints->rx_attr->op_flags & PSMX_OP_FLAGS) !=
hints->rx_attr->op_flags) {
psmx_debug("%s: hints->rx->flags=0x%llx, supported=0x%llx\n",
PSMX_DEBUG("%s: hints->rx->flags=0x%llx, supported=0x%llx\n",
__func__, hints->rx_attr->op_flags, PSMX_OP_FLAGS);
goto err_out;
}
if ((hints->mode & PSMX_MODE) != PSMX_MODE) {
psmx_debug("%s: hints->mode=0x%llx, required=0x%llx\n",
PSMX_DEBUG("%s: hints->mode=0x%llx, required=0x%llx\n",
__func__, hints->mode, PSMX_MODE);
goto err_out;
}
if (hints->fabric_attr && hints->fabric_attr->name &&
strncmp(hints->fabric_attr->name, "psm", 3)) {
psmx_debug("%s: hints->fabric_name=%s, supported=psm\n",
PSMX_DEBUG("%s: hints->fabric_name=%s, supported=psm\n",
__func__, hints->fabric_attr->name);
goto err_out;
}
if (hints->domain_attr && hints->domain_attr->name &&
strncmp(hints->domain_attr->name, "psm", 3)) {
psmx_debug("%s: hints->domain_name=%s, supported=psm\n",
PSMX_DEBUG("%s: hints->domain_name=%s, supported=psm\n",
__func__, hints->domain_attr->name);
goto err_out;
}
if (hints->ep_attr) {
if (hints->ep_attr->max_msg_size > PSMX_MAX_MSG_SIZE) {
psmx_debug("%s: hints->ep_attr->max_msg_size=%ld,"
PSMX_DEBUG("%s: hints->ep_attr->max_msg_size=%ld,"
"supported=%ld.\n", __func__,
hints->ep_attr->max_msg_size,
PSMX_MAX_MSG_SIZE);
goto err_out;
}
if (hints->ep_attr->inject_size > PSMX_INJECT_SIZE) {
psmx_debug("%s: hints->ep_attr->inject_size=%ld,"
PSMX_DEBUG("%s: hints->ep_attr->inject_size=%ld,"
"supported=%ld.\n", __func__,
hints->ep_attr->inject_size,
PSMX_INJECT_SIZE);
@ -228,7 +229,7 @@ static int psmx_getinfo(uint32_t version, const char *node, const char *service,
psmx_info = fi_allocinfo_internal();
if (!psmx_info) {
err = -ENOMEM;
err = -FI_ENOMEM;
goto err_out;
}
@ -308,7 +309,7 @@ static int psmx_fabric(struct fi_fabric_attr *attr,
{
struct psmx_fid_fabric *fabric_priv;
psmx_debug("%s\n", __func__);
PSMX_DEBUG("%s\n", __func__);
if (strncmp(attr->name, "psm", 3))
return -FI_ENODATA;
@ -327,14 +328,14 @@ static int psmx_fabric(struct fi_fabric_attr *attr,
static void psmx_fini(void)
{
psmx_debug("%s\n", __func__);
PSMX_DEBUG("%s\n", __func__);
if (! --init_count)
psm_finalize();
}
static struct fi_provider psmx_prov = {
.name = "PSM",
.name = PSMX_PROVNAME,
.version = FI_VERSION(0, 9),
.fi_version = FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION),
.getinfo = psmx_getinfo,
@ -367,14 +368,17 @@ PSM_INI
int check_version;
int err;
psmx_debug("%s\n", __func__);
fi_log_init();
psmx_env.name_server = psmx_get_int_env("OFI_PSM_NAME_SERVER", 0);
psmx_env.name_server = psmx_get_int_env("OFI_PSM_NAME_SERVER", 1);
psmx_env.am_msg = psmx_get_int_env("OFI_PSM_AM_MSG", 0);
psmx_env.tagged_rma = psmx_get_int_env("OFI_PSM_TAGGED_RMA", 0);
psmx_env.debug = psmx_get_int_env("OFI_PSM_DEBUG", 0);
psmx_env.warning = psmx_get_int_env("OFI_PSM_WARNING", 1);
psmx_env.uuid = getenv("OFI_PSM_UUID");
if (!psmx_env.uuid)
psmx_env.uuid = PSMX_DEFAULT_UUID;
PSMX_DEBUG("%s\n", __func__);
psm_error_register_handler(NULL, PSM_ERRHANDLER_NO_HANDLER);
@ -383,20 +387,29 @@ PSM_INI
err = psm_init(&major, &minor);
if (err != PSM_OK) {
fprintf(stderr, "%s: psm_init failed: %s\n", __func__,
PSMX_WARN("%s: psm_init failed: %s\n", __func__,
psm_error_get_string(err));
return NULL;
}
PSMX_DEBUG("%s: PSM header version = (%d, %d)\n", __func__, PSM_VERNO_MAJOR, PSM_VERNO_MINOR);
PSMX_DEBUG("%s: PSM library version = (%d, %d)\n", __func__, major, minor);
check_version = psmx_get_int_env("OFI_PSM_VERSION_CHECK", 1);
if (check_version && major != PSM_VERNO_MAJOR) {
fprintf(stderr, "%s: PSM version mismatch: header %d.%d, library %d.%d.\n",
FI_WARN(PSMX_PROVNAME, "%s: PSM version mismatch: header %d.%d, library %d.%d.\n",
__func__, PSM_VERNO_MAJOR, PSM_VERNO_MINOR, major, minor);
fprintf(stderr, "\tSet envar OFI_PSM_VERSION_CHECK=0 to bypass version check.\n");
FI_WARN(PSMX_PROVNAME, "\tSet envar OFI_PSM_VERSION_CHECK=0 to bypass version check.\n");
return NULL;
}
PSMX_DEBUG("%s: OFI_PSM_NAME_SERVER = %d\n", __func__, psmx_env.name_server);
PSMX_DEBUG("%s: OFI_PSM_AM_MSG = %d\n", __func__, psmx_env.am_msg);
PSMX_DEBUG("%s: OFI_PSM_TAGGED_RMA = %d\n", __func__, psmx_env.tagged_rma);
PSMX_DEBUG("%s: OFI_PSM_WARNING = %d\n", __func__, psmx_env.warning);
PSMX_DEBUG("%s: OFI_PSM_UUID = %s\n", __func__, psmx_env.uuid);
init_count++;
return (&psmx_prov);
}

Просмотреть файл

@ -56,7 +56,7 @@ static int psmx_mr_hash_add(struct psmx_fid_mr *mr)
entry = calloc(1, sizeof(*entry));
if (!entry)
return -ENOMEM;
return -FI_ENOMEM;
entry->mr = mr;
entry->next = head->next;
@ -99,7 +99,7 @@ static int psmx_mr_hash_del(struct psmx_fid_mr *mr)
entry = entry->next;
}
return -ENOENT;
return -FI_ENOENT;
}
struct psmx_fid_mr *psmx_mr_hash_get(uint64_t key)
@ -126,10 +126,10 @@ int psmx_mr_validate(struct psmx_fid_mr *mr, uint64_t addr, size_t len, uint64_t
addr += mr->offset;
if (!addr)
return -EINVAL;
return -FI_EINVAL;
if ((access & mr->access) != access)
return -EACCES;
return -FI_EACCES;
for (i = 0; i < mr->iov_count; i++) {
if ((uint64_t)mr->iov[i].iov_base <= addr &&
@ -137,7 +137,7 @@ int psmx_mr_validate(struct psmx_fid_mr *mr, uint64_t addr, size_t len, uint64_t
return 0;
}
return -EACCES;
return -FI_EACCES;
}
static int psmx_mr_close(fid_t fid)
@ -161,34 +161,34 @@ static int psmx_mr_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
mr = container_of(fid, struct psmx_fid_mr, mr.fid);
if (!bfid)
return -EINVAL;
return -FI_EINVAL;
switch (bfid->fclass) {
case FI_CLASS_EP:
ep = container_of(bfid, struct psmx_fid_ep, ep.fid);
if (mr->domain != ep->domain)
return -EINVAL;
return -FI_EINVAL;
break;
case FI_CLASS_CQ:
cq = container_of(bfid, struct psmx_fid_cq, cq.fid);
if (mr->cq && mr->cq != cq)
return -EEXIST;
return -FI_EBUSY;
if (mr->domain != cq->domain)
return -EINVAL;
return -FI_EINVAL;
mr->cq = cq;
break;
case FI_CLASS_CNTR:
cntr = container_of(bfid, struct psmx_fid_cntr, cntr.fid);
if (mr->cntr && mr->cntr != cntr)
return -EEXIST;
return -FI_EBUSY;
if (mr->domain != cntr->domain)
return -EINVAL;
return -FI_EINVAL;
mr->cntr = cntr;
break;
default:
return -ENOSYS;
return -FI_ENOSYS;
}
return 0;
@ -279,7 +279,7 @@ static int psmx_mr_reg(struct fid_domain *domain, const void *buf, size_t len,
mr_priv = (struct psmx_fid_mr *) calloc(1, sizeof(*mr_priv) + sizeof(struct iovec));
if (!mr_priv)
return -ENOMEM;
return -FI_ENOMEM;
mr_priv->mr.fid.fclass = FI_CLASS_MR;
mr_priv->mr.fid.context = context;
@ -330,13 +330,13 @@ static int psmx_mr_regv(struct fid_domain *domain,
}
if (count == 0 || iov == NULL)
return -EINVAL;
return -FI_EINVAL;
mr_priv = (struct psmx_fid_mr *)
calloc(1, sizeof(*mr_priv) +
sizeof(struct iovec) * count);
if (!mr_priv)
return -ENOMEM;
return -FI_ENOMEM;
mr_priv->mr.fid.fclass = FI_CLASS_MR;
mr_priv->mr.fid.context = context;
@ -386,16 +386,16 @@ static int psmx_mr_regattr(struct fid_domain *domain, const struct fi_mr_attr *a
}
if (!attr)
return -EINVAL;
return -FI_EINVAL;
if (attr->iov_count == 0 || attr->mr_iov == NULL)
return -EINVAL;
return -FI_EINVAL;
mr_priv = (struct psmx_fid_mr *)
calloc(1, sizeof(*mr_priv) +
sizeof(struct iovec) * attr->iov_count);
if (!mr_priv)
return -ENOMEM;
return -FI_ENOMEM;
mr_priv->mr.fid.fclass = FI_CLASS_MR;
mr_priv->mr.fid.context = attr->context;

Просмотреть файл

@ -55,7 +55,7 @@ ssize_t _psmx_recv(struct fid_ep *ep, void *buf, size_t len,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_RECV;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -73,12 +73,12 @@ ssize_t _psmx_recv(struct fid_ep *ep, void *buf, size_t len,
return 0;
}
if (src_addr) {
if ((ep_priv->caps & FI_DIRECTED_RECV) && src_addr != FI_ADDR_UNSPEC) {
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = (size_t)src_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
src_addr = (fi_addr_t)av->psm_epaddrs[idx];
}
@ -96,7 +96,7 @@ ssize_t _psmx_recv(struct fid_ep *ep, void *buf, size_t len,
}
else {
if (!context)
return -EINVAL;
return -FI_EINVAL;
fi_context = context;
user_fi_context = 1;
@ -105,7 +105,7 @@ ssize_t _psmx_recv(struct fid_ep *ep, void *buf, size_t len,
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
req->tag = psm_tag;
req->tagsel = psm_tagsel;
@ -153,7 +153,7 @@ static ssize_t psmx_recvmsg(struct fid_ep *ep, const struct fi_msg *msg, uint64_
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -176,7 +176,7 @@ static ssize_t psmx_recvv(struct fid_ep *ep, const struct iovec *iov, void **des
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -213,7 +213,7 @@ ssize_t _psmx_send(struct fid_ep *ep, const void *buf, size_t len,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_SEND;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -235,7 +235,7 @@ ssize_t _psmx_send(struct fid_ep *ep, const void *buf, size_t len,
if (av && av->type == FI_AV_TABLE) {
idx = (size_t)dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
}
@ -248,7 +248,7 @@ ssize_t _psmx_send(struct fid_ep *ep, const void *buf, size_t len,
if (flags & FI_INJECT) {
fi_context = malloc(sizeof(*fi_context) + len);
if (!fi_context)
return -ENOMEM;
return -FI_ENOMEM;
memcpy((void *)fi_context + sizeof(*fi_context), buf, len);
buf = (void *)fi_context + sizeof(*fi_context);
@ -261,7 +261,7 @@ ssize_t _psmx_send(struct fid_ep *ep, const void *buf, size_t len,
}
else {
if (!context)
return -EINVAL;
return -FI_EINVAL;
fi_context = context;
if (fi_context != &ep_priv->sendimm_context) {
@ -300,7 +300,7 @@ static ssize_t psmx_sendmsg(struct fid_ep *ep, const struct fi_msg *msg, uint64_
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -323,7 +323,7 @@ static ssize_t psmx_sendv(struct fid_ep *ep, const struct iovec *iov, void **des
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;

Просмотреть файл

@ -32,6 +32,90 @@
#include "psmx.h"
#if PSMX_AM_USE_SEND_QUEUE
static inline void psmx_am_enqueue_send(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
pthread_mutex_lock(&domain->send_queue.lock);
req->state = PSMX_AM_STATE_QUEUED;
slist_insert_tail(&req->list_entry, &domain->send_queue.list);
pthread_mutex_unlock(&domain->send_queue.lock);
}
#endif
static inline void psmx_am_enqueue_recv(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
pthread_mutex_lock(&domain->recv_queue.lock);
slist_insert_tail(&req->list_entry, &domain->recv_queue.list);
pthread_mutex_unlock(&domain->recv_queue.lock);
}
static int match_recv(struct slist_entry *item, const void *src_addr)
{
struct psmx_am_request *req;
req = container_of(item, struct psmx_am_request, list_entry);
if (!req->recv.src_addr || req->recv.src_addr == src_addr)
return 1;
return 0;
}
static struct psmx_am_request *psmx_am_search_and_dequeue_recv(
struct psmx_fid_domain *domain,
const void *src_addr)
{
struct slist_entry *item;
pthread_mutex_lock(&domain->recv_queue.lock);
item = slist_remove_first_match(&domain->recv_queue.list,
match_recv, src_addr);
pthread_mutex_unlock(&domain->recv_queue.lock);
if (!item)
return NULL;
return container_of(item, struct psmx_am_request, list_entry);
}
static inline void psmx_am_enqueue_unexp(struct psmx_fid_domain *domain,
struct psmx_unexp *unexp)
{
pthread_mutex_lock(&domain->unexp_queue.lock);
slist_insert_tail(&unexp->list_entry, &domain->unexp_queue.list);
pthread_mutex_unlock(&domain->unexp_queue.lock);
}
static int match_unexp(struct slist_entry *item, const void *src_addr)
{
struct psmx_unexp *unexp;
unexp = container_of(item, struct psmx_unexp, list_entry);
if (!src_addr || src_addr == unexp->sender_addr)
return 1;
return 0;
}
static struct psmx_unexp *psmx_am_search_and_dequeue_unexp(
struct psmx_fid_domain *domain,
const void *src_addr)
{
struct slist_entry *item;
pthread_mutex_lock(&domain->unexp_queue.lock);
item = slist_remove_first_match(&domain->unexp_queue.list,
match_unexp, src_addr);
pthread_mutex_unlock(&domain->unexp_queue.lock);
if (!item)
return NULL;
return container_of(item, struct psmx_unexp, list_entry);
}
/* Message protocol:
*
* Send REQ:
@ -48,64 +132,6 @@
* args[2].u64 recv_req
*/
struct psmx_unexp {
psm_epaddr_t sender_addr;
uint64_t sender_context;
uint32_t len_received;
uint32_t done;
struct psmx_unexp *next;
char buf[0];
};
static struct psmx_unexp *psmx_unexp_head = NULL;
static struct psmx_unexp *psmx_unexp_tail = NULL;
static pthread_mutex_t psmx_unexp_lock = PTHREAD_MUTEX_INITIALIZER;
static void psmx_unexp_enqueue(struct psmx_unexp *unexp)
{
pthread_mutex_lock(&psmx_unexp_lock);
if (!psmx_unexp_head)
psmx_unexp_head = psmx_unexp_tail = unexp;
else
psmx_unexp_tail->next = unexp;
pthread_mutex_unlock(&psmx_unexp_lock);
}
static struct psmx_unexp *psmx_unexp_dequeue(fi_addr_t src_addr)
{
struct psmx_unexp *unexp = NULL;
struct psmx_unexp *prev;
pthread_mutex_lock(&psmx_unexp_lock);
if (psmx_unexp_head) {
prev = NULL;
unexp = psmx_unexp_head;
while (unexp) {
if (!src_addr || src_addr == (fi_addr_t)unexp->sender_addr) {
if (prev)
prev->next = unexp->next;
else
psmx_unexp_head = unexp->next;
if (psmx_unexp_tail == unexp)
psmx_unexp_tail = prev;
unexp->next = NULL;
break;
}
prev = unexp;
unexp = unexp->next;
}
}
pthread_mutex_unlock(&psmx_unexp_lock);
return unexp;
}
int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
psm_amarg_t *args, int nargs, void *src, uint32_t len)
{
@ -114,7 +140,6 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
struct psmx_cq_event *event;
struct psmx_epaddr_context *epaddr_context;
struct psmx_fid_domain *domain;
int msg_len;
int copy_len;
uint64_t offset;
int cmd, eom;
@ -124,8 +149,8 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
epaddr_context = psm_epaddr_getctxt(epaddr);
if (!epaddr_context) {
fprintf(stderr, "%s: NULL context for epaddr %p\n", __func__, epaddr);
return -EIO;
PSMX_WARN("%s: NULL context for epaddr %p\n", __func__, epaddr);
return -FI_EIO;
}
domain = epaddr_context->domain;
@ -135,9 +160,8 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
switch (cmd) {
case PSMX_AM_REQ_SEND:
msg_len = args[0].u32w1;
assert(len == args[0].u32w1);
offset = args[3].u64;
assert(len == msg_len);
if (offset == 0) {
/* this is the first packet */
req = psmx_am_search_and_dequeue_recv(domain, (const void *)epaddr);
@ -149,7 +173,7 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
else {
unexp = malloc(sizeof(*unexp) + len);
if (!unexp) {
op_error = -ENOBUFS;
op_error = -FI_ENOSPC;
}
else {
memcpy(unexp->buf, src, len);
@ -157,8 +181,8 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
unexp->sender_context = args[1].u64;
unexp->len_received = len;
unexp->done = !!eom;
unexp->next = NULL;
psmx_unexp_enqueue(unexp);
unexp->list_entry.next = NULL;
psmx_am_enqueue_unexp(domain, unexp);
if (!eom) {
/* stop here. will reply when recv is posted */
@ -186,8 +210,8 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
req->recv.len_received += copy_len;
}
else {
fprintf(stderr, "%s: NULL recv_req in follow-up packets.\n", __func__);
op_error = -EBADMSG;
PSMX_WARN("%s: NULL recv_req in follow-up packets.\n", __func__);
op_error = -FI_ENOMSG;
}
}
@ -206,7 +230,7 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->recv_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->recv_cntr)
@ -260,7 +284,7 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->send_cntr)
@ -274,7 +298,7 @@ int psmx_am_msg_handler(psm_am_token_t token, psm_epaddr_t epaddr,
break;
default:
err = -EINVAL;
err = -FI_EINVAL;
}
return err;
@ -324,8 +348,6 @@ int psmx_am_process_send(struct psmx_fid_domain *domain, struct psmx_am_request
(void *)req->send.buf+offset, len,
am_flags, NULL, NULL);
free(req);
return psmx_errno(err);
}
@ -345,20 +367,23 @@ static ssize_t _psmx_recv2(struct fid_ep *ep, void *buf, size_t len,
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
if (src_addr) {
if ((ep_priv->caps & FI_DIRECTED_RECV) && src_addr != FI_ADDR_UNSPEC) {
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = (size_t)src_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
src_addr = (fi_addr_t)av->psm_epaddrs[idx];
}
}
else {
src_addr = 0;
}
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
req->op = PSMX_AM_REQ_SEND;
req->recv.buf = (void *)buf;
@ -370,7 +395,8 @@ static ssize_t _psmx_recv2(struct fid_ep *ep, void *buf, size_t len,
if (ep_priv->recv_cq_event_flag && !(flags & FI_EVENT))
req->no_event = 1;
unexp = psmx_unexp_dequeue(src_addr);
unexp = psmx_am_search_and_dequeue_unexp(ep_priv->domain,
(const void *)src_addr);
if (!unexp) {
psmx_am_enqueue_recv(ep_priv->domain, req);
return 0;
@ -412,7 +438,7 @@ static ssize_t _psmx_recv2(struct fid_ep *ep, void *buf, size_t len,
if (event)
psmx_cq_enqueue_event(req->ep->recv_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->recv_cntr)
@ -440,7 +466,7 @@ static ssize_t psmx_recvmsg2(struct fid_ep *ep, const struct fi_msg *msg,
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -463,7 +489,7 @@ static ssize_t psmx_recvv2(struct fid_ep *ep, const struct iovec *iov,
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -493,18 +519,18 @@ static ssize_t _psmx_send2(struct fid_ep *ep, const void *buf, size_t len,
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
if (!buf)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
dest_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!dest_addr) {
return -EINVAL;
return -FI_EINVAL;
}
chunk_size = MIN(PSMX_AM_CHUNK_SIZE, psmx_am_param.max_request_short);
@ -512,7 +538,7 @@ static ssize_t _psmx_send2(struct fid_ep *ep, const void *buf, size_t len,
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
req->op = PSMX_AM_REQ_SEND;
req->send.buf = (void *)buf;
@ -566,7 +592,7 @@ static ssize_t psmx_sendmsg2(struct fid_ep *ep, const struct fi_msg *msg,
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -589,7 +615,7 @@ static ssize_t psmx_sendv2(struct fid_ep *ep, const struct iovec *iov,
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;

Просмотреть файл

@ -32,6 +32,15 @@
#include "psmx.h"
static inline void psmx_am_enqueue_rma(struct psmx_fid_domain *domain,
struct psmx_am_request *req)
{
pthread_mutex_lock(&domain->rma_queue.lock);
req->state = PSMX_AM_STATE_QUEUED;
slist_insert_tail(&req->list_entry, &domain->rma_queue.list);
pthread_mutex_unlock(&domain->rma_queue.lock);
}
/* RMA protocol:
*
* Write REQ:
@ -75,7 +84,6 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
int cmd, eom, has_data;
struct psmx_am_request *req;
struct psmx_cq_event *event;
int chunk_size;
uint64_t offset;
struct psmx_fid_mr *mr;
@ -91,7 +99,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)rma_addr, len, FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (!op_error) {
rma_addr += mr->offset;
memcpy(rma_addr, src, len);
@ -112,7 +120,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr)
psmx_cntr_inc(mr->cntr);
@ -137,7 +145,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)rma_addr, len, FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (op_error) {
rep_args[0].u32w0 = PSMX_AM_REP_WRITE | eom;
rep_args[0].u32w1 = op_error;
@ -152,7 +160,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
req = calloc(1, sizeof(*req));
if (!req) {
err = -ENOMEM;
err = -FI_ENOMEM;
}
else {
req->op = args[0].u32w0;
@ -175,7 +183,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)rma_addr, rma_len, FI_REMOTE_READ) :
-EINVAL;
-FI_EINVAL;
if (!op_error) {
rma_addr += mr->offset;
}
@ -184,8 +192,6 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
rma_len = 0;
}
chunk_size = MIN(PSMX_AM_CHUNK_SIZE, psmx_am_param.max_reply_short);
assert(rma_len <= chunk_size);
rep_args[0].u32w0 = PSMX_AM_REP_READ | eom;
rep_args[0].u32w1 = op_error;
rep_args[1].u64 = args[1].u64;
@ -207,7 +213,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
mr = psmx_mr_hash_get(key);
op_error = mr ?
psmx_mr_validate(mr, (uint64_t)rma_addr, len, FI_REMOTE_WRITE) :
-EINVAL;
-FI_EINVAL;
if (op_error) {
rep_args[0].u32w0 = PSMX_AM_REP_READ | eom;
rep_args[0].u32w1 = op_error;
@ -223,7 +229,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
req = calloc(1, sizeof(*req));
if (!req) {
err = -ENOMEM;
err = -FI_ENOMEM;
}
else {
req->op = args[0].u32w0;
@ -259,7 +265,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->write_cntr)
@ -295,7 +301,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
if (event)
psmx_cq_enqueue_event(req->ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (req->ep->read_cntr)
@ -306,7 +312,7 @@ int psmx_am_rma_handler(psm_am_token_t token, psm_epaddr_t epaddr,
break;
default:
err = -EINVAL;
err = -FI_EINVAL;
}
return err;
}
@ -334,11 +340,11 @@ static ssize_t psmx_rma_self(int am_cmd,
access = FI_REMOTE_READ;
break;
default:
return -EINVAL;
return -FI_EINVAL;
}
mr = psmx_mr_hash_get(key);
op_error = mr ? psmx_mr_validate(mr, addr, len, access) : -EINVAL;
op_error = mr ? psmx_mr_validate(mr, addr, len, access) : -FI_EINVAL;
if (!op_error) {
addr += mr->offset;
@ -370,7 +376,7 @@ static ssize_t psmx_rma_self(int am_cmd,
if (event)
psmx_cq_enqueue_event(mr->cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
if (mr->cntr && am_cmd == PSMX_AM_REQ_WRITE)
psmx_cntr_inc(mr->cntr);
@ -395,7 +401,7 @@ static ssize_t psmx_rma_self(int am_cmd,
if (event)
psmx_cq_enqueue_event(ep->send_cq, event);
else
err = -ENOMEM;
err = -FI_ENOMEM;
}
switch (am_cmd) {
@ -442,7 +448,6 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
struct psmx_epaddr_context *epaddr_context;
struct psmx_am_request *req;
psm_amarg_t args[8];
int err;
int chunk_size;
size_t offset = 0;
uint64_t psm_tag;
@ -457,7 +462,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_READ;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -478,18 +483,18 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
}
if (!buf)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = src_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
src_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!src_addr) {
return -EINVAL;
return -FI_EINVAL;
}
epaddr_context = psm_epaddr_getctxt((void *)src_addr);
@ -500,7 +505,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
req->op = PSMX_AM_REQ_READ;
req->read.buf = buf;
@ -511,6 +516,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
req->ep = ep_priv;
PSMX_CTXT_TYPE(&req->fi_context) = PSMX_READ_CONTEXT;
PSMX_CTXT_USER(&req->fi_context) = context;
PSMX_CTXT_EP(&req->fi_context) = ep_priv;
if (ep_priv->send_cq_event_flag && !(flags & FI_EVENT)) {
PSMX_CTXT_TYPE(&req->fi_context) = PSMX_NOCOMP_READ_CONTEXT;
@ -521,7 +527,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
if (psmx_env.tagged_rma && len > chunk_size) {
psm_tag = PSMX_RMA_BIT | ep_priv->domain->psm_epid;
err = psm_mq_irecv(ep_priv->domain->psm_mq, psm_tag, -1ULL,
psm_mq_irecv(ep_priv->domain->psm_mq, psm_tag, -1ULL,
0, buf, len, (void *)&req->fi_context, &psm_req);
args[0].u32w0 = PSMX_AM_REQ_READ_LONG;
@ -530,7 +536,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
args[2].u64 = addr;
args[3].u64 = key;
args[4].u64 = psm_tag;
err = psm_am_request_short((psm_epaddr_t) src_addr,
psm_am_request_short((psm_epaddr_t) src_addr,
PSMX_AM_RMA_HANDLER, args, 5, NULL, 0,
PSM_AM_FLAG_NOREPLY, NULL, NULL);
@ -544,7 +550,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
args[0].u32w1 = chunk_size;
args[2].u64 = addr;
args[4].u64 = offset;
err = psm_am_request_short((psm_epaddr_t) src_addr,
psm_am_request_short((psm_epaddr_t) src_addr,
PSMX_AM_RMA_HANDLER, args, 5, NULL, 0,
0, NULL, NULL);
addr += chunk_size;
@ -556,7 +562,7 @@ ssize_t _psmx_read(struct fid_ep *ep, void *buf, size_t len,
args[0].u32w1 = len;
args[2].u64 = addr;
args[4].u64 = offset;
err = psm_am_request_short((psm_epaddr_t) src_addr,
psm_am_request_short((psm_epaddr_t) src_addr,
PSMX_AM_RMA_HANDLER, args, 5, NULL, 0,
0, NULL, NULL);
@ -579,7 +585,7 @@ static ssize_t psmx_readmsg(struct fid_ep *ep, const struct fi_msg_rma *msg,
uint64_t flags)
{
if (!msg || msg->iov_count != 1)
return -EINVAL;
return -FI_EINVAL;
return _psmx_read(ep, msg->msg_iov[0].iov_base,
msg->msg_iov[0].iov_len,
@ -593,7 +599,7 @@ static ssize_t psmx_readv(struct fid_ep *ep, const struct iovec *iov,
uint64_t addr, uint64_t key, void *context)
{
if (!iov || count != 1)
return -EINVAL;
return -FI_EINVAL;
return psmx_read(ep, iov->iov_base, iov->iov_len,
desc ? desc[0] : NULL, src_addr, addr, key, context);
@ -611,7 +617,6 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
psm_amarg_t args[8];
int nargs;
int am_flags = PSM_AM_FLAG_ASYNC;
int err;
int chunk_size;
psm_mq_req_t psm_req;
uint64_t psm_tag;
@ -625,7 +630,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_WRITE;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -647,18 +652,18 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
}
if (!buf)
return -EINVAL;
return -FI_EINVAL;
av = ep_priv->av;
if (av && av->type == FI_AV_TABLE) {
idx = dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
dest_addr = (fi_addr_t) av->psm_epaddrs[idx];
}
else if (!dest_addr) {
return -EINVAL;
return -FI_EINVAL;
}
epaddr_context = psm_epaddr_getctxt((void *)dest_addr);
@ -670,7 +675,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
if (flags & FI_INJECT) {
req = malloc(sizeof(*req) + len);
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
memset((void *)req, 0, sizeof(*req));
memcpy((void *)req + sizeof(*req), (void *)buf, len);
@ -682,7 +687,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
else {
req = calloc(1, sizeof(*req));
if (!req)
return -ENOMEM;
return -FI_ENOMEM;
if (ep_priv->send_cq_event_flag && !(flags & FI_EVENT)) {
PSMX_CTXT_TYPE(&req->fi_context) = PSMX_NOCOMP_WRITE_CONTEXT;
@ -701,6 +706,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
req->write.context = context;
req->ep = ep_priv;
PSMX_CTXT_USER(&req->fi_context) = context;
PSMX_CTXT_EP(&req->fi_context) = ep_priv;
chunk_size = MIN(PSMX_AM_CHUNK_SIZE, psmx_am_param.max_request_short);
@ -718,7 +724,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
args[0].u32w0 |= PSMX_AM_DATA;
nargs++;
}
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_RMA_HANDLER, args, nargs,
NULL, 0, am_flags | PSM_AM_FLAG_NOREPLY,
NULL, NULL);
@ -736,7 +742,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
args[1].u64 = (uint64_t)(uintptr_t)req;
args[2].u64 = addr;
args[3].u64 = key;
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_RMA_HANDLER, args, nargs,
(void *)buf, chunk_size,
am_flags | PSM_AM_FLAG_NOREPLY, NULL, NULL);
@ -755,7 +761,7 @@ ssize_t _psmx_write(struct fid_ep *ep, const void *buf, size_t len,
args[0].u32w0 |= PSMX_AM_DATA;
nargs++;
}
err = psm_am_request_short((psm_epaddr_t) dest_addr,
psm_am_request_short((psm_epaddr_t) dest_addr,
PSMX_AM_RMA_HANDLER, args, nargs,
(void *)buf, len, am_flags, NULL, NULL);
@ -778,7 +784,7 @@ static ssize_t psmx_writemsg(struct fid_ep *ep, const struct fi_msg_rma *msg,
uint64_t flags)
{
if (!msg || msg->iov_count != 1)
return -EINVAL;
return -FI_EINVAL;
return _psmx_write(ep, msg->msg_iov[0].iov_base,
msg->msg_iov[0].iov_len,
@ -792,7 +798,7 @@ static ssize_t psmx_writev(struct fid_ep *ep, const struct iovec *iov,
uint64_t addr, uint64_t key, void *context)
{
if (!iov || count != 1)
return -EINVAL;
return -FI_EINVAL;
return psmx_write(ep, iov->iov_base, iov->iov_len,
desc ? desc[0] : NULL, dest_addr, addr, key, context);

Просмотреть файл

@ -46,16 +46,13 @@ ssize_t _psmx_tagged_recv(struct fid_ep *ep, void *buf, size_t len,
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
if (src_addr)
psmx_debug("%s: warning: src_addr is currently ignored.", __func__);
if (flags & FI_TRIGGER) {
struct psmx_trigger *trigger;
struct fi_triggered_context *ctxt = context;
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_TRECV;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -76,7 +73,7 @@ ssize_t _psmx_tagged_recv(struct fid_ep *ep, void *buf, size_t len,
}
if (tag & ep_priv->domain->reserved_tag_bits) {
fprintf(stderr, "%s: warning: using reserved tag bits."
PSMX_WARN("%s: warning: using reserved tag bits."
"tag=%lx. reserved_bits=%lx.\n", __func__, tag,
ep_priv->domain->reserved_tag_bits);
}
@ -89,7 +86,7 @@ ssize_t _psmx_tagged_recv(struct fid_ep *ep, void *buf, size_t len,
}
else {
if (!context)
return -EINVAL;
return -FI_EINVAL;
fi_context = context;
user_fi_context= 1;
@ -124,8 +121,6 @@ ssize_t psmx_tagged_recv_no_flag_av_map(struct fid_ep *ep, void *buf,
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
/* NOTE: src_addr currently unused */
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
psm_tagsel = (~ignore) | ep_priv->domain->reserved_tag_bits;
@ -151,25 +146,13 @@ ssize_t psmx_tagged_recv_no_flag_av_table(struct fid_ep *ep, void *buf,
void *context)
{
struct psmx_fid_ep *ep_priv;
struct psmx_fid_av *av;
psm_epaddr_t psm_epaddr;
psm_mq_req_t psm_req;
uint64_t psm_tag, psm_tagsel;
struct fi_context *fi_context;
int err;
size_t idx;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
av = ep_priv->av;
idx = (size_t)src_addr;
if (idx >= av->last)
return -EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
/* NOTE: psm_epaddr currently unused */
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
psm_tagsel = (~ignore) | ep_priv->domain->reserved_tag_bits;
@ -202,8 +185,6 @@ ssize_t psmx_tagged_recv_no_event_av_map(struct fid_ep *ep, void *buf,
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
/* NOTE: src_addr currently unused */
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
psm_tagsel = (~ignore) | ep_priv->domain->reserved_tag_bits;
@ -223,25 +204,13 @@ ssize_t psmx_tagged_recv_no_event_av_table(struct fid_ep *ep, void *buf,
void *context)
{
struct psmx_fid_ep *ep_priv;
struct psmx_fid_av *av;
psm_epaddr_t psm_epaddr;
psm_mq_req_t psm_req;
uint64_t psm_tag, psm_tagsel;
struct fi_context *fi_context;
int err;
size_t idx;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
av = ep_priv->av;
idx = (size_t)src_addr;
if (idx >= av->last)
return -EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
/* NOTE: psm_epaddr currently unused */
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
psm_tagsel = (~ignore) | ep_priv->domain->reserved_tag_bits;
@ -273,7 +242,7 @@ static ssize_t psmx_tagged_recvmsg(struct fid_ep *ep, const struct fi_msg_tagged
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -295,10 +264,6 @@ static ssize_t psmx_tagged_recv_no_flag(struct fid_ep *ep, void *buf,
uint64_t tag, uint64_t ignore,
void *context)
{
struct psmx_fid_ep *ep_priv;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
return psmx_tagged_recv_no_flag_av_map(
ep, buf, len, desc, src_addr,
tag, ignore, context);
@ -309,10 +274,6 @@ static ssize_t psmx_tagged_recv_no_event(struct fid_ep *ep, void *buf,
uint64_t tag, uint64_t ignore,
void *context)
{
struct psmx_fid_ep *ep_priv;
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
return psmx_tagged_recv_no_event_av_map(
ep, buf, len, desc, src_addr,
tag, ignore, context);
@ -326,7 +287,7 @@ static ssize_t psmx_tagged_recvv(struct fid_ep *ep, const struct iovec *iov, voi
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -349,7 +310,7 @@ static ssize_t psmx_tagged_recvv_no_flag(struct fid_ep *ep, const struct iovec *
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -373,7 +334,7 @@ static ssize_t psmx_tagged_recvv_no_event(struct fid_ep *ep, const struct iovec
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -411,7 +372,7 @@ ssize_t _psmx_tagged_send(struct fid_ep *ep, const void *buf, size_t len,
trigger = calloc(1, sizeof(*trigger));
if (!trigger)
return -ENOMEM;
return -FI_ENOMEM;
trigger->op = PSMX_TRIGGERED_TSEND;
trigger->cntr = container_of(ctxt->trigger.threshold.cntr,
@ -431,7 +392,7 @@ ssize_t _psmx_tagged_send(struct fid_ep *ep, const void *buf, size_t len,
}
if (tag & ep_priv->domain->reserved_tag_bits) {
fprintf(stderr, "%s: warning: using reserved tag bits."
PSMX_WARN("%s: warning: using reserved tag bits."
"tag=%lx. reserved_bits=%lx.\n", __func__, tag,
ep_priv->domain->reserved_tag_bits);
}
@ -440,7 +401,7 @@ ssize_t _psmx_tagged_send(struct fid_ep *ep, const void *buf, size_t len,
if (av && av->type == FI_AV_TABLE) {
idx = (size_t)dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
}
@ -453,7 +414,7 @@ ssize_t _psmx_tagged_send(struct fid_ep *ep, const void *buf, size_t len,
if (flags & FI_INJECT) {
fi_context = malloc(sizeof(*fi_context) + len);
if (!fi_context)
return -ENOMEM;
return -FI_ENOMEM;
memcpy((void *)fi_context + sizeof(*fi_context), buf, len);
buf = (void *)fi_context + sizeof(*fi_context);
@ -466,7 +427,7 @@ ssize_t _psmx_tagged_send(struct fid_ep *ep, const void *buf, size_t len,
}
else {
if (!context)
return -EINVAL;
return -FI_EINVAL;
fi_context = context;
if (fi_context != &ep_priv->sendimm_context) {
@ -540,7 +501,7 @@ ssize_t psmx_tagged_send_no_flag_av_table(struct fid_ep *ep, const void *buf,
av = ep_priv->av;
idx = (size_t)dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
@ -607,7 +568,7 @@ ssize_t psmx_tagged_send_no_event_av_table(struct fid_ep *ep, const void *buf,
av = ep_priv->av;
idx = (size_t)dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
@ -640,7 +601,7 @@ ssize_t psmx_tagged_inject_no_flag_av_map(struct fid_ep *ep, const void *buf, si
fi_context = malloc(sizeof(*fi_context) + len);
if (!fi_context)
return -ENOMEM;
return -FI_ENOMEM;
memcpy((void *)fi_context + sizeof(*fi_context), buf, len);
buf = (void *)fi_context + sizeof(*fi_context);
@ -671,14 +632,14 @@ ssize_t psmx_tagged_inject_no_flag_av_table(struct fid_ep *ep, const void *buf,
av = ep_priv->av;
idx = (size_t)dest_addr;
if (idx >= av->last)
return -EINVAL;
return -FI_EINVAL;
psm_epaddr = av->psm_epaddrs[idx];
psm_tag = tag & (~ep_priv->domain->reserved_tag_bits);
fi_context = malloc(sizeof(*fi_context) + len);
if (!fi_context)
return -ENOMEM;
return -FI_ENOMEM;
memcpy((void *)fi_context + sizeof(*fi_context), buf, len);
buf = (void *)fi_context + sizeof(*fi_context);
@ -711,7 +672,7 @@ static ssize_t psmx_tagged_sendmsg(struct fid_ep *ep, const struct fi_msg_tagged
size_t len;
if (!msg || msg->iov_count > 1)
return -EINVAL;
return -FI_EINVAL;
if (msg->iov_count) {
buf = msg->msg_iov[0].iov_base;
@ -734,7 +695,7 @@ static ssize_t psmx_tagged_sendv(struct fid_ep *ep, const struct iovec *iov, voi
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -758,7 +719,7 @@ static ssize_t psmx_tagged_sendv_no_flag_av_map(struct fid_ep *ep, const struct
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -783,7 +744,7 @@ static ssize_t psmx_tagged_sendv_no_flag_av_table(struct fid_ep *ep, const struc
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -808,7 +769,7 @@ static ssize_t psmx_tagged_sendv_no_event_av_map(struct fid_ep *ep, const struct
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -833,7 +794,7 @@ static ssize_t psmx_tagged_sendv_no_event_av_table(struct fid_ep *ep, const stru
size_t len;
if (!iov || count > 1)
return -EINVAL;
return -FI_EINVAL;
if (count) {
buf = iov[0].iov_base;
@ -872,7 +833,7 @@ static ssize_t psmx_tagged_search(struct fid_ep *ep, uint64_t *tag, uint64_t ign
ep_priv = container_of(ep, struct psmx_fid_ep, ep);
if ((*tag) & ep_priv->domain->reserved_tag_bits) {
fprintf(stderr, "%s: warning: using reserved tag bits."
PSMX_WARN("%s: warning: using reserved tag bits."
"tag=%lx. reserved_bits=%lx.\n", __func__, *tag,
ep_priv->domain->reserved_tag_bits);
}

Просмотреть файл

@ -50,8 +50,8 @@ static void psmx_string_to_uuid(const char *s, psm_uuid_t uuid)
&uuid[10], &uuid[11], &uuid[12], &uuid[13], &uuid[14], &uuid[15]);
if (n != 16) {
fprintf(stderr, "%s: wrong uuid format: %s\n", __func__, s);
fprintf(stderr, "%s: correct uuid format is: "
PSMX_WARN("%s: wrong uuid format: %s\n", __func__, s);
PSMX_WARN("%s: correct uuid format is: "
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n",
__func__);
}
@ -111,7 +111,7 @@ void *psmx_name_server(void *args)
n = getaddrinfo(NULL, service, &hints, &res);
if (n < 0) {
fprintf(stderr, "%s: port %d: %s\n", __func__, port, gai_strerror(n));
PSMX_DEBUG("%s: port %d: %s\n", __func__, port, gai_strerror(n));
free(service);
return NULL;
}
@ -132,7 +132,7 @@ void *psmx_name_server(void *args)
free(service);
if (listenfd < 0) {
fprintf(stderr, "%s: couldn't listen to port %d\n", __func__, port);
PSMX_DEBUG("%s: couldn't listen to port %d\n", __func__, port);
return NULL;
}
@ -181,7 +181,7 @@ void *psmx_resolve_name(const char *servername, int port)
n = getaddrinfo(servername, service, &hints, &res);
if (n < 0) {
psmx_debug("%s:(%s:%d):%s\n", __func__, servername, port, gai_strerror(n));
PSMX_DEBUG("%s:(%s:%d):%s\n", __func__, servername, port, gai_strerror(n));
free(service);
return NULL;
}
@ -200,7 +200,7 @@ void *psmx_resolve_name(const char *servername, int port)
free(service);
if (sockfd < 0) {
psmx_debug("%s: couldn't connect to %s:%d\n", __func__, servername, port);
PSMX_DEBUG("%s: couldn't connect to %s:%d\n", __func__, servername, port);
return NULL;
}
@ -307,14 +307,3 @@ void psmx_query_mpi(void)
/* TODO: check other MPI */
}
void psmx_debug(char *fmt, ...)
{
va_list ap;
if (psmx_env.debug) {
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
}

Просмотреть файл

@ -86,7 +86,7 @@ static void psmx_wait_start_progress(struct psmx_fid_domain *domain)
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
err = pthread_create(&psmx_wait_thread, &attr, psmx_wait_progress, (void *)domain);
if (err)
fprintf(stderr, "%s: cannot create wait progress thread\n", __func__);
PSMX_WARN("%s: cannot create wait progress thread\n", __func__);
pthread_attr_destroy(&attr);
while (!psmx_wait_thread_ready)
;
@ -108,17 +108,15 @@ int psmx_wait_get_obj(struct psmx_fid_wait *wait, void *arg)
{
void *obj_ptr;
int obj_size = 0;
int obj_type = FI_WAIT_NONE;
struct fi_mutex_cond mutex_cond;
if (!arg)
return -EINVAL;
return -FI_EINVAL;
if (wait) {
switch (wait->type) {
case FI_WAIT_FD:
obj_size = sizeof(wait->fd[0]);
obj_type = wait->type;
obj_ptr = &wait->fd[0];
break;
@ -126,7 +124,6 @@ int psmx_wait_get_obj(struct psmx_fid_wait *wait, void *arg)
mutex_cond.mutex = &wait->mutex;
mutex_cond.cond = &wait->cond;
obj_size = sizeof(mutex_cond);
obj_type = wait->type;
obj_ptr = &mutex_cond;
break;
@ -279,7 +276,7 @@ int psmx_wait_open(struct fid_fabric *fabric, struct fi_wait_attr *attr,
break;
default:
psmx_debug("%s: attr->wait_obj=%d, supported=%d,%d,%d\n",
PSMX_DEBUG("%s: attr->wait_obj=%d, supported=%d,%d,%d\n",
__func__, attr->wait_obj, FI_WAIT_UNSPEC,
FI_WAIT_FD, FI_WAIT_MUTEX_COND);
return -FI_EINVAL;

Просмотреть файл

@ -34,6 +34,8 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <pthread.h>
#include <rdma/fabric.h>
#include <rdma/fi_atomic.h>
#include <rdma/fi_cm.h>
@ -68,7 +70,9 @@
#define SOCK_EP_MAX_RX_CNT (16)
#define SOCK_EP_MAX_IOV_LIMIT (8)
#define SOCK_EP_TX_SZ (256)
#define SOCK_EP_RX_SZ (256)
#define SOCK_EP_TX_ENTRY_SZ (256)
#define SOCK_EP_RX_ENTRY_SZ (256)
#define SOCK_EP_MIN_MULTI_RECV (64)
#define SOCK_EP_MAX_ATOMIC_SZ (256)
#define SOCK_EP_MAX_CTX_BITS (16)
@ -120,7 +124,7 @@
#define SOCK_MAJOR_VERSION 1
#define SOCK_MINOR_VERSION 0
#define SOCK_INJECT_OK(_flgs) (((_flgs) & FI_INJECT) && ((!(_flgs)) & FI_FENCE))
#define SOCK_INJECT_OK(_flgs) ((_flgs) & FI_INJECT)
struct sock_fabric{
struct fid_fabric fab_fid;

Просмотреть файл

@ -214,6 +214,7 @@ static ssize_t sock_ep_tx_atomic(struct fid_ep *ep,
return 0;
err:
SOCK_LOG_INFO("Not enough space for TX entry, try again\n");
sock_tx_ctx_abort(tx_ctx);
return ret;
}

Просмотреть файл

@ -38,6 +38,7 @@
#include <netinet/in.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@ -125,7 +126,8 @@ struct sock_conn *sock_av_lookup_addr(struct sock_av *av,
av->domain, av->cmap,
(struct sockaddr_in*)&av_addr->addr);
if (!av->key[idx]) {
SOCK_LOG_ERROR("failed to match or connect to addr %lu\n", addr);
SOCK_LOG_ERROR("failed to match or connect to addr %"
PRIu64 "\n", addr);
errno = EINVAL;
return NULL;
}
@ -295,7 +297,7 @@ static int sock_av_lookup(struct fid_av *av, fi_addr_t fi_addr, void *addr,
}
av_addr = idm_lookup(&_av->addr_idm, index);
addr = &av_addr->addr;
memcpy(addr, &av_addr->addr, MIN(*addrlen, _av->addrlen));
*addrlen = _av->addrlen;
return 0;
}
@ -447,11 +449,11 @@ static int sock_av_close(struct fid *fid)
if (!av->name)
free(av->table_hdr);
else {
shm_unlink(av->name);
free(av->name);
munmap(av->table_hdr, sizeof(struct sock_av_table_hdr) +
av->attr.count * sizeof(struct sock_av_addr));
close(av->shared_fd);
shm_unlink(av->name);
}
atomic_dec(&av->domain->ref);
@ -561,8 +563,8 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
if (ftruncate(_av->shared_fd, table_sz) == -1) {
SOCK_LOG_ERROR("ftruncate failed\n");
free(_av);
shm_unlink(_av->name);
free(_av);
return -FI_EINVAL;
}
@ -578,8 +580,8 @@ int sock_av_open(struct fid_domain *domain, struct fi_av_attr *attr,
if (_av->table_hdr == MAP_FAILED) {
SOCK_LOG_ERROR("mmap failed\n");
free(_av);
shm_unlink(_av->name);
free(_av);
return -FI_EINVAL;
}
} else {

Просмотреть файл

@ -177,7 +177,7 @@ uint16_t sock_conn_map_connect(struct sock_domain *dom,
memcpy(&map->curr_addr, addr, sizeof(struct sockaddr_in));
fastlock_release(&map->lock);
if (connect(conn_fd, addr, sizeof *addr) < 0) {
if (connect(conn_fd, (struct sockaddr *) addr, sizeof *addr) < 0) {
if (errno == EINPROGRESS) {
/* timeout after 5 secs */
tv.tv_sec = 5;
@ -355,7 +355,7 @@ static void *_sock_conn_listen(void *arg)
}
addr_size = sizeof(struct sockaddr_in);
getpeername(conn_fd, &remote, &addr_size);
getpeername(conn_fd, (struct sockaddr *) &remote, &addr_size);
memcpy(sa_ip, inet_ntoa(remote.sin_addr), INET_ADDRSTRLEN);
SOCK_LOG_INFO("ACCEPT: %s, %d\n", sa_ip, ntohs(remote.sin_port));

Просмотреть файл

@ -81,7 +81,7 @@ static struct sock_tx_ctx *sock_tx_context_alloc(const struct fi_tx_attr *attr,
return NULL;
if (rbfdinit(&tx_ctx->rbfd,
(attr->size) ? attr->size :
(attr->size) ? attr->size * SOCK_EP_TX_ENTRY_SZ:
SOCK_EP_TX_SZ * SOCK_EP_TX_ENTRY_SZ))
goto err;

Просмотреть файл

@ -40,8 +40,6 @@
#include "sock.h"
#include "sock_util.h"
extern const char const sock_dom_name[];
const struct fi_domain_attr sock_domain_attr = {
.name = NULL,
.threading = FI_THREAD_SAFE,

Просмотреть файл

@ -53,10 +53,6 @@ extern struct fi_ops_ep sock_ctx_ep_ops;
extern const struct fi_domain_attr sock_domain_attr;
extern const struct fi_fabric_attr sock_fabric_attr;
extern const char const sock_fab_name[];
extern const char const sock_dom_name[];
extern const char const sock_prov_name[];
const struct fi_tx_attr sock_stx_attr = {
.caps = SOCK_EP_RDM_CAP,
.op_flags = SOCK_DEF_OPS,
@ -157,18 +153,6 @@ static int sock_ctx_bind_cq(struct fid *fid, struct fid *bfid, uint64_t flags)
rx_ctx->comp.recv_cq_event = 1;
}
if (flags & FI_REMOTE_READ) {
rx_ctx->comp.rem_read_cq = sock_cq;
if (flags & FI_COMPLETION)
rx_ctx->comp.rem_read_cq_event = 1;
}
if (flags & FI_REMOTE_WRITE) {
rx_ctx->comp.rem_write_cq = sock_cq;
if (flags & FI_COMPLETION)
rx_ctx->comp.rem_write_cq_event = 1;
}
dlist_insert_tail(&rx_ctx->cq_entry, &sock_cq->rx_list);
break;
@ -280,68 +264,6 @@ static int sock_ctx_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
}
static int sock_ctx_control(struct fid *fid, int command, void *arg)
{
struct sock_tx_ctx *tx_ctx;
struct sock_rx_ctx *rx_ctx;
switch (fid->fclass) {
case FI_CLASS_TX_CTX:
tx_ctx = container_of(fid, struct sock_tx_ctx, fid.ctx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = tx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
tx_ctx->attr.op_flags = (uint64_t)arg;
break;
default:
return -FI_EINVAL;
}
break;
case FI_CLASS_RX_CTX:
rx_ctx = container_of(fid, struct sock_rx_ctx, ctx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = rx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
rx_ctx->attr.op_flags = (uint64_t)arg;
break;
default:
return -FI_EINVAL;
}
break;
case FI_CLASS_STX_CTX:
tx_ctx = container_of(fid, struct sock_tx_ctx, fid.stx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = tx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
tx_ctx->attr.op_flags = (uint64_t)arg;
break;
default:
return -FI_EINVAL;
}
break;
default:
return -FI_EINVAL;
}
return 0;
}
static struct fi_ops sock_ctx_ops = {
.size = sizeof(struct fi_ops),
.close = sock_ctx_close,
.bind = sock_ctx_bind,
.control = sock_ctx_control,
};
static int sock_ctx_enable(struct fid_ep *ep)
{
struct sock_tx_ctx *tx_ctx;
@ -373,6 +295,77 @@ static int sock_ctx_enable(struct fid_ep *ep)
return -FI_EINVAL;
}
static int sock_ctx_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep;
struct sock_tx_ctx *tx_ctx;
struct sock_rx_ctx *rx_ctx;
switch (fid->fclass) {
case FI_CLASS_TX_CTX:
tx_ctx = container_of(fid, struct sock_tx_ctx, fid.ctx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = tx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
tx_ctx->attr.op_flags = (uint64_t)arg;
break;
case FI_ENABLE:
ep = container_of(fid, struct fid_ep, fid);
return sock_ctx_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
case FI_CLASS_RX_CTX:
rx_ctx = container_of(fid, struct sock_rx_ctx, ctx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = rx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
rx_ctx->attr.op_flags = (uint64_t)arg;
break;
case FI_ENABLE:
ep = container_of(fid, struct fid_ep, fid);
return sock_ctx_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
case FI_CLASS_STX_CTX:
tx_ctx = container_of(fid, struct sock_tx_ctx, fid.stx.fid);
switch (command) {
case FI_GETOPSFLAG:
*(uint64_t*)arg = tx_ctx->attr.op_flags;
break;
case FI_SETOPSFLAG:
tx_ctx->attr.op_flags = (uint64_t)arg;
break;
default:
return -FI_ENOSYS;
}
break;
default:
return -FI_ENOSYS;
}
return 0;
}
static struct fi_ops sock_ctx_ops = {
.size = sizeof(struct fi_ops),
.close = sock_ctx_close,
.bind = sock_ctx_bind,
.control = sock_ctx_control,
};
static int sock_ctx_getopt(fid_t fid, int level, int optname,
void *optval, size_t *optlen)
{
@ -425,7 +418,7 @@ static ssize_t sock_rx_ctx_cancel(struct sock_rx_ctx *rx_ctx, void *context)
entry != &rx_ctx->rx_entry_list; entry = entry->next) {
rx_entry = container_of(entry, struct sock_rx_entry, entry);
if (rx_entry->is_busy || rx_entry->used)
if (rx_entry->is_busy)
continue;
if ((uint64_t)context == rx_entry->context) {
@ -470,7 +463,6 @@ static ssize_t sock_ep_cancel(fid_t fid, void *context)
struct fi_ops_ep sock_ctx_ep_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = sock_ctx_enable,
.cancel = sock_ep_cancel,
.getopt = sock_ctx_getopt,
.setopt = sock_ctx_setopt,
@ -585,18 +577,6 @@ static int sock_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
ep->comp.recv_cq_event = 1;
}
if (flags & FI_REMOTE_READ) {
ep->comp.rem_read_cq = cq;
if (flags & FI_COMPLETION)
ep->comp.rem_read_cq_event = 1;
}
if (flags & FI_REMOTE_WRITE) {
ep->comp.rem_write_cq = cq;
if (flags & FI_COMPLETION)
ep->comp.rem_write_cq_event = 1;
}
if (flags & FI_SEND || flags & FI_WRITE || flags & FI_READ) {
for (i=0; i < ep->ep_attr.tx_ctx_cnt; i++) {
tx_ctx = ep->tx_array[i];
@ -610,8 +590,7 @@ static int sock_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
}
}
if (flags & FI_RECV || flags & FI_REMOTE_READ ||
flags & FI_REMOTE_WRITE) {
if (flags & FI_RECV) {
for (i = 0; i < ep->ep_attr.rx_ctx_cnt; i++) {
rx_ctx = ep->rx_array[i];
@ -625,18 +604,6 @@ static int sock_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
ep->comp.recv_cq_event = 1;
}
if (flags & FI_REMOTE_READ) {
ep->comp.rem_read_cq = cq;
if (flags & FI_COMPLETION)
ep->comp.rem_read_cq_event = 1;
}
if (flags & FI_REMOTE_WRITE) {
ep->comp.rem_write_cq = cq;
if (flags & FI_COMPLETION)
ep->comp.rem_write_cq_event = 1;
}
dlist_insert_tail(&rx_ctx->cq_entry, &cq->rx_list);
continue;
}
@ -764,6 +731,7 @@ static int sock_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags)
static int sock_ep_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep_fid;
struct fi_alias *alias;
struct sock_ep *ep, *new_ep;
@ -798,6 +766,9 @@ static int sock_ep_control(struct fid *fid, int command, void *arg)
case FI_SETOPSFLAG:
ep->op_flags = (uint64_t)arg;
break;
case FI_ENABLE:
ep_fid = container_of(fid, struct fid_ep, fid);
return sock_ep_enable(ep_fid);
default:
return -FI_EINVAL;
@ -980,7 +951,6 @@ static int sock_ep_rx_ctx(struct fid_ep *ep, int index, struct fi_rx_attr *attr,
struct fi_ops_ep sock_ep_ops ={
.size = sizeof(struct fi_ops_ep),
.enable = sock_ep_enable,
.cancel = sock_ep_cancel,
.getopt = sock_ep_getopt,
.setopt = sock_ep_setopt,

Просмотреть файл

@ -83,7 +83,7 @@ const struct fi_rx_attr sock_dgram_rx_attr = {
.op_flags = SOCK_DEF_OPS,
.msg_order = SOCK_EP_MSG_ORDER,
.total_buffered_recv = SOCK_EP_MAX_BUFF_RECV,
.size = SOCK_EP_MAX_MSG_SZ,
.size = SOCK_EP_RX_SZ,
.iov_limit = SOCK_EP_MAX_IOV_LIMIT,
};

Просмотреть файл

@ -84,7 +84,7 @@ const struct fi_rx_attr sock_msg_rx_attr = {
.op_flags = SOCK_DEF_OPS,
.msg_order = SOCK_EP_MSG_ORDER,
.total_buffered_recv = SOCK_EP_MAX_BUFF_RECV,
.size = SOCK_EP_MAX_MSG_SZ,
.size = SOCK_EP_RX_SZ,
.iov_limit = SOCK_EP_MAX_IOV_LIMIT,
};
@ -469,7 +469,8 @@ static int sock_ep_cm_send_msg(int sock_fd,
sa_ip, ntohs(addr->sin_port));
while (retry < SOCK_EP_MAX_RETRY) {
ret = sendto(sock_fd, (char *)msg, len, 0, addr, sizeof *addr);
ret = sendto(sock_fd, (char *)msg, len, 0,
(struct sockaddr *) addr, sizeof *addr);
SOCK_LOG_INFO("Total Sent: %d\n", ret);
if (ret < 0)
return -1;
@ -482,7 +483,7 @@ static int sock_ep_cm_send_msg(int sock_fd,
addr_len = sizeof(struct sockaddr_in);
ret = recvfrom(sock_fd, &response, sizeof(response), 0,
&from_addr, &addr_len);
(struct sockaddr *) &from_addr, &addr_len);
SOCK_LOG_INFO("Received ACK: %d\n", ret);
if (ret == sizeof(response))
return 0;
@ -497,7 +498,7 @@ static int sock_ep_cm_send_ack(int sock_fd, struct sockaddr_in *addr)
while(!ack_sent && retry < SOCK_EP_MAX_RETRY) {
ret = sendto(sock_fd, &response, sizeof(response), 0,
addr, sizeof *addr);
(struct sockaddr *) addr, sizeof *addr);
retry++;
SOCK_LOG_INFO("ack: %d\n", ret);
@ -548,7 +549,7 @@ static void *sock_msg_ep_listener_thread (void *data)
addr_len = sizeof(struct sockaddr_in);
ret = recvfrom(ep->socket, (char*)conn_response,
sizeof(*conn_response) + SOCK_EP_MAX_CM_DATA_SZ,
0, &from_addr, &addr_len);
0, (struct sockaddr *) &from_addr, &addr_len);
if (ret <= 0)
continue;
@ -911,7 +912,7 @@ static void *sock_pep_listener_thread (void *data)
addr_len = sizeof(struct sockaddr_in);
ret = recvfrom(pep->socket, (char*)conn_req,
sizeof(*conn_req) + SOCK_EP_MAX_CM_DATA_SZ, 0,
&from_addr, &addr_len);
(struct sockaddr *) &from_addr, &addr_len);
if (ret <= 0)
continue;
memcpy(&conn_req->from_addr, &from_addr, sizeof(struct sockaddr_in));

Просмотреть файл

@ -84,7 +84,7 @@ const struct fi_rx_attr sock_rdm_rx_attr = {
.op_flags = SOCK_DEF_OPS,
.msg_order = SOCK_EP_MSG_ORDER,
.total_buffered_recv = SOCK_EP_MAX_BUFF_RECV,
.size = SOCK_EP_MAX_MSG_SZ,
.size = SOCK_EP_RX_SZ,
.iov_limit = SOCK_EP_MAX_IOV_LIMIT,
};

Просмотреть файл

@ -42,9 +42,11 @@
#include "sock.h"
#include "sock_util.h"
const char const sock_fab_name[] = "IP";
const char const sock_dom_name[] = "sockets";
const char const sock_prov_name[] = "sockets";
const char sock_fab_name[] = "IP";
const char sock_dom_name[] = "sockets";
const char sock_prov_name[] = "sockets";
useconds_t sock_progress_thread_wait = 0;
const struct fi_fabric_attr sock_fabric_attr = {
.fabric = NULL,
@ -246,20 +248,15 @@ struct fi_provider sock_prov = {
.cleanup = fi_sockets_fini
};
SOCKETS_INI
{
char *tmp = getenv("OFI_SOCK_LOG_LEVEL");
if (tmp) {
sock_log_level = atoi(tmp);
} else {
sock_log_level = SOCK_ERROR;
}
char *tmp;
fi_log_init();
tmp = getenv("OFI_SOCK_PROGRESS_YIELD_TIME");
if (tmp) {
if (tmp)
sock_progress_thread_wait = atoi(tmp);
}
return (&sock_prov);
}

Просмотреть файл

@ -93,7 +93,8 @@ static ssize_t sock_ep_recvmsg(struct fid_ep *ep, const struct fi_msg *msg,
rx_entry->flags = flags;
rx_entry->context = (uint64_t)msg->context;
rx_entry->addr = msg->addr;
rx_entry->addr = (rx_ctx->attr.caps & FI_DIRECTED_RECV) ?
msg->addr : FI_ADDR_UNSPEC;
rx_entry->data = msg->data;
rx_entry->ignore = 0xFFFFFFFF;
@ -239,6 +240,7 @@ static ssize_t sock_ep_sendmsg(struct fid_ep *ep, const struct fi_msg *msg,
return 0;
err:
SOCK_LOG_INFO("Not enough space for TX entry, try again\n");
sock_tx_ctx_abort(tx_ctx);
return ret;
}
@ -356,7 +358,8 @@ static ssize_t sock_ep_trecvmsg(struct fid_ep *ep,
rx_entry->flags = flags;
rx_entry->context = (uint64_t)msg->context;
rx_entry->addr = msg->addr;
rx_entry->addr = (rx_ctx->attr.caps & FI_DIRECTED_RECV) ?
msg->addr : FI_ADDR_UNSPEC;
rx_entry->data = msg->data;
rx_entry->tag = msg->tag;
rx_entry->ignore = msg->ignore;
@ -437,7 +440,11 @@ static ssize_t sock_ep_tsendmsg(struct fid_ep *ep,
}
assert(tx_ctx->enabled && msg->iov_count <= SOCK_EP_MAX_IOV_LIMIT);
conn = sock_av_lookup_addr(tx_ctx->av, msg->addr);
if (sock_ep->connected) {
conn = sock_ep_lookup_conn(sock_ep);
} else {
conn = sock_av_lookup_addr(tx_ctx->av, msg->addr);
}
if (!conn)
return -FI_EAGAIN;
@ -496,6 +503,7 @@ static ssize_t sock_ep_tsendmsg(struct fid_ep *ep,
return 0;
err:
SOCK_LOG_INFO("Not enough space for TX entry, try again\n");
sock_tx_ctx_abort(tx_ctx);
return ret;
}

Просмотреть файл

@ -51,6 +51,7 @@
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#include <inttypes.h>
#include "sock.h"
#include "sock_util.h"
@ -107,14 +108,19 @@ static void sock_pe_release_entry(struct sock_pe *pe,
dlist_remove(&pe_entry->ctx_entry);
if (pe_entry->type == SOCK_PE_TX)
pe_entry->conn->tx_pe_entry = NULL;
else
{
if (pe_entry->conn->tx_pe_entry == pe_entry)
pe_entry->conn->tx_pe_entry = NULL;
} else {
pe_entry->conn->rx_pe_entry = NULL;
}
pe->num_free_entries++;
pe_entry->conn = NULL;
memset(&pe_entry->pe.rx, 0, sizeof(pe_entry->pe.rx));
memset(&pe_entry->pe.tx, 0, sizeof(pe_entry->pe.tx));
memset(&pe_entry->msg_hdr, 0, sizeof(pe_entry->msg_hdr));
memset(&pe_entry->response, 0, sizeof(pe_entry->response));
pe_entry->type =0;
@ -123,6 +129,7 @@ static void sock_pe_release_entry(struct sock_pe *pe,
pe_entry->total_len = 0;
pe_entry->data_len = 0;
pe_entry->buf = 0;
pe_entry->flags = 0;
dlist_remove(&pe_entry->entry);
dlist_insert_head(&pe_entry->entry, &pe->free_list);
@ -576,7 +583,7 @@ static int sock_pe_process_rx_read(struct sock_pe *pe, struct sock_rx_ctx *rx_ct
pe_entry->pe.rx.rx_iov[i].iov.len,
FI_REMOTE_READ);
if (!mr) {
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %lu\n",
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %" PRIu64 "\n",
(void*)pe_entry->pe.rx.rx_iov[i].iov.addr,
pe_entry->pe.rx.rx_iov[i].iov.len,
pe_entry->pe.rx.rx_iov[i].iov.key);
@ -633,7 +640,7 @@ static int sock_pe_process_rx_write(struct sock_pe *pe, struct sock_rx_ctx *rx_c
pe_entry->pe.rx.rx_iov[i].iov.len,
FI_REMOTE_WRITE);
if (!mr) {
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %lu\n",
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %" PRIu64 "\n",
(void*)pe_entry->pe.rx.rx_iov[i].iov.addr,
pe_entry->pe.rx.rx_iov[i].iov.len,
pe_entry->pe.rx.rx_iov[i].iov.key);
@ -1047,7 +1054,7 @@ static int sock_pe_process_rx_atomic(struct sock_pe *pe, struct sock_rx_ctx *rx_
pe_entry->pe.rx.rx_iov[i].ioc.count * datatype_sz,
FI_REMOTE_WRITE);
if (!mr) {
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %lu\n",
SOCK_LOG_ERROR("Remote memory access error: %p, %lu, %" PRIu64 "\n",
(void*)pe_entry->pe.rx.rx_iov[i].ioc.addr,
pe_entry->pe.rx.rx_iov[i].ioc.count * datatype_sz,
pe_entry->pe.rx.rx_iov[i].ioc.key);
@ -1132,6 +1139,8 @@ int sock_pe_progress_buffered_rx(struct sock_rx_ctx *rx_ctx)
rem = rx_buffered->iov[0].iov.len;
rx_ctx->buffered_len -= rem;
used_len = rx_posted->used;
pe_entry.data_len = 0;
pe_entry.buf = 0L;
for (i = 0; i < rx_posted->rx_op.dest_iov_len && rem > 0; i++) {
if (used_len >= rx_posted->rx_op.dest_iov_len) {
used_len -= rx_posted->rx_op.dest_iov_len;
@ -1405,7 +1414,7 @@ static int sock_pe_peek_hdr(struct sock_pe *pe,
msg_hdr->pe_entry_id = ntohs(msg_hdr->pe_entry_id);
msg_hdr->ep_id = ntohs(msg_hdr->ep_id);
SOCK_LOG_INFO("PE RX (Hdr peek): MsgLen: %lu, TX-ID: %d, Type: %d\n",
SOCK_LOG_INFO("PE RX (Hdr peek): MsgLen: %" PRIu64 ", TX-ID: %d, Type: %d\n",
msg_hdr->msg_len, msg_hdr->rx_id, msg_hdr->op_type);
return 0;
}
@ -1463,7 +1472,7 @@ static int sock_pe_read_hdr(struct sock_pe *pe, struct sock_rx_ctx *rx_ctx,
msg_hdr->ep_id = ntohs(msg_hdr->ep_id);
pe_entry->pe.rx.header_read = 1;
SOCK_LOG_INFO("PE RX (Hdr read): MsgLen: %lu, TX-ID: %d, Type: %d\n",
SOCK_LOG_INFO("PE RX (Hdr read): MsgLen: %" PRIu64 ", TX-ID: %d, Type: %d\n",
msg_hdr->msg_len, msg_hdr->rx_id, msg_hdr->op_type);
return 0;
}

Просмотреть файл

@ -89,7 +89,12 @@ static ssize_t sock_ep_rma_readmsg(struct fid_ep *ep,
msg->iov_count <= SOCK_EP_MAX_IOV_LIMIT &&
msg->rma_iov_count <= SOCK_EP_MAX_IOV_LIMIT);
conn = sock_av_lookup_addr(tx_ctx->av, msg->addr);
if (sock_ep->connected) {
conn = sock_ep_lookup_conn(sock_ep);
} else {
conn = sock_av_lookup_addr(tx_ctx->av, msg->addr);
}
if (!conn)
return -FI_EAGAIN;
@ -149,6 +154,7 @@ static ssize_t sock_ep_rma_readmsg(struct fid_ep *ep,
return 0;
err:
SOCK_LOG_INFO("Not enough space for TX entry, try again\n");
sock_tx_ctx_abort(tx_ctx);
return ret;
}
@ -315,6 +321,7 @@ static ssize_t sock_ep_rma_writemsg(struct fid_ep *ep,
return 0;
err:
SOCK_LOG_INFO("Not enough space for TX entry, try again\n");
sock_tx_ctx_abort(tx_ctx);
return ret;
}

Просмотреть файл

@ -30,42 +30,25 @@
* SOFTWARE.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#ifndef _SOCK_UTIL_H_
#define _SOCK_UTIL_H_
#include <stdio.h>
#include "fi_log.h"
#define SOCK_ERROR (1)
#define SOCK_WARN (2)
#define SOCK_INFO (3)
extern int sock_log_level;
extern useconds_t sock_progress_thread_wait;
#define SOCK_LOG_INFO(...) do { \
if (sock_log_level >= SOCK_INFO) { \
fprintf(stderr, "[SOCK_INFO - %s:%d]: ", __func__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
extern const char sock_fab_name[];
extern const char sock_dom_name[];
extern const char sock_prov_name[];
#define SOCK_LOG_WARN(...) do { \
if (sock_log_level >= SOCK_WARN) { \
fprintf(stderr, "[SOCK_WARN - %s:%d]: ", __func__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
#define SOCK_LOG_INFO(...) FI_LOG(SOCK_INFO, sock_prov_name, __VA_ARGS__)
#define SOCK_LOG_ERROR(...) do { \
if (sock_log_level >= SOCK_ERROR) { \
fprintf(stderr, "[SOCK_ERROR - %s:%d]: ", __func__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
} \
} while (0)
#define SOCK_LOG_WARN(...) FI_WARN(sock_prov_name, __VA_ARGS__)
#define SOCK_LOG_ERROR(...) FI_WARN(sock_prov_name, __VA_ARGS__)
#endif

Просмотреть файл

@ -113,11 +113,12 @@ AC_DEFUN([FI_USNIC_CONFIGURE],[
AS_IF([test "x$enable_usnic" != "xno"],
[usnic_happy=1
AC_CHECK_HEADER([infiniband/verbs.h], [], [usnic_happy=0])
CHECK_LIBNL3([USNIC_LIBNL_CPPFLAGS],
[USNIC_LIBNL_LIBS], [0])
AS_IF([test "$USNIC_LIBNL_LIBS" != ""],
[CPPFLAGS="$USNIC_LIBNL_CPPFLAGS $CPPFLAGS"
LIBS="$USNIC_LIBNL_LIBS $LIBS"],
CHECK_LIBNL3([usnic_libnl_CPPFLAGS],
[usnic_libnl_LIBS], [0])
AC_SUBST(usnic_libnl_CPPFLAGS)
AC_SUBST(usnic_libnl_LIBS)
AS_IF([test "$usnic_libnl_LIBS" = ""],
[usnic_happy=0])
])
])

Просмотреть файл

@ -38,7 +38,7 @@
#define FI_PROTO_RUDP 100
#define FI_USNIC_INFO_VERSION 1
#define FI_EXT_USNIC_INFO_VERSION 1
/*
* usNIC specific info
@ -66,7 +66,8 @@ struct fi_usnic_info {
#define FI_USNIC_FABRIC_OPS_1 "fabric_ops 1"
struct fi_usnic_ops_fabric {
size_t size;
int (*getinfo)(struct fid_fabric *fabric, struct fi_usnic_info *info);
int (*getinfo)(uint32_t version, struct fid_fabric *fabric,
struct fi_usnic_info *info);
};
/*

Просмотреть файл

@ -39,6 +39,8 @@
#include <sys/queue.h>
#include <pthread.h>
#include "fi_log.h"
#include "usdf_progress.h"
#include "usd.h"
@ -47,6 +49,10 @@
#define USDF_MINOR_VERS 0
#define USDF_PROV_VERSION FI_VERSION(USDF_MAJOR_VERS, USDF_MINOR_VERS)
#define USDF_WARN(...) FI_WARN("usnic", __VA_ARGS__)
#define USDF_INFO(...) FI_LOG(3, "usnic", __VA_ARGS__)
#define USDF_DEBUG(...) FI_DEBUG("usnic", __VA_ARGS__)
#define USDF_HDR_BUF_ENTRY 64
#define USDF_EP_CAP_PIO (1ULL << 63)

Просмотреть файл

@ -210,21 +210,21 @@ usdf_domain_open(struct fid_fabric *fabric, struct fi_info *info,
{
struct usdf_fabric *fp;
struct usdf_domain *udp;
struct usdf_usnic_info *dp;
struct usdf_dev_entry *dep;
struct sockaddr_in *sin;
size_t addrlen;
int d;
int ret;
udp = calloc(1, sizeof *udp);
if (udp == NULL) {
USDF_DEBUG("unable to alloc mem for domain\n");
ret = -FI_ENOMEM;
goto fail;
}
fp = fab_fidtou(fabric);
USDF_DEBUG("uda_devname=%s\n", fp->fab_dev_attrs->uda_devname);
/*
* Make sure address format is good and matches this fabric
*/
@ -246,24 +246,9 @@ usdf_domain_open(struct fid_fabric *fabric, struct fi_info *info,
goto fail;
}
/* steal cached device from info if we can */
dp = __usdf_devinfo;
for (d = 0; d < dp->uu_num_devs; ++d) {
dep = &dp->uu_info[d];
if (dep->ue_dev != NULL &&
strcmp(fp->fab_dev_attrs->uda_devname,
dep->ue_dattr.uda_devname) == 0) {
udp->dom_dev = dep->ue_dev;
dep->ue_dev = NULL;
break;
}
}
if (udp->dom_dev == NULL) {
ret = usd_open(fp->fab_dev_attrs->uda_devname, &udp->dom_dev);
if (ret != 0) {
goto fail;
}
ret = usd_open(fp->fab_dev_attrs->uda_devname, &udp->dom_dev);
if (ret != 0) {
goto fail;
}
udp->dom_fid.fid.fclass = FI_CLASS_DOMAIN;

Просмотреть файл

@ -282,7 +282,6 @@ usdf_ep_dgram_close(fid_t fid)
static struct fi_ops_ep usdf_base_dgram_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = usdf_ep_dgram_enable,
.cancel = fi_no_cancel,
.getopt = fi_no_getopt,
.setopt = fi_no_setopt,
@ -294,7 +293,6 @@ static struct fi_ops_ep usdf_base_dgram_ops = {
static struct fi_ops_ep usdf_base_dgram_prefix_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = usdf_ep_dgram_enable,
.cancel = fi_no_cancel,
.getopt = fi_no_getopt,
.setopt = fi_no_setopt,
@ -336,11 +334,31 @@ static struct fi_ops_cm usdf_cm_dgram_ops = {
.shutdown = fi_no_shutdown,
};
static int usdf_ep_dgram_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep;
switch (fid->fclass) {
case FI_CLASS_EP:
ep = container_of(fid, struct fid_ep, fid);
switch (command) {
case FI_ENABLE:
return usdf_ep_dgram_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
default:
return -FI_ENOSYS;
}
}
static struct fi_ops usdf_ep_dgram_ops = {
.size = sizeof(struct fi_ops),
.close = usdf_ep_dgram_close,
.bind = usdf_ep_dgram_bind,
.control = fi_no_control,
.control = usdf_ep_dgram_control,
.ops_open = fi_no_ops_open
};

Просмотреть файл

@ -575,7 +575,6 @@ usdf_ep_msg_close(fid_t fid)
static struct fi_ops_ep usdf_base_msg_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = usdf_ep_msg_enable,
.cancel = usdf_ep_msg_cancel,
.getopt = usdf_ep_msg_getopt,
.setopt = usdf_ep_msg_setopt,
@ -609,11 +608,31 @@ static struct fi_ops_msg usdf_msg_ops = {
.injectdata = fi_no_msg_injectdata,
};
static int usdf_ep_msg_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep;
switch (fid->fclass) {
case FI_CLASS_EP:
ep = container_of(fid, struct fid_ep, fid);
switch (command) {
case FI_ENABLE:
return usdf_ep_msg_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
default:
return -FI_ENOSYS;
}
}
static struct fi_ops usdf_ep_msg_ops = {
.size = sizeof(struct fi_ops),
.close = usdf_ep_msg_close,
.bind = usdf_ep_msg_bind,
.control = fi_no_control,
.control = usdf_ep_msg_control,
.ops_open = fi_no_ops_open
};

Просмотреть файл

@ -632,7 +632,6 @@ usdf_ep_rdm_close(fid_t fid)
static struct fi_ops_ep usdf_base_rdm_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = usdf_ep_rdm_enable,
.cancel = usdf_ep_rdm_cancel,
.getopt = usdf_ep_rdm_getopt,
.setopt = usdf_ep_rdm_setopt,
@ -666,11 +665,31 @@ static struct fi_ops_msg usdf_rdm_ops = {
.injectdata = fi_no_msg_injectdata,
};
static int usdf_ep_rdm_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep;
switch (fid->fclass) {
case FI_CLASS_EP:
ep = container_of(fid, struct fid_ep, fid);
switch (command) {
case FI_ENABLE:
return usdf_ep_rdm_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
default:
return -FI_ENOSYS;
}
}
static struct fi_ops usdf_ep_rdm_ops = {
.size = sizeof(struct fi_ops),
.close = usdf_ep_rdm_close,
.bind = usdf_ep_rdm_bind,
.control = fi_no_control,
.control = usdf_ep_rdm_control,
.ops_open = fi_no_ops_open
};

Просмотреть файл

@ -38,6 +38,7 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <arpa/inet.h>
#include <asm/types.h>
#include <assert.h>
#include <errno.h>
@ -45,6 +46,7 @@
#include <netinet/in.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -556,6 +558,8 @@ usdf_get_devinfo(void)
int ret;
int d;
assert(__usdf_devinfo == NULL);
dp = calloc(1, sizeof(*dp));
if (dp == NULL) {
ret = -FI_ENOMEM;
@ -674,6 +678,8 @@ usdf_getinfo(uint32_t version, const char *node, const char *service,
/* skip this device if it has some problem */
if (!dep->ue_dev_ok) {
USDF_DEBUG("skipping %s/%s\n", dap->uda_devname,
dap->uda_ifname);
continue;
}
@ -685,6 +691,9 @@ usdf_getinfo(uint32_t version, const char *node, const char *service,
goto fail;
}
if (metric == -1) {
USDF_DEBUG("dest %s unreachable from %s/%s, skipping\n",
inet_ntoa(dest->sin_addr),
dap->uda_devname, dap->uda_ifname);
continue;
}
}
@ -693,6 +702,8 @@ usdf_getinfo(uint32_t version, const char *node, const char *service,
if (hints != NULL) {
ret = usdf_validate_hints(hints, dap);
if (ret != 0) {
USDF_DEBUG("hints do not match for %s/%s, skipping\n",
dap->uda_devname, dap->uda_ifname);
continue;
}
@ -740,6 +751,9 @@ fail:
if (ai != NULL) {
freeaddrinfo(ai);
}
if (ret != 0) {
USDF_INFO("returning %d (%s)\n", ret, fi_strerror(-ret));
}
return ret;
}
@ -772,7 +786,8 @@ usdf_fabric_close(fid_t fid)
}
static int
usdf_usnic_getinfo(struct fid_fabric *fabric, struct fi_usnic_info *uip)
usdf_usnic_getinfo(uint32_t version, struct fid_fabric *fabric,
struct fi_usnic_info *uip)
{
struct usdf_fabric *fp;
struct usd_device_attrs *dap;
@ -780,6 +795,10 @@ usdf_usnic_getinfo(struct fid_fabric *fabric, struct fi_usnic_info *uip)
fp = fab_ftou(fabric);
dap = fp->fab_dev_attrs;
if (version > FI_EXT_USNIC_INFO_VERSION) {
return -FI_EINVAL;
}
uip->ui.v1.ui_link_speed = dap->uda_bandwidth;
uip->ui.v1.ui_netmask_be = dap->uda_netmask_be;
strcpy(uip->ui.v1.ui_ifname, dap->uda_ifname);
@ -845,11 +864,14 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
}
}
if (d >= dp->uu_num_devs) {
USDF_INFO("device \"%s\" does not exit, returning -FI_ENODEV\n",
fattrp->name);
return -FI_ENODEV;
}
fp = calloc(1, sizeof(*fp));
if (fp == NULL) {
USDF_INFO("unable to allocate memory for fabric\n");
return -FI_ENOMEM;
}
fp->fab_epollfd = -1;
@ -876,12 +898,14 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
fp->fab_epollfd = epoll_create(1024);
if (fp->fab_epollfd == -1) {
ret = -errno;
USDF_INFO("unable to allocate epoll fd\n");
goto fail;
}
fp->fab_eventfd = eventfd(0, EFD_NONBLOCK | EFD_SEMAPHORE);
if (fp->fab_eventfd == -1) {
ret = -errno;
USDF_INFO("unable to allocate event fd\n");
goto fail;
}
fp->fab_poll_item.pi_rtn = usdf_fabric_progression_cb;
@ -891,6 +915,7 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
ret = epoll_ctl(fp->fab_epollfd, EPOLL_CTL_ADD, fp->fab_eventfd, &ev);
if (ret == -1) {
ret = -errno;
USDF_INFO("unable to EPOLL_CTL_ADD\n");
goto fail;
}
@ -898,12 +923,14 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
usdf_fabric_progression_thread, fp);
if (ret != 0) {
ret = -ret;
USDF_INFO("unable to create progress thread\n");
goto fail;
}
/* initialize timer subsystem */
ret = usdf_timer_init(fp);
if (ret != 0) {
USDF_INFO("unable to initialize timer\n");
goto fail;
}
@ -913,6 +940,7 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
sin.sin_addr.s_addr = fp->fab_dev_attrs->uda_ipaddr_be;
fp->fab_arp_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (fp->fab_arp_sockfd == -1) {
USDF_INFO("unable to create socket\n");
goto fail;
}
ret = bind(fp->fab_arp_sockfd, (struct sockaddr *) &sin, sizeof(sin));
@ -925,6 +953,8 @@ usdf_fabric_open(struct fi_fabric_attr *fattrp, struct fid_fabric **fabric,
fattrp->fabric = fab_utof(fp);
fattrp->prov_version = USDF_PROV_VERSION;
*fabric = fab_utof(fp);
USDF_INFO("successfully opened %s/%s\n", fattrp->name,
fp->fab_dev_attrs->uda_ifname);
return 0;
fail:
@ -941,6 +971,7 @@ fail:
usdf_timer_deinit(fp);
free(fp);
}
USDF_DEBUG("returning %d (%s)\n", ret, fi_strerror(-ret));
return ret;
}

Просмотреть файл

@ -339,6 +339,7 @@ usdf_msg_send_segment(struct usdf_tx *tx, struct usdf_ep *ep)
hdr->msg.m.rc_data.seqno = htons(ep->e.msg.ep_next_tx_seq);
++ep->e.msg.ep_next_tx_seq;
sge_len = resid;
ptr = (uint8_t *)(hdr + 1);
while (resid > 0) {
memcpy(ptr, cur_ptr, cur_resid);
@ -350,7 +351,6 @@ usdf_msg_send_segment(struct usdf_tx *tx, struct usdf_ep *ep)
}
/* add packet lengths */
sge_len = resid;
hdr->hdr.uh_ip.tot_len = htons(
sge_len + sizeof(struct rudp_pkt) -
sizeof(struct ether_header));
@ -360,7 +360,7 @@ usdf_msg_send_segment(struct usdf_tx *tx, struct usdf_ep *ep)
sizeof(struct iphdr)) + sge_len);
index = _usd_post_send_one(wq, hdr,
resid + sizeof(*hdr), 1);
sge_len + sizeof(*hdr), 1);
} else {
struct vnic_wq *vwq;
u_int8_t offload_mode = 0, eop;

Просмотреть файл

@ -420,7 +420,6 @@ struct fi_ops usdf_pep_ops = {
static struct fi_ops_ep usdf_pep_base_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = fi_no_enable,
.cancel = usdf_pep_cancel,
.getopt = fi_no_getopt,
.setopt = fi_no_setopt,

Просмотреть файл

@ -121,10 +121,11 @@ usd_alloc_mr(
void *base_addr;
struct usd_mr *mr;
size_t true_size;
size_t metadata_size;
int ret;
true_size = size + sizeof(struct usd_mr) + 2 * sizeof(uintptr_t) +
sysconf(_SC_PAGESIZE) - 1;
metadata_size = sizeof(struct usd_mr) + 2 * sizeof(uintptr_t);
true_size = size + metadata_size + sysconf(_SC_PAGESIZE) - 1;
base_addr = mmap(NULL, true_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (base_addr == NULL || base_addr == MAP_FAILED) {
@ -133,7 +134,7 @@ usd_alloc_mr(
}
mr = base_addr;
vaddr =
(void *) ALIGN((uintptr_t) base_addr + sizeof(*mr) + sizeof(mr),
(void *) ALIGN((uintptr_t) base_addr + metadata_size,
sysconf(_SC_PAGESIZE));
((uintptr_t *) vaddr)[-1] = (uintptr_t) mr;
((uintptr_t *) vaddr)[-2] = true_size;

Просмотреть файл

@ -801,6 +801,7 @@ usd_finish_create_cq(
cq_intr_enable, cq_entry_enable, cq_msg_enable,
cq_intr_offset, cq_msg_addr);
}
cq->ucq_state |= USD_QS_VNIC_INITIALIZED;
return 0;
}
@ -962,6 +963,8 @@ usd_destroy_qp(
usd_free_mr(wq->uwq_copybuf);
if (wq->uwq_desc_ring != NULL)
usd_free_mr(wq->uwq_desc_ring);
if (rq->urq_desc_ring != NULL)
usd_free_mr(rq->urq_desc_ring);
free(qp);

Просмотреть файл

@ -9,14 +9,30 @@ dnl $2: action if not configured successfully
dnl
AC_DEFUN([FI_VERBS_CONFIGURE],[
# Determine if we can support the verbs provider
verbs_happy=0
verbs_ibverbs_happy=0
verbs_rdmacm_happy=0
AS_IF([test x"$enable_verbs" != x"no"],
[verbs_happy=1
AC_CHECK_HEADER([infiniband/verbs.h], [], [verbs_happy=0])
AC_CHECK_HEADER([rdma/rsocket.h], [], [verbs_happy=0])
AC_CHECK_LIB([ibverbs], [ibv_open_device], [], [verbs_happy=0])
AC_CHECK_LIB([rdmacm], [rsocket], [], [verbs_happy=0])
[FI_CHECK_PACKAGE([verbs_ibverbs],
[infiniband/verbs.h],
[ibverbs],
[ibv_open_device],
[],
[],
[],
[verbs_ibverbs_happy=1],
[verbs_ibverbs_happy=0])
FI_CHECK_PACKAGE([verbs_rdmacm],
[rdma/rsocket.h],
[rdmacm],
[rsocket],
[],
[],
[],
[verbs_rdmacm_happy=1],
[verbs_rdmacm_happy=0])
])
AS_IF([test $verbs_happy -eq 1], [$1], [$2])
AS_IF([test $verbs_ibverbs_happy -eq 1 && \
test $verbs_rdmacm_happy -eq 1], [$1], [$2])
])

Просмотреть файл

@ -57,13 +57,14 @@
#include "fi.h"
#include "fi_enosys.h"
#include "fi_log.h"
#include "prov.h"
#include "fi_log.h"
#define VERBS_PROV_NAME "verbs"
#define VERBS_PROV_VERS FI_VERSION(1,0)
#define VERBS_WARN(fmt, ...) \
do { fprintf(stderr, "%s:%s: " fmt, PACKAGE, VERBS_PROV_NAME, ##__VA_ARGS__); } while (0)
#define VERBS_WARN(...) FI_WARN(VERBS_PROV_NAME, __VA_ARGS__)
#define VERBS_MSG_SIZE (1ULL << 31)
#define VERBS_IB_PREFIX "IB-0x"
@ -592,8 +593,10 @@ fi_ibv_getepinfo(const char *node, const char *service,
if (ret)
return ret;
if (!node && !rai_hints.ai_src_addr && !rai_hints.ai_dst_addr) {
node = local_node;
if (!node && !rai_hints.ai_dst_addr) {
if (!rai_hints.ai_src_addr) {
node = local_node;
}
rai_hints.ai_flags |= RAI_PASSIVE;
}
@ -614,6 +617,12 @@ fi_ibv_getepinfo(const char *node, const char *service,
ret = rdma_create_ep(id, rai, NULL, NULL);
if (ret) {
ret = -errno;
if (ret == -ENOENT) {
FI_LOG(1, "verbs",
"rdma_create_ep()-->ENOENT; likely usnic bug, "
"skipping verbs provider.\n");
ret = -FI_ENODATA;
}
goto err2;
}
@ -1611,6 +1620,44 @@ static struct fi_ops_atomic fi_ibv_msg_ep_atomic_ops = {
.compwritevalid = fi_ibv_msg_ep_atomic_compwritevalid
};
static int fi_ibv_copy_addr(void *dst_addr, size_t *dst_addrlen, void *src_addr)
{
size_t src_addrlen = fi_ibv_sockaddr_len(src_addr);
if (*dst_addrlen == 0) {
*dst_addrlen = src_addrlen;
return -FI_ETOOSMALL;
}
if (*dst_addrlen < src_addrlen) {
memcpy(dst_addr, src_addr, *dst_addrlen);
} else {
memcpy(dst_addr, src_addr, src_addrlen);
}
*dst_addrlen = src_addrlen;
return 0;
}
static int fi_ibv_msg_ep_getname(fid_t ep, void *addr, size_t *addrlen)
{
struct fi_ibv_msg_ep *_ep;
struct sockaddr *sa;
_ep = container_of(ep, struct fi_ibv_msg_ep, ep_fid);
sa = rdma_get_local_addr(_ep->id);
return fi_ibv_copy_addr(addr, addrlen, sa);
}
static int fi_ibv_msg_ep_getpeer(struct fid_ep *ep, void *addr, size_t *addrlen)
{
struct fi_ibv_msg_ep *_ep;
struct sockaddr *sa;
_ep = container_of(ep, struct fi_ibv_msg_ep, ep_fid);
sa = rdma_get_peer_addr(_ep->id);
return fi_ibv_copy_addr(addr, addrlen, sa);
}
static int
fi_ibv_msg_ep_connect(struct fid_ep *ep, const void *addr,
const void *param, size_t paramlen)
@ -1621,7 +1668,7 @@ fi_ibv_msg_ep_connect(struct fid_ep *ep, const void *addr,
_ep = container_of(ep, struct fi_ibv_msg_ep, ep_fid);
if (!_ep->id->qp) {
ret = ep->ops->enable(ep);
ret = ep->fid.ops->control(&ep->fid, FI_ENABLE, NULL);
if (ret)
return ret;
}
@ -1647,7 +1694,7 @@ fi_ibv_msg_ep_accept(struct fid_ep *ep, const void *param, size_t paramlen)
_ep = container_of(ep, struct fi_ibv_msg_ep, ep_fid);
if (!_ep->id->qp) {
ret = ep->ops->enable(ep);
ret = ep->fid.ops->control(&ep->fid, FI_ENABLE, NULL);
if (ret)
return ret;
}
@ -1679,8 +1726,8 @@ static int fi_ibv_msg_ep_shutdown(struct fid_ep *ep, uint64_t flags)
static struct fi_ops_cm fi_ibv_msg_ep_cm_ops = {
.size = sizeof(struct fi_ops_cm),
.getname = fi_no_getname,
.getpeer = fi_no_getpeer,
.getname = fi_ibv_msg_ep_getname,
.getpeer = fi_ibv_msg_ep_getpeer,
.connect = fi_ibv_msg_ep_connect,
.listen = fi_no_listen,
.accept = fi_ibv_msg_ep_accept,
@ -1729,7 +1776,6 @@ static int fi_ibv_msg_ep_enable(struct fid_ep *ep)
static struct fi_ops_ep fi_ibv_msg_ep_base_ops = {
.size = sizeof(struct fi_ops_ep),
.enable = fi_ibv_msg_ep_enable,
.cancel = fi_no_cancel,
.getopt = fi_ibv_msg_ep_getopt,
.setopt = fi_ibv_msg_ep_setopt,
@ -1749,11 +1795,31 @@ static int fi_ibv_msg_ep_close(fid_t fid)
return 0;
}
static int fi_ibv_msg_ep_control(struct fid *fid, int command, void *arg)
{
struct fid_ep *ep;
switch (fid->fclass) {
case FI_CLASS_EP:
ep = container_of(fid, struct fid_ep, fid);
switch (command) {
case FI_ENABLE:
return fi_ibv_msg_ep_enable(ep);
break;
default:
return -FI_ENOSYS;
}
break;
default:
return -FI_ENOSYS;
}
}
static struct fi_ops fi_ibv_msg_ep_ops = {
.size = sizeof(struct fi_ops),
.close = fi_ibv_msg_ep_close,
.bind = fi_ibv_msg_ep_bind,
.control = fi_no_control,
.control = fi_ibv_msg_ep_control,
.ops_open = fi_no_ops_open,
};
@ -2569,6 +2635,16 @@ err:
return ret;
}
static int fi_ibv_pep_getname(fid_t pep, void *addr, size_t *addrlen)
{
struct fi_ibv_pep *_pep;
struct sockaddr *sa;
_pep = container_of(pep, struct fi_ibv_pep, pep_fid);
sa = rdma_get_local_addr(_pep->id);
return fi_ibv_copy_addr(addr, addrlen, sa);
}
static int fi_ibv_pep_listen(struct fid_pep *pep)
{
struct fi_ibv_pep *_pep;
@ -2579,7 +2655,7 @@ static int fi_ibv_pep_listen(struct fid_pep *pep)
static struct fi_ops_cm fi_ibv_pep_cm_ops = {
.size = sizeof(struct fi_ops_cm),
.getname = fi_no_getname,
.getname = fi_ibv_pep_getname,
.getpeer = fi_no_getpeer,
.connect = fi_no_connect,
.listen = fi_ibv_pep_listen,
@ -2715,5 +2791,6 @@ static struct fi_provider fi_ibv_prov = {
VERBS_INI
{
fi_log_init();
return &fi_ibv_prov;
}

Просмотреть файл

@ -2,6 +2,7 @@
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Intel Corp., 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
* licenses. You may choose to be licensed under the terms of the GNU

Просмотреть файл

@ -1,6 +1,6 @@
/*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Intel Corp., Inc. All rights reserved.
*
* This software is available to you under a choice of one of two
@ -244,7 +244,7 @@ static struct fi_prov *fi_getprov(const char *prov_name)
}
__attribute__((visibility ("default")))
void fi_freeinfo_(struct fi_info *info)
void DEFAULT_SYMVER_PRE(fi_freeinfo)(struct fi_info *info)
{
struct fi_info *next;
@ -268,10 +268,10 @@ void fi_freeinfo_(struct fi_info *info)
free(info);
}
}
default_symver(fi_freeinfo_, fi_freeinfo);
DEFAULT_SYMVER(fi_freeinfo_, fi_freeinfo);
__attribute__((visibility ("default")))
int fi_getinfo_(uint32_t version, const char *node, const char *service,
int DEFAULT_SYMVER_PRE(fi_getinfo)(uint32_t version, const char *node, const char *service,
uint64_t flags, struct fi_info *hints, struct fi_info **info)
{
struct fi_prov *prov;
@ -299,7 +299,7 @@ int fi_getinfo_(uint32_t version, const char *node, const char *service,
continue;
} else {
/* a provider has an error, clean up and bail */
fi_freeinfo_(*info);
fi_freeinfo(*info);
*info = NULL;
return ret;
}
@ -319,10 +319,10 @@ int fi_getinfo_(uint32_t version, const char *node, const char *service,
return *info ? 0 : ret;
}
default_symver(fi_getinfo_, fi_getinfo);
DEFAULT_SYMVER(fi_getinfo_, fi_getinfo);
__attribute__((visibility ("default")))
struct fi_info *fi_dupinfo_(const struct fi_info *info)
struct fi_info *DEFAULT_SYMVER_PRE(fi_dupinfo)(const struct fi_info *info)
{
struct fi_info *dup;
@ -416,10 +416,10 @@ fail:
fi_freeinfo(dup);
return NULL;
}
default_symver(fi_dupinfo_, fi_dupinfo);
DEFAULT_SYMVER(fi_dupinfo_, fi_dupinfo);
__attribute__((visibility ("default")))
int fi_fabric_(struct fi_fabric_attr *attr, struct fid_fabric **fabric, void *context)
int DEFAULT_SYMVER_PRE(fi_fabric)(struct fi_fabric_attr *attr, struct fid_fabric **fabric, void *context)
{
struct fi_prov *prov;
@ -435,14 +435,14 @@ int fi_fabric_(struct fi_fabric_attr *attr, struct fid_fabric **fabric, void *co
return prov->provider->fabric(attr, fabric, context);
}
default_symver(fi_fabric_, fi_fabric);
DEFAULT_SYMVER(fi_fabric_, fi_fabric);
__attribute__((visibility ("default")))
uint32_t fi_version_(void)
uint32_t DEFAULT_SYMVER_PRE(fi_version)(void)
{
return FI_VERSION(FI_MAJOR_VERSION, FI_MINOR_VERSION);
}
default_symver(fi_version_, fi_version);
DEFAULT_SYMVER(fi_version_, fi_version);
#define FI_ERRNO_OFFSET 256
#define FI_ERRNO_MAX FI_ENOCQ
@ -456,10 +456,13 @@ static const char *const errstr[] = {
[FI_ENOEQ - FI_ERRNO_OFFSET] = "Missing or unavailable event queue",
[FI_EDOMAIN - FI_ERRNO_OFFSET] = "Invalid resource domain",
[FI_ENOCQ - FI_ERRNO_OFFSET] = "Missing or unavailable completion queue",
[FI_ECRC - FI_ERRNO_OFFSET] = "CRC error",
[FI_ETRUNC - FI_ERRNO_OFFSET] = "Truncation error",
[FI_ENOKEY - FI_ERRNO_OFFSET] = "Required key not available",
};
__attribute__((visibility ("default")))
const char *fi_strerror_(int errnum)
const char *DEFAULT_SYMVER_PRE(fi_strerror)(int errnum)
{
if (errnum < FI_ERRNO_OFFSET)
return strerror(errnum);
@ -468,6 +471,6 @@ const char *fi_strerror_(int errnum)
else
return errstr[FI_EOTHER - FI_ERRNO_OFFSET];
}
default_symver(fi_strerror_, fi_strerror);
DEFAULT_SYMVER(fi_strerror_, fi_strerror);

Просмотреть файл

@ -493,7 +493,7 @@ static void fi_tostr_version(char *buf)
}
__attribute__((visibility ("default")))
char *fi_tostr_(const void *data, enum fi_type datatype)
char *DEFAULT_SYMVER_PRE(fi_tostr)(const void *data, enum fi_type datatype)
{
static char *buf = NULL;
uint64_t val64 = *(const uint64_t *) data;
@ -574,7 +574,7 @@ char *fi_tostr_(const void *data, enum fi_type datatype)
}
return buf;
}
default_symver(fi_tostr_, fi_tostr);
DEFAULT_SYMVER(fi_tostr_, fi_tostr);
#undef CASEENUMSTR
#undef IFFLAGSTR

Просмотреть файл

@ -36,7 +36,6 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fi.h"
#include "fi_log.h"
@ -78,27 +77,29 @@ void fi_warn_impl(const char *prov, const char *fmt, ...)
va_end(vargs);
}
void fi_log_impl(int level, const char *prov, const char *fmt, ...)
void fi_log_impl(int level, const char *prov, const char *func, int line,
const char *fmt, ...)
{
va_list vargs;
if (prov != NULL)
fprintf(stderr, "%s:%s:<%d> ", PACKAGE, prov, level);
fprintf(stderr, "%s:%s:%s():%d<%d> ", PACKAGE, prov,
func, line, level);
else
fprintf(stderr, "%s:<%d> ", PACKAGE, level);
fprintf(stderr, "%s:%s():%d<%d> ", PACKAGE, func, line, level);
va_start(vargs, fmt);
vfprintf(stderr, fmt, vargs);
va_end(vargs);
}
void fi_debug_impl(const char *prov, const char *fmt, ...)
void fi_debug_impl(const char *prov, const char *func, int line, const char *fmt, ...)
{
va_list vargs;
if (prov != NULL)
fprintf(stderr, "%s:%s:<DBG> ", PACKAGE, prov);
fprintf(stderr, "%s:%s:%s():%d<DBG> ", PACKAGE, prov, func, line);
else
fprintf(stderr, "%s:<DBG> ", PACKAGE);
fprintf(stderr, "%s:%s():%d<DBG> ", PACKAGE, func, line);
va_start(vargs, fmt);
vfprintf(stderr, fmt, vargs);
va_end(vargs);

Просмотреть файл

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 Intel Corporation, 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
* licenses. You may choose to be licensed under the terms of the GNU
@ -30,29 +30,20 @@
* SOFTWARE.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include "osx/osd.h"
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <poll.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
int clock_gettime(clockid_t clk_id, struct timespec *tp) {
int retval;
#include "sock.h"
#include "sock_util.h"
clock_serv_t cclock;
mach_timespec_t mts;
int sock_log_level = SOCK_ERROR;
useconds_t sock_progress_thread_wait = 0;
host_get_clock_service(mach_host_self(), clk_id, &cclock);
retval = clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
tp->tv_sec = mts.tv_sec;
tp->tv_nsec = mts.tv_nsec;
return retval;
}