Skip to content

Commit

Permalink
Added spec file for building RPMs.
Browse files Browse the repository at this point in the history
Needed several tweaks to adjust things and paths to work properly.
  • Loading branch information
efocht committed Apr 16, 2020
1 parent 933d6c1 commit c95e823
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 37 deletions.
33 changes: 30 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ BUILD ?= $(CWD)/build

ifeq ($(URPC_INST_DIR),)
PREPARE := ve-urpc
PREPAREINSTALL := ve-urpc-install
URPC_INST_DIR := $(DEST)
endif

PACKAGE := aveo
VERSION := $(shell cat VERSION)
TARBALL := $(PACKAGE)-$(VERSION).tar.gz

include make_aveo.inc

MAKEVARS = DEST=$(DEST) BUILD=$(BUILD) URPC_INST_DIR=$(URPC_INST_DIR)
MAKEVARS = DEST=$(DEST) BUILD=$(BUILD) URPC_INST_DIR=$(URPC_INST_DIR) PREF=$(PREF)

ALL: $(PREPARE) aveo tests

Expand All @@ -23,18 +28,40 @@ test:
make -C test test $(MAKEVARS)


install: ALL
install: ALL $(PREPAREINSTALL)
make -C prereqs/ve-urpc install BUILD=$(BUILD) DEST=$(URPC_INST_DIR) PREF=$(PREF)
make -C src install $(MAKEVARS)
make -C test install $(MAKEVARS)

# -- rules for RPM build

aveo.spec: aveo.spec.in
sed -e "s,@PACKAGE@,$(PACKAGE)," -e "s,@VERSION@,$(VERSION)," \
-e "s,@PREFIX@,/usr/local/ve/$(PACKAGE)-$(VERSION)," < $< > $@

$(TARBALL): aveo.spec $(CWD)/prereqs/ve-urpc/.git
if [ -d $(PACKAGE)-$(VERSION) ]; then rm -rf $(PACKAGE)-$(VERSION); fi
mkdir -p $(PACKAGE)-$(VERSION)
cp -p aveo.spec $(PACKAGE)-$(VERSION)
cp -rl Makefile make_aveo.inc prereqs README.md scripts src test VERSION COPYING $(PACKAGE)-$(VERSION)
tar czvf $(TARBALL) $(PACKAGE)-$(VERSION)
rm -rf $(PACKAGE)-$(VERSION)

rpm: $(TARBALL)
rpmbuild -tb $<

# --------------------------

# -- rules for prerequisites

$(CWD)/prereqs/ve-urpc/.git:
git clone https://github.com/SX-Aurora/ve-urpc.git prereqs/ve-urpc

ve-urpc: $(CWD)/prereqs/ $(CWD)/prereqs/ve-urpc/.git
make -C prereqs/ve-urpc BUILD=$(BUILD) DEST=$(URPC_INST_DIR)
make -C prereqs/ve-urpc install BUILD=$(BUILD) DEST=$(URPC_INST_DIR)

ve-urpc-install: ve-urpc
make -C prereqs/ve-urpc install BUILD=$(BUILD) DEST=$(URPC_INST_DIR) PREF=$(PREF)

# --------------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AVEO-0.9.8
0.9.8
51 changes: 51 additions & 0 deletions aveo.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# don't build debuginfo package, this breaks due to mixed architectures
%define debug_package %{nil}
# avoid stripping the binaries
%global __strip /bin/true

Summary: VE Offloading Framework based on VE-UDMA RPC
Name: @PACKAGE@
Version: @VERSION@
Release: 1
Vendor: NEC HPC Europe
Group: System Environment/Libraries
License: LGPL
BuildRoot: %{_tmppath}/%{name}-buildroot-%{version}-%{release}
Source0: @PACKAGE@-@VERSION@.tar.gz
Requires: veos
BuildRequires: vedebuginfo
Requires: glibc-ve
BuildRequires: glibc-ve-devel
%description
The Alternative VE Offloading framework (AVEO) is a faster and much
lower latency replacement to VEO which brings multi-VE support,
simultaneous debugging of VE and VH side, API extensions. It allows
heterogeneous programming of SX-Aurora TSUBASA vector engines with
an accelerator-alike heterogeneous programming model like OpenMP and
OpenACC.

