Skip to content

Commit

Permalink
Merge pull request #44 from 23-Wzz/huawei
Browse files Browse the repository at this point in the history
Delete Chenge's MR
  • Loading branch information
ChenQiangFYQ authored Jun 28, 2021
2 parents 6873b70 + 2100e23 commit fc4f5b7
Show file tree
Hide file tree
Showing 20 changed files with 347 additions and 505 deletions.
13 changes: 13 additions & 0 deletions src/tools/info/group_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ucx_info.h"

#include <ucg/api/ucg_mpi.h>
#include <ucg/api/ucg_plan_component.h>
#include <ucg/api/ucg_mpi.h>
#include <ucs/debug/memtrack.h>

Expand All @@ -22,3 +23,15 @@ const char *collective_names[] = {
};

#define EMPTY UCG_GROUP_MEMBER_DISTANCE_LAST

ucg_address_t *worker_address = 0;
ucs_status_t dummy_resolve_address(void *cb_group_obj,
ucg_group_member_index_t index,
ucg_address_t **addr, size_t *addr_len)
{
*addr = worker_address;
*addr_len = 0; /* special debug flow: replace uct_ep_t with member indexes */
return UCS_OK;
}

void dummy_release_address(ucg_address_t *addr) { }
1 change: 0 additions & 1 deletion src/ucp/core/ucp_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ typedef struct ucp_am_handler {
ucp_am_tracer_t tracer;
uint32_t flags;
uct_am_callback_t proxy_cb;
void *alt_arg; /**< Alternative argument for cb */
} ucp_am_handler_t;

