From 8a2b0b74244ea5ee8cf6dcde21ea0e06a279c29d Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Tue, 15 Dec 2020 17:38:08 -0500 Subject: [PATCH] Remove hip-hcc codes: Part three 1.Rename include/hip/hcc_detail/ as include/hip/amd_detail/ 2.Rename include/hip/nvcc_detail/ as include/hip/nvidia_detail/ 3.Create __HIP_PLATFORM_AMD__ to replace __HIP_PLATFORM_HCC__ 4.Create __HIP_PLATFORM_NVIDIA__ to replace __HIP_PLATFORM_NVCC__ After hcc_detail, nvcc_detail, __HIP_PLATFORM_HCC__ and __HIP_PLATFORM_NVCC__ have been removed from upstream, they will be removed from hip runtime. Change-Id: I1ae457effd739d6c25bca203c1724b026be21fce --- hipamd/CMakeLists.txt | 16 +- hipamd/CONTRIBUTING.md | 4 +- hipamd/README.md | 2 +- hipamd/bin/hipconfig | 4 +- hipamd/docs/doxygen-input/doxy.cfg | 4 +- hipamd/docs/markdown/device_md_gen.py | 2 +- hipamd/docs/markdown/hip_faq.md | 2 +- .../docs/markdown/hip_porting_driver_api.md | 10 +- hipamd/docs/markdown/hip_porting_guide.md | 12 +- hipamd/hip-config.cmake.in | 2 +- hipamd/hip_prof_gen.py | 2 +- .../channel_descriptor.h | 8 +- .../{hcc_detail => amd_detail}/concepts.hpp | 0 .../{hcc_detail => amd_detail}/cuda/cuda.h | 0 .../cuda/math_functions.h | 0 .../device_functions.h | 8 +- .../device_library_decls.h | 8 +- .../{hcc_detail => amd_detail}/driver_types.h | 4 +- .../functional_grid_launch.hpp | 0 .../{hcc_detail => amd_detail}/grid_launch.h | 0 .../grid_launch.hpp | 0 .../grid_launch_GGL.hpp | 0 .../{hcc_detail => amd_detail}/helpers.hpp | 0 .../{hcc_detail => amd_detail}/hip_atomic.h | 0 .../{hcc_detail => amd_detail}/hip_common.h | 6 +- .../{hcc_detail => amd_detail}/hip_complex.h | 8 +- .../hip_cooperative_groups.h | 10 +- .../hip_cooperative_groups_helper.h | 14 +- .../hip/{hcc_detail => amd_detail}/hip_fp16.h | 10 +- .../{hcc_detail => amd_detail}/hip_fp16_gcc.h | 0 .../hip_fp16_math_fwd.h | 0 .../hip/{hcc_detail => amd_detail}/hip_ldg.h | 4 +- .../{hcc_detail => amd_detail}/hip_memory.h | 6 +- .../{hcc_detail => amd_detail}/hip_runtime.h | 32 +- .../hip_runtime_api.h | 18 +- .../hip_runtime_prof.h | 6 +- .../hip_surface_types.h | 10 +- .../hip_texture_types.h | 14 +- .../hip_vector_types.h | 8 +- .../hip/{hcc_detail => amd_detail}/hiprtc.h | 0 .../{hcc_detail => amd_detail}/host_defines.h | 6 +- .../hsa_helpers.hpp | 0 .../library_types.h | 4 +- .../llvm_intrinsics.h | 8 +- .../macro_based_grid_launch.hpp | 0 .../math_functions.h | 6 +- .../hip/{hcc_detail => amd_detail}/math_fwd.h | 0 .../{hcc_detail => amd_detail}/ockl_image.h | 0 .../program_state.hpp | 0 .../surface_functions.h | 6 +- .../texture_fetch_functions.h | 2 +- .../texture_functions.h | 8 +- .../texture_indirect_functions.h | 2 +- .../texture_types.h | 6 +- hipamd/include/hip/channel_descriptor.h | 10 +- hipamd/include/hip/device_functions.h | 8 +- hipamd/include/hip/driver_types.h | 8 +- hipamd/include/hip/hcc_detail | 1 + .../hip/hcc_detail/elfio/elf_types.hpp | 748 ---------------- hipamd/include/hip/hcc_detail/elfio/elfio.hpp | 740 ---------------- .../hip/hcc_detail/elfio/elfio_dump.hpp | 825 ------------------ .../hip/hcc_detail/elfio/elfio_dynamic.hpp | 217 ----- .../hip/hcc_detail/elfio/elfio_header.hpp | 142 --- .../hip/hcc_detail/elfio/elfio_note.hpp | 144 --- .../hip/hcc_detail/elfio/elfio_relocation.hpp | 280 ------ .../hip/hcc_detail/elfio/elfio_section.hpp | 240 ----- .../hip/hcc_detail/elfio/elfio_segment.hpp | 178 ---- .../hip/hcc_detail/elfio/elfio_strings.hpp | 84 -- .../hip/hcc_detail/elfio/elfio_symbols.hpp | 220 ----- .../hip/hcc_detail/elfio/elfio_utils.hpp | 157 ---- hipamd/include/hip/hip_common.h | 18 +- hipamd/include/hip/hip_complex.h | 10 +- hipamd/include/hip/hip_cooperative_groups.h | 10 +- hipamd/include/hip/hip_ext.h | 2 +- hipamd/include/hip/hip_fp16.h | 8 +- hipamd/include/hip/hip_runtime.h | 10 +- hipamd/include/hip/hip_runtime_api.h | 10 +- hipamd/include/hip/hip_texture_types.h | 10 +- hipamd/include/hip/hip_vector_types.h | 8 +- hipamd/include/hip/hiprtc.h | 12 +- hipamd/include/hip/library_types.h | 8 +- hipamd/include/hip/math_functions.h | 10 +- .../hip/nvcc_detail/hip_cooperative_groups.h | 12 - .../hip/nvcc_detail/hip_texture_types.h | 6 - .../channel_descriptor.h | 4 +- .../hip_complex.h | 4 +- .../nvidia_detail/hip_cooperative_groups.h | 12 + .../hip_runtime.h | 4 +- .../hip_runtime_api.h | 6 +- .../hip/nvidia_detail/hip_texture_types.h | 6 + hipamd/include/hip/texture_types.h | 8 +- hipamd/packaging/hip-base.postinst | 5 + hipamd/packaging/hip-base.txt | 7 +- hipamd/packaging/hip-hcc.postinst | 29 - hipamd/packaging/hip-hcc.prerm | 31 - hipamd/packaging/hip-hcc.txt | 58 -- hipamd/rocclr/CMakeLists.txt | 10 +- hipamd/rocclr/hip_conversions.hpp | 4 +- hipamd/rocclr/hip_platform.cpp | 2 +- hipamd/rocclr/hip_prof_api.h | 2 +- hipamd/rocclr/hip_prof_gen.py | 2 +- hipamd/rocclr/hip_surface.cpp | 2 +- hipamd/rocclr/hip_texture.cpp | 2 +- hipamd/samples/0_Intro/bit_extract/README.md | 2 +- .../0_Intro/bit_extract/bit_extract.cpp | 4 +- .../0_Intro/module_api/launchKernelHcc.cpp | 2 +- .../samples/0_Intro/square/square.hipref.cpp | 2 +- .../1_Utils/hipCommander/hipCommander.cpp | 4 +- .../hipDispatchEnqueueRateMT.cpp | 2 +- .../hipDispatchLatency/hipDispatchLatency.cpp | 4 +- hipamd/samples/1_Utils/hipInfo/README.md | 2 +- hipamd/samples/1_Utils/hipInfo/hipInfo.cpp | 2 +- hipamd/tests/src/cppstd/is_callable_test.hpp | 2 +- hipamd/tests/src/deviceLib/hipComplex.cpp | 2 +- .../deviceLib/hipDoublePrecisionMathHost.cpp | 6 +- .../deviceLib/hipSinglePrecisionMathHost.cpp | 8 +- hipamd/tests/src/deviceLib/hip_ballot.cpp | 2 +- hipamd/tests/src/deviceLib/hip_test_ldg.cpp | 2 +- .../src/dynamicLoading/bit_extract_kernel.cpp | 4 +- .../tests/src/experimental/xcompile/gapi.sh | 6 +- .../src/experimental/xcompile/ghipapi.sh | 4 +- .../tests/src/experimental/xcompile/gxxapi.sh | 6 +- .../src/experimental/xcompile/gxxhipapi.sh | 4 +- .../src/experimental/xcompile/hipapig.sh | 2 +- .../src/experimental/xcompile/hipapigxx.sh | 2 +- .../tests/src/experimental/xcompile/hipg.sh | 2 +- .../src/experimental/xcompile/hipgapi.sh | 2 +- .../tests/src/experimental/xcompile/hipgxx.sh | 2 +- .../src/experimental/xcompile/hipgxxapi.sh | 2 +- hipamd/tests/src/g++/hipMalloc.cpp | 2 +- hipamd/tests/src/gcc/LaunchKernel.c | 2 +- hipamd/tests/src/gcc/hipMalloc.c | 4 +- hipamd/tests/src/hipPointerAttrib.cpp | 10 +- hipamd/tests/src/kernel/hipDynamicShared.cpp | 2 +- hipamd/tests/src/kernel/inline_asm_vadd.cpp | 4 +- hipamd/tests/src/kernel/launch_bounds.cpp | 2 +- .../device/hipGetDeviceAttribute.cpp | 2 +- .../runtimeApi/event/hipEventElapsedTime.cpp | 2 +- .../src/runtimeApi/memory/hipHostMalloc.cpp | 2 +- .../memory/hipMallocManaged_MultiScenario.cpp | 4 +- .../src/runtimeApi/memory/hipMemcpy3D.cpp | 6 +- .../src/runtimeApi/memory/hipMemset3D.cpp | 4 +- .../runtimeApi/memory/p2p_copy_coherency.cpp | 2 +- .../module/hipModuleLoadUnloadStress.cpp | 4 +- .../runtimeApi/module/hipModuleNegative.cpp | 106 +-- .../module/hipModuleTexture2dDrv.cpp | 14 +- .../hipOccupancyMaxPotentialBlockSize.cpp | 2 +- .../stream/hipStreamACb_AltEnqueue.cpp | 2 +- .../stream/hipStreamACb_MStrm_Mgpu.cpp | 2 +- .../stream/hipStreamACb_MultiCalls.cpp | 2 +- .../stream/hipStreamACb_MultiThread.cpp | 2 +- .../stream/hipStreamACb_StrmSyncTiming.cpp | 2 +- .../stream/hipStreamACb_ThrdBehaviour.cpp | 2 +- .../runtimeApi/stream/hipStreamACb_order.cpp | 2 +- .../stream/hipStreamAddCallback.cpp | 2 +- .../stream/hipStreamAddCallbackCatch.cpp | 2 +- hipamd/tests/src/test_common.h | 2 +- .../texture/hipNormalizedFloatValueTex.cpp | 2 +- hipamd/tests/unit/test_common.h | 2 +- 159 files changed, 411 insertions(+), 4485 deletions(-) rename hipamd/include/hip/{hcc_detail => amd_detail}/channel_descriptor.h (98%) rename hipamd/include/hip/{hcc_detail => amd_detail}/concepts.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/cuda/cuda.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/cuda/math_functions.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/device_functions.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/device_library_decls.h (96%) rename hipamd/include/hip/{hcc_detail => amd_detail}/driver_types.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/functional_grid_launch.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/grid_launch.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/grid_launch.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/grid_launch_GGL.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/helpers.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_atomic.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_common.h (90%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_complex.h (98%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_cooperative_groups.h (97%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_cooperative_groups_helper.h (92%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_fp16.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_fp16_gcc.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_fp16_math_fwd.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_ldg.h (97%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_memory.h (96%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_runtime.h (96%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_runtime_api.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_runtime_prof.h (93%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_surface_types.h (85%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_texture_types.h (91%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hip_vector_types.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hiprtc.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/host_defines.h (95%) rename hipamd/include/hip/{hcc_detail => amd_detail}/hsa_helpers.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/library_types.h (93%) rename hipamd/include/hip/{hcc_detail => amd_detail}/llvm_intrinsics.h (88%) rename hipamd/include/hip/{hcc_detail => amd_detail}/macro_based_grid_launch.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/math_functions.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/math_fwd.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/ockl_image.h (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/program_state.hpp (100%) rename hipamd/include/hip/{hcc_detail => amd_detail}/surface_functions.h (93%) rename hipamd/include/hip/{hcc_detail => amd_detail}/texture_fetch_functions.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/texture_functions.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/texture_indirect_functions.h (99%) rename hipamd/include/hip/{hcc_detail => amd_detail}/texture_types.h (96%) create mode 120000 hipamd/include/hip/hcc_detail delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elf_types.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_dump.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_dynamic.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_header.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_note.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_relocation.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_section.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_segment.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_strings.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_symbols.hpp delete mode 100644 hipamd/include/hip/hcc_detail/elfio/elfio_utils.hpp delete mode 100644 hipamd/include/hip/nvcc_detail/hip_cooperative_groups.h delete mode 100644 hipamd/include/hip/nvcc_detail/hip_texture_types.h rename hipamd/include/hip/{nvcc_detail => nvidia_detail}/channel_descriptor.h (90%) rename hipamd/include/hip/{nvcc_detail => nvidia_detail}/hip_complex.h (97%) create mode 100644 hipamd/include/hip/nvidia_detail/hip_cooperative_groups.h rename hipamd/include/hip/{nvcc_detail => nvidia_detail}/hip_runtime.h (97%) rename hipamd/include/hip/{nvcc_detail => nvidia_detail}/hip_runtime_api.h (99%) create mode 100644 hipamd/include/hip/nvidia_detail/hip_texture_types.h delete mode 100755 hipamd/packaging/hip-hcc.postinst delete mode 100755 hipamd/packaging/hip-hcc.prerm delete mode 100644 hipamd/packaging/hip-hcc.txt diff --git a/hipamd/CMakeLists.txt b/hipamd/CMakeLists.txt index 2ae6fed884..eadc4480a9 100755 --- a/hipamd/CMakeLists.txt +++ b/hipamd/CMakeLists.txt @@ -278,7 +278,6 @@ if(HIP_RUNTIME STREQUAL "rocclr") set(HIP_ROCclr_BUILD_FLAGS "${HIP_ROCclr_BUILD_FLAGS} -fPIC ${ROCclr_CXX_FLAGS} -I${HSA_PATH}/include") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HIP_ROCclr_BUILD_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_ROCclr_BUILD_FLAGS}") - set(HCC_CXX_FLAGS "-hc -fno-gpu-rdc --amdgpu-target=gfx803 --amdgpu-target=gfx900 --amdgpu-target=gfx906 --amdgpu-target=gfx908 ") endif() if(HIP_PLATFORM STREQUAL "amd") @@ -320,18 +319,21 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0) install(DIRECTORY rocclr DESTINATION .) endif() install(DIRECTORY bin DESTINATION . USE_SOURCE_PERMISSIONS) + + # The following two lines will be removed after upstream updation + install(CODE "MESSAGE(\"Removing ${CMAKE_INSTALL_PREFIX}/include\")") + install(CODE "file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/include)") + install(DIRECTORY include DESTINATION .) install(DIRECTORY cmake DESTINATION .) endif() # Install generated headers # FIXME: Associate with individual targets. -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/hip/hcc_detail - DESTINATION include/hip - FILES_MATCHING PATTERN "*.h*") -install(DIRECTORY ${PROJECT_BINARY_DIR}/include/hip - DESTINATION include - FILES_MATCHING PATTERN "*.h*") +install(FILES ${PROJECT_BINARY_DIR}/include/hip/amd_detail/hip_prof_str.h + DESTINATION include/hip/amd_detail) +install(FILES ${PROJECT_BINARY_DIR}/include/hip/hip_version.h + DESTINATION include/hip) ############################# # hip-config diff --git a/hipamd/CONTRIBUTING.md b/hipamd/CONTRIBUTING.md index 750e6759c2..d0815a418d 100644 --- a/hipamd/CONTRIBUTING.md +++ b/hipamd/CONTRIBUTING.md @@ -20,9 +20,9 @@ After making HIP, don't forget the "make install" step ! - Add a translation to the hipify-clang tool ; many examples abound. - For stat tracking purposes, place the API into an appropriate stat category ("dev", "mem", "stream", etc). - - Add a inlined NVCC implementation for the function in include/hip/nvcc_detail/hip_runtime_api.h. + - Add a inlined NVIDIA implementation for the function in include/hip/nvidia_detail/hip_runtime_api.h. - These are typically headers - - Add an HIP_ROCclr definition and Doxygen comments for the function in include/hcc_detail/hip_runtime_api.h + - Add an HIP_ROCclr definition and Doxygen comments for the function in include/amd_detail/hip_runtime_api.h - Source implementation typically go in hip/rocclr/hip_*.cpp. The implementation involve calls to HIP runtime (ie for hipStream_t). ## Check HIP-Clang version diff --git a/hipamd/README.md b/hipamd/README.md index 9aea6a3867..0891780613 100644 --- a/hipamd/README.md +++ b/hipamd/README.md @@ -144,7 +144,7 @@ The README with the procedures and tips the team used during this porting effort * **include**: * **hip_runtime_api.h** : Defines HIP runtime APIs and can be compiled with many standard Linux compilers (hcc, GCC, ICC, CLANG, etc), in either C or C++ mode. * **hip_runtime.h** : Includes everything in hip_runtime_api.h PLUS hipLaunchKernel and syntax for writing device kernels and device functions. hip_runtime.h can only be compiled with hcc. - * **hcc_detail/**** , **nvcc_detail/**** : Implementation details for specific platforms. HIP applications should not include these files directly. + * **amd_detail/**** , **nvidia_detail/**** : Implementation details for specific platforms. HIP applications should not include these files directly. * **hcc.h** : Includes interop APIs for HIP and HCC * **bin**: Tools and scripts to help with hip porting diff --git a/hipamd/bin/hipconfig b/hipamd/bin/hipconfig index 976eb51c0f..3711f4b5c4 100755 --- a/hipamd/bin/hipconfig +++ b/hipamd/bin/hipconfig @@ -48,13 +48,13 @@ if ($HIP_COMPILER eq "clang") { $HIP_CLANG_VERSION=~/.*clang version (\S+).*/; $HIP_CLANG_VERSION=$1; - $CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -I$HIP_PATH/include -I$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION -I$HSA_PATH/include"; + $CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__= -I$HIP_PATH/include -I$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION -I$HSA_PATH/include"; } if ($HIP_RUNTIME eq "rocclr") { $CPP_CONFIG .= " -D__HIP_ROCclr__"; } if ($HIP_PLATFORM eq "nvidia") { - $CPP_CONFIG = " -D__HIP_PLATFORM_NVCC__= -I$HIP_PATH/include -I$CUDA_PATH/include"; + $CPP_CONFIG = " -D__HIP_PLATFORM_NVCC__= -D__HIP_PLATFORM_NVIDIA__= -I$HIP_PATH/include -I$CUDA_PATH/include"; }; if ($p_help) { diff --git a/hipamd/docs/doxygen-input/doxy.cfg b/hipamd/docs/doxygen-input/doxy.cfg index d09965f67d..0255ae36a0 100644 --- a/hipamd/docs/doxygen-input/doxy.cfg +++ b/hipamd/docs/doxygen-input/doxy.cfg @@ -836,7 +836,7 @@ INPUT = $(HIP_PATH)/docs/doxygen-input/mainpage.txt \ $(HIP_PATH)/INSTALL.md \ $(HIP_PATH)/docs/markdown \ $(HIP_PATH)/include/hip \ - $(HIP_PATH)/include/hip/hcc_detail/ \ + $(HIP_PATH)/include/hip/amd_detail/ \ $(HIP_PATH)/src/ # This tag can be used to specify the character encoding of the source files @@ -2170,7 +2170,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = __HCC__ __HIP_PLATFORM_HCC__ +PREDEFINED = __HCC__ __HIP_PLATFORM_HCC__ __HIP_PLATFORM_AMD__ # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/hipamd/docs/markdown/device_md_gen.py b/hipamd/docs/markdown/device_md_gen.py index 995782189f..7365479bc0 100644 --- a/hipamd/docs/markdown/device_md_gen.py +++ b/hipamd/docs/markdown/device_md_gen.py @@ -456,7 +456,7 @@ __ushort_as_half # The dictionary is to place description of each device function. Expand it to all the device functions deviceFuncDesc = {'acosf': "This function returns floating point of arc cosine from a floating point input"} -fnames = ["../../include/hip/hcc_detail/math_functions.h","../../include/hip/hcc_detail/device_functions.h","../../include/hip/hcc_detail/hip_fp16.h"] +fnames = ["../../include/hip/amd_detail/math_functions.h","../../include/hip/amd_detail/device_functions.h","../../include/hip/amd_detail/hip_fp16.h"] markdownFileName = "./hip-math-api.md" preamble = "# HIP MATH APIs Documentation \n"+\ diff --git a/hipamd/docs/markdown/hip_faq.md b/hipamd/docs/markdown/hip_faq.md index 65f4a58d07..1c772e3519 100644 --- a/hipamd/docs/markdown/hip_faq.md +++ b/hipamd/docs/markdown/hip_faq.md @@ -209,7 +209,7 @@ hipErrorToCudaError hipCUDAErrorTohipError hipCUResultTohipError -If platform portability is important, use #ifdef __HIP_PLATFORM_NVCC__ to guard the CUDA-specific code. +If platform portability is important, use #ifdef __HIP_PLATFORM_NVIDIA__ to guard the CUDA-specific code. ### How do I trace HIP application flow? See the [HIP Logging](hip_logging.md) for more information. diff --git a/hipamd/docs/markdown/hip_porting_driver_api.md b/hipamd/docs/markdown/hip_porting_driver_api.md index 1ace5fe228..3b47ee7a1e 100644 --- a/hipamd/docs/markdown/hip_porting_driver_api.md +++ b/hipamd/docs/markdown/hip_porting_driver_api.md @@ -178,11 +178,11 @@ The below sample shows how to use `hipModuleGetFunction`. #define LEN 64 #define SIZE LEN<<2 -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define fileName "vcpy_isa.co" #endif -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ #define fileName "vcpy_isa.ptx" #endif @@ -201,7 +201,7 @@ int main(){ } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipInit(0); hipDevice_t device; hipCtx_t context; @@ -238,7 +238,7 @@ int main(){ std::cout< hipconfig --cxx_config - -D__HIP_PLATFORM_HCC__ -I/home/user1/hip/include + -D__HIP_PLATFORM_AMD__ -I/home/user1/hip/include ``` You can capture the hipconfig output and passed it to the standard compiler; below is a sample makefile syntax: @@ -577,7 +577,7 @@ To see the detailed commands that hipcc issues, set the environment variable HIP export HIPCC_VERBOSE=1 make ... -hipcc-cmd: /opt/hcc/bin/hcc -hc -I/opt/hcc/include -stdlib=libc++ -I../../../../hc/include -I../../../../include/hcc_detail/cuda -I../../../../include -x c++ -I../../common -O3 -c backprop_cuda.cu +hipcc-cmd: /opt/hcc/bin/hcc -hc -I/opt/hcc/include -stdlib=libc++ -I../../../../hc/include -I../../../../include/amd_detail/cuda -I../../../../include -x c++ -I../../common -O3 -c backprop_cuda.cu ``` ### What Does This Error Mean? diff --git a/hipamd/hip-config.cmake.in b/hipamd/hip-config.cmake.in index e8dca242f8..494af4a8bc 100644 --- a/hipamd/hip-config.cmake.in +++ b/hipamd/hip-config.cmake.in @@ -121,7 +121,7 @@ endif() # Right now this is only supported for amd platforms set_target_properties(hip::host PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "__HIP_PLATFORM_HCC__=1" + INTERFACE_COMPILE_DEFINITIONS "__HIP_PLATFORM_HCC__=1;__HIP_PLATFORM_AMD__=1" ) if(HIP_RUNTIME MATCHES "rocclr") diff --git a/hipamd/hip_prof_gen.py b/hipamd/hip_prof_gen.py index 475d28186b..971c8ed48e 100755 --- a/hipamd/hip_prof_gen.py +++ b/hipamd/hip_prof_gen.py @@ -430,7 +430,7 @@ if (len(sys.argv) < 3): fatal ("Usage: " + sys.argv[0] + " [-v] \n" + " -v - verbose messages\n" + " example:\n" + - " $ hipap.py hip/include/hip/hcc_detail/hip_runtime_api.h hip/src") + " $ hipap.py hip/include/hip/amd_detail/hip_runtime_api.h hip/src") # API header file given as an argument api_hfile = sys.argv[1] diff --git a/hipamd/include/hip/hcc_detail/channel_descriptor.h b/hipamd/include/hip/amd_detail/channel_descriptor.h similarity index 98% rename from hipamd/include/hip/hcc_detail/channel_descriptor.h rename to hipamd/include/hip/amd_detail/channel_descriptor.h index 417451fb85..f07e9a1246 100644 --- a/hipamd/include/hip/hcc_detail/channel_descriptor.h +++ b/hipamd/include/hip/amd_detail/channel_descriptor.h @@ -20,12 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_CHANNEL_DESCRIPTOR_H #include -#include -#include +#include +#include #ifdef __cplusplus diff --git a/hipamd/include/hip/hcc_detail/concepts.hpp b/hipamd/include/hip/amd_detail/concepts.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/concepts.hpp rename to hipamd/include/hip/amd_detail/concepts.hpp diff --git a/hipamd/include/hip/hcc_detail/cuda/cuda.h b/hipamd/include/hip/amd_detail/cuda/cuda.h similarity index 100% rename from hipamd/include/hip/hcc_detail/cuda/cuda.h rename to hipamd/include/hip/amd_detail/cuda/cuda.h diff --git a/hipamd/include/hip/hcc_detail/cuda/math_functions.h b/hipamd/include/hip/amd_detail/cuda/math_functions.h similarity index 100% rename from hipamd/include/hip/hcc_detail/cuda/math_functions.h rename to hipamd/include/hip/amd_detail/cuda/math_functions.h diff --git a/hipamd/include/hip/hcc_detail/device_functions.h b/hipamd/include/hip/amd_detail/device_functions.h similarity index 99% rename from hipamd/include/hip/hcc_detail/device_functions.h rename to hipamd/include/hip/amd_detail/device_functions.h index 515b4cc6a4..7c285fa570 100644 --- a/hipamd/include/hip/hcc_detail/device_functions.h +++ b/hipamd/include/hip/amd_detail/device_functions.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_FUNCTIONS_H #include "host_defines.h" #include "math_fwd.h" @@ -31,8 +31,8 @@ THE SOFTWARE. #include -#include -#include +#include +#include #if __HIP_CLANG_ONLY__ && __HIP_ROCclr__ && !_WIN32 extern "C" __device__ int printf(const char *fmt, ...); diff --git a/hipamd/include/hip/hcc_detail/device_library_decls.h b/hipamd/include/hip/amd_detail/device_library_decls.h similarity index 96% rename from hipamd/include/hip/hcc_detail/device_library_decls.h rename to hipamd/include/hip/amd_detail/device_library_decls.h index 90aef16da9..99cd505ca5 100644 --- a/hipamd/include/hip/hcc_detail/device_library_decls.h +++ b/hipamd/include/hip/amd_detail/device_library_decls.h @@ -21,14 +21,14 @@ THE SOFTWARE. */ /** - * @file hcc_detail/device_library_decls.h + * @file amd_detail/device_library_decls.h * @brief Contains declarations for types and functions in device library. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_LIBRARY_DECLS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_LIBRARY_DECLS_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H -#include "hip/hcc_detail/host_defines.h" +#include "hip/amd_detail/host_defines.h" typedef unsigned char uchar; typedef unsigned short ushort; diff --git a/hipamd/include/hip/hcc_detail/driver_types.h b/hipamd/include/hip/amd_detail/driver_types.h similarity index 99% rename from hipamd/include/hip/hcc_detail/driver_types.h rename to hipamd/include/hip/amd_detail/driver_types.h index 7db78e5ded..0f22ca333e 100644 --- a/hipamd/include/hip/hcc_detail/driver_types.h +++ b/hipamd/include/hip/amd_detail/driver_types.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DRIVER_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_DRIVER_TYPES_H #ifndef __cplusplus #include diff --git a/hipamd/include/hip/hcc_detail/functional_grid_launch.hpp b/hipamd/include/hip/amd_detail/functional_grid_launch.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/functional_grid_launch.hpp rename to hipamd/include/hip/amd_detail/functional_grid_launch.hpp diff --git a/hipamd/include/hip/hcc_detail/grid_launch.h b/hipamd/include/hip/amd_detail/grid_launch.h similarity index 100% rename from hipamd/include/hip/hcc_detail/grid_launch.h rename to hipamd/include/hip/amd_detail/grid_launch.h diff --git a/hipamd/include/hip/hcc_detail/grid_launch.hpp b/hipamd/include/hip/amd_detail/grid_launch.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/grid_launch.hpp rename to hipamd/include/hip/amd_detail/grid_launch.hpp diff --git a/hipamd/include/hip/hcc_detail/grid_launch_GGL.hpp b/hipamd/include/hip/amd_detail/grid_launch_GGL.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/grid_launch_GGL.hpp rename to hipamd/include/hip/amd_detail/grid_launch_GGL.hpp diff --git a/hipamd/include/hip/hcc_detail/helpers.hpp b/hipamd/include/hip/amd_detail/helpers.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/helpers.hpp rename to hipamd/include/hip/amd_detail/helpers.hpp diff --git a/hipamd/include/hip/hcc_detail/hip_atomic.h b/hipamd/include/hip/amd_detail/hip_atomic.h similarity index 100% rename from hipamd/include/hip/hcc_detail/hip_atomic.h rename to hipamd/include/hip/amd_detail/hip_atomic.h diff --git a/hipamd/include/hip/hcc_detail/hip_common.h b/hipamd/include/hip/amd_detail/hip_common.h similarity index 90% rename from hipamd/include/hip/hcc_detail/hip_common.h rename to hipamd/include/hip/amd_detail/hip_common.h index 2e2abace0c..02a22f0985 100644 --- a/hipamd/include/hip/hcc_detail/hip_common.h +++ b/hipamd/include/hip/amd_detail/hip_common.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMMON_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMMON_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMMON_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMMON_H #if defined(__HCC__) #define __HCC_OR_HIP_CLANG__ 1 @@ -37,4 +37,4 @@ SOFTWARE. #define __HIP_CLANG_ONLY__ 0 #endif -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMMON_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMMON_H diff --git a/hipamd/include/hip/hcc_detail/hip_complex.h b/hipamd/include/hip/amd_detail/hip_complex.h similarity index 98% rename from hipamd/include/hip/hcc_detail/hip_complex.h rename to hipamd/include/hip/amd_detail/hip_complex.h index 11648ce123..9acd0d3d0d 100644 --- a/hipamd/include/hip/hcc_detail/hip_complex.h +++ b/hipamd/include/hip/amd_detail/hip_complex.h @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H -#include "hip/hcc_detail/hip_vector_types.h" +#include "hip/amd_detail/hip_vector_types.h" // TODO: Clang has a bug which allows device functions to call std functions // when std functions are introduced into default namespace by using statement. @@ -301,4 +301,4 @@ __device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, h return make_hipDoubleComplex(real, imag); } -#endif //HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#endif //HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H diff --git a/hipamd/include/hip/hcc_detail/hip_cooperative_groups.h b/hipamd/include/hip/amd_detail/hip_cooperative_groups.h similarity index 97% rename from hipamd/include/hip/hcc_detail/hip_cooperative_groups.h rename to hipamd/include/hip/amd_detail/hip_cooperative_groups.h index 353bdc5514..a5ae5f75b3 100644 --- a/hipamd/include/hip/hcc_detail/hip_cooperative_groups.h +++ b/hipamd/include/hip/amd_detail/hip_cooperative_groups.h @@ -21,7 +21,7 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_cooperative_groups.h + * @file amd_detail/hip_cooperative_groups.h * * @brief Device side implementation of `Cooperative Group` feature. * @@ -29,11 +29,11 @@ THE SOFTWARE. * feature, which the programmer can directly use in his kernel(s) in order to * make use of this feature. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H #if __cplusplus -#include +#include namespace cooperative_groups { @@ -301,4 +301,4 @@ __CG_QUALIFIER__ void sync(CGTy const &g) { } // namespace cooperative_groups #endif // __cplusplus -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H diff --git a/hipamd/include/hip/hcc_detail/hip_cooperative_groups_helper.h b/hipamd/include/hip/amd_detail/hip_cooperative_groups_helper.h similarity index 92% rename from hipamd/include/hip/hcc_detail/hip_cooperative_groups_helper.h rename to hipamd/include/hip/amd_detail/hip_cooperative_groups_helper.h index 4e10c0da72..6e71e4f1c3 100644 --- a/hipamd/include/hip/hcc_detail/hip_cooperative_groups_helper.h +++ b/hipamd/include/hip/amd_detail/hip_cooperative_groups_helper.h @@ -21,19 +21,19 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_cooperative_groups_helper.h + * @file amd_detail/hip_cooperative_groups_helper.h * * @brief Device side implementation of cooperative group feature. * * Defines helper constructs and APIs which aid the types and device API - * wrappers defined within `hcc_detail/hip_cooperative_groups.h`. + * wrappers defined within `amd_detail/hip_cooperative_groups.h`. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H #if __cplusplus -#include -#include +#include +#include #if !defined(__align__) #define __align__(x) __attribute__((aligned(x))) @@ -179,4 +179,4 @@ __CG_STATIC_QUALIFIER__ void sync() { } // namespace cooperative_groups #endif // __cplusplus -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H diff --git a/hipamd/include/hip/hcc_detail/hip_fp16.h b/hipamd/include/hip/amd_detail/hip_fp16.h similarity index 99% rename from hipamd/include/hip/hcc_detail/hip_fp16.h rename to hipamd/include/hip/amd_detail/hip_fp16.h index 670cd475c2..9220a272fa 100644 --- a/hipamd/include/hip/hcc_detail/hip_fp16.h +++ b/hipamd/include/hip/amd_detail/hip_fp16.h @@ -21,12 +21,12 @@ THE SOFTWARE. */ #pragma once -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H -#include +#include -#include "hip/hcc_detail/host_defines.h" +#include "hip/amd_detail/host_defines.h" #include #if defined(__cplusplus) #include @@ -1657,4 +1657,4 @@ THE SOFTWARE. #include "hip_fp16_gcc.h" #endif // !defined(__clang__) && defined(__GNUC__) -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H diff --git a/hipamd/include/hip/hcc_detail/hip_fp16_gcc.h b/hipamd/include/hip/amd_detail/hip_fp16_gcc.h similarity index 100% rename from hipamd/include/hip/hcc_detail/hip_fp16_gcc.h rename to hipamd/include/hip/amd_detail/hip_fp16_gcc.h diff --git a/hipamd/include/hip/hcc_detail/hip_fp16_math_fwd.h b/hipamd/include/hip/amd_detail/hip_fp16_math_fwd.h similarity index 100% rename from hipamd/include/hip/hcc_detail/hip_fp16_math_fwd.h rename to hipamd/include/hip/amd_detail/hip_fp16_math_fwd.h diff --git a/hipamd/include/hip/hcc_detail/hip_ldg.h b/hipamd/include/hip/amd_detail/hip_ldg.h similarity index 97% rename from hipamd/include/hip/hcc_detail/hip_ldg.h rename to hipamd/include/hip/amd_detail/hip_ldg.h index ab86955cd6..29a72d5bbd 100644 --- a/hipamd/include/hip/hcc_detail/hip_ldg.h +++ b/hipamd/include/hip/amd_detail/hip_ldg.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_LDG_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_LDG_H #if defined(__HCC_OR_HIP_CLANG__) #if __hcc_workweek__ >= 16164 || __HIP_CLANG_ONLY__ diff --git a/hipamd/include/hip/hcc_detail/hip_memory.h b/hipamd/include/hip/amd_detail/hip_memory.h similarity index 96% rename from hipamd/include/hip/hcc_detail/hip_memory.h rename to hipamd/include/hip/amd_detail/hip_memory.h index 0c006143de..7e2604ce3d 100644 --- a/hipamd/include/hip/hcc_detail/hip_memory.h +++ b/hipamd/include/hip/amd_detail/hip_memory.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_MEMORY_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_MEMORY_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_MEMORY_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_MEMORY_H // Implementation of malloc and free device functions. // HIP heap is implemented as a global array with fixed size. Users may define @@ -111,4 +111,4 @@ extern "C" inline __device__ void* __hip_free(void* ptr) { #endif -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_MEMORY_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_MEMORY_H diff --git a/hipamd/include/hip/hcc_detail/hip_runtime.h b/hipamd/include/hip/amd_detail/hip_runtime.h similarity index 96% rename from hipamd/include/hip/hcc_detail/hip_runtime.h rename to hipamd/include/hip/amd_detail/hip_runtime.h index 5411bb34b6..2ae3f5b16a 100644 --- a/hipamd/include/hip/hcc_detail/hip_runtime.h +++ b/hipamd/include/hip/amd_detail/hip_runtime.h @@ -21,15 +21,15 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_runtime.h + * @file amd_detail/hip_runtime.h * @brief Contains definitions of APIs for HIP runtime. */ //#pragma once -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_H -#include +#include //--- // Top part of file can be compiled with any compiler @@ -102,18 +102,18 @@ struct Empty_launch_parm {}; extern int HIP_TRACE_API; #ifdef __cplusplus -#include +#include #endif -#include -#include -#include -#include +#include +#include +#include +#include #if __HCC__ - #include - #include + #include + #include #else - #include - #include + #include + #include #endif // TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define. #if defined(__KALMAR_ACCELERATOR__) && !defined(__HCC_ACCELERATOR__) @@ -556,7 +556,7 @@ extern "C" __device__ __attribute__((const)) size_t __ockl_get_num_groups(uint); #define hipGridDim_y (__ockl_get_num_groups(1)) #define hipGridDim_z (__ockl_get_num_groups(2)) -#include +#include #if __HIP_HCC_COMPAT_MODE__ // Define HCC work item functions in terms of HIP builtin variables. @@ -607,6 +607,6 @@ hc_get_workitem_absolute_id(int dim) #endif // !__CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ #endif // defined(__clang__) && defined(__HIP__) -#include +#include -#endif // HIP_HCC_DETAIL_RUNTIME_H +#endif // HIP_AMD_DETAIL_RUNTIME_H diff --git a/hipamd/include/hip/hcc_detail/hip_runtime_api.h b/hipamd/include/hip/amd_detail/hip_runtime_api.h similarity index 99% rename from hipamd/include/hip/hcc_detail/hip_runtime_api.h rename to hipamd/include/hip/amd_detail/hip_runtime_api.h index 1980004953..35ffc07ba9 100644 --- a/hipamd/include/hip/hcc_detail/hip_runtime_api.h +++ b/hipamd/include/hip/amd_detail/hip_runtime_api.h @@ -21,10 +21,10 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_API_H /** - * @file hcc_detail/hip_runtime_api.h + * @file amd_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or * special language extensions (-hc mode) ; those functions in hip_runtime.h. */ @@ -39,14 +39,14 @@ THE SOFTWARE. #define __HIP_ROCclr__ 0 #endif -#include -#include -#include -#include +#include +#include +#include +#include #if !__HIP_ROCclr__ && defined(__cplusplus) #include -#include +#include #endif #if defined(_MSC_VER) @@ -3943,7 +3943,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const T& symbol, size_t sizeBytes #endif #if USE_PROF_API -#include +#include #endif #ifdef __cplusplus diff --git a/hipamd/include/hip/hcc_detail/hip_runtime_prof.h b/hipamd/include/hip/amd_detail/hip_runtime_prof.h similarity index 93% rename from hipamd/include/hip/hcc_detail/hip_runtime_prof.h rename to hipamd/include/hip/amd_detail/hip_runtime_prof.h index ffd8b0ab8e..a45962d459 100644 --- a/hipamd/include/hip/hcc_detail/hip_runtime_prof.h +++ b/hipamd/include/hip/amd_detail/hip_runtime_prof.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_PROF_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_PROF_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_PROF_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_PROF_H // HIP ROCclr Op IDs enumeration enum HipVdiOpId { @@ -73,5 +73,5 @@ bool hipEnableActivityCallback(uint32_t op, bool enable); */ const char* hipGetCmdName(uint32_t id); -#endif // HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_PROF_H +#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_RUNTIME_PROF_H diff --git a/hipamd/include/hip/hcc_detail/hip_surface_types.h b/hipamd/include/hip/amd_detail/hip_surface_types.h similarity index 85% rename from hipamd/include/hip/hcc_detail/hip_surface_types.h rename to hipamd/include/hip/amd_detail/hip_surface_types.h index f74c01d700..2c53d19558 100644 --- a/hipamd/include/hip/hcc_detail/hip_surface_types.h +++ b/hipamd/include/hip/amd_detail/hip_surface_types.h @@ -21,14 +21,14 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_surface_types.h + * @file amd_detail/hip_surface_types.h * @brief Defines surface types for HIP runtime. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_SURFACE_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_SURFACE_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_SURFACE_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_SURFACE_TYPES_H -#include +#include /** * An opaque value that represents a hip surface object @@ -51,4 +51,4 @@ enum hipSurfaceBoundaryMode { hipBoundaryModeClamp = 2 }; -#endif /* !HIP_INCLUDE_HIP_HCC_DETAIL_HIP_SURFACE_TYPES_H */ +#endif /* !HIP_INCLUDE_HIP_AMD_DETAIL_HIP_SURFACE_TYPES_H */ diff --git a/hipamd/include/hip/hcc_detail/hip_texture_types.h b/hipamd/include/hip/amd_detail/hip_texture_types.h similarity index 91% rename from hipamd/include/hip/hcc_detail/hip_texture_types.h rename to hipamd/include/hip/amd_detail/hip_texture_types.h index a46b2363d2..22016e25ad 100644 --- a/hipamd/include/hip/hcc_detail/hip_texture_types.h +++ b/hipamd/include/hip/amd_detail/hip_texture_types.h @@ -21,12 +21,12 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_texture_types.h + * @file amd_detail/hip_texture_types.h * @brief Defines the different newt vector types for HIP runtime. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_TEXTURE_TYPES_H /******************************************************************************* * * @@ -34,9 +34,9 @@ THE SOFTWARE. * * *******************************************************************************/ #include -//#include -#include -#include +//#include +#include +#include #if __cplusplus @@ -93,4 +93,4 @@ struct __HIP_TEXTURE_ATTRIB texture : public textureReference { #endif /* __cplusplus */ -#endif /* !HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H */ +#endif /* !HIP_INCLUDE_HIP_AMD_DETAIL_HIP_TEXTURE_TYPES_H */ diff --git a/hipamd/include/hip/hcc_detail/hip_vector_types.h b/hipamd/include/hip/amd_detail/hip_vector_types.h similarity index 99% rename from hipamd/include/hip/hcc_detail/hip_vector_types.h rename to hipamd/include/hip/amd_detail/hip_vector_types.h index 69525c5684..1848362782 100644 --- a/hipamd/include/hip/hcc_detail/hip_vector_types.h +++ b/hipamd/include/hip/amd_detail/hip_vector_types.h @@ -21,18 +21,18 @@ THE SOFTWARE. */ /** - * @file hcc_detail/hip_vector_types.h + * @file amd_detail/hip_vector_types.h * @brief Defines the different newt vector types for HIP runtime. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_VECTOR_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_VECTOR_TYPES_H #if defined(__HCC__) && (__hcc_workweek__ < 16032) #error("This version of HIP requires a newer version of HCC."); #endif -#include "hip/hcc_detail/host_defines.h" +#include "hip/amd_detail/host_defines.h" #if defined(__has_attribute) #if __has_attribute(ext_vector_type) diff --git a/hipamd/include/hip/hcc_detail/hiprtc.h b/hipamd/include/hip/amd_detail/hiprtc.h similarity index 100% rename from hipamd/include/hip/hcc_detail/hiprtc.h rename to hipamd/include/hip/amd_detail/hiprtc.h diff --git a/hipamd/include/hip/hcc_detail/host_defines.h b/hipamd/include/hip/amd_detail/host_defines.h similarity index 95% rename from hipamd/include/hip/hcc_detail/host_defines.h rename to hipamd/include/hip/amd_detail/host_defines.h index 72f3932aff..66ea7523fe 100644 --- a/hipamd/include/hip/hcc_detail/host_defines.h +++ b/hipamd/include/hip/amd_detail/host_defines.h @@ -21,12 +21,12 @@ THE SOFTWARE. */ /** - * @file hcc_detail/host_defines.h + * @file amd_detail/host_defines.h * @brief TODO-doc */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HOST_DEFINES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_HOST_DEFINES_H // Add guard to Generic Grid Launch method diff --git a/hipamd/include/hip/hcc_detail/hsa_helpers.hpp b/hipamd/include/hip/amd_detail/hsa_helpers.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/hsa_helpers.hpp rename to hipamd/include/hip/amd_detail/hsa_helpers.hpp diff --git a/hipamd/include/hip/hcc_detail/library_types.h b/hipamd/include/hip/amd_detail/library_types.h similarity index 93% rename from hipamd/include/hip/hcc_detail/library_types.h rename to hipamd/include/hip/amd_detail/library_types.h index 6fcd0dc3d1..6c3e111220 100644 --- a/hipamd/include/hip/hcc_detail/library_types.h +++ b/hipamd/include/hip/amd_detail/library_types.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_LIBRARY_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_LIBRARY_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_LIBRARY_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_LIBRARY_TYPES_H typedef enum hipDataType { HIP_R_16F = 2, diff --git a/hipamd/include/hip/hcc_detail/llvm_intrinsics.h b/hipamd/include/hip/amd_detail/llvm_intrinsics.h similarity index 88% rename from hipamd/include/hip/hcc_detail/llvm_intrinsics.h rename to hipamd/include/hip/amd_detail/llvm_intrinsics.h index 330b3d91c2..c100b846c0 100644 --- a/hipamd/include/hip/hcc_detail/llvm_intrinsics.h +++ b/hipamd/include/hip/amd_detail/llvm_intrinsics.h @@ -21,15 +21,15 @@ THE SOFTWARE. */ /** - * @file hcc_detail/llvm_intrinsics.h + * @file amd_detail/llvm_intrinsics.h * @brief Contains declarations for wrapper functions for llvm intrinsics * like llvm.amdgcn.s.barrier. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_LLVM_INTRINSICS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_LLVM_INTRINSICS_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_LLVM_INTRINSICS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_LLVM_INTRINSICS_H -#include "hip/hcc_detail/host_defines.h" +#include "hip/amd_detail/host_defines.h" // FIXME: These should all be removed and proper builtins used. __device__ diff --git a/hipamd/include/hip/hcc_detail/macro_based_grid_launch.hpp b/hipamd/include/hip/amd_detail/macro_based_grid_launch.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/macro_based_grid_launch.hpp rename to hipamd/include/hip/amd_detail/macro_based_grid_launch.hpp diff --git a/hipamd/include/hip/hcc_detail/math_functions.h b/hipamd/include/hip/amd_detail/math_functions.h similarity index 99% rename from hipamd/include/hip/hcc_detail/math_functions.h rename to hipamd/include/hip/amd_detail/math_functions.h index 3dbc9a2002..96c6413026 100644 --- a/hipamd/include/hip/hcc_detail/math_functions.h +++ b/hipamd/include/hip/amd_detail/math_functions.h @@ -26,12 +26,12 @@ THE SOFTWARE. #include "hip_vector_types.h" #include "math_fwd.h" -#include +#include #include // assert.h is only for the host version of assert. -// The device version of assert is implemented in hip/hcc_detail/hip_runtime.h. +// The device version of assert is implemented in hip/amd_detail/hip_runtime.h. // Users should include hip_runtime.h for the device version of assert. #if !__HIP_DEVICE_COMPILE__ #include @@ -1554,4 +1554,4 @@ inline _Float16 pow(_Float16 base, int iexp) { // For backward compatibility. // There are HIP applications e.g. TensorFlow, expecting __HIP_ARCH_* macros // defined after including math_functions.h. -#include +#include diff --git a/hipamd/include/hip/hcc_detail/math_fwd.h b/hipamd/include/hip/amd_detail/math_fwd.h similarity index 100% rename from hipamd/include/hip/hcc_detail/math_fwd.h rename to hipamd/include/hip/amd_detail/math_fwd.h diff --git a/hipamd/include/hip/hcc_detail/ockl_image.h b/hipamd/include/hip/amd_detail/ockl_image.h similarity index 100% rename from hipamd/include/hip/hcc_detail/ockl_image.h rename to hipamd/include/hip/amd_detail/ockl_image.h diff --git a/hipamd/include/hip/hcc_detail/program_state.hpp b/hipamd/include/hip/amd_detail/program_state.hpp similarity index 100% rename from hipamd/include/hip/hcc_detail/program_state.hpp rename to hipamd/include/hip/amd_detail/program_state.hpp diff --git a/hipamd/include/hip/hcc_detail/surface_functions.h b/hipamd/include/hip/amd_detail/surface_functions.h similarity index 93% rename from hipamd/include/hip/hcc_detail/surface_functions.h rename to hipamd/include/hip/amd_detail/surface_functions.h index b9cab1f466..51c32bf85d 100644 --- a/hipamd/include/hip/hcc_detail/surface_functions.h +++ b/hipamd/include/hip/amd_detail/surface_functions.h @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_SURFACE_FUNCTIONS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_SURFACE_FUNCTIONS_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H -#include +#include #define __SURFACE_FUNCTIONS_DECL__ static inline __device__ template diff --git a/hipamd/include/hip/hcc_detail/texture_fetch_functions.h b/hipamd/include/hip/amd_detail/texture_fetch_functions.h similarity index 99% rename from hipamd/include/hip/hcc_detail/texture_fetch_functions.h rename to hipamd/include/hip/amd_detail/texture_fetch_functions.h index 03c1780030..004b021b80 100644 --- a/hipamd/include/hip/hcc_detail/texture_fetch_functions.h +++ b/hipamd/include/hip/amd_detail/texture_fetch_functions.h @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include -#include +#include #include diff --git a/hipamd/include/hip/hcc_detail/texture_functions.h b/hipamd/include/hip/amd_detail/texture_functions.h similarity index 99% rename from hipamd/include/hip/hcc_detail/texture_functions.h rename to hipamd/include/hip/amd_detail/texture_functions.h index 4a845079fb..07db9129da 100644 --- a/hipamd/include/hip/hcc_detail/texture_functions.h +++ b/hipamd/include/hip/amd_detail/texture_functions.h @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_FUNCTIONS_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_FUNCTIONS_H -#include -#include +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_TEXTURE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_TEXTURE_FUNCTIONS_H +#include +#include #pragma push_macro("TYPEDEF_VECTOR_VALUE_TYPE") #define TYPEDEF_VECTOR_VALUE_TYPE(SCALAR_TYPE) \ diff --git a/hipamd/include/hip/hcc_detail/texture_indirect_functions.h b/hipamd/include/hip/amd_detail/texture_indirect_functions.h similarity index 99% rename from hipamd/include/hip/hcc_detail/texture_indirect_functions.h rename to hipamd/include/hip/amd_detail/texture_indirect_functions.h index 2fe33f3ede..d55c9a50a4 100644 --- a/hipamd/include/hip/hcc_detail/texture_indirect_functions.h +++ b/hipamd/include/hip/amd_detail/texture_indirect_functions.h @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include -#include +#include #include diff --git a/hipamd/include/hip/hcc_detail/texture_types.h b/hipamd/include/hip/amd_detail/texture_types.h similarity index 96% rename from hipamd/include/hip/hcc_detail/texture_types.h rename to hipamd/include/hip/amd_detail/texture_types.h index 832b9095bd..3cfb7dac9f 100644 --- a/hipamd/include/hip/hcc_detail/texture_types.h +++ b/hipamd/include/hip/amd_detail/texture_types.h @@ -21,10 +21,10 @@ THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H -#define HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H +#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_AMD_DETAIL_TEXTURE_TYPES_H -#include +#include #define hipTextureType1D 0x01 #define hipTextureType2D 0x02 diff --git a/hipamd/include/hip/channel_descriptor.h b/hipamd/include/hip/channel_descriptor.h index 842701bad7..47d842fd3e 100644 --- a/hipamd/include/hip/channel_descriptor.h +++ b/hipamd/include/hip/channel_descriptor.h @@ -28,12 +28,12 @@ THE SOFTWARE. // on NVCC path: -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#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__)) +#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/device_functions.h b/hipamd/include/hip/device_functions.h index f6059f2026..585d986c7d 100644 --- a/hipamd/include/hip/device_functions.h +++ b/hipamd/include/hip/device_functions.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#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__)) #include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/driver_types.h b/hipamd/include/hip/driver_types.h index d428ec7f2d..1a8aa0daa8 100644 --- a/hipamd/include/hip/driver_types.h +++ b/hipamd/include/hip/driver_types.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#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__)) #include "driver_types.h" #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/hcc_detail b/hipamd/include/hip/hcc_detail new file mode 120000 index 0000000000..4931d48978 --- /dev/null +++ b/hipamd/include/hip/hcc_detail @@ -0,0 +1 @@ +amd_detail \ No newline at end of file diff --git a/hipamd/include/hip/hcc_detail/elfio/elf_types.hpp b/hipamd/include/hip/hcc_detail/elfio/elf_types.hpp deleted file mode 100644 index a17b70046d..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elf_types.hpp +++ /dev/null @@ -1,748 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFTYPES_H -#define ELFTYPES_H - -#ifndef ELFIO_NO_OWN_TYPES -#if !defined(ELFIO_NO_CSTDINT) && !defined(ELFIO_NO_INTTYPES) -#include -#else -typedef unsigned char uint8_t; -typedef signed char int8_t; -typedef unsigned short uint16_t; -typedef signed short int16_t; -#ifdef _MSC_VER -typedef unsigned __int32 uint32_t; -typedef signed __int32 int32_t; -typedef unsigned __int64 uint64_t; -typedef signed __int64 int64_t; -#else -typedef unsigned int uint32_t; -typedef signed int int32_t; -typedef unsigned long long uint64_t; -typedef signed long long int64_t; -#endif // _MSC_VER -#endif // ELFIO_NO_CSTDINT -#endif // ELFIO_NO_OWN_TYPES - -namespace ELFIO { - -// Attention! Platform depended definitions. -typedef uint16_t Elf_Half; -typedef uint32_t Elf_Word; -typedef int32_t Elf_Sword; -typedef uint64_t Elf_Xword; -typedef int64_t Elf_Sxword; - -typedef uint32_t Elf32_Addr; -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; - -#define Elf32_Half Elf_Half -#define Elf64_Half Elf_Half -#define Elf32_Word Elf_Word -#define Elf64_Word Elf_Word -#define Elf32_Sword Elf_Sword -#define Elf64_Sword Elf_Sword - -/////////////////////// -// ELF Header Constants - -// File type -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_LOOS 0xFE00 -#define ET_HIOS 0xFEFF -#define ET_LOPROC 0xFF00 -#define ET_HIPROC 0xFFFF - - -#define EM_NONE 0 // No machine -#define EM_M32 1 // AT&T WE 32100 -#define EM_SPARC 2 // SUN SPARC -#define EM_386 3 // Intel 80386 -#define EM_68K 4 // Motorola m68k family -#define EM_88K 5 // Motorola m88k family -#define EM_486 6 // Intel 80486// Reserved for future use -#define EM_860 7 // Intel 80860 -#define EM_MIPS 8 // MIPS R3000 (officially, big-endian only) -#define EM_S370 9 // IBM System/370 -#define EM_MIPS_RS3_LE 10 // MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated -#define EM_res011 11 // Reserved -#define EM_res012 12 // Reserved -#define EM_res013 13 // Reserved -#define EM_res014 14 // Reserved -#define EM_PARISC 15 // HPPA -#define EM_res016 16 // Reserved -#define EM_VPP550 17 // Fujitsu VPP500 -#define EM_SPARC32PLUS 18 // Sun's "v8plus" -#define EM_960 19 // Intel 80960 -#define EM_PPC 20 // PowerPC -#define EM_PPC64 21 // 64-bit PowerPC -#define EM_S390 22 // IBM S/390 -#define EM_SPU 23 // Sony/Toshiba/IBM SPU -#define EM_res024 24 // Reserved -#define EM_res025 25 // Reserved -#define EM_res026 26 // Reserved -#define EM_res027 27 // Reserved -#define EM_res028 28 // Reserved -#define EM_res029 29 // Reserved -#define EM_res030 30 // Reserved -#define EM_res031 31 // Reserved -#define EM_res032 32 // Reserved -#define EM_res033 33 // Reserved -#define EM_res034 34 // Reserved -#define EM_res035 35 // Reserved -#define EM_V800 36 // NEC V800 series -#define EM_FR20 37 // Fujitsu FR20 -#define EM_RH32 38 // TRW RH32 -#define EM_MCORE 39 // Motorola M*Core // May also be taken by Fujitsu MMA -#define EM_RCE 39 // Old name for MCore -#define EM_ARM 40 // ARM -#define EM_OLD_ALPHA 41 // Digital Alpha -#define EM_SH 42 // Renesas (formerly Hitachi) / SuperH SH -#define EM_SPARCV9 43 // SPARC v9 64-bit -#define EM_TRICORE 44 // Siemens Tricore embedded processor -#define EM_ARC 45 // ARC Cores -#define EM_H8_300 46 // Renesas (formerly Hitachi) H8/300 -#define EM_H8_300H 47 // Renesas (formerly Hitachi) H8/300H -#define EM_H8S 48 // Renesas (formerly Hitachi) H8S -#define EM_H8_500 49 // Renesas (formerly Hitachi) H8/500 -#define EM_IA_64 50 // Intel IA-64 Processor -#define EM_MIPS_X 51 // Stanford MIPS-X -#define EM_COLDFIRE 52 // Motorola Coldfire -#define EM_68HC12 53 // Motorola M68HC12 -#define EM_MMA 54 // Fujitsu Multimedia Accelerator -#define EM_PCP 55 // Siemens PCP -#define EM_NCPU 56 // Sony nCPU embedded RISC processor -#define EM_NDR1 57 // Denso NDR1 microprocesspr -#define EM_STARCORE 58 // Motorola Star*Core processor -#define EM_ME16 59 // Toyota ME16 processor -#define EM_ST100 60 // STMicroelectronics ST100 processor -#define EM_TINYJ 61 // Advanced Logic Corp. TinyJ embedded processor -#define EM_X86_64 62 // Advanced Micro Devices X86-64 processor -#define EM_PDSP 63 // Sony DSP Processor -#define EM_PDP10 64 // Digital Equipment Corp. PDP-10 -#define EM_PDP11 65 // Digital Equipment Corp. PDP-11 -#define EM_FX66 66 // Siemens FX66 microcontroller -#define EM_ST9PLUS 67 // STMicroelectronics ST9+ 8/16 bit microcontroller -#define EM_ST7 68 // STMicroelectronics ST7 8-bit microcontroller -#define EM_68HC16 69 // Motorola MC68HC16 Microcontroller -#define EM_68HC11 70 // Motorola MC68HC11 Microcontroller -#define EM_68HC08 71 // Motorola MC68HC08 Microcontroller -#define EM_68HC05 72 // Motorola MC68HC05 Microcontroller -#define EM_SVX 73 // Silicon Graphics SVx -#define EM_ST19 74 // STMicroelectronics ST19 8-bit cpu -#define EM_VAX 75 // Digital VAX -#define EM_CRIS 76 // Axis Communications 32-bit embedded processor -#define EM_JAVELIN 77 // Infineon Technologies 32-bit embedded cpu -#define EM_FIREPATH 78 // Element 14 64-bit DSP processor -#define EM_ZSP 79 // LSI Logic's 16-bit DSP processor -#define EM_MMIX 80 // Donald Knuth's educational 64-bit processor -#define EM_HUANY 81 // Harvard's machine-independent format -#define EM_PRISM 82 // SiTera Prism -#define EM_AVR 83 // Atmel AVR 8-bit microcontroller -#define EM_FR30 84 // Fujitsu FR30 -#define EM_D10V 85 // Mitsubishi D10V -#define EM_D30V 86 // Mitsubishi D30V -#define EM_V850 87 // NEC v850 -#define EM_M32R 88 // Renesas M32R (formerly Mitsubishi M32R) -#define EM_MN10300 89 // Matsushita MN10300 -#define EM_MN10200 90 // Matsushita MN10200 -#define EM_PJ 91 // picoJava -#define EM_OPENRISC 92 // OpenRISC 32-bit embedded processor -#define EM_ARC_A5 93 // ARC Cores Tangent-A5 -#define EM_XTENSA 94 // Tensilica Xtensa Architecture -#define EM_VIDEOCORE 95 // Alphamosaic VideoCore processor -#define EM_TMM_GPP 96 // Thompson Multimedia General Purpose Processor -#define EM_NS32K 97 // National Semiconductor 32000 series -#define EM_TPC 98 // Tenor Network TPC processor -#define EM_SNP1K 99 // Trebia SNP 1000 processor -#define EM_ST200 100 // STMicroelectronics ST200 microcontroller -#define EM_IP2K 101 // Ubicom IP2022 micro controller -#define EM_MAX 102 // MAX Processor -#define EM_CR 103 // National Semiconductor CompactRISC -#define EM_F2MC16 104 // Fujitsu F2MC16 -#define EM_MSP430 105 // TI msp430 micro controller -#define EM_BLACKFIN 106 // ADI Blackfin -#define EM_SE_C33 107 // S1C33 Family of Seiko Epson processors -#define EM_SEP 108 // Sharp embedded microprocessor -#define EM_ARCA 109 // Arca RISC Microprocessor -#define EM_UNICORE 110 // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University -#define EM_EXCESS 111 // eXcess: 16/32/64-bit configurable embedded CPU -#define EM_DXP 112 // Icera Semiconductor Inc. Deep Execution Processor -#define EM_ALTERA_NIOS2 113 // Altera Nios II soft-core processor -#define EM_CRX 114 // National Semiconductor CRX -#define EM_XGATE 115 // Motorola XGATE embedded processor -#define EM_C166 116 // Infineon C16x/XC16x processor -#define EM_M16C 117 // Renesas M16C series microprocessors -#define EM_DSPIC30F 118 // Microchip Technology dsPIC30F Digital Signal Controller -#define EM_CE 119 // Freescale Communication Engine RISC core -#define EM_M32C 120 // Renesas M32C series microprocessors -#define EM_res121 121 // Reserved -#define EM_res122 122 // Reserved -#define EM_res123 123 // Reserved -#define EM_res124 124 // Reserved -#define EM_res125 125 // Reserved -#define EM_res126 126 // Reserved -#define EM_res127 127 // Reserved -#define EM_res128 128 // Reserved -#define EM_res129 129 // Reserved -#define EM_res130 130 // Reserved -#define EM_TSK3000 131 // Altium TSK3000 core -#define EM_RS08 132 // Freescale RS08 embedded processor -#define EM_res133 133 // Reserved -#define EM_ECOG2 134 // Cyan Technology eCOG2 microprocessor -#define EM_SCORE 135 // Sunplus Score -#define EM_SCORE7 135 // Sunplus S+core7 RISC processor -#define EM_DSP24 136 // New Japan Radio (NJR) 24-bit DSP Processor -#define EM_VIDEOCORE3 137 // Broadcom VideoCore III processor -#define EM_LATTICEMICO32 138 // RISC processor for Lattice FPGA architecture -#define EM_SE_C17 139 // Seiko Epson C17 family -#define EM_TI_C6000 140 // Texas Instruments TMS320C6000 DSP family -#define EM_TI_C2000 141 // Texas Instruments TMS320C2000 DSP family -#define EM_TI_C5500 142 // Texas Instruments TMS320C55x DSP family -#define EM_res143 143 // Reserved -#define EM_res144 144 // Reserved -#define EM_res145 145 // Reserved -#define EM_res146 146 // Reserved -#define EM_res147 147 // Reserved -#define EM_res148 148 // Reserved -#define EM_res149 149 // Reserved -#define EM_res150 150 // Reserved -#define EM_res151 151 // Reserved -#define EM_res152 152 // Reserved -#define EM_res153 153 // Reserved -#define EM_res154 154 // Reserved -#define EM_res155 155 // Reserved -#define EM_res156 156 // Reserved -#define EM_res157 157 // Reserved -#define EM_res158 158 // Reserved -#define EM_res159 159 // Reserved -#define EM_MMDSP_PLUS 160 // STMicroelectronics 64bit VLIW Data Signal Processor -#define EM_CYPRESS_M8C 161 // Cypress M8C microprocessor -#define EM_R32C 162 // Renesas R32C series microprocessors -#define EM_TRIMEDIA 163 // NXP Semiconductors TriMedia architecture family -#define EM_QDSP6 164 // QUALCOMM DSP6 Processor -#define EM_8051 165 // Intel 8051 and variants -#define EM_STXP7X 166 // STMicroelectronics STxP7x family -#define EM_NDS32 167 // Andes Technology compact code size embedded RISC processor family -#define EM_ECOG1 168 // Cyan Technology eCOG1X family -#define EM_ECOG1X 168 // Cyan Technology eCOG1X family -#define EM_MAXQ30 169 // Dallas Semiconductor MAXQ30 Core Micro-controllers -#define EM_XIMO16 170 // New Japan Radio (NJR) 16-bit DSP Processor -#define EM_MANIK 171 // M2000 Reconfigurable RISC Microprocessor -#define EM_CRAYNV2 172 // Cray Inc. NV2 vector architecture -#define EM_RX 173 // Renesas RX family -#define EM_METAG 174 // Imagination Technologies META processor architecture -#define EM_MCST_ELBRUS 175 // MCST Elbrus general purpose hardware architecture -#define EM_ECOG16 176 // Cyan Technology eCOG16 family -#define EM_CR16 177 // National Semiconductor CompactRISC 16-bit processor -#define EM_ETPU 178 // Freescale Extended Time Processing Unit -#define EM_SLE9X 179 // Infineon Technologies SLE9X core -#define EM_L1OM 180 // Intel L1OM -#define EM_INTEL181 181 // Reserved by Intel -#define EM_INTEL182 182 // Reserved by Intel -#define EM_res183 183 // Reserved by ARM -#define EM_res184 184 // Reserved by ARM -#define EM_AVR32 185 // Atmel Corporation 32-bit microprocessor family -#define EM_STM8 186 // STMicroeletronics STM8 8-bit microcontroller -#define EM_TILE64 187 // Tilera TILE64 multicore architecture family -#define EM_TILEPRO 188 // Tilera TILEPro multicore architecture family -#define EM_MICROBLAZE 189 // Xilinx MicroBlaze 32-bit RISC soft processor core -#define EM_CUDA 190 // NVIDIA CUDA architecture -#define EM_TILEGX 191 // Tilera TILE-Gx multicore architecture family -#define EM_CLOUDSHIELD 192 // CloudShield architecture family -#define EM_COREA_1ST 193 // KIPO-KAIST Core-A 1st generation processor family -#define EM_COREA_2ND 194 // KIPO-KAIST Core-A 2nd generation processor family -#define EM_ARC_COMPACT2 195 // Synopsys ARCompact V2 -#define EM_OPEN8 196 // Open8 8-bit RISC soft processor core -#define EM_RL78 197 // Renesas RL78 family -#define EM_VIDEOCORE5 198 // Broadcom VideoCore V processor -#define EM_78KOR 199 // Renesas 78KOR family -#define EM_56800EX 200 // Freescale 56800EX Digital Signal Controller (DSC) -#define EM_BA1 201 // Beyond BA1 CPU architecture -#define EM_BA2 202 // Beyond BA2 CPU architecture -#define EM_XCORE 203 // XMOS xCORE processor family -#define EM_MCHP_PIC 204 // Microchip 8-bit PIC(r) family -#define EM_INTEL205 205 // Reserved by Intel -#define EM_INTEL206 206 // Reserved by Intel -#define EM_INTEL207 207 // Reserved by Intel -#define EM_INTEL208 208 // Reserved by Intel -#define EM_INTEL209 209 // Reserved by Intel -#define EM_KM32 210 // KM211 KM32 32-bit processor -#define EM_KMX32 211 // KM211 KMX32 32-bit processor -#define EM_KMX16 212 // KM211 KMX16 16-bit processor -#define EM_KMX8 213 // KM211 KMX8 8-bit processor -#define EM_KVARC 214 // KM211 KVARC processor -#define EM_CDP 215 // Paneve CDP architecture family -#define EM_COGE 216 // Cognitive Smart Memory Processor -#define EM_COOL 217 // iCelero CoolEngine -#define EM_NORC 218 // Nanoradio Optimized RISC -#define EM_CSR_KALIMBA 219 // CSR Kalimba architecture family -#define EM_Z80 220 // Zilog Z80 -#define EM_VISIUM 221 // Controls and Data Services VISIUMcore processor -#define EM_FT32 222 // FTDI Chip FT32 high performance 32-bit RISC architecture -#define EM_MOXIE 223 // Moxie processor family -#define EM_AMDGPU 224 // AMD GPU architecture -#define EM_RISCV 243 // RISC-V -#define EM_LANAI 244 // Lanai processor -#define EM_CEVA 245 // CEVA Processor Architecture Family -#define EM_CEVA_X2 246 // CEVA X2 Processor Family -#define EM_BPF 247 // Linux BPF – in-kernel virtual machine - -// File version -#define EV_NONE 0 -#define EV_CURRENT 1 - -// Identification index -#define EI_MAG0 0 -#define EI_MAG1 1 -#define EI_MAG2 2 -#define EI_MAG3 3 -#define EI_CLASS 4 -#define EI_DATA 5 -#define EI_VERSION 6 -#define EI_OSABI 7 -#define EI_ABIVERSION 8 -#define EI_PAD 9 -#define EI_NIDENT 16 - -// Magic number -#define ELFMAG0 0x7F -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' - -// File class -#define ELFCLASSNONE 0 -#define ELFCLASS32 1 -#define ELFCLASS64 2 - -// Encoding -#define ELFDATANONE 0 -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 - -// OS extensions -#define ELFOSABI_NONE 0 // No extensions or unspecified -#define ELFOSABI_HPUX 1 // Hewlett-Packard HP-UX -#define ELFOSABI_NETBSD 2 // NetBSD -#define ELFOSABI_LINUX 3 // Linux -#define ELFOSABI_SOLARIS 6 // Sun Solaris -#define ELFOSABI_AIX 7 // AIX -#define ELFOSABI_IRIX 8 // IRIX -#define ELFOSABI_FREEBSD 9 // FreeBSD -#define ELFOSABI_TRU64 10 // Compaq TRU64 UNIX -#define ELFOSABI_MODESTO 11 // Novell Modesto -#define ELFOSABI_OPENBSD 12 // Open BSD -#define ELFOSABI_OPENVMS 13 // Open VMS -#define ELFOSABI_NSK 14 // Hewlett-Packard Non-Stop Kernel -#define ELFOSABI_AROS 15 // Amiga Research OS -#define ELFOSABI_FENIXOS 16 // The FenixOS highly scalable multi-core OS -// 64-255 Architecture-specific value range - - -///////////////////// -// Sections constants - -// Section indexes -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xFF00 -#define SHN_LOPROC 0xFF00 -#define SHN_HIPROC 0xFF1F -#define SHN_LOOS 0xFF20 -#define SHN_HIOS 0xFF3F -#define SHN_ABS 0xFFF1 -#define SHN_COMMON 0xFFF2 -#define SHN_XINDEX 0xFFFF -#define SHN_HIRESERVE 0xFFFF - -// Section types -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_INIT_ARRAY 14 -#define SHT_FINI_ARRAY 15 -#define SHT_PREINIT_ARRAY 16 -#define SHT_GROUP 17 -#define SHT_SYMTAB_SHNDX 18 -#define SHT_LOOS 0x60000000 -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 -#define SHT_HIPROC 0x7FFFFFFF -#define SHT_LOUSER 0x80000000 -#define SHT_HIUSER 0xFFFFFFFF - -// Section attribute flags -#define SHF_WRITE 0x1 -#define SHF_ALLOC 0x2 -#define SHF_EXECINSTR 0x4 -#define SHF_MERGE 0x10 -#define SHF_STRINGS 0x20 -#define SHF_INFO_LINK 0x40 -#define SHF_LINK_ORDER 0x80 -#define SHF_OS_NONCONFORMING 0x100 -#define SHF_GROUP 0x200 -#define SHF_TLS 0x400 -#define SHF_MASKOS 0x0ff00000 -#define SHF_MASKPROC 0xF0000000 - -// Section group flags -#define GRP_COMDAT 0x1 -#define GRP_MASKOS 0x0ff00000 -#define GRP_MASKPROC 0xf0000000 - -// Symbol binding -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 -#define STB_LOOS 10 -#define STB_HIOS 12 -#define STB_MULTIDEF 13 -#define STB_LOPROC 13 -#define STB_HIPROC 15 - -// Symbol types -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 -#define STT_COMMON 5 -#define STT_TLS 6 -#define STT_LOOS 10 -#define STT_HIOS 12 -#define STT_LOPROC 13 -#define STT_HIPROC 15 - -// Symbol visibility -#define STV_DEFAULT 0 -#define STV_INTERNAL 1 -#define STV_HIDDEN 2 -#define STV_PROTECTED 3 - -// Undefined name -#define STN_UNDEF 0 - -// Relocation types -#define R_386_NONE 0 -#define R_X86_64_NONE 0 -#define R_386_32 1 -#define R_X86_64_64 1 -#define R_386_PC32 2 -#define R_X86_64_PC32 2 -#define R_386_GOT32 3 -#define R_X86_64_GOT32 3 -#define R_386_PLT32 4 -#define R_X86_64_PLT32 4 -#define R_386_COPY 5 -#define R_X86_64_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_X86_64_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_X86_64_JUMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_X86_64_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_X86_64_GOTPCREL 9 -#define R_386_GOTPC 10 -#define R_X86_64_32 10 -#define R_X86_64_32S 11 -#define R_X86_64_16 12 -#define R_X86_64_PC16 13 -#define R_X86_64_8 14 -#define R_X86_64_PC8 15 -#define R_X86_64_DTPMOD64 16 -#define R_X86_64_DTPOFF64 17 -#define R_X86_64_TPOFF64 18 -#define R_X86_64_TLSGD 19 -#define R_X86_64_TLSLD 20 -#define R_X86_64_DTPOFF32 21 -#define R_X86_64_GOTTPOFF 22 -#define R_X86_64_TPOFF32 23 -#define R_X86_64_PC64 24 -#define R_X86_64_GOTOFF64 25 -#define R_X86_64_GOTPC32 26 -#define R_X86_64_GOT64 27 -#define R_X86_64_GOTPCREL64 28 -#define R_X86_64_GOTPC64 29 -#define R_X86_64_GOTPLT64 30 -#define R_X86_64_PLTOFF64 31 -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_X86_64_TLSDESC_CALL 35 -#define R_X86_64_TLSDESC 36 -#define R_X86_64_IRELATIVE 37 -#define R_X86_64_GNU_VTINHERIT 250 -#define R_X86_64_GNU_VTENTRY 251 - -// Segment types -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_TLS 7 -#define PT_LOOS 0x60000000 -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 -#define PT_HIPROC 0x7FFFFFFF - -// Segment flags -#define PF_X 1 // Execute -#define PF_W 2 // Write -#define PF_R 4 // Read -#define PF_MASKOS 0x0ff00000 // Unspecified -#define PF_MASKPROC 0xf0000000 // Unspecified - -// Dynamic Array Tags -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_BIND_NOW 24 -#define DT_INIT_ARRAY 25 -#define DT_FINI_ARRAY 26 -#define DT_INIT_ARRAYSZ 27 -#define DT_FINI_ARRAYSZ 28 -#define DT_RUNPATH 29 -#define DT_FLAGS 30 -#define DT_ENCODING 32 -#define DT_PREINIT_ARRAY 32 -#define DT_PREINIT_ARRAYSZ 33 -#define DT_MAXPOSTAGS 34 -#define DT_LOOS 0x6000000D -#define DT_HIOS 0x6ffff000 -#define DT_LOPROC 0x70000000 -#define DT_HIPROC 0x7FFFFFFF - -// DT_FLAGS values -#define DF_ORIGIN 0x1 -#define DF_SYMBOLIC 0x2 -#define DF_TEXTREL 0x4 -#define DF_BIND_NOW 0x8 -#define DF_STATIC_TLS 0x10 - - -// ELF file header -struct Elf32_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - -struct Elf64_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - - -// Section header -struct Elf32_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf_Word sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Word sh_addralign; - Elf_Word sh_entsize; -}; - -struct Elf64_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf_Xword sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Xword sh_addralign; - Elf_Xword sh_entsize; -}; - - -// Segment header -struct Elf32_Phdr { - Elf_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf_Word p_filesz; - Elf_Word p_memsz; - Elf_Word p_flags; - Elf_Word p_align; -}; - -struct Elf64_Phdr { - Elf_Word p_type; - Elf_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf_Xword p_filesz; - Elf_Xword p_memsz; - Elf_Xword p_align; -}; - - -// Symbol table entry -struct Elf32_Sym { - Elf_Word st_name; - Elf32_Addr st_value; - Elf_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; -}; - -struct Elf64_Sym { - Elf_Word st_name; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; - Elf64_Addr st_value; - Elf_Xword st_size; -}; - - -#define ELF_ST_BIND(i) ((i) >> 4) -#define ELF_ST_TYPE(i) ((i)&0xf) -#define ELF_ST_INFO(b, t) (((b) << 4) + ((t)&0xf)) - -#define ELF_ST_VISIBILITY(o) ((o)&0x3) - - -// Relocation entries -struct Elf32_Rel { - Elf32_Addr r_offset; - Elf_Word r_info; -}; - -struct Elf32_Rela { - Elf32_Addr r_offset; - Elf_Word r_info; - Elf_Sword r_addend; -}; - -struct Elf64_Rel { - Elf64_Addr r_offset; - Elf_Xword r_info; -}; - -struct Elf64_Rela { - Elf64_Addr r_offset; - Elf_Xword r_info; - Elf_Sxword r_addend; -}; - - -#define ELF32_R_SYM(i) ((i) >> 8) -#define ELF32_R_TYPE(i) ((unsigned char)(i)) -#define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i)&0xffffffffL) -#define ELF64_R_INFO(s, t) ((((int64_t)s) << 32) + ((t)&0xffffffffL)) - -// Dynamic structure -struct Elf32_Dyn { - Elf_Sword d_tag; - union { - Elf_Word d_val; - Elf32_Addr d_ptr; - } d_un; -}; - -struct Elf64_Dyn { - Elf_Sxword d_tag; - union { - Elf_Xword d_val; - Elf64_Addr d_ptr; - } d_un; -}; - -} // namespace ELFIO - -#endif // ELFTYPES_H diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio.hpp deleted file mode 100644 index 6bc0418d14..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio.hpp +++ /dev/null @@ -1,740 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_HPP -#define ELFIO_HPP - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4996) -#pragma warning(disable : 4355) -#pragma warning(disable : 4244) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "elf_types.hpp" -#include "elfio_utils.hpp" -#include "elfio_header.hpp" -#include "elfio_section.hpp" -#include "elfio_segment.hpp" -#include "elfio_strings.hpp" - -#define ELFIO_HEADER_ACCESS_GET(TYPE, FNAME) \ - TYPE get_##FNAME() const { return header->get_##FNAME(); } - -#define ELFIO_HEADER_ACCESS_GET_SET(TYPE, FNAME) \ - TYPE get_##FNAME() const { return header->get_##FNAME(); } \ - void set_##FNAME(TYPE val) { header->set_##FNAME(val); } - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class elfio { - public: - //------------------------------------------------------------------------------ - elfio() : sections(this), segments(this) { - header = 0; - current_file_pos = 0; - create(ELFCLASS32, ELFDATA2LSB); - } - - //------------------------------------------------------------------------------ - ~elfio() { clean(); } - - //------------------------------------------------------------------------------ - void create(unsigned char file_class, unsigned char encoding) { - clean(); - convertor.setup(encoding); - header = create_header(file_class, encoding); - create_mandatory_sections(); - } - - //------------------------------------------------------------------------------ - bool load(const std::string& file_name) { - std::ifstream stream; - stream.open(file_name.c_str(), std::ios::in | std::ios::binary); - if (!stream) { - return false; - } - - return load(stream); - } - - //------------------------------------------------------------------------------ - bool load(std::istream& stream) { - clean(); - - unsigned char e_ident[EI_NIDENT]; - - // Read ELF file signature - stream.seekg(0); - stream.read(reinterpret_cast(&e_ident), sizeof(e_ident)); - - // Is it ELF file? - if (stream.gcount() != sizeof(e_ident) || e_ident[EI_MAG0] != ELFMAG0 || - e_ident[EI_MAG1] != ELFMAG1 || e_ident[EI_MAG2] != ELFMAG2 || - e_ident[EI_MAG3] != ELFMAG3) { - return false; - } - - if ((e_ident[EI_CLASS] != ELFCLASS64) && (e_ident[EI_CLASS] != ELFCLASS32)) { - return false; - } - - convertor.setup(e_ident[EI_DATA]); - - header = create_header(e_ident[EI_CLASS], e_ident[EI_DATA]); - if (0 == header) { - return false; - } - if (!header->load(stream)) { - return false; - } - - load_sections(stream); - load_segments(stream); - - return true; - } - - //------------------------------------------------------------------------------ - bool save(const std::string& file_name) { - std::ofstream f(file_name.c_str(), std::ios::out | std::ios::binary); - - if (!f) { - return false; - } - - bool is_still_good = true; - - // Define layout specific header fields - // The position of the segment table is fixed after the header. - // The position of the section table is variable and needs to be fixed - // before saving. - header->set_segments_num(segments.size()); - header->set_segments_offset(segments.size() ? header->get_header_size() : 0); - header->set_sections_num(sections.size()); - header->set_sections_offset(0); - - // Layout the first section right after the segment table - current_file_pos = header->get_header_size() + - header->get_segment_entry_size() * header->get_segments_num(); - - is_still_good = layout_segments_and_their_sections(); - is_still_good = is_still_good && layout_sections_without_segments(); - is_still_good = is_still_good && layout_section_table(); - - is_still_good = is_still_good && save_header(f); - is_still_good = is_still_good && save_sections(f); - is_still_good = is_still_good && save_segments(f); - - f.close(); - - return is_still_good; - } - - //------------------------------------------------------------------------------ - // ELF header access functions - ELFIO_HEADER_ACCESS_GET(unsigned char, class); - ELFIO_HEADER_ACCESS_GET(unsigned char, elf_version); - ELFIO_HEADER_ACCESS_GET(unsigned char, encoding); - ELFIO_HEADER_ACCESS_GET(Elf_Word, version); - ELFIO_HEADER_ACCESS_GET(Elf_Half, header_size); - ELFIO_HEADER_ACCESS_GET(Elf_Half, section_entry_size); - ELFIO_HEADER_ACCESS_GET(Elf_Half, segment_entry_size); - - ELFIO_HEADER_ACCESS_GET_SET(unsigned char, os_abi); - ELFIO_HEADER_ACCESS_GET_SET(unsigned char, abi_version); - ELFIO_HEADER_ACCESS_GET_SET(Elf_Half, type); - ELFIO_HEADER_ACCESS_GET_SET(Elf_Half, machine); - ELFIO_HEADER_ACCESS_GET_SET(Elf_Word, flags); - ELFIO_HEADER_ACCESS_GET_SET(Elf64_Addr, entry); - ELFIO_HEADER_ACCESS_GET_SET(Elf64_Off, sections_offset); - ELFIO_HEADER_ACCESS_GET_SET(Elf64_Off, segments_offset); - ELFIO_HEADER_ACCESS_GET_SET(Elf_Half, section_name_str_index); - - //------------------------------------------------------------------------------ - const endianess_convertor& get_convertor() const { return convertor; } - - //------------------------------------------------------------------------------ - Elf_Xword get_default_entry_size(Elf_Word section_type) const { - switch (section_type) { - case SHT_RELA: - if (header->get_class() == ELFCLASS64) { - return sizeof(Elf64_Rela); - } else { - return sizeof(Elf32_Rela); - } - case SHT_REL: - if (header->get_class() == ELFCLASS64) { - return sizeof(Elf64_Rel); - } else { - return sizeof(Elf32_Rel); - } - case SHT_SYMTAB: - if (header->get_class() == ELFCLASS64) { - return sizeof(Elf64_Sym); - } else { - return sizeof(Elf32_Sym); - } - case SHT_DYNAMIC: - if (header->get_class() == ELFCLASS64) { - return sizeof(Elf64_Dyn); - } else { - return sizeof(Elf32_Dyn); - } - default: - return 0; - } - } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - void clean() { - delete header; - header = 0; - - std::vector::const_iterator it; - for (it = sections_.begin(); it != sections_.end(); ++it) { - delete *it; - } - sections_.clear(); - - std::vector::const_iterator it1; - for (it1 = segments_.begin(); it1 != segments_.end(); ++it1) { - delete *it1; - } - segments_.clear(); - } - - //------------------------------------------------------------------------------ - elf_header* create_header(unsigned char file_class, unsigned char encoding) { - elf_header* new_header = 0; - - if (file_class == ELFCLASS64) { - new_header = new elf_header_impl(&convertor, encoding); - } else if (file_class == ELFCLASS32) { - new_header = new elf_header_impl(&convertor, encoding); - } else { - return 0; - } - - return new_header; - } - - //------------------------------------------------------------------------------ - section* create_section() { - section* new_section; - unsigned char file_class = get_class(); - - if (file_class == ELFCLASS64) { - new_section = new section_impl(&convertor); - } else if (file_class == ELFCLASS32) { - new_section = new section_impl(&convertor); - } else { - return 0; - } - - new_section->set_index((Elf_Half)sections_.size()); - sections_.push_back(new_section); - - return new_section; - } - - - //------------------------------------------------------------------------------ - segment* create_segment() { - segment* new_segment; - unsigned char file_class = header->get_class(); - - if (file_class == ELFCLASS64) { - new_segment = new segment_impl(&convertor); - } else if (file_class == ELFCLASS32) { - new_segment = new segment_impl(&convertor); - } else { - return 0; - } - - new_segment->set_index((Elf_Half)segments_.size()); - segments_.push_back(new_segment); - - return new_segment; - } - - //------------------------------------------------------------------------------ - void create_mandatory_sections() { - // Create null section without calling to 'add_section' as no string - // section containing section names exists yet - section* sec0 = create_section(); - sec0->set_index(0); - sec0->set_name(""); - sec0->set_name_string_offset(0); - - set_section_name_str_index(1); - section* shstrtab = sections.add(".shstrtab"); - shstrtab->set_type(SHT_STRTAB); - shstrtab->set_addr_align(1); - } - - //------------------------------------------------------------------------------ - Elf_Half load_sections(std::istream& stream) { - Elf_Half entry_size = header->get_section_entry_size(); - Elf_Half num = header->get_sections_num(); - Elf64_Off offset = header->get_sections_offset(); - - for (Elf_Half i = 0; i < num; ++i) { - section* sec = create_section(); - sec->load(stream, (std::streamoff)offset + i * entry_size); - sec->set_index(i); - // To mark that the section is not permitted to reassign address - // during layout calculation - sec->set_address(sec->get_address()); - } - - Elf_Half shstrndx = get_section_name_str_index(); - - if (SHN_UNDEF != shstrndx) { - string_section_accessor str_reader(sections[shstrndx]); - for (Elf_Half i = 0; i < num; ++i) { - Elf_Word offset = sections[i]->get_name_string_offset(); - const char* p = str_reader.get_string(offset); - if (p != 0) { - sections[i]->set_name(p); - } - } - } - - return num; - } - - //------------------------------------------------------------------------------ - bool load_segments(std::istream& stream) { - Elf_Half entry_size = header->get_segment_entry_size(); - Elf_Half num = header->get_segments_num(); - Elf64_Off offset = header->get_segments_offset(); - - for (Elf_Half i = 0; i < num; ++i) { - segment* seg; - unsigned char file_class = header->get_class(); - - if (file_class == ELFCLASS64) { - seg = new segment_impl(&convertor); - } else if (file_class == ELFCLASS32) { - seg = new segment_impl(&convertor); - } else { - return false; - } - - seg->load(stream, (std::streamoff)offset + i * entry_size); - seg->set_index(i); - - // Add sections to the segments (similar to readelfs algorithm) - Elf64_Off segBaseOffset = seg->get_offset(); - Elf64_Off segEndOffset = segBaseOffset + seg->get_file_size(); - Elf64_Off segVBaseAddr = seg->get_virtual_address(); - Elf64_Off segVEndAddr = segVBaseAddr + seg->get_memory_size(); - for (Elf_Half j = 0; j < sections.size(); ++j) { - const section* psec = sections[j]; - - // SHF_ALLOC sections are matched based on the virtual address - // otherwise the file offset is matched - if (psec->get_flags() & SHF_ALLOC - ? (segVBaseAddr <= psec->get_address() && - psec->get_address() + psec->get_size() <= segVEndAddr) - : (segBaseOffset <= psec->get_offset() && - psec->get_offset() + psec->get_size() <= segEndOffset)) { - seg->add_section_index(psec->get_index(), psec->get_addr_align()); - } - } - - // Add section into the segments' container - segments_.push_back(seg); - } - - return true; - } - - //------------------------------------------------------------------------------ - bool save_header(std::ofstream& f) { return header->save(f); } - - //------------------------------------------------------------------------------ - bool save_sections(std::ofstream& f) { - for (unsigned int i = 0; i < sections_.size(); ++i) { - section* sec = sections_.at(i); - - std::streampos headerPosition = (std::streamoff)header->get_sections_offset() + - header->get_section_entry_size() * sec->get_index(); - - sec->save(f, headerPosition, sec->get_offset()); - } - return true; - } - - //------------------------------------------------------------------------------ - bool save_segments(std::ofstream& f) { - for (unsigned int i = 0; i < segments_.size(); ++i) { - segment* seg = segments_.at(i); - - std::streampos headerPosition = - header->get_segments_offset() + header->get_segment_entry_size() * seg->get_index(); - - seg->save(f, headerPosition, seg->get_offset()); - } - return true; - } - - //------------------------------------------------------------------------------ - bool is_section_without_segment(unsigned int section_index) { - bool found = false; - - for (unsigned int j = 0; !found && (j < segments.size()); ++j) { - for (unsigned int k = 0; !found && (k < segments[j]->get_sections_num()); ++k) { - found = segments[j]->get_section_index_at(k) == section_index; - } - } - - return !found; - } - - //------------------------------------------------------------------------------ - bool is_subsequence_of(segment* seg1, segment* seg2) { - // Return 'true' if sections of seg1 are a subset of sections in seg2 - const std::vector& sections1 = seg1->get_sections(); - const std::vector& sections2 = seg2->get_sections(); - - bool found = false; - if (sections1.size() < sections2.size()) { - found = std::includes(sections2.begin(), sections2.end(), sections1.begin(), - sections1.end()); - } - - return found; - } - - //------------------------------------------------------------------------------ - std::vector get_ordered_segments() { - std::vector res; - std::deque worklist; - - res.reserve(segments.size()); - std::copy(segments_.begin(), segments_.end(), std::back_inserter(worklist)); - - // Bring the segments which start at address 0 to the front - size_t nextSlot = 0; - for (size_t i = 0; i < worklist.size(); ++i) { - if (i != nextSlot && worklist[i]->is_offset_initialized() && - worklist[i]->get_offset() == 0) { - std::swap(worklist[i], worklist[nextSlot]); - ++nextSlot; - } - } - - while (!worklist.empty()) { - segment* seg = worklist.front(); - worklist.pop_front(); - - size_t i = 0; - for (; i < worklist.size(); ++i) { - if (is_subsequence_of(seg, worklist[i])) { - break; - } - } - - if (i < worklist.size()) - worklist.push_back(seg); - else - res.push_back(seg); - } - - return res; - } - - - //------------------------------------------------------------------------------ - bool layout_sections_without_segments() { - for (unsigned int i = 0; i < sections_.size(); ++i) { - if (is_section_without_segment(i)) { - section* sec = sections_[i]; - - Elf_Xword section_align = sec->get_addr_align(); - if (section_align > 1 && current_file_pos % section_align != 0) { - current_file_pos += section_align - current_file_pos % section_align; - } - - if (0 != sec->get_index()) sec->set_offset(current_file_pos); - - if (SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type()) { - current_file_pos += sec->get_size(); - } - } - } - - return true; - } - - - //------------------------------------------------------------------------------ - bool layout_segments_and_their_sections() { - std::vector worklist; - std::vector section_generated(sections.size(), false); - - // Get segments in a order in where segments which contain a - // sub sequence of other segments are located at the end - worklist = get_ordered_segments(); - - for (unsigned int i = 0; i < worklist.size(); ++i) { - Elf_Xword segment_memory = 0; - Elf_Xword segment_filesize = 0; - Elf_Xword seg_start_pos = current_file_pos; - segment* seg = worklist[i]; - - // Special case: PHDR segment - // This segment contains the program headers but no sections - if (seg->get_type() == PT_PHDR && seg->get_sections_num() == 0) { - seg_start_pos = header->get_segments_offset(); - segment_memory = segment_filesize = - header->get_segment_entry_size() * header->get_segments_num(); - } - // Special case: - // Segments which start with the NULL section and have further sections - else if (seg->get_sections_num() > 1 && - sections[seg->get_section_index_at(0)]->get_type() == SHT_NULL) { - seg_start_pos = 0; - if (seg->get_sections_num()) { - segment_memory = segment_filesize = current_file_pos; - } - } - // New segments with not generated sections - // have to be aligned - else if (seg->get_sections_num() && !section_generated[seg->get_section_index_at(0)]) { - Elf64_Off cur_page_alignment = current_file_pos % seg->get_align(); - Elf64_Off req_page_alignment = seg->get_virtual_address() % seg->get_align(); - Elf64_Off error = req_page_alignment - cur_page_alignment; - - current_file_pos += (seg->get_align() + error) % seg->get_align(); - seg_start_pos = current_file_pos; - } else if (seg->get_sections_num()) { - seg_start_pos = sections[seg->get_section_index_at(0)]->get_offset(); - } - - // Write segment's data - for (unsigned int j = 0; j < seg->get_sections_num(); ++j) { - Elf_Half index = seg->get_section_index_at(j); - - section* sec = sections[index]; - - // The NULL section is always generated - if (SHT_NULL == sec->get_type()) { - section_generated[index] = true; - continue; - } - - Elf_Xword secAlign = 0; - // Fix up the alignment - if (!section_generated[index] && sec->is_address_initialized() && - SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type()) { - // Align the sections based on the virtual addresses - // when possible (this is what matters for execution) - Elf64_Off req_offset = sec->get_address() - seg->get_virtual_address(); - Elf64_Off cur_offset = current_file_pos - seg_start_pos; - secAlign = req_offset - cur_offset; - } else if (!section_generated[index]) { - // If no address has been specified then only the section - // alignment constraint has to be matched - Elf_Xword align = sec->get_addr_align(); - if (align == 0) { - align = 1; - } - Elf64_Off error = current_file_pos % align; - secAlign = (align - error) % align; - } else { - // Alignment for already generated sections - secAlign = sec->get_offset() - seg_start_pos - segment_filesize; - } - - // Determine the segment file and memory sizes - // Special case .tbss section (NOBITS) in non TLS segment - if ((sec->get_flags() & SHF_ALLOC) && - !((sec->get_flags() & SHF_TLS) && (seg->get_type() != PT_TLS) && - (SHT_NOBITS == sec->get_type()))) - segment_memory += sec->get_size() + secAlign; - if (SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type()) - segment_filesize += sec->get_size() + secAlign; - - // Nothing to be done when generating nested segments - if (section_generated[index]) { - continue; - } - - current_file_pos += secAlign; - - // Set the section addresses when missing - if (!sec->is_address_initialized()) - sec->set_address(seg->get_virtual_address() + current_file_pos - seg_start_pos); - - if (0 != sec->get_index()) sec->set_offset(current_file_pos); - - if (SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type()) - current_file_pos += sec->get_size(); - section_generated[index] = true; - } - - seg->set_file_size(segment_filesize); - seg->set_memory_size(segment_memory); - seg->set_offset(seg_start_pos); - } - - return true; - } - - //------------------------------------------------------------------------------ - bool layout_section_table() { - // Simply place the section table at the end for now - Elf64_Off alignmentError = current_file_pos % 4; - current_file_pos += (4 - alignmentError) % 4; - header->set_sections_offset(current_file_pos); - return true; - } - - - //------------------------------------------------------------------------------ - public: - friend class Sections; - class Sections { - public: - //------------------------------------------------------------------------------ - Sections(elfio* parent_) : parent(parent_) {} - - //------------------------------------------------------------------------------ - Elf_Half size() const { return (Elf_Half)parent->sections_.size(); } - - //------------------------------------------------------------------------------ - section* operator[](unsigned int index) const { - section* sec = 0; - - if (index < parent->sections_.size()) { - sec = parent->sections_[index]; - } - - return sec; - } - - //------------------------------------------------------------------------------ - section* operator[](const std::string& name) const { - section* sec = 0; - - std::vector::const_iterator it; - for (it = parent->sections_.begin(); it != parent->sections_.end(); ++it) { - if ((*it)->get_name() == name) { - sec = *it; - break; - } - } - - return sec; - } - - //------------------------------------------------------------------------------ - section* add(const std::string& name) { - section* new_section = parent->create_section(); - new_section->set_name(name); - - Elf_Half str_index = parent->get_section_name_str_index(); - section* string_table(parent->sections_[str_index]); - string_section_accessor str_writer(string_table); - Elf_Word pos = str_writer.add_string(name); - new_section->set_name_string_offset(pos); - - return new_section; - } - - //------------------------------------------------------------------------------ - std::vector::iterator begin() { return parent->sections_.begin(); } - - //------------------------------------------------------------------------------ - std::vector::iterator end() { return parent->sections_.end(); } - - //------------------------------------------------------------------------------ - private: - elfio* parent; - } sections; - - //------------------------------------------------------------------------------ - public: - friend class Segments; - class Segments { - public: - //------------------------------------------------------------------------------ - Segments(elfio* parent_) : parent(parent_) {} - - //------------------------------------------------------------------------------ - Elf_Half size() const { return (Elf_Half)parent->segments_.size(); } - - //------------------------------------------------------------------------------ - segment* operator[](unsigned int index) const { return parent->segments_[index]; } - - - //------------------------------------------------------------------------------ - segment* add() { return parent->create_segment(); } - - //------------------------------------------------------------------------------ - std::vector::iterator begin() { return parent->segments_.begin(); } - - //------------------------------------------------------------------------------ - std::vector::iterator end() { return parent->segments_.end(); } - - //------------------------------------------------------------------------------ - private: - elfio* parent; - } segments; - - //------------------------------------------------------------------------------ - private: - elf_header* header; - std::vector sections_; - std::vector segments_; - endianess_convertor convertor; - - Elf_Xword current_file_pos; -}; - -} // namespace ELFIO - -#include "elfio_symbols.hpp" -#include "elfio_note.hpp" -#include "elfio_relocation.hpp" -#include "elfio_dynamic.hpp" - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif // ELFIO_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_dump.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_dump.hpp deleted file mode 100644 index c40a01090e..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_dump.hpp +++ /dev/null @@ -1,825 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_DUMP_HPP -#define ELFIO_DUMP_HPP - -#include -#include -#include -#include -#include -#include "elfio.hpp" - -namespace ELFIO { - - -static struct class_table_t { - const char key; - const char* str; -} class_table[] = { - {ELFCLASS32, "ELF32"}, - {ELFCLASS64, "ELF64"}, -}; - - -static struct endian_table_t { - const char key; - const char* str; -} endian_table[] = { - {ELFDATANONE, "None"}, - {ELFDATA2LSB, "Little endian"}, - {ELFDATA2MSB, "Big endian"}, -}; - - -static struct version_table_t { - const Elf64_Word key; - const char* str; -} version_table[] = { - {EV_NONE, "None"}, - {EV_CURRENT, "Current"}, -}; - - -static struct type_table_t { - const Elf32_Half key; - const char* str; -} type_table[] = { - {ET_NONE, "No file type"}, {ET_REL, "Relocatable file"}, {ET_EXEC, "Executable file"}, - {ET_DYN, "Shared object file"}, {ET_CORE, "Core file"}, -}; - - -static struct machine_table_t { - const Elf64_Half key; - const char* str; -} machine_table[] = { - {EM_NONE, "No machine"}, - {EM_M32, "AT&T WE 32100"}, - {EM_SPARC, "SUN SPARC"}, - {EM_386, "Intel 80386"}, - {EM_68K, "Motorola m68k family"}, - {EM_88K, "Motorola m88k family"}, - {EM_486, "Intel 80486// Reserved for future use"}, - {EM_860, "Intel 80860"}, - {EM_MIPS, "MIPS R3000 (officially, big-endian only)"}, - {EM_S370, "IBM System/370"}, - {EM_MIPS_RS3_LE, "MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated"}, - {EM_res011, "Reserved"}, - {EM_res012, "Reserved"}, - {EM_res013, "Reserved"}, - {EM_res014, "Reserved"}, - {EM_PARISC, "HPPA"}, - {EM_res016, "Reserved"}, - {EM_VPP550, "Fujitsu VPP500"}, - {EM_SPARC32PLUS, "Sun's v8plus"}, - {EM_960, "Intel 80960"}, - {EM_PPC, "PowerPC"}, - {EM_PPC64, "64-bit PowerPC"}, - {EM_S390, "IBM S/390"}, - {EM_SPU, "Sony/Toshiba/IBM SPU"}, - {EM_res024, "Reserved"}, - {EM_res025, "Reserved"}, - {EM_res026, "Reserved"}, - {EM_res027, "Reserved"}, - {EM_res028, "Reserved"}, - {EM_res029, "Reserved"}, - {EM_res030, "Reserved"}, - {EM_res031, "Reserved"}, - {EM_res032, "Reserved"}, - {EM_res033, "Reserved"}, - {EM_res034, "Reserved"}, - {EM_res035, "Reserved"}, - {EM_V800, "NEC V800 series"}, - {EM_FR20, "Fujitsu FR20"}, - {EM_RH32, "TRW RH32"}, - {EM_MCORE, "Motorola M*Core // May also be taken by Fujitsu MMA"}, - {EM_RCE, "Old name for MCore"}, - {EM_ARM, "ARM"}, - {EM_OLD_ALPHA, "Digital Alpha"}, - {EM_SH, "Renesas (formerly Hitachi) / SuperH SH"}, - {EM_SPARCV9, "SPARC v9 64-bit"}, - {EM_TRICORE, "Siemens Tricore embedded processor"}, - {EM_ARC, "ARC Cores"}, - {EM_H8_300, "Renesas (formerly Hitachi) H8/300"}, - {EM_H8_300H, "Renesas (formerly Hitachi) H8/300H"}, - {EM_H8S, "Renesas (formerly Hitachi) H8S"}, - {EM_H8_500, "Renesas (formerly Hitachi) H8/500"}, - {EM_IA_64, "Intel IA-64 Processor"}, - {EM_MIPS_X, "Stanford MIPS-X"}, - {EM_COLDFIRE, "Motorola Coldfire"}, - {EM_68HC12, "Motorola M68HC12"}, - {EM_MMA, "Fujitsu Multimedia Accelerator"}, - {EM_PCP, "Siemens PCP"}, - {EM_NCPU, "Sony nCPU embedded RISC processor"}, - {EM_NDR1, "Denso NDR1 microprocesspr"}, - {EM_STARCORE, "Motorola Star*Core processor"}, - {EM_ME16, "Toyota ME16 processor"}, - {EM_ST100, "STMicroelectronics ST100 processor"}, - {EM_TINYJ, "Advanced Logic Corp. TinyJ embedded processor"}, - {EM_X86_64, "Advanced Micro Devices X86-64 processor"}, - {EM_PDSP, "Sony DSP Processor"}, - {EM_PDP10, "Digital Equipment Corp. PDP-10"}, - {EM_PDP11, "Digital Equipment Corp. PDP-11"}, - {EM_FX66, "Siemens FX66 microcontroller"}, - {EM_ST9PLUS, "STMicroelectronics ST9+ 8/16 bit microcontroller"}, - {EM_ST7, "STMicroelectronics ST7 8-bit microcontroller"}, - {EM_68HC16, "Motorola MC68HC16 Microcontroller"}, - {EM_68HC11, "Motorola MC68HC11 Microcontroller"}, - {EM_68HC08, "Motorola MC68HC08 Microcontroller"}, - {EM_68HC05, "Motorola MC68HC05 Microcontroller"}, - {EM_SVX, "Silicon Graphics SVx"}, - {EM_ST19, "STMicroelectronics ST19 8-bit cpu"}, - {EM_VAX, "Digital VAX"}, - {EM_CRIS, "Axis Communications 32-bit embedded processor"}, - {EM_JAVELIN, "Infineon Technologies 32-bit embedded cpu"}, - {EM_FIREPATH, "Element 14 64-bit DSP processor"}, - {EM_ZSP, "LSI Logic's 16-bit DSP processor"}, - {EM_MMIX, "Donald Knuth's educational 64-bit processor"}, - {EM_HUANY, "Harvard's machine-independent format"}, - {EM_PRISM, "SiTera Prism"}, - {EM_AVR, "Atmel AVR 8-bit microcontroller"}, - {EM_FR30, "Fujitsu FR30"}, - {EM_D10V, "Mitsubishi D10V"}, - {EM_D30V, "Mitsubishi D30V"}, - {EM_V850, "NEC v850"}, - {EM_M32R, "Renesas M32R (formerly Mitsubishi M32R)"}, - {EM_MN10300, "Matsushita MN10300"}, - {EM_MN10200, "Matsushita MN10200"}, - {EM_PJ, "picoJava"}, - {EM_OPENRISC, "OpenRISC 32-bit embedded processor"}, - {EM_ARC_A5, "ARC Cores Tangent-A5"}, - {EM_XTENSA, "Tensilica Xtensa Architecture"}, - {EM_VIDEOCORE, "Alphamosaic VideoCore processor"}, - {EM_TMM_GPP, "Thompson Multimedia General Purpose Processor"}, - {EM_NS32K, "National Semiconductor 32000 series"}, - {EM_TPC, "Tenor Network TPC processor"}, - {EM_SNP1K, "Trebia SNP 1000 processor"}, - {EM_ST200, "STMicroelectronics ST200 microcontroller"}, - {EM_IP2K, "Ubicom IP2022 micro controller"}, - {EM_MAX, "MAX Processor"}, - {EM_CR, "National Semiconductor CompactRISC"}, - {EM_F2MC16, "Fujitsu F2MC16"}, - {EM_MSP430, "TI msp430 micro controller"}, - {EM_BLACKFIN, "ADI Blackfin"}, - {EM_SE_C33, "S1C33 Family of Seiko Epson processors"}, - {EM_SEP, "Sharp embedded microprocessor"}, - {EM_ARCA, "Arca RISC Microprocessor"}, - {EM_UNICORE, "Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University"}, - {EM_EXCESS, "eXcess: 16/32/64-bit configurable embedded CPU"}, - {EM_DXP, "Icera Semiconductor Inc. Deep Execution Processor"}, - {EM_ALTERA_NIOS2, "Altera Nios II soft-core processor"}, - {EM_CRX, "National Semiconductor CRX"}, - {EM_XGATE, "Motorola XGATE embedded processor"}, - {EM_C166, "Infineon C16x/XC16x processor"}, - {EM_M16C, "Renesas M16C series microprocessors"}, - {EM_DSPIC30F, "Microchip Technology dsPIC30F Digital Signal Controller"}, - {EM_CE, "Freescale Communication Engine RISC core"}, - {EM_M32C, "Renesas M32C series microprocessors"}, - {EM_res121, "Reserved"}, - {EM_res122, "Reserved"}, - {EM_res123, "Reserved"}, - {EM_res124, "Reserved"}, - {EM_res125, "Reserved"}, - {EM_res126, "Reserved"}, - {EM_res127, "Reserved"}, - {EM_res128, "Reserved"}, - {EM_res129, "Reserved"}, - {EM_res130, "Reserved"}, - {EM_TSK3000, "Altium TSK3000 core"}, - {EM_RS08, "Freescale RS08 embedded processor"}, - {EM_res133, "Reserved"}, - {EM_ECOG2, "Cyan Technology eCOG2 microprocessor"}, - {EM_SCORE, "Sunplus Score"}, - {EM_SCORE7, "Sunplus S+core7 RISC processor"}, - {EM_DSP24, "New Japan Radio (NJR) 24-bit DSP Processor"}, - {EM_VIDEOCORE3, "Broadcom VideoCore III processor"}, - {EM_LATTICEMICO32, "RISC processor for Lattice FPGA architecture"}, - {EM_SE_C17, "Seiko Epson C17 family"}, - {EM_TI_C6000, "Texas Instruments TMS320C6000 DSP family"}, - {EM_TI_C2000, "Texas Instruments TMS320C2000 DSP family"}, - {EM_TI_C5500, "Texas Instruments TMS320C55x DSP family"}, - {EM_res143, "Reserved"}, - {EM_res144, "Reserved"}, - {EM_res145, "Reserved"}, - {EM_res146, "Reserved"}, - {EM_res147, "Reserved"}, - {EM_res148, "Reserved"}, - {EM_res149, "Reserved"}, - {EM_res150, "Reserved"}, - {EM_res151, "Reserved"}, - {EM_res152, "Reserved"}, - {EM_res153, "Reserved"}, - {EM_res154, "Reserved"}, - {EM_res155, "Reserved"}, - {EM_res156, "Reserved"}, - {EM_res157, "Reserved"}, - {EM_res158, "Reserved"}, - {EM_res159, "Reserved"}, - {EM_MMDSP_PLUS, "STMicroelectronics 64bit VLIW Data Signal Processor"}, - {EM_CYPRESS_M8C, "Cypress M8C microprocessor"}, - {EM_R32C, "Renesas R32C series microprocessors"}, - {EM_TRIMEDIA, "NXP Semiconductors TriMedia architecture family"}, - {EM_QDSP6, "QUALCOMM DSP6 Processor"}, - {EM_8051, "Intel 8051 and variants"}, - {EM_STXP7X, "STMicroelectronics STxP7x family"}, - {EM_NDS32, "Andes Technology compact code size embedded RISC processor family"}, - {EM_ECOG1, "Cyan Technology eCOG1X family"}, - {EM_ECOG1X, "Cyan Technology eCOG1X family"}, - {EM_MAXQ30, "Dallas Semiconductor MAXQ30 Core Micro-controllers"}, - {EM_XIMO16, "New Japan Radio (NJR) 16-bit DSP Processor"}, - {EM_MANIK, "M2000 Reconfigurable RISC Microprocessor"}, - {EM_CRAYNV2, "Cray Inc. NV2 vector architecture"}, - {EM_RX, "Renesas RX family"}, - {EM_METAG, "Imagination Technologies META processor architecture"}, - {EM_MCST_ELBRUS, "MCST Elbrus general purpose hardware architecture"}, - {EM_ECOG16, "Cyan Technology eCOG16 family"}, - {EM_CR16, "National Semiconductor CompactRISC 16-bit processor"}, - {EM_ETPU, "Freescale Extended Time Processing Unit"}, - {EM_SLE9X, "Infineon Technologies SLE9X core"}, - {EM_L1OM, "Intel L1OM"}, - {EM_INTEL181, "Reserved by Intel"}, - {EM_INTEL182, "Reserved by Intel"}, - {EM_res183, "Reserved by ARM"}, - {EM_res184, "Reserved by ARM"}, - {EM_AVR32, "Atmel Corporation 32-bit microprocessor family"}, - {EM_STM8, "STMicroeletronics STM8 8-bit microcontroller"}, - {EM_TILE64, "Tilera TILE64 multicore architecture family"}, - {EM_TILEPRO, "Tilera TILEPro multicore architecture family"}, - {EM_MICROBLAZE, "Xilinx MicroBlaze 32-bit RISC soft processor core"}, - {EM_CUDA, "NVIDIA CUDA architecture "}, -}; - - -static struct section_type_table_t { - const Elf64_Half key; - const char* str; -} section_type_table[] = { - {SHT_NULL, "NULL"}, - {SHT_PROGBITS, "PROGBITS"}, - {SHT_SYMTAB, "SYMTAB"}, - {SHT_STRTAB, "STRTAB"}, - {SHT_RELA, "RELA"}, - {SHT_HASH, "HASH"}, - {SHT_DYNAMIC, "DYNAMIC"}, - {SHT_NOTE, "NOTE"}, - {SHT_NOBITS, "NOBITS"}, - {SHT_REL, "REL"}, - {SHT_SHLIB, "SHLIB"}, - {SHT_DYNSYM, "DYNSYM"}, - {SHT_INIT_ARRAY, "INIT_ARRAY"}, - {SHT_FINI_ARRAY, "FINI_ARRAY"}, - {SHT_PREINIT_ARRAY, "PREINIT_ARRAY"}, - {SHT_GROUP, "GROUP"}, - {SHT_SYMTAB_SHNDX, "SYMTAB_SHNDX "}, -}; - - -static struct segment_type_table_t { - const Elf_Word key; - const char* str; -} segment_type_table[] = { - {PT_NULL, "NULL"}, {PT_LOAD, "LOAD"}, {PT_DYNAMIC, "DYNAMIC"}, {PT_INTERP, "INTERP"}, - {PT_NOTE, "NOTE"}, {PT_SHLIB, "SHLIB"}, {PT_PHDR, "PHDR"}, {PT_TLS, "TLS"}, -}; - - -static struct segment_flag_table_t { - const Elf_Word key; - const char* str; -} segment_flag_table[] = { - {0, ""}, {1, "X"}, {2, "W"}, {3, "WX"}, {4, "R"}, {5, "RX"}, {6, "RW"}, {7, "RWX"}, -}; - - -static struct symbol_bind_t { - const Elf_Word key; - const char* str; -} symbol_bind_table[] = { - {STB_LOCAL, "LOCAL"}, {STB_GLOBAL, "GLOBAL"}, {STB_WEAK, "WEAK"}, - {STB_LOOS, "LOOS"}, {STB_HIOS, "HIOS"}, {STB_MULTIDEF, "MULTIDEF"}, - {STB_LOPROC, "LOPROC"}, {STB_HIPROC, "HIPROC"}, -}; - - -static struct symbol_type_t { - const Elf_Word key; - const char* str; -} symbol_type_table[] = { - {STT_NOTYPE, "NOTYPE"}, {STT_OBJECT, "OBJECT"}, {STT_FUNC, "FUNC"}, - {STT_SECTION, "SECTION"}, {STT_FILE, "FILE"}, {STT_COMMON, "COMMON"}, - {STT_TLS, "TLS"}, {STT_LOOS, "LOOS"}, {STT_HIOS, "HIOS"}, - {STT_LOPROC, "LOPROC"}, {STT_HIPROC, "HIPROC"}, -}; - - -static struct dynamic_tag_t { - const Elf_Word key; - const char* str; -} dynamic_tag_table[] = { - {DT_NULL, "NULL"}, - {DT_NEEDED, "NEEDED"}, - {DT_PLTRELSZ, "PLTRELSZ"}, - {DT_PLTGOT, "PLTGOT"}, - {DT_HASH, "HASH"}, - {DT_STRTAB, "STRTAB"}, - {DT_SYMTAB, "SYMTAB"}, - {DT_RELA, "RELA"}, - {DT_RELASZ, "RELASZ"}, - {DT_RELAENT, "RELAENT"}, - {DT_STRSZ, "STRSZ"}, - {DT_SYMENT, "SYMENT"}, - {DT_INIT, "INIT"}, - {DT_FINI, "FINI"}, - {DT_SONAME, "SONAME"}, - {DT_RPATH, "RPATH"}, - {DT_SYMBOLIC, "SYMBOLIC"}, - {DT_REL, "REL"}, - {DT_RELSZ, "RELSZ"}, - {DT_RELENT, "RELENT"}, - {DT_PLTREL, "PLTREL"}, - {DT_DEBUG, "DEBUG"}, - {DT_TEXTREL, "TEXTREL"}, - {DT_JMPREL, "JMPREL"}, - {DT_BIND_NOW, "BIND_NOW"}, - {DT_INIT_ARRAY, "INIT_ARRAY"}, - {DT_FINI_ARRAY, "FINI_ARRAY"}, - {DT_INIT_ARRAYSZ, "INIT_ARRAYSZ"}, - {DT_FINI_ARRAYSZ, "FINI_ARRAYSZ"}, - {DT_RUNPATH, "RUNPATH"}, - {DT_FLAGS, "FLAGS"}, - {DT_ENCODING, "ENCODING"}, - {DT_PREINIT_ARRAY, "PREINIT_ARRAY"}, - {DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ"}, - {DT_MAXPOSTAGS, "MAXPOSTAGS"}, -}; - -static const ELFIO::Elf_Xword MAX_DATA_ENTRIES = 64; - -//------------------------------------------------------------------------------ -class dump { -#define DUMP_DEC_FORMAT(width) std::setw(width) << std::setfill(' ') << std::dec << std::right -#define DUMP_HEX_FORMAT(width) std::setw(width) << std::setfill('0') << std::hex << std::right -#define DUMP_STR_FORMAT(width) std::setw(width) << std::setfill(' ') << std::hex << std::left - - public: - //------------------------------------------------------------------------------ - static void header(std::ostream& out, const elfio& reader) { - out << "ELF Header" << std::endl - << std::endl - << " Class: " << str_class(reader.get_class()) << std::endl - << " Encoding: " << str_endian(reader.get_encoding()) << std::endl - << " ELFVersion: " << str_version(reader.get_elf_version()) << std::endl - << " Type: " << str_type(reader.get_type()) << std::endl - << " Machine: " << str_machine(reader.get_machine()) << std::endl - << " Version: " << str_version(reader.get_version()) << std::endl - << " Entry: " - << "0x" << std::hex << reader.get_entry() << std::endl - << " Flags: " - << "0x" << std::hex << reader.get_flags() << std::endl - << std::endl; - } - - //------------------------------------------------------------------------------ - static void section_headers(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.sections.size(); - - if (n == 0) { - return; - } - - out << "Section Headers:" << std::endl; - if (reader.get_class() == ELFCLASS32) { // Output for 32-bit - out << "[ Nr ] Type Addr Size ES Flg Lk Inf Al Name" << std::endl; - } else { // Output for 64-bit - out << "[ Nr ] Type Addr Size ES Flg" - << std::endl - << " Lk Inf Al Name" << std::endl; - } - - for (Elf_Half i = 0; i < n; ++i) { // For all sections - section* sec = reader.sections[i]; - section_header(out, i, sec, reader.get_class()); - } - - out << "Key to Flags: W (write), A (alloc), X (execute)\n\n" << std::endl; - } - - //------------------------------------------------------------------------------ - static void section_header(std::ostream& out, Elf_Half no, const section* sec, - unsigned char elf_class) { - std::ios_base::fmtflags original_flags = out.flags(); - - if (elf_class == ELFCLASS32) { // Output for 32-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_STR_FORMAT(17) - << str_section_type(sec->get_type()) << " " << DUMP_HEX_FORMAT(8) - << sec->get_address() << " " << DUMP_HEX_FORMAT(8) << sec->get_size() << " " - << DUMP_HEX_FORMAT(2) << sec->get_entry_size() << " " << DUMP_STR_FORMAT(3) - << section_flags(sec->get_flags()) << " " << DUMP_HEX_FORMAT(2) << sec->get_link() - << " " << DUMP_HEX_FORMAT(3) << sec->get_info() << " " << DUMP_HEX_FORMAT(2) - << sec->get_addr_align() << " " << DUMP_STR_FORMAT(17) << sec->get_name() << " " - << std::endl; - } else { // Output for 64-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_STR_FORMAT(17) - << str_section_type(sec->get_type()) << " " << DUMP_HEX_FORMAT(16) - << sec->get_address() << " " << DUMP_HEX_FORMAT(16) << sec->get_size() << " " - << DUMP_HEX_FORMAT(4) << sec->get_entry_size() << " " << DUMP_STR_FORMAT(3) - << section_flags(sec->get_flags()) << " " << std::endl - << " " << DUMP_HEX_FORMAT(4) << sec->get_link() << " " << DUMP_HEX_FORMAT(4) - << sec->get_info() << " " << DUMP_HEX_FORMAT(4) << sec->get_addr_align() << " " - << DUMP_STR_FORMAT(17) << sec->get_name() << " " << std::endl; - } - - out.flags(original_flags); - - return; - } - - //------------------------------------------------------------------------------ - static void segment_headers(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.segments.size(); - if (n == 0) { - return; - } - - out << "Segment headers:" << std::endl; - if (reader.get_class() == ELFCLASS32) { // Output for 32-bit - out << "[ Nr ] Type VirtAddr PhysAddr FileSize Mem.Size Flags Align" - << std::endl; - } else { // Output for 64-bit - out << "[ Nr ] Type VirtAddr PhysAddr Flags" << std::endl - << " FileSize Mem.Size Align" << std::endl; - } - - for (Elf_Half i = 0; i < n; ++i) { - segment* seg = reader.segments[i]; - segment_header(out, i, seg, reader.get_class()); - } - - out << std::endl; - } - - //------------------------------------------------------------------------------ - static void segment_header(std::ostream& out, Elf_Half no, const segment* seg, - unsigned int elf_class) { - std::ios_base::fmtflags original_flags = out.flags(); - - if (elf_class == ELFCLASS32) { // Output for 32-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_STR_FORMAT(14) - << str_segment_type(seg->get_type()) << " " << DUMP_HEX_FORMAT(8) - << seg->get_virtual_address() << " " << DUMP_HEX_FORMAT(8) - << seg->get_physical_address() << " " << DUMP_HEX_FORMAT(8) << seg->get_file_size() - << " " << DUMP_HEX_FORMAT(8) << seg->get_memory_size() << " " << DUMP_STR_FORMAT(8) - << str_segment_flag(seg->get_flags()) << " " << DUMP_HEX_FORMAT(8) - << seg->get_align() << " " << std::endl; - } else { // Output for 64-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_STR_FORMAT(14) - << str_segment_type(seg->get_type()) << " " << DUMP_HEX_FORMAT(16) - << seg->get_virtual_address() << " " << DUMP_HEX_FORMAT(16) - << seg->get_physical_address() << " " << DUMP_STR_FORMAT(16) - << str_segment_flag(seg->get_flags()) << " " << std::endl - << " " << DUMP_HEX_FORMAT(16) << seg->get_file_size() << " " - << DUMP_HEX_FORMAT(16) << seg->get_memory_size() << " " << DUMP_HEX_FORMAT(16) - << seg->get_align() << " " << std::endl; - } - - out.flags(original_flags); - } - - //------------------------------------------------------------------------------ - static void symbol_tables(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.sections.size(); - for (Elf_Half i = 0; i < n; ++i) { // For all sections - section* sec = reader.sections[i]; - if (SHT_SYMTAB == sec->get_type() || SHT_DYNSYM == sec->get_type()) { - symbol_section_accessor symbols(reader, sec); - - Elf_Xword sym_no = symbols.get_symbols_num(); - if (sym_no > 0) { - out << "Symbol table (" << sec->get_name() << ")" << std::endl; - if (reader.get_class() == ELFCLASS32) { // Output for 32-bit - out << "[ Nr ] Value Size Type Bind Sect Name" << std::endl; - } else { // Output for 64-bit - out << "[ Nr ] Value Size Type Bind Sect" - << std::endl - << " Name" << std::endl; - } - for (Elf_Half i = 0; i < sym_no; ++i) { - std::string name; - Elf64_Addr value = 0; - Elf_Xword size = 0; - unsigned char bind = 0; - unsigned char type = 0; - Elf_Half section = 0; - unsigned char other = 0; - symbols.get_symbol(i, name, value, size, bind, type, section, other); - symbol_table(out, i, name, value, size, bind, type, section, - reader.get_class()); - } - - out << std::endl; - } - } - } - } - - //------------------------------------------------------------------------------ - static void symbol_table(std::ostream& out, Elf_Half no, std::string& name, Elf64_Addr value, - Elf_Xword size, unsigned char bind, unsigned char type, - Elf_Half section, unsigned int elf_class) { - std::ios_base::fmtflags original_flags = out.flags(); - - if (elf_class == ELFCLASS32) { // Output for 32-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_HEX_FORMAT(8) << value << " " - << DUMP_HEX_FORMAT(8) << size << " " << DUMP_STR_FORMAT(7) << str_symbol_type(type) - << " " << DUMP_STR_FORMAT(8) << str_symbol_bind(bind) << " " << DUMP_DEC_FORMAT(5) - << section << " " << DUMP_STR_FORMAT(1) << name << " " << std::endl; - } else { // Output for 64-bit - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_HEX_FORMAT(16) << value << " " - << DUMP_HEX_FORMAT(16) << size << " " << DUMP_STR_FORMAT(7) << str_symbol_type(type) - << " " << DUMP_STR_FORMAT(8) << str_symbol_bind(bind) << " " << DUMP_DEC_FORMAT(5) - << section << " " << std::endl - << " " << DUMP_STR_FORMAT(1) << name << " " << std::endl; - } - - out.flags(original_flags); - } - - //------------------------------------------------------------------------------ - static void notes(std::ostream& out, const elfio& reader) { - Elf_Half no = reader.sections.size(); - for (Elf_Half i = 0; i < no; ++i) { // For all sections - section* sec = reader.sections[i]; - if (SHT_NOTE == sec->get_type()) { // Look at notes - note_section_accessor notes(reader, sec); - int no_notes = notes.get_notes_num(); - if (no > 0) { - out << "Note section (" << sec->get_name() << ")" << std::endl - << " No Type Name" << std::endl; - for (int j = 0; j < no_notes; ++j) { // For all notes - Elf_Word type; - std::string name; - void* desc; - Elf_Word descsz; - - if (notes.get_note(j, type, name, desc, descsz)) { - // 'name' usually contains \0 at the end. Try to fix it - name = name.c_str(); - note(out, j, type, name); - } - } - - out << std::endl; - } - } - } - } - - //------------------------------------------------------------------------------ - static void note(std::ostream& out, int no, Elf_Word type, const std::string& name) { - out << " [" << DUMP_DEC_FORMAT(2) << no << "] " << DUMP_HEX_FORMAT(8) << type << " " - << DUMP_STR_FORMAT(1) << name << std::endl; - } - - //------------------------------------------------------------------------------ - static void dynamic_tags(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.sections.size(); - for (Elf_Half i = 0; i < n; ++i) { // For all sections - section* sec = reader.sections[i]; - if (SHT_DYNAMIC == sec->get_type()) { - dynamic_section_accessor dynamic(reader, sec); - - Elf_Xword dyn_no = dynamic.get_entries_num(); - if (dyn_no > 0) { - out << "Dynamic section (" << sec->get_name() << ")" << std::endl; - out << "[ Nr ] Tag Name/Value" << std::endl; - for (int i = 0; i < dyn_no; ++i) { - Elf_Xword tag = 0; - Elf_Xword value = 0; - std::string str; - dynamic.get_entry(i, tag, value, str); - dynamic_tag(out, i, tag, value, str, reader.get_class()); - if (DT_NULL == tag) { - break; - } - } - - out << std::endl; - } - } - } - } - - //------------------------------------------------------------------------------ - static void dynamic_tag(std::ostream& out, int no, Elf_Xword tag, Elf_Xword value, - std::string str, unsigned int /*elf_class*/) { - out << "[" << DUMP_DEC_FORMAT(5) << no << "] " << DUMP_STR_FORMAT(16) - << str_dynamic_tag(tag) << " "; - if (str.empty()) { - out << DUMP_HEX_FORMAT(16) << value << " "; - } else { - out << DUMP_STR_FORMAT(32) << str << " "; - } - out << std::endl; - } - - //------------------------------------------------------------------------------ - static void section_data(std::ostream& out, const section* sec) { - std::ios_base::fmtflags original_flags = out.flags(); - - out << sec->get_name() << std::endl; - const char* pdata = sec->get_data(); - if (pdata) { - ELFIO::Elf_Xword i; - for (i = 0; i < std::min(sec->get_size(), MAX_DATA_ENTRIES); ++i) { - if (i % 16 == 0) { - out << "[" << DUMP_HEX_FORMAT(8) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT(2) << (pdata[i] & 0x000000FF); - - if (i % 16 == 15) { - out << std::endl; - } - } - if (i % 16 != 0) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - - //------------------------------------------------------------------------------ - static void section_datas(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.sections.size(); - - if (n == 0) { - return; - } - - out << "Section Data:" << std::endl; - - for (Elf_Half i = 1; i < n; ++i) { // For all sections - section* sec = reader.sections[i]; - if (sec->get_type() == SHT_NOBITS) { - continue; - } - section_data(out, sec); - } - - out << std::endl; - } - - //------------------------------------------------------------------------------ - static void segment_data(std::ostream& out, Elf_Half no, const segment* seg) { - std::ios_base::fmtflags original_flags = out.flags(); - - out << "Segment # " << no << std::endl; - const char* pdata = seg->get_data(); - if (pdata) { - ELFIO::Elf_Xword i; - for (i = 0; i < std::min(seg->get_file_size(), MAX_DATA_ENTRIES); ++i) { - if (i % 16 == 0) { - out << "[" << DUMP_HEX_FORMAT(8) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT(2) << (pdata[i] & 0x000000FF); - - if (i % 16 == 15) { - out << std::endl; - } - } - if (i % 16 != 0) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - - //------------------------------------------------------------------------------ - static void segment_datas(std::ostream& out, const elfio& reader) { - Elf_Half n = reader.segments.size(); - - if (n == 0) { - return; - } - - out << "Segment Data:" << std::endl; - - for (Elf_Half i = 0; i < n; ++i) { // For all sections - segment* seg = reader.segments[i]; - segment_data(out, i, seg); - } - - out << std::endl; - } - - private: - //------------------------------------------------------------------------------ - template - std::string static find_value_in_table(const T& table, const K& key) { - std::string res = "?"; - for (unsigned int i = 0; i < sizeof(table) / sizeof(table[0]); ++i) { - if (table[i].key == key) { - res = table[i].str; - break; - } - } - - return res; - } - - - //------------------------------------------------------------------------------ - template - static std::string format_assoc(const T& table, const K& key) { - std::string str = find_value_in_table(table, key); - if (str == "?") { - std::ostringstream oss; - oss << str << " (0x" << std::hex << key << ")"; - str = oss.str(); - } - - return str; - } - - - //------------------------------------------------------------------------------ - template - static std::string format_assoc(const T& table, const char key) { - return format_assoc(table, (const int)key); - } - - - //------------------------------------------------------------------------------ - static std::string section_flags(Elf_Xword flags) { - std::string ret = ""; - if (flags & SHF_WRITE) { - ret += "W"; - } - if (flags & SHF_ALLOC) { - ret += "A"; - } - if (flags & SHF_EXECINSTR) { - ret += "X"; - } - - return ret; - } - - -//------------------------------------------------------------------------------ -#define STR_FUNC_TABLE(name) \ - template \ - static std::string str_##name(const T key) { \ - return format_assoc(name##_table, key); \ - } - - STR_FUNC_TABLE(class) - STR_FUNC_TABLE(endian) - STR_FUNC_TABLE(version) - STR_FUNC_TABLE(type) - STR_FUNC_TABLE(machine) - STR_FUNC_TABLE(section_type) - STR_FUNC_TABLE(segment_type) - STR_FUNC_TABLE(segment_flag) - STR_FUNC_TABLE(symbol_bind) - STR_FUNC_TABLE(symbol_type) - STR_FUNC_TABLE(dynamic_tag) - -#undef STR_FUNC_TABLE -#undef DUMP_DEC_FORMAT -#undef DUMP_HEX_FORMAT -#undef DUMP_STR_FORMAT -}; // class dump - - -}; // namespace ELFIO - -#endif // ELFIO_DUMP_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_dynamic.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_dynamic.hpp deleted file mode 100644 index 53a6e28991..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_dynamic.hpp +++ /dev/null @@ -1,217 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_DYNAMIC_HPP -#define ELFIO_DYNAMIC_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class dynamic_section_accessor { - public: - //------------------------------------------------------------------------------ - dynamic_section_accessor(const elfio& elf_file_, section* section_) - : elf_file(elf_file_), dynamic_section(section_) {} - - //------------------------------------------------------------------------------ - Elf_Xword get_entries_num() const { - Elf_Xword nRet = 0; - - if (0 != dynamic_section->get_entry_size()) { - nRet = dynamic_section->get_size() / dynamic_section->get_entry_size(); - } - - return nRet; - } - - //------------------------------------------------------------------------------ - bool get_entry(Elf_Xword index, Elf_Xword& tag, Elf_Xword& value, std::string& str) const { - if (index >= get_entries_num()) { // Is index valid - return false; - } - - if (elf_file.get_class() == ELFCLASS32) { - generic_get_entry_dyn(index, tag, value); - } else { - generic_get_entry_dyn(index, tag, value); - } - - // If the tag may have a string table reference, prepare the string - if (tag == DT_NEEDED || tag == DT_SONAME || tag == DT_RPATH || tag == DT_RUNPATH) { - string_section_accessor strsec = elf_file.sections[get_string_table_index()]; - const char* result = strsec.get_string(value); - if (0 == result) { - str.clear(); - return false; - } - str = result; - } else { - str.clear(); - } - - return true; - } - - //------------------------------------------------------------------------------ - void add_entry(Elf_Xword& tag, Elf_Xword& value) { - if (elf_file.get_class() == ELFCLASS32) { - generic_add_entry(tag, value); - } else { - generic_add_entry(tag, value); - } - } - - //------------------------------------------------------------------------------ - void add_entry(Elf_Xword& tag, std::string& str) { - string_section_accessor strsec = elf_file.sections[get_string_table_index()]; - Elf_Xword value = strsec.add_string(str); - add_entry(tag, value); - } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - Elf_Half get_string_table_index() const { return (Elf_Half)dynamic_section->get_link(); } - - //------------------------------------------------------------------------------ - template - void generic_get_entry_dyn(Elf_Xword index, Elf_Xword& tag, Elf_Xword& value) const { - const endianess_convertor& convertor = elf_file.get_convertor(); - - // Check unusual case when dynamic section has no data - if (dynamic_section->get_data() == 0 || - (index + 1) * dynamic_section->get_entry_size() > dynamic_section->get_size()) { - tag = DT_NULL; - value = 0; - return; - } - - const T* pEntry = reinterpret_cast(dynamic_section->get_data() + - index * dynamic_section->get_entry_size()); - tag = convertor(pEntry->d_tag); - switch (tag) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - break; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - value = convertor(pEntry->d_un.d_val); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - value = convertor(pEntry->d_un.d_ptr); - break; - } - } - - //------------------------------------------------------------------------------ - template - void generic_add_entry(Elf_Xword tag, Elf_Xword value) { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - - switch (tag) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - entry.d_un.d_val = convertor(value); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - entry.d_un.d_ptr = convertor(value); - break; - } - - entry.d_tag = convertor(tag); - - dynamic_section->append_data(reinterpret_cast(&entry), sizeof(entry)); - } - - //------------------------------------------------------------------------------ - private: - const elfio& elf_file; - section* dynamic_section; -}; - -} // namespace ELFIO - -#endif // ELFIO_DYNAMIC_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_header.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_header.hpp deleted file mode 100644 index b95f0a9fa3..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_header.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELF_HEADER_HPP -#define ELF_HEADER_HPP - -#include - -namespace ELFIO { - -class elf_header { - public: - virtual ~elf_header(){}; - virtual bool load(std::istream& stream) = 0; - virtual bool save(std::ostream& stream) const = 0; - - // ELF header functions - ELFIO_GET_ACCESS_DECL(unsigned char, class); - ELFIO_GET_ACCESS_DECL(unsigned char, elf_version); - ELFIO_GET_ACCESS_DECL(unsigned char, encoding); - ELFIO_GET_ACCESS_DECL(Elf_Word, version); - ELFIO_GET_ACCESS_DECL(Elf_Half, header_size); - ELFIO_GET_ACCESS_DECL(Elf_Half, section_entry_size); - ELFIO_GET_ACCESS_DECL(Elf_Half, segment_entry_size); - - ELFIO_GET_SET_ACCESS_DECL(unsigned char, os_abi); - ELFIO_GET_SET_ACCESS_DECL(unsigned char, abi_version); - ELFIO_GET_SET_ACCESS_DECL(Elf_Half, type); - ELFIO_GET_SET_ACCESS_DECL(Elf_Half, machine); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, flags); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Addr, entry); - ELFIO_GET_SET_ACCESS_DECL(Elf_Half, sections_num); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Off, sections_offset); - ELFIO_GET_SET_ACCESS_DECL(Elf_Half, segments_num); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Off, segments_offset); - ELFIO_GET_SET_ACCESS_DECL(Elf_Half, section_name_str_index); -}; - - -template -struct elf_header_impl_types; -template <> -struct elf_header_impl_types { - typedef Elf32_Phdr Phdr_type; - typedef Elf32_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS32; -}; -template <> -struct elf_header_impl_types { - typedef Elf64_Phdr Phdr_type; - typedef Elf64_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS64; -}; - -template -class elf_header_impl : public elf_header { - public: - elf_header_impl(endianess_convertor* convertor_, unsigned char encoding) { - convertor = convertor_; - - std::fill_n(reinterpret_cast(&header), sizeof(header), '\0'); - - header.e_ident[EI_MAG0] = ELFMAG0; - header.e_ident[EI_MAG1] = ELFMAG1; - header.e_ident[EI_MAG2] = ELFMAG2; - header.e_ident[EI_MAG3] = ELFMAG3; - header.e_ident[EI_CLASS] = elf_header_impl_types::file_class; - header.e_ident[EI_DATA] = encoding; - header.e_ident[EI_VERSION] = EV_CURRENT; - header.e_version = EV_CURRENT; - header.e_version = (*convertor)(header.e_version); - header.e_ehsize = (sizeof(header)); - header.e_ehsize = (*convertor)(header.e_ehsize); - header.e_shstrndx = (*convertor)((Elf_Half)1); - header.e_phentsize = sizeof(typename elf_header_impl_types::Phdr_type); - header.e_shentsize = sizeof(typename elf_header_impl_types::Shdr_type); - header.e_phentsize = (*convertor)(header.e_phentsize); - header.e_shentsize = (*convertor)(header.e_shentsize); - } - - bool load(std::istream& stream) { - stream.seekg(0); - stream.read(reinterpret_cast(&header), sizeof(header)); - - return (stream.gcount() == sizeof(header)); - } - - bool save(std::ostream& stream) const { - stream.seekp(0); - stream.write(reinterpret_cast(&header), sizeof(header)); - - return stream.good(); - } - - // ELF header functions - ELFIO_GET_ACCESS(unsigned char, class, header.e_ident[EI_CLASS]); - ELFIO_GET_ACCESS(unsigned char, elf_version, header.e_ident[EI_VERSION]); - ELFIO_GET_ACCESS(unsigned char, encoding, header.e_ident[EI_DATA]); - ELFIO_GET_ACCESS(Elf_Word, version, header.e_version); - ELFIO_GET_ACCESS(Elf_Half, header_size, header.e_ehsize); - ELFIO_GET_ACCESS(Elf_Half, section_entry_size, header.e_shentsize); - ELFIO_GET_ACCESS(Elf_Half, segment_entry_size, header.e_phentsize); - - ELFIO_GET_SET_ACCESS(unsigned char, os_abi, header.e_ident[EI_OSABI]); - ELFIO_GET_SET_ACCESS(unsigned char, abi_version, header.e_ident[EI_ABIVERSION]); - ELFIO_GET_SET_ACCESS(Elf_Half, type, header.e_type); - ELFIO_GET_SET_ACCESS(Elf_Half, machine, header.e_machine); - ELFIO_GET_SET_ACCESS(Elf_Word, flags, header.e_flags); - ELFIO_GET_SET_ACCESS(Elf_Half, section_name_str_index, header.e_shstrndx); - ELFIO_GET_SET_ACCESS(Elf64_Addr, entry, header.e_entry); - ELFIO_GET_SET_ACCESS(Elf_Half, sections_num, header.e_shnum); - ELFIO_GET_SET_ACCESS(Elf64_Off, sections_offset, header.e_shoff); - ELFIO_GET_SET_ACCESS(Elf_Half, segments_num, header.e_phnum); - ELFIO_GET_SET_ACCESS(Elf64_Off, segments_offset, header.e_phoff); - - private: - T header; - endianess_convertor* convertor; -}; - -} // namespace ELFIO - -#endif // ELF_HEADER_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_note.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_note.hpp deleted file mode 100644 index e350c853dd..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_note.hpp +++ /dev/null @@ -1,144 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_NOTE_HPP -#define ELFIO_NOTE_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -// There are discrepancies in documentations. SCO documentation -// (http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section) -// requires 8 byte entries alignment for 64-bit ELF file, -// but Oracle's definition uses the same structure -// for 32-bit and 64-bit formats. -// (https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html) -// -// It looks like EM_X86_64 Linux implementation is similar to Oracle's -// definition. Therefore, the same alignment works for both formats -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -class note_section_accessor { - public: - //------------------------------------------------------------------------------ - note_section_accessor(const elfio& elf_file_, section* section_) - : elf_file(elf_file_), note_section(section_) { - process_section(); - } - - //------------------------------------------------------------------------------ - Elf_Word get_notes_num() const { return (Elf_Word)note_start_positions.size(); } - - //------------------------------------------------------------------------------ - bool get_note(Elf_Word index, Elf_Word& type, std::string& name, void*& desc, - Elf_Word& descSize) const { - if (index >= note_section->get_size()) { - return false; - } - - const char* pData = note_section->get_data() + note_start_positions[index]; - int align = sizeof(Elf_Word); - - const endianess_convertor& convertor = elf_file.get_convertor(); - type = convertor(*(Elf_Word*)(pData + 2 * align)); - Elf_Word namesz = convertor(*(Elf_Word*)(pData)); - descSize = convertor(*(Elf_Word*)(pData + sizeof(namesz))); - Elf_Word max_name_size = note_section->get_size() - note_start_positions[index]; - if (namesz > max_name_size || namesz + descSize > max_name_size) { - return false; - } - name.assign(pData + 3 * align, namesz - 1); - if (0 == descSize) { - desc = 0; - } else { - desc = const_cast(pData + 3 * align + ((namesz + align - 1) / align) * align); - } - - return true; - } - - //------------------------------------------------------------------------------ - void add_note(Elf_Word type, const std::string& name, const void* desc, Elf_Word descSize) { - const endianess_convertor& convertor = elf_file.get_convertor(); - - int align = sizeof(Elf_Word); - Elf_Word nameLen = (Elf_Word)name.size() + 1; - Elf_Word nameLenConv = convertor(nameLen); - std::string buffer(reinterpret_cast(&nameLenConv), align); - Elf_Word descSizeConv = convertor(descSize); - buffer.append(reinterpret_cast(&descSizeConv), align); - type = convertor(type); - buffer.append(reinterpret_cast(&type), align); - buffer.append(name); - buffer.append(1, '\x00'); - const char pad[] = {'\0', '\0', '\0', '\0'}; - if (nameLen % align != 0) { - buffer.append(pad, align - nameLen % align); - } - if (desc != 0 && descSize != 0) { - buffer.append(reinterpret_cast(desc), descSize); - if (descSize % align != 0) { - buffer.append(pad, align - descSize % align); - } - } - - note_start_positions.push_back(note_section->get_size()); - note_section->append_data(buffer); - } - - private: - //------------------------------------------------------------------------------ - void process_section() { - const endianess_convertor& convertor = elf_file.get_convertor(); - const char* data = note_section->get_data(); - Elf_Xword size = note_section->get_size(); - Elf_Xword current = 0; - - note_start_positions.clear(); - - // Is it empty? - if (0 == data || 0 == size) { - return; - } - - int align = sizeof(Elf_Word); - while (current + 3 * align <= size) { - note_start_positions.push_back(current); - Elf_Word namesz = convertor(*(Elf_Word*)(data + current)); - Elf_Word descsz = convertor(*(Elf_Word*)(data + current + sizeof(namesz))); - - current += 3 * sizeof(Elf_Word) + ((namesz + align - 1) / align) * align + - ((descsz + align - 1) / align) * align; - } - } - - //------------------------------------------------------------------------------ - private: - const elfio& elf_file; - section* note_section; - std::vector note_start_positions; -}; - -} // namespace ELFIO - -#endif // ELFIO_NOTE_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_relocation.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_relocation.hpp deleted file mode 100644 index 270c911a11..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_relocation.hpp +++ /dev/null @@ -1,280 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_RELOCATION_HPP -#define ELFIO_RELOCATION_HPP - -namespace ELFIO { - -template -struct get_sym_and_type; -template <> -struct get_sym_and_type { - static int get_r_sym(Elf_Xword info) { return ELF32_R_SYM((Elf_Word)info); } - static int get_r_type(Elf_Xword info) { return ELF32_R_TYPE((Elf_Word)info); } -}; -template <> -struct get_sym_and_type { - static int get_r_sym(Elf_Xword info) { return ELF32_R_SYM((Elf_Word)info); } - static int get_r_type(Elf_Xword info) { return ELF32_R_TYPE((Elf_Word)info); } -}; -template <> -struct get_sym_and_type { - static int get_r_sym(Elf_Xword info) { return ELF64_R_SYM(info); } - static int get_r_type(Elf_Xword info) { return ELF64_R_TYPE(info); } -}; -template <> -struct get_sym_and_type { - static int get_r_sym(Elf_Xword info) { return ELF64_R_SYM(info); } - static int get_r_type(Elf_Xword info) { return ELF64_R_TYPE(info); } -}; - - -//------------------------------------------------------------------------------ -class relocation_section_accessor { - public: - //------------------------------------------------------------------------------ - relocation_section_accessor(const elfio& elf_file_, section* section_) - : elf_file(elf_file_), relocation_section(section_) {} - - //------------------------------------------------------------------------------ - Elf_Xword get_entries_num() const { - Elf_Xword nRet = 0; - - if (0 != relocation_section->get_entry_size()) { - nRet = relocation_section->get_size() / relocation_section->get_entry_size(); - } - - return nRet; - } - - //------------------------------------------------------------------------------ - bool get_entry(Elf_Xword index, Elf64_Addr& offset, Elf_Word& symbol, Elf_Word& type, - Elf_Sxword& addend) const { - if (index >= get_entries_num()) { // Is index valid - return false; - } - - if (elf_file.get_class() == ELFCLASS32) { - if (SHT_REL == relocation_section->get_type()) { - generic_get_entry_rel(index, offset, symbol, type, addend); - } else if (SHT_RELA == relocation_section->get_type()) { - generic_get_entry_rela(index, offset, symbol, type, addend); - } - } else { - if (SHT_REL == relocation_section->get_type()) { - generic_get_entry_rel(index, offset, symbol, type, addend); - } else if (SHT_RELA == relocation_section->get_type()) { - generic_get_entry_rela(index, offset, symbol, type, addend); - } - } - - return true; - } - - //------------------------------------------------------------------------------ - bool get_entry(Elf_Xword index, Elf64_Addr& offset, Elf64_Addr& symbolValue, - std::string& symbolName, Elf_Word& type, Elf_Sxword& addend, - Elf_Sxword& calcValue) const { - // Do regular job - Elf_Word symbol; - bool ret = get_entry(index, offset, symbol, type, addend); - - // Find the symbol - Elf_Xword size; - unsigned char bind; - unsigned char symbolType; - Elf_Half section; - unsigned char other; - - symbol_section_accessor symbols(elf_file, elf_file.sections[get_symbol_table_index()]); - ret = ret && symbols.get_symbol(symbol, symbolName, symbolValue, size, bind, symbolType, - section, other); - - if (ret) { // Was it successful? - switch (type) { - case R_386_NONE: // none - calcValue = 0; - break; - case R_386_32: // S + A - calcValue = symbolValue + addend; - break; - case R_386_PC32: // S + A - P - calcValue = symbolValue + addend - offset; - break; - case R_386_GOT32: // G + A - P - calcValue = 0; - break; - case R_386_PLT32: // L + A - P - calcValue = 0; - break; - case R_386_COPY: // none - calcValue = 0; - break; - case R_386_GLOB_DAT: // S - case R_386_JMP_SLOT: // S - calcValue = symbolValue; - break; - case R_386_RELATIVE: // B + A - calcValue = addend; - break; - case R_386_GOTOFF: // S + A - GOT - calcValue = 0; - break; - case R_386_GOTPC: // GOT + A - P - calcValue = 0; - break; - default: // Not recognized symbol! - calcValue = 0; - break; - } - } - - return ret; - } - - //------------------------------------------------------------------------------ - void add_entry(Elf64_Addr offset, Elf_Xword info) { - if (elf_file.get_class() == ELFCLASS32) { - generic_add_entry(offset, info); - } else { - generic_add_entry(offset, info); - } - } - - //------------------------------------------------------------------------------ - void add_entry(Elf64_Addr offset, Elf_Word symbol, unsigned char type) { - Elf_Xword info; - if (elf_file.get_class() == ELFCLASS32) { - info = ELF32_R_INFO((Elf_Xword)symbol, type); - } else { - info = ELF64_R_INFO((Elf_Xword)symbol, type); - } - - add_entry(offset, info); - } - - //------------------------------------------------------------------------------ - void add_entry(Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend) { - if (elf_file.get_class() == ELFCLASS32) { - generic_add_entry(offset, info, addend); - } else { - generic_add_entry(offset, info, addend); - } - } - - //------------------------------------------------------------------------------ - void add_entry(Elf64_Addr offset, Elf_Word symbol, unsigned char type, Elf_Sxword addend) { - Elf_Xword info; - if (elf_file.get_class() == ELFCLASS32) { - info = ELF32_R_INFO((Elf_Xword)symbol, type); - } else { - info = ELF64_R_INFO((Elf_Xword)symbol, type); - } - - add_entry(offset, info, addend); - } - - //------------------------------------------------------------------------------ - void add_entry(string_section_accessor str_writer, const char* str, - symbol_section_accessor sym_writer, Elf64_Addr value, Elf_Word size, - unsigned char sym_info, unsigned char other, Elf_Half shndx, Elf64_Addr offset, - unsigned char type) { - Elf_Word str_index = str_writer.add_string(str); - Elf_Word sym_index = sym_writer.add_symbol(str_index, value, size, sym_info, other, shndx); - add_entry(offset, sym_index, type); - } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - Elf_Half get_symbol_table_index() const { return (Elf_Half)relocation_section->get_link(); } - - //------------------------------------------------------------------------------ - template - void generic_get_entry_rel(Elf_Xword index, Elf64_Addr& offset, Elf_Word& symbol, - Elf_Word& type, Elf_Sxword& addend) const { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast(relocation_section->get_data() + - index * relocation_section->get_entry_size()); - offset = convertor(pEntry->r_offset); - Elf_Xword tmp = convertor(pEntry->r_info); - symbol = get_sym_and_type::get_r_sym(tmp); - type = get_sym_and_type::get_r_type(tmp); - addend = 0; - } - - //------------------------------------------------------------------------------ - template - void generic_get_entry_rela(Elf_Xword index, Elf64_Addr& offset, Elf_Word& symbol, - Elf_Word& type, Elf_Sxword& addend) const { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast(relocation_section->get_data() + - index * relocation_section->get_entry_size()); - offset = convertor(pEntry->r_offset); - Elf_Xword tmp = convertor(pEntry->r_info); - symbol = get_sym_and_type::get_r_sym(tmp); - type = get_sym_and_type::get_r_type(tmp); - addend = convertor(pEntry->r_addend); - } - - //------------------------------------------------------------------------------ - template - void generic_add_entry(Elf64_Addr offset, Elf_Xword info) { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_offset = convertor(entry.r_offset); - entry.r_info = convertor(entry.r_info); - - relocation_section->append_data(reinterpret_cast(&entry), sizeof(entry)); - } - - //------------------------------------------------------------------------------ - template - void generic_add_entry(Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend) { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_addend = addend; - entry.r_offset = convertor(entry.r_offset); - entry.r_info = convertor(entry.r_info); - entry.r_addend = convertor(entry.r_addend); - - relocation_section->append_data(reinterpret_cast(&entry), sizeof(entry)); - } - - //------------------------------------------------------------------------------ - private: - const elfio& elf_file; - section* relocation_section; -}; - -} // namespace ELFIO - -#endif // ELFIO_RELOCATION_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_section.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_section.hpp deleted file mode 100644 index 6106fc7dd7..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_section.hpp +++ /dev/null @@ -1,240 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SECTION_HPP -#define ELFIO_SECTION_HPP - -#include -#include - -namespace ELFIO { - -class section { - friend class elfio; - - public: - virtual ~section(){}; - - ELFIO_GET_ACCESS_DECL(Elf_Half, index); - ELFIO_GET_SET_ACCESS_DECL(std::string, name); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, type); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, flags); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, info); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, link); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, addr_align); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, entry_size); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Addr, address); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, size); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, name_string_offset); - - virtual const char* get_data() const = 0; - virtual void set_data(const char* pData, Elf_Word size) = 0; - virtual void set_data(const std::string& data) = 0; - virtual void append_data(const char* pData, Elf_Word size) = 0; - virtual void append_data(const std::string& data) = 0; - - protected: - ELFIO_GET_SET_ACCESS_DECL(Elf64_Off, offset); - ELFIO_SET_ACCESS_DECL(Elf_Half, index); - - virtual void load(std::istream& f, std::streampos header_offset) = 0; - virtual void save(std::ostream& f, std::streampos header_offset, - std::streampos data_offset) = 0; - virtual bool is_address_initialized() const = 0; -}; - - -template -class section_impl : public section { - public: - //------------------------------------------------------------------------------ - section_impl(const endianess_convertor* convertor_) : convertor(convertor_) { - std::fill_n(reinterpret_cast(&header), sizeof(header), '\0'); - is_address_set = false; - data = 0; - data_size = 0; - } - - //------------------------------------------------------------------------------ - ~section_impl() { delete[] data; } - - //------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS(Elf_Word, type, header.sh_type); - ELFIO_GET_SET_ACCESS(Elf_Xword, flags, header.sh_flags); - ELFIO_GET_SET_ACCESS(Elf_Xword, size, header.sh_size); - ELFIO_GET_SET_ACCESS(Elf_Word, link, header.sh_link); - ELFIO_GET_SET_ACCESS(Elf_Word, info, header.sh_info); - ELFIO_GET_SET_ACCESS(Elf_Xword, addr_align, header.sh_addralign); - ELFIO_GET_SET_ACCESS(Elf_Xword, entry_size, header.sh_entsize); - ELFIO_GET_SET_ACCESS(Elf_Word, name_string_offset, header.sh_name); - ELFIO_GET_ACCESS(Elf64_Addr, address, header.sh_addr); - - //------------------------------------------------------------------------------ - Elf_Half get_index() const { return index; } - - - //------------------------------------------------------------------------------ - std::string get_name() const { return name; } - - //------------------------------------------------------------------------------ - void set_name(std::string name_) { name = name_; } - - //------------------------------------------------------------------------------ - void set_address(Elf64_Addr value) { - header.sh_addr = value; - header.sh_addr = (*convertor)(header.sh_addr); - is_address_set = true; - } - - //------------------------------------------------------------------------------ - bool is_address_initialized() const { return is_address_set; } - - //------------------------------------------------------------------------------ - const char* get_data() const { return data; } - - //------------------------------------------------------------------------------ - void set_data(const char* raw_data, Elf_Word size) { - if (get_type() != SHT_NOBITS) { - delete[] data; - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - size = 0; - } - if (0 != data && 0 != raw_data) { - data_size = size; - std::copy(raw_data, raw_data + size, data); - } - } - - set_size(size); - } - - //------------------------------------------------------------------------------ - void set_data(const std::string& str_data) { - return set_data(str_data.c_str(), (Elf_Word)str_data.size()); - } - - //------------------------------------------------------------------------------ - void append_data(const char* raw_data, Elf_Word size) { - if (get_type() != SHT_NOBITS) { - if (get_size() + size < data_size) { - std::copy(raw_data, raw_data + size, data + get_size()); - } else { - data_size = 2 * (data_size + size); - char* new_data; - try { - new_data = new char[data_size]; - } catch (const std::bad_alloc&) { - new_data = 0; - size = 0; - } - if (0 != new_data) { - std::copy(data, data + get_size(), new_data); - std::copy(raw_data, raw_data + size, new_data + get_size()); - delete[] data; - data = new_data; - } - } - set_size(get_size() + size); - } - } - - //------------------------------------------------------------------------------ - void append_data(const std::string& str_data) { - return append_data(str_data.c_str(), (Elf_Word)str_data.size()); - } - - //------------------------------------------------------------------------------ - protected: - //------------------------------------------------------------------------------ - ELFIO_GET_SET_ACCESS(Elf64_Off, offset, header.sh_offset); - - //------------------------------------------------------------------------------ - void set_index(Elf_Half value) { index = value; } - - //------------------------------------------------------------------------------ - void load(std::istream& stream, std::streampos header_offset) { - std::fill_n(reinterpret_cast(&header), sizeof(header), '\0'); - stream.seekg(header_offset); - stream.read(reinterpret_cast(&header), sizeof(header)); - - Elf_Xword size = get_size(); - if (0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type()) { - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - } - if (0 != size) { - stream.seekg((*convertor)(header.sh_offset)); - stream.read(data, size); - data_size = size; - } - } - } - - //------------------------------------------------------------------------------ - void save(std::ostream& f, std::streampos header_offset, std::streampos data_offset) { - if (0 != get_index()) { - header.sh_offset = data_offset; - header.sh_offset = (*convertor)(header.sh_offset); - } - - save_header(f, header_offset); - if (get_type() != SHT_NOBITS && get_type() != SHT_NULL && get_size() != 0 && data != 0) { - save_data(f, data_offset); - } - } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - void save_header(std::ostream& f, std::streampos header_offset) const { - f.seekp(header_offset); - f.write(reinterpret_cast(&header), sizeof(header)); - } - - //------------------------------------------------------------------------------ - void save_data(std::ostream& f, std::streampos data_offset) const { - f.seekp(data_offset); - f.write(get_data(), get_size()); - } - - //------------------------------------------------------------------------------ - private: - T header; - Elf_Half index; - std::string name; - char* data; - Elf_Word data_size; - const endianess_convertor* convertor; - bool is_address_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SECTION_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_segment.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_segment.hpp deleted file mode 100644 index 59e37ec9e0..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_segment.hpp +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SEGMENT_HPP -#define ELFIO_SEGMENT_HPP - -#include -#include - -namespace ELFIO { - -class segment { - friend class elfio; - - public: - virtual ~segment(){}; - - ELFIO_GET_ACCESS_DECL(Elf_Half, index); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, type); - ELFIO_GET_SET_ACCESS_DECL(Elf_Word, flags); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, align); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Addr, virtual_address); - ELFIO_GET_SET_ACCESS_DECL(Elf64_Addr, physical_address); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, file_size); - ELFIO_GET_SET_ACCESS_DECL(Elf_Xword, memory_size); - ELFIO_GET_ACCESS_DECL(Elf64_Off, offset); - - virtual const char* get_data() const = 0; - - virtual Elf_Half add_section_index(Elf_Half index, Elf_Xword addr_align) = 0; - virtual Elf_Half get_sections_num() const = 0; - virtual Elf_Half get_section_index_at(Elf_Half num) const = 0; - virtual bool is_offset_initialized() const = 0; - - protected: - ELFIO_SET_ACCESS_DECL(Elf64_Off, offset); - ELFIO_SET_ACCESS_DECL(Elf_Half, index); - - virtual const std::vector& get_sections() const = 0; - virtual void load(std::istream& stream, std::streampos header_offset) = 0; - virtual void save(std::ostream& f, std::streampos header_offset, - std::streampos data_offset) = 0; -}; - - -//------------------------------------------------------------------------------ -template -class segment_impl : public segment { - public: - //------------------------------------------------------------------------------ - segment_impl(endianess_convertor* convertor_) : convertor(convertor_) { - is_offset_set = false; - std::fill_n(reinterpret_cast(&ph), sizeof(ph), '\0'); - data = 0; - } - - //------------------------------------------------------------------------------ - virtual ~segment_impl() { delete[] data; } - - //------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS(Elf_Word, type, ph.p_type); - ELFIO_GET_SET_ACCESS(Elf_Word, flags, ph.p_flags); - ELFIO_GET_SET_ACCESS(Elf_Xword, align, ph.p_align); - ELFIO_GET_SET_ACCESS(Elf64_Addr, virtual_address, ph.p_vaddr); - ELFIO_GET_SET_ACCESS(Elf64_Addr, physical_address, ph.p_paddr); - ELFIO_GET_SET_ACCESS(Elf_Xword, file_size, ph.p_filesz); - ELFIO_GET_SET_ACCESS(Elf_Xword, memory_size, ph.p_memsz); - ELFIO_GET_ACCESS(Elf64_Off, offset, ph.p_offset); - - //------------------------------------------------------------------------------ - Elf_Half get_index() const { return index; } - - //------------------------------------------------------------------------------ - const char* get_data() const { return data; } - - //------------------------------------------------------------------------------ - Elf_Half add_section_index(Elf_Half sec_index, Elf_Xword addr_align) { - sections.push_back(sec_index); - if (addr_align > get_align()) { - set_align(addr_align); - } - - return (Elf_Half)sections.size(); - } - - //------------------------------------------------------------------------------ - Elf_Half get_sections_num() const { return (Elf_Half)sections.size(); } - - //------------------------------------------------------------------------------ - Elf_Half get_section_index_at(Elf_Half num) const { - if (num < sections.size()) { - return sections[num]; - } - - return -1; - } - - //------------------------------------------------------------------------------ - protected: - //------------------------------------------------------------------------------ - - //------------------------------------------------------------------------------ - void set_offset(Elf64_Off value) { - ph.p_offset = value; - ph.p_offset = (*convertor)(ph.p_offset); - is_offset_set = true; - } - - //------------------------------------------------------------------------------ - bool is_offset_initialized() const { return is_offset_set; } - - //------------------------------------------------------------------------------ - const std::vector& get_sections() const { return sections; } - - //------------------------------------------------------------------------------ - void set_index(Elf_Half value) { index = value; } - - //------------------------------------------------------------------------------ - void load(std::istream& stream, std::streampos header_offset) { - stream.seekg(header_offset); - stream.read(reinterpret_cast(&ph), sizeof(ph)); - is_offset_set = true; - - if (PT_NULL != get_type() && 0 != get_file_size()) { - stream.seekg((*convertor)(ph.p_offset)); - Elf_Xword size = get_file_size(); - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - } - if (0 != data) { - stream.read(data, size); - } - } - } - - //------------------------------------------------------------------------------ - void save(std::ostream& f, std::streampos header_offset, std::streampos data_offset) { - ph.p_offset = data_offset; - ph.p_offset = (*convertor)(ph.p_offset); - f.seekp(header_offset); - f.write(reinterpret_cast(&ph), sizeof(ph)); - } - - //------------------------------------------------------------------------------ - private: - T ph; - Elf_Half index; - char* data; - std::vector sections; - endianess_convertor* convertor; - bool is_offset_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SEGMENT_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_strings.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_strings.hpp deleted file mode 100644 index 07adc3a310..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_strings.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_STRINGS_HPP -#define ELFIO_STRINGS_HPP - -#include -#include -#include - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class string_section_accessor { - public: - //------------------------------------------------------------------------------ - string_section_accessor(section* section_) : string_section(section_) {} - - - //------------------------------------------------------------------------------ - const char* get_string(Elf_Word index) const { - if (string_section) { - if (index < string_section->get_size()) { - const char* data = string_section->get_data(); - if (0 != data) { - return data + index; - } - } - } - - return 0; - } - - - //------------------------------------------------------------------------------ - Elf_Word add_string(const char* str) { - Elf_Word current_position = 0; - - if (string_section) { - // Strings are addeded to the end of the current section data - current_position = (Elf_Word)string_section->get_size(); - - if (current_position == 0) { - char empty_string = '\0'; - string_section->append_data(&empty_string, 1); - current_position++; - } - string_section->append_data(str, (Elf_Word)std::strlen(str) + 1); - } - - return current_position; - } - - - //------------------------------------------------------------------------------ - Elf_Word add_string(const std::string& str) { return add_string(str.c_str()); } - - //------------------------------------------------------------------------------ - private: - section* string_section; -}; - -} // namespace ELFIO - -#endif // ELFIO_STRINGS_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_symbols.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_symbols.hpp deleted file mode 100644 index 8184bcd6c0..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_symbols.hpp +++ /dev/null @@ -1,220 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_SYMBOLS_HPP -#define ELFIO_SYMBOLS_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class symbol_section_accessor { - public: - //------------------------------------------------------------------------------ - symbol_section_accessor(const elfio& elf_file_, section* symbol_section_) - : elf_file(elf_file_), symbol_section(symbol_section_) { - find_hash_section(); - } - - //------------------------------------------------------------------------------ - Elf_Xword get_symbols_num() const { - Elf_Xword nRet = 0; - if (0 != symbol_section->get_entry_size()) { - nRet = symbol_section->get_size() / symbol_section->get_entry_size(); - } - - return nRet; - } - - //------------------------------------------------------------------------------ - bool get_symbol(Elf_Xword index, std::string& name, Elf64_Addr& value, Elf_Xword& size, - unsigned char& bind, unsigned char& type, Elf_Half& section_index, - unsigned char& other) const { - bool ret = false; - - if (elf_file.get_class() == ELFCLASS32) { - ret = generic_get_symbol(index, name, value, size, bind, type, section_index, - other); - } else { - ret = generic_get_symbol(index, name, value, size, bind, type, section_index, - other); - } - - return ret; - } - - //------------------------------------------------------------------------------ - bool get_symbol(const std::string& name, Elf64_Addr& value, Elf_Xword& size, - unsigned char& bind, unsigned char& type, Elf_Half& section_index, - unsigned char& other) const { - bool ret = false; - - if (0 != get_hash_table_index()) { - Elf_Word nbucket = *(Elf_Word*)hash_section->get_data(); - Elf_Word nchain = *(Elf_Word*)(hash_section->get_data() + sizeof(Elf_Word)); - Elf_Word val = elf_hash((const unsigned char*)name.c_str()); - - Elf_Word y = - *(Elf_Word*)(hash_section->get_data() + (2 + val % nbucket) * sizeof(Elf_Word)); - std::string str; - get_symbol(y, str, value, size, bind, type, section_index, other); - while (str != name && STN_UNDEF != y && y < nchain) { - y = *(Elf_Word*)(hash_section->get_data() + (2 + nbucket + y) * sizeof(Elf_Word)); - get_symbol(y, str, value, size, bind, type, section_index, other); - } - if (str == name) { - ret = true; - } - } - - return ret; - } - - //------------------------------------------------------------------------------ - Elf_Word add_symbol(Elf_Word name, Elf64_Addr value, Elf_Xword size, unsigned char info, - unsigned char other, Elf_Half shndx) { - Elf_Word nRet; - - if (symbol_section->get_size() == 0) { - if (elf_file.get_class() == ELFCLASS32) { - nRet = generic_add_symbol(0, 0, 0, 0, 0, 0); - } else { - nRet = generic_add_symbol(0, 0, 0, 0, 0, 0); - } - } - - if (elf_file.get_class() == ELFCLASS32) { - nRet = generic_add_symbol(name, value, size, info, other, shndx); - } else { - nRet = generic_add_symbol(name, value, size, info, other, shndx); - } - - return nRet; - } - - //------------------------------------------------------------------------------ - Elf_Word add_symbol(Elf_Word name, Elf64_Addr value, Elf_Xword size, unsigned char bind, - unsigned char type, unsigned char other, Elf_Half shndx) { - return add_symbol(name, value, size, ELF_ST_INFO(bind, type), other, shndx); - } - - //------------------------------------------------------------------------------ - Elf_Word add_symbol(string_section_accessor& pStrWriter, const char* str, Elf64_Addr value, - Elf_Xword size, unsigned char info, unsigned char other, Elf_Half shndx) { - Elf_Word index = pStrWriter.add_string(str); - return add_symbol(index, value, size, info, other, shndx); - } - - //------------------------------------------------------------------------------ - Elf_Word add_symbol(string_section_accessor& pStrWriter, const char* str, Elf64_Addr value, - Elf_Xword size, unsigned char bind, unsigned char type, unsigned char other, - Elf_Half shndx) { - return add_symbol(pStrWriter, str, value, size, ELF_ST_INFO(bind, type), other, shndx); - } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - void find_hash_section() { - hash_section = 0; - hash_section_index = 0; - Elf_Half nSecNo = elf_file.sections.size(); - for (Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i) { - const section* sec = elf_file.sections[i]; - if (sec->get_link() == symbol_section->get_index()) { - hash_section = sec; - hash_section_index = i; - } - } - } - - //------------------------------------------------------------------------------ - Elf_Half get_string_table_index() const { return (Elf_Half)symbol_section->get_link(); } - - //------------------------------------------------------------------------------ - Elf_Half get_hash_table_index() const { return hash_section_index; } - - //------------------------------------------------------------------------------ - template - bool generic_get_symbol(Elf_Xword index, std::string& name, Elf64_Addr& value, Elf_Xword& size, - unsigned char& bind, unsigned char& type, Elf_Half& section_index, - unsigned char& other) const { - bool ret = false; - - if (index < get_symbols_num()) { - const T* pSym = reinterpret_cast(symbol_section->get_data() + - index * symbol_section->get_entry_size()); - - const endianess_convertor& convertor = elf_file.get_convertor(); - - section* string_section = elf_file.sections[get_string_table_index()]; - string_section_accessor str_reader(string_section); - const char* pStr = str_reader.get_string(convertor(pSym->st_name)); - if (0 != pStr) { - name = pStr; - } - value = convertor(pSym->st_value); - size = convertor(pSym->st_size); - bind = ELF_ST_BIND(pSym->st_info); - type = ELF_ST_TYPE(pSym->st_info); - section_index = convertor(pSym->st_shndx); - other = pSym->st_other; - - ret = true; - } - - return ret; - } - - //------------------------------------------------------------------------------ - template - Elf_Word generic_add_symbol(Elf_Word name, Elf64_Addr value, Elf_Xword size, unsigned char info, - unsigned char other, Elf_Half shndx) { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.st_name = convertor(name); - entry.st_value = value; - entry.st_value = convertor(entry.st_value); - entry.st_size = size; - entry.st_size = convertor(entry.st_size); - entry.st_info = convertor(info); - entry.st_other = convertor(other); - entry.st_shndx = convertor(shndx); - - symbol_section->append_data(reinterpret_cast(&entry), sizeof(entry)); - - Elf_Word nRet = symbol_section->get_size() / sizeof(entry) - 1; - - return nRet; - } - - //------------------------------------------------------------------------------ - private: - const elfio& elf_file; - section* symbol_section; - Elf_Half hash_section_index; - const section* hash_section; -}; - -} // namespace ELFIO - -#endif // ELFIO_SYMBOLS_HPP diff --git a/hipamd/include/hip/hcc_detail/elfio/elfio_utils.hpp b/hipamd/include/hip/hcc_detail/elfio/elfio_utils.hpp deleted file mode 100644 index b1bb00e169..0000000000 --- a/hipamd/include/hip/hcc_detail/elfio/elfio_utils.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ELFIO_UTILS_HPP -#define ELFIO_UTILS_HPP - -#define ELFIO_GET_ACCESS(TYPE, NAME, FIELD) \ - TYPE get_##NAME() const { return (*convertor)(FIELD); } -#define ELFIO_SET_ACCESS(TYPE, NAME, FIELD) \ - void set_##NAME(TYPE value) { \ - FIELD = value; \ - FIELD = (*convertor)(FIELD); \ - } -#define ELFIO_GET_SET_ACCESS(TYPE, NAME, FIELD) \ - TYPE get_##NAME() const { return (*convertor)(FIELD); } \ - void set_##NAME(TYPE value) { \ - FIELD = value; \ - FIELD = (*convertor)(FIELD); \ - } - -#define ELFIO_GET_ACCESS_DECL(TYPE, NAME) virtual TYPE get_##NAME() const = 0 - -#define ELFIO_SET_ACCESS_DECL(TYPE, NAME) virtual void set_##NAME(TYPE value) = 0 - -#define ELFIO_GET_SET_ACCESS_DECL(TYPE, NAME) \ - virtual TYPE get_##NAME() const = 0; \ - virtual void set_##NAME(TYPE value) = 0 - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class endianess_convertor { - public: - //------------------------------------------------------------------------------ - endianess_convertor() { need_conversion = false; } - - //------------------------------------------------------------------------------ - void setup(unsigned char elf_file_encoding) { - need_conversion = (elf_file_encoding != get_host_encoding()); - } - - //------------------------------------------------------------------------------ - uint64_t operator()(uint64_t value) const { - if (!need_conversion) { - return value; - } - value = ((value & 0x00000000000000FFull) << 56) | ((value & 0x000000000000FF00ull) << 40) | - ((value & 0x0000000000FF0000ull) << 24) | ((value & 0x00000000FF000000ull) << 8) | - ((value & 0x000000FF00000000ull) >> 8) | ((value & 0x0000FF0000000000ull) >> 24) | - ((value & 0x00FF000000000000ull) >> 40) | ((value & 0xFF00000000000000ull) >> 56); - - return value; - } - - //------------------------------------------------------------------------------ - int64_t operator()(int64_t value) const { - if (!need_conversion) { - return value; - } - return (int64_t)(*this)((uint64_t)value); - } - - //------------------------------------------------------------------------------ - uint32_t operator()(uint32_t value) const { - if (!need_conversion) { - return value; - } - value = ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8) | - ((value & 0x00FF0000) >> 8) | ((value & 0xFF000000) >> 24); - - return value; - } - - //------------------------------------------------------------------------------ - int32_t operator()(int32_t value) const { - if (!need_conversion) { - return value; - } - return (int32_t)(*this)((uint32_t)value); - } - - //------------------------------------------------------------------------------ - uint16_t operator()(uint16_t value) const { - if (!need_conversion) { - return value; - } - value = ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8); - - return value; - } - - //------------------------------------------------------------------------------ - int16_t operator()(int16_t value) const { - if (!need_conversion) { - return value; - } - return (int16_t)(*this)((uint16_t)value); - } - - //------------------------------------------------------------------------------ - int8_t operator()(int8_t value) const { return value; } - - //------------------------------------------------------------------------------ - uint8_t operator()(uint8_t value) const { return value; } - - //------------------------------------------------------------------------------ - private: - //------------------------------------------------------------------------------ - unsigned char get_host_encoding() const { - static const int tmp = 1; - if (1 == *(char*)&tmp) { - return ELFDATA2LSB; - } else { - return ELFDATA2MSB; - } - } - - //------------------------------------------------------------------------------ - private: - bool need_conversion; -}; - - -//------------------------------------------------------------------------------ -inline uint32_t elf_hash(const unsigned char* name) { - uint32_t h = 0, g; - while (*name) { - h = (h << 4) + *name++; - g = h & 0xf0000000; - if (g != 0) h ^= g >> 24; - h &= ~g; - } - return h; -} - -} // namespace ELFIO - -#endif // ELFIO_UTILS_HPP diff --git a/hipamd/include/hip/hip_common.h b/hipamd/include/hip/hip_common.h index 79c787be4e..48ee052063 100644 --- a/hipamd/include/hip/hip_common.h +++ b/hipamd/include/hip/hip_common.h @@ -24,15 +24,25 @@ THE SOFTWARE. #define HIP_INCLUDE_HIP_HIP_COMMON_H // Common code included at start of every hip file. -// Auto enable __HIP_PLATFORM_HCC__ if compiling with HCC +// Auto enable __HIP_PLATFORM_AMD__ if compiling on AMD platform // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly #if defined(__HCC__) || (defined(__clang__) && defined(__HIP__)) -#define __HIP_PLATFORM_HCC__ +#ifndef __HIP_PLATFORM_HCC__ +#define __HIP_PLATFORM_HCC__ // To be removed +#endif +#ifndef __HIP_PLATFORM_AMD__ +#define __HIP_PLATFORM_AMD__ +#endif #endif //__HCC__ -// Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC +// Auto enable __HIP_PLATFORM_NVIDIA__ if compiling with NVIDIA platform #if defined(__NVCC__) || (defined(__clang__) && defined(__CUDA__) && !defined(__HIP__)) -#define __HIP_PLATFORM_NVCC__ +#ifndef __HIP_PLATFORM_NVCC__ +#define __HIP_PLATFORM_NVCC__ // To be removed +#endif +#ifndef __HIP_PLATFORM_NVIDIA__ +#define __HIP_PLATFORM_NVIDIA__ +#endif #ifdef __CUDACC__ #define __HIPCC__ #endif diff --git a/hipamd/include/hip/hip_complex.h b/hipamd/include/hip/hip_complex.h index fb9cad5e48..89943a6cc0 100644 --- a/hipamd/include/hip/hip_complex.h +++ b/hipamd/include/hip/hip_complex.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#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__)) +#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/hip_cooperative_groups.h b/hipamd/include/hip/hip_cooperative_groups.h index 41f36378bb..cff88d4217 100644 --- a/hipamd/include/hip/hip_cooperative_groups.h +++ b/hipamd/include/hip/hip_cooperative_groups.h @@ -33,14 +33,14 @@ THE SOFTWARE. #include #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) +#if (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) #if __cplusplus && defined(__clang__) && defined(__HIP__) -#include +#include #endif -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#include +#elif !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) +#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif // HIP_INCLUDE_HIP_HIP_COOPERATIVE_GROUP_H diff --git a/hipamd/include/hip/hip_ext.h b/hipamd/include/hip/hip_ext.h index ef8f53b513..a3361eae20 100644 --- a/hipamd/include/hip/hip_ext.h +++ b/hipamd/include/hip/hip_ext.h @@ -102,7 +102,7 @@ inline void hipExtLaunchKernelGGL(F kernel, const dim3& numBlocks, const dim3& d hipExtLaunchKernel(k, numBlocks, dimBlocks, _Args, sharedMemBytes, stream, startEvent, stopEvent, (int)flags); } -#elif defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__) +#elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__) //kernel_descriptor and hip_impl::make_kernarg are in "grid_launch_GGL.hpp" namespace hip_impl { diff --git a/hipamd/include/hip/hip_fp16.h b/hipamd/include/hip/hip_fp16.h index 994ce62bd8..626ce64c7d 100644 --- a/hipamd/include/hip/hip_fp16.h +++ b/hipamd/include/hip/hip_fp16.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#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__)) #include "cuda_fp16.h" #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/hip_runtime.h b/hipamd/include/hip/hip_runtime.h index c785f8d00c..ffd71bcd93 100644 --- a/hipamd/include/hip/hip_runtime.h +++ b/hipamd/include/hip/hip_runtime.h @@ -56,12 +56,12 @@ THE SOFTWARE. #include #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#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__)) +#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif diff --git a/hipamd/include/hip/hip_runtime_api.h b/hipamd/include/hip/hip_runtime_api.h index ed9a288282..6a281b43c4 100644 --- a/hipamd/include/hip/hip_runtime_api.h +++ b/hipamd/include/hip/hip_runtime_api.h @@ -379,12 +379,12 @@ enum hipComputeMode { * @} */ -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include "hip/hcc_detail/hip_runtime_api.h" -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#include "hip/nvcc_detail/hip_runtime_api.h" +#if (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) +#include "hip/amd_detail/hip_runtime_api.h" +#elif !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) +#include "hip/nvidia_detail/hip_runtime_api.h" #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif diff --git a/hipamd/include/hip/hip_texture_types.h b/hipamd/include/hip/hip_texture_types.h index a7feab011b..308da167a0 100644 --- a/hipamd/include/hip/hip_texture_types.h +++ b/hipamd/include/hip/hip_texture_types.h @@ -24,12 +24,12 @@ THE SOFTWARE. #ifndef HIP_INCLUDE_HIP_HIP_TEXTURE_TYPES_H #define HIP_INCLUDE_HIP_HIP_TEXTURE_TYPES_H -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -#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__)) +#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif diff --git a/hipamd/include/hip/hip_vector_types.h b/hipamd/include/hip/hip_vector_types.h index c1a0373c06..9aa27dbbf1 100644 --- a/hipamd/include/hip/hip_vector_types.h +++ b/hipamd/include/hip/hip_vector_types.h @@ -28,14 +28,14 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) +#if (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) #if __cplusplus -#include +#include #endif -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#elif !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__)) #include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/hiprtc.h b/hipamd/include/hip/hiprtc.h index 22d78d2656..72105382e8 100644 --- a/hipamd/include/hip/hiprtc.h +++ b/hipamd/include/hip/hiprtc.h @@ -23,10 +23,10 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) - #include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) - #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__)) + #include #else - #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif \ No newline at end of file + #error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); +#endif diff --git a/hipamd/include/hip/library_types.h b/hipamd/include/hip/library_types.h index 4a988df52b..805a385644 100644 --- a/hipamd/include/hip/library_types.h +++ b/hipamd/include/hip/library_types.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#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__)) #include "library_types.h" #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/math_functions.h b/hipamd/include/hip/math_functions.h index 2dfec4551b..7488052e73 100644 --- a/hipamd/include/hip/math_functions.h +++ b/hipamd/include/hip/math_functions.h @@ -29,12 +29,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) -//#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__)) +//#include #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/include/hip/nvcc_detail/hip_cooperative_groups.h b/hipamd/include/hip/nvcc_detail/hip_cooperative_groups.h deleted file mode 100644 index 113e600eec..0000000000 --- a/hipamd/include/hip/nvcc_detail/hip_cooperative_groups.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COOPERATIVE_GROUPS_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COOPERATIVE_GROUPS_H - -// Include CUDA headers -#include -#include - -// Include HIP wrapper headers around CUDA -#include -#include - -#endif // HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COOPERATIVE_GROUPS_H diff --git a/hipamd/include/hip/nvcc_detail/hip_texture_types.h b/hipamd/include/hip/nvcc_detail/hip_texture_types.h deleted file mode 100644 index 751dd8e4d4..0000000000 --- a/hipamd/include/hip/nvcc_detail/hip_texture_types.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_TYPES_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_TYPES_H - -#include - -#endif diff --git a/hipamd/include/hip/nvcc_detail/channel_descriptor.h b/hipamd/include/hip/nvidia_detail/channel_descriptor.h similarity index 90% rename from hipamd/include/hip/nvcc_detail/channel_descriptor.h rename to hipamd/include/hip/nvidia_detail/channel_descriptor.h index c3e9dc1ff6..7eb0e65fda 100644 --- a/hipamd/include/hip/nvcc_detail/channel_descriptor.h +++ b/hipamd/include/hip/nvidia_detail/channel_descriptor.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_CHANNEL_DESCRIPTOR_H #include "channel_descriptor.h" diff --git a/hipamd/include/hip/nvcc_detail/hip_complex.h b/hipamd/include/hip/nvidia_detail/hip_complex.h similarity index 97% rename from hipamd/include/hip/nvcc_detail/hip_complex.h rename to hipamd/include/hip/nvidia_detail/hip_complex.h index d0e45d26db..10a53d1743 100644 --- a/hipamd/include/hip/nvcc_detail/hip_complex.h +++ b/hipamd/include/hip/nvidia_detail/hip_complex.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H #include "cuComplex.h" diff --git a/hipamd/include/hip/nvidia_detail/hip_cooperative_groups.h b/hipamd/include/hip/nvidia_detail/hip_cooperative_groups.h new file mode 100644 index 0000000000..fc98ae2281 --- /dev/null +++ b/hipamd/include/hip/nvidia_detail/hip_cooperative_groups.h @@ -0,0 +1,12 @@ +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H + +// Include CUDA headers +#include +#include + +// Include HIP wrapper headers around CUDA +#include +#include + +#endif // HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H diff --git a/hipamd/include/hip/nvcc_detail/hip_runtime.h b/hipamd/include/hip/nvidia_detail/hip_runtime.h similarity index 97% rename from hipamd/include/hip/nvcc_detail/hip_runtime.h rename to hipamd/include/hip/nvidia_detail/hip_runtime.h index e7c3eaf32a..84414fb4a3 100644 --- a/hipamd/include/hip/nvcc_detail/hip_runtime.h +++ b/hipamd/include/hip/nvidia_detail/hip_runtime.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_H #include diff --git a/hipamd/include/hip/nvcc_detail/hip_runtime_api.h b/hipamd/include/hip/nvidia_detail/hip_runtime_api.h similarity index 99% rename from hipamd/include/hip/nvcc_detail/hip_runtime_api.h rename to hipamd/include/hip/nvidia_detail/hip_runtime_api.h index 257d795cf3..eb3df19bc4 100644 --- a/hipamd/include/hip/nvcc_detail/hip_runtime_api.h +++ b/hipamd/include/hip/nvidia_detail/hip_runtime_api.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H -#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_API_H #include #include @@ -2042,4 +2042,4 @@ inline static hipError_t hipArrayDestroy(hiparray hArray){ #endif //__CUDACC__ -#endif // HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H +#endif // HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_API_H diff --git a/hipamd/include/hip/nvidia_detail/hip_texture_types.h b/hipamd/include/hip/nvidia_detail/hip_texture_types.h new file mode 100644 index 0000000000..df374d705a --- /dev/null +++ b/hipamd/include/hip/nvidia_detail/hip_texture_types.h @@ -0,0 +1,6 @@ +#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_TEXTURE_TYPES_H + +#include + +#endif diff --git a/hipamd/include/hip/texture_types.h b/hipamd/include/hip/texture_types.h index 7d785708d4..4088d67af4 100644 --- a/hipamd/include/hip/texture_types.h +++ b/hipamd/include/hip/texture_types.h @@ -25,12 +25,12 @@ THE SOFTWARE. #include -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) -#include -#elif defined(__HIP_PLATFORM_NVCC__) && !defined(__HIP_PLATFORM_HCC__) +#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__)) #include "texture_types.h" #else -#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__"); #endif #endif diff --git a/hipamd/packaging/hip-base.postinst b/hipamd/packaging/hip-base.postinst index 2fff152f7a..a842aa0b42 100755 --- a/hipamd/packaging/hip-base.postinst +++ b/hipamd/packaging/hip-base.postinst @@ -28,3 +28,8 @@ mkdir -p $ROCMINCDIR pushd $ROCMINCDIR ln -r -s -f $HIPINCDIR hip popd + +# The following will be removed after upstream updation +pushd $HIPINCDIR + ln -r -s -f amd_detail hcc_detail +popd \ No newline at end of file diff --git a/hipamd/packaging/hip-base.txt b/hipamd/packaging/hip-base.txt index 55d715b2b2..ab7ef5d848 100644 --- a/hipamd/packaging/hip-base.txt +++ b/hipamd/packaging/hip-base.txt @@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 2.8.3) project(hip_base) install(DIRECTORY @hip_SOURCE_DIR@/bin DESTINATION . USE_SOURCE_PERMISSIONS) -install(DIRECTORY @hip_SOURCE_DIR@/include DESTINATION .) -install(FILES @PROJECT_BINARY_DIR@/include/hip/hcc_detail/hip_prof_str.h - DESTINATION include/hip/hcc_detail) +# The following 'ATTERN "hcc_detail" EXCLUDE' will be removed after upstream updation +install(DIRECTORY @hip_SOURCE_DIR@/include DESTINATION . PATTERN "hcc_detail" EXCLUDE) +install(FILES @PROJECT_BINARY_DIR@/include/hip/amd_detail/hip_prof_str.h + DESTINATION include/hip/amd_detail) install(FILES @PROJECT_BINARY_DIR@/include/hip/hip_version.h DESTINATION include/hip) install(FILES @PROJECT_BINARY_DIR@/.hipVersion DESTINATION bin) diff --git a/hipamd/packaging/hip-hcc.postinst b/hipamd/packaging/hip-hcc.postinst deleted file mode 100755 index 080c846f40..0000000000 --- a/hipamd/packaging/hip-hcc.postinst +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -pushd () { - command pushd "$@" > /dev/null -} - -popd () { - command popd "$@" > /dev/null -} - - -ROCMDIR=@ROCM_PATH@ -ROCMLIBDIR=$ROCMDIR/lib -HIPDIR=$ROCMDIR/hip -HIPLIBDIR=$ROCMDIR/hip/lib - -# Soft-link to library files -HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v "cmake\|[-/$]") -mkdir -p $ROCMLIBDIR -mkdir -p $ROCMLIBDIR/cmake -pushd $ROCMLIBDIR -for f in $HIPLIBFILES -do - ln -s -r -f $HIPLIBDIR/$f $(basename $f) -done -# Make the hip cmake directory link. -pushd cmake -ln -s -r -f $HIPLIBDIR/cmake/hip hip -popd -popd diff --git a/hipamd/packaging/hip-hcc.prerm b/hipamd/packaging/hip-hcc.prerm deleted file mode 100755 index bf2be36523..0000000000 --- a/hipamd/packaging/hip-hcc.prerm +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -pushd () { - command pushd "$@" > /dev/null -} - -popd () { - command popd "$@" > /dev/null -} - -ROCMDIR=@ROCM_PATH@ -ROCMLIBDIR=$ROCMDIR/lib -HIPDIR=$ROCMDIR/hip -HIPLIBDIR=$ROCMDIR/hip/lib -([ ! -d $ROCMDIR ] || [ ! -d $HIPDIR ]) && exit 0 -([ ! -d $ROCMLIBDIR ] || [ ! -d $HIPLIBDIR ]) && exit 0 - -# Remove soft-links to libraries -HIPLIBFILES=$(ls -A $HIPLIBDIR | grep -v [-/$]) -pushd $ROCMLIBDIR -for f in $HIPLIBFILES; do - [ -e $f ] || continue - rm $(basename $f) -done -pushd cmake -unlink hip -popd -rmdir --ignore-fail-on-non-empty cmake -popd -rmdir --ignore-fail-on-non-empty $ROCMLIBDIR - diff --git a/hipamd/packaging/hip-hcc.txt b/hipamd/packaging/hip-hcc.txt deleted file mode 100644 index 58365b24d6..0000000000 --- a/hipamd/packaging/hip-hcc.txt +++ /dev/null @@ -1,58 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(hip_hcc) - -install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so DESTINATION lib) -install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so.@HIP_LIB_VERSION_MAJOR@ DESTINATION lib) -install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so.@HIP_LIB_VERSION_STRING@ DESTINATION lib) -install(FILES @PROJECT_BINARY_DIR@/libhip_hcc_static.a DESTINATION lib) -if(NOT @HIP_COMPILER@ STREQUAL "clang") - install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so DESTINATION lib) - install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so.@HIP_LIB_VERSION_MAJOR@ DESTINATION lib) - install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so.@HIP_LIB_VERSION_STRING@ DESTINATION lib) -endif() -install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib) -install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip) -install(FILES @CONFIG_PACKAGE_INSTALL_DIR@/hip-targets.cmake @CONFIG_PACKAGE_INSTALL_DIR@/hip-targets-release.cmake DESTINATION lib/cmake/hip) - -############################# -# Packaging steps -############################# -set(CPACK_SET_DESTDIR TRUE) -set(CPACK_INSTALL_PREFIX @CPACK_INSTALL_PREFIX@ ) -set(CPACK_PACKAGE_NAME "hip-hcc") -if(@HCC_VERSION_MAJOR@ EQUAL 0) - set(HCC_PACKAGE_NAME "hcc_lc") -else() - set(HCC_PACKAGE_NAME "hcc") -endif() -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HCC]") -set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") -set(CPACK_PACKAGE_CONTACT "HIP Support ") -set(CPACK_PACKAGE_VERSION_MAJOR @HIP_VERSION_MAJOR@) -set(CPACK_PACKAGE_VERSION_MINOR @HIP_VERSION_MINOR@) -set(CPACK_PACKAGE_VERSION_PATCH @HIP_VERSION_PATCH@) -set(CPACK_PACKAGE_VERSION @HIP_VERSION_MAJOR@.@HIP_VERSION_MINOR@.@HIP_PACKAGING_VERSION_PATCH@) -set(CPACK_GENERATOR "TGZ;DEB;RPM") - -set(CPACK_BINARY_DEB "ON") -set(CPACK_DEBIAN_PACKAGE_RELEASE @CPACK_DEBIAN_PACKAGE_RELEASE@) -set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), comgr (>= 1.1)") -set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip-hcc") -set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_hcc") - -set(CPACK_BINARY_RPM "ON") -set(CPACK_RPM_PACKAGE_RELEASE @CPACK_RPM_PACKAGE_RELEASE@) -set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") -set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") -set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") -set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") -string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION}) -set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, comgr >= 1.1") -set(CPACK_RPM_PACKAGE_OBSOLETES "hip_hcc") -set(CPACK_RPM_PACKAGE_CONFLICTS "hip_hcc") -set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") -set(CPACK_SOURCE_GENERATOR "TGZ") -include(CPack) diff --git a/hipamd/rocclr/CMakeLists.txt b/hipamd/rocclr/CMakeLists.txt index 95d2892393..0c17cf3cc7 100755 --- a/hipamd/rocclr/CMakeLists.txt +++ b/hipamd/rocclr/CMakeLists.txt @@ -15,7 +15,7 @@ set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip) find_package(PythonInterp REQUIRED) -add_definitions(-D__HIP_ROCclr__ -D__HIP_PLATFORM_HCC__ -DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DCL_TARGET_OPENCL_VERSION=220 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER -DUSE_PROF_API) +add_definitions(-D__HIP_ROCclr__ -D__HIP_PLATFORM_HCC__ -D__HIP_PLATFORM_AMD__ -DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DCL_TARGET_OPENCL_VERSION=220 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER -DUSE_PROF_API) if(CMAKE_BUILD_TYPE MATCHES "^Debug$") add_definitions(-DDEBUG) @@ -46,8 +46,8 @@ find_package(ROCclr REQUIRED CONFIG) # Profiling API support ############################# # Generate profiling API macros/structures header -set(PROF_API_STR "${PROJECT_BINARY_DIR}/include/hip/hcc_detail/hip_prof_str.h") -set(PROF_API_HDR "${PROJECT_SOURCE_DIR}/include/hip/hcc_detail/hip_runtime_api.h") +set(PROF_API_STR "${PROJECT_BINARY_DIR}/include/hip/amd_detail/hip_prof_str.h") +set(PROF_API_HDR "${PROJECT_SOURCE_DIR}/include/hip/amd_detail/hip_runtime_api.h") set(PROF_API_SRC "${CMAKE_CURRENT_SOURCE_DIR}") set(PROF_API_GEN "${CMAKE_CURRENT_SOURCE_DIR}/hip_prof_gen.py") set(PROF_API_LOG "${PROJECT_BINARY_DIR}/hip_prof_gen.log.txt") @@ -220,8 +220,8 @@ target_link_libraries(amdhip64 PRIVATE amdrocclr_static Threads::Threads dl hsa- add_custom_command(TARGET amdhip64 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/.hipInfo ${PROJECT_BINARY_DIR}/lib/.hipInfo) -add_custom_command(TARGET amdhip64 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) +add_custom_command(TARGET amdhip64 POST_BUILD COMMAND cp -rf + ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/) INSTALL(PROGRAMS $ DESTINATION lib COMPONENT MAIN) diff --git a/hipamd/rocclr/hip_conversions.hpp b/hipamd/rocclr/hip_conversions.hpp index 8838d5010d..a15923c0f3 100644 --- a/hipamd/rocclr/hip_conversions.hpp +++ b/hipamd/rocclr/hip_conversions.hpp @@ -22,8 +22,8 @@ THE SOFTWARE. #pragma once -#include -#include +#include +#include namespace hip { diff --git a/hipamd/rocclr/hip_platform.cpp b/hipamd/rocclr/hip_platform.cpp index 4a58877ebe..fc359515ae 100755 --- a/hipamd/rocclr/hip_platform.cpp +++ b/hipamd/rocclr/hip_platform.cpp @@ -19,7 +19,7 @@ THE SOFTWARE. */ #include -#include +#include #include "hip_platform.hpp" #include "hip_internal.hpp" #include "platform/program.hpp" diff --git a/hipamd/rocclr/hip_prof_api.h b/hipamd/rocclr/hip_prof_api.h index ff81fb7cf5..e047f89b7f 100644 --- a/hipamd/rocclr/hip_prof_api.h +++ b/hipamd/rocclr/hip_prof_api.h @@ -26,7 +26,7 @@ #include #if USE_PROF_API -#include "hip/hcc_detail/hip_prof_str.h" +#include "hip/amd_detail/hip_prof_str.h" #include "platform/prof_protocol.h" // HIP API callbacks spawner object macro diff --git a/hipamd/rocclr/hip_prof_gen.py b/hipamd/rocclr/hip_prof_gen.py index 3e0a657f3c..aa44a70bd2 100755 --- a/hipamd/rocclr/hip_prof_gen.py +++ b/hipamd/rocclr/hip_prof_gen.py @@ -589,7 +589,7 @@ if (len(sys.argv) < 3): " -p - HIP_INIT_API macro patching mode\n" + "\n" + " Example:\n" + - " $ " + sys.argv[0] + " -v -p -t --priv ./api/hip/include/hip/hcc_detail/hip_runtime_api.h ./api/hip ./api/hip/include/hip/hcc_detail/hip_prof_str.h"); + " $ " + sys.argv[0] + " -v -p -t --priv ./api/hip/include/hip/amd_detail/hip_runtime_api.h ./api/hip ./api/hip/include/hip/amd_detail/hip_prof_str.h"); # API header file given as an argument src_pat = "\.cpp$" diff --git a/hipamd/rocclr/hip_surface.cpp b/hipamd/rocclr/hip_surface.cpp index 5adaf418cf..c88e3ea3cf 100644 --- a/hipamd/rocclr/hip_surface.cpp +++ b/hipamd/rocclr/hip_surface.cpp @@ -21,7 +21,7 @@ #include #include "hip_internal.hpp" -#include +#include hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc) { diff --git a/hipamd/rocclr/hip_texture.cpp b/hipamd/rocclr/hip_texture.cpp index 955e1b5304..112f3399f5 100755 --- a/hipamd/rocclr/hip_texture.cpp +++ b/hipamd/rocclr/hip_texture.cpp @@ -19,7 +19,7 @@ THE SOFTWARE. */ #include -#include +#include #include "hip_internal.hpp" #include "hip_platform.hpp" #include "hip_conversions.hpp" diff --git a/hipamd/samples/0_Intro/bit_extract/README.md b/hipamd/samples/0_Intro/bit_extract/README.md index 76f8906595..69995721b0 100644 --- a/hipamd/samples/0_Intro/bit_extract/README.md +++ b/hipamd/samples/0_Intro/bit_extract/README.md @@ -1,6 +1,6 @@ # bit_extract -Show an application written directly in HIP which uses platform-specific check on __HIP_PLATFORM_HCC__ to enable use of +Show an application written directly in HIP which uses platform-specific check on __HIP_PLATFORM_AMD__ to enable use of an instruction that only exists on the HCC platform. See related [blog](http://gpuopen.com/platform-aware-coding-inside-hip/) demonstrating platform specialization. diff --git a/hipamd/samples/0_Intro/bit_extract/bit_extract.cpp b/hipamd/samples/0_Intro/bit_extract/bit_extract.cpp index 1f7770ccb5..dad27f759d 100644 --- a/hipamd/samples/0_Intro/bit_extract/bit_extract.cpp +++ b/hipamd/samples/0_Intro/bit_extract/bit_extract.cpp @@ -39,9 +39,9 @@ __global__ void bit_extract_kernel(uint32_t* C_d, const uint32_t* A_d, size_t N) size_t stride = hipBlockDim_x * hipGridDim_x; for (size_t i = offset; i < N; i += stride) { -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ C_d[i] = __bitextract_u32(A_d[i], 8, 4); -#else /* defined __HIP_PLATFORM_NVCC__ or other path */ +#else /* defined __HIP_PLATFORM_NVIDIA__ or other path */ C_d[i] = ((A_d[i] & 0xf00) >> 8); #endif } diff --git a/hipamd/samples/0_Intro/module_api/launchKernelHcc.cpp b/hipamd/samples/0_Intro/module_api/launchKernelHcc.cpp index 90e569c5bc..5bb1bd3e96 100644 --- a/hipamd/samples/0_Intro/module_api/launchKernelHcc.cpp +++ b/hipamd/samples/0_Intro/module_api/launchKernelHcc.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #include #endif diff --git a/hipamd/samples/0_Intro/square/square.hipref.cpp b/hipamd/samples/0_Intro/square/square.hipref.cpp index a2b21f17e4..300a875997 100644 --- a/hipamd/samples/0_Intro/square/square.hipref.cpp +++ b/hipamd/samples/0_Intro/square/square.hipref.cpp @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) { hipDeviceProp_t props; CHECK(hipGetDeviceProperties(&props, device /*deviceID*/)); printf("info: running on device %s\n", props.name); -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ printf("info: architecture on AMD GPU device is: %s\n", props.gcnArchName); #endif printf("info: allocate host mem (%6.2f MB)\n", 2 * Nbytes / 1024.0 / 1024.0); diff --git a/hipamd/samples/1_Utils/hipCommander/hipCommander.cpp b/hipamd/samples/1_Utils/hipCommander/hipCommander.cpp index 21b5505623..37eb0845b1 100644 --- a/hipamd/samples/1_Utils/hipCommander/hipCommander.cpp +++ b/hipamd/samples/1_Utils/hipCommander/hipCommander.cpp @@ -813,12 +813,12 @@ int main(int argc, char* argv[]) { CommandStream* cs; if (p_blockingSync) { -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ printf("setting BlockingSync for AMD\n"); setenv("HIP_BLOCKING_SYNC", "1", 1); #endif -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ printf("setting cudaDeviceBlockingSync\n"); HIPCHECK(hipSetDeviceFlags(cudaDeviceBlockingSync)); #endif diff --git a/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchEnqueueRateMT.cpp b/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchEnqueueRateMT.cpp index 8b58dd55e6..81cae36296 100644 --- a/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchEnqueueRateMT.cpp +++ b/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchEnqueueRateMT.cpp @@ -19,7 +19,7 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #include "hip/hip_ext.h" #endif #include diff --git a/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp b/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp index b528b0c75d..fb4ab8455c 100644 --- a/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp +++ b/hipamd/samples/1_Utils/hipDispatchLatency/hipDispatchLatency.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #include "hip/hip_ext.h" #endif #include @@ -109,7 +109,7 @@ int main() { /***********************************************************************************/ //Timing directly the dispatch -#if defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__) +#if defined(__HIP_PLATFORM_AMD__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__) for (auto i = 0; i < TOTAL_RUN_COUNT; ++i) { hipExtLaunchKernelGGL((EmptyKernel), dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream0, start, stop, 0); hipEventSynchronize(stop); diff --git a/hipamd/samples/1_Utils/hipInfo/README.md b/hipamd/samples/1_Utils/hipInfo/README.md index 1c2749880a..d52f8d8fef 100644 --- a/hipamd/samples/1_Utils/hipInfo/README.md +++ b/hipamd/samples/1_Utils/hipInfo/README.md @@ -3,4 +3,4 @@ Simple tool that prints properties for each device (from hipGetDeviceProperties), and compiler info. Properties includes all of the architectural feature flags for each device. -Also demonstrates how to use platform-specific compilation path (testing `__HIP_PLATFORM_NVCC__` or `__HIP_PLATFORM_HCC__`) +Also demonstrates how to use platform-specific compilation path (testing `__HIP_PLATFORM_AMD__` or `__HIP_PLATFORM_NVIDIA__`) diff --git a/hipamd/samples/1_Utils/hipInfo/hipInfo.cpp b/hipamd/samples/1_Utils/hipInfo/hipInfo.cpp index e5998bfb64..e15ce583b9 100644 --- a/hipamd/samples/1_Utils/hipInfo/hipInfo.cpp +++ b/hipamd/samples/1_Utils/hipInfo/hipInfo.cpp @@ -171,7 +171,7 @@ void printDeviceProp(int deviceId) { cout << endl; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ // Limits: cout << endl; printLimit(w1, cudaLimitStackSize, "bytes/thread"); diff --git a/hipamd/tests/src/cppstd/is_callable_test.hpp b/hipamd/tests/src/cppstd/is_callable_test.hpp index 87e4e35b8b..36fc8c848b 100644 --- a/hipamd/tests/src/cppstd/is_callable_test.hpp +++ b/hipamd/tests/src/cppstd/is_callable_test.hpp @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include using hip_impl::is_callable; diff --git a/hipamd/tests/src/deviceLib/hipComplex.cpp b/hipamd/tests/src/deviceLib/hipComplex.cpp index 09d0ceec77..d60d1e2d3f 100644 --- a/hipamd/tests/src/deviceLib/hipComplex.cpp +++ b/hipamd/tests/src/deviceLib/hipComplex.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" #include "hip/hip_runtime_api.h" -#include "hip/hcc_detail/hip_complex.h" +#include "hip/amd_detail/hip_complex.h" #define LEN 64 #define SIZE 64 << 2 diff --git a/hipamd/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/hipamd/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 295d2f5c95..bded98d3ae 100644 --- a/hipamd/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/hipamd/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -102,7 +102,7 @@ __host__ void double_precision_math_functions() { nearbyint(0.0); // nextafter(0.0); fX = 1.0; // norm(1, &fX); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // norm3d(1.0, 0.0, 0.0); // norm4d(1.0, 0.0, 0.0, 0.0); #endif @@ -113,11 +113,11 @@ __host__ void double_precision_math_functions() { remainder(2.0, 1.0); remquo(1.0, 2.0, &iX); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // rhypot(0.0, 1.0); #endif rint(1.0); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) fX = 1.0; // rnorm(1, &fX); // rnorm3d(0.0, 0.0, 1.0); // rnorm4d(0.0, 0.0, 0.0, 1.0); diff --git a/hipamd/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/hipamd/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 78c2099e8f..c8e7b32a45 100644 --- a/hipamd/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/hipamd/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -66,7 +66,7 @@ __host__ void single_precision_math_functions() { expm1f(0.0f); fabsf(1.0f); fdimf(1.0f, 0.0f); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // fdividef(0.0f, 1.0f); #endif floorf(0.0f); @@ -100,7 +100,7 @@ __host__ void single_precision_math_functions() { nanf("1"); nearbyintf(0.0f); // nextafterf(0.0f); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // norm3df(1.0f, 0.0f, 0.0f); // norm4df(1.0f, 0.0f, 0.0f, 0.0f); #endif @@ -111,11 +111,11 @@ __host__ void single_precision_math_functions() { // rcbrtf(1.0f); remainderf(2.0f, 1.0f); remquof(1.0f, 2.0f, &iX); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // rhypotf(0.0f, 1.0f); #endif rintf(1.0f); -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) // rnorm3df(0.0f, 0.0f, 1.0f); // rnorm4df(0.0f, 0.0f, 0.0f, 1.0f); fX = 1.0f; // rnormf(1, &fX); diff --git a/hipamd/tests/src/deviceLib/hip_ballot.cpp b/hipamd/tests/src/deviceLib/hip_ballot.cpp index 324047a6b1..52a597b78f 100644 --- a/hipamd/tests/src/deviceLib/hip_ballot.cpp +++ b/hipamd/tests/src/deviceLib/hip_ballot.cpp @@ -34,7 +34,7 @@ __global__ void gpu_ballot(unsigned int* device_ballot, int Num_Warps_per_Block, int pshift) { int tid = threadIdx.x + blockIdx.x * blockDim.x; const unsigned int warp_num = threadIdx.x >> pshift; -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ atomicAdd(&device_ballot[warp_num + blockIdx.x * Num_Warps_per_Block], __popcll(__ballot(tid - 245))); #else diff --git a/hipamd/tests/src/deviceLib/hip_test_ldg.cpp b/hipamd/tests/src/deviceLib/hip_test_ldg.cpp index 0f97c1f0ad..27fc24a201 100644 --- a/hipamd/tests/src/deviceLib/hip_test_ldg.cpp +++ b/hipamd/tests/src/deviceLib/hip_test_ldg.cpp @@ -35,7 +35,7 @@ THE SOFTWARE. #include "hip/hip_vector_types.h" #include "test_common.h" -#if (__hcc_workweek__ >= 16164) || defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_CLANG_ONLY__) +#if (__hcc_workweek__ >= 16164) || defined(__HIP_PLATFORM_NVIDIA__) || defined(__HIP_CLANG_ONLY__) #define HIP_ASSERT(x) (assert((x) == hipSuccess)) diff --git a/hipamd/tests/src/dynamicLoading/bit_extract_kernel.cpp b/hipamd/tests/src/dynamicLoading/bit_extract_kernel.cpp index 54b33bdcf1..b6df629070 100644 --- a/hipamd/tests/src/dynamicLoading/bit_extract_kernel.cpp +++ b/hipamd/tests/src/dynamicLoading/bit_extract_kernel.cpp @@ -25,9 +25,9 @@ extern "C" __global__ void bit_extract_kernel(uint32_t* C_d, const uint32_t* size_t stride = hipBlockDim_x * hipGridDim_x; for (size_t i = offset; i < N; i += stride) { -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ C_d[i] = __bitextract_u32(A_d[i], 8, 4); -#else /* defined __HIP_PLATFORM_NVCC__ or other path */ +#else /* defined __HIP_PLATFORM_NVIDIA__ or other path */ C_d[i] = ((A_d[i] & 0xf00) >> 8); #endif } diff --git a/hipamd/tests/src/experimental/xcompile/gapi.sh b/hipamd/tests/src/experimental/xcompile/gapi.sh index d1b3936dbf..ab8f481f05 100755 --- a/hipamd/tests/src/experimental/xcompile/gapi.sh +++ b/hipamd/tests/src/experimental/xcompile/gapi.sh @@ -1,9 +1,9 @@ #!/bin/bash -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hHipApi.o -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include hHipApi.o gHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -lm -o gApi +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include hHipApi.o gHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -lm -o gApi diff --git a/hipamd/tests/src/experimental/xcompile/ghipapi.sh b/hipamd/tests/src/experimental/xcompile/ghipapi.sh index ac424871ef..3e79821cf9 100755 --- a/hipamd/tests/src/experimental/xcompile/ghipapi.sh +++ b/hipamd/tests/src/experimental/xcompile/ghipapi.sh @@ -1,8 +1,8 @@ #!/bin/bash -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hHipApi.o hipcc hHipApi.o gHipApi.o -o gHipApi diff --git a/hipamd/tests/src/experimental/xcompile/gxxapi.sh b/hipamd/tests/src/experimental/xcompile/gxxapi.sh index 9625f94380..592f7956d4 100755 --- a/hipamd/tests/src/experimental/xcompile/gxxapi.sh +++ b/hipamd/tests/src/experimental/xcompile/gxxapi.sh @@ -1,8 +1,8 @@ #!/bin/bash -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hxxHipApi.o +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c hxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o hxxHipApi.o -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxHipApi.o hxxHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxApi +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxHipApi.o hxxHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxApi diff --git a/hipamd/tests/src/experimental/xcompile/gxxhipapi.sh b/hipamd/tests/src/experimental/xcompile/gxxhipapi.sh index 690bccaacb..43321f2fe0 100755 --- a/hipamd/tests/src/experimental/xcompile/gxxhipapi.sh +++ b/hipamd/tests/src/experimental/xcompile/gxxhipapi.sh @@ -1,8 +1,8 @@ #!/bin/bash -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o hipcc -c hxxHipApi.cpp -o hxxHipApi.o -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxHipApi.o hxxHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxHipApi.o hxxHipApi.o ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi diff --git a/hipamd/tests/src/experimental/xcompile/hipapig.sh b/hipamd/tests/src/experimental/xcompile/hipapig.sh index 47cf811bf9..bb465b1824 100755 --- a/hipamd/tests/src/experimental/xcompile/hipapig.sh +++ b/hipamd/tests/src/experimental/xcompile/hipapig.sh @@ -1,3 +1,3 @@ #!/bin/bash -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include gApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -lm -o gApi +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include gApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -lm -o gApi diff --git a/hipamd/tests/src/experimental/xcompile/hipapigxx.sh b/hipamd/tests/src/experimental/xcompile/hipapigxx.sh index 1b675964bd..97f8080048 100755 --- a/hipamd/tests/src/experimental/xcompile/hipapigxx.sh +++ b/hipamd/tests/src/experimental/xcompile/hipapigxx.sh @@ -1,3 +1,3 @@ #!/bin/bash -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxApi +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include gxxApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxApi diff --git a/hipamd/tests/src/experimental/xcompile/hipg.sh b/hipamd/tests/src/experimental/xcompile/hipg.sh index 799cc164b2..a143e7d1b6 100755 --- a/hipamd/tests/src/experimental/xcompile/hipg.sh +++ b/hipamd/tests/src/experimental/xcompile/hipg.sh @@ -1,6 +1,6 @@ #!/bin/bash -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o hipcc -c hHip.c -o hHip.o diff --git a/hipamd/tests/src/experimental/xcompile/hipgapi.sh b/hipamd/tests/src/experimental/xcompile/hipgapi.sh index d6919832e2..3f78d5ba33 100755 --- a/hipamd/tests/src/experimental/xcompile/hipgapi.sh +++ b/hipamd/tests/src/experimental/xcompile/hipgapi.sh @@ -1,6 +1,6 @@ #!/bin/bash -gcc -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o +gcc -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gHipApi.c ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gHipApi.o hipcc -c hHipApi.c -o hHipApi.o diff --git a/hipamd/tests/src/experimental/xcompile/hipgxx.sh b/hipamd/tests/src/experimental/xcompile/hipgxx.sh index 19340cfcaf..0d3dea200f 100755 --- a/hipamd/tests/src/experimental/xcompile/hipgxx.sh +++ b/hipamd/tests/src/experimental/xcompile/hipgxx.sh @@ -1,6 +1,6 @@ #!/bin/bash -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o hipcc -c hxxHip.cpp -o hxxHip.o diff --git a/hipamd/tests/src/experimental/xcompile/hipgxxapi.sh b/hipamd/tests/src/experimental/xcompile/hipgxxapi.sh index 8d3f61b941..3b475a133b 100755 --- a/hipamd/tests/src/experimental/xcompile/hipgxxapi.sh +++ b/hipamd/tests/src/experimental/xcompile/hipgxxapi.sh @@ -1,6 +1,6 @@ #!/bin/bash -g++ -D__HIP_PLATFORM_HCC__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o +g++ -D__HIP_PLATFORM_AMD__= -I${HIP_PATH}/include -I${HCC_HOME}/include -c gxxHipApi.cpp ${HIP_PATH}/lib/device_util.cpp.o ${HIP_PATH}/lib/hip_device.cpp.o ${HIP_PATH}/lib/hip_error.cpp.o ${HIP_PATH}/lib/hip_event.cpp.o ${HIP_PATH}/lib/hip_hcc.cpp.o ${HIP_PATH}/lib/hip_memory.cpp.o ${HIP_PATH}/lib/hip_peer.cpp.o ${HIP_PATH}/lib/hip_stream.cpp.o ${HIP_PATH}/lib/unpinned_copy_engine.cpp.o -L${HCC_HOME}/lib -lhc_am -L${HSA_PATH}/lib -lhsa-runtime64 -lc++ -lmcwamp -ldl -o gxxHipApi.o hipcc -c hxxHipApi.cpp -o hxxHipApi.o diff --git a/hipamd/tests/src/g++/hipMalloc.cpp b/hipamd/tests/src/g++/hipMalloc.cpp index 69f3433e6a..d0533b2ec5 100644 --- a/hipamd/tests/src/g++/hipMalloc.cpp +++ b/hipamd/tests/src/g++/hipMalloc.cpp @@ -18,7 +18,7 @@ * */ /* HIT_START - * BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_HCC__ -I%hip-path/include -I%rocm-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static + * BUILD_CMD: hipMalloc %cxx -D__HIP_PLATFORM_AMD__ -I%hip-path/include -I/opt/rocm/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t -std=c++11 EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * TEST: %t EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_LIB_TYPE static * HIT_END */ diff --git a/hipamd/tests/src/gcc/LaunchKernel.c b/hipamd/tests/src/gcc/LaunchKernel.c index bac8a8f3d1..658b6c9df0 100644 --- a/hipamd/tests/src/gcc/LaunchKernel.c +++ b/hipamd/tests/src/gcc/LaunchKernel.c @@ -20,7 +20,7 @@ /* HIT_START * BUILD_CMD: gpu.o %hc -I%hip-path/include -g -c %S/gpu.cpp -o %T/gpu.o EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr - * BUILD_CMD: launchkernel.o %hc -D__HIP_PLATFORM_HCC__ -g -I%hip-path/include -c %S/LaunchKernel.c -o %T/launchkernel.o EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr + * BUILD_CMD: launchkernel.o %hc -D__HIP_PLATFORM_AMD__ -g -I%hip-path/include -c %S/LaunchKernel.c -o %T/launchkernel.o EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr * BUILD_CMD: LaunchKernel %hc %T/launchkernel.o %T/gpu.o -g -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/%t DEPENDS gpu.o launchkernel.o EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr * TEST: %t EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr * HIT_END diff --git a/hipamd/tests/src/gcc/hipMalloc.c b/hipamd/tests/src/gcc/hipMalloc.c index cec4a4bbaf..880dafbef6 100644 --- a/hipamd/tests/src/gcc/hipMalloc.c +++ b/hipamd/tests/src/gcc/hipMalloc.c @@ -18,8 +18,8 @@ * */ /* HIT_START - * BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_NVCC__ -I%hip-path/include -I/usr/local/cuda/include %S/%s -o %T/hipMalloc_nv -L/usr/local/cuda/lib64 -lcudart EXCLUDE_HIP_PLATFORM amd - * BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_HCC__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr + * BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_NVIDIA__ -I%hip-path/include -I/usr/local/cuda/include %S/%s -o %T/hipMalloc_nv -L/usr/local/cuda/lib64 -lcudart EXCLUDE_HIP_PLATFORM amd + * BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_AMD__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libamdhip64.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr * TEST: hipMalloc_nv EXCLUDE_HIP_PLATFORM amd * TEST: hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvidia EXCLUDE_HIP_RUNTIME rocclr * HIT_END diff --git a/hipamd/tests/src/hipPointerAttrib.cpp b/hipamd/tests/src/hipPointerAttrib.cpp index b3f08efff0..c5eeedbc4b 100644 --- a/hipamd/tests/src/hipPointerAttrib.cpp +++ b/hipamd/tests/src/hipPointerAttrib.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. #include "test_common.h" #include -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #include "hc_am.hpp" #endif @@ -289,7 +289,7 @@ void clusterAllocs(int numAllocs, size_t minSize, size_t maxSize) { reference[i]._pointer = ptr; } -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ if (p_verbose & 0x2) { printf("Tracker after insertions:\n"); hc::am_memtracker_print(); @@ -327,7 +327,7 @@ void clusterAllocs(int numAllocs, size_t minSize, size_t maxSize) { } } -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ if (p_verbose & 0x2) { printf("Tracker after cleanup:\n"); hc::am_memtracker_print(); @@ -392,7 +392,7 @@ void thread_query(void* ptr, const hipPointerAttribute_t* refAttrib) { } -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ //--- // Add pointers to tracker very quickly, then remove them quickly: enum Dir { Up, Down }; @@ -511,7 +511,7 @@ int main(int argc, char* argv[]) { } -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ if (p_tests & 0x10) { srand(0x400); testMultiThreaded_2(); diff --git a/hipamd/tests/src/kernel/hipDynamicShared.cpp b/hipamd/tests/src/kernel/hipDynamicShared.cpp index e26ca34684..b8123d1d05 100644 --- a/hipamd/tests/src/kernel/hipDynamicShared.cpp +++ b/hipamd/tests/src/kernel/hipDynamicShared.cpp @@ -49,7 +49,7 @@ template __global__ void testExternSharedKernel(const T* A_d, const T* B_d, T* C_d, size_t numElements, size_t groupElements) { // declare dynamic shared memory -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) HIP_DYNAMIC_SHARED(T, sdata) #else HIP_DYNAMIC_SHARED(__align__(sizeof(T)) unsigned char, my_sdata) diff --git a/hipamd/tests/src/kernel/inline_asm_vadd.cpp b/hipamd/tests/src/kernel/inline_asm_vadd.cpp index 32f1b54403..a45e0098b7 100644 --- a/hipamd/tests/src/kernel/inline_asm_vadd.cpp +++ b/hipamd/tests/src/kernel/inline_asm_vadd.cpp @@ -36,11 +36,11 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA __global__ void vadd_asm(float* out, float* in) { int i = blockDim.x * blockIdx.x + threadIdx.x; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ asm volatile("add.f32 %0,%1,%2;" : "=f"(out[i]) : "f"(in[i]), "f"(out[i])); #endif -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ asm volatile("v_add_f32_e32 %0, %1, %2" : "=v"(out[i]) : "v"(in[i]), "v"(out[i])); #endif } diff --git a/hipamd/tests/src/kernel/launch_bounds.cpp b/hipamd/tests/src/kernel/launch_bounds.cpp index c6b57ea86e..92945bfd89 100644 --- a/hipamd/tests/src/kernel/launch_bounds.cpp +++ b/hipamd/tests/src/kernel/launch_bounds.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) { hipLaunchKernel(myKern, dim3(blocks), dim3(p_blockSize), 0, 0, C_d, A_d, N, 0); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ cudaFuncAttributes attrib; cudaFuncGetAttributes(&attrib, myKern); printf("binaryVersion = %d\n", attrib.binaryVersion); diff --git a/hipamd/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp b/hipamd/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp index 9463e9e918..cbbbb1b085 100644 --- a/hipamd/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp +++ b/hipamd/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp @@ -136,7 +136,7 @@ int main(int argc, char* argv[]) { CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeCooperativeLaunch, props.cooperativeLaunch)); CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeCooperativeMultiDeviceLaunch, props.cooperativeMultiDeviceLaunch)); -#ifndef __HIP_PLATFORM_NVCC__ +#ifndef __HIP_PLATFORM_NVIDIA__ CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpMemFlushCntl, props.hdpMemFlushCntl)); CHECK(test_hipDeviceGetHdpAddress(deviceId, hipDeviceAttributeHdpRegFlushCntl, props.hdpRegFlushCntl)); #endif diff --git a/hipamd/tests/src/runtimeApi/event/hipEventElapsedTime.cpp b/hipamd/tests/src/runtimeApi/event/hipEventElapsedTime.cpp index 080fb11649..36e37d21fb 100644 --- a/hipamd/tests/src/runtimeApi/event/hipEventElapsedTime.cpp +++ b/hipamd/tests/src/runtimeApi/event/hipEventElapsedTime.cpp @@ -35,7 +35,7 @@ void NegativeTests(){ hipEvent_t start,end; float tms = 1.0f; HIPASSERT(hipEventElapsedTime(nullptr,start,end) == hipErrorInvalidValue); -#ifndef __HIP_PLATFORM_NVCC__ +#ifndef __HIP_PLATFORM_NVIDIA__ // On NVCC platform API throws seg fault hence skipping HIPASSERT(hipEventElapsedTime(&tms,nullptr,end) == hipErrorInvalidHandle); HIPASSERT(hipEventElapsedTime(&tms,start,nullptr) == hipErrorInvalidHandle); diff --git a/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp b/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp index 04dd74b545..b9c2472c75 100644 --- a/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp +++ b/hipamd/tests/src/runtimeApi/memory/hipHostMalloc.cpp @@ -150,7 +150,7 @@ int main() { int numElements = 1024 * 16; size_t sizeBytes = numElements * sizeof(int); -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ { // Stimulate error condition: int* A = &numElements; diff --git a/hipamd/tests/src/runtimeApi/memory/hipMallocManaged_MultiScenario.cpp b/hipamd/tests/src/runtimeApi/memory/hipMallocManaged_MultiScenario.cpp index 9fbe14a4a7..293218aa78 100644 --- a/hipamd/tests/src/runtimeApi/memory/hipMallocManaged_MultiScenario.cpp +++ b/hipamd/tests/src/runtimeApi/memory/hipMallocManaged_MultiScenario.cpp @@ -206,7 +206,7 @@ bool NegativeTestsMallocManaged(int NumDevices) { IfTestPassed = false; } -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ // The flag hipMemAttachHost is currently not supported therefore // api should return "hipErrorInvalidValue" for now err = hipMallocManaged(&A, 1024, hipMemAttachHost); @@ -215,7 +215,7 @@ bool NegativeTestsMallocManaged(int NumDevices) { hipGetErrorString(err)); IfTestPassed = false; } -#endif // __HIP_PLATFORM_HCC__ +#endif // __HIP_PLATFORM_AMD__ err = hipMallocManaged(NULL, 0, 0); if (hipErrorInvalidValue != err) { diff --git a/hipamd/tests/src/runtimeApi/memory/hipMemcpy3D.cpp b/hipamd/tests/src/runtimeApi/memory/hipMemcpy3D.cpp index 255a3490b6..1c9185c6cc 100644 --- a/hipamd/tests/src/runtimeApi/memory/hipMemcpy3D.cpp +++ b/hipamd/tests/src/runtimeApi/memory/hipMemcpy3D.cpp @@ -51,7 +51,7 @@ void runTest(int width,int height,int depth, hipChannelFormatKind formatKind) myparms.srcPtr = make_hipPitchedPtr(hData, width * sizeof(T), width, height); myparms.dstArray = arr; myparms.extent = make_hipExtent(width , height, depth); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ myparms.kind = cudaMemcpyHostToDevice; #else myparms.kind = hipMemcpyHostToDevice; @@ -65,7 +65,7 @@ void runTest(int width,int height,int depth, hipChannelFormatKind formatKind) myparms.srcArray = arr; myparms.dstArray = arr1; myparms.extent = make_hipExtent(width, height, depth); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ myparms.kind = cudaMemcpyDeviceToDevice; #else myparms.kind = hipMemcpyDeviceToDevice; @@ -82,7 +82,7 @@ void runTest(int width,int height,int depth, hipChannelFormatKind formatKind) myparms.dstPtr = make_hipPitchedPtr(hOutputData, width * sizeof(T), width, height); myparms.srcArray = arr1; myparms.extent = make_hipExtent(width, height, depth); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ myparms.kind = cudaMemcpyDeviceToHost; #else myparms.kind = hipMemcpyDeviceToHost; diff --git a/hipamd/tests/src/runtimeApi/memory/hipMemset3D.cpp b/hipamd/tests/src/runtimeApi/memory/hipMemset3D.cpp index 1917559f2a..7e9057f305 100644 --- a/hipamd/tests/src/runtimeApi/memory/hipMemset3D.cpp +++ b/hipamd/tests/src/runtimeApi/memory/hipMemset3D.cpp @@ -60,7 +60,7 @@ bool testhipMemset3D(int memsetval,int p_gpuDevice) myparms.dstPtr = make_hipPitchedPtr(A_h, width , numW, numH); myparms.srcPtr = devPitchedPtr; myparms.extent = extent; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ myparms.kind = hipMemcpyKindToCudaMemcpyKind(hipMemcpyDeviceToHost); #else myparms.kind = hipMemcpyDeviceToHost; @@ -111,7 +111,7 @@ bool testhipMemset3DAsync(int memsetval,int p_gpuDevice) myparms.dstPtr = make_hipPitchedPtr(A_h, width , numW, numH); myparms.srcPtr = devPitchedPtr; myparms.extent = extent; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ myparms.kind = hipMemcpyKindToCudaMemcpyKind(hipMemcpyDeviceToHost); #else myparms.kind = hipMemcpyDeviceToHost; diff --git a/hipamd/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp b/hipamd/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp index 22bd683631..b104a648e8 100644 --- a/hipamd/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp +++ b/hipamd/tests/src/runtimeApi/memory/p2p_copy_coherency.cpp @@ -34,7 +34,7 @@ THE SOFTWARE. #define USE_HCC_MEMTRACKER 0 /* Debug flag to show the memtracker periodically */ -#if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_ROCclr__) +#if defined(__HIP_PLATFORM_AMD__) && !defined(__HIP_ROCclr__) #include #else #define USE_HCC_MEMTRACKER 0 diff --git a/hipamd/tests/src/runtimeApi/module/hipModuleLoadUnloadStress.cpp b/hipamd/tests/src/runtimeApi/module/hipModuleLoadUnloadStress.cpp index bc72c5b3b8..ceb9aba502 100644 --- a/hipamd/tests/src/runtimeApi/module/hipModuleLoadUnloadStress.cpp +++ b/hipamd/tests/src/runtimeApi/module/hipModuleLoadUnloadStress.cpp @@ -98,7 +98,7 @@ void testhipModuleLoadDataExUnloadStress() { int main(int argc, char* argv[]) { HipTest::parseStandardArguments(argc, argv, true); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipInit(0)); hipDevice_t device; hipCtx_t context; @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) { } else if (p_tests == 0x3) { testhipModuleLoadDataExUnloadStress(); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif passed(); diff --git a/hipamd/tests/src/runtimeApi/module/hipModuleNegative.cpp b/hipamd/tests/src/runtimeApi/module/hipModuleNegative.cpp index ca19d1dd5f..3ed088e382 100644 --- a/hipamd/tests/src/runtimeApi/module/hipModuleNegative.cpp +++ b/hipamd/tests/src/runtimeApi/module/hipModuleNegative.cpp @@ -101,7 +101,7 @@ void createRandomFile(const char* filename) { /** * Internal Function */ -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ void initHipCtx(hipCtx_t *pcontext) { HIPCHECK(hipInit(0)); hipDevice_t device; @@ -117,7 +117,7 @@ void initHipCtx(hipCtx_t *pcontext) { bool testhipModuleLoadNeg10() { bool TestPassed = false; hipError_t ret; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -127,7 +127,7 @@ bool testhipModuleLoadNeg10() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -141,7 +141,7 @@ bool testhipModuleLoadNeg11() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -151,7 +151,7 @@ bool testhipModuleLoadNeg11() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -168,7 +168,7 @@ bool testhipModuleLoadNeg12() { std::fstream fs; fs.open(FILENAME_EMPTY, std::ios::out); fs.close(); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -178,7 +178,7 @@ bool testhipModuleLoadNeg12() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif remove(FILENAME_EMPTY); @@ -195,7 +195,7 @@ bool testhipModuleLoadNeg13() { hipModule_t Module; // Create a binary file with random numbers createRandomFile(FILENAME_RAND); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -205,7 +205,7 @@ bool testhipModuleLoadNeg13() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif remove(FILENAME_RAND); @@ -220,7 +220,7 @@ bool testhipModuleLoadNeg14() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -230,7 +230,7 @@ bool testhipModuleLoadNeg14() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -244,7 +244,7 @@ bool testhipModuleLoadNeg15() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -253,7 +253,7 @@ bool testhipModuleLoadNeg15() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -267,7 +267,7 @@ bool testhipModuleLoadDataNeg20() { bool TestPassed = false; hipError_t ret; auto buffer = load_file(CODEOBJ_FILE); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -277,7 +277,7 @@ bool testhipModuleLoadDataNeg20() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -291,7 +291,7 @@ bool testhipModuleLoadDataNeg21() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -301,7 +301,7 @@ bool testhipModuleLoadDataNeg21() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -319,7 +319,7 @@ bool testhipModuleLoadDataNeg22() { createRandomFile(FILENAME_RAND); // Open the code object file and copy it in a buffer auto buffer = load_file(FILENAME_RAND); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -329,7 +329,7 @@ bool testhipModuleLoadDataNeg22() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif remove(FILENAME_RAND); @@ -344,7 +344,7 @@ bool testhipModuleLoadDataExNeg30() { hipError_t ret; // Open the code object file and copy it in a buffer auto buffer = load_file(CODEOBJ_FILE); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -354,7 +354,7 @@ bool testhipModuleLoadDataExNeg30() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -368,7 +368,7 @@ bool testhipModuleLoadDataExNeg31() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -378,7 +378,7 @@ bool testhipModuleLoadDataExNeg31() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -396,7 +396,7 @@ bool testhipModuleLoadDataExNeg32() { createRandomFile(FILENAME_RAND); // Open the code object file and copy it in a buffer auto buffer = load_file(FILENAME_RAND); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -406,7 +406,7 @@ bool testhipModuleLoadDataExNeg32() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif remove(FILENAME_RAND); @@ -421,7 +421,7 @@ bool testhipModuleGetFunctionNeg40() { bool TestPassed = false; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -433,7 +433,7 @@ bool testhipModuleGetFunctionNeg40() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -448,7 +448,7 @@ bool testhipModuleGetFunctionNeg41() { hipError_t ret; hipModule_t Module; hipFunction_t Function; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -458,7 +458,7 @@ bool testhipModuleGetFunctionNeg41() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -473,7 +473,7 @@ bool testhipModuleGetFunctionNeg42() { hipError_t ret; hipModule_t Module; hipFunction_t Function; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -485,7 +485,7 @@ bool testhipModuleGetFunctionNeg42() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -500,7 +500,7 @@ bool testhipModuleGetFunctionNeg43() { hipError_t ret; hipModule_t Module; hipFunction_t Function; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -512,7 +512,7 @@ bool testhipModuleGetFunctionNeg43() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -527,7 +527,7 @@ bool testhipModuleGetFunctionNeg44() { hipError_t ret; hipModule_t Module; hipFunction_t Function; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -539,7 +539,7 @@ bool testhipModuleGetFunctionNeg44() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -554,7 +554,7 @@ bool testhipModuleGetFunctionNeg45() { hipError_t ret; hipModule_t Module; hipFunction_t Function; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -566,7 +566,7 @@ bool testhipModuleGetFunctionNeg45() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -581,7 +581,7 @@ bool testhipModuleGetGlobalNeg50() { hipError_t ret; hipModule_t Module; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -593,7 +593,7 @@ bool testhipModuleGetGlobalNeg50() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -608,7 +608,7 @@ bool testhipModuleGetGlobalNeg51() { hipError_t ret; hipModule_t Module; hipDeviceptr_t deviceGlobal; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -620,7 +620,7 @@ bool testhipModuleGetGlobalNeg51() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -636,7 +636,7 @@ bool testhipModuleGetGlobalNeg52() { hipModule_t Module; hipDeviceptr_t deviceGlobal; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -648,7 +648,7 @@ bool testhipModuleGetGlobalNeg52() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -664,7 +664,7 @@ bool testhipModuleGetGlobalNeg53() { hipModule_t Module; hipDeviceptr_t deviceGlobal; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -676,7 +676,7 @@ bool testhipModuleGetGlobalNeg53() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -692,7 +692,7 @@ bool testhipModuleGetGlobalNeg54() { hipModule_t Module; hipDeviceptr_t deviceGlobal; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -704,7 +704,7 @@ bool testhipModuleGetGlobalNeg54() { hipGetErrorString(ret), ret); } HIPCHECK(hipModuleUnload(Module)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -720,7 +720,7 @@ bool testhipModuleGetGlobalNeg55() { hipModule_t Module; hipDeviceptr_t deviceGlobal; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -732,7 +732,7 @@ bool testhipModuleGetGlobalNeg55() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -748,7 +748,7 @@ bool testhipModuleGetGlobalNeg56() { hipModule_t Module; hipDeviceptr_t deviceGlobal; size_t deviceGlobalSize; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -758,7 +758,7 @@ bool testhipModuleGetGlobalNeg56() { printf("Test Passed: Error Code Returned: '%s'(%d)\n", hipGetErrorString(ret), ret); } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; @@ -773,7 +773,7 @@ bool testhipModuleLoadNeg60() { bool TestPassed = true; hipError_t ret; hipModule_t Module; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ hipCtx_t context; initHipCtx(&context); #endif @@ -793,7 +793,7 @@ bool testhipModuleLoadNeg60() { } else { TestPassed &= false; } -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipCtxDestroy(context)); #endif return TestPassed; diff --git a/hipamd/tests/src/runtimeApi/module/hipModuleTexture2dDrv.cpp b/hipamd/tests/src/runtimeApi/module/hipModuleTexture2dDrv.cpp index f3cf20bfa0..8f74f34041 100755 --- a/hipamd/tests/src/runtimeApi/module/hipModuleTexture2dDrv.cpp +++ b/hipamd/tests/src/runtimeApi/module/hipModuleTexture2dDrv.cpp @@ -59,7 +59,7 @@ THE SOFTWARE. #define GRIDDIMZ 1 #define BLOCKDIMZ 1 -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ #define CTX_CREATE() \ hipCtx_t context;\ @@ -79,14 +79,14 @@ void initHipCtx(hipCtx_t *pcontext) { HIPCHECK(hipCtxCreate(pcontext, 0, device)); } -#else // __HIP_PLATFORM_NVCC__ +#else // __HIP_PLATFORM_NVIDIA__ #define CTX_CREATE() #define CTX_DESTROY() #define ARRAY_DESTROY(array) HIPCHECK(hipFreeArray(array)); #define HIP_TEX_REFERENCE textureReference* #define HIP_ARRAY hipArray* -#endif // __HIP_PLATFORM_NVCC__ +#endif // __HIP_PLATFORM_NVIDIA__ std::atomic g_thTestPassed(1); @@ -271,7 +271,7 @@ template void copyBuffer2Array(unsigned int width, ) { hip_Memcpy2D copyParam; memset(©Param, 0, sizeof(copyParam)); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ copyParam.dstMemoryType = CU_MEMORYTYPE_ARRAY; copyParam.srcMemoryType = CU_MEMORYTYPE_HOST; copyParam.dstArray = *array; @@ -293,7 +293,7 @@ template void assignArray2TexRef(hipArray_Format format, T array ) { HIP_TEX_REFERENCE texref; -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ HIPCHECK(hipModuleGetTexRef(&texref, Module, texRefName)); HIPCHECK(hipTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP)); HIPCHECK(hipTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP)); @@ -351,7 +351,7 @@ template bool testTexType(hipArray_Format format, HIPCHECK(hipModuleLoad(&Module, CODEOBJ_FILE)); HIP_ARRAY array; allocInitArray(width, height, format, &array); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ // Copy from hData to array using hipMemcpyParam2D copyBuffer2Array(width, height, hData, &array); // Get tex reference from the loaded kernel file @@ -438,7 +438,7 @@ template bool testTexMultStream(const std::vector& buffer, HIPCHECK(hipModuleLoadData(&Module, &buffer[0])); HIP_ARRAY array; allocInitArray(width, height, format, &array); -#ifdef __HIP_PLATFORM_NVCC__ +#ifdef __HIP_PLATFORM_NVIDIA__ // Copy from hData to array using hipMemcpyParam2D copyBuffer2Array(width, height, hData, &array); // Get tex reference from the loaded kernel file diff --git a/hipamd/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp b/hipamd/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp index 39323fa930..36161ccae0 100644 --- a/hipamd/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp +++ b/hipamd/tests/src/runtimeApi/occupancy/hipOccupancyMaxPotentialBlockSize.cpp @@ -79,7 +79,7 @@ bool argValidation() { TestPassed &= false; } -#ifndef __HIP_PLATFORM_NVCC__ +#ifndef __HIP_PLATFORM_NVIDIA__ // nvcc doesnt support kernelfunc(NULL) for api ret = hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, NULL, 0, 0); if (ret != hipErrorInvalidValue) { diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_AltEnqueue.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_AltEnqueue.cpp index 1b33447cde..e8163d7e5c 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_AltEnqueue.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_AltEnqueue.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MStrm_Mgpu.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MStrm_Mgpu.cpp index b1c49f61b5..c71ce345e8 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MStrm_Mgpu.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MStrm_Mgpu.cpp @@ -33,7 +33,7 @@ #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiCalls.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiCalls.cpp index f2c2e5c3ce..a5a1d39108 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiCalls.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiCalls.cpp @@ -34,7 +34,7 @@ #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiThread.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiThread.cpp index 29f6ed5f40..687d79fb10 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiThread.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_MultiThread.cpp @@ -36,7 +36,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp index ec7a796b49..bb1d9f082c 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_StrmSyncTiming.cpp @@ -34,7 +34,7 @@ #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp index e2fb998051..fc723cf9b0 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_ThrdBehaviour.cpp @@ -32,7 +32,7 @@ #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_order.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_order.cpp index d088ad7db5..4a68239b4a 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamACb_order.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamACb_order.cpp @@ -31,7 +31,7 @@ #include #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallback.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallback.cpp index 70c77d7c9f..313000ee2c 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallback.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallback.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "test_common.h" -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallbackCatch.cpp b/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallbackCatch.cpp index b9b2647503..4a0c419a88 100644 --- a/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallbackCatch.cpp +++ b/hipamd/tests/src/runtimeApi/stream/hipStreamAddCallbackCatch.cpp @@ -30,7 +30,7 @@ using TestQueues = std::tuple, QueueHipRt>; #define HIP_ASSERT(x) (assert((x)==hipSuccess)) #define HIP_ASSERT_IGNORE(x,ign) auto err=x; HIP_ASSERT(err==ign ? hipSuccess : err) -#ifdef __HIP_PLATFORM_HCC__ +#ifdef __HIP_PLATFORM_AMD__ #define HIPRT_CB #endif diff --git a/hipamd/tests/src/test_common.h b/hipamd/tests/src/test_common.h index ded14d6fad..6ef1aaff6c 100755 --- a/hipamd/tests/src/test_common.h +++ b/hipamd/tests/src/test_common.h @@ -379,7 +379,7 @@ void freeArrays(T* A_d, T* B_d, T* C_d, T* A_h, T* B_h, T* C_h, bool usePinnedHo freeArraysForHost(A_h, B_h, C_h, usePinnedHost); } -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) template void initArrays2DPitch(T** A_d, T** B_d, T** C_d, size_t* pitch_A, size_t* pitch_B, size_t* pitch_C, size_t numW, size_t numH) { diff --git a/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp b/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp index 04a681fa40..6a267354ff 100644 --- a/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp +++ b/hipamd/tests/src/texture/hipNormalizedFloatValueTex.cpp @@ -116,7 +116,7 @@ int main(int argc, char** argv) hipDeviceProp_t props; HIPCHECK(hipGetDeviceProperties(&props, device)); std::cout << "Device :: " << props.name << std::endl; - #ifdef __HIP_PLATFORM_HCC__ + #ifdef __HIP_PLATFORM_AMD__ std::cout << "Arch - AMD GPU :: " << props.gcnArch << std::endl; #endif diff --git a/hipamd/tests/unit/test_common.h b/hipamd/tests/unit/test_common.h index ae6f1cba04..e5310b3122 100755 --- a/hipamd/tests/unit/test_common.h +++ b/hipamd/tests/unit/test_common.h @@ -359,7 +359,7 @@ bool freeArrays(T* A_d, T* B_d, T* C_d, T* A_h, T* B_h, T* C_h, bool usePinnedHo return freeArraysForHost(A_h, B_h, C_h, usePinnedHost); } -#if defined(__HIP_PLATFORM_HCC__) +#if defined(__HIP_PLATFORM_AMD__) template bool initArrays2DPitch(T** A_d, T** B_d, T** C_d, size_t* pitch_A, size_t* pitch_B, size_t* pitch_C, size_t numW, size_t numH) {