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
856c5a6e
Commit
856c5a6e
authored
2 years ago
by
floreal.risso
Browse files
Options
Downloads
Patches
Plain Diff
auto config nvidia
parent
22721bfe
No related branches found
No related tags found
2 merge requests
!9
fix sensor example (doc)
,
!5
Add dev name to labels
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
configure.sh
+44
-35
44 additions, 35 deletions
configure.sh
makefile
+4
-2
4 additions, 2 deletions
makefile
with
48 additions
and
37 deletions
configure.sh
+
44
−
35
View file @
856c5a6e
...
...
@@ -4,12 +4,15 @@
# Copyright (C) 2023-2023 Georges Da Costa <georges.da-costa@irit.fr>
try
()
{
"
$@
"
||
die
"cannot
$*
"
;
}
die
()
{
yell
"
$*
"
;
exit
111
;
}
die
()
{
yell
"
$*
"
exit
111
}
yell
()
{
echo
"
$0
:
$*
"
>
&2
;
}
echo
()
{
printf
'%s\n'
"
$*
"
;
}
isnum
()
{
case
"
${
1
#[+-]
}
"
in
*
[!
0-9]
*
|
''
)
return
1
;;
*
[!
0-9]
*
|
''
)
return
1
;;
*
)
return
0
;;
esac
}
...
...
@@ -51,7 +54,7 @@ ls_sensors() {
ls
-1
*
.h |
grep
-xEv
"(
$hdr_blacklist
)
\.
h"
|
grep
-xE
"(
$hdr_whitelist
)
\.
h"
|
grep
-xE
"(
$hdr_whitelist
)
\.
h"
|
sed
's/\.h$//'
}
...
...
@@ -86,10 +89,10 @@ gen_sensors_h() {
printf
' int opt_idx = offset;\n'
for
sensor
in
$sensors
;
do
cat
<<-!
for
(
int i
=
0
;
i <
${
sensor
}
.nb_opt
;
i++
)
{
opts[opt_idx++]
=
${
sensor
}
_opt[i]
;
}
sensors[
(
*
nb_defined
)
++]
=
${
sensor
}
;
for
(
int i
=
0
;
i <
${
sensor
}
.nb_opt
;
i++
)
{
opts[opt_idx++]
=
${
sensor
}
_opt[i]
;
}
sensors[
(
*
nb_defined
)
++]
=
${
sensor
}
;
!
done
printf
' assert((offset + *nb_defined) <= len);\n'
...
...
@@ -117,6 +120,8 @@ detect_caps() {
if
[
-e
/usr/local/cuda/lib64
]
&&
[
-e
/usr/local/cuda/include
]
;
then
hdr_whitelist
=
"
${
hdr_whitelist
}
|nvidia_gpu"
NVML_LDFLAGS
=
"-L/usr/local/cuda/lib64 -lnvidia-ml"
NVML_IFLAGS
=
"-I/usr/local/cuda/include"
fi
vendor
=
$(
awk
'/vendor_id/ {print $3; exit}'
/proc/cpuinfo
)
...
...
@@ -140,7 +145,7 @@ detect_caps() {
}
case
$1
in
--all
|
-a
)
--all
|
-a
)
all
=
1
;;
esac
...
...
@@ -148,30 +153,33 @@ esac
[
"
$all
"
]
||
detect_caps
[
"
$all
"
]
||
while
[
"
$1
"
]
;
do
case
$1
in
--include
|
-i
)
shift
;
[
"
$1
"
]
||
usage
hdr_whitelist
=
"
${
hdr_whitelist
}
|
${
1
}
"
;;
--exclude
|
-e
)
shift
;
[
"
$1
"
]
||
usage
hdr_blacklist
=
"
${
hdr_blacklist
}
|
${
1
}
"
;;
--list-sensors
|
-l
)
ls_sensors
exit
0
;;
--unique
|
-u
)
shift
;
[
"
$1
"
]
||
usage
hdr_whitelist
=
$1
;;
--help
|
-h
)
usage
;;
esac
shift
done
while
[
"
$1
"
]
;
do
case
$1
in
--include
|
-i
)
shift
[
"
$1
"
]
||
usage
hdr_whitelist
=
"
${
hdr_whitelist
}
|
${
1
}
"
;;
--exclude
|
-e
)
shift
[
"
$1
"
]
||
usage
hdr_blacklist
=
"
${
hdr_blacklist
}
|
${
1
}
"
;;
--list-sensors
|
-l
)
ls_sensors
exit
0
;;
--unique
|
-u
)
shift
[
"
$1
"
]
||
usage
hdr_whitelist
=
$1
;;
--help
|
-h
)
usage
;;
esac
shift
done
sensors
=
$(
ls_sensors
)
nb_sensors
=
$(
echo
"
$sensors
"
|
sed
'/^$/d'
|
wc
-l
)
...
...
@@ -181,12 +189,13 @@ if [ "$nb_sensors" -eq 0 ]; then
exit
1
fi
try gen_sensors_h
"
$sensors
"
"
$nb_sensors
"
>
"
$target_hdr
"
try gen_sensors_mk
"
$sensors
"
>
"
$target_mk
"
try gen_sensors_h
"
$sensors
"
"
$nb_sensors
"
>
"
$target_hdr
"
try gen_sensors_mk
"
$sensors
"
>
"
$target_mk
"
try
printf
"LDFLAGS += %s
\n
"
"
$NVML_LDFLAGS
"
>>
"
$target_mk
"
try
printf
"IFLAGS += %s
\n
"
"
$NVML_IFLAGS
"
>>
"
$target_mk
"
printf
--
'Run `make` to build `bin/mojitos`.\n'
>
&2
printf
--
'The resulting binary will have the %d following sensors:\n'
"
$nb_sensors
"
>
&2
echo
"
$sensors
"
>
&2
make clean
>
/dev/null
This diff is collapsed.
Click to expand it.
makefile
+
4
−
2
View file @
856c5a6e
...
...
@@ -9,6 +9,8 @@ TESTS_DIR = tests
BIN
=
mojitos
CAPTOR_OBJ
=
IFLAGS
=
LDFLAGS
=
include
./sensors.mk
...
...
@@ -17,9 +19,9 @@ OBJ = \
$(
OBJ_DIR
)
/util.o
CC
=
gcc
CPPFLAGS
=
-std
=
gnu99
-Wall
-Wextra
-Wpedantic
-Wno-unused-function
-I
./lib
-I
/usr/local/cuda/include
CPPFLAGS
=
-std
=
gnu99
-Wall
-Wextra
-Wpedantic
-Wno-unused-function
-I
./lib
$(
IFLAGS
)
CFLAGS
=
$(
CPPFLAGS
)
-O3
-Werror
LDFLAGS
=
-L
/usr/local/cuda/lib64
-lnvidia-ml
LDFLAGS
+
=
ASTYLE
=
astyle
--style
=
kr
-xf
-s4
-k3
-n
-Z
-Q
...
...
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