Skip to content

Commit f4bdde1

Browse files
committed
Runtime CI: Add a tool to display the hwloc binding without relying on MPI or PMIx interfaces
Signed-off-by: Joshua Hursey <jhursey@us.ibm.com>
1 parent d386b88 commit f4bdde1

File tree

13 files changed

+876
-1
lines changed

13 files changed

+876
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ comm_split_type/cmsplit_type
3838
singleton/hello_c
3939
singleton/simple_spawn
4040
singleton/simple_spawn_multiple
41+
42+
.vscode

runtime/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ The CI infrastructure defines the following environment variables to be used in
3737
- CI will call this exactly one time (with a timeout in case it hangs).
3838
- If the script returns `0` then it is considered successful. Otherwise it is considered failed.
3939
4. Add your directory name to the `.ci-tests` file in this directory in the order that they should be executed.
40-
- Note that adding the directory is not sufficient to have CI run the test, it must be in the file.
40+
- Note that adding the directory is not sufficient to have CI run the test, it must be in the `.ci-tests` file.
4141
- Comments (starting with `#`) are allowed.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf
53+
54+
# Autoconf/Automake leftovers
55+
autom4te.cache/
56+
compile
57+
depcomp
58+
aclocal.m4
59+
config.log
60+
config.status
61+
configure
62+
install-sh
63+
missing
64+
.deps
65+
.libs
66+
*.in
67+
Makefile
68+
src/include/autogen/config.h*
69+
src/include/autogen/stamp-h1
70+
71+
# Binary leftovers
72+
src/get-pretty-cpu
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# High level Makefile
3+
#
4+
headers =
5+
sources =
6+
nodist_headers =
7+
EXTRA_DIST =
8+
9+
SUBDIRS = . src
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Pretty Print HWLOC Process Binding
2+
3+
## Building
4+
5+
```shell
6+
./autogen.sh
7+
./configure --prefix=${YOUR_INSTALL_DIR} --with-hwloc=${HWLOC_INSTALL_PATH}
8+
make
9+
make install
10+
````
11+
12+
## Running
13+
14+
### Default: Print HWLOC bitmap
15+
16+
```shell
17+
shell$ get-pretty-cpu
18+
0/ 0 on c660f5n18) Process Bound : 0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff
19+
```
20+
21+
```shell
22+
shell$ hwloc-bind core:2 get-pretty-cpu
23+
0/ 0 on c660f5n18) Process Bound : 0x00ff0000
24+
```
25+
26+
```shell
27+
shell$ mpirun -np 2 get-pretty-cpu
28+
0/ 2 on c660f5n18) Process Bound : 0x000000ff
29+
1/ 2 on c660f5n18) Process Bound : 0x0000ff00
30+
```
31+
32+
### Full descriptive output
33+
34+
```shell
35+
shell$ get-pretty-cpu -b -f
36+
0/ 0 on c660f5n18) Process Bound : socket 0[core 0[hwt 0-7]],socket 0[core 1[hwt 0-7]],socket 0[core 2[hwt 0-7]],socket 0[core 3[hwt 0-7]],socket 0[core 4[hwt 0-7]],socket 0[core 5[hwt 0-7]],socket 0[core 6[hwt 0-7]],socket 0[core 7[hwt 0-7]],socket 0[core 8[hwt 0-7]],socket 0[core 9[hwt 0-7]],socket 1[core 10[hwt 0-7]],socket 1[core 11[hwt 0-7]],socket 1[core 12[hwt 0-7]],socket 1[core 13[hwt 0-7]],socket 1[core 14[hwt 0-7]],socket 1[core 15[hwt 0-7]],socket 1[core 16[hwt 0-7]],socket 1[core 17[hwt 0-7]],socket 1[core 18[hwt 0-7]],socket 1[core 19[hwt 0-7]]
37+
```
38+
39+
```shell
40+
shell$ hwloc-bind core:2 get-pretty-cpu -b -f
41+
0/ 0 on c660f5n18) Process Bound : socket 0[core 2[hwt 0-7]]
42+
```
43+
44+
```shell
45+
shell$ mpirun -np 2 get-pretty-cpu -b -f
46+
1/ 2 on c660f5n18) Process Bound : socket 0[core 1[hwt 0-7]]
47+
0/ 2 on c660f5n18) Process Bound : socket 0[core 0[hwt 0-7]]
48+
```
49+
50+
### Full descriptive bracketed output
51+
52+
```shell
53+
shell$ get-pretty-cpu -b -m
54+
0/ 0 on c660f5n18) Process Bound : [BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB][BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB/BBBBBBBB]
55+
```
56+
57+
```shell
58+
shell$ hwloc-bind core:2 get-pretty-cpu -b -m
59+
0/ 0 on c660f5n18) Process Bound : [......../......../BBBBBBBB/......../......../......../......../......../......../........][......../......../......../......../......../......../......../......../......../........]
60+
```
61+
62+
```shell
63+
shell$ mpirun -np 2 get-pretty-cpu -b -m
64+
1/ 2 on c660f5n18) Process Bound : [......../BBBBBBBB/......../......../......../......../......../......../......../........][......../......../......../......../......../......../......../......../......../........]
65+
0/ 2 on c660f5n18) Process Bound : [BBBBBBBB/......../......../......../......../......../......../......../......../........][......../......../......../......../......../......../......../......../......../........]
66+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash -e
2+
3+
autoreconf -ivf
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#
2+
#
3+
#
4+
5+
######################
6+
# Project Information
7+
######################
8+
AC_INIT([HWLOC Tools],
9+
[0.1])
10+
AC_PREREQ(2.63)
11+
12+
13+
######################
14+
# Utilities
15+
######################
16+
_show_title() {
17+
cat <<EOF
18+
19+
============================================================================
20+
== ${1}
21+
============================================================================
22+
EOF
23+
}
24+
25+
26+
######################
27+
# Setup Makefile
28+
######################
29+
_show_title "Setup Basic Information"
30+
31+
# Initialize automake
32+
AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define 1.10.1 -Wall -Werror])
33+
34+
# Make becomes a bit more quiet
35+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
36+
37+
# Set the language
38+
CFLAGS_save="$CFLAGS"
39+
AC_LANG([C])
40+
CFLAGS="$CFLAGS_save"
41+
42+
43+
######################
44+
# Create a configure header file
45+
######################
46+
AH_TOP([/*
47+
* This file is automatically generated by configure. Edits will be lost
48+
* the next time you run configure!
49+
*/
50+
#ifndef HWLOC_TOOLS_H
51+
#define HWLOC_TOOLS_H
52+
53+
#include <autogen/hwloc_tools_config_top.h>
54+
55+
])
56+
AH_BOTTOM([
57+
58+
#include <autogen/hwloc_tools_config_bottom.h>
59+
#endif /* HWLOC_TOOLS_CONFIG_H */
60+
])
61+
62+
AC_CONFIG_HEADERS([src/include/autogen/config.h])
63+
64+
65+
######################
66+
# Make automake clean emacs ~ files for "make clean"
67+
######################
68+
CLEANFILES="*~ .\#*"
69+
AC_SUBST(CLEANFILES)
70+
71+
72+
######################
73+
# C Compiler
74+
######################
75+
_show_title "Setup C Compiler"
76+
77+
CFLAGS_save="$CFLAGS"
78+
AC_PROG_CC
79+
CFLAGS="$CFLAGS_save"
80+
81+
AC_SUBST(CFLAGS)
82+
AC_SUBST(CXXFLAGS)
83+
AC_SUBST(CPPFLAGS)
84+
AC_SUBST(LDFLAGS)
85+
AC_SUBST(LIBS)
86+
87+
88+
######################
89+
# HWLOC Install
90+
######################
91+
_show_title "Setup HWLOC"
92+
93+
#
94+
# --with-hwloc=DIR
95+
# --with-hwloc-libdir=DIR
96+
#
97+
AC_ARG_WITH([hwloc],
98+
[AC_HELP_STRING([--with-hwloc=DIR],
99+
[Search for hwloc headers and libraries in DIR ])])
100+
101+
AC_ARG_WITH([hwloc-libdir],
102+
[AC_HELP_STRING([--with-hwloc-libdir=DIR],
103+
[Search for hwloc libraries in DIR ])])
104+
# HWLOC is required
105+
AS_IF([test "$with_hwloc" = "no"],
106+
[AC_MSG_WARN([HWLOC is required. --without-hwloc is not supported.])
107+
AC_MSG_ERROR([Cannot continue])])
108+
AS_IF([test -z "$with_hwloc" || test "$with_hwloc" == "yes"],
109+
[AC_MSG_WARN([HWLOC is required. Default search functionality not supported.])
110+
AC_MSG_ERROR([Cannot continue])])
111+
112+
AC_MSG_CHECKING([HWLOC Location])
113+
AC_MSG_RESULT([$with_hwloc])
114+
115+
CFLAGS="-I$with_hwloc/include $CFLAGS"
116+
117+
# Do we really need '-ludev'?
118+
#LDFLAGS="-ludev $LDFLAGS"
119+
120+
AC_MSG_CHECKING([If static HWLOC library is available])
121+
AS_IF([test -f "$with_hwloc/lib/libhwloc.a" ],
122+
[AC_MSG_RESULT([yes])
123+
LIBS="$with_hwloc/lib/libhwloc.a $LIBS"],
124+
[LDFLAGS="-L$with_hwloc/lib $LDFLAGS"
125+
LIBS="-lhwloc $LIBS"])
126+
127+
AC_MSG_CHECKING([Final CFLAGS])
128+
AC_MSG_RESULT([$CFLAGS])
129+
130+
AC_MSG_CHECKING([Final LDFLAGS])
131+
AC_MSG_RESULT([$LDFLAGS])
132+
133+
AC_MSG_CHECKING([Final LIBS])
134+
AC_MSG_RESULT([$LIBS])
135+
136+
######################
137+
# Makefile
138+
######################
139+
AC_CONFIG_FILES([Makefile src/Makefile])
140+
141+
######################
142+
# Done
143+
######################
144+
_show_title "All Done"
145+
AC_OUTPUT
146+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
#
3+
#
4+
5+
headers =
6+
sources =
7+
nodist_headers =
8+
EXTRA_DIST =
9+
10+
AM_CPPFLAGS = -I./include/
11+
AM_LDFLAGS = -lm
12+
13+
# Headers
14+
headers += include/utils.h
15+
16+
# Source
17+
sources += \
18+
get-pretty-cpu.c \
19+
support.c
20+
21+
bin_PROGRAMS = get-pretty-cpu
22+
23+
get_pretty_cpu_SOURCES = $(sources) $(headers)
24+
#get_pretty_cpu_CFLAGS = $(CFLAGS_HWLOC)
25+
#get_pretty_cpu_LDADD = $(LIBS_HWLOC)

0 commit comments

Comments
 (0)