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#pragma once
7
8#include <hip/hip_common.h>
9#include <hip/linker_types.h>
10
11#if !defined(__HIP_PLATFORM_AMD__) && defined(__HIP_PLATFORM_NVIDIA__)
12#include <hip/nvidia_detail/nvidia_hiprtc.h>
13#elif defined(__HIP_PLATFORM_AMD__) && !defined(__HIP_PLATFORM_NVIDIA__)
14
15#ifdef __cplusplus
16#include <cstdlib>
17#else
18#include <stdlib.h>
19#endif
20
21#ifdef __cplusplus
22extern "C" {
23#endif /* __cplusplus */
24
25#if !defined(_WIN32)
26#pragma GCC visibility push(default)
27#endif
28
56#define hiprtcJIT_option hipJitOption
57#define HIPRTC_JIT_MAX_REGISTERS \
58 hipJitOptionMaxRegisters
60#define HIPRTC_JIT_THREADS_PER_BLOCK \
61 hipJitOptionThreadsPerBlock
62#define HIPRTC_JIT_WALL_TIME hipJitOptionWallTime
63#define HIPRTC_JIT_INFO_LOG_BUFFER \
64 hipJitOptionInfoLogBuffer
66#define HIPRTC_JIT_INFO_LOG_BUFFER_SIZE_BYTES \
67 hipJitOptionInfoLogBufferSizeBytes
69#define HIPRTC_JIT_ERROR_LOG_BUFFER \
70 hipJitOptionErrorLogBuffer
72#define HIPRTC_JIT_ERROR_LOG_BUFFER_SIZE_BYTES \
73 hipJitOptionErrorLogBufferSizeBytes
75#define HIPRTC_JIT_OPTIMIZATION_LEVEL \
76 hipJitOptionOptimizationLevel
79#define HIPRTC_JIT_TARGET_FROM_HIPCONTEXT \
80 hipJitOptionTargetFromContext
82#define HIPRTC_JIT_TARGET hipJitOptionTarget
83#define HIPRTC_JIT_FALLBACK_STRATEGY hipJitOptionFallbackStrategy
84#define HIPRTC_JIT_GENERATE_DEBUG_INFO \
85 hipJitOptionGenerateDebugInfo
86#define HIPRTC_JIT_LOG_VERBOSE hipJitOptionLogVerbose
87#define HIPRTC_JIT_GENERATE_LINE_INFO \
88 hipJitOptionGenerateLineInfo
89#define HIPRTC_JIT_CACHE_MODE hipJitOptionCacheMode
90#define HIPRTC_JIT_NEW_SM3X_OPT hipJitOptionSm3xOpt
91#define HIPRTC_JIT_FAST_COMPILE hipJitOptionFastCompile
92#define HIPRTC_JIT_GLOBAL_SYMBOL_NAMES \
93 hipJitOptionGlobalSymbolNames
95#define HIPRTC_JIT_GLOBAL_SYMBOL_ADDRESS \
96 hipJitOptionGlobalSymbolAddresses
98#define HIPRTC_JIT_GLOBAL_SYMBOL_COUNT \
99 hipJitOptionGlobalSymbolCount
100#define HIPRTC_JIT_LTO \
101 hipJitOptionLto
103#define HIPRTC_JIT_FTZ \
104 hipJitOptionFtz
106#define HIPRTC_JIT_PREC_DIV \
107 hipJitOptionPrecDiv
110#define HIPRTC_JIT_PREC_SQRT \
111 hipJitOptionPrecSqrt
114#define HIPRTC_JIT_FMA \
115 hipJitOptionFma
118#define HIPRTC_JIT_POSITION_INDEPENDENT_CODE \
119 hipJitOptionPositionIndependentCode
121#define HIPRTC_JIT_MIN_CTA_PER_SM \
122 hipJitOptionMinCTAPerSM
125#define HIPRTC_JIT_MAX_THREADS_PER_BLOCK \
126 hipJitOptionMaxThreadsPerBlock
128#define HIPRTC_JIT_OVERRIDE_DIRECT_VALUES \
129 hipJitOptionOverrideDirectiveValues
131#define HIPRTC_JIT_NUM_OPTIONS hipJitOptionNumOptions
132#define HIPRTC_JIT_IR_TO_ISA_OPT_EXT \
133 hipJitOptionIRtoISAOptExt
135#define HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT \
136 hipJitOptionIRtoISAOptCountExt
138
141#define hiprtcJITInputType hipJitInputType
142#define HIPRTC_JIT_INPUT_CUBIN hipJitInputCubin
143#define HIPRTC_JIT_INPUT_PTX hipJitInputPtx
144#define HIPRTC_JIT_INPUT_FATBINARY hipJitInputFatBinary
145#define HIPRTC_JIT_INPUT_OBJECT \
146 hipJitInputObject
147#define HIPRTC_JIT_INPUT_LIBRARY \
148 hipJitInputLibrary
149#define HIPRTC_JIT_INPUT_NVVM \
150 hipJitInputNvvm
151#define HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES \
152 hipJitNumLegacyInputTypes
153#define HIPRTC_JIT_INPUT_LLVM_BITCODE \
154 hipJitInputLLVMBitcode
155#define HIPRTC_JIT_INPUT_LLVM_BUNDLED_BITCODE \
156 hipJitInputLLVMBundledBitcode
157#define HIPRTC_JIT_INPUT_LLVM_ARCHIVES_OF_BUNDLED_BITCODE \
158 hipJitInputLLVMArchivesOfBundledBitcode
161#define HIPRTC_JIT_INPUT_SPIRV hipJitInputSpirv
162#define HIPRTC_JIT_NUM_INPUT_TYPES hipJitNumInputTypes
171typedef struct ihiprtcLinkState* hiprtcLinkState;
186
197hiprtcResult hiprtcVersion(int* major, int* minor);
198
203typedef struct _hiprtcProgram* hiprtcProgram;
204
217hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char* name_expression);
218
233hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char* const* options);
234
255hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog, const char* src, const char* name,
256 int numHeaders, const char* const* headers,
257 const char* const* includeNames);
258
270
288hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char* name_expression,
289 const char** lowered_name);
290
301
312
323
334
345
357
370hiprtcResult hiprtcLinkCreate(unsigned int num_options, hiprtcJIT_option* option_ptr,
371 void** option_vals_pptr, hiprtcLinkState* hip_link_state_ptr);
372
392 const char* file_path, unsigned int num_options,
393 hiprtcJIT_option* options_ptr, void** option_values);
394
416 void* image, size_t image_size, const char* name,
417 unsigned int num_options, hiprtcJIT_option* options_ptr,
418 void** option_values);
419
434hiprtcResult hiprtcLinkComplete(hiprtcLinkState hip_link_state, void** bin_out, size_t* size_out);
435
446
447#if !defined(_WIN32)
448#pragma GCC visibility pop
449#endif
450
451#ifdef __cplusplus
452}
453#endif /* __cplusplus */
454
455#else
456#error ("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
457#endif
#define hiprtcJIT_option
Definition hiprtc.h:56
#define hiprtcJITInputType
Definition hiprtc.h:141
hiprtcResult
Definition hiprtc.h:38
@ HIPRTC_ERROR_PROGRAM_CREATION_FAILURE
Failed to create program.
Definition hiprtc.h:41
@ HIPRTC_ERROR_INVALID_PROGRAM
Invalid program.
Definition hiprtc.h:43
@ HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION
No name expression after compilation.
Definition hiprtc.h:47
@ HIPRTC_ERROR_INVALID_OPTION
Invalid option.
Definition hiprtc.h:44
@ HIPRTC_ERROR_INVALID_INPUT
Invalid input.
Definition hiprtc.h:42
@ HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID
Invalid name expression.
Definition hiprtc.h:49
@ HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION
No lowered names before compilation.
Definition hiprtc.h:48
@ HIPRTC_SUCCESS
Success.
Definition hiprtc.h:39
@ HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE
Failed in builtin operation.
Definition hiprtc.h:46
@ HIPRTC_ERROR_INTERNAL_ERROR
Internal error.
Definition hiprtc.h:50
@ HIPRTC_ERROR_COMPILATION
Compilation error.
Definition hiprtc.h:45
@ HIPRTC_ERROR_OUT_OF_MEMORY
Out of memory.
Definition hiprtc.h:40
@ HIPRTC_ERROR_LINKING
Error in linking.
Definition hiprtc.h:51
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:171
struct _hiprtcProgram * hiprtcProgram
Definition hiprtc.h:203