diff --git a/pystencils_benchmark/benchmark_gpu.py b/pystencils_benchmark/benchmark_gpu.py index 67ce0dde0261a72b6c8fa7586cb290c1053932c7..d68a31dd685f0512bf5d9a7f8a7758939d65d732 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 98fcaaa19d9a753fd346da9480fd4935d112f2e5..ea385709951281a23f08ca5f95e07be0fafa5496 100644 --- a/pystencils_benchmark/templates/Makefile +++ b/pystencils_benchmark/templates/Makefile @@ -14,6 +14,8 @@ INCLUDES += -I./include 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) @@ -28,6 +30,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 $@