Fix ucp_context_query usage
After calling ucp_context_query(ctx_, &attr)
, attr is still uninitialized. Therefore the request_size cannot be queried. Currently, the check in linktest is deactivated and a fixed size is used. This might impact performance and it can fail if the real request size is bigger than the chosen one. The UCX doc has no example for usage of ucp_context_query. According to documentation our code should work. See minimal example below. I also found other sources with similar code f.ex. https://github.com/ghex-org/oomph/search?q=ucp_context_query
Minimal Example
#include <ucp/api/ucp.h>
#include <cstring>
#include <cinttypes>
int main() {
ucp_config_t * config_p;
auto retCodeConfig = ucp_config_read (nullptr, nullptr, &config_p);
ucp_context_h ctx_;
ucp_params_t params;
memset(¶ms, 0, sizeof(params));
params.field_mask = UCP_PARAM_FIELD_FEATURES;
params.features = UCP_FEATURE_TAG;
auto retCodeInit = ucp_init(¶ms, config_p, &ctx_);
ucp_context_attr_t attr;
memset(&attr, 0, sizeof(attr));
printf("attr.field_mask before calling ucp_context_query %" PRIu64 "\n", attr.field_mask);
printf("attr.request_size before calling ucp_context_query %" PRIu64 "\n", attr.request_size);
auto retCodeQuery = ucp_context_query(ctx_, &attr);
printf("attr.field_mask after calling ucp_context_query %" PRIu64 "\n", attr.field_mask);
printf("attr.request_size after calling ucp_context_query %" PRIu64 "\n", attr.request_size);
printf("Return Code von ucp_init %d, ucp_context_query %d, ucp_config_read %d\n", retCodeInit, retCodeQuery, retCodeConfig);
ucp_context_print_info(ctx_, stdout);
ucp_config_print(config_p, stdout, "", UCS_CONFIG_PRINT_CONFIG);
ucp_config_release(config_p);
ucp_cleanup(ctx_);
return 0;
}
Edited by Yannik Müller