Skip to content

UCT/MM: Only poll the mm_iface selected for AM_LANE - #10679

Open
arun-chandran-edarath wants to merge 2 commits into
openucx:masterfrom
arun-chandran-edarath:fifo_poll_only_am_lane
Open

arun-chandran-edarath wants to merge 2 commits into
openucx:masterfrom
arun-chandran-edarath:fifo_poll_only_am_lane

Conversation

@arun-chandran-edarath

@arun-chandran-edarath arun-chandran-edarath commented May 12, 2025 •

Copy link
Copy Markdown
Contributor

What

Enhancement: Avoid Polling on Multiple Memory Interface FIFOs

Currently, in intra-node scenarios, multiple memory interface FIFOs (e.g., sysv, xpmem) are getting polled for messages.
This patch ensures that only the interface selected for AM_LANE is polled, avoiding unnecessary polling of other FIFOs; as we
use only the FIFO selected for AM_LANE for communication


1. Wireup Stage

During the wireup stage, lanes of types UCP_LANE_TYPE_AM, UCP_LANE_TYPE_RKEY_PTR, and UCP_LANE_TYPE_RMA_BW are constructed to reach other ucp_worker instances (ranks).

Logs:

[1747027683.309179] [lib-ssp-04:3568845:0]      ucp_worker.c:1903 UCX  INFO    ucp_context_0 intra-node cfg#1 tag(sysv/memory xpmem/memory cma/memory)
[1747029739.340268] [lib-ssp-04:3568845:0]          wireup.c:1280 UCX  DEBUG   ep 0x7f1b937940a0: am_lane 0 wireup_msg_lane <none> cm_lane <none> keepalive_lane <none> reachable_mds 0x1e
[1747029739.340300] [lib-ssp-04:3568845:0]          wireup.c:1290 UCX  DEBUG   ep 0x7f1b937940a0: lane[0]:  1:sysv/memory.0 md[1]           -> addr[1].md[1]/sysv/sysdev[255] seg 4294967295 am
[1747029739.340308] [lib-ssp-04:3568845:0]          wireup.c:1290 UCX  DEBUG   ep 0x7f1b937940a0: lane[1]:  4:xpmem/memory.0 md[4]          -> addr[4].md[4]/xpmem/sysdev[255] seg 4294967295 rkey_ptr
[1747029739.340317] [lib-ssp-04:3568845:0]          wireup.c:1290 UCX  DEBUG   ep 0x7f1b937940a0: lane[2]:  3:cma/memory.0 md[3]            -> addr[3].md[3]/cma/sysdev[255] seg 4294967295 rma_bw#0

GDB Output:

(gdb) info line
Line 1917 of "wireup/wireup.c" starts at address 0x7f1b92323422 <ucp_wireup_init_lanes+3457> and ends at 0x7f1b9232342d <ucp_wireup_init_lanes+3468>.

(gdb) p key
$3 = {
  num_lanes = 3,
  lanes = {{
      rsc_index = 1,
      dst_md_index = 1,
      dst_sys_dev = 255,
      path_index = 0,
      lane_types = 1,
      seg_size = 4294967295
  }, {
      rsc_index = 4,
      dst_md_index = 4,
      dst_sys_dev = 255,
      path_index = 0,
      lane_types = 16,
      seg_size = 4294967295
  }, {
      rsc_index = 3,
      dst_md_index = 3,
      dst_sys_dev = 255,
      path_index = 0,
      lane_types = 8,
      seg_size = 4294967295
  }},
  am_lane = 0,
  tag_lane = 255,
  wireup_msg_lane = 255,
  cm_lane = 255,
  keepalive_lane = 255,
  ...
}

2. Polling

Both sysv and xpmem FIFOs are being polled during mca_pml_ucx_progress()

(gdb) bt
#0  uct_worker_progress (worker=0x22fdcf0) at src/uct/api/uct.h:2823
#1  ucp_worker_progress (worker=0x2313ed0) at core/ucp_worker.c:3059
#2  0x00007f1b932336af in mca_pml_ucx_progress () at pml_ucx.c:588
#3  0x00007f1b925c8af5 in opal_progress () at runtime/opal_progress.c:224
#4  0x00007f1b92f70990 in ompi_mpi_init (argc=0, argv=0x0, requested=0, provided=0x7ffd28f05e1c, reinit_ok=false)
    at runtime/ompi_mpi_init.c:517
