cuda.c: fix typos in comments
[ppcg.git] / cuda_common.c
blob802e9c0bbb1a077bef87cec2fbad71c6bd75aff8
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 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 "rewrite.h"
18 /* Open the "input" file for reading and open the host .cu file
19 * and the kernel .hu and .cu files for writing.
20 * Add the necessary includes and copy all code from the input
21 * file up to the openscop pragma to the host .cu file.
23 void cuda_open_files(struct cuda_info *info, const char *input)
25 char name[PATH_MAX];
26 const char *base;
27 const char *ext;
28 int len;
30 base = strrchr(input, '/');
31 if (base)
32 base++;
33 else
34 base = input;
35 ext = strrchr(base, '.');
36 len = ext ? ext - base : strlen(base);
38 memcpy(name, base, len);
39 strcpy(name + len, "_host.cu");
40 info->host_c = fopen(name, "w");
42 strcpy(name + len, "_kernel.cu");
43 info->kernel_c = fopen(name, "w");
45 strcpy(name + len, "_kernel.hu");
46 info->kernel_h = fopen(name, "w");
47 fprintf(info->host_c, "#include <assert.h>\n");
48 fprintf(info->host_c, "#include \"%s\"\n", name);
49 fprintf(info->kernel_c, "#include \"%s\"\n", name);
50 fprintf(info->kernel_h, "#include \"cuda.h\"\n\n");
52 info->input = fopen(input, "r");
53 copy_before_scop(info->input, info->host_c);
56 /* Copy all code starting at the endscop pragma from the input
57 * file to the host .cu file and close all input and output files.
59 void cuda_close_files(struct cuda_info *info)
61 copy_after_scop(info->input, info->host_c);
62 fclose(info->input);
63 fclose(info->kernel_c);
64 fclose(info->kernel_h);
65 fclose(info->host_c);