include/hip/hiprtc.h Source File

include/hip/hiprtc.h Source File#

HIP Runtime API Reference: include/hip/hiprtc.h Source File
hiprtc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8
9#include <hip/hip_common.h>
10#include <hip/linker_types.h>
11
12#if !defined(__HIP_PLATFORM_AMD__) && defined(__HIP_PLATFORM_NVIDIA__)
13#include <hip/nvidia_detail/nvidia_hiprtc.h>
14#elif defined(__HIP_PLATFORM_AMD__) && !defined(__HIP_PLATFORM_NVIDIA__)
15
16#ifdef __cplusplus
17#include <cstdlib>
18#else
19#include <stdlib.h>
20#endif
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26#if !defined(_WIN32)
27#pragma GCC visibility push(default)
28#endif
29
57#define hiprtcJIT_option hipJitOption
58#define HIPRTC_JIT_MAX_REGISTERS \
59 hipJitOptionMaxRegisters
61#define HIPRTC_JIT_THREADS_PER_BLOCK \
62 hipJitOptionThreadsPerBlock
63#define HIPRTC_JIT_WALL_TIME hipJitOptionWallTime
64#define HIPRTC_JIT_INFO_LOG_BUFFER \
65 hipJitOptionInfoLogBuffer
67#define HIPRTC_JIT_INFO_LOG_BUFFER_SIZE_BYTES \
68 hipJitOptionInfoLogBufferSizeBytes
70#define HIPRTC_JIT_ERROR_LOG_BUFFER \
71 hipJitOptionErrorLogBuffer
73#define HIPRTC_JIT_ERROR_LOG_BUFFER_SIZE_BYTES \
74 hipJitOptionErrorLogBufferSizeBytes
76#define HIPRTC_JIT_OPTIMIZATION_LEVEL \
77 hipJitOptionOptimizationLevel
80#define HIPRTC_JIT_TARGET_FROM_HIPCONTEXT \
81 hipJitOptionTargetFromContext
83#define HIPRTC_JIT_TARGET hipJitOptionTarget
84#define HIPRTC_JIT_FALLBACK_STRATEGY hipJitOptionFallbackStrategy
85#define HIPRTC_JIT_GENERATE_DEBUG_INFO \
86 hipJitOptionGenerateDebugInfo
87#define HIPRTC_JIT_LOG_VERBOSE hipJitOptionLogVerbose
88#define HIPRTC_JIT_GENERATE_LINE_INFO \
89 hipJitOptionGenerateLineInfo
90#define HIPRTC_JIT_CACHE_MODE hipJitOptionCacheMode
91#define HIPRTC_JIT_NEW_SM3X_OPT hipJitOptionSm3xOpt
92#define HIPRTC_JIT_FAST_COMPILE hipJitOptionFastCompile
93#define HIPRTC_JIT_GLOBAL_SYMBOL_NAMES \
94 hipJitOptionGlobalSymbolNames
96#define HIPRTC_JIT_GLOBAL_SYMBOL_ADDRESS \
97 hipJitOptionGlobalSymbolAddresses
99#define HIPRTC_JIT_GLOBAL_SYMBOL_COUNT \
100 hipJitOptionGlobalSymbolCount
101#define HIPRTC_JIT_LTO \
102 hipJitOptionLto
104#define HIPRTC_JIT_FTZ \
105 hipJitOptionFtz
107#define HIPRTC_JIT_PREC_DIV \
108 hipJitOptionPrecDiv
111#define HIPRTC_JIT_PREC_SQRT \
112 hipJitOptionPrecSqrt
115#define HIPRTC_JIT_FMA \
116 hipJitOptionFma
119#define HIPRTC_JIT_POSITION_INDEPENDENT_CODE \
120 hipJitOptionPositionIndependentCode
122#define HIPRTC_JIT_MIN_CTA_PER_SM \
123 hipJitOptionMinCTAPerSM
126#define HIPRTC_JIT_MAX_THREADS_PER_BLOCK \
127 hipJitOptionMaxThreadsPerBlock
129#define HIPRTC_JIT_OVERRIDE_DIRECT_VALUES \
130 hipJitOptionOverrideDirectiveValues
132#define HIPRTC_JIT_NUM_OPTIONS hipJitOptionNumOptions
133#define HIPRTC_JIT_IR_TO_ISA_OPT_EXT \
134 hipJitOptionIRtoISAOptExt
136#define HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT \
137 hipJitOptionIRtoISAOptCountExt
139
142#define hiprtcJITInputType hipJitInputType
143#define HIPRTC_JIT_INPUT_CUBIN hipJitInputCubin
144#define HIPRTC_JIT_INPUT_PTX hipJitInputPtx
145#define HIPRTC_JIT_INPUT_FATBINARY hipJitInputFatBinary
146#define HIPRTC_JIT_INPUT_OBJECT \
147 hipJitInputObject
148#define HIPRTC_JIT_INPUT_LIBRARY \
149 hipJitInputLibrary
150#define HIPRTC_JIT_INPUT_NVVM \
151 hipJitInputNvvm
152#define HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES \
153 hipJitNumLegacyInputTypes
154#define HIPRTC_JIT_INPUT_LLVM_BITCODE \
155 hipJitInputLLVMBitcode
156#define HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE \
157 hipJitInputLLVMBundledBitcode
158#define HIPRTC_JIT_INPUT_LLVM_ARCHIVES_OF_BUNDLED_BITCODE \
159 hipJitInputLLVMArchivesOfBundledBitcode
162#define HIPRTC_JIT_INPUT_SPIRV hipJitInputSpirv
163#define HIPRTC_JIT_NUM_INPUT_TYPES hipJitNumInputTypes
172typedef struct ihiprtcLinkState* hiprtcLinkState;
187
198hiprtcResult hiprtcVersion(int* major, int* minor);
199
204typedef struct _hiprtcProgram* hiprtcProgram;
205
218hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char* name_expression);
219
234hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char* const* options);
235
256hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog, const char* src, const char* name,
257 int numHeaders, const char* const* headers,
258 const char* const* includeNames);
259
271
289hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char* name_expression,
290 const char** lowered_name);
291
302
313
324
335
346
358
371hiprtcResult hiprtcLinkCreate(unsigned int num_options, hiprtcJIT_option* option_ptr,
372 void** option_vals_pptr, hiprtcLinkState* hip_link_state_ptr);
373
393 const char* file_path, unsigned int num_options,
394 hiprtcJIT_option* options_ptr, void** option_values);
395
417 void* image, size_t image_size, const char* name,
418 unsigned int num_options, hiprtcJIT_option* options_ptr,
419 void** option_values);
420
435hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void** bin_out, size_t* size_out);
436
447
448#if !defined(_WIN32)
449#pragma GCC visibility pop
450#endif
451
452#ifdef __cplusplus
453}
454#endif /* __cplusplus */
455
456#else
457#error ("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
458#endif
#define hiprtcJIT_option
Definition hiprtc.h:57
#define hiprtcJITInputType
Definition hiprtc.h:142
hiprtcResult
Definition hiprtc.h:39
@ HIPRTC_ERROR_PROGRAM_CREATION_FAILURE
Failed to create program.
Definition hiprtc.h:42
@ HIPRTC_ERROR_INVALID_PROGRAM
Invalid program.
Definition hiprtc.h:44
@ HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION
No name expression after compilation.
Definition hiprtc.h:48
@ HIPRTC_ERROR_INVALID_OPTION
Invalid option.
Definition hiprtc.h:45
@ HIPRTC_ERROR_INVALID_INPUT
Invalid input.
Definition hiprtc.h:43
@ HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID
Invalid name expression.
Definition hiprtc.h:50
@ HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION
No lowered names before compilation.
Definition hiprtc.h:49
@ HIPRTC_SUCCESS
Success.
Definition hiprtc.h:40
@ HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE
Failed in builtin operation.
Definition hiprtc.h:47
@ HIPRTC_ERROR_INTERNAL_ERROR
Internal error.
Definition hiprtc.h:51
@ HIPRTC_ERROR_COMPILATION
Compilation error.
Definition hiprtc.h:46
@ HIPRTC_ERROR_OUT_OF_MEMORY
Out of memory.
Definition hiprtc.h:41
@ HIPRTC_ERROR_LINKING
Error in linking.
Definition hiprtc.h:52
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 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 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 hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char *const *options)
Compiles the given runtime compilation program.
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 hiprtcCreateProgram(hiprtcProgram *prog, const char *src, const char *name, int numHeaders, const char *const *headers, const char *const *includeNames)
Creates an instance of hiprtcProgram with the given input parameters, and sets the output hiprtcProgr...
hiprtcResult hiprtcVersion(int *major, int *minor)
Sets the parameters as major and minor version.
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog, size_t *logSizeRet)
Gets the size of log generated by the runtime compilation program instance.
hiprtcResult hiprtcGetBitcode(hiprtcProgram prog, char *bitcode)
Gets the pointer of compiled bitcode by the runtime compilation program instance.
struct ihiprtcLinkState * hiprtcLinkState
Definition hiprtc.h:172
struct _hiprtcProgram * hiprtcProgram
Definition hiprtc.h:204