Skip to content

Commit

Permalink
Improve slurm-spank-plugins build system for build outside LLNL.
Browse files Browse the repository at this point in the history
Rename project to slurm-spank-plugins and create
slurm-spank-plugins.spec specfile with new cpuset and llnl
subpackages. To build these subpackages, use '--with cpuset' and/or
'--with llnl_plugins' on the rpmbuild command line.

These changes are just an incremental improvement over previous
build system, but should suffice until the project is converted to
autoconf & friends.
  • Loading branch information
grondo committed Oct 3, 2008
1 parent 602036c commit 7ea93d0
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 93 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2008-10-03 Mark Grondona <[email protected]>

* chaos-spankings.spec :
Removed.

* slurm-spank-plugins.spec :
New spec file for slurm-spank-plugins RPM.

* META :
Rename project to slurm-spank-plugins.

* Makefile, cpuset/Makefile,
overcommit-memory/Makefile,
use-env/Makefile :
Update to build system to not build cpuset and oom-detect
plugins by default, and to support "make install" target.


2008-09-25 Mark Grondona <[email protected]>

* : tag v0.34.
Expand Down
4 changes: 2 additions & 2 deletions META
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name: chaos-spankings
Version: 0.34
Name: slurm-spank-plugins
Version: 0.1
Release: 1
Author: Mark Grondona <[email protected]>
61 changes: 49 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
PACKAGE ?= slurm-spank-plugins

CFLAGS = -Wall -ggdb
LIBNAME ?= lib$(shell uname -m | grep -q x86_64 && echo 64)
LIBDIR ?= /usr/$(LIBNAME)
BINDIR ?= /usr/bin
SBINDIR ?= /sbin
LIBEXECDIR ?= /usr/libexec

all: renice.so \
oom-detect.so \
system-safe-preload.so system-safe.so \
iotrace.so \
tmpdir.so \
auto-affinity.so \
pty.so \
addr-no-randomize.so \
preserve-env.so \
subdirs
export LIBNAME LIBDIR BINDIR SBINDIR LIBEXECDIR PACKAGE

SUBDIRS = use-env overcommit-memory cpuset
CFLAGS = -Wall -ggdb

PLUGINS = \
renice.so \
system-safe.so \
iotrace.so \
tmpdir.so \
auto-affinity.so \
pty.so \
addr-no-randomize.so \
preserve-env.so

LIBRARIES = \
system-safe-preload.so \

ifeq ($(BUILD_LLNL_ONLY), 1)
PLUGINS += oom-detect.so
endif

SUBDIRS = \
use-env \
overcommit-memory

ifeq ($(BUILD_CPUSET), 1)
SUBDIRS += cpuset
endif

all: $(PLUGINS) $(LIBRARIES) subdirs

.SUFFIXES: .c .o .so

