Skip to content

Commit e6b5c5e

Browse files
iskunkBar-BY
authored andcommitted
[src] Add --debug-level=N configure option to control assertions (kaldi-asr#3690) (kaldi-asr#3700)
1 parent 4c087a2 commit e6b5c5e

10 files changed

+110
-9
lines changed

src/configure

+11
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Configuration options:
7373
--cudatk-dir=DIR CUDA toolkit directory
7474
--cuda-arch=FLAGS Override the default CUDA_ARCH flags. See:
7575
https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#nvcc-examples.
76+
--debug-level=N Use assertion level 0 (disabled), 1, or 2 [default=1]
7677
--double-precision Build with BaseFloat set to double if yes [default=no],
7778
mostly useful for testing purposes.
7879
--static-fst Build with static OpenFst libraries [default=no]
@@ -739,6 +740,7 @@ ENV_LDFLAGS=$LDFLAGS
739740
ENV_LDLIBS=$LDLIBS
740741

741742
# Default configuration
743+
debug_level=1
742744
double_precision=false
743745
dynamic_kaldi=false
744746
use_cuda=true
@@ -771,6 +773,9 @@ do
771773
static_math=false;
772774
static_fst=false;
773775
shift ;;
776+
--debug-level=*)
777+
GetSwitchValueOrDie debug_level "$1"
778+
shift ;;
774779
--double-precision)
775780
double_precision=true;
776781
shift ;;
@@ -901,6 +906,11 @@ do
901906
esac
902907
done
903908

909+
case "$debug_level" in
910+
[012]) ;;
911+
*) failure "Invalid value --debug-level=$debug_level. Supported values are 0, 1, and 2." ;;
912+
esac
913+
904914
# The idea here is that if you change the configuration options from using
905915
# CUDA to not using it, or vice versa, we want to recompile all parts of the
906916
# code that may use a GPU. Touching this file is a way to force this.
@@ -1033,6 +1043,7 @@ if $dynamic_kaldi ; then
10331043
echo "KALDI_FLAVOR := dynamic" >> kaldi.mk
10341044
echo "KALDILIBDIR := $KALDILIBDIR" >> kaldi.mk
10351045
fi
1046+
echo "DEBUG_LEVEL = $debug_level" >> kaldi.mk
10361047
if $double_precision; then
10371048
echo "DOUBLE_PRECISION = 1" >> kaldi.mk
10381049
else

src/makefiles/linux_atlas.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ATLAS specific Linux configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -22,12 +25,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2225
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_ATLAS -I$(ATLASINC) \
2427
-msse -msse2 -pthread \
25-
-g # -O0 -DKALDI_PARANOID
28+
-g
2629

2730
ifeq ($(KALDI_FLAVOR), dynamic)
2831
CXXFLAGS += -fPIC
2932
endif
3033

34+
ifeq ($(DEBUG_LEVEL), 0)
35+
CXXFLAGS += -DNDEBUG
36+
endif
37+
ifeq ($(DEBUG_LEVEL), 2)
38+
CXXFLAGS += -O0 -DKALDI_PARANOID
39+
endif
40+
3141
# Compiler specific flags
3242
COMPILER = $(shell $(CXX) -v 2>&1)
3343
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_atlas_ppc64le.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ATLAS specific Linux ppc64le configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -23,12 +26,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_ATLAS -I$(ATLASINC) \
2427
-m64 -maltivec -mcpu=power8 -mtune=power8 -mpower8-vector -mvsx \
2528
-pthread \
26-
-g # -O0 -DKALDI_PARANOID
29+
-g
2730

2831
ifeq ($(KALDI_FLAVOR), dynamic)
2932
CXXFLAGS += -fPIC
3033
endif
3134

35+
ifeq ($(DEBUG_LEVEL), 0)
36+
CXXFLAGS += -DNDEBUG
37+
endif
38+
ifeq ($(DEBUG_LEVEL), 2)
39+
CXXFLAGS += -O0 -DKALDI_PARANOID
40+
endif
41+
3242
# Compiler specific flags
3343
COMPILER = $(shell $(CXX) -v 2>&1)
3444
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_clapack.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CLAPACK specific Linux configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -16,12 +19,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
1619
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
1720
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_CLAPACK -I../../tools/CLAPACK \
1821
-msse -msse2 -pthread \
19-
-g # -O0 -DKALDI_PARANOID
22+
-g
2023

2124
ifeq ($(KALDI_FLAVOR), dynamic)
2225
CXXFLAGS += -fPIC
2326
endif
2427

28+
ifeq ($(DEBUG_LEVEL), 0)
29+
CXXFLAGS += -DNDEBUG
30+
endif
31+
ifeq ($(DEBUG_LEVEL), 2)
32+
CXXFLAGS += -O0 -DKALDI_PARANOID
33+
endif
34+
2535
# Compiler specific flags
2636
COMPILER = $(shell $(CXX) -v 2>&1)
2737
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_clapack_arm.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CLAPACK specific Linux ARM configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -16,12 +19,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
1619
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
1720
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_CLAPACK -I../../tools/CLAPACK \
1821
-ftree-vectorize -mfloat-abi=hard -mfpu=neon -pthread \
19-
-g # -O0 -DKALDI_PARANOID
22+
-g
2023

2124
ifeq ($(KALDI_FLAVOR), dynamic)
2225
CXXFLAGS += -fPIC
2326
endif
2427

