Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

ACLOCAL_AMFLAGS = -I config/m4

SUBDIRS = src/ucs src/uct src/tools/info test/perf
SUBDIRS = src/ucs src/uct src/ucp src/tools/info test/perf

if HAVE_GTEST
SUBDIRS += test/gtest
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ AC_CONFIG_FILES([
src/ucs/Makefile
src/uct/Makefile
src/uct/api/version.h
src/ucp/Makefile
src/tools/info/Makefile
test/gtest/Makefile
test/perf/Makefile
Expand Down
23 changes: 23 additions & 0 deletions src/ucp/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
# $COPYRIGHT$
# $HEADER$
#

lib_LTLIBRARIES = libucp.la

libucp_la_CFLAGS =
libucp_la_LIBS =
libucp_la_CPPFLAGS = -I$(abs_top_srcdir)/src -I$(abs_top_builddir)/src
libucp_la_LDFLAGS = -ldl -version-info $(SOVERSION)
libucp_la_LIBADD = ../ucs/libucs.la
libucp_ladir = $(includedir)

nobase_dist_libucp_la_HEADERS = \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be just nodist_HEADERS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't include (doesn't find) the ucp.h in ucp.c if i change this.

api/ucp_def.h \
api/ucp.h

noinst_HEADERS =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noinst_HEADERS can replace nobase_dist_libucp_la_HEADERS


libucp_la_SOURCES = \
ucp.c
98 changes: 98 additions & 0 deletions src/ucp/api/ucp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* $COPYRIGHT$
* $HEADER$
*/

#ifndef UCP_H_
#define UCP_H_

#include "ucp_def.h"
#include <uct/api/uct.h>
#include <ucs/type/status.h>
#include <ucs/debug/memtrack.h>
#include <ucs/debug/log.h>


typedef struct ucp_context {
uct_context_h uct_context;
uct_resource_desc_t *resources; /* TODO should be list/array of resources? */
} ucp_context_t;

/**
* Remote protocol layer endpoint
*/
typedef struct ucp_ep {
ucp_iface_h ucp_iface;
uct_ep_h uct_ep; /* TODO remote eps - one per transport */
} ucp_ep_t;

/**
* Local protocol layer interface
*/
typedef struct ucp_iface {
ucp_context_h context;
uct_iface_h uct_iface;
} ucp_iface_t;

/**
* @ingroup CONTEXT
* @brief Initialize global ucp context.
*
* @param [out] context_p Filled with a ucp context handle.
*
* @return Error code.
*/
ucs_status_t ucp_init(ucp_context_h *context_p);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add doxygen-style comments


/**
* @ingroup CONTEXT
* @brief Destroy global ucp context.
*
* @param [in] context_p Handle to the ucp context.
*/
void ucp_cleanup(ucp_context_h context_p);

/**
* @ingroup CONTEXT
* @brief Create and open a communication interface.
*
* @param [in] ucp_context Handle to the ucp context.
* @param [in] env_prefix If non-NULL, search for environment variables
* starting with this UCP_<prefix>_. Otherwise, search
* for environment variables starting with just UCP_.
* @param [out] ucp_iface Filled with a handle to the opened communication interface.
*
* @return Error code.
*/
ucs_status_t ucp_iface_create(ucp_context_h ucp_context, const char *env_prefix, ucp_iface_h *ucp_iface);

/**
* @ingroup CONTEXT
* @brief Close the communication interface.
*
* @param [in] ucp_iface Handle to the communication interface.
*/
void ucp_iface_close(ucp_iface_h ucp_iface);

/**
* @ingroup CONTEXT
* @brief Create and open a remote endpoint.
*
* @param [in] ucp_iface Handle to the communication interface.
* @param [out] ucp_ep Filled with a handle to the opened remote endpoint.
*
* @return Error code.
*/
ucs_status_t ucp_ep_create(ucp_iface_h ucp_iface, ucp_ep_h *ucp_ep);

/**
* @ingroup CONTEXT
* @brief Close the remote endpoint.
*
* @param [in] ucp_ep Handle to the remote endpoint.
*/
void ucp_ep_destroy(ucp_ep_h ucp_ep);


#endif /* UCP_H_ */
14 changes: 14 additions & 0 deletions src/ucp/api/ucp_def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* $COPYRIGHT$
* $HEADER$
*/

#ifndef UCP_DEF_H_
#define UCP_DEF_H_

typedef struct ucp_context *ucp_context_h;
typedef struct ucp_ep *ucp_ep_h;
typedef struct ucp_iface *ucp_iface_h;

#endif /* UCP_DEF_H_ */
137 changes: 137 additions & 0 deletions src/ucp/ucp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* $COPYRIGHT$
* $HEADER$
*/

#include <ucp/api/ucp.h>
#include <ucs/type/component.h>

ucs_status_t ucp_init(ucp_context_h *context_p)
{
ucs_status_t status;
ucp_context_t *context;
uct_resource_desc_t *resources;
unsigned num_resources;

/* allocate a ucp context */
context = ucs_malloc(sizeof(*context),"ucp context");
if (context == NULL) {
status = UCS_ERR_NO_MEMORY;
goto err;
}

/* initialize uct */
status = uct_init(&context->uct_context);
if (status != UCS_OK) {
ucs_error("Failed to initialize UCT: %s", ucs_status_string(status));
goto err_free_ctx;
}

status = uct_query_resources(context->uct_context, &resources, &num_resources);
if (status != UCS_OK) {
ucs_error("Failed to query resources: %s",ucs_status_string(status));
goto err_free_uct;
}

context->resources = resources;
*context_p = context;

return UCS_OK;

err_free_uct:
uct_cleanup(context->uct_context);
err_free_ctx:
ucs_free(context);
err:
return status;
}

void ucp_cleanup(ucp_context_h context)
{
uct_release_resource_list(context->resources);
uct_cleanup(context->uct_context);
ucs_free(context);
}

ucs_status_t ucp_iface_create(ucp_context_h ucp_context, const char *env_prefix,
ucp_iface_h *ucp_iface_p)
{
ucp_iface_t *ucp_iface;
uct_iface_config_t *iface_config;
ucs_status_t status;

ucp_iface = ucs_malloc(sizeof(*ucp_iface), "ucp iface");
if (ucp_iface == NULL) {
status = UCS_ERR_NO_MEMORY;
goto err;
}

status = uct_iface_config_read(ucp_context->uct_context,
ucp_context->resources->tl_name, env_prefix, NULL,
&iface_config);
if (status != UCS_OK) {
ucs_error("Failed to read UCT config: %s", ucs_status_string(status));
goto err_free_iface;
}

/* TODO open all resources. for now we open just the 1st */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This big fat todo. You have to make sure that you have proper infrastructure in place to support multiple uct_iface's

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can discuss the design on next call. this is just a reminder we have to do it

status = uct_iface_open(ucp_context->uct_context,
ucp_context->resources->tl_name,
ucp_context->resources->dev_name, 0, iface_config,
&ucp_iface->uct_iface);
if (status != UCS_OK) {
goto err_release_cfg;
}

uct_iface_config_release(iface_config);

ucp_iface->context = ucp_context;
*ucp_iface_p = ucp_iface;

return UCS_OK;

err_release_cfg:
uct_iface_config_release(iface_config);
err_free_iface:
ucs_free(ucp_iface);
err:
return status;
}

void ucp_iface_close(ucp_iface_h ucp_iface)
{
uct_iface_close(ucp_iface->uct_iface);
ucs_free(ucp_iface);
}

ucs_status_t ucp_ep_create(ucp_iface_h ucp_iface, ucp_ep_h *ucp_ep_p)
{
ucp_ep_t *ucp_ep;
ucs_status_t status;

ucp_ep = ucs_malloc(sizeof(*ucp_ep), "ucp ep");
if (ucp_ep == NULL) {
status = UCS_ERR_NO_MEMORY;
goto err;
}

status = uct_ep_create(ucp_iface->uct_iface, &ucp_ep->uct_ep);
if (UCS_OK != status) {
goto err_free_ep;
}

*ucp_ep_p = ucp_ep;
return UCS_OK;

err_free_ep:
ucs_free(ucp_ep);
err:
return status;
}

void ucp_ep_destroy(ucp_ep_h ucp_ep)
{
uct_ep_destroy(ucp_ep->uct_ep);
ucs_free(ucp_ep);
}
6 changes: 5 additions & 1 deletion test/gtest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ gtestdir = $(includedir)
gtest_LDADD = \
$(top_builddir)/src/ucs/libucs.la \
$(top_builddir)/src/uct/libuct.la \
$(top_builddir)/src/ucp/libucp.la \
$(top_builddir)/src/ucs/libucstest.la \
$(top_builddir)/test/perf/libucxperf.la \
$(GTEST_LIBS) \
Expand All @@ -47,6 +48,8 @@ gtest_SOURCES = \
uct/test_uct_perf.cc \
uct/uct_p2p_test.cc \
uct/uct_test.cc \
ucp/ucp_test.cc \
ucp/test_ucp_ep.cc \
ucs/test_class.cc \
ucs/test_component.cc \
ucs/test_config.cc \
Expand All @@ -64,7 +67,8 @@ gtest_SOURCES = \

noinst_HEADERS = \
uct/uct_p2p_test.h \
uct/uct_test.h
uct/uct_test.h \
ucp/ucp_test.h

.PHONY: test test gdb valgrind fix_rpath ucx

Expand Down
40 changes: 40 additions & 0 deletions test/gtest/ucp/test_ucp_ep.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* $COPYRIGHT$
* $HEADER$
*/

#include <ucs/gtest/test.h>
extern "C" {
#include <ucp/api/ucp.h>
}

class test_ucp : public ucs::test {
};

UCS_TEST_F(test_ucp, open_ep) {
ucs_status_t status;
ucp_context_h ucph;
ucp_iface_h iface;
ucp_ep_h ep;

ucph = NULL;
iface = NULL;
ep = NULL;

/* initialize ucp context, interface and ep */
status = ucp_init(&ucph);
ASSERT_UCS_OK(status);
ASSERT_TRUE(ucph != NULL);

status = ucp_iface_create(ucph, NULL, &iface);
ASSERT_UCS_OK(status);

status = ucp_ep_create(iface, &ep);
ASSERT_UCS_OK(status);

/* release everything */
ucp_ep_destroy(ep);
ucp_iface_close(iface);
ucp_cleanup (ucph);
}
Loading