forked from oneapi-src/SYCLomatic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenHelperFunction.cpp
More file actions
275 lines (260 loc) · 11.2 KB
/
Copy pathGenHelperFunction.cpp
File metadata and controls
275 lines (260 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
//===--------------- GenHelperFunction.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "GenHelperFunction.h"
#include "Utility.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_os_ostream.h"
#include <fstream>
namespace clang {
namespace dpct {
const std::string DpctAllContentStr =
#include "clang/DPCT/dpct.hpp.inc"
;
const std::string AtomicAllContentStr =
#include "clang/DPCT/atomic.hpp.inc"
;
const std::string BindlessImageAllContentStr =
#include "clang/DPCT/bindless_images.hpp.inc"
;
const std::string BlasUtilsAllContentStr =
#include "clang/DPCT/blas_utils.hpp.inc"
;
const std::string DnnlUtilsAllContentStr =
#include "clang/DPCT/dnnl_utils.hpp.inc"
;
const std::string DeviceAllContentStr =
#include "clang/DPCT/device.hpp.inc"
;
const std::string DplUtilsAllContentStr =
#include "clang/DPCT/dpl_utils.hpp.inc"
;
const std::string GraphAllContentStr =
#include "clang/DPCT/graph.hpp.inc"
;
const std::string ImageAllContentStr =
#include "clang/DPCT/image.hpp.inc"
;
const std::string KernelAllContentStr =
#include "clang/DPCT/kernel.hpp.inc"
;
const std::string MathAllContentStr =
#include "clang/DPCT/math.hpp.inc"
;
const std::string MemoryAllContentStr =
#include "clang/DPCT/memory.hpp.inc"
;
const std::string UtilAllContentStr =
#include "clang/DPCT/util.hpp.inc"
;
const std::string RngUtilsAllContentStr =
#include "clang/DPCT/rng_utils.hpp.inc"
;
const std::string LibCommonUtilsAllContentStr =
#include "clang/DPCT/lib_common_utils.hpp.inc"
;
const std::string CclUtilsAllContentStr =
#include "clang/DPCT/ccl_utils.hpp.inc"
;
const std::string SparseUtilsAllContentStr =
#include "clang/DPCT/sparse_utils.hpp.inc"
;
const std::string FftUtilsAllContentStr =
#include "clang/DPCT/fft_utils.hpp.inc"
;
const std::string LapackUtilsAllContentStr =
#include "clang/DPCT/lapack_utils.hpp.inc"
;
const std::string GroupUtilsAllContentStr =
#include "clang/DPCT/group_utils.hpp.inc"
;
const std::string BlasGemmUtilsAllContentStr =
#include "clang/DPCT/blas_gemm_utils.hpp.inc"
;
const std::string CompatServiceAllContentStr =
#include "clang/DPCT/compat_service.hpp.inc"
;
const std::string DplExtrasAlgorithmAllContentStr =
#include "clang/DPCT/dpl_extras/algorithm.h.inc"
;
const std::string DplExtrasFunctionalAllContentStr =
#include "clang/DPCT/dpl_extras/functional.h.inc"
;
const std::string DplExtrasIteratorsAllContentStr =
#include "clang/DPCT/dpl_extras/iterators.h.inc"
;
const std::string DplExtrasMemoryAllContentStr =
#include "clang/DPCT/dpl_extras/memory.h.inc"
;
const std::string DplExtrasNumericAllContentStr =
#include "clang/DPCT/dpl_extras/numeric.h.inc"
;
const std::string DplExtrasVectorAllContentStr =
#include "clang/DPCT/dpl_extras/vector.h.inc"
;
const std::string DplExtrasDpcppExtensionsAllContentStr =
#include "clang/DPCT/dpl_extras/dpcpp_extensions.h.inc"
;
const std::string DplExtrasIteratorAdaptorAllContentStr =
#include "clang/DPCT/dpl_extras/iterator_adaptor.h.inc"
;
const std::string GroupUtilsDetailAllContentStr =
#include "clang/DPCT/detail/group_utils_detail.hpp.inc"
;
const std::string MathDetailAllContentStr =
#include "clang/DPCT/detail/math_detail.hpp.inc"
;
const std::string MemoryDetailAllContentStr =
#include "clang/DPCT/detail/memory_detail.hpp.inc"
;
const std::string LibCommonUtilsDetailAllContentStr =
#include "clang/DPCT/detail/lib_common_utils_detail.hpp.inc"
;
const std::string BlasUtilsDetailAllContentStr =
#include "clang/DPCT/detail/blas_utils_detail.hpp.inc"
;
const std::string LapackUtilsDetailAllContentStr =
#include "clang/DPCT/detail/lapack_utils_detail.hpp.inc"
;
const std::string RngUtilsDetailAllContentStr =
#include "clang/DPCT/detail/rng_utils_detail.hpp.inc"
;
const std::string SparseUtilsDetailAllContentStr =
#include "clang/DPCT/detail/sparse_utils_detail.hpp.inc"
;
const std::string DnnlUtilsDetailAllContentStr =
#include "clang/DPCT/detail/dnnl_utils_detail.hpp.inc"
;
const std::string BlasGemmUtilsDetailAllContentStr =
#include "clang/DPCT/detail/blas_gemm_utils_detail.hpp.inc"
;
const std::string CclUtilsDetailAllContentStr =
#include "clang/DPCT/detail/ccl_utils_detail.hpp.inc"
;
const std::string CodePinAllContentStr =
#include "clang/DPCT/codepin/codepin.hpp.inc"
;
const std::string CodePinSerializationBasicAllContentStr =
#include "clang/DPCT/codepin/serialization/basic.hpp.inc"
;
const std::string ZEUtilsAllContentStr =
#include "clang/DPCT/ze_utils.hpp.inc"
;
const std::string CmakeAllContentStr =
#include "clang/DPCT/dpct.cmake.inc"
;
void genHelperFunction(const clang::tooling::UnifiedPath &OutRoot) {
if (!llvm::sys::fs::is_directory(OutRoot.getCanonicalPath()))
createDirectories(OutRoot);
clang::tooling::UnifiedPath ToPath =
appendPath(OutRoot.getCanonicalPath().str(), "include");
if (!llvm::sys::fs::is_directory(ToPath.getCanonicalPath()))
createDirectories(ToPath);
ToPath = appendPath(ToPath.getCanonicalPath().str(), "dpct");
if (!llvm::sys::fs::is_directory(ToPath.getCanonicalPath()))
createDirectories(ToPath);
if (!llvm::sys::fs::is_directory(
appendPath(ToPath.getCanonicalPath().str(), "dpl_extras")))
createDirectories(
appendPath(ToPath.getCanonicalPath().str(), "dpl_extras"));
if (!llvm::sys::fs::is_directory(
appendPath(ToPath.getCanonicalPath().str(), "codepin")))
createDirectories(appendPath(ToPath.getCanonicalPath().str(), "codepin"));
if (!llvm::sys::fs::is_directory(
appendPath(ToPath.getCanonicalPath().str(), "detail")))
createDirectories(appendPath(ToPath.getCanonicalPath().str(), "detail"));
if (!llvm::sys::fs::is_directory(
appendPath(appendPath(ToPath.getCanonicalPath().str(), "codepin"),
"serialization")))
createDirectories(
appendPath(appendPath(ToPath.getCanonicalPath().str(), "codepin"),
"serialization"));
#define GENERATE_ALL_FILE_CONTENT(VAR_NAME, FOLDER_NAME, FILE_NAME) \
{ \
std::ofstream VAR_NAME##File( \
appendPath(appendPath(ToPath.getCanonicalPath().str(), FOLDER_NAME), \
#FILE_NAME), \
std::ios::out | std::ios::trunc); \
std::string Code = VAR_NAME##AllContentStr; \
VAR_NAME##File << Code; \
VAR_NAME##File.flush(); \
}
GENERATE_ALL_FILE_CONTENT(Atomic, ".", atomic.hpp)
GENERATE_ALL_FILE_CONTENT(BindlessImage, ".", bindless_images.hpp)
GENERATE_ALL_FILE_CONTENT(BlasUtils, ".", blas_utils.hpp)
GENERATE_ALL_FILE_CONTENT(Device, ".", device.hpp)
GENERATE_ALL_FILE_CONTENT(Dpct, ".", dpct.hpp)
GENERATE_ALL_FILE_CONTENT(DplUtils, ".", dpl_utils.hpp)
GENERATE_ALL_FILE_CONTENT(DnnlUtils, ".", dnnl_utils.hpp)
GENERATE_ALL_FILE_CONTENT(Graph, ".", graph.hpp)
GENERATE_ALL_FILE_CONTENT(Image, ".", image.hpp)
GENERATE_ALL_FILE_CONTENT(Kernel, ".", kernel.hpp)
GENERATE_ALL_FILE_CONTENT(Math, ".", math.hpp)
GENERATE_ALL_FILE_CONTENT(Memory, ".", memory.hpp)
GENERATE_ALL_FILE_CONTENT(Util, ".", util.hpp)
GENERATE_ALL_FILE_CONTENT(RngUtils, ".", rng_utils.hpp)
GENERATE_ALL_FILE_CONTENT(LibCommonUtils, ".", lib_common_utils.hpp)
GENERATE_ALL_FILE_CONTENT(ZEUtils, ".", ze_utils.hpp)
GENERATE_ALL_FILE_CONTENT(CclUtils, ".", ccl_utils.hpp)
GENERATE_ALL_FILE_CONTENT(SparseUtils, ".", sparse_utils.hpp)
GENERATE_ALL_FILE_CONTENT(FftUtils, ".", fft_utils.hpp)
GENERATE_ALL_FILE_CONTENT(LapackUtils, ".", lapack_utils.hpp)
GENERATE_ALL_FILE_CONTENT(GroupUtils, ".", group_utils.hpp)
GENERATE_ALL_FILE_CONTENT(BlasGemmUtils, ".", blas_gemm_utils.hpp)
GENERATE_ALL_FILE_CONTENT(CompatService, ".", compat_service.hpp)
GENERATE_ALL_FILE_CONTENT(GroupUtilsDetail, "detail", group_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(MathDetail, "detail", math_detail.hpp)
GENERATE_ALL_FILE_CONTENT(MemoryDetail, "detail", memory_detail.hpp)
GENERATE_ALL_FILE_CONTENT(LibCommonUtilsDetail, "detail",
lib_common_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(BlasUtilsDetail, "detail", blas_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(LapackUtilsDetail, "detail",
lapack_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(RngUtilsDetail, "detail", rng_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(SparseUtilsDetail, "detail",
sparse_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(DnnlUtilsDetail, "detail", dnnl_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(BlasGemmUtilsDetail, "detail",
blas_gemm_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(CclUtilsDetail, "detail", ccl_utils_detail.hpp)
GENERATE_ALL_FILE_CONTENT(CodePin, "codepin", codepin.hpp)
GENERATE_ALL_FILE_CONTENT(CodePinSerializationBasic, "codepin/serialization",
basic.hpp)
GENERATE_ALL_FILE_CONTENT(DplExtrasAlgorithm, "dpl_extras", algorithm.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasFunctional, "dpl_extras", functional.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasIterators, "dpl_extras", iterators.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasMemory, "dpl_extras", memory.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasNumeric, "dpl_extras", numeric.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasVector, "dpl_extras", vector.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasDpcppExtensions, "dpl_extras",
dpcpp_extensions.h)
GENERATE_ALL_FILE_CONTENT(DplExtrasIteratorAdaptor, "dpl_extras",
iterator_adaptor.h)
#undef GENERATE_ALL_FILE_CONTENT
}
void genCmakeHelperFunction(const clang::tooling::UnifiedPath &OutRoot) {
if (!llvm::sys::fs::is_directory(OutRoot.getCanonicalPath()))
createDirectories(OutRoot);
clang::tooling::UnifiedPath ToPath =
appendPath(OutRoot.getCanonicalPath().str(), ".");
#define GENERATE_ALL_FILE_CONTENT(VAR_NAME, FOLDER_NAME, FILE_NAME) \
{ \
std::ofstream VAR_NAME##File( \
appendPath(appendPath(ToPath.getCanonicalPath().str(), FOLDER_NAME), \
#FILE_NAME), \
std::ios::out | std::ios::trunc); \
std::string Code = VAR_NAME##AllContentStr; \
VAR_NAME##File << Code; \
VAR_NAME##File.flush(); \
}
GENERATE_ALL_FILE_CONTENT(Cmake, ".", dpct.cmake)
#undef GENERATE_ALL_FILE_CONTENT
}
} // namespace dpct
} // namespace clang