SWDEV-299127 - Merge 'develop' into 'amd-staging'

Change-Id: Ia3bfdf39fe7d27ff644c9d6dbb566c6f2e0012de


[ROCm/hip commit: fc664ee979]
This commit is contained in:
Jenkins
2023-03-07 00:11:22 +00:00
commit 9e3e55fb8b
3 muutettua tiedostoa jossa 62 lisäystä ja 40 poistoa
+18 -2
Näytä tiedosto
@@ -159,13 +159,13 @@ hiprtcLinkComplete(rtc_link_state, // hiprtc link state
If the hiprtcLinkComplete returns successfully, the generated binary can be loaded and run using the hipModule* APIs.
```cpp
hipModuleLoadData( &module, binary );
hipModuleLoadData(&module, binary);
```
#### Note
- The compiled binary must be loaded before hiprtc link instance is destroyed using the hiprtcLinkDestroy API.
```cpp
hiprtcLinkDestroy( rtc_link_state);
hiprtcLinkDestroy(rtc_link_state);
```
- The correct sequence of calls is : hiprtcLinkCreate, hiprtcLinkAddData or hiprtcLinkAddFile, hiprtcLinkComplete, hiprtcModuleLoadData, hiprtcLinkDestroy.
@@ -186,6 +186,22 @@ HIPRTC_JIT_INPUT_LLVM_ARCHIVES_OF_BUNDLED_BITCODE = 102,
HIPRTC_JIT_NUM_INPUT_TYPES = (HIPRTC_JIT_NUM_LEGACY_INPUT_TYPES + 3)
```
#### Link Options
- `HIPRTC_JIT_IR_TO_ISA_OPT_EXT` - AMD Only. Options to be passed on to link step of compiler by `hiprtcLinkCreate`.
- `HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT` - AMD Only. Count of options passed on to link step of compiler.
Example:
```cpp
const char* isaopts[] = {"-mllvm", "-inline-threshold=1", "-mllvm", "-inlinehint-threshold=1"};
std::vector<hiprtcJIT_option> jit_options = {HIPRTC_JIT_IR_TO_ISA_OPT_EXT,
HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT};
size_t isaoptssize = 4;
const void* lopts[] = {(void*)isaopts, (void*)(isaoptssize)};
hiprtcLinkState linkstate;
hiprtcLinkCreate(2, jit_options.data(), (void**)lopts, &linkstate);
```
## Error Handling
HIPRTC defines the hiprtcResult enumeration type and a function hiprtcGetErrorString for API call error handling. hiprtcResult enum defines the API result codes. HIPRTC APIs return hiprtcResult to indicate the call result. hiprtcGetErrorString function returns a string describing the given hiprtcResult code, e.g., HIPRTC_SUCCESS to "HIPRTC_SUCCESS". For unrecognized enumeration values, it returns "Invalid HIPRTC error code".
+43 -37
Näytä tiedosto
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
Copyright (c) 2015 - 2023 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -23,9 +23,11 @@ THE SOFTWARE.
#include <hip/hip_common.h>
#if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
#include <hip/nvidia_detail/nvidia_hiprtc.h>
#elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
#if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && \
(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
#include <hip/nvidia_detail/nvidia_hiprtc.h>
#elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && \
!(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
/**
* @addtogroup Runtime Runtime Compilation
@@ -40,7 +42,7 @@ extern "C" {
#include <stdlib.h>
#if !defined(_WIN32)
#pragma GCC visibility push (default)
#pragma GCC visibility push(default)
#endif
/**
@@ -50,21 +52,27 @@ extern "C" {
*/
typedef enum hiprtcResult {
HIPRTC_SUCCESS = 0,
HIPRTC_ERROR_OUT_OF_MEMORY = 1,
HIPRTC_ERROR_PROGRAM_CREATION_FAILURE = 2,
HIPRTC_ERROR_INVALID_INPUT = 3,
HIPRTC_ERROR_INVALID_PROGRAM = 4,
HIPRTC_ERROR_INVALID_OPTION = 5,
HIPRTC_ERROR_COMPILATION = 6,
HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7,
HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8,
HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9,
HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10,
HIPRTC_ERROR_INTERNAL_ERROR = 11,
HIPRTC_ERROR_LINKING = 100
HIPRTC_SUCCESS = 0,
HIPRTC_ERROR_OUT_OF_MEMORY = 1,
HIPRTC_ERROR_PROGRAM_CREATION_FAILURE = 2,
HIPRTC_ERROR_INVALID_INPUT = 3,
HIPRTC_ERROR_INVALID_PROGRAM = 4,
HIPRTC_ERROR_INVALID_OPTION = 5,
HIPRTC_ERROR_COMPILATION = 6,
HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7,
HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8,
HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9,
HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10,
HIPRTC_ERROR_INTERNAL_ERROR = 11,
HIPRTC_ERROR_LINKING = 100
} hiprtcResult;
/**
* @brief hiprtcJIT_option
* @enum
*
*/
typedef enum hiprtcJIT_option {
HIPRTC_JIT_MAX_REGISTERS = 0,
HIPRTC_JIT_THREADS_PER_BLOCK,
@@ -92,8 +100,15 @@ typedef enum hiprtcJIT_option {
HIPRTC_JIT_PREC_SQRT,
HIPRTC_JIT_FMA,
HIPRTC_JIT_NUM_OPTIONS,
HIPRTC_JIT_IR_TO_ISA_OPT_EXT = 10000, //! AMD only. Linker options to be passed on to
HIPRTC_JIT_IR_TO_ISA_OPT_COUNT_EXT, //! AMD only. Count of linker options
} hiprtcJIT_option;
/**
* @brief hiprtcJITInputType
* @enum
*
*/
typedef enum hiprtcJITInputType {
HIPRTC_JIT_INPUT_CUBIN = 0,
HIPRTC_JIT_INPUT_PTX,
@@ -110,7 +125,7 @@ typedef enum hiprtcJITInputType {
typedef struct ihiprtcLinkState* hiprtcLinkState;
/**
/**
* @brief Returns text string message to explain the error which occurred
*
* @param [in] result code to convert to string.
@@ -145,8 +160,7 @@ typedef struct _hiprtcProgram* hiprtcProgram;
*
* @see hiprtcResult
*/
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog,
const char* name_expression);
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char* name_expression);
/**
* @brief Compiles the given runtime compilation program.
@@ -161,9 +175,7 @@ hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog,
*
* @see hiprtcResult
*/
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog,
int numOptions,
const char** options);
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char** options);
/**
* @brief Creates an instance of hiprtcProgram with the given input parameters,
@@ -184,12 +196,8 @@ hiprtcResult hiprtcCompileProgram(hiprtcProgram prog,
*
* @see hiprtcResult
*/
hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog,
const char* src,
const char* name,
int numHeaders,
const char** headers,
const char** includeNames);
hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog, const char* src, const char* name,
int numHeaders, const char** headers, const char** includeNames);
/**
* @brief Destroys an instance of given hiprtcProgram.
@@ -204,8 +212,8 @@ hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog,
hiprtcResult hiprtcDestroyProgram(hiprtcProgram* prog);
/**
* @brief Gets the lowered (mangled) name from an instance of hiprtcProgram with the given input parameters,
* and sets the output lowered_name with it.
* @brief Gets the lowered (mangled) name from an instance of hiprtcProgram with the given input
* parameters, and sets the output lowered_name with it.
*
* @param [in] prog runtime compilation program instance.
* @param [in] name_expression const char pointer to the name expression.
@@ -220,8 +228,7 @@ hiprtcResult hiprtcDestroyProgram(hiprtcProgram* prog);
*
* @see hiprtcResult
*/
hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog,
const char* name_expression,
hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char* name_expression,
const char** lowered_name);
/**
@@ -244,8 +251,7 @@ hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char* log);
*
* @see hiprtcResult
*/
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog,
size_t* logSizeRet);
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog, size_t* logSizeRet);
/**
* @brief Gets the pointer of compilation binary by the runtime compilation program instance.
@@ -336,7 +342,7 @@ hiprtcResult hiprtcLinkAddFile(hiprtcLinkState hip_link_state, hiprtcJITInputTyp
* @see hiprtcResult
*/
hiprtcResult hiprtcLinkAddData(hiprtcLinkState hip_link_state, hiprtcJITInputType input_type,
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);
@@ -82,7 +82,7 @@ bool argValidation() {
#ifndef __HIP_PLATFORM_NVIDIA__
// nvcc doesnt support kernelfunc(NULL) for api
ret = hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, NULL, 0, 0);
if (ret != hipErrorInvalidValue) {
if (ret != hipErrorInvalidValue && ret != hipErrorInvalidDeviceFunction) {
printf("ArgValidation : Inappropritate error value returned for"
" kernelfunc(NULL). gridSize %d, blkSize %d, Error: '%s'(%d)\n",
gridSize, blockSize, hipGetErrorString(ret), ret);