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,
15 #include "cuda_common.h"
17 /* Open the host .cu file and the kernel .hu and .cu files for writing.
18 * Add the necessary includes.
20 void cuda_open_files(struct cuda_info
*info
, const char *input
)
27 base
= strrchr(input
, '/');
32 ext
= strrchr(base
, '.');
33 len
= ext
? ext
- base
: strlen(base
);
35 memcpy(name
, base
, len
);
36 strcpy(name
+ len
, "_host.cu");
37 info
->host_c
= fopen(name
, "w");
39 strcpy(name
+ len
, "_kernel.cu");
40 info
->kernel_c
= fopen(name
, "w");
42 strcpy(name
+ len
, "_kernel.hu");
43 info
->kernel_h
= fopen(name
, "w");
44 fprintf(info
->host_c
, "#include <assert.h>\n");
45 fprintf(info
->host_c
, "#include \"%s\"\n", name
);
46 fprintf(info
->kernel_c
, "#include \"%s\"\n", name
);
47 fprintf(info
->kernel_h
, "#include \"cuda.h\"\n\n");
50 /* Close all output files.
52 void cuda_close_files(struct cuda_info
*info
)
54 fclose(info
->kernel_c
);
55 fclose(info
->kernel_h
);