print more understandable error message in case of unbounded arrays
[ppcg.git] / cuda_common.c
blob497353f4319f4cbfd7e931ae591b037cdd95b911
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include <ctype.h>
12 #include <limits.h>
13 #include <string.h>
15 #include "cuda_common.h"
16 #include "ppcg.h"
18 /* Open the host .cu file and the kernel .hu and .cu files for writing.
19 * Add the necessary includes.
21 void cuda_open_files(struct cuda_info *info, const char *input)
23 char name[PATH_MAX];
24 int len;
26 len = ppcg_extract_base_name(name, input);
28 strcpy(name + len, "_host.cu");
29 info->host_c = fopen(name, "w");
31 strcpy(name + len, "_kernel.cu");
32 info->kernel_c = fopen(name, "w");
34 strcpy(name + len, "_kernel.hu");
35 info->kernel_h = fopen(name, "w");
36 fprintf(info->host_c, "#include <assert.h>\n");
37 fprintf(info->host_c, "#include <stdio.h>\n");
38 fprintf(info->host_c, "#include \"%s\"\n", name);
39 fprintf(info->kernel_c, "#include \"%s\"\n", name);
40 fprintf(info->kernel_h, "#include \"cuda.h\"\n\n");
43 /* Close all output files.
45 void cuda_close_files(struct cuda_info *info)
47 fclose(info->kernel_c);
48 fclose(info->kernel_h);
49 fclose(info->host_c);