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
70ffc288
Commit
70ffc288
authored
Jan 30, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example: add argument for device name
parent
b26ab9e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
13 deletions
+33
-13
README.md
README.md
+4
-5
example/rdma_standalone.c
example/rdma_standalone.c
+29
-8
No files found.
README.md
View file @
70ffc288
...
...
@@ -4,31 +4,30 @@ Minimal working examples for RDMA: standalone server and client and library for
## Configuring an RDMA interface
In order to run this RDMA example, you will need to create a RDMA interface on two virtual machines:
In order to run this RDMA example, you will need to create a RDMA interface on two virtual machines.
For instance, to use RoCE (RDMA over Converged Ethernet) on interface
`enp1s0`
:
```
bash
modprobe rdma_rxe
rdma
link
add rxe0
type
rxe netdev enp1s0
rdma
link
show
mkdir
-p
/sys/kernel/config/rdma_cm/rxe0
```
## Standalone server and client
The provided
`rdma_standalone`
example allows reading the memory of one computer from another one.
On one machine, run the server program, which will read content to be put in the shared memory from STDIN:
```
bash
make
install
rdma_standalone < README.md
rdma_standalone
-d
rxe0
< README.md
```
The other machine will act as a client, so we need to pass it the IP address of the server:
```
bash
make
install
rdma_standalone
-c
192.168.16.10 < Makefile
rdma_standalone
-
d
rxe0
-
c
192.168.16.10 < Makefile
```
The client should (almost) immediately display the content of
`README.md`
, and the server the content of
`Makefile`
.
...
...
example/rdma_standalone.c
View file @
70ffc288
...
...
@@ -38,13 +38,22 @@ int main(int argc, char *argv[]) {
pthread_t
serve_mr_td
;
struct
ServeMrThreadContext
serve_mr_td_ctx
;
size_t
remote_host_size
;
size_t
device_name_size
;
int
allocated_size
;
int
server_socket
;
char
remote_host
[
16
];
int
opt
;
char
*
remote_host
;
char
*
device_name
;
char
in_mr_fc
;
bool
is_client
;
bool
result
;
int
allocated_size
=
16384
*
sizeof
(
char
);
bool
is_client
=
false
;
// Preallocate some variables
allocated_size
=
16384
*
sizeof
(
char
);
remote_host
=
NULL
;
device_name
=
NULL
;
is_client
=
false
;
srand48
(
getpid
()
*
time
(
NULL
));
result
=
common_hashtable_initialize
(
&
mr_mgr
,
33
);
...
...
@@ -56,12 +65,24 @@ int main(int argc, char *argv[]) {
/******************************
**** Arguments processing ****
******************************/
while
((
opt
=
getopt
(
argc
,
argv
,
"c:d:"
))
!=
-
1
)
{
// Detect if a server was given; if any, act as a client
if
(
argc
>=
3
)
{
if
(
strcmp
(
argv
[
1
],
"-c"
)
==
0
)
{
strcpy
((
void
*
)
remote_host
,
(
void
*
)
argv
[
2
]);
if
(
opt
==
'c'
)
{
remote_host_size
=
strlen
(
optarg
)
+
1
;
remote_host
=
(
char
*
)
malloc
(
remote_host_size
*
sizeof
(
char
));
strcpy
(
remote_host
,
optarg
);
is_client
=
true
;
}
else
if
(
opt
==
'd'
)
{
device_name_size
=
strlen
(
optarg
)
+
1
;
device_name
=
(
char
*
)
malloc
(
device_name_size
*
sizeof
(
char
));
strcpy
(
device_name
,
optarg
);
}
}
if
(
device_name
==
NULL
)
{
fprintf
(
stderr
,
"Device name is mandatory: use option `-d`
\n
"
);
return
-
1
;
}
// Set up remote address
...
...
@@ -79,7 +100,7 @@ int main(int argc, char *argv[]) {
/******************************
***** RDMA initialization ****
******************************/
result
=
capulet_rdma_ib_initialize_device
(
&
rdma_ctx
,
"rxe0"
);
result
=
capulet_rdma_ib_initialize_device
(
&
rdma_ctx
,
device_name
);
if
(
!
result
)
{
fprintf
(
stderr
,
"Device initialization failed
\n
"
);
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