From 96c63098a1c8e5f40d2dfd4157a47e29601eb662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6nig?= <jan.hoenig@fau.de> Date: Mon, 21 Feb 2022 22:29:44 +0100 Subject: [PATCH] Working CUDA benchmark Version. CUDA needs '.cu' files, otherwise it doesn't work? --- pystencils_benchmark/benchmark_gpu.py | 7 +++++-- pystencils_benchmark/templates/Makefile | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pystencils_benchmark/benchmark_gpu.py b/pystencils_benchmark/benchmark_gpu.py index 67ce0dd..d68a31d 100644 --- a/pystencils_benchmark/benchmark_gpu.py +++ b/pystencils_benchmark/benchmark_gpu.py @@ -41,10 +41,11 @@ def generate_benchmark_gpu(kernel_asts: Union[KernelFunction, List[KernelFunctio f.write(header) source = kernel_source(kernel_ast) - with open(src_path / f'{kernel_name}.c', 'w+') as f: + # TODO CUDA specific suffix + with open(src_path / f'{kernel_name}.cu', 'w+') as f: f.write(source) - with open(src_path / 'main.c', 'w+') as f: + with open(src_path / 'main.cu', 'w+') as f: f.write(kernel_main(kernel_asts)) copy_static_files(path) @@ -77,6 +78,8 @@ def copy_static_files(path: Path) -> None: target_path = include_path / file_name elif file_name[-1] == 'c': target_path = src_path / file_name + # TODO CUDA specific suffix: + target_path = target_path.with_suffix('.cu') else: target_path = path / file_name with open(target_path, 'w+') as f: diff --git a/pystencils_benchmark/templates/Makefile b/pystencils_benchmark/templates/Makefile index 66b68b8..d62c513 100644 --- a/pystencils_benchmark/templates/Makefile +++ b/pystencils_benchmark/templates/Makefile @@ -29,6 +29,8 @@ LIBS += -llikwid VPATH = $(SRC_DIR) ASM = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.s,$(wildcard $(SRC_DIR)/*.c)) OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.c)) +# TODO CUDA specific SUFFIX +OBJ += $(patsubst $(SRC_DIR)/%.cu, $(BUILD_DIR)/%.o,$(wildcard $(SRC_DIR)/*.cu)) CFLAGS := $(CFLAGS) $(DEFINES) $(INCLUDES) @@ -43,6 +45,12 @@ $(BUILD_DIR)/%.o: %.c $(Q)$(CC) -c $(CFLAGS) $< -o $@ $(Q)$(CC) $(CFLAGS) -MT $(@:.d=.o) -MM $< > $(BUILD_DIR)/$*.d +# TODO CUDA specific SUFFIX +$(BUILD_DIR)/%.o: %.cu + @echo "===> COMPILE $@" + $(Q)$(CC) -c $(CFLAGS) $< -o $@ + $(Q)$(CC) $(CFLAGS) -MT $(@:.d=.o) -MM $< > $(BUILD_DIR)/$*.d + $(BUILD_DIR)/%.s: %.c @echo "===> GENERATE ASM $@" $(Q)$(CC) -S $(CFLAGS) $< -o $@ -- GitLab