HIP: Heterogenous-computing Interface for Portability
hiprtc.h
1 /*
2 Copyright (c) 2015 - 2023 Advanced Micro Devices, Inc. All rights reserved.
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22 #pragma once
23 
24 #include <hip/hip_common.h>
25 
26 #if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && \
27  (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
28 #include <hip/nvidia_detail/nvidia_hiprtc.h>
29 #elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && \
30  !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 
37 #include <stdlib.h>
38 
39 #if !defined(_WIN32)
40 #pragma GCC visibility push(default)
41 #endif
42 
52 typedef enum hiprtcResult {
66 } hiprtcResult;
67 
72 typedef enum hiprtcJIT_option {
81  HIPRTC_JIT_TARGET_FROM_HIPCONTEXT,
99  HIPRTC_JIT_IR_TO_ISA_OPT_EXT = 10000, //< AMD only. Linker options to be passed on to
100  HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT, //< AMD only. Count of linker options
102 
106 typedef enum hiprtcJITInputType {
117  HIPRTC_JIT_NUM_INPUT_TYPES = (HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES + 3)
127 typedef struct ihiprtcLinkState* hiprtcLinkState;
141 const char* hiprtcGetErrorString(hiprtcResult result);
142 
151 hiprtcResult hiprtcVersion(int* major, int* minor);
156 typedef struct _hiprtcProgram* hiprtcProgram;
157 
170 hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog,
171  const char* name_expression);
172 
187 hiprtcResult hiprtcCompileProgram(hiprtcProgram prog,
188  int numOptions,
189  const char** options);
190 
211 hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog,
212  const char* src,
213  const char* name,
214  int numHeaders,
215  const char** headers,
216  const char** includeNames);
217 
228 hiprtcResult hiprtcDestroyProgram(hiprtcProgram* prog);
229 
247 hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog,
248  const char* name_expression,
249  const char** lowered_name);
250 
260 hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char* log);
261 
271 hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog,
272  size_t* logSizeRet);
273 
283 hiprtcResult hiprtcGetCode(hiprtcProgram prog, char* code);
284 
294 hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t* codeSizeRet);
295 
305 hiprtcResult hiprtcGetBitcode(hiprtcProgram prog, char* bitcode);
306 
317 hiprtcResult hiprtcGetBitcodeSize(hiprtcProgram prog, size_t* bitcode_size);
318 
331 hiprtcResult hiprtcLinkCreate(unsigned int num_options, hiprtcJIT_option* option_ptr,
332  void** option_vals_pptr, hiprtcLinkState* hip_link_state_ptr);
333 
352 hiprtcResult hiprtcLinkAddFile(hiprtcLinkState hip_link_state, hiprtcJITInputType input_type,
353  const char* file_path, unsigned int num_options,
354  hiprtcJIT_option* options_ptr, void** option_values);
355 
376 hiprtcResult hiprtcLinkAddData(hiprtcLinkState hip_link_state, hiprtcJITInputType input_type,
377  void* image, size_t image_size, const char* name,
378  unsigned int num_options, hiprtcJIT_option* options_ptr,
379  void** option_values);
380 
395 hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void** bin_out, size_t* size_out);
396 
406 hiprtcResult hiprtcLinkDestroy(hiprtcLinkState hip_link_state);
407 
408 #if !defined(_WIN32)
409 #pragma GCC visibility pop
410 #endif
411 
412 #ifdef __cplusplus
413 }
414 #endif /* __cplusplus */
415 
416 #else
417 #error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
418 #endif
hiprtcJITInputType
Definition: hiprtc.h:106
Error in linking.
Definition: hiprtc.h:65
Success.
Definition: hiprtc.h:53
Fallback strategy.
Definition: hiprtc.h:83
Log verbose.
Definition: hiprtc.h:85
Invalid name expression.
Definition: hiprtc.h:63
LTO.
Definition: hiprtc.h:93
Input NVVM.
Definition: hiprtc.h:112
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char *name_expression)
Adds the given name exprssion to the runtime compilation program.
Maximum registers.
Definition: hiprtc.h:73
Global symbol names.
Definition: hiprtc.h:90
hiprtcResult hiprtcVersion(int *major, int *minor)
Sets the parameters as major and minor version.
FTZ.
Definition: hiprtc.h:94
FMA.
Definition: hiprtc.h:97
Input fat binary.
Definition: hiprtc.h:109
Invalid input.
Definition: hiprtc.h:56
hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char *log)
Gets the log generated by the runtime compilation program instance.
hiprtcResult hiprtcLinkCreate(unsigned int num_options, hiprtcJIT_option *option_ptr, void **option_vals_pptr, hiprtcLinkState *hip_link_state_ptr)
Creates the link instance via hiprtc APIs.
hiprtcResult hiprtcLinkDestroy(hiprtcLinkState hip_link_state)
Deletes the link instance via hiprtc APIs.
No lowered names before compilation.
Definition: hiprtc.h:62
Invalid program.
Definition: hiprtc.h:57
LLVM archives of boundled bitcode.
Definition: hiprtc.h:116
Input object.
Definition: hiprtc.h:110
Failed in builtin operation.
Definition: hiprtc.h:60
hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t *codeSizeRet)
Gets the size of compilation binary by the runtime compilation program instance.
hiprtcResult
Definition: hiprtc.h:52
Generate debug information.
Definition: hiprtc.h:84
Cache mode.
Definition: hiprtc.h:87
Time from aall clock.
Definition: hiprtc.h:75
Log buffer size in bytes.
Definition: hiprtc.h:79
Global symbol address.
Definition: hiprtc.h:91
hiprtcResult hiprtcCreateProgram(hiprtcProgram *prog, const char *src, const char *name, int numHeaders, const char **headers, const char **includeNames)
Creates an instance of hiprtcProgram with the given input parameters, and sets the output hiprtcProgr...
Global symbol count.
Definition: hiprtc.h:92
Input PTX.
Definition: hiprtc.h:108
Input library.
Definition: hiprtc.h:111
Compilation error.
Definition: hiprtc.h:59
Number of legacy input type.
Definition: hiprtc.h:113
LLVM bundled bitcode.
Definition: hiprtc.h:115
PREC_SQRT.
Definition: hiprtc.h:96
hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char *name_expression, const char **lowered_name)
Gets the lowered (mangled) name from an instance of hiprtcProgram with the given input parameters...
JIT target.
Definition: hiprtc.h:82
Thread per block.
Definition: hiprtc.h:74
Invalid option.
Definition: hiprtc.h:58
Log buffer info.
Definition: hiprtc.h:76
hiprtcResult hiprtcGetBitcodeSize(hiprtcProgram prog, size_t *bitcode_size)
Gets the size of compiled bitcode by the runtime compilation program instance.
hiprtcResult hiprtcDestroyProgram(hiprtcProgram *prog)
Destroys an instance of given hiprtcProgram.
Number of options.
Definition: hiprtc.h:98
Prec_VIV.
Definition: hiprtc.h:95
Failed to create program.
Definition: hiprtc.h:55
LLVM bitcode.
Definition: hiprtc.h:114
hiprtcResult hiprtcGetCode(hiprtcProgram prog, char *code)
Gets the pointer of compilation binary by the runtime compilation program instance.
Log buffer size in bytes.
Definition: hiprtc.h:77
const char * hiprtcGetErrorString(hiprtcResult result)
Returns text string message to explain the error which occurred.
Internal error.
Definition: hiprtc.h:64
Fast compile.
Definition: hiprtc.h:89
hiprtcJIT_option
Definition: hiprtc.h:72
hiprtcResult hiprtcLinkAddFile(hiprtcLinkState hip_link_state, hiprtcJITInputType input_type, const char *file_path, unsigned int num_options, hiprtcJIT_option *options_ptr, void **option_values)
Adds a file with bit code to be linked with options.
New SM3X option.
Definition: hiprtc.h:88
hiprtcResult hiprtcLinkAddData(hiprtcLinkState hip_link_state, hiprtcJITInputType input_type, void *image, size_t image_size, const char *name, unsigned int num_options, hiprtcJIT_option *options_ptr, void **option_values)
Completes the linking of the given program.
hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void **bin_out, size_t *size_out)
Completes the linking of the given program.
No name expression after compilation.
Definition: hiprtc.h:61
Out of memory.
Definition: hiprtc.h:54
Log buffer error.
Definition: hiprtc.h:78
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char **options)
Compiles the given runtime compilation program.
Input cubin.
Definition: hiprtc.h:107
Generate line information.
Definition: hiprtc.h:86
Optimization level.
Definition: hiprtc.h:80