Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rdma-mwe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
rdma-mwe
Commits
8761063e
Commit
8761063e
authored
Feb 14, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example: avoid GCC warnings
parent
5baa2247
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
39 deletions
+46
-39
example/rdma_test.c
example/rdma_test.c
+46
-39
No files found.
example/rdma_test.c
View file @
8761063e
...
...
@@ -42,19 +42,21 @@ int main(int argc, char *argv[]) {
struct
timespec
timestamps
[
2
];
pthread_t
serve_mr_td
;
ssize_t
read_count
;
size_t
remote_host_size
;
size_t
device_name_size
;
long
elapsed_time
;
long
max_time
;
int
allocated_size
;
int
server_socket
;
int
poll_result
;
int
opt
;
char
*
remote_host
;
char
*
device_name
;
char
mode
;
char
in_mr_fc
;
char
mode
;
bool
bool_result
;
bool
is_client
;
bool
result
;
// Preallocate some variables
allocated_size
=
16384
*
sizeof
(
char
);
...
...
@@ -64,8 +66,8 @@ int main(int argc, char *argv[]) {
is_client
=
false
;
srand48
(
getpid
()
*
time
(
NULL
));
result
=
common_hashtable_initialize
(
&
mr_mgr
,
33
);
if
(
!
result
)
{
bool_
result
=
common_hashtable_initialize
(
&
mr_mgr
,
33
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Creation of the MR manager failed
\n
"
);
return
-
1
;
}
...
...
@@ -117,8 +119,8 @@ int main(int argc, char *argv[]) {
/******************************
***** RDMA initialization ****
******************************/
result
=
capulet_rdma_ib_initialize_device
(
&
rdma_ctx
,
device_name
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_initialize_device
(
&
rdma_ctx
,
device_name
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Device initialization failed
\n
"
);
return
-
1
;
}
...
...
@@ -131,20 +133,20 @@ int main(int argc, char *argv[]) {
return
-
1
;
}
result
=
common_hashtable_insert
(
&
mr_mgr
,
"in"
,
(
void
*
)
in_mr
);
if
(
!
result
)
{
bool_
result
=
common_hashtable_insert
(
&
mr_mgr
,
"in"
,
(
void
*
)
in_mr
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Adding MR to hashtable failed
\n
"
);
return
-
1
;
}
result
=
common_hashtable_insert
(
&
mr_mgr
,
"out"
,
(
void
*
)
out_mr
);
if
(
!
result
)
{
bool_
result
=
common_hashtable_insert
(
&
mr_mgr
,
"out"
,
(
void
*
)
out_mr
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Adding MR to hashtable failed
\n
"
);
return
-
1
;
}
result
=
capulet_rdma_ib_initialize_qp
(
&
rdma_ctx
,
IBV_ACCESS_LOCAL_WRITE
|
IBV_ACCESS_REMOTE_READ
|
IBV_ACCESS_REMOTE_WRITE
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_initialize_qp
(
&
rdma_ctx
,
IBV_ACCESS_LOCAL_WRITE
|
IBV_ACCESS_REMOTE_READ
|
IBV_ACCESS_REMOTE_WRITE
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Queue Pair initialization failed
\n
"
);
return
-
1
;
}
...
...
@@ -159,8 +161,8 @@ int main(int argc, char *argv[]) {
return
-
1
;
}
result
=
capulet_rdma_ib_fill_base_udp
(
&
rdma_ctx
,
udp_ctx
->
local
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_fill_base_udp
(
&
rdma_ctx
,
udp_ctx
->
local
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Query port failed
\n
"
);
return
-
1
;
}
...
...
@@ -180,8 +182,8 @@ int main(int argc, char *argv[]) {
capulet_net_udp_dump_qp_packet
(
udp_ctx
->
remote
);
result
=
capulet_rdma_ib_set_peer_from_udp
(
&
rdma_ctx
,
udp_ctx
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_set_peer_from_udp
(
&
rdma_ctx
,
udp_ctx
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Setting state to RTS failed
\n
"
);
return
-
1
;
}
...
...
@@ -191,19 +193,24 @@ int main(int argc, char *argv[]) {
******** Read or wait ********
******************************/
if
(
is_client
)
{
read
(
STDIN_FILENO
,
(
char
*
)
in_mr
->
addr
,
allocated_size
);
read
_count
=
read
(
STDIN_FILENO
,
(
char
*
)
in_mr
->
addr
,
allocated_size
);
}
else
{
read
(
STDIN_FILENO
,
(
char
*
)
out_mr
->
addr
,
allocated_size
);
read_count
=
read
(
STDIN_FILENO
,
(
char
*
)
out_mr
->
addr
,
allocated_size
);
}
if
(
read_count
==
-
1
)
{
perror
(
"Reading file failed
\n
"
);
return
-
1
;
}
result
=
capulet_rdma_ib_post_recv
(
&
rdma_ctx
,
in_mr
,
allocated_size
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_post_recv
(
&
rdma_ctx
,
in_mr
,
allocated_size
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Posting Recv (in) failed
\n
"
);
return
-
1
;
}
result
=
capulet_rdma_ib_post_recv
(
&
rdma_ctx
,
out_mr
,
allocated_size
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_post_recv
(
&
rdma_ctx
,
out_mr
,
allocated_size
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Posting Recv (out) failed
\n
"
);
return
-
1
;
}
...
...
@@ -214,26 +221,26 @@ int main(int argc, char *argv[]) {
pthread_create
(
&
serve_mr_td
,
NULL
,
*
serve_mr_td_fn
,
(
void
*
)
&
serve_mr_td_ctx
);
}
else
{
result
=
capulet_net_udp_query_mr
(
server_socket
,
server_infos
,
"in"
,
&
in_info_packet
);
if
(
!
result
||
(
strcmp
(
in_info_packet
.
name
,
"in"
)
!=
0
))
{
bool_
result
=
capulet_net_udp_query_mr
(
server_socket
,
server_infos
,
"in"
,
&
in_info_packet
);
if
(
!
bool_
result
||
(
strcmp
(
in_info_packet
.
name
,
"in"
)
!=
0
))
{
fprintf
(
stderr
,
"Querying MR (in) from server failed
\n
"
);
return
-
1
;
}
result
=
capulet_net_udp_query_mr
(
server_socket
,
server_infos
,
"out"
,
&
out_info_packet
);
if
(
!
result
||
(
strcmp
(
out_info_packet
.
name
,
"out"
)
!=
0
))
{
bool_
result
=
capulet_net_udp_query_mr
(
server_socket
,
server_infos
,
"out"
,
&
out_info_packet
);
if
(
!
bool_
result
||
(
strcmp
(
out_info_packet
.
name
,
"out"
)
!=
0
))
{
fprintf
(
stderr
,
"Querying MR (out) from server failed
\n
"
);
return
-
1
;
}
result
=
capulet_rdma_ib_post_send
(
&
rdma_ctx
,
IBV_WR_RDMA_READ
,
out_mr
,
allocated_size
,
&
out_info_packet
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_post_send
(
&
rdma_ctx
,
IBV_WR_RDMA_READ
,
out_mr
,
allocated_size
,
&
out_info_packet
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Sending Read failed
\n
"
);
return
-
1
;
}
result
=
capulet_rdma_ib_post_send
(
&
rdma_ctx
,
IBV_WR_RDMA_WRITE
,
in_mr
,
allocated_size
,
&
in_info_packet
);
if
(
!
result
)
{
bool_
result
=
capulet_rdma_ib_post_send
(
&
rdma_ctx
,
IBV_WR_RDMA_WRITE
,
in_mr
,
allocated_size
,
&
in_info_packet
);
if
(
!
bool_
result
)
{
fprintf
(
stderr
,
"Sending Write failed
\n
"
);
return
-
1
;
}
...
...
@@ -244,11 +251,11 @@ int main(int argc, char *argv[]) {
******************************/
if
(
is_client
)
{
do
{
result
=
ibv_poll_cq
(
rdma_ctx
.
send_cq
,
1
,
&
poll_wc
);
poll_
result
=
ibv_poll_cq
(
rdma_ctx
.
send_cq
,
1
,
&
poll_wc
);
usleep
(
100
);
}
while
(
result
==
0
);
}
while
(
poll_
result
==
0
);
if
(
result
>
0
&&
poll_wc
.
status
==
IBV_WC_SUCCESS
)
{
if
(
poll_
result
>
0
&&
poll_wc
.
status
==
IBV_WC_SUCCESS
)
{
if
(
is_client
)
{
printf
(
"%s
\n
"
,
(
char
*
)
out_mr
->
addr
);
}
...
...
@@ -282,20 +289,20 @@ int main(int argc, char *argv[]) {
// Wait for Send
capulet_rdma_ib_post_send
(
&
rdma_ctx
,
IBV_WR_SEND
,
out_mr
,
allocated_size
,
NULL
);
do
{
result
=
ibv_poll_cq
(
rdma_ctx
.
send_cq
,
1
,
&
poll_wc
);
}
while
(
result
==
0
);
poll_
result
=
ibv_poll_cq
(
rdma_ctx
.
send_cq
,
1
,
&
poll_wc
);
}
while
(
poll_
result
==
0
);
if
(
result
<
0
||
poll_wc
.
status
!=
IBV_WC_SUCCESS
)
{
if
(
poll_
result
<
0
||
poll_wc
.
status
!=
IBV_WC_SUCCESS
)
{
printf
(
"WR %lu failed: %s (%d)
\n
"
,
poll_wc
.
wr_id
,
ibv_wc_status_str
(
poll_wc
.
status
),
poll_wc
.
vendor_err
);
return
-
1
;
}
// Wait for Recv
do
{
result
=
ibv_poll_cq
(
rdma_ctx
.
recv_cq
,
1
,
&
poll_wc
);
}
while
(
result
==
0
);
poll_
result
=
ibv_poll_cq
(
rdma_ctx
.
recv_cq
,
1
,
&
poll_wc
);
}
while
(
poll_
result
==
0
);
if
(
result
<
0
||
poll_wc
.
status
!=
IBV_WC_SUCCESS
)
{
if
(
poll_
result
<
0
||
poll_wc
.
status
!=
IBV_WC_SUCCESS
)
{
printf
(
"WR %lu failed: %s (%d)
\n
"
,
poll_wc
.
wr_id
,
ibv_wc_status_str
(
poll_wc
.
status
),
poll_wc
.
vendor_err
);
return
-
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment