1/*
2 * Copyright (c) 2017      Mellanox Technologies, Inc.
3 *                         All rights reserved.
4 * $COPYRIGHT$
5 *
6 * Additional copyrights may follow
7 *
8 * $HEADER$
9 */
10
11# MCA_oshmem_sshmem_ucx_CONFIG([action-if-can-compile],
12#                    [action-if-cant-compile])
13# ------------------------------------------------
14AC_DEFUN([MCA_oshmem_sshmem_ucx_CONFIG],[
15    AC_CONFIG_FILES([oshmem/mca/sshmem/ucx/Makefile])
16
17    OMPI_CHECK_UCX([sshmem_ucx],
18                   [sshmem_ucx_happy="yes"],
19                   [sshmem_ucx_happy="no"])
20
21    AS_IF([test "$sshmem_ucx_happy" = "yes"],
22          [$1],
23          [$2])
24
25    # Check for UCX device memory allocation support
26    save_LDFLAGS="$LDFLAGS"
27    save_LIBS="$LIBS"
28    save_CPPFLAGS="$CPPFLAGS"
29
30    alloc_dm_LDFLAGS=" -L$ompi_check_ucx_libdir/ucx"
31    alloc_dm_LIBS=" -luct_ib"
32    CPPFLAGS+=" $sshmem_ucx_CPPFLAGS"
33    LDFLAGS+=" $sshmem_ucx_LDFLAGS $alloc_dm_LDFLAGS"
34    LIBS+=" $sshmem_ucx_LIBS $alloc_dm_LIBS"
35
36    AC_LANG_PUSH([C])
37    AC_LINK_IFELSE([AC_LANG_PROGRAM(
38          [[
39            #include <ucp/core/ucp_resource.h>
40            #include <uct/ib/base/ib_alloc.h>
41          ]],
42          [[
43            uct_md_h md = ucp_context_find_tl_md((ucp_context_h)NULL, "");
44            (void)uct_ib_md_alloc_device_mem(md, NULL, NULL, 0, "", NULL);
45            uct_ib_md_release_device_mem(NULL);
46          ]])],
47          [
48           AC_MSG_NOTICE([UCX device memory allocation is supported])
49           AC_DEFINE([HAVE_UCX_DEVICE_MEM], [1], [Support for device memory allocation])
50           sshmem_ucx_LIBS+=" $alloc_dm_LIBS"
51           sshmem_ucx_LDFLAGS+=" $alloc_dm_LDFLAGS"
52          ],
53          [AC_MSG_NOTICE([UCX device memory allocation is not supported])])
54    AC_LANG_POP([C])
55
56    CPPFLAGS="$save_CPPFLAGS"
57    LDFLAGS="$save_LDFLAGS"
58    LIBS="$save_LIBS"
59
60    # substitute in the things needed to build ucx
61    AC_SUBST([sshmem_ucx_CFLAGS])
62    AC_SUBST([sshmem_ucx_CPPFLAGS])
63    AC_SUBST([sshmem_ucx_LDFLAGS])
64    AC_SUBST([sshmem_ucx_LIBS])
65])dnl
66
67