%define _prefix @PREFIX@
%define _docdir %{_prefix}/doc
%define _testsdir %{_prefix}/tests
%define _libdir %{_prefix}/lib
%define _libexecdir %{_prefix}/libexec
%define _includedir %{_prefix}/include

%prep
%setup -q -n @PACKAGE@-@VERSION@

%build
make DEST=%{_prefix} PREF=%{buildroot}

%install
make install DEST=%{_prefix} PREF=%{buildroot}
install -d %{buildroot}%{_prefix}/doc/examples
install README.md COPYING %{buildroot}%{_prefix}/doc
cp -pr test/* %{buildroot}%{_prefix}/doc/examples

%files
%{_libexecdir}/*
%{_libdir}/*
%{_includedir}/*
%{_docdir}/*
%{_testsdir}/*
12 changes: 7 additions & 5 deletions make_aveo.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $(error "URPC_INST_DIR is undefined! Please point it to the place where veo-urpc
endif
endif

INCL = -I$(DEST)/include -I. -I$(URPC_INST_DIR)/include
INCL = -I$(BUILD)/include -I$(DEST)/include -I. -I$(URPC_INST_DIR)/include
GPPFLAGS = -std=gnu++11 -pthread $(OPT) $(DEBUG) $(INCL)
GCCFLAGS = -std=c11 -pthread $(OPT) $(DEBUG) $(INCL)
NCPPFLAGS = $(FTRACE) -std=gnu++11 -pthread $(OPT) $(DEBUG) $(INCL) -finline -finline-functions
Expand All @@ -29,11 +29,13 @@ NLDFLAGS = -Wl,-rpath,/opt/nec/ve/lib -L/opt/nec/ve/lib $(LDFLAGS)


# build directory substructure
BVE = $(BUILD)/ve
BVE = $(BUILD)/ve
BVE_OMP = $(BUILD)/ve_omp
BVH = $(BUILD)/vh
BB = $(BUILD)/bin
BLIB = $(BUILD)/lib
BVH = $(BUILD)/vh
BB = $(BUILD)/bin
BLIB = $(BUILD)/lib
BLIBEX = $(BUILD)/libexec
BINC = $(BUILD)/include

# rule for creating directories
%/:
Expand Down
56 changes: 35 additions & 21 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# destination path for install
DEST ?= ../install

# install prefix (when building an RPM)
PREF ?=

# build path
BUILD ?= ../build

include ../make_aveo.inc
Expand All @@ -16,33 +22,34 @@ VHLIB_OBJS := $(addprefix $(BVH)/,\
VELIB_OBJS := $(addprefix $(BVE)/,veo_urpc.o veo_urpc_ve.o)

LIBS = $(addprefix $(BLIB)/,libaveoVE.so libaveoVH.so libaveoVE.a libaveoVH.a)
PROGS = $(BB)/aveorun $(BB)/aveorun-ftrace $(BB)/relink_aveorun
INCLUDES := ve_offload.h
PROGS = $(addprefix $(BLIBEX)/,aveorun aveorun-ftrace relink_aveorun gen_aveorun_static_symtable)
INCLUDES := $(addprefix $(BINC)/,ve_offload.h)


ALL: $(LIBS) $(PROGS)
ALL: $(LIBS) $(INCLUDES) $(PROGS)

.PRECIOUS: $(DEST)/ $(DEST)%/

%/:
mkdir -p $@


install: ALL | $(DEST)/lib/ $(DEST)/libexec/ $(DEST)/include/ $(dir $(VEORUN_BIN))/
/usr/bin/install -t $(DEST)/lib $(LIBS)
if [ -L $(DEST)/lib/libveo.so ]; then \
rm -f $(DEST)/lib/libveo.so; \
install: ALL
mkdir -p $(PREF)$(DEST)/lib/ $(PREF)$(DEST)/libexec/ $(PREF)$(DEST)/include/ $(PREF)$(dir $(VEORUN_BIN))/
/usr/bin/install -t $(PREF)$(DEST)/lib $(LIBS)
if [ -L $(PREF)$(DEST)/lib/libveo.so ]; then \
rm -f $(PREF)$(DEST)/lib/libveo.so; \
fi
ln -s $(DEST)/lib/libaveoVH.so $(DEST)/lib/libveo.so
/usr/bin/install -t $(DEST)/include $(INCLUDES)
/usr/bin/install $(BB)/aveorun $(VEORUN_BIN)
/usr/bin/install $(BB)/aveorun-ftrace $(VEORUN_BIN)-ftrace
/usr/bin/install ../scripts/gen_aveorun_static_symtable $(DEST)/libexec
/usr/bin/install $(BB)/relink_aveorun $(DEST)/libexec
if [ -L $(DEST)/libexec/mk_veorun_static ]; then \
rm -f $(DEST)/libexec/mk_veorun_static; \
( cd $(PREF)$(DEST)/lib; ln -s libaveoVH.so libveo.so; )
/usr/bin/install -t $(PREF)$(DEST)/include $(INCLUDES)
/usr/bin/install $(BLIBEX)/* $(PREF)$(dir $(VEORUN_BIN))
/usr/bin/install ../scripts/gen_aveorun_static_symtable $(PREF)$(DEST)/libexec
sed -e "s,@libexecdir@,$(DEST)/libexec,g" -e "s,@libdir@,$(DEST)/lib,g" \
< ../scripts/relink_aveorun.in > $(PREF)$(DEST)/libexec/relink_aveorun
chmod 755 $(PREF)$(DEST)/libexec/relink_aveorun
if [ -L $(PREF)$(DEST)/libexec/mk_veorun_static ]; then \
rm -f $(PREF)$(DEST)/libexec/mk_veorun_static; \
fi
ln -s $(DEST)/libexec/relink_aveorun $(DEST)/libexec/mk_veorun_static
( cd $(PREF)$(DEST)/libexec; ln -s relink_aveorun mk_veorun_static; )


%/ProcHandle.o: ProcHandle.cpp ProcHandle.hpp VEOException.hpp veo_urpc.h CallArgs.hpp log.h
Expand All @@ -59,6 +66,10 @@ install: ALL | $(DEST)/lib/ $(DEST)/libexec/ $(DEST)/include/ $(dir $(VEORUN_BIN

.SECONDEXPANSION:


$(BINC)/%.h: %.h | $$(@D)/
/usr/bin/install -t $(BINC) $<

$(BLIB)/libaveoVE.so: $(VELIB_OBJS) | $$(@D)/
$(NCPP) -Wl,-zdefs $(NCPPFLAGS) -fopenmp -fpic -shared -o $@ $^ \
$(BLIB)/liburpcVE_omp.a $(NLDFLAGS) -lveio -lveftrace -ldl
Expand All @@ -74,19 +85,22 @@ $(BLIB)/libaveoVH.a: $(VHLIB_OBJS) | $$(@D)/
$(AR) rv $@ $^


$(BB)/aveorun: $(BVE)/aveorun.o | $$(@D)/
$(BLIBEX)/aveorun: $(BVE)/aveorun.o | $$(@D)/
$(NFORT) $(NFORTFLAGS) -v -cxxlib -fopenmp -o $@ $^ $(NLDFLAGS) -L. \
-L$(BLIB) -laveoVE -lveio -lpthread

$(BB)/aveorun-ftrace: $(BVE)/aveorun-ftrace.o | $$(@D)/
$(BLIBEX)/aveorun-ftrace: $(BVE)/aveorun-ftrace.o | $$(@D)/
$(NFORT) $(NFORTFLAGS) -ftrace -cxxlib -fopenmp -o $@ $^ $(NLDFLAGS) -L. \
-L$(BLIB) -laveoVE -lveio -lpthread

$(BB)/relink_aveorun: ../scripts/relink_aveorun.in
sed -e "s,@libexecdir@,$(DEST)/libexec,g" -e "s,@libdir@,$(DEST)/lib,g" \
$(BLIBEX)/relink_aveorun: ../scripts/relink_aveorun.in
sed -e "s,@libexecdir@,$(DEST)/libexec,g" -e "s,@libdir@,$(BUILD)/lib,g" \
< $< > $@
chmod 755 $@

$(BLIBEX)/gen_aveorun_static_symtable: ../scripts/gen_aveorun_static_symtable
cp -p $< $@
chmod 755 $@

$(BVE)/veo_urpc.o: veo_urpc.c
$(NCC) $(NCCFLAGS) -fpic -DAVEO_VERSION_STRING=\"$(VERSION)\" -o $@ -c $<
Expand Down
8 changes: 4 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ALL: $(TESTS) $(VELIBS) $(STATICS) $(SCRIPTS)
#
# install
#
install: $(TESTS) $(VELIBS) $(STATICS) | $(DEST)/tests/
/usr/bin/install $(TESTS) $(VELIBS) $(STATICS) $(DEST)/tests
/usr/bin/install $(SCRIPTS) $(DEST)/tests
install: $(TESTS) $(VELIBS) $(STATICS) | $(PREF)$(DEST)/tests/
/usr/bin/install $(TESTS) $(VELIBS) $(STATICS) $(PREF)$(DEST)/tests
/usr/bin/install $(SCRIPTS) $(PREF)$(DEST)/tests

#
# run the tests from the build directory
Expand Down Expand Up @@ -58,7 +58,7 @@ $(BB)/%_ftrace.so: $(BVE)/%_ftrace.o | $$(@D)/
$(BB)/veorun_%: $(BVE)/libve%.o | $$(@D)/
env RELINKVEO_GEN=../scripts/gen_aveorun_static_symtable \
RELINKVEO_LIB=$(BLIB)/libaveoVE.a \
$(BB)/relink_aveorun $@ -fopenmp $<
$(BLIBEX)/relink_aveorun $@ -fopenmp $<

$(BVE)/%.o: %.c | $$(@D)/
$(NCC) $(NCCFLAGS) -fopenmp -fpic -o $@ -c $<
Expand Down
8 changes: 5 additions & 3 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Super simple run loop for running the tests for AVEO.
# Can be improved a lot...
#
SCRIPTPATH=$(dirname $(realpath ${BASH_SOURCE[0]}))
LIBEXECDIR=$(realpath $SCRIPTPATH/../libexec)
good=0
bad=0

Expand Down Expand Up @@ -30,7 +32,7 @@ for t in test_*; do
#
if [ "${t%_ftrace}" != "$t" ]; then
[ -f ftrace.out ] && rm -f ftrace.out
env VEORUN_BIN=./aveorun-ftrace ./$t
env VEORUN_BIN=$LIBEXECDIR/aveorun-ftrace ./$t
if [ $? -ne 0 ]; then
bad=$((bad+1))
failed[$t]=1
Expand All @@ -54,7 +56,7 @@ for t in test_*; do
#
# run normal dynamic test
#
env VEORUN_BIN=./aveorun ./$t
env VEORUN_BIN=$LIBEXECDIR/aveorun ./$t
if [ $? -ne 0 ]; then
bad=$((bad+1))
failed[$t]=1
Expand All @@ -72,7 +74,7 @@ echo "$bad tests failed"
if [ $bad -gt 0 ]; then
echo
echo "The failed tests were:"
echo ${failed[*]}
echo ${!failed[*]}
fi

echo "============================================================"
Expand Down

0 comments on commit c95e823

Please sign in to comment.