Expand All @@ -39,6 +62,20 @@ pty.so : pty.o
clean: subdirs-clean
rm -f *.so *.o lib/*.o

install:
@mkdir -p --mode=0755 $(DESTDIR)$(LIBDIR)/slurm
@for p in $(PLUGINS); do \
echo "Installing $$p in $(LIBDIR)/slurm"; \
install -m0755 $$p $(DESTDIR)$(LIBDIR)/slurm; \
done
@for f in $(LIBRARIES); do \
echo "Installing $$f in $(LIBDIR)"; \
install -m0755 $$f $(DESTDIR)$(LIBDIR); \
done
@for d in $(SUBDIRS); do \
make -C $$d DESTDIR=$(DESTDIR) install; \
done

subdirs-clean:
@for d in $(SUBDIRS); do make -C $$d clean; done

36 changes: 28 additions & 8 deletions cpuset/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
NAME := cpuset

FLAGS := -ggdb -Wall -I../lib
SHOPTS := -shared -Wl,--version-script=version.map
LLIBS := -lbitmask -lcpuset -ldl -lfl
OBJS := nodemap.o util.o create.o log.o slurm.o \
conf.o conf-lexer.o conf-parser.o \
../lib/fd.o ../lib/list.o ../lib/split.o
NAME := cpuset
SBINDIR ?= /sbin
LIBNAME ?= lib$(shell uname -m | grep -q x86_64 && echo 64)
LIBDIR ?= /usr/$(LIBNAME)
MANDIR ?= /usr/share/man
PAMDIR := /$(LIBNAME)/security

FLAGS := -ggdb -Wall -I../lib
SHOPTS := -shared -Wl,--version-script=version.map
LLIBS := -lbitmask -lcpuset -ldl -lfl
OBJS := nodemap.o util.o create.o log.o slurm.o \
conf.o conf-lexer.o conf-parser.o \
../lib/fd.o ../lib/list.o ../lib/split.o

MAN8 := slurm-cpuset.8 pam_slurm_cpuset.8
MAN1 := use-cpusets.1

all: $(NAME).so test cpuset_release_agent pam_slurm_cpuset.so

install:
mkdir -p --mode=0755 $(DESTDIR)$(LIBDIR)/slurm
install -m0755 cpuset.so $(DESTDIR)$(LIBDIR)/slurm
mkdir -p --mode=0755 $(DESTDIR)$(PAMDIR)
install -m0755 pam_slurm_cpuset.so $(DESTDIR)$(PAMDIR)
mkdir -p --mode=0755 $(DESTDIR)$(SBINDIR)
install -m0755 cpuset_release_agent $(DESTDIR)$(SBINDIR)/
mkdir -p --mode=0755 $(DESTDIR)$(MANDIR)/man1
mkdir -p --mode=0755 $(DESTDIR)$(MANDIR)/man8
install -m0644 $(MAN8) $(DESTDIR)$(MANDIR)/man8
install -m0644 $(MAN1) $(DESTDIR)$(MANDIR)/man1

$(NAME).so: $(OBJS) $(NAME).o
$(CC) $(SHOPTS) -o $(NAME).so $(OBJS) $(NAME).o $(LLIBS)

Expand Down
10 changes: 10 additions & 0 deletions overcommit-memory/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
LIBDIR ?= /usr/lib$(shell uname -m | grep -q x86_64 && echo 64)
LIBEXECDIR ?= /usr/libexec
PACKAGE ?= slurm-spank-plugins

SHOPTS := -shared
OBJS := overcommit-memory.o overcommit.o ../lib/fd.o

all: overcommit-memory.so overcommit-util

install:
mkdir -p --mode=0755 $(DESTDIR)$(LIBDIR)/slurm
install -m0755 overcommit-memory.so $(DESTDIR)$(LIBDIR)/slurm/
mkdir -p --mode=0755 $(DESTDIR)$(LIBEXECDIR)/$(PACKAGE)
install -m0755 overcommit-util $(DESTDIR)$(LIBEXECDIR)/$(PACKAGE)/

overcommit-memory.so : $(OBJS)
$(CC) $(SHOPTS) -o overcommit-memory.so $(OBJS)

Expand Down
166 changes: 95 additions & 71 deletions chaos-spankings.spec → slurm-spank-plugins.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@
# $Id: chaos-spankings.spec 7813 2008-09-25 23:08:25Z grondo $
##

#
# Allow defining --with and --without build options or %_with and %without in .
# _with builds option by default unless --without is specified
# _without builds option iff --with specified
#
%define _with_opt() %{expand:%%{!?_without_%{1}:%%global _with_%{1} 1}}
%define _without_opt() %{expand:%%{?_with_%{1}:%%global _with_%{1} 1}}

#
# _with helper macro to test for slurm_with_*
#
%define _with() %{expand:%%{?_with_%{1}:1}%%{!?_with_%{1}:0}}

#
# Build llnl plugins and cpuset by default on chaos systems
#

%if 0%{?chaos}
%_with_opt llnl_plugins
%_with_opt cpuset
%else
%_without_opt llnl_plugins
%_without_opt cpuset
%endif

Name:
Version:
Release:
Expand All @@ -12,27 +37,31 @@ License: GPL

BuildRoot: %{_tmppath}/%{name}-%{version}
Source0: %{name}-%{version}.tgz
Requires: slurm

BuildRequires: slurm-devel bison flex

BuildRequires: slurm-devel job bison flex
%if %{_with cpuset}
BuildRequires: libbitmask libcpuset
BuildRequires: pam-devel
%endif

Requires: slurm
%if %{_with llnl_plugins}
BuildRequires: job
%endif

%description
This package contains a set of SLURM SPANK modules for CHAOS clusters.
This package contains a set of SLURM spank plugins which enhance and
extend SLURM functionality for users and administrators.

Currently includes:
- renice.so : add --renice option to srun allowing users to set priority
of job
- oom-detect.so : Detect tasks killed by OOM killer via /proc/oomkilled file.
- system-safe.so : Implement pre-forked system(3) replacement in case MPI
implementation doesn't support fork(2).
- iotrace.so : Enable tracing of IO calls through LD_PRELOAD trick
- use-env.so : Add --use-env flag to srun to override environment
variables for job
- tmpdir.so : Create a job-specific TMPDIR and remove it (as the user)
after the job has exited.

- auto-affinity.so:
Try to set CPU affinity on jobs using some kind of
presumably sane defaults. Also adds an --auto-affinity
Expand All @@ -43,11 +72,28 @@ Currently includes:
their job.

- pty.so : Run task 0 of SLURM job under pseudo tty.
- preserve-env.so: Attempt to preserve exactly the SLURM_* environment
variables in remote tasks. Meant to be used like:
salloc -n100 srun --preserve-slurm-env -n1 -N1 --pty bash

%package cpuset
Summary: Cpuset spank plugin for slurm.
Group: System Environment/Base
Requires: libbitmask libcpuset slurm

%if %{_with llnl_plugins}
%package llnl
Summary: SLURM spank plugins LLNL-only
Group: System Environment/Base
Requires: slurm job
%description llnl
The set of SLURM SPANK plugins that will only run on LLNL systems.
Includes:
- oom-detect.so : Detect tasks killed by OOM killer.
%endif


%if %{_with cpuset}
%package cpuset
Summary: Cpuset spank plugin for slurm.
Group: System Environment/Base
Requires: libbitmask libcpuset slurm pam

%description cpuset
This package contains a SLURM spank plugin for enabling
Expand All @@ -66,73 +112,35 @@ A PAM module - pam_slurm_cpuset.so - is also provided for
constraining user logins in a similar fashion. For more
information see the slurm-cpuset(8) man page provided with
this package.

%endif

%prep
%setup

%build
make CFLAGS="$RPM_OPT_FLAGS"
make \
%{?_with_llnl_plugins:BUILD_LLNL_ONLY=1} \
%{?_with_cpuset:BUILD_CPUSET=1} \
CFLAGS="$RPM_OPT_FLAGS"

%install
rm -rf "$RPM_BUILD_ROOT"
mkdir -p "$RPM_BUILD_ROOT"

plugins="renice.so \
oom-detect.so \
system-safe.so \
iotrace.so \
tmpdir.so \
use-env/use-env.so \
overcommit-memory/overcommit-memory.so \
auto-affinity.so \
preserve-env.so \
pty.so
"

libs="system-safe-preload.so"
utilities="overcommit-memory/overcommit-util"

libdir=$RPM_BUILD_ROOT%{_libdir}
plugindir=${libdir}/slurm
utildir=$RPM_BUILD_ROOT%{_libexecdir}/chaos-spankings/

mkdir -p --mode=0755 $plugindir
mkdir -p --mode=0755 $utildir

cat /dev/null > std-plugins.list
for plugin in $plugins; do
install -m0755 $plugin $plugindir
echo %{_libdir}/slurm/$(basename $plugin) >>std-plugins.list
done

for lib in $libs; do
install -m0755 $lib $libdir
done

for utility in $utilities; do
install -m0755 $utility $utildir
done

#
# cpuset_release_agent goes into /sbin
#
mkdir -p $RPM_BUILD_ROOT/sbin
install -m0755 cpuset/cpuset_release_agent $RPM_BUILD_ROOT/sbin
install -m0755 cpuset/cpuset.so $plugindir
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/
install -m0755 cpuset/cpuset.init \
$RPM_BUILD_ROOT/%{_sysconfdir}/init.d/slurm-cpuset

mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man8
mkdir -p $RPM_BUILD_ROOT/%{_lib}/security

install -m0755 cpuset/pam_slurm_cpuset.so $RPM_BUILD_ROOT/%{_lib}/security
install -m0644 cpuset/slurm-cpuset.8 cpuset/pam_slurm_cpuset.8 \
$RPM_BUILD_ROOT/%{_mandir}/man8
install -m0644 cpuset/use-cpusets.1 \
$RPM_BUILD_ROOT/%{_mandir}/man1
make \
LIBNAME=%{_lib} \
LIBDIR=%{_libdir} \
BINDIR=%{_bindir} \
SBINDIR=/sbin \
LIBEXECDIR=%{_libexecdir} \
DESTDIR="$RPM_BUILD_ROOT" \
%{?_with_llnl_plugins:BUILD_LLNL_ONLY=1} \
%{?_with_cpuset:BUILD_CPUSET=1} \
install

# slurm-cpuset init script
install -D -m0755 cpuset/cpuset.init \
$RPM_BUILD_ROOT/%{_sysconfdir}/init.d/slurm-cpuset

# create /etc/slurm/plugstack.d directory
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/slurm/plugstack.conf.d
Expand All @@ -152,14 +160,30 @@ if [ "$1" = 0 ]; then
if [ -x /sbin/chkconfig ]; then /sbin/chkconfig --del slurm-cpuset; fi
fi

%files -f std-plugins.list
%files
%defattr(-,root,root,0755)
%doc NEWS ChangeLog README.use-env
/%{_libdir}/*.so
/%{_libexecdir}/chaos-spankings/*
%{_libdir}/slurm/renice.so
%{_libdir}/slurm/oom-detect.so
%{_libdir}/slurm/system-safe.so
%{_libdir}/slurm/iotrace.so
%{_libdir}/slurm/tmpdir.so
%{_libdir}/slurm/use-env.so
%{_libdir}/slurm/overcommit-memory.so
%{_libdir}/slurm/auto-affinity.so
%{_libdir}/slurm/preserve-env.so
%{_libdir}/slurm/pty.so
%{_libdir}/slurm/addr-no-randomize.so
%{_libdir}/system-safe-preload.so
%{_libexecdir}/%{name}/overcommit-util
%dir %attr(0755,root,root) %{_sysconfdir}/slurm/plugstack.conf.d
%config(noreplace) %{_sysconfdir}/slurm/plugstack.conf.d/*

%files llnl
%defattr(-,root,root,0755)
%doc NEWS ChangeLog
%{_libdir}/slurm/oom-detect.so

%files cpuset
%defattr(-,root,root,0755)
%doc NEWS ChangeLog cpuset/README
Expand Down
Loading

0 comments on commit 7ea93d0

Please sign in to comment.