Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
i4
manycore
emper-io-eval
Commits
05235b7c
Commit
05235b7c
authored
Nov 25, 2021
by
Florian Fischer
Browse files
clients/io_uring: replace cpp latch with pthread_barrier_t
parent
932d61ae
Pipeline
#72814
failed with stage
in 1 minute and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
clients/io_uring/client.cpp
View file @
05235b7c
...
...
@@ -2,6 +2,7 @@
// Copyright © 2021 Florian Fischer
#include <liburing.h>
#include <netdb.h>
#include <pthread.h>
#include <sys/socket.h>
#include <sys/types.h>
...
...
@@ -13,14 +14,6 @@
#include <thread>
#include <vector>
#include "config.h"
#ifdef CPP_HAS_LATCH_H
#include <latch>
#else
#include <experimental/latch>
#endif
#define DIE_MSG(...) \
do { \
std::cout << __VA_ARGS__ << std::endl; \
...
...
@@ -66,7 +59,7 @@ class Client {
std
::
atomic
<
bool
>
quit
=
false
;
std
::
latch
connectBarrier
;
pthread_barrier_t
connectBarrier
;
public:
Client
(
const
std
::
string
&
host
,
const
std
::
string
&
port
,
unsigned
connections
,
unsigned
time
,
...
...
@@ -125,10 +118,7 @@ class Connection {
Client
::
Client
(
const
std
::
string
&
host
,
const
std
::
string
&
port
,
unsigned
connections
,
unsigned
time
,
unsigned
iterations
,
unsigned
_workerCount
,
unsigned
echoSize
)
:
iterations
(
iterations
),
workerCount
(
std
::
min
(
_workerCount
,
connections
)),
echoSize
(
echoSize
),
connectBarrier
(
workerCount
+
1
)
{
:
iterations
(
iterations
),
workerCount
(
std
::
min
(
_workerCount
,
connections
)),
echoSize
(
echoSize
)
{
std
::
cout
<<
"[global]"
<<
std
::
endl
;
std
::
cout
<<
"clients = "
<<
connections
<<
std
::
endl
;
std
::
cout
<<
"size = "
<<
echoSize
<<
std
::
endl
;
...
...
@@ -136,6 +126,9 @@ Client::Client(const std::string& host, const std::string& port, unsigned connec
std
::
cout
<<
"iterations = "
<<
iterations
<<
std
::
endl
;
server
=
getFirstAddrInfo
(
host
,
port
);
int
res
=
pthread_barrier_init
(
&
connectBarrier
,
nullptr
,
workerCount
+
1
);
if
(
res
)
DIE_MSG_ERRNO
(
"pthread_barrier_init failed"
);
workers
=
new
Worker
*
[
workerCount
];
for
(
unsigned
i
=
0
;
i
<
workerCount
;
++
i
)
{
unsigned
workerConnections
=
connections
/
workerCount
;
...
...
@@ -148,7 +141,7 @@ Client::Client(const std::string& host, const std::string& port, unsigned connec
workers
[
i
]
=
new
Worker
(
*
this
,
i
,
workerConnections
);
}
connectBarrier
.
arrive_and_wait
(
);
pthread_barrier_wait
(
&
connectBarrier
);
if
(
time
)
{
std
::
jthread
([
this
,
time
]
{
...
...
@@ -168,6 +161,8 @@ Client::~Client() {
}
std
::
cout
<<
"total_iterations = "
<<
echos
<<
std
::
endl
;
delete
[]
workers
;
pthread_barrier_destroy
(
&
connectBarrier
);
}
Worker
::
Worker
(
Client
&
client
,
unsigned
id
,
unsigned
connectionCount
)
...
...
@@ -198,7 +193,7 @@ Worker::Worker(Client& client, unsigned id, unsigned connectionCount)
connected
+=
count
;
}
this
->
client
.
connectBarrier
.
arrive_and_wait
(
);
pthread_barrier_wait
(
&
this
->
client
.
connectBarrier
);
for
(
unsigned
i
=
0
;
i
<
this
->
connectionCount
;
++
i
)
this
->
connections
[
i
]
->
prepSend
();
...
...
clients/io_uring/meson.build
View file @
05235b7c
...
...
@@ -19,15 +19,6 @@ if not uring_dep.found()
endif
dependencies = [thread_dep, uring_dep]
conf_data = configuration_data()
cpp_compiler = meson.get_compiler('cpp')
if cpp_compiler.has_header('latch')
conf_data.set('CPP_HAS_LATCH_H', true)
endif
config_header = configure_file(output: 'config.h', configuration: conf_data)
client = executable(
'client',
'client.cpp',
...
...
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