From d3152b14153065a8e2961cd9e165fa323cb6f82e Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:11:25 +0530 Subject: [PATCH 1/2] SWDEV-373630 - Modified occupancy query tests to conform with new error messages. (#3175) Change-Id: I20e16e78cb5f170609b33e0770b7fca5bff2b280 [ROCm/hip commit: 5557d17afc6abba779234aaf9498e79d923f04f2] --- .../runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp b/projects/hip/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp index e06ea9c600..49f0ed1bf7 100644 --- a/projects/hip/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp +++ b/projects/hip/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp @@ -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); From c808e5394f0c88fe7fdcd17ac2b0dd224ad1f155 Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Mon, 6 Mar 2023 21:11:39 +0530 Subject: [PATCH 2/2] SWDEV-384013 - Add HIPRTC_JIT_IR_TO_ISA_OPT_EXT header changes (#3176) Change-Id: Ie466cd02f2aed30e1568c4d76d60c9048af0fe4c [ROCm/hip commit: fdc00547cb40a4f1a60be8b924d272b602c79d70] --- projects/hip/docs/markdown/hip_rtc.md | 20 ++++++- projects/hip/include/hip/hiprtc.h | 80 ++++++++++++++------------- 2 files changed, 61 insertions(+), 39 deletions(-) diff --git a/projects/hip/docs/markdown/hip_rtc.md b/projects/hip/docs/markdown/hip_rtc.md index ef77c8bc77..24db183b87 100644 --- a/projects/hip/docs/markdown/hip_rtc.md +++ b/projects/hip/docs/markdown/hip_rtc.md @@ -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 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". diff --git a/projects/hip/include/hip/hiprtc.h b/projects/hip/include/hip/hiprtc.h index 2c421605ad..4eb5ee6bdc 100644 --- a/projects/hip/include/hip/hiprtc.h +++ b/projects/hip/include/hip/hiprtc.h @@ -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 -#if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) - #include -#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 +#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 #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);