-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (75 loc) · 3.38 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# Copyright 2021 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include config.conf
.PHONY: all clean install package_jars cpp_clean emit_config
all: cpp_lib package_jars lpf_java_launcher emit_config assemble_jars
GRBCXX=$(GRB_INSTALL_PATH)/bin/grbcxx
CXX=$(GRBCXX) -b $(GRB_BACKEND)
JNI_INCLUDE=$(patsubst %/bin/javac, %, $(realpath $(shell which $(JAVAC))))/include
# OPT_FLAGS=-O0
OPT_FLAGS=-O3 -DNDEBUG #-DFILE_LOGGING
CPPFLAGS=-g -I $(JNI_INCLUDE) -I $(JNI_INCLUDE)/linux $(OPT_FLAGS) -Wall -Wextra
LFLAGS=
${GRB_INSTALL_PATH}/lib/spark/%: build/%
mkdir -p ${GRB_INSTALL_PATH}/lib/spark || true
cp "$<" "$@"
package_jars:
sbt package
assemble_jars:
sbt assembly
build/com_huawei_graphblas_Native.h: graphBLAS/src/main/java/com/huawei/graphblas/Native.java
mkdir build || true
$(JAVAC) -cp graphBLAS/src/main/java -d ./build -h ./build "$<"
build/native.o: cpp/native.cpp build/com_huawei_graphblas_Native.h cpp/sparkgrb.hpp cpp/pagerank.hpp
${CXX} ${CPPFLAGS} -fPIC -Ibuild/ -I${GRB_INSTALL_PATH}/include/:./cpp/ -c -o "$@" "$<"
build/pagerank.o: cpp/pagerank.cpp cpp/sparkgrb.hpp cpp/pagerank.hpp
${CXX} ${CPPFLAGS} -fPIC -Ibuild/ -I${GRB_INSTALL_PATH}/include/:./cpp/ -c -o "$@" "$<"
#This is an ugly workaround to an ALP bug (see GitHub issue 171)
CMD:="$(shell ${CXX} -b $(GRB_BACKEND) --show ${LFLAGS})"
PREFIX:=$(shell echo "${CMD}" | sed 's/\(^.*reference_omp\).*/\1/')
POSTFIX:=$(shell echo "${CMD}" | sed 's/^.*reference_omp\ \(.*\)/\1/')
MPOSTFIX:=$(shell echo "${POSTFIX}" | sed 's/\.a/\.so/g')
build/libsparkgrb.so: build/native.o build/pagerank.o
${PREFIX} -shared -o "${@}" ${^} ${MPOSTFIX}
# The following is bugged:
#${CXX} -shared -o "${@}" ${^}
build/grbinit.o: cpp/grbinit.cpp
${CXX} ${CPPFLAGS} -fPIC -Ibuild/ -I${GRB_INSTALL_PATH}/include/:./cpp/ -c -o "$@" "$<"
build/libgrbinit.so: build/grbinit.o
${PREFIX} -shared -o "${@}" ${^} ${MPOSTFIX}
cpp_lib: build/libsparkgrb.so build/libgrbinit.so
cpp_clean:
@rm -rf build/libsparkgrb.so build/*.o || true &> /dev/null
clean: cpp_clean
sbt clean
@rm -rf build lpf_java_launcher &> /dev/null
lpf_java_launcher:
@mkdir -p lpf_java_launcher/bin
@echo '#!/bin/bash' > lpf_java_launcher/bin/java
@echo >> lpf_java_launcher/bin/java
@echo '$(LPF_INSTALL_PATH)/bin/lpfrun -no-auto-init -np 1 -engine $(LPF_ENGINE) $(shell which $(JAVA)) $$@' >> lpf_java_launcher/bin/java
@chmod +x lpf_java_launcher/bin/java
emit_config:
@echo
@echo "### you should place the following options inside <SPARK_HOME>/conf/spark-defaults.conf ###"
@echo
@echo "# extra paths for libraries"
@echo "spark.executor.extraLibraryPath $(GRB_INSTALL_PATH)/lib:$(GRB_INSTALL_PATH)/lib/hybrid:$(shell pwd)/build"
@echo "# use the LPF-Java wrapper"
@echo "spark.executorEnv.JAVA_HOME $(shell pwd)/lpf_java_launcher"
@echo
# @echo spark.scheduler.excludeOnFailure.unschedulableTaskSetTimeout 1000000000
# @echo spark.executor.memory 400g