Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG UE
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
Michael Black
OpenXG UE
Commits
ce6b8a41
Commit
ce6b8a41
authored
May 06, 2021
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhance cpu measurment implementation
parent
68eb3bd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
56 deletions
+71
-56
common/utils/telnetsrv/telnetsrv.c
common/utils/telnetsrv/telnetsrv.c
+1
-44
openair1/PHY/TOOLS/time_meas.c
openair1/PHY/TOOLS/time_meas.c
+46
-12
openair1/PHY/TOOLS/time_meas.h
openair1/PHY/TOOLS/time_meas.h
+24
-0
No files found.
common/utils/telnetsrv/telnetsrv.c
View file @
ce6b8a41
...
...
@@ -682,7 +682,6 @@ void run_telnetclt(void) {
pthread_setname_np
(
pthread_self
(),
"telnetclt"
);
set_sched
(
pthread_self
(),
0
,
telnetparams
.
priority
);
sock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
// FIELD *field[4];
if
(
sock
<
0
)
fprintf
(
stderr
,
"[TELNETSRV] Error %s on socket call
\n
"
,
strerror
(
errno
));
char
prompt
[
sizeof
(
TELNET_PROMPT_PREFIX
)
+
10
];
...
...
@@ -694,50 +693,17 @@ void run_telnetclt(void) {
name
.
sin_port
=
htons
((
unsigned
short
)(
telnetparams
.
listenport
));
if
(
connect
(
sock
,
(
void
*
)
&
name
,
sizeof
(
name
)))
fprintf
(
stderr
,
"[TELNETSRV] Error %s on connect call
\n
"
,
strerror
(
errno
));
// (void) initscr(); /* initialize the curses library */
// keypad(stdscr, TRUE); /* enable keyboard mapping */
// (void) nonl(); /* tell curses not to do NL->CR/NL on output */
// (void) cbreak(); /* take input chars one at a time, no wait for \n */
// (void) echo(); /* echo input - in color */
// WINDOW *inputw = newwin(10, 132, 0, 0);
// int row,col;
// getmaxyx(stdscr,row,col);
// field[0] = new_field((row-2)/2, col, 0, 0, 0, 0);
// field[1] = new_field((row-2)/2, col, (row-2)/2, 0, 0, 0);
// field[2] = new_field(1, col, row-2, 0, 0, 0);
// field[3] = NULL;
/* Set field options */
// field_opts_off(field[0], O_ACTIVE);
// field_opts_off(field[1], O_ACTIVE);
// set_field_back(field[0], A_UNDERLINE); /* Print a line for the option */
// field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */
/* Field is filled up */
// set_field_back(field[1], A_UNDERLINE);
// field_opts_off(field[1], O_AUTOSKIP);
/* Create the form and post it */
// FORM *my_form = new_form(field);
// post_form(my_form);
// refresh();
// echo();
struct
timeval
ts
;
ts
.
tv_sec
=
1
;
// 1 second
ts
.
tv_usec
=
0
;
while
(
1
)
{
// select setup
fd_set
fds
;
FD_ZERO
(
&
fds
);
FD_SET
(
sock
,
&
fds
);
FD_SET
(
STDIN_FILENO
,
&
fds
);
// wait for data
int
nready
=
select
(
sock
+
1
,
&
fds
,
(
fd_set
*
)
0
,
(
fd_set
*
)
0
,
&
ts
);
// mvprintw(row-2,0,"select: %i \n",nready);
if
(
nready
<
0
)
{
perror
(
"select. Error"
);
break
;
...
...
@@ -767,22 +733,13 @@ void run_telnetclt(void) {
char
*
inbuf
=
NULL
;
size_t
inlen
=
0
;
inlen
=
getline
(
&
inbuf
,
&
inlen
,
stdin
);
// mvprintw(row-1,0,inbuf);
if
(
inlen
>
0
)
{
if
(
send
(
sock
,
inbuf
,
inlen
,
0
)
<
0
)
break
;
}
free
(
inbuf
);
// refresh();
free
(
inbuf
);
}
}
/* nocbreak();
unpost_form(my_form);
free_form(my_form);
free_field(field[0]);
free_field(field[1]);
free_field(field[2]);
endwin();*/
close
(
sock
);
return
;
}
/* run_telnetclt */
...
...
openair1/PHY/TOOLS/time_meas.c
View file @
ce6b8a41
...
...
@@ -18,7 +18,7 @@
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#define _GNU_SOURCE
#include <stdio.h>
#include "time_meas.h"
#include <math.h>
...
...
@@ -26,6 +26,7 @@
#include <string.h>
#include "assertions.h"
#ifndef PHYSIM
#include <pthread.h>
#include "common/config/config_userapi.h"
#endif
// global var for openair performance profiler
...
...
@@ -35,7 +36,8 @@ double cpu_freq_GHz __attribute__ ((aligned(32)));
double
cpu_freq_GHz
__attribute__
((
aligned
(
32
)))
=
0
.
0
;
#ifndef PHYSIM
static
uint32_t
max_cpumeasur
;
time_stats_t
**
measur_table
;
static
time_stats_t
**
measur_table
;
notifiedFIFO_t
measur_fifo
;
#endif
double
get_cpu_freq_GHz
(
void
)
{
...
...
@@ -146,27 +148,59 @@ double get_time_meas_us(time_stats_t *ts)
int
register_meas
(
char
*
name
,
time_stats_t
*
dst_ts
)
{
{
for
(
int
i
=
0
;
i
<
max_cpumeasur
;
i
++
)
{
if
(
measur_table
[
i
]
==
NULL
)
{
measur_table
[
i
]
=
(
time_stats_t
*
)
malloc
(
sizeof
(
time_stats_t
));
memset
(
measur_table
[
i
]
,
0
,
sizeof
(
time_stats_t
));
measur_table
[
i
]
->
meas_name
=
strdup
(
name
);
measur_table
[
i
]
->
meas_index
=
i
;
if
(
measur_table
[
i
]
==
NULL
)
{
measur_table
[
i
]
=
(
time_stats_t
*
)
malloc
(
sizeof
(
time_stats_t
));
memset
(
measur_table
[
i
]
,
0
,
sizeof
(
time_stats_t
));
measur_table
[
i
]
->
meas_name
=
strdup
(
name
);
measur_table
[
i
]
->
meas_index
=
i
;
return
i
;
}
}
return
-
1
;
return
-
1
;
}
void
run_cpumeasur
(
void
)
{
struct
sched_param
schedp
;
pthread_setname_np
(
pthread_self
(),
"measur"
);
schedp
.
sched_priority
=
0
;
int
rt
=
pthread_setschedparam
(
pthread_self
(),
SCHED_IDLE
,
&
schedp
);
AssertFatal
(
rt
==
0
,
"couldn't set measur thread priority: %s
\n
"
,
strerror
(
errno
));
initNotifiedFIFO
(
&
measur_fifo
);
while
(
1
)
{
notifiedFIFO_elt_t
*
msg
=
pullNotifiedFIFO
(
&
measur_fifo
);
time_stats_msg_t
*
tsm
=
(
time_stats_msg_t
*
)
NotifiedFifoData
(
msg
);
switch
(
tsm
->
msgid
)
{
case
TIMESTAT_MSGID_START
:
measur_table
[
tsm
->
timestat_id
]
->
in
=
tsm
->
ts
;
(
measur_table
[
tsm
->
timestat_id
]
->
trials
)
++
;
break
;
case
TIMESTAT_MSGID_STOP
:
/// process duration is the difference between two clock points
measur_table
[
tsm
->
timestat_id
]
->
p_time
=
(
tsm
->
ts
-
measur_table
[
tsm
->
timestat_id
]
->
in
);
measur_table
[
tsm
->
timestat_id
]
->
diff
+=
measur_table
[
tsm
->
timestat_id
]
->
p_time
;
if
(
measur_table
[
tsm
->
timestat_id
]
->
p_time
>
measur_table
[
tsm
->
timestat_id
]
->
max
)
measur_table
[
tsm
->
timestat_id
]
->
max
=
measur_table
[
tsm
->
timestat_id
]
->
p_time
;
break
;
default:
break
;
}
delNotifiedFIFO_elt
(
msg
);
}
}
void
init_meas
(
void
)
{
pthread_t
thid
;
paramdef_t
cpumeasur_params
[]
=
CPUMEASUR_PARAMS_DESC
;
int
numparams
=
sizeof
(
cpumeasur_params
)
/
sizeof
(
paramdef_t
);
int
r
e
t
=
config_get
(
cpumeasur_params
,
numparams
,
CPUMEASUR_SECTION
);
AssertFatal
(
r
e
t
>=
0
,
"cpumeasur configuration couldn't be performed"
);
int
rt
=
config_get
(
cpumeasur_params
,
numparams
,
CPUMEASUR_SECTION
);
AssertFatal
(
rt
>=
0
,
"cpumeasur configuration couldn't be performed"
);
measur_table
=
calloc
(
max_cpumeasur
,
sizeof
(
time_stats_t
*
));
AssertFatal
(
measur_table
!=
NULL
,
"couldn't allocate %u cpu measurements entries
\n
"
,
max_cpumeasur
);
rt
=
pthread_create
(
&
thid
,
NULL
,
(
void
*
(
*
)(
void
*
))
run_cpumeasur
,
NULL
);
AssertFatal
(
rt
==
0
,
"couldn't create cpu measurment thread: %s
\n
"
,
strerror
(
errno
));
}
#endif
openair1/PHY/TOOLS/time_meas.h
View file @
ce6b8a41
...
...
@@ -31,6 +31,9 @@
#include <pthread.h>
#include <linux/kernel.h>
#include <linux/types.h>
#ifndef PHYSIM
#include "common/utils/threadPool/thread-pool.h"
#endif
// global var to enable openair performance profiler
extern
int
opp_enabled
;
extern
double
cpu_freq_GHz
__attribute__
((
aligned
(
32
)));;
...
...
@@ -58,6 +61,13 @@ typedef struct {
}
time_stats_t
;
#endif
#define TIMESTAT_MSGID_START 0
#define TIMESTAT_MSGID_STOP 1
typedef
struct
{
int
msgid
;
/*!< \brief message id, as defined by TIMESTAT_MSGID_X macros */
int
timestat_id
;
/*!< \brief points to the time_stats_t entry in cpumeas table */
OAI_CPUTIME_TYPE
ts
;
/*!< \brief time stamp */
}
time_stats_msg_t
;
static
inline
void
start_meas
(
time_stats_t
*
ts
)
__attribute__
((
always_inline
));
static
inline
void
stop_meas
(
time_stats_t
*
ts
)
__attribute__
((
always_inline
));
...
...
@@ -122,6 +132,20 @@ static inline void stop_meas(time_stats_t *ts) {
}
}
static
inline
void
send_meas
(
int
measur_idx
)
{
if
(
opp_enabled
)
{
extern
notifiedFIFO_t
measur_fifo
;
notifiedFIFO_elt_t
*
msg
=
newNotifiedFIFO_elt
(
sizeof
(
time_stats_msg_t
),
0
,
NULL
,
NULL
);
time_stats_msg_t
*
tsm
=
(
time_stats_msg_t
*
)
NotifiedFifoData
(
msg
);
tsm
->
ts
=
rdtsc_oai
();
pushNotifiedFIFO
(
&
measur_fifo
,
msg
);
}
}
static
inline
void
reset_meas
(
time_stats_t
*
ts
)
{
ts
->
in
=
0
;
ts
->
diff
=
0
;
...
...
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