-
Notifications
You must be signed in to change notification settings - Fork 11
/
hat.tosd
420 lines (328 loc) · 15.1 KB
/
hat.tosd
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# HAT TOML Schema
[toml-schema]
version = "0.0.0.3"
# Types to be used elsewhere in this schema
[types]
# Parameter type of arguments and return values
[types.paramType]
type = "table"
# Name of the parameter
[types.paramType.name]
type = "string"
# Friendly string describing the parameter
[types.paramType.description]
type = "string"
# The logical type of the parameter, such as if it's really a multi-dimensional array
[types.paramType.logical_type]
type = "string"
allowedvalues = ["affine_array", "runtime_array", "void", "element"]
# The declared type of the parameter as a valid C type declaration
[types.paramType.declared_type]
type = "string"
# The type of elements in the parameter. E.g. "float" if the declared type is "const float*", "float*", or "float"
[types.paramType.element_type]
type = "string"
# The usage of the parameter in the context of the function
[types.paramType.usage]
type = "string"
allowedvalues = [ "input_output", "input", "output" ]
# Optional array giving the logical shape of the buffer for an affine_array logical type, e.g. [256, 256]
[types.paramType.shape]
type = "array"
arraytype = "integer"
optional = true
# Optional array giving the affine map coefficients used to map from multi-dimensional coordinates to an
# offset in the C-style array buffer for an affine_array logical type.
# e.g. [256, 1] would indicate that for index (i, j), the position in the buffer is (256 * i) + (1 * j)
# Should have the same number of elements as the shape array
[types.paramType.affine_map]
type = "array"
arraytype = "integer"
optional = true
# Offset from the buffer pointer where the array data begins for an affine_array logical type.
[types.paramType.affine_offset]
type = "integer"
optional = true
# A string describing the number of elements in the buffer for a runtime_array logical type.
# Typically expected to reference other parameters in the function in their shape order.
# e.g. "N", "lda * K" for shape (lda, K)
[types.paramType.size]
type = "string"
optional = true
# Type for a function described by TOML data and declared in the C declaration later in the HAT file
[types.functionType]
type = "table"
##########
# Required
##########
# The name of the function
[types.functionType.name]
type = "string"
# A friendly description of what the function does
[types.functionType.description]
type = "string"
# The calling convention for this function
[types.functionType.calling_convention]
type = "string"
allowedvalues = [ "stdcall", "cdecl", "fastcall", "vectorcall", "device" ]
# An array of arguments to the function
[types.functionType.arguments]
type = "array"
arraytype = "types.paramType"
# The return type description of the function
[types.functionType.return]
typeof = "paramType"
##########
# Optional
##########
# The parameters needed to launch this function, if applicable
[types.functionType.launch_parameters]
type = "array"
optional = true
# The dynamic shared memory size in bytes to be allocated for this device function
[types.functionType.dynamic_shared_mem_bytes]
type = "integer"
optional = true
# The function that is launched by this function
[types.functionType.launches]
type = "string"
optional = true
# The provider of this function, if any
[types.functionType.provider]
type = "string"
optional = true
# The runtime used by the function
[types.functionType.runtime]
type = "string"
optional = true
# Optional additional usage-specific information about the function that isn't part of this schema
[types.functionType.auxiliary]
type = "table"
optional = true
# Type of an external library referenced by this metadata, such as a library that was linked into this one or a dependency a user must link
[types.referencedLibraryType]
type = "table"
# Friendly name of the library
[types.referencedLibraryType.name]
type = "string"
# Friendly version string of the library
[types.referencedLibraryType.version]
type = "string"
# The name of the library that is linked or a flag to link it with, as could be used by a build system.
# E.g. "ucrtbase.dll" or "/openmp"
[types.referencedLibraryType.target_file]
type = "string"
# Definition of the well-known tables/keys/etc in HAT TOML data
[elements]
# Description of the HAT contents
[elements.description]
type = "table"
# Optional user-specified author name
[elements.description.author]
type = "string"
optional = true
# Version number of the HAT package
[elements.description.version]
type = "string"
# Url to the full license text for this package
[elements.description.license_url]
type = "string"
# Optional additional description that isn't part of this schema
[elements.description.auxiliary]
type = "table"
optional = true
# Collection of host functions declared within the HAT file and their metadata
# The keys in a collection are not prescribed by the schema, and in this case are the names of the functions as the HAT format does not support function overloading.
[elements.functions]
type = "collection"
typeof = "functionType"
# Collection of device functions declared within the HAT file and their metadata
# The keys in a collection are not prescribed by the schema, and in this case are the names of the functions as the HAT format does not support function overloading.
[elements.device_functions]
type = "collection"
typeof = "functionType"
# Table of information about the target device the functions described in this HAT file are intended to be used with
[elements.target]
type = "table"
# Required target features in order to run these functions without error
[elements.target.required]
type = "table"
# The OS that this HAT package is built for
[elements.target.required.os]
type = "string"
allowedvalues = [ "windows", "macos", "linux" ]
# Required CPU characteristics
[elements.target.required.CPU]
type = "table"
# Instruction set architecture, e.g. "x86_64"
[elements.target.required.CPU.architecture]
type = "string"
# Instruction set extensions used by these functions, e.g. "AVX2", "AVX512", etc
[elements.target.required.CPU.extensions]
type = "array"
arraytype = "string"
# Optional CPU runtime library
[elements.target.required.CPU.runtime]
type = "string"
allowedvalues = [ "openmp" ]
optional = true
# Optional additional information not defined in this schema
[elements.target.required.CPU.auxiliary]
type = "table"
optional = true
# Required GPU characteristics if there are GPU functions in this HAT package
[elements.target.required.GPU]
type = "table"
optional = true
# Required GPU runtime library
[elements.target.required.GPU.runtime]
type = "string"
allowedvalues = [ "cuda", "rocm", "vulkan" ]
# Minimum GPU instruction set version
[elements.target.required.GPU.instruction_set_version]
type = "string"
# Minimum number of GPU threads functions declared in this .hat file will attempt to use
[elements.target.required.GPU.min_threads]
type = "integer"
# Minimum global memory in KB that will be allocated
[elements.target.required.GPU.min_global_memory_KB]
type = "integer"
# Minimum shared memory in KB that will be allocated
[elements.target.required.GPU.min_shared_memory_KB]
type = "integer"
# Minimum texture memory in KB that will be allocated
[elements.target.required.GPU.min_texture_memory_KB]
type = "integer"
# Optional additional requirements not specified in this schema
[elements.target.required.GPU.auxiliary]
type = "table"
optional = true
# Target characteristics that these functions are optimized for, but are not required in order to function
[elements.target.optimized_for]
type = "table"
optional = true
# Optimized CPU target information
[elements.target.optimized_for.CPU]
type = "table"
optional = true
# Full name and version of the CPU, e.g. "Intel Xeon E5-4669 v4"
[elements.target.optimized_for.CPU.name]
type = "string"
# Processor family, e.g. "Broadwell"
[elements.target.optimized_for.CPU.family]
type = "string"
# Base processor clock speed
[elements.target.optimized_for.CPU.clock_frequency]
type = "integer"
# Number of CPU cores
[elements.target.optimized_for.CPU.cores]
type = "integer"
# Number of CPU threads
[elements.target.optimized_for.CPU.threads]
type = "integer"
# Optimized cache characteristics
[elements.target.optimized_for.CPU.cache]
type = "table"
optional = true
# Instruction cache size in KB
[elements.target.optimized_for.CPU.cache.instruction_KB]
type = "integer"
# Ordered cache sizes in KB
[elements.target.optimized_for.CPU.cache.sizes_KB]
type = "array"
arraytype = "integer"
# Ordered cache line sizes in bytes
[elements.target.optimized_for.CPU.cache.line_sizes]
type = "array"
arraytype = "integer"
# Optional additional optimized target characteristics not specified in this schema
[elements.target.optimized_for.CPU.auxiliary]
type = "table"
optional = true
# Optimized GPU target information
[elements.target.optimized_for.GPU]
type = "table"
optional = true
# Full name and version of the GPU, e.g. "NVIDIA GTX 3090"
[elements.target.optimized_for.GPU.name]
type = "string"
# Architecture family, e.g. "Ampere"
[elements.target.optimized_for.GPU.family]
type = "string"
# Base GPU clock speed
[elements.target.optimized_for.GPU.clock_frequency]
type = "integer"
# Best optimized GPU core count
[elements.target.optimized_for.GPU.cores]
type = "integer"
# Best optimized GPU thread count
[elements.target.optimized_for.GPU.threads]
type = "integer"
# Optimized instruction set version
[elements.target.optimized_for.GPU.instruction_set_version]
type = "string"
# Optimized global memory size in KB
[elements.target.optimized_for.GPU.global_memory_KB]
type = "integer"
# Optimized shared memory size in KB
[elements.target.optimized_for.GPU.shared_memory_KB]
type = "integer"
# Optimized shared memory cache line size in bytes
[elements.target.optimized_for.GPU.shared_memory_line_size]
type = "integer"
# Optimized texture memory size in KB
[elements.target.optimized_for.GPU.texture_memory_KB]
type = "integer"
# Optional additional optimized target characteristics not specified in this schema
[elements.target.optimized_for.GPU.auxiliary]
type = "table"
optional = true
# Table describing dependencies that consumers of this HAT package will need to
# provide or otherwise satisfy in order to properly consume the package, such as library
# files in the package to link and dynamic libraries to make available at runtime
[elements.dependencies]
type = "table"
# Name of the library file in this HAT package that the consumer should link
[elements.description.link_target]
type = "string"
# Names of files in this HAT package that must be deployed with a built binary that consumes this package,
# such as dynamic library files
[elements.description.deploy_files]
type = "array"
arraytype = "string"
# Dynamic libraries outside of this HAT package that must be made available at runtime
[elements.dependencies.dynamic]
type = "array"
arraytype = "types.referencedLibraryType"
# Optonal additonal dependency information not specified in this schema
[elements.dependencies.auxiliary]
type = "table"
optional = true
# Table giving information about how this HAT package was built. It is expected
# that a consumer of the package may find this information useful but may not
# necessarily need to act on in order to successfully consume this package
[elements.compiled_with]
type = "table"
# Compiler name and version, e.g. "MSVC141"
[elements.compiled_with.compiler]
type = "string"
# Compilation flags, e.g. "-std=c++14 -ffast-math"
[elements.compiled_with.flags]
type = "string"
# C Runtime linked against, e.g. "ucrt"
[elements.compiled_with.crt]
type = "string"
# Libraries that were statically linked into the library files in this HAT package
[elements.compiled_with.libraries]
type = "array"
arraytype = "types.referencedLibraryType"
# Optional additional compilation information not specified in this schema
[elements.compiled_with.auxiliary]
type = "table"
optional = true
# Table containing the C header code in this HAT file
[elements.declaration]
type = "table"
# String containing the entirety of the C header code
[elements.declaration.code]
type = "string"