2014-03-04 01:11:02 +08:00
|
|
|
#Copyright (c) 2012 The Broad Institute
|
|
|
|
|
|
|
|
|
|
#Permission is hereby granted, free of charge, to any person
|
|
|
|
|
#obtaining a copy of this software and associated documentation
|
|
|
|
|
#files (the "Software"), to deal in the Software without
|
|
|
|
|
#restriction, including without limitation the rights to use,
|
|
|
|
|
#copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
#copies of the Software, and to permit persons to whom the
|
|
|
|
|
#Software is furnished to do so, subject to the following
|
|
|
|
|
#conditions:
|
|
|
|
|
|
|
|
|
|
#The above copyright notice and this permission notice shall be
|
|
|
|
|
#included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
|
#OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
#NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
|
#HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
|
#WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
|
|
|
|
#THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
#
|
2014-03-04 01:04:00 +08:00
|
|
|
|
|
|
|
|
|
2014-01-23 14:57:32 +08:00
|
|
|
#OMPCFLAGS=-fopenmp
|
|
|
|
|
#OMPLFLAGS=-fopenmp #-openmp-link static
|
2014-01-15 09:26:55 +08:00
|
|
|
|
|
|
|
|
#CFLAGS=-O2 -std=c++11 -W -Wall -march=corei7-avx -Wa,-q -pedantic $(OMPCFLAGS) -Wno-unknown-pragmas
|
|
|
|
|
#CFLAGS=-O2 -W -Wall -march=corei7 -mfpmath=sse -msse4.2 -pedantic $(OMPCFLAGS) -Wno-unknown-pragmas
|
|
|
|
|
|
2014-03-01 08:08:28 +08:00
|
|
|
JRE_HOME?=/opt/jdk1.7.0_25/jre
|
2014-02-27 07:17:15 +08:00
|
|
|
JNI_COMPILATION_FLAGS=-D_REENTRANT -fPIC -I${JRE_HOME}/../include -I${JRE_HOME}/../include/linux
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-03-18 02:42:19 +08:00
|
|
|
#COMMON_COMPILATION_FLAGS=$(JNI_COMPILATION_FLAGS) -O3 -W -Wall -pedantic $(OMPCFLAGS) -Wno-unknown-pragmas
|
|
|
|
|
COMMON_COMPILATION_FLAGS=$(JNI_COMPILATION_FLAGS) -O3 -Wall $(OMPCFLAGS) -Wno-unknown-pragmas -Wno-write-strings -Wno-unused-variable -Wno-unused-but-set-variable
|
2014-02-07 03:01:33 +08:00
|
|
|
ifdef DISABLE_FTZ
|
2014-03-18 02:42:19 +08:00
|
|
|
COMMON_COMPILATION_FLAGS+=-DDISABLE_FTZ
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifdef USE_GCC
|
|
|
|
|
C_COMPILER?=gcc
|
|
|
|
|
CPP_COMPILER?=g++
|
|
|
|
|
AVX_FLAGS=-mavx
|
|
|
|
|
SSE41_FLAGS=-msse4.1
|
|
|
|
|
COMMON_COMPILATION_FLAGS+=-Wno-char-subscripts
|
|
|
|
|
else
|
|
|
|
|
C_COMPILER?=icc
|
|
|
|
|
CPP_COMPILER?=icc
|
|
|
|
|
AVX_FLAGS=-xAVX
|
|
|
|
|
SSE41_FLAGS=-xSSE4.1
|
|
|
|
|
LIBFLAGS=-static-intel
|
|
|
|
|
ifdef DISABLE_FTZ
|
|
|
|
|
COMMON_COMPILATION_FLAGS+=-no-ftz
|
|
|
|
|
endif
|
2014-02-07 03:01:33 +08:00
|
|
|
endif
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-03-18 02:42:19 +08:00
|
|
|
LDFLAGS=-lm -lrt $(OMPLDFLAGS)
|
|
|
|
|
|
2014-02-05 08:27:29 +08:00
|
|
|
PAPI_DIR=/home/karthikg/softwares/papi-5.3.0
|
|
|
|
|
ifdef USE_PAPI
|
|
|
|
|
ifeq ($(USE_PAPI),1)
|
1. Whew, finally debugged the source of performance issues with PairHMM
JNI. See copied text from email below.
2. This commit contains all the code used in profiling, detecting FP
exceptions, dumping intermediate results. All flagged off using ifdefs,
but it's there.
--------------Text from email
As we discussed before, it's the denormal numbers that are causing the
slowdown - the core executes some microcode uops (called FP assists)
when denormal numbers are detected for FP operations (even un-vectorized
code).
The C++ compiler by default enables flush to zero (FTZ) - when set, the
hardware simply converts denormal numbers to 0. The Java binary
(executable provided by Oracle, not the native library) seems to be
compiled without FTZ (sensible choice, they want to be conservative).
Hence, the JNI invocation sees a large slowdown. Disabling FTZ in C++
slows down the C++ sandbox performance to the JNI version (fortunately,
the reverse also holds :)).
Not sure how to show the overhead for these FP assists easily - measured
a couple of counters.
FP_ASSISTS:ANY - shows number of uops executed as part of the FP
assists. When FTZ is enabled, this is 0 (both C++ and JNI), when FTZ is
disabled this value is around 203540557 (both C++ and JNI)
IDQ:MS_UOPS_CYCLES - shows the number of cycles the decoder was issuing
uops when the microcode sequencing engine was busy. When FTZ is enabled,
this is around 1.77M cycles (both C++ and JNI), when FTZ is disabled
this value is around 4.31B cycles (both C++ and JNI). This number is
still small with respect to total cycles (~40B), but it only reflects
the cycles in the decode stage. The total overhead of the microcode
assist ops could be larger.
As suggested by Mustafa, I compared intermediate values (matrices M,X,Y)
and final output of compute_full_prob. The values produced by C++ and
Java are identical to the last bit (as long as both use FTZ or no-FTZ).
Comparing the outputs of compute_full_prob for the cases no-FTZ and FTZ,
there are differences for very small values (denormal numbers).
Examples:
Diff values 1.952970E-33 1.952967E-33
Diff values 1.135071E-32 1.135070E-32
Diff values 1.135071E-32 1.135070E-32
Diff values 1.135071E-32 1.135070E-32
For this test case (low coverage NA12878), all these values would be
recomputed using the double precision version. Enabling FTZ should be
fine.
-------------------End text from email
2014-02-06 09:09:57 +08:00
|
|
|
COMMON_COMPILATION_FLAGS+=-I$(PAPI_DIR)/include -DUSE_PAPI
|
2014-02-05 08:27:29 +08:00
|
|
|
LDFLAGS+=-L$(PAPI_DIR)/lib -lpapi
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
|
2014-01-27 11:18:12 +08:00
|
|
|
BIN=libVectorLoglessPairHMM.so pairhmm-template-main checker
|
2014-01-19 03:07:23 +08:00
|
|
|
#BIN=checker
|
2014-01-15 09:26:55 +08:00
|
|
|
|
|
|
|
|
DEPDIR=.deps
|
|
|
|
|
DF=$(DEPDIR)/$(*).d
|
|
|
|
|
|
2014-01-19 03:07:23 +08:00
|
|
|
#Common across libJNI and sandbox
|
2014-01-23 02:52:41 +08:00
|
|
|
COMMON_SOURCES=utils.cc avx_function_instantiations.cc baseline.cc sse_function_instantiations.cc LoadTimeInitializer.cc
|
2014-01-19 03:07:23 +08:00
|
|
|
#Part of libJNI
|
2014-05-10 01:43:01 +08:00
|
|
|
LIBSOURCES=org_broadinstitute_gatk_utils_pairhmm_VectorLoglessPairHMM.cc org_broadinstitute_gatk_utils_pairhmm_DebugJNILoglessPairHMM.cc Sandbox.cc $(COMMON_SOURCES)
|
2014-01-19 03:07:23 +08:00
|
|
|
SOURCES=$(LIBSOURCES) pairhmm-template-main.cc pairhmm-1-base.cc
|
|
|
|
|
LIBOBJECTS=$(LIBSOURCES:.cc=.o)
|
|
|
|
|
COMMON_OBJECTS=$(COMMON_SOURCES:.cc=.o)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#No vectorization for these files
|
2014-05-10 01:43:01 +08:00
|
|
|
NO_VECTOR_SOURCES=org_broadinstitute_gatk_utils_pairhmm_VectorLoglessPairHMM.cc org_broadinstitute_gatk_utils_pairhmm_DebugJNILoglessPairHMM.cc pairhmm-template-main.cc pairhmm-1-base.cc utils.cc baseline.cc LoadTimeInitializer.cc Sandbox.cc
|
2014-01-19 03:07:23 +08:00
|
|
|
#Use -xAVX for these files
|
|
|
|
|
AVX_SOURCES=avx_function_instantiations.cc
|
|
|
|
|
#Use -xSSE4.2 for these files
|
2014-01-21 00:03:42 +08:00
|
|
|
SSE_SOURCES=sse_function_instantiations.cc
|
2014-01-19 03:07:23 +08:00
|
|
|
|
|
|
|
|
NO_VECTOR_OBJECTS=$(NO_VECTOR_SOURCES:.cc=.o)
|
|
|
|
|
AVX_OBJECTS=$(AVX_SOURCES:.cc=.o)
|
|
|
|
|
SSE_OBJECTS=$(SSE_SOURCES:.cc=.o)
|
|
|
|
|
$(NO_VECTOR_OBJECTS): CXXFLAGS=$(COMMON_COMPILATION_FLAGS)
|
2014-03-18 02:42:19 +08:00
|
|
|
$(AVX_OBJECTS): CXXFLAGS=$(COMMON_COMPILATION_FLAGS) $(AVX_FLAGS)
|
|
|
|
|
$(SSE_OBJECTS): CXXFLAGS=$(COMMON_COMPILATION_FLAGS) $(SSE41_FLAGS)
|
2014-01-19 03:07:23 +08:00
|
|
|
OBJECTS=$(NO_VECTOR_OBJECTS) $(AVX_OBJECTS) $(SSE_OBJECTS)
|
|
|
|
|
|
2014-02-27 02:53:51 +08:00
|
|
|
all: $(BIN) Sandbox.class copied_lib
|
2014-01-15 09:26:55 +08:00
|
|
|
|
|
|
|
|
-include $(addprefix $(DEPDIR)/,$(SOURCES:.cc=.d))
|
|
|
|
|
|
2014-01-19 03:07:23 +08:00
|
|
|
checker: pairhmm-1-base.o $(COMMON_OBJECTS)
|
2014-03-18 02:42:19 +08:00
|
|
|
$(CPP_COMPILER) $(OMPLFLAGS) -o $@ $^ $(LDFLAGS)
|
2014-01-17 11:53:50 +08:00
|
|
|
|
2014-01-19 03:07:23 +08:00
|
|
|
pairhmm-template-main: pairhmm-template-main.o $(COMMON_OBJECTS)
|
2014-03-18 02:42:19 +08:00
|
|
|
$(CPP_COMPILER) $(OMPLFLAGS) -o $@ $^ $(LDFLAGS)
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-01-27 11:18:12 +08:00
|
|
|
libVectorLoglessPairHMM.so: $(LIBOBJECTS)
|
2014-03-18 02:42:19 +08:00
|
|
|
$(CPP_COMPILER) $(OMPLFLAGS) -shared $(LIBFLAGS) -o $@ $(LIBOBJECTS) ${LDFLAGS}
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-01-19 03:07:23 +08:00
|
|
|
|
|
|
|
|
$(OBJECTS): %.o: %.cc
|
2014-01-15 09:26:55 +08:00
|
|
|
@mkdir -p $(DEPDIR)
|
2014-03-18 02:42:19 +08:00
|
|
|
$(CPP_COMPILER) -c -MMD -MF $(DF) $(CXXFLAGS) $(OUTPUT_OPTION) $<
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-02-05 08:27:29 +08:00
|
|
|
Sandbox.class: Sandbox.java
|
|
|
|
|
javac Sandbox.java
|
2014-01-15 09:26:55 +08:00
|
|
|
|
2014-02-27 02:53:51 +08:00
|
|
|
copied_lib: libVectorLoglessPairHMM.so
|
|
|
|
|
ifdef OUTPUT_DIR
|
|
|
|
|
mkdir -p $(OUTPUT_DIR)
|
|
|
|
|
rsync -a libVectorLoglessPairHMM.so $(OUTPUT_DIR)/
|
|
|
|
|
endif
|
|
|
|
|
|
2014-01-15 09:26:55 +08:00
|
|
|
clean:
|
2014-02-05 08:27:29 +08:00
|
|
|
rm -rf $(BIN) *.o $(DEPDIR) *.class
|