From 83d0c764dcd940fc058e8649c6982c7512563344 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 15 May 2017 17:15:46 -0700 Subject: [PATCH] added several compilation flags --- examples/Makefile | 2 +- lib/Makefile | 4 +++- programs/Makefile | 6 ++++-- tests/Makefile | 4 +++- tests/datagencli.c | 19 ++++++++++--------- tests/fullbench.c | 12 ++++++------ tests/paramgrill.c | 10 ++++++---- 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index b84983f0..e279a537 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -46,7 +46,7 @@ clean: simple_compression simple_decompression \ dictionary_compression dictionary_decompression \ streaming_compression streaming_decompression \ - multiple_streaming_compression + multiple_streaming_compression @echo Cleaning completed test: all diff --git a/lib/Makefile b/lib/Makefile index f5f61037..cc109944 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -24,7 +24,9 @@ CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_ CFLAGS ?= -O3 DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ - -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security + -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \ + -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ + -Wbad-function-cast -Wredundant-decls CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) diff --git a/programs/Makefile b/programs/Makefile index bb40253b..9efa0007 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -43,7 +43,9 @@ CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ CFLAGS ?= -O3 DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ - -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security + -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \ + -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ + -Wbad-function-cast -Wredundant-decls CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @@ -56,7 +58,7 @@ ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o ZSTD_LEGACY_SUPPORT ?= 4 -ZSTDLEGACY_FILES:= +ZSTDLEGACY_FILES := ifneq ($(ZSTD_LEGACY_SUPPORT), 0) ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0) ZSTDLEGACY_FILES += $(shell ls $(ZSTDDIR)/legacy/*.c | grep 'v0[$(ZSTD_LEGACY_SUPPORT)-7]') diff --git a/tests/Makefile b/tests/Makefile index ea58c0fe..560c36e1 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -33,7 +33,9 @@ CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ CFLAGS ?= -O3 CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ - -Wstrict-prototypes -Wundef -Wformat-security + -Wstrict-prototypes -Wundef -Wformat-security \ + -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ + -Wbad-function-cast -Wredundant-decls CFLAGS += $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) diff --git a/tests/datagencli.c b/tests/datagencli.c index 2f3ebc4d..3bb634b7 100644 --- a/tests/datagencli.c +++ b/tests/datagencli.c @@ -48,7 +48,8 @@ static int usage(const char* programName) DISPLAY( "Arguments :\n"); DISPLAY( " -g# : generate # data (default:%i)\n", SIZE_DEFAULT); DISPLAY( " -s# : Select seed (default:%i)\n", SEED_DEFAULT); - DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", COMPRESSIBILITY_DEFAULT); + DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", + COMPRESSIBILITY_DEFAULT); DISPLAY( " -h : display help and exit\n"); return 0; } @@ -56,7 +57,7 @@ static int usage(const char* programName) int main(int argc, const char** argv) { - double proba = (double)COMPRESSIBILITY_DEFAULT / 100; + unsigned probaU32 = COMPRESSIBILITY_DEFAULT; double litProba = 0.0; U64 size = SIZE_DEFAULT; U32 seed = SEED_DEFAULT; @@ -94,11 +95,10 @@ int main(int argc, const char** argv) break; case 'P': argument++; - proba=0.0; + probaU32=0.0; while ((*argument>='0') && (*argument<='9')) - proba *= 10, proba += *argument++ - '0'; - if (proba>100.) proba=100.; - proba /= 100.; + probaU32 *= 10, probaU32 += *argument++ - '0'; + if (probaU32>100.) probaU32=100.; break; case 'L': /* hidden argument : Literal distribution probability */ argument++; @@ -117,11 +117,12 @@ int main(int argc, const char** argv) } } } } /* for(argNb=1; argNb %s !! \n", benchName, ZSTD_getErrorName(benchResult)); exit(1); } } - averageTime = (((double)BMK_clockSpan(clockStart)) / CLOCKS_PER_SEC) / nbRounds; - if (averageTime < bestTime) bestTime = averageTime; - DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", loopNb, benchName, (double)srcSize / (1 MB) / bestTime, (U32)benchResult); - } } + { clock_t const clockTotal = BMK_clockSpan(clockStart); + double const averageTime = (double)clockTotal / CLOCKS_PER_SEC / nbRounds; + if (averageTime < bestTime) bestTime = averageTime; + DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", loopNb, benchName, (double)srcSize / (1 MB) / bestTime, (U32)benchResult); + } } } DISPLAY("%2u\n", benchNb); _cleanOut: diff --git a/tests/paramgrill.c b/tests/paramgrill.c index 9b032c0a..1185c664 100644 --- a/tests/paramgrill.c +++ b/tests/paramgrill.c @@ -38,7 +38,7 @@ #define GB *(1ULL<<30) #define NBLOOPS 2 -#define TIMELOOP (2 * CLOCKS_PER_SEC) +#define TIMELOOP (2 * CLOCKS_PER_SEC) #define NB_LEVELS_TRACKED 30 @@ -47,7 +47,7 @@ static const size_t maxMemory = (sizeof(size_t)==4) ? (2 GB - 64 MB) : (size_t #define COMPRESSIBILITY_DEFAULT 0.50 static const size_t sampleSize = 10000000; -static const U32 g_grillDuration_s = 60000; /* about 16 hours */ +static const double g_grillDuration_s = 90000; /* about 24 hours */ static const clock_t g_maxParamTime = 15 * CLOCKS_PER_SEC; static const clock_t g_maxVariationTime = 60 * CLOCKS_PER_SEC; static const int g_maxNbVariations = 64; @@ -87,9 +87,11 @@ void BMK_SetNbIterations(int nbLoops) * Private functions *********************************************************/ -static clock_t BMK_clockSpan(clock_t cStart) { return clock() - cStart; } /* works even if overflow ; max span ~ 30 mn */ +/* works even if overflow ; max span ~ 30 mn */ +static clock_t BMK_clockSpan(clock_t cStart) { return clock() - cStart; } -static U32 BMK_timeSpan(time_t tStart) { return (U32)difftime(time(NULL), tStart); } /* accuracy in seconds only, span can be multiple years */ +/* accuracy in seconds only, span can be multiple years */ +static double BMK_timeSpan(time_t tStart) { return difftime(time(NULL), tStart); } static size_t BMK_findMaxMem(U64 requiredMem)