Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MojitOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sepia-pub
MojitOS
Commits
23717da5
Commit
23717da5
authored
5 years ago
by
Georges Da Costa
Browse files
Options
Downloads
Patches
Plain Diff
Corrects a bug concerning RAPL column names
parent
b1a951a9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mojitos.c
+7
-4
7 additions, 4 deletions
mojitos.c
rapl.c
+39
-20
39 additions, 20 deletions
rapl.c
rapl.h
+6
-5
6 additions, 5 deletions
rapl.h
with
52 additions
and
29 deletions
mojitos.c
+
7
−
4
View file @
23717da5
...
@@ -217,7 +217,7 @@ int main(int argc, char **argv) {
...
@@ -217,7 +217,7 @@ int main(int argc, char **argv) {
if
(
rapl_mode
==
0
)
{
if
(
rapl_mode
==
0
)
{
rapl
=
init_rapl
(
nbzones
,
rapl_zones
);
rapl
=
init_rapl
(
nbzones
,
rapl_zones
);
// prepare rapl data stores
// prepare rapl data stores
rapl_size
=
rapl
->
nb
packages
*
rapl
->
nbzones
*
sizeof
(
uint64_t
);
rapl_size
=
rapl
->
nb
*
sizeof
(
uint64_t
);
//rapl_values = malloc(rapl_size);
//rapl_values = malloc(rapl_size);
rapl_values
=
calloc
(
sizeof
(
char
),
rapl_size
);
rapl_values
=
calloc
(
sizeof
(
char
),
rapl_size
);
//tmp_rapl_values = malloc(rapl_size);
//tmp_rapl_values = malloc(rapl_size);
...
@@ -250,8 +250,8 @@ int main(int argc, char **argv) {
...
@@ -250,8 +250,8 @@ int main(int argc, char **argv) {
fprintf
(
output
,
"irxp irxb itxp itxb "
);
fprintf
(
output
,
"irxp irxb itxp itxb "
);
if
(
rapl_mode
==
0
)
if
(
rapl_mode
==
0
)
for
(
int
r
=
0
;
r
<
rapl
->
nb
packages
*
rapl
->
nbzones
;
r
++
)
for
(
int
r
=
0
;
r
<
rapl
->
nb
;
r
++
)
fprintf
(
output
,
"%s
%u
"
,
rapl
->
names
[
r
]
,
(
unsigned
int
)
r
/
rapl
->
nbzones
);
fprintf
(
output
,
"%s "
,
rapl
->
names
[
r
]);
if
(
load_mode
==
0
)
if
(
load_mode
==
0
)
fprintf
(
output
,
"user nice system idle iowait irq softirq steal guest guest_nice "
);
fprintf
(
output
,
"user nice system idle iowait irq softirq steal guest guest_nice "
);
...
@@ -322,7 +322,7 @@ int main(int argc, char **argv) {
...
@@ -322,7 +322,7 @@ int main(int argc, char **argv) {
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
fprintf
(
output
,
"%lld "
,
tmp_infiniband_values
[
i
]
-
infiniband_values
[
i
]);
fprintf
(
output
,
"%lld "
,
tmp_infiniband_values
[
i
]
-
infiniband_values
[
i
]);
if
(
rapl_mode
==
0
)
if
(
rapl_mode
==
0
)
for
(
int
r
=
0
;
r
<
rapl
->
nb
packages
*
rapl
->
nbzones
;
r
++
)
for
(
int
r
=
0
;
r
<
rapl
->
nb
;
r
++
)
fprintf
(
output
,
"%ld "
,
tmp_rapl_values
[
r
]
-
rapl_values
[
r
]);
fprintf
(
output
,
"%ld "
,
tmp_rapl_values
[
r
]
-
rapl_values
[
r
]);
if
(
load_mode
==
0
)
if
(
load_mode
==
0
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
...
@@ -359,6 +359,9 @@ int main(int argc, char **argv) {
...
@@ -359,6 +359,9 @@ int main(int argc, char **argv) {
if
(
perf_mode
==
0
){
if
(
perf_mode
==
0
){
clean_counters
(
fd
);
clean_counters
(
fd
);
free
(
counter_values
);
free
(
counter_values
);
free
(
perf_type
);
free
(
perf_key
);
free
(
perf_indexes
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
rapl.c
+
39
−
20
View file @
23717da5
...
@@ -28,30 +28,47 @@
...
@@ -28,30 +28,47 @@
_rapl_t
*
init_rapl
(
const
uint32_t
nb_zones
,
const
int
*
rapl_zones
)
{
_rapl_t
*
init_rapl
(
const
uint32_t
nb_zones
,
const
int
*
rapl_zones
)
{
// get number of processor sockets
// get number of processor sockets
_rapl_t
*
rapl
=
malloc
(
sizeof
(
struct
_rapl_t
));
_rapl_t
*
rapl
=
malloc
(
sizeof
(
struct
_rapl_t
));
rapl
->
nbzones
=
nb_zones
;
rapl
->
nb
=
0
;
rapl
->
zones
=
rapl_zones
;
rapl
->
packages
=
NULL
;
rapl
->
zones
=
NULL
;
rapl
->
nb
package
s
=
powercap_rapl_get_num_packages
();
rapl
->
nb
_pkg
s
=
powercap_rapl_get_num_packages
();
if
(
rapl
->
nb
package
s
==
0
)
{
if
(
rapl
->
nb
_pkg
s
==
0
)
{
perror
(
"no packages found (maybe the kernel module isn't loaded?)"
);
perror
(
"no packages found (maybe the kernel module isn't loaded?)"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
rapl
->
pkgs
=
malloc
(
rapl
->
nb
package
s
*
sizeof
(
powercap_rapl_pkg
));
rapl
->
pkgs
=
malloc
(
rapl
->
nb
_pkg
s
*
sizeof
(
powercap_rapl_pkg
));
for
(
int
package
=
0
;
package
<
rapl
->
nb
package
s
;
package
++
)
for
(
int
package
=
0
;
package
<
rapl
->
nb
_pkg
s
;
package
++
)
if
(
powercap_rapl_init
(
package
,
&
rapl
->
pkgs
[
package
],
0
))
{
if
(
powercap_rapl_init
(
package
,
&
rapl
->
pkgs
[
package
],
0
))
{
perror
(
"powercap_rapl_init, check access (root needed ?)"
);
perror
(
"powercap_rapl_init, check access (root needed ?)"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
rapl
->
names
=
malloc
(
sizeof
(
char
*
)
*
(
rapl
->
nbzones
)
*
(
rapl
->
nbpackages
)
);
printf
(
"%d %d
\n\n
"
,
nb_zones
,
rapl
->
nb_pkgs
);
rapl
->
names
=
NULL
;
char
_name
[
MAX_LEN_NAME
+
1
];
char
_name
[
MAX_LEN_NAME
+
1
];
char
_name2
[
MAX_LEN_NAME
+
10
];
for
(
int
package
=
0
;
package
<
rapl
->
nb
package
s
;
package
++
)
{
for
(
unsigned
int
package
=
0
;
package
<
rapl
->
nb
_pkg
s
;
package
++
)
{
for
(
int
zone
=
0
;
zone
<
rapl
->
nbzones
;
zone
++
)
{
for
(
unsigned
int
zone
=
0
;
zone
<
nb
_
zones
;
zone
++
)
{
powercap_rapl_get_name
(
&
rapl
->
pkgs
[
package
],
rapl_zones
[
zone
],
int
a
=
powercap_rapl_get_name
(
&
rapl
->
pkgs
[
package
],
rapl_zones
[
zone
],
_name
,
MAX_LEN_NAME
);
_name
,
MAX_LEN_NAME
);
rapl
->
names
[
package
*
rapl
->
nbzones
+
zone
]
=
malloc
(
sizeof
(
char
)
*
(
strlen
(
_name
)
+
1
));
if
(
a
>
0
)
{
strcpy
(
rapl
->
names
[
package
*
rapl
->
nbzones
+
zone
],
_name
);
sprintf
(
_name2
,
"%s%u "
,
_name
,
package
);
rapl
->
nb
++
;
rapl
->
names
=
realloc
(
rapl
->
names
,
sizeof
(
char
*
)
*
rapl
->
nb
);
rapl
->
names
[
rapl
->
nb
-
1
]
=
malloc
(
sizeof
(
char
)
*
(
strlen
(
_name2
)
+
1
));
rapl
->
zones
=
realloc
(
rapl
->
zones
,
sizeof
(
uint32_t
)
*
rapl
->
nb
);
rapl
->
packages
=
realloc
(
rapl
->
packages
,
sizeof
(
uint32_t
)
*
rapl
->
nb
);
strcpy
(
rapl
->
names
[
rapl
->
nb
-
1
],
_name2
);
rapl
->
zones
[
rapl
->
nb
-
1
]
=
zone
;
rapl
->
packages
[
rapl
->
nb
-
1
]
=
package
;
}
printf
(
"%d %d %d %s
\n\n
"
,
a
,
package
,
zone
,
_name2
);
}
}
}
}
return
rapl
;
return
rapl
;
...
@@ -61,21 +78,23 @@ _rapl_t* init_rapl(const uint32_t nb_zones, const int *rapl_zones) {
...
@@ -61,21 +78,23 @@ _rapl_t* init_rapl(const uint32_t nb_zones, const int *rapl_zones) {
// values [zone + package *nbzones] microjoules
// values [zone + package *nbzones] microjoules
void
get_rapl
(
uint64_t
*
values
,
_rapl_t
*
rapl
)
{
void
get_rapl
(
uint64_t
*
values
,
_rapl_t
*
rapl
)
{
for
(
int
package
=
0
;
package
<
rapl
->
nbpackages
;
package
++
)
{
for
(
int
i
=
0
;
i
<
rapl
->
nb
;
i
++
)
{
for
(
int
zone
=
0
;
zone
<
rapl
->
nbzones
;
zone
++
)
{
powercap_rapl_get_energy_uj
(
&
rapl
->
pkgs
[
rapl
->
packages
[
i
]],
powercap_rapl_get_energy_uj
(
&
rapl
->
pkgs
[
package
],
rapl
->
zones
[
zone
],
&
values
[
package
*
rapl
->
nbzones
+
zone
]);
rapl
->
zones
[
i
],
}
&
values
[
i
]);
}
}
}
}
void
clean_rapl
(
_rapl_t
*
rapl
)
{
void
clean_rapl
(
_rapl_t
*
rapl
)
{
for
(
int
package
=
0
;
package
<
rapl
->
nb
package
s
;
package
++
)
{
for
(
int
package
=
0
;
package
<
rapl
->
nb
_pkg
s
;
package
++
)
if
(
powercap_rapl_destroy
(
&
rapl
->
pkgs
[
package
]))
if
(
powercap_rapl_destroy
(
&
rapl
->
pkgs
[
package
]))
perror
(
"powercap_rapl_destroy"
);
perror
(
"powercap_rapl_destroy"
);
for
(
int
zone
=
0
;
zone
<
rapl
->
nbzones
;
zone
++
)
for
(
int
elem
=
0
;
elem
<
rapl
->
nb
;
elem
++
)
free
(
rapl
->
names
[
package
*
rapl
->
nbzones
+
zone
]);
free
(
rapl
->
names
[
elem
]);
}
free
(
rapl
->
names
);
free
(
rapl
->
names
);
free
(
rapl
->
pkgs
);
free
(
rapl
->
pkgs
);
free
(
rapl
->
zones
);
free
(
rapl
->
packages
);
free
(
rapl
);
free
(
rapl
);
}
}
This diff is collapsed.
Click to expand it.
rapl.h
+
6
−
5
View file @
23717da5
...
@@ -22,14 +22,15 @@
...
@@ -22,14 +22,15 @@
struct
_rapl_t
{
struct
_rapl_t
{
powercap_rapl_pkg
*
pkgs
;
powercap_rapl_pkg
*
pkgs
;
uint32_t
nbpackages
;
uint32_t
nb_pkgs
;
uint32_t
nbzones
;
uint32_t
nb
;
char
**
names
;
char
**
names
;
const
int
*
zones
;
uint32_t
*
zones
;
uint32_t
*
packages
;
};
};
typedef
struct
_rapl_t
*
rapl_t
;
typedef
struct
_rapl_t
_rapl_t
;
typedef
struct
_rapl_t
_rapl_t
;
_rapl_t
*
init_rapl
(
const
uint32_t
nb_zones
,
const
int
*
rapl_zones
);
_rapl_t
*
init_rapl
(
const
uint32_t
nb_zones
,
const
int
*
rapl_zones
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment