Skip to content

Commit

Permalink
UCP/INFO: Print UCP context, worker, and endpoint info.
Browse files Browse the repository at this point in the history
  • Loading branch information
yosefe committed Sep 15, 2016
1 parent 260db49 commit 109a2bf
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 132 deletions.
2 changes: 1 addition & 1 deletion contrib/test_jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ if [ -n "$JENKINS_RUN_TESTS" ]; then
make $make_opt all

echo "Running ucx_info"
$AFFINITY $TIMEOUT ./src/tools/info/ucx_info -f -c -v -y -d -b -p
$AFFINITY $TIMEOUT ./src/tools/info/ucx_info -f -c -v -y -d -b -p -w -e -uart

export GTEST_RANDOM_SEED=0
export GTEST_SHUFFLE=1
Expand Down
44 changes: 37 additions & 7 deletions src/tools/info/proto_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,70 @@
#include <string.h>


void print_proto_info(ucs_config_print_flags_t print_flags)
void print_ucp_info(int print_opts, ucs_config_print_flags_t print_flags,
uint64_t features)
{
ucp_config_t *config;
ucs_status_t status;
ucp_context_h context;
ucp_worker_h worker;
ucp_params_t params;
ucp_address_t *address;
size_t address_length;
ucp_ep_h ep;

status = ucp_config_read(NULL, NULL, &config);
if (status != UCS_OK) {
return;
}

memset(&params, 0, sizeof(params));
params.features = UCP_FEATURE_TAG |
UCP_FEATURE_RMA |
UCP_FEATURE_AMO32 |
UCP_FEATURE_AMO64;
params.features = features;
status = ucp_init(&params, config, &context);
if (status != UCS_OK) {
printf("<Failed to create UCP context>\n");
goto out_release_config;
}

if (print_opts & PRINT_UCP_CONTEXT) {
ucp_context_print_info(context, stdout);
}

if (!(print_opts & (PRINT_UCP_WORKER|PRINT_UCP_EP))) {
goto out_cleanup_context;
}

status = ucp_worker_create(context, UCS_THREAD_MODE_MULTI, &worker);
if (status != UCS_OK) {
printf("<Failed to create UCP worker>\n");
goto out_cleanup_context;
}

ucp_worker_proto_print(worker, stdout, "UCP protocols", print_flags);
if (print_opts & PRINT_UCP_WORKER) {
ucp_worker_print_info(worker, stdout);
}

if (print_opts & PRINT_UCP_EP) {
status = ucp_worker_get_address(worker, &address, &address_length);
if (status != UCS_OK) {
printf("<Failed to get UCP worker address>\n");
goto out_destroy_worker;
}

ucp_worker_destroy(worker);
status = ucp_ep_create(worker, address, &ep);
ucp_worker_release_address(worker, address);
if (status != UCS_OK) {
printf("<Failed to get create UCP endpoint>\n");
goto out_destroy_worker;
}

ucp_ep_print_info(ep, stdout);

ucp_ep_destroy(ep);
}

out_destroy_worker:
ucp_worker_destroy(worker);
out_cleanup_context:
ucp_cleanup(context);
out_release_config:
Expand Down
14 changes: 7 additions & 7 deletions src/tools/info/tl_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ static void print_iface_info(uct_worker_h worker, uct_md_h md,
if (status != UCS_OK) {
printf("# < failed to query interface >\n");
} else {
printf("# bandwidth: %.2f MB/sec\n", iface_attr.bandwidth / (1024 * 1024));
printf("# latency: %.0f nsec\n", iface_attr.latency * 1e9);
printf("# overhead: %.0f nsec\n", iface_attr.overhead * 1e9);
printf("# bandwidth: %-.2f MB/sec\n", iface_attr.bandwidth / (1024 * 1024));
printf("# latency: %-.0f nsec\n", iface_attr.latency * 1e9);
printf("# overhead: %-.0f nsec\n", iface_attr.overhead * 1e9);

PRINT_CAP(PUT_SHORT, iface_attr.cap.flags, iface_attr.cap.put.max_short);
PRINT_CAP(PUT_BCOPY, iface_attr.cap.flags, iface_attr.cap.put.max_bcopy);
Expand Down Expand Up @@ -282,21 +282,21 @@ static void print_md_info(const char *md_name, int print_opts,
} else {
printf("#\n");
printf("# Memory domain: %s\n", md_name);
printf("# component: %s\n", md_attr.component_name);
printf("# component: %s\n", md_attr.component_name);
if (md_attr.cap.flags & UCT_MD_FLAG_ALLOC) {
printf("# allocate: %s\n",
printf("# allocate: %s\n",
size_limit_to_str(md_attr.cap.max_alloc));
}
if (md_attr.cap.flags & UCT_MD_FLAG_REG) {
printf("# register: %s, cost: %.0f",
printf("# register: %s, cost: %.0f",
size_limit_to_str(md_attr.cap.max_reg),
md_attr.reg_cost.overhead * 1e9);
if (md_attr.reg_cost.growth * 1e9 > 1e-3) {
printf("+(%.3f*<SIZE>)", md_attr.reg_cost.growth * 1e9);
}
printf(" nsec\n");
}
printf("# remote key: %zu bytes\n", md_attr.rkey_packed_size);
printf("# remote key: %zu bytes\n", md_attr.rkey_packed_size);
}

if (num_resources == 0) {
Expand Down
62 changes: 52 additions & 10 deletions src/tools/info/ucx_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ static void usage() {
printf(" -s System\n");
printf(" -d Devices\n");
printf(" -c Configuration\n");
printf(" -p Protocols\n");
printf(" -p UCP context\n");
printf(" -w UCP worker\n");
printf(" -e UCP endpoint\n");
printf(" -u UCP features to use. String of one or more of:\n");
printf(" 'a' : atomic operations\n");
printf(" 'r' : remote memory access\n");
printf(" 't' : tag matching \n");
printf(" 'w' : wakeup\n");
printf(" -a Show also hidden configuration\n");
printf(" -b Build configuration\n");
printf(" -y Type information\n");
Expand All @@ -31,14 +38,17 @@ static void usage() {
int main(int argc, char **argv)
{
ucs_config_print_flags_t print_flags;
uint64_t ucp_features;
unsigned print_opts;
char *tl_name;
const char *f;
int c;

print_opts = 0;
print_flags = 0;
tl_name = NULL;
while ((c = getopt(argc, argv, "fahvcydbspt:")) != -1) {
print_opts = 0;
print_flags = 0;
tl_name = NULL;
ucp_features = 0;
while ((c = getopt(argc, argv, "fahvcydbswpet:u:")) != -1) {
switch (c) {
case 'f':
print_flags |= UCS_CONFIG_PRINT_CONFIG | UCS_CONFIG_PRINT_HEADER | UCS_CONFIG_PRINT_DOC;
Expand All @@ -65,11 +75,38 @@ int main(int argc, char **argv)
print_opts |= PRINT_SYS_INFO;
break;
case 'p':
print_opts |= PRINT_PROTOCOLS;
print_opts |= PRINT_UCP_CONTEXT;
break;
case 'w':
print_opts |= PRINT_UCP_WORKER;
break;
case 'e':
print_opts |= PRINT_UCP_EP;
break;
case 't':
tl_name = optarg;
break;
case 'u':
for (f = optarg; *f; ++f) {
switch (*f) {
case 'a':
ucp_features |= UCP_FEATURE_AMO32|UCP_FEATURE_AMO64;
break;
case 'r':
ucp_features |= UCP_FEATURE_RMA;
break;
case 't':
ucp_features |= UCP_FEATURE_TAG;
break;
case 'w':
ucp_features |= UCP_FEATURE_WAKEUP;
break;
default:
usage();
return -1;
}
}
break;
case 'h':
default:
usage();
Expand Down Expand Up @@ -105,12 +142,17 @@ int main(int argc, char **argv)
ucm_config_print(stdout, print_flags);
}

if (print_opts & PRINT_PROTOCOLS) {
print_proto_info(print_flags);
}

if (print_opts & PRINT_DEVICES) {
print_uct_info(print_opts, print_flags, tl_name);
}

if (print_opts & (PRINT_UCP_CONTEXT|PRINT_UCP_WORKER|PRINT_UCP_EP)) {
if (ucp_features == 0) {
printf("Please select UCP features using -u switch\n");
return -1;
}
print_ucp_info(print_opts, print_flags, ucp_features);
}

return 0;
}
8 changes: 6 additions & 2 deletions src/tools/info/ucx_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ enum {
PRINT_BUILD_CONFIG = UCS_BIT(2),
PRINT_TYPES = UCS_BIT(3),
PRINT_DEVICES = UCS_BIT(4),
PRINT_PROTOCOLS = UCS_BIT(5)
PRINT_UCP_CONTEXT = UCS_BIT(5),
PRINT_UCP_WORKER = UCS_BIT(6),
PRINT_UCP_EP = UCS_BIT(7)

};


Expand All @@ -36,7 +39,8 @@ void print_uct_info(int print_opts, ucs_config_print_flags_t print_flags,

void print_type_info(const char * tl_name);

void print_proto_info(ucs_config_print_flags_t print_flags);
void print_ucp_info(int print_opts, ucs_config_print_flags_t print_flags,
uint64_t features);

/**
* @ingroup RESOURCE
Expand Down
37 changes: 31 additions & 6 deletions src/ucp/api/ucp.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,21 @@ void ucp_cleanup(ucp_context_h context_p);
ucs_status_t ucp_context_query(ucp_context_h context_p,
ucp_context_attr_t *attr);


/**
* @ingroup UCP_CONTEXT
* @brief Print context information.
*
* This routine prints information about the context configuration, including
* memory domains, transport resources, and other useful information associated
* with the context.
*
* @param [in] context Context object whose configuration to print.
* @param [in] stream Output stream to print the information to.
*/
void ucp_context_print_info(ucp_context_h context, FILE *stream);


/**
* @ingroup UCP_WORKER
* @brief Create a worker object.
Expand Down Expand Up @@ -645,18 +660,15 @@ void ucp_worker_destroy(ucp_worker_h worker);

/**
* @ingroup UCP_WORKER
* @brief Print information about protocols that would be used by a worker.
* @brief Print information about the worker.
*
* This routine prints information about the protocols being used, thresholds,
* UCT transport methods, and other useful information associated with the worker.
*
* @param [in] worker Worker object whose address to return.
* @param [in] worker Worker object ro print information for.
* @param [in] stream Output stream to print the information to.
* @param [in] title Configuration title to print.
* @param [in] print_flags Flags that control various printing options.
*/
void ucp_worker_proto_print(ucp_worker_h worker, FILE *stream, const char *title,
ucs_config_print_flags_t print_flags);
void ucp_worker_print_info(ucp_worker_h worker, FILE *stream);


/**
Expand Down Expand Up @@ -886,6 +898,19 @@ ucs_status_t ucp_ep_create(ucp_worker_h worker, const ucp_address_t *address,
ucs_status_ptr_t ucp_disconnect_nb(ucp_ep_h ep);


/**
* @ingroup UCP_ENDPOINT
* @brief Print endpoint information.
*
* This routine prints information about the endpoint transport methods, limits,
* thresholds, and other useful information associated with the endpoint.
*
* @param [in] ep Endpoint object whose configuration to print.
* @param [in] stream Output stream to print the information to.
*/
void ucp_ep_print_info(ucp_ep_h ep, FILE *stream);


/**
* @ingroup UCP_ENDPOINT
*
Expand Down
24 changes: 24 additions & 0 deletions src/ucp/core/ucp_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,27 @@ ucs_status_t ucp_context_query(ucp_context_h context, ucp_context_attr_t *attr)
return UCS_OK;
}

void ucp_context_print_info(ucp_context_h context, FILE *stream)
{
ucp_rsc_index_t md_index, rsc_index;

fprintf(stream, "#\n");
fprintf(stream, "# UCP context\n");
fprintf(stream, "#\n");

for (md_index = 0; md_index < context->num_mds; ++md_index) {
fprintf(stream, "# md[%d]: %s\n", md_index,
context->md_rscs[md_index].md_name);
}

fprintf(stream, "#\n");

for (rsc_index = 0; rsc_index < context->num_tls; ++rsc_index) {
fprintf(stream, "# rsc[%2d] / md[%d]: "UCT_TL_RESOURCE_DESC_FMT"\n",
rsc_index, context->tl_rscs[rsc_index].md_index,
UCT_TL_RESOURCE_DESC_ARG(&context->tl_rscs[rsc_index].tl_rsc)
);
}

fprintf(stream, "#\n");
}
Loading

0 comments on commit 109a2bf

Please sign in to comment.