[warning] add -Wdouble-promotion

Mostly just a few warnings where things are promoted via passing floats to
printf. Those we should generally remove anyway because they're just
benchmarking code. Most things LK runs on either doesn't have float or
doesn't have double sized floats.
This commit is contained in:
Travis Geiselbrecht
2020-07-25 17:16:22 -07:00
parent f7d8e2300c
commit ba530722f5
5 changed files with 22 additions and 12 deletions

View File

@@ -34,8 +34,7 @@ __NO_INLINE static void bench_set_overhead(void) {
}
count = arch_cycle_count() - count;
printf("took %lu cycles overhead to loop %u times\n",
count, ITER);
printf("took %lu cycles overhead to loop %u times\n", count, ITER);
free(buf);
}
@@ -53,8 +52,10 @@ __NO_INLINE static void bench_memset(void) {
}
count = arch_cycle_count() - count;
size_t total_bytes = BUFSIZE * ITER;
double bytes_cycle = total_bytes / (float)count;
printf("took %lu cycles to memset a buffer of size %zu %d times (%zu bytes), %f bytes/cycle\n",
count, BUFSIZE, ITER, BUFSIZE * ITER, (BUFSIZE * ITER) / (float)count);
count, BUFSIZE, ITER, total_bytes, bytes_cycle);
free(buf);
}
@@ -76,8 +77,10 @@ __NO_INLINE static void bench_cset_##type(void) \
} \
count = arch_cycle_count() - count; \
\
size_t total_bytes = BUFSIZE * ITER; \
double bytes_cycle = total_bytes / (float)count; \
printf("took %lu cycles to manually clear a buffer using wordsize %zu of size %zu %u times (%zu bytes), %f bytes/cycle\n", \
count, sizeof(*buf), BUFSIZE, ITER, BUFSIZE * ITER, (BUFSIZE * ITER) / (float)count); \
count, sizeof(*buf), BUFSIZE, ITER, total_bytes, bytes_cycle); \
\
free(buf); \
}
@@ -109,8 +112,10 @@ __NO_INLINE static void bench_cset_wide(void) {
}
count = arch_cycle_count() - count;
size_t total_bytes = BUFSIZE * ITER;
double bytes_cycle = total_bytes / (float)count;
printf("took %lu cycles to manually clear a buffer of size %zu %d times 8 words at a time (%zu bytes), %f bytes/cycle\n",
count, BUFSIZE, ITER, BUFSIZE * ITER, (BUFSIZE * ITER) / (float)count);
count, BUFSIZE, ITER, total_bytes, bytes_cycle);
free(buf);
}
@@ -128,8 +133,10 @@ __NO_INLINE static void bench_memcpy(void) {
}
count = arch_cycle_count() - count;
size_t total_bytes = (BUFSIZE / 2) * ITER;
double bytes_cycle = total_bytes / (float)count;
printf("took %lu cycles to memcpy a buffer of size %zu %d times (%zu source bytes), %f source bytes/cycle\n",
count, BUFSIZE / 2, ITER, BUFSIZE / 2 * ITER, (BUFSIZE / 2 * ITER) / (float)count);
count, BUFSIZE / 2, ITER, total_bytes, bytes_cycle);
free(buf);
}
@@ -153,8 +160,10 @@ __NO_INLINE static void arm_bench_cset_stm(void) {
}
count = arch_cycle_count() - count;
size_t total_bytes = BUFSIZE * ITER;
double bytes_cycle = total_bytes / (float)count;
printf("took %lu cycles to manually clear a buffer of size %zu %d times 8 words at a time using stm (%zu bytes), %f bytes/cycle\n",
count, BUFSIZE, ITER, BUFSIZE * ITER, (BUFSIZE * ITER) / (float)count);
count, BUFSIZE, ITER, total_bytes, bytes_cycle);
free(buf);
}
@@ -179,7 +188,8 @@ __NO_INLINE static void arm_bench_multi_issue(void) {
}
cycles = arch_cycle_count() - cycles;
printf("took %lu cycles to issue 8 integer ops (%f cycles/iteration)\n", cycles, (float)cycles / ITER);
double cycles_iter = (float)cycles / ITER;
printf("took %lu cycles to issue 8 integer ops (%f cycles/iteration)\n", cycles, cycles_iter);
#undef ITER
}
#endif // __CORTEX_M

View File

@@ -89,7 +89,7 @@ static int float_tests(int argc, const console_cmd_args *argv) {
int res;
for (uint i = 0; i < countof(t); i++) {
thread_join(t[i], &res, INFINITE_TIME);
printf("float thread %u returns %d, val %f\n", i, res, val[i]);
printf("float thread %u returns %d, val %f\n", i, res, (double)val[i]);
}
printf("the above values should be close\n");

View File

@@ -56,7 +56,7 @@ CONFIGHEADER := $(BUILDDIR)/config.h
GLOBAL_INCLUDES := $(BUILDDIR) $(addsuffix /include,$(LKINC))
GLOBAL_OPTFLAGS ?= $(ARCH_OPTFLAGS)
GLOBAL_COMPILEFLAGS := -g -include $(CONFIGHEADER)
GLOBAL_COMPILEFLAGS += -W -Wall -Werror=return-type -Wshadow
GLOBAL_COMPILEFLAGS += -W -Wall -Werror=return-type -Wshadow -Wdouble-promotion
GLOBAL_COMPILEFLAGS += -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wno-nonnull-compare
GLOBAL_COMPILEFLAGS += -fno-common
GLOBAL_CFLAGS := --std=gnu11 -Werror-implicit-function-declaration -Wstrict-prototypes -Wwrite-strings

View File

@@ -2,7 +2,7 @@ LOCAL_DIR := $(GET_LOCAL_DIR)
MODULE := $(LOCAL_DIR)
MODULE_CFLAGS += -Wno-unused-variable -Wno-sign-compare -Wno-parentheses
MODULE_CFLAGS += -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-double-promotion
MODULE_SRCS += \
$(LOCAL_DIR)/k_sin.c \

View File

@@ -742,7 +742,7 @@ static int gfx_draw_mandelbrot(gfx_surface *surface) {
b=0;
mag=0;
iter = 0;
while ((mag < 4.0) && (iter < 200) ) {
while ((mag < 4.0f) && (iter < 200) ) {
float a1;
a1 = a*a - b*b + c;
b = 2.0f * a * b + ci;