Skip to content

Commit 930c9f7

Browse files
committed
addressing comments.
1 parent c6b9588 commit 930c9f7

File tree

2 files changed

+59
-42
lines changed

2 files changed

+59
-42
lines changed

test/unit/plugins/ucx/ucx_backend_multi.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ void test_thread(int id)
3232
{
3333
nixlBackendInitParams init_params;
3434
nixl_b_params_t custom_params;
35-
nixlBackendEngine* ucx;
3635
nixl_status_t ret;
3736

3837
std::string my_name("Agent1");
@@ -50,9 +49,9 @@ void test_thread(int id)
5049

5150
std::cout << my_name << " Started\n";
5251

53-
ucx = nixlUcxEngine::create(init_params).release();
52+
auto ucx = nixlUcxEngine::create(init_params).release();
5453

55-
if (!USE_PTHREAD) ((nixlUcxEngine *)ucx)->progress();
54+
if (!USE_PTHREAD) ucx->progress();
5655

5756
ucx->getConnInfo(conn_info[id]);
5857

@@ -71,7 +70,7 @@ void test_thread(int id)
7170

7271
done[id] = true;
7372
while(!done[!id])
74-
if (!USE_PTHREAD && id) ((nixlUcxEngine *)ucx)->progress();
73+
if (!USE_PTHREAD && id) ucx->progress();
7574

7675
std::cout << "Thread passed with id " << id << "\n";
7776

@@ -83,7 +82,7 @@ void test_thread(int id)
8382
//wait for other
8483
while(!disconnect[!id]);
8584

86-
if (!USE_PTHREAD) ((nixlUcxEngine *)ucx)->progress();
85+
if (!USE_PTHREAD) ucx->progress();
8786

8887
std::cout << "Thread disconnected with id " << id << "\n";
8988

test/unit/plugins/ucx/ucx_backend_test.cpp

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ class testHndlIterator {
106106
}
107107
};
108108

