Repository navigation
UCP/GTEST: initialization of the ucp layer. and a test in gtest for testing it. #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 = \ | ||
| api/ucp_def.h \ | ||
| api/ucp.h | ||
|
|
||
| noinst_HEADERS = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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_ */ | ||
| 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_ */ |
| 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 */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
| 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); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.