24 #include <hip/hip_common.h>
26 #if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
27 #include <hip/nvidia_detail/nvidia_hiprtc.h>
28 #elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
43 #pragma GCC visibility push (default)
52 typedef enum hiprtcResult {
54 HIPRTC_ERROR_OUT_OF_MEMORY = 1,
55 HIPRTC_ERROR_PROGRAM_CREATION_FAILURE = 2,
56 HIPRTC_ERROR_INVALID_INPUT = 3,
57 HIPRTC_ERROR_INVALID_PROGRAM = 4,
58 HIPRTC_ERROR_INVALID_OPTION = 5,
59 HIPRTC_ERROR_COMPILATION = 6,
60 HIPRTC_ERROR_LINKING = 7,
61 HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE = 8,
62 HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 9,
63 HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 10,
64 HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 11,
65 HIPRTC_ERROR_INTERNAL_ERROR = 12
68 typedef enum hiprtcJIT_option {
69 HIPRTC_JIT_MAX_REGISTERS = 0,
70 HIPRTC_JIT_THREADS_PER_BLOCK,
72 HIPRTC_JIT_INFO_LOG_BUFFER,
73 HIPRTC_JIT_INFO_LOG_BUFFER_SIZE_BYTES,
74 HIPRTC_JIT_ERROR_LOG_BUFFER,
75 HIPRTC_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,
76 HIPRTC_JIT_OPTIMIZATION_LEVEL,
77 HIPRTC_JIT_TARGET_FROM_HIPCONTEXT,
79 HIPRTC_JIT_FALLBACK_STRATEGY,
80 HIPRTC_JIT_GENERATE_DEBUG_INFO,
81 HIPRTC_JIT_LOG_VERBOSE,
82 HIPRTC_JIT_GENERATE_LINE_INFO,
83 HIPRTC_JIT_CACHE_MODE,
84 HIPRTC_JIT_NEW_SM3X_OPT,
85 HIPRTC_JIT_FAST_COMPILE,
86 HIPRTC_JIT_GLOBAL_SYMBOL_NAMES,
87 HIPRTC_JIT_GLOBAL_SYMBOL_ADDRESS,
88 HIPRTC_JIT_GLOBAL_SYMBOL_COUNT,
94 HIPRTC_JIT_NUM_OPTIONS,
97 typedef enum hiprtcJITInputType {
98 HIPRTC_JIT_INPUT_CUBIN = 0,
100 HIPRTC_JIT_INPUT_FATBINARY,
101 HIPRTC_JIT_INPUT_OBJECT,
102 HIPRTC_JIT_INPUT_LIBRARY,
103 HIPRTC_JIT_INPUT_NVVM,
104 HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES,
105 HIPRTC_JIT_INPUT_LLVM_BITCODE = 100,
106 HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE = 101,
107 HIPRTC_JIT_INPUT_LLVM_ARCHIVES_OF_BUNDLED_BITCODE = 102,
108 HIPRTC_JIT_NUM_INPUT_TYPES = (HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES + 3)
109 } hiprtcJITInputType;
111 typedef struct ihiprtcLinkState* hiprtcLinkState;
135 typedef struct _hiprtcProgram* hiprtcProgram;
149 const char* name_expression);
166 const char** options);
191 const char** headers,
192 const char** includeNames);
224 const char* name_expression,
225 const char** lowered_name);
305 void** option_vals_pptr, hiprtcLinkState* hip_link_state_ptr);
322 const char* file_path,
unsigned int num_options,
323 hiprtcJIT_option* options_ptr,
void** option_values);
340 void* image,
size_t image_size,
const char* name,
341 unsigned int num_options, hiprtcJIT_option* options_ptr,
342 void** option_values);
373 #pragma GCC visibility pop
384 #error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog, size_t *logSizeRet)
Gets the size of log generated by the runtime compilation program instance.
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char *name_expression)
Adds the given name exprssion to the runtime compilation program.
hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void **bin_out, size_t *size_out)
Completes the linking of the given program.
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.
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,...
const char * hiprtcGetErrorString(hiprtcResult result)
Returns text string message to explain the error which occurred.
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...
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 hiprtcGetCodeSize(hiprtcProgram prog, size_t *codeSizeRet)
Gets the size of compilation binary by the runtime compilation program instance.
hiprtcResult hiprtcLinkDestroy(hiprtcLinkState hip_link_state)
Deletes the link instance via hiprtc APIs.
hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char *log)
Gets the log generated by the runtime compilation program instance.
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char **options)
Compiles the given runtime compilation program.
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 hiprtcGetBitcodeSize(hiprtcProgram prog, size_t *bitcode_size)
Gets the size of compiled bitcode by the runtime compilation program instance.
hiprtcResult hiprtcGetBitcode(hiprtcProgram prog, char *bitcode)
Gets the pointer of compiled bitcode by the runtime compilation program instance.
hiprtcResult hiprtcDestroyProgram(hiprtcProgram *prog)
Destroys an instance of given hiprtcProgram.
hiprtcResult hiprtcGetCode(hiprtcProgram prog, char *code)
Gets the pointer of compilation binary by the runtime compilation program instance.
hiprtcResult hiprtcVersion(int *major, int *minor)
Sets the parameters as major and minor version.