diff --git a/pystencils_benchmark/benchmark.py b/pystencils_benchmark/benchmark.py index f3658dff15d8a031d0254d3ebe41ee78bb98d734..1b4dcae7eab6a335cc80f1654fc099a7bef77ef7 100644 --- a/pystencils_benchmark/benchmark.py +++ b/pystencils_benchmark/benchmark.py @@ -48,7 +48,7 @@ def copy_static_files(path: Path) -> None: env = Environment(loader=PackageLoader('pystencils_benchmark'), undefined=StrictUndefined) files = ['Makefile', 'aligned_malloc.h', 'timing.h', 'timing.c', 'include_Clang.mk', 'include_GCC.mk', - 'include_ICC.mk'] + 'include_ICC.mk', 'include_GCCdebug.mk'] for file_name in files: template = env.get_template(file_name).render() if file_name[-1] == 'h': @@ -61,7 +61,7 @@ def copy_static_files(path: Path) -> None: f.write(template) -def kernel_main(kernel: KernelFunction, timing: bool = False): +def kernel_main(kernel: KernelFunction, timing: bool = True): """ Return C code of a benchmark program for the given kernel. @@ -142,16 +142,13 @@ def kernel_header(kernel_ast: KernelFunction, dialect: Backend = Backend.C) -> s def kernel_source(kernel_ast: KernelFunction, dialect: Backend = Backend.C) -> str: kernel_name = kernel_ast.function_name function_source = generate_c(kernel_ast, dialect=dialect) - headers = get_headers(kernel_ast) - # TODO remove this after pystencils update - if isinstance(headers, list): - headers.append(f'"{kernel_name}.h"') - else: - headers.add(f'"{kernel_name}.h"') + headers = {f'"{kernel_name}.h"', '<math.h>', '<stdint.h>'} + headers.update(get_headers(kernel_ast)) jinja_context = { 'function_source': function_source, 'headers': sorted(headers), + 'timing': True, } env = Environment(loader=PackageLoader('pystencils_benchmark'), undefined=StrictUndefined) diff --git a/pystencils_benchmark/templates/include_GCC.mk b/pystencils_benchmark/templates/include_GCC.mk index 7c0c44690030e2a2b29f0597f24e0b6875ff6b5b..c633858f2f897b5255dd9995391cab1bdaad7caf 100644 --- a/pystencils_benchmark/templates/include_GCC.mk +++ b/pystencils_benchmark/templates/include_GCC.mk @@ -1,23 +1,18 @@ CC = gcc -CXX = g++ -FC = gfortran -LINKER = $(CXX) +LINKER = $(CC) ANSI_CFLAGS = -ansi -ANSI_CFLAGS += -std=c++0x +ANSI_CFLAGS += -std=c99 ANSI_CFLAGS += -pedantic ANSI_CFLAGS += -Wextra -CFLAGS = -O3 -Wno-format -Wall $(ANSI_CFLAGS) -fopenmp +CFLAGS = -O3 -Wno-format -Wall $(ANSI_CFLAGS) -fopenmp # More warning pls #CFLAGS += -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wstrict-overflow=5 -Wwrite-strings -Waggregate-return # Maybe too much warnings #CFLAGS += -Wcast-qual -Wswitch-default -Wconversion -Wunreachable-code -CXXFLAGS := $(CFLAGS) # Specific C flags CFLAGS := $(CFLAGS) -Wstrict-prototypes -FCFLAGS = -CPPFLAGS = -std=c++0x LFLAGS = -fopenmp DEFINES = -D_GNU_SOURCE -DNDEBUG INCLUDES = diff --git a/pystencils_benchmark/templates/include_GCCdebug.mk b/pystencils_benchmark/templates/include_GCCdebug.mk new file mode 100644 index 0000000000000000000000000000000000000000..1685617c693bb2540af002caa15185aab30660a6 --- /dev/null +++ b/pystencils_benchmark/templates/include_GCCdebug.mk @@ -0,0 +1,16 @@ +CC = gcc +LINKER = $(CC) + +ANSI_CFLAGS = -ansi +ANSI_CFLAGS += -std=c99 +ANSI_CFLAGS += -pedantic +ANSI_CFLAGS += -Wextra +ANSI_CFLAGS += -O0 +ANSI_CFLAGS += -g + +CFLAGS = -Wno-format -Wall $(ANSI_CFLAGS) +FCFLAGS = +LFLAGS = +DEFINES = -D_GNU_SOURCE +INCLUDES = +LIBS = diff --git a/pystencils_benchmark/templates/main.c b/pystencils_benchmark/templates/main.c index 7f7ad47536790c6315f872b2f3e102a0f520a5a3..f15e9ab54b443a1eafd414216af297d92493937d 100644 --- a/pystencils_benchmark/templates/main.c +++ b/pystencils_benchmark/templates/main.c @@ -9,6 +9,7 @@ #define RESTRICT __restrict__ #define FUNC_PREFIX + void timing(double* wcTime, double* cpuTime); int main(int argc, char **argv) @@ -18,7 +19,7 @@ int main(int argc, char **argv) {%- if alignment > 0 %} {{dataType}} * {{field_name}} = ({{dataType}} *) aligned_malloc_with_offset({{size}}, {{alignment}}, {{offset}}); {%- else %} - {{dataType}} * {{field_name}} = new {{dataType}}[{{elements}}]; + {{dataType}} * {{field_name}} = ({{dataType}} *) malloc({{size}}); {%- endif %} for (unsigned long long i = 0; i < {{elements}}; ++i) {{field_name}}[i] = 0.23; @@ -54,6 +55,6 @@ int main(int argc, char **argv) } {%- for field_name, dataType, elements, size, offset, alignment in fields %} - delete[] {{field_name}}; + free({{field_name}}); {%- endfor %} }