typedef struct ucp_tl_iface_atomic_flags {
Expand Down
2 changes: 1 addition & 1 deletion src/ucp/core/ucp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ enum {
UCP_AM_ID_SINGLE_REPLY = 26, /* Single fragment user defined AM
carrying remote ep for reply */
UCP_AM_ID_LAST,
UCP_AM_ID_MAX = UCT_AM_ID_MAX /* Total IDs available for pre-registration */
UCP_AM_ID_MAX = 32 /* Total IDs available for pre-registration */
};


Expand Down
10 changes: 2 additions & 8 deletions src/ucp/core/ucp_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,11 @@ static void ucp_worker_set_am_handlers(ucp_worker_iface_t *wiface, int is_proxy)
ucp_context_h context = worker->context;
ucs_status_t status;
unsigned am_id;
void *cb_arg;

ucs_trace_func("iface=%p is_proxy=%d", wiface->iface, is_proxy);

for (am_id = 0; am_id < UCP_AM_ID_MAX; ++am_id) {
if (!is_proxy && ucp_am_handlers[am_id].cb == NULL) {
if (!ucp_am_handlers[am_id].cb) {
continue;
}

Expand Down Expand Up @@ -179,14 +178,9 @@ static void ucp_worker_set_am_handlers(ucp_worker_iface_t *wiface, int is_proxy)
wiface,
ucp_am_handlers[am_id].flags);
} else {
if (ucp_am_handlers[am_id].alt_arg != NULL) {
cb_arg = ucp_am_handlers[am_id].alt_arg;
} else {
cb_arg = worker;
}
status = uct_iface_set_am_handler(wiface->iface, am_id,
ucp_am_handlers[am_id].cb,
cb_arg,
worker,
ucp_am_handlers[am_id].flags);
}
if (status != UCS_OK) {
Expand Down
2 changes: 1 addition & 1 deletion src/ucs/datastruct/ptr_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void ucs_ptr_array_set(ucs_ptr_array_t *ptr_array, unsigned element_index,
ucs_ptr_array_elem_t *elem;
unsigned next, free_iter, free_ahead, new_size;

if (ucs_unlikely(element_index >= ptr_array->size)) {
if (ucs_unlikely(element_index > ptr_array->size)) {
new_size = ucs_max(ptr_array->size * 2, element_index + 1);
ucs_ptr_array_grow(ptr_array, new_size UCS_MEMTRACK_NAME(ptr_array->name));
} else if (!__ucs_ptr_array_is_free(ptr_array->start[element_index])) {
Expand Down
150 changes: 89 additions & 61 deletions test/gtest/ucg/test_builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@ extern "C" {
#include "ucg_test.h"
#include "ucg_plan_test.h"


ucg_plan_test::ucg_plan_test()
{
m_builtin_ctx = NULL;
m_planc = NULL;
m_group_params = NULL;
m_coll_params = NULL;
m_group = NULL;
m_planner_p = NULL;
m_all_rank_infos.clear();
}

ucg_plan_test::ucg_plan_test(size_t node_cnt, size_t ppn, unsigned myrank)
{
m_planc = NULL;
m_all_rank_infos.clear();
m_resource_factory->create_balanced_rank_info(m_all_rank_infos, node_cnt, ppn);
m_group_params = m_resource_factory->create_group_params(m_all_rank_infos[myrank], m_all_rank_infos, m_ucp_worker);
m_resource_factory->create_group(m_group_params, m_ucg_context, &m_group);
m_group_params = m_resource_factory->create_group_params(m_all_rank_infos[myrank], m_all_rank_infos);
m_group = m_resource_factory->create_group(m_group_params, m_ucg_worker);
m_coll_params = m_resource_factory->create_collective_params(UCG_GROUP_COLLECTIVE_MODIFIER_SINGLE_SOURCE,
0, NULL, 1, NULL, 4, NULL, NULL);
m_coll_type.modifiers = UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE;
m_coll_type.root = 0;

ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucg_group_select_planner(m_group, NULL, m_coll_params, &planner, &planner_ctx);
ucg_builtin_component.query(&m_planner_p);
m_builtin_ctx = (ucg_builtin_planner_ctx_t *)planner_ctx;
ucg_plan_select(m_group, NULL, m_coll_params, &m_planc);
m_builtin_ctx = (ucg_builtin_group_ctx_t *)UCG_GROUP_TO_COMPONENT_CTX(ucg_builtin_component, m_group);
}

ucg_plan_test::~ucg_plan_test()
Expand All @@ -51,53 +49,47 @@ ucg_plan_test::~ucg_plan_test()
m_group_params = NULL;
}

if (m_planner_p != NULL) {
delete m_planner_p;
m_planner_p = NULL;
}

m_all_rank_infos.clear();
}



TEST(ucg_plan_test, ucg_plan_1_test) {
ucg_plan_test example(4, 8, 0);
size_t msg_size = UCG_GROUP_MED_MSG_SIZE - 1024;

ucg_plan_t *plan = NULL;

ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucs_status_t ret = ucg_group_select_planner(example.m_group, NULL, example.m_coll_params,
&planner, &planner_ctx);
ucs_status_t ret = ucg_builtin_component.create(&ucg_builtin_component, example.m_ucg_worker,
example.m_group, 23, 0, NULL, example.m_group_params);
EXPECT_EQ(UCS_OK, ret);
ret = example.m_planner_p->plan(planner_ctx, example.m_coll_params, &plan);
ret = ucg_builtin_component.plan(&ucg_builtin_component, &example.m_coll_type, msg_size,
example.m_group, example.m_coll_params, &plan);
EXPECT_EQ(UCS_OK, ret);

}

TEST(ucg_plan_test, ucg_plan_2_test) {
ucg_plan_test example(4, 8, 0);

size_t msg_size = UCG_GROUP_MED_MSG_SIZE + 1024;

ucg_plan_t *plan = NULL;
ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucs_status_t ret = ucg_group_select_planner(example.m_group, NULL, example.m_coll_params,
&planner, &planner_ctx);
ucs_status_t ret = ucg_builtin_component.create(&ucg_builtin_component, example.m_ucg_worker,
example.m_group, 23, 0, NULL, example.m_group_params);
EXPECT_EQ(UCS_OK, ret);
ret = example.m_planner_p->plan(planner_ctx, example.m_coll_params, &plan);
ret = ucg_builtin_component.plan(&ucg_builtin_component, &example.m_coll_type, msg_size,
example.m_group, example.m_coll_params, &plan);
EXPECT_EQ(UCS_OK, ret);
}

TEST(ucg_plan_test, ucg_plan_3_test) {
ucg_plan_test example(4, 8, 0);
size_t msg_size = UCG_GROUP_MED_MSG_SIZE - 1024;

ucg_plan_t *plan = NULL;
ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucs_status_t ret = ucg_group_select_planner(example.m_group, NULL, example.m_coll_params,
&planner, &planner_ctx);
ucs_status_t ret = ucg_builtin_component.create(&ucg_builtin_component, example.m_ucg_worker,
example.m_group, 23, 0, NULL, example.m_group_params);
EXPECT_EQ(UCS_OK, ret);
ret = example.m_planner_p->plan(planner_ctx, example.m_coll_params, &plan);
ret = ucg_builtin_component.plan(&ucg_builtin_component, &example.m_coll_type, msg_size,
example.m_group, example.m_coll_params, &plan);
EXPECT_EQ(UCS_OK, ret);
}
/*
Expand All @@ -106,7 +98,7 @@ TEST(ucg_plan_test, ucg_plan_4_test) {
size_t msg_size = UCG_GROUP_MED_MSG_SIZE + 1024;
ucg_plan_t *plan;
ucs_status_t ret = ucg_builtin_component.create(&ucg_builtin_component, example.m_ucp_worker,
ucs_status_t ret = ucg_builtin_component.create(&ucg_builtin_component, example.m_ucg_worker,
example.m_group, 23, 0, NULL, example.m_group_params);
EXPECT_EQ(UCS_OK, ret);
ret = ucg_builtin_component.plan(&ucg_builtin_component, &example.m_coll_type, msg_size,
Expand All @@ -115,29 +107,37 @@ TEST(ucg_plan_test, ucg_plan_4_test) {
}
*/
TEST(ucg_plan_test, algorithm_selection) {
ucs_status_t ret;
unsigned idx;
for (idx = 0; idx < UCG_ALGORITHM_ALLREDUCE_LAST; idx++) {
ucg_builtin_allreduce_algo_switch((enum ucg_builtin_allreduce_algorithm) idx, &ucg_builtin_algo_config);
ret = ucg_builtin_allreduce_algo_switch((enum ucg_builtin_allreduce_algorithm) idx, &ucg_algo);
ASSERT_EQ(UCS_OK, ret);
}

for (idx = 0; idx < UCG_ALGORITHM_BARRIER_LAST; idx++) {
ucg_builtin_barrier_algo_switch((enum ucg_builtin_barrier_algorithm) idx, &ucg_builtin_algo_config);
ret = ucg_builtin_barrier_algo_switch((enum ucg_builtin_barrier_algorithm) idx, &ucg_algo);
ASSERT_EQ(UCS_OK, ret);
}

for (idx = 0; idx < UCG_ALGORITHM_BCAST_LAST; idx++) {
ucg_builtin_bcast_algo_switch((enum ucg_builtin_bcast_algorithm) idx, &ucg_builtin_algo_config);
ret = ucg_builtin_bcast_algo_switch((enum ucg_builtin_bcast_algorithm) idx, &ucg_algo);
ASSERT_EQ(UCS_OK, ret);
}

}

TEST(ucg_plan_test, topo_level) {
ucg_builtin_algo_config.topo_level = UCG_GROUP_HIERARCHY_LEVEL_NODE;
ucs_status_t ret;
ucg_algo.topo_level = UCG_GROUP_HIERARCHY_LEVEL_NODE;
enum ucg_group_member_distance domain_distance = UCG_GROUP_MEMBER_DISTANCE_SELF;
choose_distance_from_topo_aware_level(&domain_distance);
ucg_builtin_algo_config.topo_level = UCG_GROUP_HIERARCHY_LEVEL_SOCKET;
choose_distance_from_topo_aware_level(&domain_distance);
ucg_builtin_algo_config.topo_level = UCG_GROUP_HIERARCHY_LEVEL_L3CACHE;
choose_distance_from_topo_aware_level(&domain_distance);
ret = choose_distance_from_topo_aware_level(&domain_distance);
ASSERT_EQ(UCS_OK, ret);
ucg_algo.topo_level = UCG_GROUP_HIERARCHY_LEVEL_SOCKET;
ret = choose_distance_from_topo_aware_level(&domain_distance);
ASSERT_EQ(UCS_OK, ret);
ucg_algo.topo_level = UCG_GROUP_HIERARCHY_LEVEL_L3CACHE;
ret = choose_distance_from_topo_aware_level(&domain_distance);
ASSERT_EQ(UCS_OK, ret);
}

TEST(ucg_plan_test, check_continus_number) {
Expand All @@ -163,6 +163,50 @@ TEST(ucg_plan_test, check_continus_number) {
ASSERT_EQ(1u, discount);
}

TEST(ucg_plan_test, choose_type) {

enum ucg_collective_modifiers flags[] = \
{ UCG_GROUP_COLLECTIVE_MODIFIER_SINGLE_SOURCE, UCG_GROUP_COLLECTIVE_MODIFIER_SINGLE_DESTINATION, \
UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE, UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE, UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE, \
UCG_GROUP_COLLECTIVE_MODIFIER_ALLGATHER, UCG_GROUP_COLLECTIVE_MODIFIER_ALLGATHER};

enum ucg_builtin_plan_topology_type expect_result[] = {UCG_PLAN_TREE_FANOUT, UCG_PLAN_TREE_FANIN, \
UCG_PLAN_RECURSIVE, UCG_PLAN_RING, UCG_PLAN_TREE_FANIN_FANOUT, \
UCG_PLAN_BRUCK, UCG_PLAN_RECURSIVE};
enum ucg_builtin_plan_topology_type ret_type;
/* TODO */
unsigned case_num = 7;
for (unsigned i = 0; i < case_num; i++) {

switch (i)
{
case 2:
ucg_algo.recursive = 1;
ucg_algo.ring = 0;
ucg_algo.bruck = 0;
break;
case 3:
ucg_algo.recursive = 0;
ucg_algo.ring = 1;
ucg_algo.bruck = 0;
break;
case 5:
ucg_algo.recursive = 0;
ucg_algo.ring = 0;
ucg_algo.bruck = 1;
break;
default:
ucg_algo.recursive = 0;
ucg_algo.ring = 0;
ucg_algo.bruck = 0;
break;
}

ret_type = ucg_builtin_choose_type(flags[i]);
ASSERT_EQ(expect_result[i], ret_type);
}
}

/* TODO: add verification to below functions */
/*
TEST(ucg_plan_test, plan_decision_in_discontinuous_case) {
Expand All @@ -180,7 +224,6 @@ TEST(ucg_plan_test, plan_decision_in_discontinuous_case) {
}
}
*/

TEST(ucg_plan_test, plan_decision_fixed) {
ucg_plan_test example(2, 2, 0);
unsigned op_num = 3;
Expand All @@ -198,41 +241,26 @@ TEST(ucg_plan_test, plan_decision_fixed) {
for (unsigned i = 0; i < op_num; i++) {
for (unsigned j = 0; j < size_num; j++) {
for (unsigned k = 0; k < data_num; k++) {
plan_decision_fixed(msg_size[j], example.m_group_params, modifiers[i],
example.m_coll_params, large_data[k], 0,
&bcast_algo_decision, &allreduce_algo_decision, &barrier_algo_decision);
plan_decision_fixed(msg_size[j], example.m_group_params, modifiers[i], example.m_coll_params, large_data[k], 0, &bcast_algo_decision, &allreduce_algo_decision, &barrier_algo_decision);
}
}
}
}

TEST(ucg_plan_test, plan_chooose_ops) {
ucg_plan_test example(2, 2, 0);
ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucs_status_t ret = ucg_group_select_planner(example.m_group, NULL, example.m_coll_params,
&planner, &planner_ctx);
ASSERT_EQ(UCS_OK, ret);
ucg_builtin_planner_ctx_t *ctx = (ucg_builtin_planner_ctx_t *)planner_ctx;
unsigned op_num = 3;
enum ucg_collective_modifiers modifiers[op_num] = { (enum ucg_collective_modifiers ) (UCG_GROUP_COLLECTIVE_MODIFIER_BROADCAST | UCG_GROUP_COLLECTIVE_MODIFIER_SINGLE_SOURCE), \
(enum ucg_collective_modifiers) (UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE | UCG_GROUP_COLLECTIVE_MODIFIER_BROADCAST | UCG_GROUP_COLLECTIVE_MODIFIER_BARRIER), \
(enum ucg_collective_modifiers) (UCG_GROUP_COLLECTIVE_MODIFIER_AGGREGATE | UCG_GROUP_COLLECTIVE_MODIFIER_BROADCAST) };

for (unsigned i = 0; i < op_num; i++) {
ucg_builtin_plan_choose_ops(ctx->config, modifiers[i]);
ucg_builtin_plan_choose_ops(example.m_planc, modifiers[i]);
}
}

TEST(ucg_plan_test, test_algorithm_decision) {
ucg_plan_test example(2, 2, 0);

ucg_planner_h planner = NULL;
ucg_planner_ctx_h planner_ctx;
ucs_status_t ret = ucg_group_select_planner(example.m_group, NULL, example.m_coll_params,
&planner, &planner_ctx);
ASSERT_EQ(UCS_OK, ret);
ucg_builtin_planner_ctx_t *ctx = (ucg_builtin_planner_ctx_t *)planner_ctx;
ret = ucg_builtin_algorithm_decision(ctx, example.m_coll_params);
ucs_status_t ret = ucg_builtin_algorithm_decision(&(example.m_coll_type), 1024, example.m_group_params, example.m_coll_params, example.m_planc);
ASSERT_EQ(UCS_OK, ret);
}
Loading

0 comments on commit fc4f5b7

Please sign in to comment.