109-
110-
nixlBackendEngine *createEngine(std::string name, bool p_thread)
111-
{
112-
nixlBackendEngine *ucx;
109+
nixlUcxEngine *
110+
createEngine(std::string name, bool p_thread) {
113111
nixlBackendInitParams init;
114112
nixl_b_params_t custom_params;
115113

@@ -119,7 +117,7 @@ nixlBackendEngine *createEngine(std::string name, bool p_thread)
119117
init.customParams = &custom_params;
120118
init.type = "UCX";
121119

122-
ucx = nixlUcxEngine::create(init).release();
120+
auto ucx = nixlUcxEngine::create(init).release();
123121
assert(!ucx->getInitErr());
124122
if (ucx->getInitErr()) {
125123
std::cout << "Failed to initialize worker1" << std::endl;
@@ -129,8 +127,8 @@ nixlBackendEngine *createEngine(std::string name, bool p_thread)
129127
return ucx;
130128
}
131129

132-
void releaseEngine(nixlBackendEngine *ucx)
133-
{
130+
void
131+
releaseEngine(nixlUcxEngine *ucx) {
134132
delete ucx;
135133
}
136134

@@ -283,8 +281,8 @@ void *releaseValidationPtr(nixl_mem_t mem_type, void *addr)
283281
return NULL;
284282
}
285283

286-
void allocateWrongGPUTest(nixlBackendEngine* ucx, int dev_id)
287-
{
284+
void
285+
allocateWrongGPUTest(nixlUcxEngine *ucx, int dev_id) {
288286
nixlBlobDesc desc;
289287
nixlBackendMD* md;
290288
void* buf;
@@ -301,9 +299,13 @@ void allocateWrongGPUTest(nixlBackendEngine* ucx, int dev_id)
301299
releaseBuffer(VRAM_SEG, dev_id, buf);
302300
}
303301

304-
void allocateAndRegister(nixlBackendEngine *ucx, int dev_id, nixl_mem_t mem_type,
305-
void* &addr, size_t len, nixlBackendMD* &md)
306-
{
302+
void
303+
allocateAndRegister(nixlUcxEngine *ucx,
304+
int dev_id,
305+
nixl_mem_t mem_type,
306+
void *&addr,
307+
size_t len,
308+
nixlBackendMD *&md) {
307309
nixlBlobDesc desc;
308310

309311
allocateBuffer(mem_type, dev_id, len, addr);
@@ -317,17 +319,25 @@ void allocateAndRegister(nixlBackendEngine *ucx, int dev_id, nixl_mem_t mem_type
317319
assert(ret == NIXL_SUCCESS);
318320
}
319321

320-
void deallocateAndDeregister(nixlBackendEngine *ucx, int dev_id, nixl_mem_t mem_type,
321-
void* &addr, nixlBackendMD* &md)
322-
{
322+
void
323+
deallocateAndDeregister(nixlUcxEngine *ucx,
324+
int dev_id,
325+
nixl_mem_t mem_type,
326+
void *&addr,
327+
nixlBackendMD *&md) {
323328
ucx->deregisterMem(md);
324329
releaseBuffer(mem_type, dev_id, addr);
325330
}
326331

327-
void loadRemote(nixlBackendEngine *ucx, int dev_id, std::string agent,
328-
nixl_mem_t mem_type, void *addr, size_t len,
329-
nixlBackendMD* &lmd, nixlBackendMD* &rmd)
330-
{
332+
void
333+
loadRemote(nixlUcxEngine *ucx,
334+
int dev_id,
335+
std::string agent,
336+
nixl_mem_t mem_type,
337+
void *addr,
338+
size_t len,
339+
nixlBackendMD *&lmd,
340+
nixlBackendMD *&rmd) {
331341
nixlBlobDesc info;
332342
info.addr = (uintptr_t) addr;
333343
info.len = len;
@@ -367,15 +377,18 @@ static string op2string(nixl_xfer_op_t op, bool hasNotif)
367377
return string("ERR-OP");
368378
}
369379

370-
371-
void performTransfer(nixlBackendEngine *ucx1, nixlBackendEngine *ucx2,
372-
nixl_meta_dlist_t &req_src_descs,
373-
nixl_meta_dlist_t &req_dst_descs,
374-
void* addr1, void* addr2, size_t len,
375-
nixl_xfer_op_t op,
376-
testHndlIterator &hiter,
377-
bool progress, bool use_notif)
378-
{
380+
void
381+
performTransfer(nixlUcxEngine *ucx1,
382+
nixlUcxEngine *ucx2,
383+
nixl_meta_dlist_t &req_src_descs,
384+
nixl_meta_dlist_t &req_dst_descs,
385+
void *addr1,
386+
void *addr2,
387+
size_t len,
388+
nixl_xfer_op_t op,
389+
testHndlIterator &hiter,
390+
bool progress,
391+
bool use_notif) {
379392
int ret2;
380393
nixl_status_t ret3;
381394
void *chkptr1, *chkptr2;
@@ -414,7 +427,7 @@ void performTransfer(nixlBackendEngine *ucx1, nixlBackendEngine *ucx2,
414427
while(ret3 == NIXL_IN_PROG) {
415428
ret3 = ucx1->checkXfer(handle);
416429
if(progress){
417-
((nixlUcxEngine *)ucx2)->progress();
430+
ucx2->progress();
418431
}
419432
assert( ret3 == NIXL_SUCCESS || ret3 == NIXL_IN_PROG);
420433
}
@@ -436,7 +449,7 @@ void performTransfer(nixlBackendEngine *ucx1, nixlBackendEngine *ucx2,
436449
ret3 = ucx2->getNotifs(target_notifs);
437450
ret2 = target_notifs.size();
438451
if(progress){
439-
((nixlUcxEngine *)ucx1)->progress();
452+
ucx1->progress();
440453
}
441454
assert(ret3 == NIXL_SUCCESS);
442455
}
@@ -465,8 +478,8 @@ void performTransfer(nixlBackendEngine *ucx1, nixlBackendEngine *ucx2,
465478
cout << "OK" << endl;
466479
}
467480

468-
void test_intra_agent_transfer(bool p_thread, nixlBackendEngine *ucx, nixl_mem_t mem_type)
469-
{
481+
void
482+
test_intra_agent_transfer(bool p_thread, nixlUcxEngine *ucx, nixl_mem_t mem_type) {
470483

471484
std::cout << std::endl << std::endl;
472485
std::cout << "****************************************************" << std::endl;
@@ -541,10 +554,15 @@ void test_intra_agent_transfer(bool p_thread, nixlBackendEngine *ucx, nixl_mem_t
541554
ucx->disconnect(agent1);
542555
}
543556

544-
void test_inter_agent_transfer(bool p_thread, bool reuse_hndl,
545-
nixlBackendEngine *ucx1, nixl_mem_t src_mem_type, int src_dev_id,
546-
nixlBackendEngine *ucx2, nixl_mem_t dst_mem_type, int dst_dev_id)
547-
{
557+
void
558+
test_inter_agent_transfer(bool p_thread,
559+
bool reuse_hndl,
560+
nixlUcxEngine *ucx1,
561+
nixl_mem_t src_mem_type,
562+
int src_dev_id,
563+
nixlUcxEngine *ucx2,
564+
nixl_mem_t dst_mem_type,
565+
int dst_dev_id) {
548566
int ret;
549567
int iter = 10;
550568

@@ -674,7 +692,7 @@ void test_inter_agent_transfer(bool p_thread, bool reuse_hndl,
674692
int main()
675693
{
676694
bool thread_on[2] = {false, true};
677-
nixlBackendEngine *ucx[2][2] = { 0 };
695+
nixlUcxEngine *ucx[2][2] = {0};
678696

679697
// Allocate UCX engines
680698
for(int i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)