-
Notifications
You must be signed in to change notification settings - Fork 592
UCP/CORE: Implement flush+destroy for UCT EPs on UCP Worker #5608
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 1 commit
f7b0e3c
627a8a5
e9d3b1d
ecd8663
8d4a9f9
d229eae
8558d4c
cdfe88d
c1a8fee
28edf67
022a6f2
46b1272
cb197a4
5d0b3fa
12d1c34
d1ab7d4
d809dc1
7e6a5b4
a0f759b
46afaaf
e2982d5
7ecd09d
9ef1f34
efdb4d3
509dd6c
07b8bb3
43c3e92
9153e50
9c346d6
465be85
cdb8875
2a5888f
d3cf051
ea18b51
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 |
|---|---|---|
|
|
@@ -25,19 +25,22 @@ class test_ucp_worker_discard : public ucp_test { | |
| } | ||
|
|
||
| protected: | ||
| typedef std::map<uct_ep_h, | ||
| std::vector<uct_pending_req_t*> > ep_pending_reqs_map; | ||
| struct ep_test_info_t { | ||
| std::vector<uct_pending_req_t*> pending_reqs; | ||
| unsigned flush_count; | ||
| unsigned pending_add_count; | ||
| }; | ||
| typedef std::map<uct_ep_h, ep_test_info_t> ep_test_info_map_t; | ||
|
|
||
| void init() { | ||
| ucp_test::init(); | ||
| m_created_ep_count = 0; | ||
| m_destroyed_ep_count = 0; | ||
| m_flush_ep_count = 0; | ||
| m_pending_add_ep_count = 0; | ||
| m_fake_ep.flags = UCP_EP_FLAG_REMOTE_CONNECTED; | ||
| m_created_ep_count = 0; | ||
| m_destroyed_ep_count = 0; | ||
| m_fake_ep.flags = UCP_EP_FLAG_REMOTE_CONNECTED; | ||
|
|
||
| m_flush_comps.clear(); | ||
| m_pending_reqs.clear(); | ||
| m_ep_test_info_map.clear(); | ||
| } | ||
|
|
||
| void add_pending_reqs(uct_ep_h uct_ep, | ||
|
|
@@ -210,6 +213,23 @@ class test_ucp_worker_discard : public ucp_test { | |
| EXPECT_UCS_OK(ucp_request_check_status(flush_req)); | ||
| EXPECT_EQ(m_created_ep_count, m_destroyed_ep_count); | ||
| EXPECT_EQ(m_created_ep_count, total_ep_count); | ||
|
|
||
| for (unsigned i = 0; i < m_created_ep_count; i++) { | ||
| ep_test_info_t *test_info = ep_test_info_get(&eps[i]); | ||
|
|
||
| /* check EP flush counters */ | ||
| if (ep_flush_func == ep_flush_func_return_3_no_resource_then_ok) { | ||
| EXPECT_EQ(4, test_info->flush_count); | ||
| } else if (ep_flush_func == ep_flush_func_return_in_progress) { | ||
| EXPECT_EQ(1, test_info->flush_count); | ||
| } | ||
|
|
||
| /* check EP pending add counters */ | ||
| if (ep_pending_add_func == ep_pending_add_func_return_ok_then_busy) { | ||
| EXPECT_EQ(3, test_info->pending_add_count); | ||
| } | ||
| } | ||
|
|
||
| EXPECT_TRUE(m_flush_comps.empty()); | ||
| EXPECT_TRUE(m_pending_reqs.empty()); | ||
|
|
||
|
|
@@ -227,28 +247,61 @@ class test_ucp_worker_discard : public ucp_test { | |
| m_destroyed_ep_count++; | ||
| } | ||
|
|
||
| static ep_test_info_t* ep_test_info_get(uct_ep_h ep) { | ||
| ep_test_info_t *test_info_p; | ||
| ep_test_info_map_t::iterator it = m_ep_test_info_map.find(ep); | ||
|
|
||
| if (it == m_ep_test_info_map.end()) { | ||
| ep_test_info_t test_info = {}; | ||
|
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. since it's c++ struct, better to implement a constructor
Member
Author
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. done |
||
|
|
||
| m_ep_test_info_map.insert(std::make_pair(ep, test_info)); | ||
| test_info_p = &m_ep_test_info_map.find(ep)->second; | ||
| } else { | ||
| test_info_p = &it->second; | ||
| } | ||
|
|
||
| return test_info_p; | ||
| } | ||
|
|
||
| static unsigned | ||
| ep_test_info_flush_inc(uct_ep_h ep) { | ||
| ep_test_info_t *test_info = ep_test_info_get(ep); | ||
| test_info->flush_count++; | ||
| return test_info->flush_count; | ||
| } | ||
|
|
||
| static unsigned | ||
| ep_test_info_pending_add_inc(uct_ep_h ep) { | ||
| ep_test_info_t *test_info = ep_test_info_get(ep); | ||
| test_info->pending_add_count++; | ||
| return test_info->pending_add_count; | ||
| } | ||
|
|
||
| static ucs_status_t | ||
| ep_flush_func_return_3_no_resource_then_ok(uct_ep_h ep, unsigned flags, | ||
| uct_completion_t *comp) { | ||
| EXPECT_LT(m_flush_ep_count, 4 * m_created_ep_count); | ||
| return (++m_flush_ep_count < 3 * m_created_ep_count) ? | ||
| unsigned flush_ep_count = ep_test_info_flush_inc(ep); | ||
| EXPECT_LE(flush_ep_count, 4); | ||
| return (flush_ep_count < 4) ? | ||
| UCS_ERR_NO_RESOURCE : UCS_OK; | ||
| } | ||
|
|
||
| static ucs_status_t | ||
| ep_flush_func_return_in_progress(uct_ep_h ep, unsigned flags, | ||
| uct_completion_t *comp) { | ||
| EXPECT_LT(m_flush_ep_count, m_created_ep_count); | ||
| unsigned flush_ep_count = ep_test_info_flush_inc(ep); | ||
| EXPECT_LE(flush_ep_count, m_created_ep_count); | ||
| m_flush_comps.push_back(comp); | ||
| return UCS_INPROGRESS; | ||
| } | ||
|
|
||
| static ucs_status_t | ||
| ep_pending_add_func_return_ok_then_busy(uct_ep_h ep, uct_pending_req_t *req, | ||
| unsigned flags) { | ||
| EXPECT_LT(m_pending_add_ep_count, 3 * m_created_ep_count); | ||
| unsigned pending_add_ep_count = ep_test_info_pending_add_inc(ep); | ||
| EXPECT_LE(pending_add_ep_count, m_created_ep_count); | ||
|
|
||
| if (++m_pending_add_ep_count < m_created_ep_count) { | ||
| if (pending_add_ep_count < m_created_ep_count) { | ||
| m_pending_reqs.push_back(req); | ||
| return UCS_OK; | ||
| } | ||
|
|
@@ -286,28 +339,20 @@ class test_ucp_worker_discard : public ucp_test { | |
| static ucs_status_t | ||
| ep_pending_add_save_req(uct_ep_h ep, uct_pending_req_t *req, | ||
| unsigned flags) { | ||
| ep_pending_reqs_map::iterator it = m_pending_reqs_map.find(ep); | ||
| if (it == m_pending_reqs_map.end()) { | ||
| std::vector<uct_pending_req_t*> vec; | ||
| vec.push_back(req); | ||
| m_pending_reqs_map.insert(std::make_pair(ep, vec)); | ||
| } else { | ||
| std::vector<uct_pending_req_t*> *req_vec = &it->second; | ||
| req_vec->push_back(req); | ||
| } | ||
| ep_test_info_t *test_info = ep_test_info_get(ep); | ||
| test_info->pending_reqs.push_back(req); | ||
| return UCS_OK; | ||
| } | ||
|
|
||
| static void | ||
| ep_pending_purge_func_iter_reqs(uct_ep_h ep, | ||
| uct_pending_purge_callback_t cb, | ||
| void *arg) { | ||
| uct_pending_purge_callback_t cb, | ||
| void *arg) { | ||
| ep_test_info_t *test_info = ep_test_info_get(ep); | ||
| uct_pending_req_t *req; | ||
| for (unsigned i = 0; i < m_pending_purge_reqs_count; i++) { | ||
| ep_pending_reqs_map::iterator it = m_pending_reqs_map.find(ep); | ||
| ASSERT_NE(it, m_pending_reqs_map.end()); | ||
|
|
||
| std::vector<uct_pending_req_t*> *req_vec = &it->second; | ||
| for (unsigned i = 0; i < m_pending_purge_reqs_count; i++) { | ||
| std::vector<uct_pending_req_t*> *req_vec = &test_info->pending_reqs; | ||
|
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. std::vector<uct_pending_req_t*> &req_vec = ...
Member
Author
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. done |
||
| if (req_vec->size() == 0) { | ||
| break; | ||
| } | ||
|
|
@@ -321,26 +366,22 @@ class test_ucp_worker_discard : public ucp_test { | |
| protected: | ||
| static unsigned m_created_ep_count; | ||
| static unsigned m_destroyed_ep_count; | ||
| static unsigned m_flush_ep_count; | ||
| static unsigned m_pending_add_ep_count; | ||
| static ucp_ep_t m_fake_ep; | ||
| static const unsigned m_pending_purge_reqs_count; | ||
|
|
||
| static std::vector<uct_completion_t*> m_flush_comps; | ||
| static std::vector<uct_pending_req_t*> m_pending_reqs; | ||
| static ep_pending_reqs_map m_pending_reqs_map; | ||
| static ep_test_info_map_t m_ep_test_info_map; | ||
| }; | ||
|
|
||
| unsigned test_ucp_worker_discard::m_created_ep_count = 0; | ||
| unsigned test_ucp_worker_discard::m_destroyed_ep_count = 0; | ||
| unsigned test_ucp_worker_discard::m_flush_ep_count = 0; | ||
| unsigned test_ucp_worker_discard::m_pending_add_ep_count = 0; | ||
| ucp_ep_t test_ucp_worker_discard::m_fake_ep = {}; | ||
| const unsigned test_ucp_worker_discard::m_pending_purge_reqs_count = 10; | ||
|
|
||
| std::vector<uct_completion_t*> test_ucp_worker_discard::m_flush_comps; | ||
| std::vector<uct_pending_req_t*> test_ucp_worker_discard::m_pending_reqs; | ||
| test_ucp_worker_discard::ep_pending_reqs_map test_ucp_worker_discard::m_pending_reqs_map; | ||
| std::vector<uct_completion_t*> test_ucp_worker_discard::m_flush_comps; | ||
| std::vector<uct_pending_req_t*> test_ucp_worker_discard::m_pending_reqs; | ||
| test_ucp_worker_discard::ep_test_info_map_t test_ucp_worker_discard::m_ep_test_info_map; | ||
|
|
||
|
|
||
| UCS_TEST_P(test_ucp_worker_discard, flush_ok) { | ||
|
|
||
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.
return type can be reference
ep_test_info_t &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.
done