28+
ifeq ($(DEBUG_LEVEL), 0)
29+
CXXFLAGS += -DNDEBUG
30+
endif
31+
ifeq ($(DEBUG_LEVEL), 2)
32+
CXXFLAGS += -O0 -DKALDI_PARANOID
33+
endif
34+
2535
# Compiler specific flags
2636
COMPILER = $(shell $(CXX) -v 2>&1)
2737
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_openblas.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenBLAS specific Linux configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -22,12 +25,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2225
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_OPENBLAS -I$(OPENBLASINC) \
2427
-msse -msse2 -pthread \
25-
-g # -O0 -DKALDI_PARANOID
28+
-g
2629

2730
ifeq ($(KALDI_FLAVOR), dynamic)
2831
CXXFLAGS += -fPIC
2932
endif
3033

34+
ifeq ($(DEBUG_LEVEL), 0)
35+
CXXFLAGS += -DNDEBUG
36+
endif
37+
ifeq ($(DEBUG_LEVEL), 2)
38+
CXXFLAGS += -O0 -DKALDI_PARANOID
39+
endif
40+
3141
# Compiler specific flags
3242
COMPILER = $(shell $(CXX) -v 2>&1)
3343
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_openblas_aarch64.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenBLAS specific Linux ARM configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -22,12 +25,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2225
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_OPENBLAS -I$(OPENBLASINC) \
2427
-ftree-vectorize -pthread \
25-
-g # -O0 -DKALDI_PARANOID
28+
-g
2629

2730
ifeq ($(KALDI_FLAVOR), dynamic)
2831
CXXFLAGS += -fPIC
2932
endif
3033

34+
ifeq ($(DEBUG_LEVEL), 0)
35+
CXXFLAGS += -DNDEBUG
36+
endif
37+
ifeq ($(DEBUG_LEVEL), 2)
38+
CXXFLAGS += -O0 -DKALDI_PARANOID
39+
endif
40+
3141
# Compiler specific flags
3242
COMPILER = $(shell $(CXX) -v 2>&1)
3343
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_openblas_arm.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenBLAS specific Linux ARM configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -22,12 +25,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2225
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_OPENBLAS -I$(OPENBLASINC) \
2427
-ftree-vectorize -mfloat-abi=hard -mfpu=neon -pthread \
25-
-g # -O0 -DKALDI_PARANOID
28+
-g
2629

2730
ifeq ($(KALDI_FLAVOR), dynamic)
2831
CXXFLAGS += -fPIC
2932
endif
3033

34+
ifeq ($(DEBUG_LEVEL), 0)
35+
CXXFLAGS += -DNDEBUG
36+
endif
37+
ifeq ($(DEBUG_LEVEL), 2)
38+
CXXFLAGS += -O0 -DKALDI_PARANOID
39+
endif
40+
3141
# Compiler specific flags
3242
COMPILER = $(shell $(CXX) -v 2>&1)
3343
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_openblas_ppc64le.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# OpenBLAS specific Linux configuration
22

3+
ifndef DEBUG_LEVEL
4+
$(error DEBUG_LEVEL not defined.)
5+
endif
36
ifndef DOUBLE_PRECISION
47
$(error DOUBLE_PRECISION not defined.)
58
endif
@@ -23,12 +26,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
2326
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_OPENBLAS -I$(OPENBLASINC) \
2427
-m64 -maltivec -mcpu=power8 -mtune=power8 -mpower8-vector -mvsx \
2528
-pthread \
26-
-g # -O0 -DKALDI_PARANOID
29+
-g
2730

2831
ifeq ($(KALDI_FLAVOR), dynamic)
2932
CXXFLAGS += -fPIC
3033
endif
3134

35+
ifeq ($(DEBUG_LEVEL), 0)
36+
CXXFLAGS += -DNDEBUG
37+
endif
38+
ifeq ($(DEBUG_LEVEL), 2)
39+
CXXFLAGS += -O0 -DKALDI_PARANOID
40+
endif
41+
3242
# Compiler specific flags
3343
COMPILER = $(shell $(CXX) -v 2>&1)
3444
ifeq ($(findstring clang,$(COMPILER)),clang)

src/makefiles/linux_x86_64_mkl.mk

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
# Use the options obtained from this website to manually configure for other
1010
# platforms using MKL.
1111

12+
ifndef DEBUG_LEVEL
13+
$(error DEBUG_LEVEL not defined.)
14+
endif
1215
ifndef DOUBLE_PRECISION
1316
$(error DOUBLE_PRECISION not defined.)
1417
endif
@@ -30,12 +33,19 @@ CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
3033
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
3134
-DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_MKL -I$(MKLROOT)/include \
3235
-m64 -msse -msse2 -pthread \
33-
-g # -O0 -DKALDI_PARANOID
36+
-g
3437

3538
ifeq ($(KALDI_FLAVOR), dynamic)
3639
CXXFLAGS += -fPIC
3740
endif
3841

42+
ifeq ($(DEBUG_LEVEL), 0)
43+
CXXFLAGS += -DNDEBUG
44+
endif
45+
ifeq ($(DEBUG_LEVEL), 2)
46+
CXXFLAGS += -O0 -DKALDI_PARANOID
47+
endif
48+
3949
# Compiler specific flags
4050
COMPILER = $(shell $(CXX) -v 2>&1)
4151
ifeq ($(findstring clang,$(COMPILER)),clang)

0 commit comments

Comments
 (0)