#5  0x00007f1b92fd4d5a in PMPI_Init (argc=0x0, argv=0x0) at init.c:69
#6  0x0000000000400b74 in main (argc=4, argv=0x7ffd28f05f98) at send_recv.c:28
(gdb) p worker->progress_q
$11 = {
    fast_elems = {{
      cb = 0x7f1b91e97ca0 <uct_mm_iface_progress>,
      arg = 0x233a310
    }, {
      cb = 0x7f1b91e97ca0 <uct_mm_iface_progress>,
      arg = 0x2337820
    }, {
      cb = 0x0,
      arg = 0x22fdcf0
    },
    ...
}

3. During MPI Execution

When the MPI application is running, ranks use only one memory interface FIFO to exchange messages.
The xpmem FIFO is polled unnecessarily. If multiple FIFOs were used to exchange messages, it would need a mechanism to avoid out-of-order message delivery.


@yosefe

yosefe commented May 12, 2025 •

Copy link
Copy Markdown
Member

because of the need to support assymetric situations, we cannot assume the other peers would use the same transport. so we use the adaptive progress mechanism in order to progress only on transports that received at least one active message - see ucp_worker_iface_check_events_do function.
i wonder why it didn't work as expected in this case.

@arun-chandran-edarath

Copy link
Copy Markdown
Contributor Author

because of the need to support assymetric situations, we cannot assume the other peers would use the same transport. so we use the adaptive progress mechanism in order to progress only on transports that received at least one active message - see ucp_worker_iface_check_events_do function. i wonder why it didn't work as expected in this case.

This change is not about stopping polling of 'devices' from two different interfaces of different types.

It is about stopping polling of two FIFOs (sysv, xpmem) from the same type of 'memory' interface.

The sysv transport layer (TLS) gets selected for UCP_LANE_TYPE_AM. The function ucp_wireup_select_transport() makes this selection by comparing scores from ucp_wireup_am_score_func().

All three TLS options (sysv, posix, xpmem) get the same score: 10000.000030387355. sysv wins the selection because it has the lowest rsc_index.

I am not sure why sysv always gets the lowest rsc_index. Could it be due to some compile-time configuration? (I tried changing the order using the UCX_TLS="" command-line parameter, but it did not work.)

(gdb) info line
Line 620 of "wireup/select.c" is at address 0x7fc4c7021d63 <ucp_wireup_select_transport+10036> but contains no code.
(gdb) p score
$13 = 10000.000030387355
(gdb) p *resource
$14 = {tl_name = "sysv", dev_name = "memory", dev_type = UCT_DEVICE_TYPE_SHM, sys_device = 255}
(gdb) p *resource
$17 = {tl_name = "posix", dev_name = "memory", dev_type = UCT_DEVICE_TYPE_SHM, sys_device = 255}
(gdb) p score
$18 = 10000.000030387355
(gdb) p *resource
$19 = {tl_name = "xpmem", dev_name = "memory", dev_type = UCT_DEVICE_TYPE_SHM, sys_device = 255}
(gdb) p score
$20 = 10000.000030387355

Eventually, xpmem gets selected for UCP_LANE_TYPE_RKEY_PTR.

As a result, worker->progress_q ends up polling both sysv and xpmem. However, only one FIFO is used to exchange messages when the application runs.

Inside a single node, what asymmetries cause a ucp_worker (rank) to choose two different types of memory interfaces (one among sysv, posix, and xpmem) to communicate with two different peers (ranks) on the same node?

@arun-chandran-edarath

Copy link
Copy Markdown
Contributor Author

@yosefe
Is the simultaneous polling of two different FIFOs from the shared_memory_interface (sysv, posix, and xpmem) a valid use-case?

With my patch, I am seeing the following gtest fail intermittently (about 1 out of 5 runs).

./test/gtest/gtest --gtest_filter=shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0
[ INFO ] srd is not available
[ INFO ] ugni is not available
[ INFO ] srd,cuda_copy,rocm_copy is not available
[ INFO ] ugni,cuda_copy,rocm_copy is not available
[ INFO ] Using random seed of 25844
Note: Google Test filter = shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from shm_ib/test_ucp_tag_match
[ RUN ] shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0 <shm,ib/req_int>
[1747379624.132179] [muncl02:3500059:0] ucp_test.cc:295 UCX ERROR request 0x39f1090 did not complete on time
[1747379624.179177] [muncl02:3500059:0] mpool.c:54 UCX WARN object 0x39f0f80 {{rls|cb} } was not returned to mpool ucp_requests
[1747379624.208605] [muncl02:3500059:0] callbackq.c:561 UCX WARN callbackq 0x32243c0: 1 callback was not removed, increase log level to diag for details
common/test.cc:366: Failure
Failed
Got 1 errors and 2 warnings during the test
[ INFO ] < ucp/ucp_test.cc:295 request 0x39f1090 did not complete on time >
[ INFO ] < datastruct/mpool.c:54 object 0x39f0f80 {{rls|cb} } was not returned to mpool ucp_requests >
[ INFO ] < datastruct/callbackq.c:561 callbackq 0x32243c0: 1 callback was not removed, increase log level to diag for details >
[ FAILED ] shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0, where GetParam() = shm,ib/req_int (180178 ms)
[----------] 1 test from shm_ib/test_ucp_tag_match (180178 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (180179 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0, where GetParam() = shm,ib/req_int

1 FAILED TEST

The full log is attached. Can you please check? I feel it is introducing some weird timing issue. Please let me know if you need more information.

gtest_fail_log.txt

@arun-chandran-edarath

Copy link
Copy Markdown
Contributor Author

because of the need to support assymetric situations, we cannot assume the other peers would use the same transport. so we use the adaptive progress mechanism in order to progress only on transports that received at least one active message - see ucp_worker_iface_check_events_do function. i wonder why it didn't work as expected in this case.

@yosefe , thanks for the pointer; I am able to see this in the gdb bt of the test "shm_ib/test_ucp_tag_match.send_nb_recv_unexp/0"

(gdb) bt
#0 uct_iface_progress_enable (iface=0x31b3750, flags=131) at api/uct.h:3608
#1 ucp_worker_iface_activate (wiface=0x31b3010, uct_flags=128) at core/ucp_worker.c:611
#2 0x00001555551af2e9 in ucp_worker_iface_check_events_do (wiface=0x31b3010, progress_count=0x7fffffffbe7c) at core/ucp_worker.c:644
#3 0x00001555551af73b in ucp_worker_iface_check_events_progress (arg=0x31b3010) at core/ucp_worker.c:697
#4 0x00001555554b080e in ucs_callbackq_spill_elems_dispatch (cbq=0x3170380) at datastruct/callbackq.c:380
#5 0x00001555554b0ca3 in ucs_callbackq_proxy_callback (arg=0x3170380) at datastruct/callbackq.c:476
#6 0x00001555551aa839 in ucs_callbackq_dispatch (cbq=0x3170380) at datastruct/callbackq.h:215
#7 0x00001555551b9f89 in uct_worker_progress (worker=0x3170380) at api/uct.h:2825
#8 ucp_worker_progress (worker=0x31b9050) at core/ucp_worker.c:3063
#9 0x0000000000d29ea1 in ucp_test_base::entity::progress (this=0x30b6af0, worker_index=0) at ucp/ucp_test.cc:1055
#10 0x0000000000d24908 in ucp_test::progress (this=0x2ea5090, entities=..., worker_index=0) at ucp/ucp_test.cc:167
#11 0x0000000000d24976 in ucp_test::progress (this=0x2ea5090, worker_index=0) at ucp/ucp_test.cc:175
#12 0x0000000000b646ea in test_ucp_tag::wait (this=0x2ea5090, ucx_req=0x3438090, user_data=0x0, buf_index=0) at ucp/test_ucp_tag.cc:147
#13 0x0000000000b65704 in test_ucp_tag::recv (this=0x2ea5090, receiver=..., type=test_ucp_tag::RECV_B, buffer=0x7fffffffc6f0, count=8, datatype=8, tag=4919, tag_mask=65535, info=0x7fffffffc700, user_data=0x0, buf_index=0) at ucp/test_ucp_tag.cc:340
#14 0x0000000000b65c1a in test_ucp_tag::recv_b (this=0x2ea5090, buffer=0x7fffffffc6f0, count=8, datatype=8, tag=4919, tag_mask=65535, info=0x7fffffffc700, user_data=0x0, buf_index=0) at ucp/test_ucp_tag.cc:399
#15 0x0000000000ab7f64 in test_ucp_tag_match_send_nb_recv_unexp_Test::test_body (this=0x2ea5090) at ucp/test_ucp_tag_match.cc:420
#16 0x000000000060e42c in ucs::test_base::run (this=0x2ea5090) at common/test.cc:378
#17 0x000000000060e5b5 in ucs::test_base::TestBodyProxy (this=0x2ea5090) at common/test.cc:404
#18 0x00000000008dc066 in ucp_test::TestBody (this=0x2ea5090) at ucp/ucp_test.h:211
#19 0x0000000001154d13 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x2ea5110, method=&virtual testing::Test::TestBody(), location=0x12d0bf3 "the test body") at gtest.cc:2433
#20 0x0000000001150151 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x2ea5110, method=&virtual testing::Test::TestBody(), location=0x12d0bf3 "the test body") at gtest.cc:2469
#21 0x000000000113a109 in testing::Test::Run (this=0x2ea5110) at gtest.cc:2508
#22 0x000000000113aa14 in testing::TestInfo::Run (this=0x1d47b20) at gtest.cc:2687
#23 0x000000000113b0e1 in testing::TestSuite::Run (this=0x1d1bbf0) at gtest.cc:2819
#24 0x0000000001146be4 in testing::internal::UnitTestImpl::RunAllTests (this=0x175c510) at gtest.cc:5350
#25 0x0000000001155f3e in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x175c510,
method=(bool (testing::internal::UnitTestImpl::)(testing::internal::UnitTestImpl * const)) 0x1146832 testing::internal::UnitTestImpl::RunAllTests(), location=0x12d15a8 "auxiliary test code (environments or event listeners)") at gtest.cc:2433
#26 0x0000000001151087 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x175c510,
method=(bool (testing::internal::UnitTestImpl::
)(testing::internal::UnitTestImpl * const)) 0x1146832 testing::internal::UnitTestImpl::RunAllTests(), location=0x12d15a8 "auxiliary test code (environments or event listeners)") at gtest.cc:2469
#27 0x00000000011455de in testing::UnitTest::Run (this=0x17595e0 testing::UnitTest::GetInstance()::instance) at gtest.cc:4937
#28 0x00000000005f1da2 in RUN_ALL_TESTS () at common/googletest/gtest.h:2473
#29 0x00000000005f1ae3 in main (argc=1, argv=0x7fffffffd408) at common/main.cc:125

@arun-chandran-edarath
arun-chandran-edarath force-pushed the fifo_poll_only_am_lane branch 3 times, most recently from da7b251 to 585c529 Compare May 26, 2025 04:18
Signed-off-by: Arun Chandran <Arun.Chandran@amd.com>
Signed-off-by: Arun Chandran <Arun.Chandran@amd.com>
@openucx openucx deleted a comment from svc-nixl May 4, 2026
@gleon99

gleon99 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Hi @arun-chandran-edarath - we're cleaning up the UCX PR backlog and plan to close this PR in 7 days. Please let us know if you'd like to keep it open.

@arun-chandran-edarath

Copy link
Copy Markdown
Contributor Author

@gleon99 I'd like to keep this open. The underlying issue still stands: the xpmem FIFO gets polled even though only the sysv FIFO (selected for AM_LANE) is used to exchange messages, so the extra polling is wasted work.

To recap where this stands: sysv, posix, and xpmem all get the same wireup score, sysv wins AM_LANE on the lowest rsc_index, and xpmem ends up selected for RKEY_PTR, which leaves both FIFOs in worker->progress_q.

@yosefe, could you take another look? I'd like your feedback on whether this is the right approach to avoid polling the unused xpmem FIFO.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants