From f29bfc159f605e0976aa02ccf13ab546d80cf0a8 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 15 Jul 2020 10:29:22 -0500 Subject: [PATCH 01/31] Added cmake logic to install components into rocm-bin --- utils/CMakeLists.txt | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 8f21d22..ae01915 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -151,20 +151,37 @@ target_link_libraries(prepare-builtins ${llvm_libs} ZLIB::ZLIB) add_custom_target(prepare-builtins-bin ALL DEPENDS ${PREPARE_BUILTINS}) -install(PROGRAMS - # ${CMAKE_CURRENT_SOURCE_DIR}/bin/bundle.sh - # ${CMAKE_CURRENT_SOURCE_DIR}/bin/unbundle.sh - ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh - ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh - ${CMAKE_CURRENT_BINARY_DIR}/aompcc - ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion - ${CMAKE_CURRENT_BINARY_DIR}/mymcpu - ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt - ${CMAKE_CURRENT_BINARY_DIR}/aompversion - ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu - ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch - ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch - ${CMAKE_CURRENT_BINARY_DIR}/clang-ocl - ${CMAKE_CURRENT_BINARY_DIR}/modulefile - ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins +if(${AOMP_STANDALONE_BUILD}) + install(PROGRAMS + # ${CMAKE_CURRENT_SOURCE_DIR}/bin/bundle.sh + # ${CMAKE_CURRENT_SOURCE_DIR}/bin/unbundle.sh + ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh + ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh + ${CMAKE_CURRENT_BINARY_DIR}/aompcc + ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion + ${CMAKE_CURRENT_BINARY_DIR}/mymcpu + ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt + ${CMAKE_CURRENT_BINARY_DIR}/aompversion + ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu + ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch + ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch + ${CMAKE_CURRENT_BINARY_DIR}/clang-ocl + ${CMAKE_CURRENT_BINARY_DIR}/modulefile + ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins DESTINATION "bin") + +else() + install(PROGRAMS + ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh + ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh + ${CMAKE_CURRENT_BINARY_DIR}/aompcc + ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion + ${CMAKE_CURRENT_BINARY_DIR}/mymcpu + ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt + ${CMAKE_CURRENT_BINARY_DIR}/aompversion + ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu + ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch + ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch + ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins + DESTINATION "rocm-bin") +endif() From b277085bc31708e0c8b0efb92cdb99d045880f6a Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Fri, 4 Sep 2020 13:28:50 -0500 Subject: [PATCH 02/31] Removed utils for UC. --- utils/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index ae01915..1a81505 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -172,16 +172,9 @@ if(${AOMP_STANDALONE_BUILD}) else() install(PROGRAMS - ${CMAKE_CURRENT_BINARY_DIR}/cloc.sh - ${CMAKE_CURRENT_BINARY_DIR}/raja_build.sh - ${CMAKE_CURRENT_BINARY_DIR}/aompcc - ${CMAKE_CURRENT_BINARY_DIR}/aompExtractRegion ${CMAKE_CURRENT_BINARY_DIR}/mymcpu ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt - ${CMAKE_CURRENT_BINARY_DIR}/aompversion ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu - ${CMAKE_CURRENT_SOURCE_DIR}/bin/blt.patch - ${CMAKE_CURRENT_SOURCE_DIR}/bin/raja.patch ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins DESTINATION "rocm-bin") endif() From c21f25e88212538b86293500da7e6419ac0975d5 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Tue, 13 Oct 2020 17:57:07 -0500 Subject: [PATCH 03/31] PR 31 to cleanup libm build for aomp --- aomp-device-libs/libm/CMakeLists.txt | 53 +- aomp-device-libs/libm/src/complex.def | 165 ---- aomp-device-libs/libm/src/libm-amdgcn.c | 888 ---------------------- aomp-device-libs/libm/src/libm-amdgcn.cpp | 169 ---- aomp-device-libs/libm/src/libm-amdgcn.h | 405 ---------- aomp-device-libs/libm/src/libm-nvptx.c | 724 ------------------ aomp-device-libs/libm/src/libm-nvptx.cpp | 273 ------- aomp-device-libs/libm/src/libm-nvptx.h | 583 -------------- aomp-device-libs/libm/src/libm.c | 13 +- aomp-device-libs/libm/src/libm.cpp | 23 - 10 files changed, 25 insertions(+), 3271 deletions(-) delete mode 100644 aomp-device-libs/libm/src/complex.def delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.c delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.cpp delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.h delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.c delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.cpp delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.h delete mode 100644 aomp-device-libs/libm/src/libm.cpp diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt index 4febc8a..939a995 100644 --- a/aomp-device-libs/libm/CMakeLists.txt +++ b/aomp-device-libs/libm/CMakeLists.txt @@ -33,14 +33,6 @@ else() return() endif() -# FIXME DELETE THESE COMMENTS -# Assome rocm-device-libs repository is next to aomp-extras repository -#set(ROCDL ${CMAKE_CURRENT_SOURCE_DIR}/../../../rocm-device-libs) -#set(ROCDL_INC_OCKL ${ROCDL}/ockl/inc) -#set(ROCDL_INC_OCML ${ROCDL}/ocml/inc) -#set(ROCDL_INC_IRIF ${ROCDL}/irif/inc) -#set(HIPINC ${CMAKE_CURRENT_SOURCE_DIR}/../../../hip/include) - #optimization level set(optimization_level 2) @@ -48,10 +40,6 @@ set(OUTPUTDIR ${CMAKE_CURRENT_BINARY_DIR}) macro(build_static_device_bc_lib) foreach(mcpu ${gpulist}) - # set(bundled_filename bundle_cpp.${mcpu}.bc) - # set(bundled_c_filename bundle_c.${mcpu}.bc) - set(bc_filename libm_cpp.${mcpu}.bc) - set(bc_c_filename libm_c.${mcpu}.bc) set(cpu_target x86_64-pc-linux-gnu) if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "ppc64le") set(cpu_target powerpc64le-linux-gnu) @@ -59,17 +47,15 @@ foreach(mcpu ${gpulist}) set(omp_common_args -c - --cuda-device-only + -emit-llvm -target ${cpu_target} -fopenmp -fopenmp-targets=${triple} -Xopenmp-target=${triple} -march=${mcpu} - -emit-llvm - -DNO_LIBM_HEADER_DEFS=1 - -O${optimization_level} - -I${CMAKE_CURRENT_SOURCE_DIR}/src - -I${LLVM_LIBRARY_DIRS}/libdevice/include) + --cuda-device-only + -nocudalib + -O${optimization_level}) if(NOT ${AOMP_STANDALONE_BUILD}) #FIXME Remove NEW_BC_PATH along with reference to /lib/bitcode when non-standalone build switches to new amdgcn path. @@ -81,25 +67,13 @@ foreach(mcpu ${gpulist}) set(omp_common_args "${omp_common_args};--hip-device-lib-path=${BC_DIR}") endif(NOT ${AOMP_STANDALONE_BUILD}) - set(openmp_cmd ${LLVM_INSTALL_PREFIX}/bin/clang++ -std=c++11 ${omp_common_args} - ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.cpp -o ${bc_filename}) set(openmp_c_cmd ${LLVM_INSTALL_PREFIX}/bin/clang ${omp_common_args} - ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c -o ${bc_c_filename}) - set(bc_files ${bc_filename} ${bc_c_filename}) - file(GLOB h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") - # Compile cpp code with openmp to make bundled_filename - add_custom_command( - OUTPUT ${bc_filename} - COMMAND ${openmp_cmd} - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.cpp" ${h_files}) - add_custom_command( - OUTPUT ${bc_c_filename} - COMMAND ${openmp_c_cmd} - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" ${h_files}) + ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c) + add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}.bc - COMMAND ${LLVM_INSTALL_PREFIX}/bin/llvm-link ${bc_files} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DEPENDS ${bc_files} + OUTPUT libm-${systemarch}-${mcpu}.bc + COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" ) add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc) install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc @@ -129,17 +103,18 @@ set(nvptx_numbers $ENV{NVPTXGPUS}) if(NOT nvptx_numbers) set(nvptx_numbers "30,35,50,60,61,70") endif() + set(nvptxgpus) string(REGEX REPLACE "," ";" nvptx_numbers_list ${nvptx_numbers}) foreach(sm_number ${nvptx_numbers_list}) list(APPEND nvptxgpus "sm_${sm_number}") endforeach() + # prepare variables used by build_static_device_bc_lib set(gpulist ${nvptxgpus}) -message(" -- SKIPPING libm generation for ${gpulist} because cuda-clang already defined them.") -#set(systemarch "nvptx") -#set(triple "nvptx64-nvidia-cuda ") -#build_static_device_bc_lib() +set(systemarch "nvptx") +set(triple "nvptx64-nvidia-cuda ") +build_static_device_bc_lib() if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") message("--------------------------------------------") diff --git a/aomp-device-libs/libm/src/complex.def b/aomp-device-libs/libm/src/complex.def deleted file mode 100644 index d0e4948..0000000 --- a/aomp-device-libs/libm/src/complex.def +++ /dev/null @@ -1,165 +0,0 @@ -double _Complex __muldc3(double __a, double __b, double __c, - double __d) { - double __ac = __a * __c; - double __bd = __b * __d; - double __ad = __a * __d; - double __bc = __b * __c; - double _Complex z; - __real__(z) = __ac - __bd; - __imag__(z) = __ad + __bc; - if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { - int __recalc = 0; - if (_ISINFd(__a) || _ISINFd(__b)) { - __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a); - __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b); - if (_ISNANd(__c)) - __c = _COPYSIGNd(0, __c); - if (_ISNANd(__d)) - __d = _COPYSIGNd(0, __d); - __recalc = 1; - } - if (_ISINFd(__c) || _ISINFd(__d)) { - __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c); - __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d); - if (_ISNANd(__a)) - __a = _COPYSIGNd(0, __a); - if (_ISNANd(__b)) - __b = _COPYSIGNd(0, __b); - __recalc = 1; - } - if (!__recalc && - (_ISINFd(__ac) || _ISINFd(__bd) || _ISINFd(__ad) || _ISINFd(__bc))) { - if (_ISNANd(__a)) - __a = _COPYSIGNd(0, __a); - if (_ISNANd(__b)) - __b = _COPYSIGNd(0, __b); - if (_ISNANd(__c)) - __c = _COPYSIGNd(0, __c); - if (_ISNANd(__d)) - __d = _COPYSIGNd(0, __d); - __recalc = 1; - } - if (__recalc) { - // Can't use std::numeric_limits::infinity() -- that doesn't have - // a device overload (and isn't constexpr before C++11, naturally). - __real__(z) = __builtin_huge_val() * (__a * __c - __b * __d); - __imag__(z) = __builtin_huge_val() * (__a * __d + __b * __c); - } - } - return z; -} - -float _Complex __mulsc3(float __a, float __b, float __c, float __d) { - float __ac = __a * __c; - float __bd = __b * __d; - float __ad = __a * __d; - float __bc = __b * __c; - float _Complex z; - __real__(z) = __ac - __bd; - __imag__(z) = __ad + __bc; - if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { - int __recalc = 0; - if (_ISINFf(__a) || _ISINFf(__b)) { - __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); - __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); - if (_ISNANf(__c)) - __c = _COPYSIGNf(0, __c); - if (_ISNANf(__d)) - __d = _COPYSIGNf(0, __d); - __recalc = 1; - } - if (_ISINFf(__c) || _ISINFf(__d)) { - __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); - __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); - if (_ISNANf(__a)) - __a = _COPYSIGNf(0, __a); - if (_ISNANf(__b)) - __b = _COPYSIGNf(0, __b); - __recalc = 1; - } - if (!__recalc && - (_ISINFf(__ac) || _ISINFf(__bd) || _ISINFf(__ad) || _ISINFf(__bc))) { - if (_ISNANf(__a)) - __a = _COPYSIGNf(0, __a); - if (_ISNANf(__b)) - __b = _COPYSIGNf(0, __b); - if (_ISNANf(__c)) - __c = _COPYSIGNf(0, __c); - if (_ISNANf(__d)) - __d = _COPYSIGNf(0, __d); - __recalc = 1; - } - if (__recalc) { - __real__(z) = __builtin_huge_valf() * (__a * __c - __b * __d); - __imag__(z) = __builtin_huge_valf() * (__a * __d + __b * __c); - } - } - return z; -} - -double _Complex __divdc3(double __a, double __b, double __c, - double __d) { - int __ilogbw = 0; - double __logbw = _LOGBd(fmax(_ABSd(__c), _ABSd(__d))); - if (_ISFINITEd(__logbw)) { - __ilogbw = (int)__logbw; - __c = _SCALBNd(__c, -__ilogbw); - __d = _SCALBNd(__d, -__ilogbw); - } - double __denom = __c * __c + __d * __d; - double _Complex z; - __real__(z) = _SCALBNd((__a * __c + __b * __d) / __denom, -__ilogbw); - __imag__(z) = _SCALBNd((__b * __c - __a * __d) / __denom, -__ilogbw); - if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { - if ((__denom == 0.0) && (!_ISNANd(__a) || !_ISNANd(__b))) { - __real__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __a; - __imag__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __b; - } else if ((_ISINFd(__a) || _ISINFd(__b)) && _ISFINITEd(__c) && - _ISFINITEd(__d)) { - __a = _COPYSIGNd(_ISINFd(__a) ? 1.0 : 0.0, __a); - __b = _COPYSIGNd(_ISINFd(__b) ? 1.0 : 0.0, __b); - __real__(z) = __builtin_huge_val() * (__a * __c + __b * __d); - __imag__(z) = __builtin_huge_val() * (__b * __c - __a * __d); - } else if (_ISINFd(__logbw) && __logbw > 0.0 && _ISFINITEd(__a) && - _ISFINITEd(__b)) { - __c = _COPYSIGNd(_ISINFd(__c) ? 1.0 : 0.0, __c); - __d = _COPYSIGNd(_ISINFd(__d) ? 1.0 : 0.0, __d); - __real__(z) = 0.0 * (__a * __c + __b * __d); - __imag__(z) = 0.0 * (__b * __c - __a * __d); - } - } - return z; -} - -float _Complex __divsc3(float __a, float __b, float __c, float __d) { - int __ilogbw = 0; - float __logbw = _LOGBf(fmaxf(_ABSf(__c), _ABSf(__d))); - if (_ISFINITEf(__logbw)) { - __ilogbw = (int)__logbw; - __c = _SCALBNf(__c, -__ilogbw); - __d = _SCALBNf(__d, -__ilogbw); - } - float __denom = __c * __c + __d * __d; - float _Complex z; - __real__(z) = _SCALBNf((__a * __c + __b * __d) / __denom, -__ilogbw); - __imag__(z) = _SCALBNf((__b * __c - __a * __d) / __denom, -__ilogbw); - if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { - if ((__denom == 0) && (!_ISNANf(__a) || !_ISNANf(__b))) { - __real__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __a; - __imag__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __b; - } else if ((_ISINFf(__a) || _ISINFf(__b)) && _ISFINITEf(__c) && - _ISFINITEf(__d)) { - __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); - __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); - __real__(z) = __builtin_huge_valf() * (__a * __c + __b * __d); - __imag__(z) = __builtin_huge_valf() * (__b * __c - __a * __d); - } else if (_ISINFf(__logbw) && __logbw > 0 && _ISFINITEf(__a) && - _ISFINITEf(__b)) { - __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); - __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); - __real__(z) = 0 * (__a * __c + __b * __d); - __imag__(z) = 0 * (__b * __c - __a * __d); - } - } - return z; -} diff --git a/aomp-device-libs/libm/src/libm-amdgcn.c b/aomp-device-libs/libm/src/libm-amdgcn.c deleted file mode 100644 index e9471b6..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.c +++ /dev/null @@ -1,888 +0,0 @@ -//===--------- libm/libm-amdgcn.c -----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include "libm-amdgcn.h" - -#define __private __attribute__((address_space(5))) -#define USED __attribute__((used)) -#pragma omp declare target -unsigned long long __make_mantissa_base8(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '7') r = (r * 8u) + tmp - '0'; - else return 0; - - ++tagp; - } - - return r; -} - -unsigned long long __make_mantissa_base10(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '9') r = (r * 10u) + tmp - '0'; - else return 0; - - ++tagp; - } - - return r; -} - - -unsigned long long __make_mantissa_base16(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '9') r = (r * 16u) + tmp - '0'; - else if (tmp >= 'a' && tmp <= 'f') r = (r * 16u) + tmp - 'a' + 10; - else if (tmp >= 'A' && tmp <= 'F') r = (r * 16u) + tmp - 'A' + 10; - else return 0; - - ++tagp; - } - - return r; -} - - -unsigned long long __make_mantissa(const char* tagp) -{ - if (!tagp) return 0u; - - if (*tagp == '0') { - ++tagp; - - if (*tagp == 'x' || *tagp == 'X') return __make_mantissa_base16(tagp); - else return __make_mantissa_base8(tagp); - } - - return __make_mantissa_base10(tagp); -} - -// BEGIN FLOAT - -float acosf(float x) { return __ocml_acos_f32(x); } - -float acoshf(float x) { return __ocml_acosh_f32(x); } - -float asinf(float x) { return __ocml_asin_f32(x); } - -float asinhf(float x) { return __ocml_asinh_f32(x); } - -float atan2f(float x, float y) { return __ocml_atan2_f32(x, y); } - -float atanf(float x) { return __ocml_atan_f32(x); } - -float atanhf(float x) { return __ocml_atanh_f32(x); } - -float cbrtf(float x) { return __ocml_cbrt_f32(x); } - -float ceilf(float x) { return __ocml_ceil_f32(x); } - -float copysignf(float x, float y) { return __ocml_copysign_f32(x, y); } - -USED float cosf(float x) { return __ocml_cos_f32(x); } - -float coshf(float x) { return __ocml_cosh_f32(x); } - -float cospif(float x) { return __ocml_cospi_f32(x); } - -float cyl_bessel_i0f(float x) { return __ocml_i0_f32(x); } - -float cyl_bessel_i1f(float x) { return __ocml_i1_f32(x); } - -float erfcf(float x) { return __ocml_erfc_f32(x); } - -float erfcinvf(float x) { return __ocml_erfcinv_f32(x); } - -float erfcxf(float x) { return __ocml_erfcx_f32(x); } - -float erff(float x) { return __ocml_erf_f32(x); } - -float erfinvf(float x) { return __ocml_erfinv_f32(x); } - -float exp10f(float x) { return __ocml_exp10_f32(x); } - -float exp2f(float x) { return __ocml_exp2_f32(x); } - -float expf(float x) { return __ocml_exp_f32(x); } - -float expm1f(float x) { return __ocml_expm1_f32(x); } - -float fabsf(float x) { return __ocml_fabs_f32(x); } - -float fdimf(float x, float y) { return __ocml_fdim_f32(x, y); } - -float fdividef(float x, float y) { return x / y; } - -float floorf(float x) { return __ocml_floor_f32(x); } - -float fmaf(float x, float y, float z) { return __ocml_fma_f32(x, y, z); } - -float fmaxf(float x, float y) { return __ocml_fmax_f32(x, y); } - -float fminf(float x, float y) { return __ocml_fmin_f32(x, y); } - -float fmodf(float x, float y) { return __ocml_fmod_f32(x, y); } - -float frexpf(float x, int* nptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - float r = - __ocml_frexp_f32(x, &tmp); - *nptr = tmp; - - return r; -} - -float hypotf(float x, float y) { return __ocml_hypot_f32(x, y); } - -int ilogbf(float x) { return __ocml_ilogb_f32(x); } - -//int isfinite(float x) { return __ocml_isfinite_f32(x); } -int __finitef(float x) { return __ocml_isfinite_f32(x); } - - -int __isinff(float x) { return __ocml_isinf_f32(x); } - -int __isnanf(float x) { return __ocml_isnan_f32(x); } - -float j0f(float x) { return __ocml_j0_f32(x); } - -float j1f(float x) { return __ocml_j1_f32(x); } - -float jnf(int n, float x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - float x0 = j0f(x); - float x1 = j1f(x); - for (int i = 1; i < n; ++i) { - float x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -float ldexpf(float x, int e) { return __ocml_ldexp_f32(x, e); } - -float lgammaf(float x) { return __ocml_lgamma_f32(x); } - -long long int llrintf(float x) { return __ocml_rint_f32(x); } - -long long int llroundf(float x) { return __ocml_round_f32(x); } - -float log10f(float x) { return __ocml_log10_f32(x); } - -float log1pf(float x) { return __ocml_log1p_f32(x); } - -float log2f(float x) { return __ocml_log2_f32(x); } - -float logbf(float x) { return __ocml_logb_f32(x); } - -float logf(float x) { return __ocml_log_f32(x); } - -long int lrintf(float x) { return __ocml_rint_f32(x); } - -long int lroundf(float x) { return __ocml_round_f32(x); } - -float modff(float x, float* iptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - float r = - __ocml_modf_f32(x, &tmp); - *iptr = tmp; - - return r; -} - -float nanf(const char* tagp) -{ - union { - float val; - struct ieee_float { - unsigned mantissa : 22; - unsigned quiet : 1; - unsigned exponent : 8; - unsigned sign : 1; - } bits; - - // static_assert(sizeof(float) == sizeof(ieee_float), ""); - } tmp; - - tmp.bits.sign = 0u; - tmp.bits.exponent = ~0u; - tmp.bits.quiet = 1u; - tmp.bits.mantissa = __make_mantissa(tagp); - - return tmp.val; -} - -float nearbyintf(float x) { return __ocml_nearbyint_f32(x); } - -float nextafterf(float x, float y) { return __ocml_nextafter_f32(x, y); } - -float norm3df(float x, float y, float z) { return __ocml_len3_f32(x, y, z); } - -float norm4df(float x, float y, float z, float w) -{ - return __ocml_len4_f32(x, y, z, w); -} - -float normcdff(float x) { return __ocml_ncdf_f32(x); } - -float normcdfinvf(float x) { return __ocml_ncdfinv_f32(x); } - -float normf(int dim, const float* a) -{ // TODO: placeholder until OCML adds support. - float r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_sqrt_f32(r); -} - -float powf(float x, float y) { return __ocml_pow_f32(x, y); } - -float rcbrtf(float x) { return __ocml_rcbrt_f32(x); } - -float remainderf(float x, float y) { return __ocml_remainder_f32(x, y); } - -float remquof(float x, float y, int* quo) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - float r = - __ocml_remquo_f32(x, y, &tmp); - *quo = tmp; - - return r; -} - -float rhypotf(float x, float y) { return __ocml_rhypot_f32(x, y); } - -float rintf(float x) { return __ocml_rint_f32(x); } - -float rnorm3df(float x, float y, float z) -{ - return __ocml_rlen3_f32(x, y, z); -} - - -float rnorm4df(float x, float y, float z, float w) -{ - return __ocml_rlen4_f32(x, y, z, w); -} - -float rnormf(int dim, const float* a) -{ // TODO: placeholder until OCML adds support. - float r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_rsqrt_f32(r); -} - -float roundf(float x) { return __ocml_round_f32(x); } - -float rsqrtf(float x) { return __ocml_rsqrt_f32(x); } - -float scalblnf(float x, long int n) -{ - return (n < INT_MAX) ? __ocml_scalbn_f32(x, n) : __ocml_scalb_f32(x, n); -} - -float scalbnf(float x, int n) { return __ocml_scalbn_f32(x, n); } - -int __signbitf(float x) { return __ocml_signbit_f32(x); } - -void sincosf(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincos_f32(x, &tmp); - *cptr = tmp; -} - -void sincospif(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincospi_f32(x, &tmp); - *cptr = tmp; -} - -USED float sinf(float x) { return __ocml_sin_f32(x); } - -float sinhf(float x) { return __ocml_sinh_f32(x); } - -float sinpif(float x) { return __ocml_sinpi_f32(x); } - -USED float sqrtf(float x) { return __ocml_sqrt_f32(x); } - -float tanf(float x) { return __ocml_tan_f32(x); } - -float tanhf(float x) { return __ocml_tanh_f32(x); } - -float tgammaf(float x) { return __ocml_tgamma_f32(x); } - -float truncf(float x) { return __ocml_trunc_f32(x); } - -float y0f(float x) { return __ocml_y0_f32(x); } - -float y1f(float x) { return __ocml_y1_f32(x); } - -float ynf(int n, float x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return y0f(x); - if (n == 1) return y1f(x); - - float x0 = y0f(x); - float x1 = y1f(x); - for (int i = 1; i < n; ++i) { - float x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -// BEGIN INTRINSICS - -float __cosf(float x) { return __llvm_amdgcn_cos_f32(x); } - -float __exp10f(float x) { return __ocml_exp10_f32(x); } - -float __expf(float x) { return __ocml_exp_f32(x); } - -float __fadd_rd(float x, float y) { return __ocml_add_rtp_f32(x, y); } - -float __fadd_rn(float x, float y) { return __ocml_add_rte_f32(x, y); } - -float __fadd_ru(float x, float y) { return __ocml_add_rtn_f32(x, y); } - -float __fadd_rz(float x, float y) { return __ocml_add_rtz_f32(x, y); } - -float __fdiv_rd(float x, float y) { return x / y; } - -float __fdiv_rn(float x, float y) { return x / y; } - -float __fdiv_ru(float x, float y) { return x / y; } - -float __fdiv_rz(float x, float y) { return x / y; } - -float __fdividef(float x, float y) { return x / y; } - -float __fmaf_rd(float x, float y, float z) -{ - return __ocml_fma_rtp_f32(x, y, z); -} - -float __fmaf_rn(float x, float y, float z) -{ - return __ocml_fma_rte_f32(x, y, z); -} - -float __fmaf_ru(float x, float y, float z) -{ - return __ocml_fma_rtn_f32(x, y, z); -} - -float __fmaf_rz(float x, float y, float z) -{ - return __ocml_fma_rtz_f32(x, y, z); -} - -float __fmul_rd(float x, float y) { return __ocml_mul_rtp_f32(x, y); } - -float __fmul_rn(float x, float y) { return __ocml_mul_rte_f32(x, y); } - -float __fmul_ru(float x, float y) { return __ocml_mul_rtn_f32(x, y); } - -float __fmul_rz(float x, float y) { return __ocml_mul_rtz_f32(x, y); } - -float __frcp_rd(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_rn(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_ru(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_rz(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frsqrt_rn(float x) { return __llvm_amdgcn_rsq_f32(x); } - -float __fsqrt_rd(float x) { return __ocml_sqrt_rtp_f32(x); } - -float __fsqrt_rn(float x) { return __ocml_sqrt_rte_f32(x); } - -float __fsqrt_ru(float x) { return __ocml_sqrt_rtn_f32(x); } - -float __fsqrt_rz(float x) { return __ocml_sqrt_rtz_f32(x); } - -float __fsub_rd(float x, float y) { return __ocml_sub_rtp_f32(x, y); } - -float __fsub_rn(float x, float y) { return __ocml_sub_rte_f32(x, y); } - -float __fsub_ru(float x, float y) { return __ocml_sub_rtn_f32(x, y); } - -float __fsub_rz(float x, float y) { return __ocml_sub_rtz_f32(x, y); } - -float __log10f(float x) { return __ocml_log10_f32(x); } - -float __log2f(float x) { return __ocml_log2_f32(x); } - -float __logf(float x) { return __ocml_log_f32(x); } - -float __powf(float x, float y) { return __ocml_pow_f32(x, y); } - -float __saturatef(float x) { return (x < 0) ? 0 : ((x > 1) ? 1 : x); } - -void __sincosf(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincos_f32(x, &tmp); - *cptr = tmp; -} - -float __sinf(float x) { return __llvm_amdgcn_sin_f32(x); } - -float __tanf(float x) { return __ocml_tan_f32(x); } -// END INTRINSICS -// END FLOAT - -// BEGIN DOUBLE - -//double abs(double x) { return __ocml_fabs_f64(x); } - -double acos(double x) { return __ocml_acos_f64(x); } - -double acosh(double x) { return __ocml_acosh_f64(x); } - -double asin(double x) { return __ocml_asin_f64(x); } - -double asinh(double x) { return __ocml_asinh_f64(x); } - -double atan(double x) { return __ocml_atan_f64(x); } - -double atan2(double x, double y) { return __ocml_atan2_f64(x, y); } - -double atanh(double x) { return __ocml_atanh_f64(x); } - -double cbrt(double x) { return __ocml_cbrt_f64(x); } - -double ceil(double x) { return __ocml_ceil_f64(x); } - -double copysign(double x, double y) { return __ocml_copysign_f64(x, y); } - -double cos(double x) { return __ocml_cos_f64(x); } - -double cosh(double x) { return __ocml_cosh_f64(x); } - -double cospi(double x) { return __ocml_cospi_f64(x); } - -double cyl_bessel_i0(double x) { return __ocml_i0_f64(x); } - -double cyl_bessel_i1(double x) { return __ocml_i1_f64(x); } - -double erf(double x) { return __ocml_erf_f64(x); } - -double erfc(double x) { return __ocml_erfc_f64(x); } - -double erfcinv(double x) { return __ocml_erfcinv_f64(x); } - -double erfcx(double x) { return __ocml_erfcx_f64(x); } - -double erfinv(double x) { return __ocml_erfinv_f64(x); } - -double exp(double x) { return __ocml_exp_f64(x); } - -double exp10(double x) { return __ocml_exp10_f64(x); } - -double exp2(double x) { return __ocml_exp2_f64(x); } - -double expm1(double x) { return __ocml_expm1_f64(x); } - -double fabs(double x) { return __ocml_fabs_f64(x); } - -double fdim(double x, double y) { return __ocml_fdim_f64(x, y); } - -double fdivide(double x, double y) { return x / y; } - -double floor(double x) { return __ocml_floor_f64(x); } - -double fma(double x, double y, double z) { return __ocml_fma_f64(x, y, z); } - -double fmax(double x, double y) { return __ocml_fmax_f64(x, y); } - -double fmin(double x, double y) { return __ocml_fmin_f64(x, y); } - -double fmod(double x, double y) { return __ocml_fmod_f64(x, y); } - -double frexp(double x, int* nptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - double r = - __ocml_frexp_f64(x, &tmp); - *nptr = tmp; - - return r; -} - -double hypot(double x, double y) { return __ocml_hypot_f64(x, y); } - -int ilogb(double x) { return __ocml_ilogb_f64(x); } - -int __finite(double x) { return __ocml_isfinite_f64(x); } - -//int __isinf(double x) { return __ocml_isinf_f64(x); } - -//int __isnan(double x) { return __ocml_isnan_f64(x); } - -double j0(double x) { return __ocml_j0_f64(x); } - -double j1(double x) { return __ocml_j1_f64(x); } - -double jn(int n, double x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - double x0 = j0f(x); - double x1 = j1f(x); - for (int i = 1; i < n; ++i) { - double x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -double ldexp(double x, int e) { return __ocml_ldexp_f64(x, e); } - -double lgamma(double x) { return __ocml_lgamma_f64(x); } - -long long int llrint(double x) { return __ocml_rint_f64(x); } - -long long int llround(double x) { return __ocml_round_f64(x); } - -double log(double x) { return __ocml_log_f64(x); } - -double log10(double x) { return __ocml_log10_f64(x); } - -double log1p(double x) { return __ocml_log1p_f64(x); } - -double log2(double x) { return __ocml_log2_f64(x); } - -double logb(double x) { return __ocml_logb_f64(x); } - -long int lrint(double x) { return __ocml_rint_f64(x); } - -long int lround(double x) { return __ocml_round_f64(x); } - -double modf(double x, double* iptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - double r = - __ocml_modf_f64(x, &tmp); - *iptr = tmp; - - return r; -} - -double nan(const char* tagp) -{ - union { - double val; - struct ieee_double { - unsigned long long mantissa : 51; - unsigned quiet : 1; - unsigned exponent : 11; - unsigned sign : 1; - } bits; - - // static_assert(sizeof(double) == sizeof(ieee_double), ""); - } tmp; - - tmp.bits.sign = 0u; - tmp.bits.exponent = ~0u; - tmp.bits.quiet = 1u; - tmp.bits.mantissa = __make_mantissa(tagp); - - return tmp.val; -} - -double nearbyint(double x) { return __ocml_nearbyint_f64(x); } - -double nextafter(double x, double y) { return __ocml_nextafter_f64(x, y); } - -double norm(int dim, const double* a) -{ // TODO: placeholder until OCML adds support. - double r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_sqrt_f64(r); -} - -double norm3d(double x, double y, double z) -{ - return __ocml_len3_f64(x, y, z); -} - -double norm4d(double x, double y, double z, double w) -{ - return __ocml_len4_f64(x, y, z, w); -} - -double normcdf(double x) { return __ocml_ncdf_f64(x); } - -double normcdfinv(double x) { return __ocml_ncdfinv_f64(x); } - -double pow(double x, double y) { return __ocml_pow_f64(x, y); } - -double rcbrt(double x) { return __ocml_rcbrt_f64(x); } - -double remainder(double x, double y) { return __ocml_remainder_f64(x, y); } - -double remquo(double x, double y, int* quo) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - double r = - __ocml_remquo_f64(x, y, &tmp); - *quo = tmp; - - return r; -} - -double rhypot(double x, double y) { return __ocml_rhypot_f64(x, y); } - -double rint(double x) { return __ocml_rint_f64(x); } - -double rnorm(int dim, const double* a) -{ // TODO: placeholder until OCML adds support. - double r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_rsqrt_f64(r); -} - -double rnorm3d(double x, double y, double z) -{ - return __ocml_rlen3_f64(x, y, z); -} - -double rnorm4d(double x, double y, double z, double w) -{ - return __ocml_rlen4_f64(x, y, z, w); -} - -double round(double x) { return __ocml_round_f64(x); } - -double rsqrt(double x) { return __ocml_rsqrt_f64(x); } - -double scalbln(double x, long int n) -{ - return (n < INT_MAX) ? __ocml_scalbn_f64(x, n) : __ocml_scalb_f64(x, n); -} - -double scalbn(double x, int n) { return __ocml_scalbn_f64(x, n); } - -int __signbit(double x) { return __ocml_signbit_f64(x); } - -double sin(double x) { return __ocml_sin_f64(x); } - -void sincos(double x, double* sptr, double* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - *sptr = __ocml_sincos_f64(x, &tmp); - *cptr = tmp; -} - -void sincospi(double x, double* sptr, double* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - *sptr = __ocml_sincospi_f64(x, &tmp); - *cptr = tmp; -} - -double sinh(double x) { return __ocml_sinh_f64(x); } - -double sinpi(double x) { return __ocml_sinpi_f64(x); } - -double sqrt(double x) { return __ocml_sqrt_f64(x); } - -double tan(double x) { return __ocml_tan_f64(x); } - -double tanh(double x) { return __ocml_tanh_f64(x); } - -double tgamma(double x) { return __ocml_tgamma_f64(x); } - -double trunc(double x) { return __ocml_trunc_f64(x); } - -double y0(double x) { return __ocml_y0_f64(x); } - -double y1(double x) { return __ocml_y1_f64(x); } - -double yn(int n, double x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - double x0 = j0f(x); - double x1 = j1f(x); - for (int i = 1; i < n; ++i) { - double x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -// BEGIN INTRINSICS - -double __dadd_rd(double x, double y) { return __ocml_add_rtp_f64(x, y); } - -double __dadd_rn(double x, double y) { return __ocml_add_rte_f64(x, y); } - -double __dadd_ru(double x, double y) { return __ocml_add_rtn_f64(x, y); } - -double __dadd_rz(double x, double y) { return __ocml_add_rtz_f64(x, y); } - -double __ddiv_rd(double x, double y) { return x / y; } - -double __ddiv_rn(double x, double y) { return x / y; } - -double __ddiv_ru(double x, double y) { return x / y; } - -double __ddiv_rz(double x, double y) { return x / y; } - -double __dmul_rd(double x, double y) { return __ocml_mul_rtp_f64(x, y); } - -double __dmul_rn(double x, double y) { return __ocml_mul_rte_f64(x, y); } - -double __dmul_ru(double x, double y) { return __ocml_mul_rtn_f64(x, y); } - -double __dmul_rz(double x, double y) { return __ocml_mul_rtz_f64(x, y); } - -double __drcp_rd(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_rn(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_ru(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_rz(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __dsqrt_rd(double x) { return __ocml_sqrt_rtp_f64(x); } - -double __dsqrt_rn(double x) { return __ocml_sqrt_rte_f64(x); } - -double __dsqrt_ru(double x) { return __ocml_sqrt_rtn_f64(x); } - -double __dsqrt_rz(double x) { return __ocml_sqrt_rtz_f64(x); } - -double __dsub_rd(double x, double y) { return __ocml_sub_rtp_f64(x, y); } - -double __dsub_rn(double x, double y) { return __ocml_sub_rte_f64(x, y); } - -double __dsub_ru(double x, double y) { return __ocml_sub_rtn_f64(x, y); } - -double __dsub_rz(double x, double y) { return __ocml_sub_rtz_f64(x, y); } - -double __fma_rd(double x, double y, double z) -{ - return __ocml_fma_rtp_f64(x, y, z); -} - -double __fma_rn(double x, double y, double z) -{ - return __ocml_fma_rte_f64(x, y, z); -} - -double __fma_ru(double x, double y, double z) -{ - return __ocml_fma_rtn_f64(x, y, z); -} - -double __fma_rz(double x, double y, double z) -{ - return __ocml_fma_rtz_f64(x, y, z); -} -// END INTRINSICS -// END DOUBLE - -// Complex functions -#define _ISNANd __ocml_isnan_f64 -#define _ISNANf __isnanf -#define _ISINFd __ocml_isinf_f64 -#define _ISINFf __isinff -#define _ISFINITEd __finite -#define _ISFINITEf __finitef -#define _COPYSIGNd copysign -#define _COPYSIGNf copysignf -#define _SCALBNd scalbn -#define _SCALBNf scalbnf -#define _ABSd fabs -#define _ABSf fabsf -#define _LOGBd logb -#define _LOGBf logbf - -#include "complex.def" - -#undef _ISNANd -#undef _ISNANf -#undef _ISINFd -#undef _ISINFf -#undef _COPYSIGNd -#undef _COPYSIGNf -#undef _ISFINITEd -#undef _ISFINITEf -#undef _SCALBNd -#undef _SCALBNf -#undef _ABSd -#undef _ABSf -#undef _LOGBd -#undef _LOGBf - -#pragma omp end declare target diff --git a/aomp-device-libs/libm/src/libm-amdgcn.cpp b/aomp-device-libs/libm/src/libm-amdgcn.cpp deleted file mode 100644 index 202248d..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.cpp +++ /dev/null @@ -1,169 +0,0 @@ -//===--------- libm/libm-amdgcn.cpp ---------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include "libm-amdgcn.h" -#pragma omp declare target - -/// Do not provide the double overload because the base functions -/// are defined in libm-amdgcn.c. Only provide non-base variants. - -int abs(int x) -{ - int sgn = x >> (sizeof(int) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} -long labs(long x) -{ - long sgn = x >> (sizeof(long) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} -long long llabs(long long x) -{ - long long sgn = x >> (sizeof(long long) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} - -// Template helpers -template -struct __amdgcn_enable_if {}; - -template struct __amdgcn_enable_if { - typedef __T type; -}; - -#define __AMDGCN_OVERLOAD1(__retty, __fn) \ - template \ - typename __amdgcn_enable_if::is_integer, \ - __retty>::type \ - __fn(__T __x) { \ - return ::__fn((double)__x); \ - } - -#define __AMDGCN_OVERLOAD2(__retty, __fn) \ - template \ - typename __amdgcn_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y) { \ - return __fn((double)__x, (double)__y); \ - } -#define __AMDGCN_OVERLOAD3(__retty, __fn) \ - template \ - typename __amdgcn_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized && \ - std::numeric_limits<__T3>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y, __T3 __z) { \ - return __fn((double)__x, (double)__y, (double)__z); \ - } -#define __DEF_FUN1(retty, func) \ -inline \ -float func(float x) \ -{ \ - return func##f(x); \ -} \ -__AMDGCN_OVERLOAD1(retty, func) - -// Define cmath functions with float argument and returns retty. -#define __DEF_FUNI(retty, func) \ -inline \ -retty func(float x) \ -{ \ - return func##f(x); \ -} \ -__AMDGCN_OVERLOAD1(retty, func) - -// define cmath functions with two float arguments. -#define __DEF_FUN2(retty, func) \ -inline \ -float func(float x, float y) \ -{ \ - return func##f(x, y); \ -} \ -__AMDGCN_OVERLOAD2(retty, func) - -// define cmath functions with three float arguments. -#define __DEF_FUN3(retty, func) \ -inline \ -float func(float x, float y, float z) \ -{ \ - return func##f(x, y, z); \ -} \ -__AMDGCN_OVERLOAD3(retty, func) -// cmath functions -long abs(long x) { return labs(x); } -long long abs(long long x) { return llabs(x); } -__DEF_FUN1(double, acos) -__DEF_FUN1(double, acosh) -__DEF_FUN1(double, asin) -__DEF_FUN1(double, asinh) -__DEF_FUN1(double, atan) -__DEF_FUN2(double, atan2); -__DEF_FUN1(double, atanh) -__DEF_FUN1(double, cbrt) -__DEF_FUN1(double, ceil) -__DEF_FUN2(double, copysign); -__DEF_FUN1(double, cos) -__DEF_FUN1(double, cosh) -__DEF_FUN1(double, erf) -__DEF_FUN1(double, erfc) -__DEF_FUN1(double, exp) -__DEF_FUN1(double, exp2) -__DEF_FUN1(double, expm1) -__DEF_FUN1(double, fabs) -__DEF_FUN2(double, fdim); -__DEF_FUN1(double, floor) -__DEF_FUN3(double, fma) -__DEF_FUN2(double, fmax); -__DEF_FUN2(double, fmin); -__DEF_FUN2(double, fmod); -//__AMDGCN_OVERLOAD1(int, fpclassify) -__DEF_FUN2(double, hypot); -__DEF_FUNI(int, ilogb) -//__AMDGCN_OVERLOAD1(bool, isfinite) -__AMDGCN_OVERLOAD2(bool, isgreater); -__AMDGCN_OVERLOAD2(bool, isgreaterequal); -//__AMDGCN_OVERLOAD1(bool, isinf); -__AMDGCN_OVERLOAD2(bool, isless); -__AMDGCN_OVERLOAD2(bool, islessequal); -__AMDGCN_OVERLOAD2(bool, islessgreater); -//__AMDGCN_OVERLOAD1(bool, isnan); -//__AMDGCN_OVERLOAD1(bool, isnormal) -__AMDGCN_OVERLOAD2(bool, isunordered); -__DEF_FUN1(double, lgamma) -__DEF_FUN1(double, log) -__DEF_FUN1(double, log10) -__DEF_FUN1(double, log1p) -__DEF_FUN1(double, log2) -__DEF_FUN1(double, logb) -__DEF_FUNI(long long, llrint) -__DEF_FUNI(long long, llround) -__DEF_FUNI(long, lrint) -__DEF_FUNI(long, lround) -__DEF_FUN1(double, nearbyint); -__DEF_FUN2(double, nextafter); -__DEF_FUN2(double, pow); -__DEF_FUN2(double, remainder); -__DEF_FUN1(double, rint); -__DEF_FUN1(double, round); -//__AMDGCN_OVERLOAD1(bool, signbit) -__DEF_FUN1(double, sin) -__DEF_FUN1(double, sinh) -__DEF_FUN1(double, sqrt) -__DEF_FUN1(double, tan) -__DEF_FUN1(double, tanh) -__DEF_FUN1(double, tgamma) -__DEF_FUN1(double, trunc); - -#pragma omp end declare target diff --git a/aomp-device-libs/libm/src/libm-amdgcn.h b/aomp-device-libs/libm/src/libm-amdgcn.h deleted file mode 100644 index b0d6378..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.h +++ /dev/null @@ -1,405 +0,0 @@ -//===--------- libm/libm-amdgcn.h -----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef __LIBM_AMDGCN_H__ -#define __LIBM_AMDGCN_H__ - - -#if defined(__cplusplus) - extern "C" { -#endif - -// BEGIN FLOAT -__attribute__((const)) -float __ocml_acos_f32(float); -__attribute__((pure)) -float __ocml_acosh_f32(float); -__attribute__((const)) -float __ocml_asin_f32(float); -__attribute__((pure)) -float __ocml_asinh_f32(float); -__attribute__((const)) -float __ocml_atan2_f32(float, float); -__attribute__((const)) -float __ocml_atan_f32(float); -__attribute__((pure)) -float __ocml_atanh_f32(float); -__attribute__((pure)) -float __ocml_cbrt_f32(float); -__attribute__((const)) -float __ocml_ceil_f32(float); -__attribute__((const)) -float __ocml_copysign_f32(float, float); -float __ocml_cos_f32(float); -__attribute__((pure)) -float __ocml_cosh_f32(float); -float __ocml_cospi_f32(float); -float __ocml_i0_f32(float); -float __ocml_i1_f32(float); -__attribute__((pure)) -float __ocml_erfc_f32(float); -__attribute__((pure)) -float __ocml_erfcinv_f32(float); -__attribute__((pure)) -float __ocml_erfcx_f32(float); -__attribute__((pure)) -float __ocml_erf_f32(float); -__attribute__((pure)) -float __ocml_erfinv_f32(float); -__attribute__((pure)) -float __ocml_exp10_f32(float); -__attribute__((pure)) -float __ocml_exp2_f32(float); -__attribute__((pure)) -float __ocml_exp_f32(float); -__attribute__((pure)) -float __ocml_expm1_f32(float); -__attribute__((const)) -float __ocml_fabs_f32(float); -__attribute__((const)) -float __ocml_fdim_f32(float, float); -__attribute__((const)) -float __ocml_floor_f32(float); -__attribute__((const)) -float __ocml_fma_f32(float, float, float); -__attribute__((const)) -float __ocml_fmax_f32(float, float); -__attribute__((const)) -float __ocml_fmin_f32(float, float); -__attribute__((const)) -float __ocml_fmod_f32(float, float); -float __ocml_frexp_f32(float, __attribute__((address_space(5))) int*); -__attribute__((const)) -float __ocml_hypot_f32(float, float); -__attribute__((const)) -int __ocml_ilogb_f32(float); -__attribute__((const)) -int __ocml_isfinite_f32(float); -__attribute__((const)) -int __ocml_isinf_f32(float); -__attribute__((const)) -int __ocml_isnan_f32(float); -float __ocml_j0_f32(float); -float __ocml_j1_f32(float); -__attribute__((const)) -float __ocml_ldexp_f32(float, int); -float __ocml_lgamma_f32(float); -__attribute__((pure)) -float __ocml_log10_f32(float); -__attribute__((pure)) -float __ocml_log1p_f32(float); -__attribute__((pure)) -float __ocml_log2_f32(float); -__attribute__((const)) -float __ocml_logb_f32(float); -__attribute__((pure)) -float __ocml_log_f32(float); -float __ocml_modf_f32(float, __attribute__((address_space(5))) float*); -__attribute__((const)) -float __ocml_nearbyint_f32(float); -__attribute__((const)) -float __ocml_nextafter_f32(float, float); -__attribute__((const)) -float __ocml_len3_f32(float, float, float); -__attribute__((const)) -float __ocml_len4_f32(float, float, float, float); -__attribute__((pure)) -float __ocml_ncdf_f32(float); -__attribute__((pure)) -float __ocml_ncdfinv_f32(float); -__attribute__((pure)) -float __ocml_pow_f32(float, float); -__attribute__((pure)) -float __ocml_rcbrt_f32(float); -__attribute__((const)) -float __ocml_remainder_f32(float, float); -float __ocml_remquo_f32(float, float, __attribute__((address_space(5))) int*); -__attribute__((const)) -float __ocml_rhypot_f32(float, float); -__attribute__((const)) -float __ocml_rint_f32(float); -__attribute__((const)) -float __ocml_rlen3_f32(float, float, float); -__attribute__((const)) -float __ocml_rlen4_f32(float, float, float, float); -__attribute__((const)) -float __ocml_round_f32(float); -__attribute__((pure)) -float __ocml_rsqrt_f32(float); -__attribute__((const)) -float __ocml_scalb_f32(float, float); -__attribute__((const)) -float __ocml_scalbn_f32(float, int); -__attribute__((const)) -int __ocml_signbit_f32(float); -float __ocml_sincos_f32(float, __attribute__((address_space(5))) float*); -float __ocml_sincospi_f32(float, __attribute__((address_space(5))) float*); -float __ocml_sin_f32(float); -__attribute__((pure)) -float __ocml_sinh_f32(float); -float __ocml_sinpi_f32(float); -__attribute__((const)) -float __ocml_sqrt_f32(float); -float __ocml_tan_f32(float); -__attribute__((pure)) -float __ocml_tanh_f32(float); -float __ocml_tgamma_f32(float); -__attribute__((const)) -float __ocml_trunc_f32(float); -float __ocml_y0_f32(float); -float __ocml_y1_f32(float); - -// BEGIN INTRINSICS -__attribute__((const)) -float __ocml_add_rte_f32(float, float); -__attribute__((const)) -float __ocml_add_rtn_f32(float, float); -__attribute__((const)) -float __ocml_add_rtp_f32(float, float); -__attribute__((const)) -float __ocml_add_rtz_f32(float, float); -__attribute__((const)) -float __ocml_sub_rte_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtn_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtp_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtz_f32(float, float); -__attribute__((const)) -float __ocml_mul_rte_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtn_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtp_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtz_f32(float, float); -__attribute__((const)) -float __ocml_sqrt_rte_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtn_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtp_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtz_f32(float); -__attribute__((const)) -float __ocml_fma_rte_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtn_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtp_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtz_f32(float, float, float); - -__attribute__((const)) -float __llvm_amdgcn_cos_f32(float) __asm("llvm.amdgcn.cos.f32"); -__attribute__((const)) -float __llvm_amdgcn_rcp_f32(float) __asm("llvm.amdgcn.rcp.f32"); -__attribute__((const)) -float __llvm_amdgcn_rsq_f32(float) __asm("llvm.amdgcn.rsq.f32"); -__attribute__((const)) -float __llvm_amdgcn_sin_f32(float) __asm("llvm.amdgcn.sin.f32"); -// END INTRINSICS -// END FLOAT - -// BEGIN DOUBLE -__attribute__((const)) -double __ocml_acos_f64(double); -__attribute__((pure)) -double __ocml_acosh_f64(double); -__attribute__((const)) -double __ocml_asin_f64(double); -__attribute__((pure)) -double __ocml_asinh_f64(double); -__attribute__((const)) -double __ocml_atan2_f64(double, double); -__attribute__((const)) -double __ocml_atan_f64(double); -__attribute__((pure)) -double __ocml_atanh_f64(double); -__attribute__((pure)) -double __ocml_cbrt_f64(double); -__attribute__((const)) -double __ocml_ceil_f64(double); -__attribute__((const)) -double __ocml_copysign_f64(double, double); -double __ocml_cos_f64(double); -__attribute__((pure)) -double __ocml_cosh_f64(double); -double __ocml_cospi_f64(double); -double __ocml_i0_f64(double); -double __ocml_i1_f64(double); -__attribute__((pure)) -double __ocml_erfc_f64(double); -__attribute__((pure)) -double __ocml_erfcinv_f64(double); -__attribute__((pure)) -double __ocml_erfcx_f64(double); -__attribute__((pure)) -double __ocml_erf_f64(double); -__attribute__((pure)) -double __ocml_erfinv_f64(double); -__attribute__((pure)) -double __ocml_exp10_f64(double); -__attribute__((pure)) -double __ocml_exp2_f64(double); -__attribute__((pure)) -double __ocml_exp_f64(double); -__attribute__((pure)) -double __ocml_expm1_f64(double); -__attribute__((const)) -double __ocml_fabs_f64(double); -__attribute__((const)) -double __ocml_fdim_f64(double, double); -__attribute__((const)) -double __ocml_floor_f64(double); -__attribute__((const)) -double __ocml_fma_f64(double, double, double); -__attribute__((const)) -double __ocml_fmax_f64(double, double); -__attribute__((const)) -double __ocml_fmin_f64(double, double); -__attribute__((const)) -double __ocml_fmod_f64(double, double); -double __ocml_frexp_f64(double, __attribute__((address_space(5))) int*); -__attribute__((const)) -double __ocml_hypot_f64(double, double); -__attribute__((const)) -int __ocml_ilogb_f64(double); -__attribute__((const)) -int __ocml_isfinite_f64(double); -__attribute__((const)) -int __ocml_isinf_f64(double); -__attribute__((const)) -int __ocml_isnan_f64(double); -double __ocml_j0_f64(double); -double __ocml_j1_f64(double); -__attribute__((const)) -double __ocml_ldexp_f64(double, int); -double __ocml_lgamma_f64(double); -__attribute__((pure)) -double __ocml_log10_f64(double); -__attribute__((pure)) -double __ocml_log1p_f64(double); -__attribute__((pure)) -double __ocml_log2_f64(double); -__attribute__((const)) -double __ocml_logb_f64(double); -__attribute__((pure)) -double __ocml_log_f64(double); -double __ocml_modf_f64(double, __attribute__((address_space(5))) double*); -__attribute__((const)) -double __ocml_nearbyint_f64(double); -__attribute__((const)) -double __ocml_nextafter_f64(double, double); -__attribute__((const)) -double __ocml_len3_f64(double, double, double); -__attribute__((const)) -double __ocml_len4_f64(double, double, double, double); -__attribute__((pure)) -double __ocml_ncdf_f64(double); -__attribute__((pure)) -double __ocml_ncdfinv_f64(double); -__attribute__((pure)) -double __ocml_pow_f64(double, double); -__attribute__((pure)) -double __ocml_rcbrt_f64(double); -__attribute__((const)) -double __ocml_remainder_f64(double, double); -double __ocml_remquo_f64( - double, double, __attribute__((address_space(5))) int*); -__attribute__((const)) -double __ocml_rhypot_f64(double, double); -__attribute__((const)) -double __ocml_rint_f64(double); -__attribute__((const)) -double __ocml_rlen3_f64(double, double, double); -__attribute__((const)) -double __ocml_rlen4_f64(double, double, double, double); -__attribute__((const)) -double __ocml_round_f64(double); -__attribute__((pure)) -double __ocml_rsqrt_f64(double); -__attribute__((const)) -double __ocml_scalb_f64(double, double); -__attribute__((const)) -double __ocml_scalbn_f64(double, int); -__attribute__((const)) -int __ocml_signbit_f64(double); -double __ocml_sincos_f64(double, __attribute__((address_space(5))) double*); -double __ocml_sincospi_f64(double, __attribute__((address_space(5))) double*); -double __ocml_sin_f64(double); -__attribute__((pure)) -double __ocml_sinh_f64(double); -double __ocml_sinpi_f64(double); -__attribute__((const)) -double __ocml_sqrt_f64(double); -double __ocml_tan_f64(double); -__attribute__((pure)) -double __ocml_tanh_f64(double); -double __ocml_tgamma_f64(double); -__attribute__((const)) -double __ocml_trunc_f64(double); -double __ocml_y0_f64(double); -double __ocml_y1_f64(double); - -// BEGIN INTRINSICS -__attribute__((const)) -double __ocml_add_rte_f64(double, double); -__attribute__((const)) -double __ocml_add_rtn_f64(double, double); -__attribute__((const)) -double __ocml_add_rtp_f64(double, double); -__attribute__((const)) -double __ocml_add_rtz_f64(double, double); -__attribute__((const)) -double __ocml_sub_rte_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtn_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtp_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtz_f64(double, double); -__attribute__((const)) -double __ocml_mul_rte_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtn_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtp_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtz_f64(double, double); -__attribute__((const)) -double __ocml_sqrt_rte_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtn_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtp_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtz_f64(double); -__attribute__((const)) -double __ocml_fma_rte_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtn_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtp_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtz_f64(double, double, double); - -__attribute__((const)) -double __llvm_amdgcn_rcp_f64(double) __asm("llvm.amdgcn.rcp.f64"); -__attribute__((const)) -double __llvm_amdgcn_rsq_f64(double) __asm("llvm.amdgcn.rsq.f64"); -// END INTRINSICS -// END DOUBLE - -#if defined(__cplusplus) - } // extern "C" -#endif - -#endif // __LIBM_AMDGCN_H__ diff --git a/aomp-device-libs/libm/src/libm-nvptx.c b/aomp-device-libs/libm/src/libm-nvptx.c deleted file mode 100644 index cb08595..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.c +++ /dev/null @@ -1,724 +0,0 @@ -//===--------- libm/libm-nvptx.c ------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// Ignore all these definitions if clang compiler already defined them -#ifndef __CLANG_CUDA_DEVICE_FUNCTIONS_H__ -#include -#include -#include -#include "libm-nvptx.h" -#pragma omp declare target - -#if 0 -#define __FAST_OR_SLOW(fast, slow) fast -#else -#define __FAST_OR_SLOW(fast, slow) slow -#endif - -// BEGIN FLOAT -float acosf(float __a) { return __nv_acosf(__a); } - -float acoshf(float __a) { return __nv_acoshf(__a); } - -float asinf(float __a) { return __nv_asinf(__a); } - -float asinhf(float __a) { return __nv_asinhf(__a); } - -float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); } - -float atanf(float __a) { return __nv_atanf(__a); } - -float atanhf(float __a) { return __nv_atanhf(__a); } - -float cbrtf(float __a) { return __nv_cbrtf(__a); } - -float ceilf(float __a) { return __nv_ceilf(__a); } - -float copysignf(float __a, float __b) { - return __nv_copysignf(__a, __b); -} - -float cosf(float __a) { - return __FAST_OR_SLOW(__nv_fast_cosf, __nv_cosf)(__a); -} - -float coshf(float __a) { return __nv_coshf(__a); } - -float cospif(float __a) { return __nv_cospif(__a); } - -float cyl_bessel_i0f(float __a) { return __nv_cyl_bessel_i0f(__a); } - -float cyl_bessel_i1f(float __a) { return __nv_cyl_bessel_i1f(__a); } - -float erfcf(float __a) { return __nv_erfcf(__a); } - -float erfcinvf(float __a) { return __nv_erfcinvf(__a); } - -float erfcxf(float __a) { return __nv_erfcxf(__a); } - -float erff(float __a) { return __nv_erff(__a); } - -float erfinvf(float __a) { return __nv_erfinvf(__a); } - -float exp10f(float __a) { return __nv_exp10f(__a); } - -float exp2f(float __a) { return __nv_exp2f(__a); } - -float expf(float __a) { return __nv_expf(__a); } - -float expm1f(float __a) { return __nv_expm1f(__a); } - -float fabsf(float __a) { return __nv_fabsf(__a); } - -float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); } - -float fdividef(float __a, float __b) { -#if __FAST_MATH__ && !__CUDA_PREC_DIV - return __nv_fast_fdividef(__a, __b); -#else - return __a / __b; -#endif -} - -float floorf(float __f) { return __nv_floorf(__f); } - -float fmaf(float __a, float __b, float __c) { - return __nv_fmaf(__a, __b, __c); -} - -float fmaxf(float __a, float __b) { return __nv_fmaxf(__a, __b); } - -float fminf(float __a, float __b) { return __nv_fminf(__a, __b); } - -float fmodf(float __a, float __b) { return __nv_fmodf(__a, __b); } - -float frexpf(float __a, int *__b) { return __nv_frexpf(__a, __b); } - -float hypotf(float __a, float __b) { return __nv_hypotf(__a, __b); } - -int ilogbf(float __a) { return __nv_ilogbf(__a); } - -int __finitef(float __a) { return __nv_finitef(__a); } - -int __isinff(float __a) { return __nv_isinff(__a); } - -int __isnanf(float __a) { return __nv_isnanf(__a); } - -float j0f(float __a) { return __nv_j0f(__a); } - -float j1f(float __a) { return __nv_j1f(__a); } - -float jnf(int __n, float __a) { return __nv_jnf(__n, __a); } - -float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); } - -float lgammaf(float __a) { return __nv_lgammaf(__a); } - -long long llrintf(float __a) { return __nv_llrintf(__a); } - -long long llroundf(float __a) { return __nv_llroundf(__a); } - -float log10f(float __a) { return __nv_log10f(__a); } - -float log1pf(float __a) { return __nv_log1pf(__a); } - -float log2f(float __a) { - return __FAST_OR_SLOW(__nv_fast_log2f, __nv_log2f)(__a); -} - -float logbf(float __a) { return __nv_logbf(__a); } - -float logf(float __a) { - return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a); -} - -long long __float2ll_rn(float __a) { return __nv_float2ll_rn(__a); } - -#if defined(__LP64__) -long lrintf(float __a) { return __float2ll_rn(__a); } -long lroundf(float __a) { return llroundf(__a); } -#else -long lrintf(float __a) { return __float2int_rn(__a); } -long lroundf(float __a) { return roundf(__a); } -#endif - -float modff(float __a, float *__b) { return __nv_modff(__a, __b); } - -// nanf - missing - -float nearbyintf(float __a) { return __nv_nearbyintf(__a); } - -float nextafterf(float __a, float __b) { - return __nv_nextafterf(__a, __b); -} - -float norm3df(float __a, float __b, float __c) { - return __nv_norm3df(__a, __b, __c); -} - -float norm4df(float __a, float __b, float __c, float __d) { - return __nv_norm4df(__a, __b, __c, __d); -} - -float normcdff(float __a) { return __nv_normcdff(__a); } - -float normf(int __dim, const float *__t) { - return __nv_normf(__dim, __t); -} - -float powf(float __a, float __b) { return __nv_powf(__a, __b); } - -float rcbrtf(float __a) { return __nv_rcbrtf(__a); } - -float remainderf(float __a, float __b) { - return __nv_remainderf(__a, __b); -} - -float remquof(float __a, float __b, int *__c) { - return __nv_remquof(__a, __b, __c); -} - -float rhypotf(float __a, float __b) { - return __nv_rhypotf(__a, __b); -} - -float rintf(float __a) { return __nv_rintf(__a); } - -float rnorm3df(float __a, float __b, float __c) { - return __nv_rnorm3df(__a, __b, __c); -} - -float rnorm4df(float __a, float __b, float __c, float __d) { - return __nv_rnorm4df(__a, __b, __c, __d); -} - -float normcdfinvf(float __a) { return __nv_normcdfinvf(__a); } - -float rnormf(int __dim, const float *__t) { - return __nv_rnormf(__dim, __t); -} - -float roundf(float __a) { return __nv_roundf(__a); } - -float rsqrtf(float __a) { return __nv_rsqrtf(__a); } - -float scalblnf(float __a, long __b) { - if (__b > INT_MAX) - return __a > 0 ? HUGE_VALF : -HUGE_VALF; - if (__b < INT_MIN) - return __a > 0 ? 0.f : -0.f; - return scalbnf(__a, (int)__b); -} - -float scalbnf(float __a, int __b) { return __nv_scalbnf(__a, __b); } - -int __signbitf(float __a) { return __nv_signbitf(__a); } - -void sincosf(float __a, float *__sptr, float *__cptr) { - return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr); -} - -void sincospif(float __a, float *__sptr, float *__cptr) { - return __nv_sincospif(__a, __sptr, __cptr); -} - -float sinf(float __a) { - return __FAST_OR_SLOW(__nv_fast_sinf, __nv_sinf)(__a); -} - -float sinhf(float __a) { return __nv_sinhf(__a); } - -float sinpif(float __a) { return __nv_sinpif(__a); } - -float sqrtf(float __a) { return __nv_sqrtf(__a); } - -float tanf(float __a) { return __nv_tanf(__a); } - -float tanhf(float __a) { return __nv_tanhf(__a); } - -float tgammaf(float __a) { return __nv_tgammaf(__a); } - -float truncf(float __a) { return __nv_truncf(__a); } - -float y0f(float __a) { return __nv_y0f(__a); } - -float y1f(float __a) { return __nv_y1f(__a); } - -float ynf(int __a, float __b) { return __nv_ynf(__a, __b); } - -// BEGIN INTRINSICS - -float __cosf(float __a) { return __nv_fast_cosf(__a); } - -float __exp10f(float __a) { return __nv_fast_exp10f(__a); } - -float __expf(float __a) { return __nv_fast_expf(__a); } - -float __fadd_rd(float __a, float __b) { - return __nv_fadd_rd(__a, __b); -} -float __fadd_rn(float __a, float __b) { - return __nv_fadd_rn(__a, __b); -} -float __fadd_ru(float __a, float __b) { - return __nv_fadd_ru(__a, __b); -} -float __fadd_rz(float __a, float __b) { - return __nv_fadd_rz(__a, __b); -} -float __fdiv_rd(float __a, float __b) { - return __nv_fdiv_rd(__a, __b); -} -float __fdiv_rn(float __a, float __b) { - return __nv_fdiv_rn(__a, __b); -} -float __fdiv_ru(float __a, float __b) { - return __nv_fdiv_ru(__a, __b); -} -float __fdiv_rz(float __a, float __b) { - return __nv_fdiv_rz(__a, __b); -} - -float __fdividef(float __a, float __b) { - return __nv_fast_fdividef(__a, __b); -} - -float __fmaf_rd(float __a, float __b, float __c) { - return __nv_fmaf_rd(__a, __b, __c); -} - -float __fmaf_rn(float __a, float __b, float __c) { - return __nv_fmaf_rn(__a, __b, __c); -} - -float __fmaf_ru(float __a, float __b, float __c) { - return __nv_fmaf_ru(__a, __b, __c); -} - -float __fmaf_rz(float __a, float __b, float __c) { - return __nv_fmaf_rz(__a, __b, __c); -} - -float __fmul_rd(float __a, float __b) { - return __nv_fmul_rd(__a, __b); -} -float __fmul_rn(float __a, float __b) { - return __nv_fmul_rn(__a, __b); -} -float __fmul_ru(float __a, float __b) { - return __nv_fmul_ru(__a, __b); -} -float __fmul_rz(float __a, float __b) { - return __nv_fmul_rz(__a, __b); -} - -float __frcp_rd(float __a) { return __nv_frcp_rd(__a); } - -float __frcp_rn(float __a) { return __nv_frcp_rn(__a); } - -float __frcp_ru(float __a) { return __nv_frcp_ru(__a); } - -float __frcp_rz(float __a) { return __nv_frcp_rz(__a); } - -float __fsqrt_rd(float __a) { return __nv_fsqrt_rd(__a); } - -float __fsqrt_rn(float __a) { return __nv_fsqrt_rn(__a); } - -float __fsqrt_ru(float __a) { return __nv_fsqrt_ru(__a); } - -float __fsqrt_rz(float __a) { return __nv_fsqrt_rz(__a); } - -float __fsub_rd(float __a, float __b) { - return __nv_fsub_rd(__a, __b); -} - -float __fsub_rn(float __a, float __b) { - return __nv_fsub_rn(__a, __b); -} - -float __fsub_ru(float __a, float __b) { - return __nv_fsub_ru(__a, __b); -} - -float __fsub_rz(float __a, float __b) { - return __nv_fsub_rz(__a, __b); -} - -float __log10f(float __a) { return __nv_fast_log10f(__a); } - -float __log2f(float __a) { return __nv_fast_log2f(__a); } - -float __logf(float __a) { return __nv_fast_logf(__a); } - -float __powf(float __a, float __b) { - return __nv_fast_powf(__a, __b); -} - -float __saturatef(float __a) { return __nv_saturatef(__a); } - -void __sincosf(float __a, float *__sptr, float *__cptr) { - return __nv_fast_sincosf(__a, __sptr, __cptr); -} -float __sinf(float __a) { return __nv_fast_sinf(__a); } - -float __tanf(float __a) { return __nv_fast_tanf(__a); } - -// BEGIN DOUBLE - - -double acos(double __a) { return __nv_acos(__a); } - -double acosh(double __a) { return __nv_acosh(__a); } - -double asin(double __a) { return __nv_asin(__a); } - -double asinh(double __a) { return __nv_asinh(__a); } - -double atan(double __a) { return __nv_atan(__a); } - -double atan2(double __a, double __b) { return __nv_atan2(__a, __b); } - -double atanh(double __a) { return __nv_atanh(__a); } - -double cbrt(double __a) { return __nv_cbrt(__a); } - -double ceil(double __a) { return __nv_ceil(__a); } - -double copysign(double __a, double __b) { - return __nv_copysign(__a, __b); -} - -double cos(double __a) { return __nv_cos(__a); } - -double cosh(double __a) { return __nv_cosh(__a); } - -double cospi(double __a) { return __nv_cospi(__a); } - -double cyl_bessel_i0(double __a) { return __nv_cyl_bessel_i0(__a); } - -double cyl_bessel_i1(double __a) { return __nv_cyl_bessel_i1(__a); } - -double erf(double __a) { return __nv_erf(__a); } - -double erfc(double __a) { return __nv_erfc(__a); } - -double erfcinv(double __a) { return __nv_erfcinv(__a); } - -double erfcx(double __a) { return __nv_erfcx(__a); } - -double erfinv(double __a) { return __nv_erfinv(__a); } - -double exp(double __a) { return __nv_exp(__a); } - -double exp10(double __a) { return __nv_exp10(__a); } - -double exp2(double __a) { return __nv_exp2(__a); } - -double expm1(double __a) { return __nv_expm1(__a); } - -double fabs(double __a) { return __nv_fabs(__a); } - -double fdim(double __a, double __b) { return __nv_fdim(__a, __b); } - -double floor(double __f) { return __nv_floor(__f); } - -double fma(double __a, double __b, double __c) { - return __nv_fma(__a, __b, __c); -} - -double fmax(double __a, double __b) { return __nv_fmax(__a, __b); } - -double fmin(double __a, double __b) { return __nv_fmin(__a, __b); } - -double fmod(double __a, double __b) { return __nv_fmod(__a, __b); } - -double frexp(double __a, int *__b) { return __nv_frexp(__a, __b); } - -double hypot(double __a, double __b) { return __nv_hypot(__a, __b); } - -int ilogb(double __a) { return __nv_ilogb(__a); } - -int __finite(double __a) { return __nv_isfinited(__a); } - -// These symbols, isnan and isinf, cause issues on some RHEL systems. -//int __isinf(double __a) { return __nv_isinfd(__a); } - -//int __isnan(double __a) { return __nv_isnand(__a); } - -double j0(double __a) { return __nv_j0(__a); } - -double j1(double __a) { return __nv_j1(__a); } - -double jn(int __n, double __a) { return __nv_jn(__n, __a); } - -double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); } - -double lgamma(double __a) { return __nv_lgamma(__a); } - -long long llrint(double __a) { return __nv_llrint(__a); } - -long long llround(double __a) { return __nv_llround(__a); } - -double log(double __a) { return __nv_log(__a); } - -double log10(double __a) { return __nv_log10(__a); } - -double log1p(double __a) { return __nv_log1p(__a); } - -double log2(double __a) { return __nv_log2(__a); } - -double logb(double __a) { return __nv_logb(__a); } - -#if defined(__LP64__) -long lrint(double __a) { return llrint(__a); } - -long lround(double __a) { return llround(__a); } -#else -long lrint(double __a) { return (long)rint(__a); } - -long lround(double __a) { return round(__a); } -#endif - -double modf(double __a, double *__b) { return __nv_modf(__a, __b); } - -// nan - missing - -double nearbyint(double __a) { return __nv_nearbyint(__a); } - -double nextafter(double __a, double __b) { - return __nv_nextafter(__a, __b); -} - -double norm(int __dim, const double *__t) { - return __nv_norm(__dim, __t); -} - -double norm3d(double __a, double __b, double __c) { - return __nv_norm3d(__a, __b, __c); -} - -double norm4d(double __a, double __b, double __c, double __d) { - return __nv_norm4d(__a, __b, __c, __d); -} - -double normcdf(double __a) { return __nv_normcdf(__a); } - -double normcdfinv(double __a) { return __nv_normcdfinv(__a); } - -double pow(double __a, double __b) { return __nv_pow(__a, __b); } - -double rcbrt(double __a) { return __nv_rcbrt(__a); } - -double remainder(double __a, double __b) { - return __nv_remainder(__a, __b); -} - -double remquo(double __a, double __b, int *__c) { - return __nv_remquo(__a, __b, __c); -} - -double rhypot(double __a, double __b) { - return __nv_rhypot(__a, __b); -} - -double rint(double __a) { return __nv_rint(__a); } - -double rnorm(int __a, const double *__b) { - return __nv_rnorm(__a, __b); -} - -double rnorm3d(double __a, double __b, double __c) { - return __nv_rnorm3d(__a, __b, __c); -} - -double rnorm4d(double __a, double __b, double __c, double __d) { - return __nv_rnorm4d(__a, __b, __c, __d); -} - -double round(double __a) { return __nv_round(__a); } - -double rsqrt(double __a) { return __nv_rsqrt(__a); } - -double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); } - -double scalbln(double __a, long __b) { - if (__b > INT_MAX) - return __a > 0 ? HUGE_VAL : -HUGE_VAL; - if (__b < INT_MIN) - return __a > 0 ? 0.0 : -0.0; - return scalbn(__a, (int)__b); -} - -int __signbit(double __a) { return __nv_signbitd(__a); } - -double sin(double __a) { return __nv_sin(__a); } - -void sincos(double __a, double *__sptr, double *__cptr) { - return __nv_sincos(__a, __sptr, __cptr); -} - -void sincospi(double __a, double *__sptr, double *__cptr) { - return __nv_sincospi(__a, __sptr, __cptr); -} - -double sinh(double __a) { return __nv_sinh(__a); } - -double sinpi(double __a) { return __nv_sinpi(__a); } - -double sqrt(double __a) { return __nv_sqrt(__a); } - -double tan(double __a) { return __nv_tan(__a); } - -double tanh(double __a) { return __nv_tanh(__a); } - -double tgamma(double __a) { return __nv_tgamma(__a); } - -double trunc(double __a) { return __nv_trunc(__a); } - -double y0(double __a) { return __nv_y0(__a); } - -double y1(double __a) { return __nv_y1(__a); } - -double yn(int __a, double __b) { return __nv_yn(__a, __b); } - -// BEGIN INTRINSICS - -double __dadd_rd(double __a, double __b) { - return __nv_dadd_rd(__a, __b); -} - -double __dadd_rn(double __a, double __b) { - return __nv_dadd_rn(__a, __b); -} - -double __dadd_ru(double __a, double __b) { - return __nv_dadd_ru(__a, __b); -} - -double __dadd_rz(double __a, double __b) { - return __nv_dadd_rz(__a, __b); -} - -double __ddiv_rd(double __a, double __b) { - return __nv_ddiv_rd(__a, __b); -} - -double __ddiv_rn(double __a, double __b) { - return __nv_ddiv_rn(__a, __b); -} - -double __ddiv_ru(double __a, double __b) { - return __nv_ddiv_ru(__a, __b); -} - -double __ddiv_rz(double __a, double __b) { - return __nv_ddiv_rz(__a, __b); -} - -double __dmul_rd(double __a, double __b) { - return __nv_dmul_rd(__a, __b); -} - -double __dmul_rn(double __a, double __b) { - return __nv_dmul_rn(__a, __b); -} - -double __dmul_ru(double __a, double __b) { - return __nv_dmul_ru(__a, __b); -} - -double __dmul_rz(double __a, double __b) { - return __nv_dmul_rz(__a, __b); -} - -double __drcp_rd(double __a) { return __nv_drcp_rd(__a); } - -double __drcp_rn(double __a) { return __nv_drcp_rn(__a); } - -double __drcp_ru(double __a) { return __nv_drcp_ru(__a); } - -double __drcp_rz(double __a) { return __nv_drcp_rz(__a); } - -double __dsqrt_rd(double __a) { return __nv_dsqrt_rd(__a); } - -double __dsqrt_rn(double __a) { return __nv_dsqrt_rn(__a); } - -double __dsqrt_ru(double __a) { return __nv_dsqrt_ru(__a); } - -double __dsqrt_rz(double __a) { return __nv_dsqrt_rz(__a); } - -double __dsub_rd(double __a, double __b) { - return __nv_dsub_rd(__a, __b); -} - -double __dsub_rn(double __a, double __b) { - return __nv_dsub_rn(__a, __b); -} - -double __dsub_ru(double __a, double __b) { - return __nv_dsub_ru(__a, __b); -} - -double __dsub_rz(double __a, double __b) { - return __nv_dsub_rz(__a, __b); -} - -double __fma_rd(double __a, double __b, double __c) { - return __nv_fma_rd(__a, __b, __c); -} - -double __fma_rn(double __a, double __b, double __c) { - return __nv_fma_rn(__a, __b, __c); -} - -double __fma_ru(double __a, double __b, double __c) { - return __nv_fma_ru(__a, __b, __c); -} - -double __fma_rz(double __a, double __b, double __c) { - return __nv_fma_rz(__a, __b, __c); -} - -// END DOUBLE - -// Complex functions -#define _ISNANd __nv_isnand -#define _ISNANf __isnanf -#define _ISINFd __nv_isinfd -#define _ISINFf __isinff -#define _ISFINITEd __finite -#define _ISFINITEf __finitef -#define _COPYSIGNd copysign -#define _COPYSIGNf copysignf -#define _SCALBNd scalbn -#define _SCALBNf scalbnf -#define _ABSd fabs -#define _ABSf fabsf -#define _LOGBd logb -#define _LOGBf logbf - -#include "complex.def" - -#undef _ISNANd -#undef _ISNANf -#undef _ISINFd -#undef _ISINFf -#undef _COPYSIGNd -#undef _COPYSIGNf -#undef _ISFINITEd -#undef _ISFINITEf -#undef _SCALBNd -#undef _SCALBNf -#undef _ABSd -#undef _ABSf -#undef _LOGBd -#undef _LOGBf - -#pragma omp end declare target -#endif - diff --git a/aomp-device-libs/libm/src/libm-nvptx.cpp b/aomp-device-libs/libm/src/libm-nvptx.cpp deleted file mode 100644 index fc7ae83..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.cpp +++ /dev/null @@ -1,273 +0,0 @@ -//===--------- libm/libm-nvptx.cpp ----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include -#include "libm-nvptx.h" -#ifdef __cplusplus -#pragma omp declare target - -// Extern declarations -extern long long llabs(long long __a); -extern long labs(long __a); -extern float powif(float __a, int __b); -extern double powi(double __a, int __b); -extern float powif(float __a, int __b); -extern int __isfinited(double __a); - -/// Do not provide the double overload because the base functions -/// are defined in libm-amdgcn.c. Only provide non base variants. - -long long abs(long long __n) { return llabs(__n); } -long abs(long __n) { return labs(__n); } -float abs(float __x) { return fabsf(__x); } -double abs(double __x) { return fabs(__x); } -float acos(float __x) { return acosf(__x); } -float asin(float __x) { return asinf(__x); } -float atan(float __x) { return atanf(__x); } -float atan2(float __x, float __y) { return atan2f(__x, __y); } -float ceil(float __x) { return ceilf(__x); } -float cos(float __x) { return cosf(__x); } -float cosh(float __x) { return coshf(__x); } -float exp(float __x) { return expf(__x); } -float fabs(float __x) { return fabsf(__x); } -float floor(float __x) { return floorf(__x); } -float fmod(float __x, float __y) { return fmodf(__x, __y); } -int fpclassify(float __x) { - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, - FP_ZERO, __x); -} -int fpclassify(double __x) { - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, - FP_ZERO, __x); -} -float frexp(float __arg, int *__exp) { - return frexpf(__arg, __exp); -} - -bool isinf(float __x) { return __isinff(__x); } -//bool isinf(double __x) { return __isinf(__x); } -bool isfinite(float __x) { return __finitef(__x); } -bool isfinite(double __x) { return __isfinited(__x); } -bool isnan(float __x) { return __isnanf(__x); } -//bool isnan(double __x) { return __isnan(__x); } - -bool isgreater(float __x, float __y) { - return __builtin_isgreater(__x, __y); -} -bool isgreater(double __x, double __y) { - return __builtin_isgreater(__x, __y); -} -bool isgreaterequal(float __x, float __y) { - return __builtin_isgreaterequal(__x, __y); -} -bool isgreaterequal(double __x, double __y) { - return __builtin_isgreaterequal(__x, __y); -} -bool isless(float __x, float __y) { - return __builtin_isless(__x, __y); -} -bool isless(double __x, double __y) { - return __builtin_isless(__x, __y); -} -bool islessequal(float __x, float __y) { - return __builtin_islessequal(__x, __y); -} -bool islessequal(double __x, double __y) { - return __builtin_islessequal(__x, __y); -} -bool islessgreater(float __x, float __y) { - return __builtin_islessgreater(__x, __y); -} -bool islessgreater(double __x, double __y) { - return __builtin_islessgreater(__x, __y); -} -bool isnormal(float __x) { return __builtin_isnormal(__x); } -bool isnormal(double __x) { return __builtin_isnormal(__x); } -bool isunordered(float __x, float __y) { - return __builtin_isunordered(__x, __y); -} -bool isunordered(double __x, double __y) { - return __builtin_isunordered(__x, __y); -} -float ldexp(float __arg, int __exp) { - return ldexpf(__arg, __exp); -} - -float log(float __x) { return logf(__x); } -float log10(float __x) { return log10f(__x); } -float modf(float __x, float *__iptr) { return modff(__x, __iptr); } -float pow(float __base, float __exp) { - return powf(__base, __exp); -} -float pow(float __base, int __iexp) { - return powif(__base, __iexp); -} -double pow(double __base, int __iexp) { - return powi(__base, __iexp); -} -/* -bool signbit(float __x) { return __signbitf(__x); } -bool signbit(double __x) { return __signbitd(__x); } -*/ -float sin(float __x) { return sinf(__x); } -float sinh(float __x) { return sinhf(__x); } -float sqrt(float __x) { return sqrtf(__x); } -float tan(float __x) { return tanf(__x); } -float tanh(float __x) { return tanhf(__x); } - - -template struct __clang_cuda_enable_if {}; - -template struct __clang_cuda_enable_if { - typedef __T type; -}; - -// Defines an overload of __fn that accepts one integral argument, calls -// __fn((double)x), and returns __retty. -#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_1(__retty, __fn) \ - template \ - \ - typename __clang_cuda_enable_if::is_integer, \ - __retty>::type \ - __fn(__T __x) { \ - return ::__fn((double)__x); \ - } - -// Defines an overload of __fn that accepts one two arithmetic arguments, calls -// __fn((double)x, (double)y), and returns a double. -// -// Note this is different from OVERLOAD_1, which generates an overload that -// accepts only *integral* arguments. -#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_2(__retty, __fn) \ - template \ - typename __clang_cuda_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y) { \ - return __fn((double)__x, (double)__y); \ - } - -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acos) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acosh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asin) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asinh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atan) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, atan2); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atanh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cbrt) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, ceil) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, copysign); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cos) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cosh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erf) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erfc) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp2) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, expm1) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, fabs) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fdim); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, floor) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmax); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmin); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmod); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, fpclassify) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, hypot); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, ilogb) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isfinite) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreater); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreaterequal); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isinf); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isless); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessequal); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessgreater); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnan); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnormal) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isunordered); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, lgamma) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log10) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log1p) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log2) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, logb) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llrint) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llround) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lrint) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lround) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, nearbyint); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, nextafter); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, pow); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, remainder); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, rint); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, round); -//__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, signbit) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sin) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sinh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sqrt) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tan) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tanh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tgamma) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, trunc); - -#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_1 -#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_2 - -// Overloads for functions that don't match the patterns expected by -// __CUDA_CLANG_FN_INTEGER_OVERLOAD_{1,2}. -template -typename __clang_cuda_enable_if< - std::numeric_limits<__T1>::is_specialized && - std::numeric_limits<__T2>::is_specialized && - std::numeric_limits<__T3>::is_specialized, - double>::type -fma(__T1 __x, __T2 __y, __T3 __z) { - return std::fma((double)__x, (double)__y, (double)__z); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -frexp(__T __x, int *__exp) { - return std::frexp((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -ldexp(__T __x, int __exp) { - return std::ldexp((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if< - std::numeric_limits<__T1>::is_specialized && - std::numeric_limits<__T2>::is_specialized, - double>::type -remquo(__T1 __x, __T2 __y, int *__quo) { - return std::remquo((double)__x, (double)__y, __quo); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -scalbln(__T __x, long __exp) { - return std::scalbln((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -scalbn(__T __x, int __exp) { - return std::scalbn((double)__x, __exp); -} - -#pragma omp end declare target -#endif // if c++ - diff --git a/aomp-device-libs/libm/src/libm-nvptx.h b/aomp-device-libs/libm/src/libm-nvptx.h deleted file mode 100644 index 95e1aab..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.h +++ /dev/null @@ -1,583 +0,0 @@ -//===--------- libm/libm-nvptx.h ------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#ifndef __LIBM_NVTPX_H__ -#define __LIBM_NVTPX_H__ - -int __nv_brev(int x); -long long __nv_brevll(long long x); -int __nv_clz(int x); -int __nv_clzll(long long x); -float __nv_fast_cosf(float x); -double __nv_dadd_rd(double __a, double __b); -double __nv_dadd_rn(double __a, double __b); -double __nv_dadd_ru(double __a, double __b); -double __nv_dadd_rz(double __a, double __b); -int __nv_byte_perm(int __a, int __b, - int __c); -double __nv_ddiv_rd(double __a, double __b); -double __nv_ddiv_rn(double __a, double __b); -double __nv_ddiv_ru(double __a, double __b); -double __nv_ddiv_rz(double __a, double __b); -double __nv_dmul_rd(double __a, double __b); -double __nv_dmul_rn(double __a, double __b); -double __nv_dmul_ru(double __a, double __b); -double __nv_dmul_rz(double __a, double __b); -float __nv_double2float_rd(double __a); -float __nv_double2float_rn(double __a); -float __nv_double2float_ru(double __a); -float __nv_double2float_rz(double __a); -int __nv_double2hiint(double __a); -int __nv_double2int_rd(double __a); -int __nv_double2int_rn(double __a); -int __nv_double2int_ru(double __a); -int __nv_double2int_rz(double __a); -long long __nv_double2ll_rd(double __a); -long long __nv_double2ll_rn(double __a); -long long __nv_double2ll_ru(double __a); -long long __nv_double2ll_rz(double __a); -int __nv_double2loint(double __a); -unsigned int __nv_double2uint_rd(double __a); -unsigned int __nv_double2uint_rn(double __a); -unsigned int __nv_double2uint_ru(double __a); -unsigned int __nv_double2uint_rz(double __a); -unsigned long long __nv_double2ull_rd(double __a); -unsigned long long __nv_double2ull_rn(double __a); -unsigned long long __nv_double2ull_ru(double __a); -unsigned long long __nv_double2ull_rz(double __a); -unsigned long long __nv_double_as_longlong(double __a); -double __nv_drcp_rd(double __a); -double __nv_drcp_rn(double __a); -double __nv_drcp_ru(double __a); -double __nv_drcp_rz(double __a); -double __nv_dsqrt_rd(double __a); -double __nv_dsqrt_rn(double __a); -double __nv_dsqrt_ru(double __a); -double __nv_dsqrt_rz(double __a); -double __nv_dsub_rd(double __a, double __b); -double __nv_dsub_rn(double __a, double __b); -double __nv_dsub_ru(double __a, double __b); -double __nv_dsub_rz(double __a, double __b); -float __nv_fast_exp10f(float __a); -float __nv_fast_expf(float __a); -float __nvvm_atom_add_gen_f(volatile float *__p, float __v); -float __nvvm_atom_cta_add_gen_f(volatile float *__p, float __v); -float __nv_fadd_rd(float __a, float __b); -float __nv_fadd_rn(float __a, float __b); -float __nv_fadd_ru(float __a, float __b); -float __nv_fadd_rz(float __a, float __b); -float __nv_fdiv_rd(float __a, float __b); -float __nv_fdiv_rn(float __a, float __b); -float __nv_fdiv_ru(float __a, float __b); -float __nv_fdiv_rz(float __a, float __b); -float __nv_fast_fdividef(float __a, float __b); -int __nv_ffs(int __a); -int __nv_ffsll(long long __a); -int __nv_isfinited(double __a); -int __nv_finitef(float __a); -int __nv_float2int_rd(float __a); -int __nv_float2int_rn(float __a); -int __nv_float2int_ru(float __a); -int __nv_float2int_rz(float __a); -long long __nv_float2ll_rd(float __a); -long long __nv_float2ll_rn(float __a); -long long __nv_float2ll_ru(float __a); -long long __nv_float2ll_rz(float __a); -unsigned int __nv_float2uint_rd(float __a); -unsigned int __nv_float2uint_rn(float __a); -unsigned int __nv_float2uint_ru(float __a); -unsigned int __nv_float2uint_rz(float __a); -unsigned long long __nv_float2ull_rd(float __a); -unsigned long long __nv_float2ull_rn(float __a); -unsigned long long __nv_float2ull_ru(float __a); -unsigned long long __nv_float2ull_rz(float __a); -int __nv_float_as_int(float __a); -unsigned int __nv_float_as_uint(float __a); -double __nv_fma_rd(double __a, double __b, double __c); -double __nv_fma_rn(double __a, double __b, double __c); -double __nv_fma_ru(double __a, double __b, double __c); -double __nv_fma_rz(double __a, double __b, double __c); -float __nv_fmaf_ieee_rd(float __a, float __b, float __c); -float __nv_fmaf_ieee_rn(float __a, float __b, float __c); -float __nv_fmaf_ieee_ru(float __a, float __b, float __c); -float __nv_fmaf_ieee_rz(float __a, float __b, float __c); -float __nv_fmaf_rd(float __a, float __b, float __c); -float __nv_fmaf_rn(float __a, float __b, float __c); -float __nv_fmaf_ru(float __a, float __b, float __c); -float __nv_fmaf_rz(float __a, float __b, float __c); -float __nv_fmul_rd(float __a, float __b); -float __nv_fmul_rn(float __a, float __b); -float __nv_fmul_ru(float __a, float __b); -float __nv_fmul_rz(float __a, float __b); -float __nv_frcp_rd(float __a); -float __nv_frcp_rn(float __a); -float __nv_frcp_ru(float __a); -float __nv_frcp_rz(float __a); -float __nv_frsqrt_rn(float __a); -float __nv_fsqrt_rd(float __a); -float __nv_fsqrt_rn(float __a); -float __nv_fsqrt_ru(float __a); -float __nv_fsqrt_rz(float __a); -float __nv_fsub_rd(float __a, float __b); -float __nv_fsub_rn(float __a, float __b); -float __nv_fsub_ru(float __a, float __b); -float __nv_fsub_rz(float __a, float __b); -int __nv_hadd(int __a, int __b); -double __nv_hiloint2double(int __a, int __b); -int __nvvm_atom_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_cta_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_sys_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_xor_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_xor_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_xor_gen_i(volatile int *__p, int __v); -long long __nvvm_atom_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_min_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_min_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_min_gen_ll(volatile long long *__p, - long long __v); -double __nv_int2double_rn(int __a); -float __nv_int2float_rd(int __a); -float __nv_int2float_rn(int __a); -float __nv_int2float_ru(int __a); -float __nv_int2float_rz(int __a); -float __nv_int_as_float(int __a); -int __nv_isfinited(double __a); -int __nv_isinfd(double __a); -int __nv_isinff(float __a); -int __nv_isnand(double __a); -int __nv_isnanf(float __a); -double __nv_ll2double_rd(long long __a); -double __nv_ll2double_rn(long long __a); -double __nv_ll2double_ru(long long __a); -double __nv_ll2double_rz(long long __a); -float __nv_ll2float_rd(long long __a); -float __nv_ll2float_rn(long long __a); -float __nv_ll2float_ru(long long __a); -float __nv_ll2float_rz(long long __a); -long long __nvvm_atom_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_xor_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_xor_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_xor_gen_ll(volatile long long *__p, - long long __v); -float __nv_fast_log10f(float __a); -float __nv_fast_log2f(float __a); -float __nv_fast_logf(float __a); -double __nv_longlong_as_double(long long __a); -int __nv_mul24(int __a, int __b); -long long __nv_mul64hi(long long __a, long long __b); -int __nv_mulhi(int __a, int __b); -//unsigned int __nvvm_read_ptx_sreg_pm0(void); -//unsigned int __nvvm_read_ptx_sreg_pm1(void); -//unsigned int __nvvm_read_ptx_sreg_pm2(void); -//unsigned int __nvvm_read_ptx_sreg_pm3(void); -int __nv_popc(int __a); -int __nv_popcll(long long __a); -float __nv_fast_powf(float __a, float __b); -int __nv_rhadd(int __a, int __b); -int __nv_sad(int __a, int __b, int __c); -float __nv_saturatef(float __a); -int __nv_signbitd(double __a); -int __nv_signbitf(float __a); -void __nv_fast_sincosf(float __a, float *__sptr, float *__cptr); -float __nv_fast_sinf(float __a); -//int __nvvm_bar0_and(int __a); -//int __nvvm_bar0_popc(int __a); -//int __nvvm_bar0_or(int __a); -float __nv_fast_tanf(float __a); -//void __nvvm_membar_gl(); -//void __nvvm_membar_cta(); -//void __nvvm_membar_sys(); -unsigned int __nvvm_atom_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -int __nv_uhadd(unsigned int __a, unsigned int __b); -double __nv_uint2double_rn(unsigned int __a); -float __nv_uint2float_rd(unsigned int __a); -float __nv_uint2float_rn(unsigned int __a); -float __nv_uint2float_ru(unsigned int __a); -float __nv_uint2float_rz(unsigned int __a); -float __nv_uint_as_float(unsigned int __a); -double __nv_ull2double_rd(unsigned long long __a); -double __nv_ull2double_rn(unsigned long long __a); -double __nv_ull2double_ru(unsigned long long __a); -double __nv_ull2double_rz(unsigned long long __a); -float __nv_ull2float_rd(unsigned long long __a); -float __nv_ull2float_rn(unsigned long long __a); -float __nv_ull2float_ru(unsigned long long __a); -float __nv_ull2float_rz(unsigned long long __a); -long long int __nvvm_atom_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_cta_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_sys_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_cta_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_sys_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_xchg_gen_ll(volatile long long int *__p, - long long int __v); -long long int -__nvvm_atom_cta_xchg_gen_ll(volatile long long int *__p, long long int __v); -long long int -__nvvm_atom_sys_xchg_gen_ll(volatile long long int *__p, long long int __v); -unsigned long long -__nvvm_atom_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_cta_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_sys_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_cta_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_sys_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned int __nv_umul24(unsigned int __a, unsigned int __b); -unsigned long long __nv_umul64hi(unsigned long long __a, - unsigned long long __b); -unsigned int __nv_umulhi(unsigned int __a, unsigned int __b); -unsigned int __nv_urhadd(unsigned int __a, unsigned int __b); -unsigned int __nv_usad(unsigned int __a, unsigned int __b, - unsigned int __c); -unsigned int __nv_vabs2(unsigned int __a); -unsigned int __nv_vabs4(unsigned int __a); -unsigned int __nv_vabsdiffs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsss2(unsigned int __a); -unsigned int __nv_vabsss4(unsigned int __a); -unsigned int __nv_vadd2(unsigned int __a, unsigned int __b); -unsigned int __nv_vadd4(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddss2(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddss4(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddus2(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddus4(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpeq2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpeq4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpges2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpges4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgeu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgeu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgtu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgtu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmples2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmples4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpleu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpleu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmplts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmplts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpltu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpltu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpne2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpne4(unsigned int __a, unsigned int __b); -unsigned int __nv_vhaddu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vhaddu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmins2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmins4(unsigned int __a, unsigned int __b); -unsigned int __nv_vminu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vminu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vneg2(unsigned int __a); -unsigned int __nv_vneg4(unsigned int __a); -unsigned int __nv_vnegss2(unsigned int __a); -unsigned int __nv_vnegss4(unsigned int __a); -unsigned int __nv_vsads2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsads4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsadu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsadu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vseteq2(unsigned int __a, unsigned int __b); -unsigned int __nv_vseteq4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetges2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetges4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgeu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgeu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgtu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgtu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetles2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetles4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetleu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetleu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetlts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetlts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetltu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetltu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetne2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetne4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsub2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsub4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubss2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubss4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubus2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubus4(unsigned int __a, unsigned int __b); -int __nv_abs(int __a); -double __nv_acos(double __a); -float __nv_acosf(float __a); -double __nv_acosh(double __a); -float __nv_acoshf(float __a); -double __nv_asin(double __a); -float __nv_asinf(float __a); -double __nv_asinh(double __a); -float __nv_asinhf(float __a); -double __nv_atan(double __a); -double __nv_atan2(double __a, double __b); -float __nv_atan2f(float __a, float __b); -float __nv_atanf(float __a); -double __nv_atanh(double __a); -float __nv_atanhf(float __a); -double __nv_cbrt(double __a); -float __nv_cbrtf(float __a); -double __nv_ceil(double __a); -float __nv_ceilf(float __a); -//int __nvvm_read_ptx_sreg_clock(); -//long long __nvvm_read_ptx_sreg_clock64(); -double __nv_copysign(double __a, double __b); -float __nv_copysignf(float __a, float __b); -double __nv_cos(double __); -float __nv_fast_cosf(float __a); -float __nv_cosf(float __a); -double __nv_cosh(double __a); -float __nv_coshf(float __a); -double __nv_cospi(double __a); -float __nv_cospif(float __a); -double __nv_cyl_bessel_i0(double __a); -float __nv_cyl_bessel_i0f(float __a); -double __nv_cyl_bessel_i1(double __a); -float __nv_cyl_bessel_i1f(float __a); -double __nv_erf(double __a); -double __nv_erfc(double __a); -float __nv_erfcf(float __a); -double __nv_erfcinv(double __a); -float __nv_erfcinvf(float __a); -double __nv_erfcx(double __a); -float __nv_erfcxf(float __a); -float __nv_erff(float __a); -double __nv_erfinv(double __a); -float __nv_erfinvf(float __a); -double __nv_exp(double __a); -double __nv_exp10(double __a); -float __nv_exp10f(float __a); -double __nv_exp2(double __a); -float __nv_exp2f(float __a); -float __nv_expf(float __a); -double __nv_expm1(double __a); -float __nv_expm1f(float __a); -double __nv_fabs(double __a); -float __nv_fabsf(float __a); -double __nv_fdim(double __a, double __b); -float __nv_fdimf(float __a, float __b); -float __nv_fast_fdividef(float __a, float __b); -double __nv_floor(double __f); -float __nv_floorf(float __f); -double __nv_fma(double __a, double __b, double __c); -float __nv_fmaf(float __a, float __b, float __c); -double __nv_fmax(double __a, double __b); -float __nv_fmaxf(float __a, float __b); -double __nv_fmin(double __a, double __b); -float __nv_fminf(float __a, float __b); -double __nv_fmod(double __a, double __b); -float __nv_fmodf(float __a, float __b); -double __nv_frexp(double __a, int *__b); -float __nv_frexpf(float __a, int *__b); -double __nv_hypot(double __a, double __b); -float __nv_hypotf(float __a, float __b); -int __nv_ilogb(double __a); -int __nv_ilogbf(float __a); -double __nv_j0(double __a); -float __nv_j0f(float __a); -double __nv_j1(double __a); -float __nv_j1f(float __a); -double __nv_jn(int __n, double __a); -float __nv_jnf(int __n, float __a); -// long __nv_abs(long __a); -double __nv_ldexp(double __a, int __b); -float __nv_ldexpf(float __a, int __b); -double __nv_lgamma(double __a); -float __nv_lgammaf(float __a); -long long __nv_llabs(long long __a); -long long __nv_llmax(long long __a, long long __b); -long long __nv_llmin(long long __a, long long __b); -long long __nv_llrint(double __a); -long long __nv_llrintf(float __a); -long long __nv_llround(double __a); -long long __nv_llroundf(float __a); -double __nv_log(double __a); -double __nv_log10(double __a); -float __nv_log10f(float __a); -double __nv_log1p(double __a); -float __nv_log1pf(float __a); -double __nv_log2(double __a); -float __nv_log2f(float __a); -float __nv_fast_log2f(float __a); -double __nv_logb(double __a); -float __nv_logbf(float __a); -float __nv_fast_logf(float __a); -float __nv_logf(float __a); -int __nv_max(int __a, int __b); -int __nv_min(int __a, int __b); -double __nv_modf(double __a, double *__b); -float __nv_modff(float __a, float *__b); -double __nv_nearbyint(double __a); -float __nv_nearbyintf(float __a); -double __nv_nextafter(double __a, double __b); -float __nv_nextafterf(float __a, float __b); -double __nv_norm(int __dim, const double *__t); -double __nv_norm3d(double __a, double __b, double __c); -float __nv_norm3df(float __a, float __b, float __c); -double __nv_norm4d(double __a, double __b, double __c, double __d); -float __nv_norm4df(float __a, float __b, float __c, float __d); -double __nv_normcdf(double __a); -float __nv_normcdff(float __a); -double __nv_normcdfinv(double __a); -float __nv_normcdfinvf(float __a); -float __nv_normf(int __dim, const float *__t); - -double __nv_pow(double __a, double __b); -float __nv_powf(float __a, float __b); -double __nv_powi(double __a, int __b); -float __nv_powif(float __a, int __b); -double __nv_rcbrt(double __a); -float __nv_rcbrtf(float __a); -double __nv_remainder(double __a, double __b); -float __nv_remainderf(float __a, float __b); -double __nv_remquo(double __a, double __b, int *__c); -float __nv_remquof(float __a, float __b, int *__c); -double __nv_rhypot(double __a, double __b); -float __nv_rhypotf(float __a, float __b); -double __nv_rint(double __a); -float __nv_rintf(float __a); -double __nv_rnorm(int __a, const double *__b); -double __nv_rnorm3d(double __a, double __b, double __c); -float __nv_rnorm3df(float __a, float __b, float __c); -double __nv_rnorm4d(double __a, double __b, double __c, double __d); -float __nv_rnorm4df(float __a, float __b, float __c, float __d); -float __nv_rnormf(int __dim, const float *__t); -double __nv_round(double __a); -float __nv_roundf(float __a); -double __nv_rsqrt(double __a); -float __nv_rsqrtf(float __a); -double __nv_scalbn(double __a, int __b); -float __nv_scalbnf(float __a, int __b); -double __nv_sin(double __a); -void __nv_sincos(double __a, double *__sptr, double *__cptr); -void __nv_sincosf(float __a, float *__sptr, float *__cptr); -void __nv_sincospi(double __a, double *__sptr, double *__cptr); -void __nv_sincospif(float __a, float *__sptr, float *__cptr); -float __nv_fast_sinf(float __a); -float __nv_sinf(float __a); -double __nv_sinh(double __a); -float __nv_sinhf(float __a); -double __nv_sinpi(double __a); -float __nv_sinpif(float __a); -double __nv_sqrt(double __a); -float __nv_sqrtf(float __a); -double __nv_tan(double __a); -float __nv_tanf(float __a); -double __nv_tanh(double __a); -float __nv_tanhf(float __a); -double __nv_tgamma(double __a); -float __nv_tgammaf(float __a); -double __nv_trunc(double __a); -float __nv_truncf(float __a); -unsigned long long __nv_ullmax(unsigned long long __a, - unsigned long long __b); -unsigned long long __nv_ullmin(unsigned long long __a, - unsigned long long __b); -unsigned int __nv_umax(unsigned int __a, unsigned int __b); -unsigned int __nv_umin(unsigned int __a, unsigned int __b); - -double __nv_y0(double __a); -float __nv_y0f(float __a); -double __nv_y1(double __a); -float __nv_y1f(float __a); -double __nv_yn(int __a, double __b); -float __nv_ynf(int __a, float __b); - -#endif // __LIBM_NVTPX_H__ diff --git a/aomp-device-libs/libm/src/libm.c b/aomp-device-libs/libm/src/libm.c index ca05a6d..e22a11a 100644 --- a/aomp-device-libs/libm/src/libm.c +++ b/aomp-device-libs/libm/src/libm.c @@ -14,10 +14,19 @@ // double fast_sqrt(double __a) { ... } // #endif +#define __BUILD_MATH_BUILTINS_LIB__ + #ifdef __AMDGCN__ -#include "libm-amdgcn.c" +#pragma omp declare target +#define __OPENMP_AMDGCN__ +#include <__clang_hip_math.h> +#pragma omp end declare target #endif #ifdef __NVPTX__ -#include "libm-nvptx.c" +#pragma omp declare target +#define __CUDA__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_math.h> +#pragma omp end declare target #endif diff --git a/aomp-device-libs/libm/src/libm.cpp b/aomp-device-libs/libm/src/libm.cpp deleted file mode 100644 index 1d3fcb8..0000000 --- a/aomp-device-libs/libm/src/libm.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===--------- libm/libm.cpp ----------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// If the library needs to destinguish betwen different target versions, -// target specific macros for that GPU can be used. -// For nvptx use __NVPTX__. For amdgcn, use __AMDGCN__. -// Example: -// #ifdef __AMDGCN__ && (__AMDGCN__ == 1000) -// double fast_sqrt(double __a) { ... } -// #endif - -#ifdef __AMDGCN__ -#include "libm-amdgcn.cpp" -#endif - -#ifdef __NVPTX__ -#include "libm-nvptx.cpp" -#endif From a627766f8be91fb3d18015717b114943221bdc6d Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Tue, 13 Oct 2020 17:57:07 -0500 Subject: [PATCH 04/31] PR 31 to cleanup libm build for aomp --- aomp-device-libs/libm/CMakeLists.txt | 53 +- aomp-device-libs/libm/src/complex.def | 165 ---- aomp-device-libs/libm/src/libm-amdgcn.c | 888 ---------------------- aomp-device-libs/libm/src/libm-amdgcn.cpp | 169 ---- aomp-device-libs/libm/src/libm-amdgcn.h | 405 ---------- aomp-device-libs/libm/src/libm-nvptx.c | 724 ------------------ aomp-device-libs/libm/src/libm-nvptx.cpp | 273 ------- aomp-device-libs/libm/src/libm-nvptx.h | 583 -------------- aomp-device-libs/libm/src/libm.c | 13 +- aomp-device-libs/libm/src/libm.cpp | 23 - 10 files changed, 25 insertions(+), 3271 deletions(-) delete mode 100644 aomp-device-libs/libm/src/complex.def delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.c delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.cpp delete mode 100644 aomp-device-libs/libm/src/libm-amdgcn.h delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.c delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.cpp delete mode 100644 aomp-device-libs/libm/src/libm-nvptx.h delete mode 100644 aomp-device-libs/libm/src/libm.cpp diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt index 4febc8a..939a995 100644 --- a/aomp-device-libs/libm/CMakeLists.txt +++ b/aomp-device-libs/libm/CMakeLists.txt @@ -33,14 +33,6 @@ else() return() endif() -# FIXME DELETE THESE COMMENTS -# Assome rocm-device-libs repository is next to aomp-extras repository -#set(ROCDL ${CMAKE_CURRENT_SOURCE_DIR}/../../../rocm-device-libs) -#set(ROCDL_INC_OCKL ${ROCDL}/ockl/inc) -#set(ROCDL_INC_OCML ${ROCDL}/ocml/inc) -#set(ROCDL_INC_IRIF ${ROCDL}/irif/inc) -#set(HIPINC ${CMAKE_CURRENT_SOURCE_DIR}/../../../hip/include) - #optimization level set(optimization_level 2) @@ -48,10 +40,6 @@ set(OUTPUTDIR ${CMAKE_CURRENT_BINARY_DIR}) macro(build_static_device_bc_lib) foreach(mcpu ${gpulist}) - # set(bundled_filename bundle_cpp.${mcpu}.bc) - # set(bundled_c_filename bundle_c.${mcpu}.bc) - set(bc_filename libm_cpp.${mcpu}.bc) - set(bc_c_filename libm_c.${mcpu}.bc) set(cpu_target x86_64-pc-linux-gnu) if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "ppc64le") set(cpu_target powerpc64le-linux-gnu) @@ -59,17 +47,15 @@ foreach(mcpu ${gpulist}) set(omp_common_args -c - --cuda-device-only + -emit-llvm -target ${cpu_target} -fopenmp -fopenmp-targets=${triple} -Xopenmp-target=${triple} -march=${mcpu} - -emit-llvm - -DNO_LIBM_HEADER_DEFS=1 - -O${optimization_level} - -I${CMAKE_CURRENT_SOURCE_DIR}/src - -I${LLVM_LIBRARY_DIRS}/libdevice/include) + --cuda-device-only + -nocudalib + -O${optimization_level}) if(NOT ${AOMP_STANDALONE_BUILD}) #FIXME Remove NEW_BC_PATH along with reference to /lib/bitcode when non-standalone build switches to new amdgcn path. @@ -81,25 +67,13 @@ foreach(mcpu ${gpulist}) set(omp_common_args "${omp_common_args};--hip-device-lib-path=${BC_DIR}") endif(NOT ${AOMP_STANDALONE_BUILD}) - set(openmp_cmd ${LLVM_INSTALL_PREFIX}/bin/clang++ -std=c++11 ${omp_common_args} - ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.cpp -o ${bc_filename}) set(openmp_c_cmd ${LLVM_INSTALL_PREFIX}/bin/clang ${omp_common_args} - ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c -o ${bc_c_filename}) - set(bc_files ${bc_filename} ${bc_c_filename}) - file(GLOB h_files "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") - # Compile cpp code with openmp to make bundled_filename - add_custom_command( - OUTPUT ${bc_filename} - COMMAND ${openmp_cmd} - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.cpp" ${h_files}) - add_custom_command( - OUTPUT ${bc_c_filename} - COMMAND ${openmp_c_cmd} - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" ${h_files}) + ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c) + add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}.bc - COMMAND ${LLVM_INSTALL_PREFIX}/bin/llvm-link ${bc_files} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DEPENDS ${bc_files} + OUTPUT libm-${systemarch}-${mcpu}.bc + COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" ) add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc) install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc @@ -129,17 +103,18 @@ set(nvptx_numbers $ENV{NVPTXGPUS}) if(NOT nvptx_numbers) set(nvptx_numbers "30,35,50,60,61,70") endif() + set(nvptxgpus) string(REGEX REPLACE "," ";" nvptx_numbers_list ${nvptx_numbers}) foreach(sm_number ${nvptx_numbers_list}) list(APPEND nvptxgpus "sm_${sm_number}") endforeach() + # prepare variables used by build_static_device_bc_lib set(gpulist ${nvptxgpus}) -message(" -- SKIPPING libm generation for ${gpulist} because cuda-clang already defined them.") -#set(systemarch "nvptx") -#set(triple "nvptx64-nvidia-cuda ") -#build_static_device_bc_lib() +set(systemarch "nvptx") +set(triple "nvptx64-nvidia-cuda ") +build_static_device_bc_lib() if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") message("--------------------------------------------") diff --git a/aomp-device-libs/libm/src/complex.def b/aomp-device-libs/libm/src/complex.def deleted file mode 100644 index d0e4948..0000000 --- a/aomp-device-libs/libm/src/complex.def +++ /dev/null @@ -1,165 +0,0 @@ -double _Complex __muldc3(double __a, double __b, double __c, - double __d) { - double __ac = __a * __c; - double __bd = __b * __d; - double __ad = __a * __d; - double __bc = __b * __c; - double _Complex z; - __real__(z) = __ac - __bd; - __imag__(z) = __ad + __bc; - if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { - int __recalc = 0; - if (_ISINFd(__a) || _ISINFd(__b)) { - __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a); - __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b); - if (_ISNANd(__c)) - __c = _COPYSIGNd(0, __c); - if (_ISNANd(__d)) - __d = _COPYSIGNd(0, __d); - __recalc = 1; - } - if (_ISINFd(__c) || _ISINFd(__d)) { - __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c); - __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d); - if (_ISNANd(__a)) - __a = _COPYSIGNd(0, __a); - if (_ISNANd(__b)) - __b = _COPYSIGNd(0, __b); - __recalc = 1; - } - if (!__recalc && - (_ISINFd(__ac) || _ISINFd(__bd) || _ISINFd(__ad) || _ISINFd(__bc))) { - if (_ISNANd(__a)) - __a = _COPYSIGNd(0, __a); - if (_ISNANd(__b)) - __b = _COPYSIGNd(0, __b); - if (_ISNANd(__c)) - __c = _COPYSIGNd(0, __c); - if (_ISNANd(__d)) - __d = _COPYSIGNd(0, __d); - __recalc = 1; - } - if (__recalc) { - // Can't use std::numeric_limits::infinity() -- that doesn't have - // a device overload (and isn't constexpr before C++11, naturally). - __real__(z) = __builtin_huge_val() * (__a * __c - __b * __d); - __imag__(z) = __builtin_huge_val() * (__a * __d + __b * __c); - } - } - return z; -} - -float _Complex __mulsc3(float __a, float __b, float __c, float __d) { - float __ac = __a * __c; - float __bd = __b * __d; - float __ad = __a * __d; - float __bc = __b * __c; - float _Complex z; - __real__(z) = __ac - __bd; - __imag__(z) = __ad + __bc; - if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { - int __recalc = 0; - if (_ISINFf(__a) || _ISINFf(__b)) { - __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); - __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); - if (_ISNANf(__c)) - __c = _COPYSIGNf(0, __c); - if (_ISNANf(__d)) - __d = _COPYSIGNf(0, __d); - __recalc = 1; - } - if (_ISINFf(__c) || _ISINFf(__d)) { - __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); - __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); - if (_ISNANf(__a)) - __a = _COPYSIGNf(0, __a); - if (_ISNANf(__b)) - __b = _COPYSIGNf(0, __b); - __recalc = 1; - } - if (!__recalc && - (_ISINFf(__ac) || _ISINFf(__bd) || _ISINFf(__ad) || _ISINFf(__bc))) { - if (_ISNANf(__a)) - __a = _COPYSIGNf(0, __a); - if (_ISNANf(__b)) - __b = _COPYSIGNf(0, __b); - if (_ISNANf(__c)) - __c = _COPYSIGNf(0, __c); - if (_ISNANf(__d)) - __d = _COPYSIGNf(0, __d); - __recalc = 1; - } - if (__recalc) { - __real__(z) = __builtin_huge_valf() * (__a * __c - __b * __d); - __imag__(z) = __builtin_huge_valf() * (__a * __d + __b * __c); - } - } - return z; -} - -double _Complex __divdc3(double __a, double __b, double __c, - double __d) { - int __ilogbw = 0; - double __logbw = _LOGBd(fmax(_ABSd(__c), _ABSd(__d))); - if (_ISFINITEd(__logbw)) { - __ilogbw = (int)__logbw; - __c = _SCALBNd(__c, -__ilogbw); - __d = _SCALBNd(__d, -__ilogbw); - } - double __denom = __c * __c + __d * __d; - double _Complex z; - __real__(z) = _SCALBNd((__a * __c + __b * __d) / __denom, -__ilogbw); - __imag__(z) = _SCALBNd((__b * __c - __a * __d) / __denom, -__ilogbw); - if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) { - if ((__denom == 0.0) && (!_ISNANd(__a) || !_ISNANd(__b))) { - __real__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __a; - __imag__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __b; - } else if ((_ISINFd(__a) || _ISINFd(__b)) && _ISFINITEd(__c) && - _ISFINITEd(__d)) { - __a = _COPYSIGNd(_ISINFd(__a) ? 1.0 : 0.0, __a); - __b = _COPYSIGNd(_ISINFd(__b) ? 1.0 : 0.0, __b); - __real__(z) = __builtin_huge_val() * (__a * __c + __b * __d); - __imag__(z) = __builtin_huge_val() * (__b * __c - __a * __d); - } else if (_ISINFd(__logbw) && __logbw > 0.0 && _ISFINITEd(__a) && - _ISFINITEd(__b)) { - __c = _COPYSIGNd(_ISINFd(__c) ? 1.0 : 0.0, __c); - __d = _COPYSIGNd(_ISINFd(__d) ? 1.0 : 0.0, __d); - __real__(z) = 0.0 * (__a * __c + __b * __d); - __imag__(z) = 0.0 * (__b * __c - __a * __d); - } - } - return z; -} - -float _Complex __divsc3(float __a, float __b, float __c, float __d) { - int __ilogbw = 0; - float __logbw = _LOGBf(fmaxf(_ABSf(__c), _ABSf(__d))); - if (_ISFINITEf(__logbw)) { - __ilogbw = (int)__logbw; - __c = _SCALBNf(__c, -__ilogbw); - __d = _SCALBNf(__d, -__ilogbw); - } - float __denom = __c * __c + __d * __d; - float _Complex z; - __real__(z) = _SCALBNf((__a * __c + __b * __d) / __denom, -__ilogbw); - __imag__(z) = _SCALBNf((__b * __c - __a * __d) / __denom, -__ilogbw); - if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) { - if ((__denom == 0) && (!_ISNANf(__a) || !_ISNANf(__b))) { - __real__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __a; - __imag__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __b; - } else if ((_ISINFf(__a) || _ISINFf(__b)) && _ISFINITEf(__c) && - _ISFINITEf(__d)) { - __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a); - __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b); - __real__(z) = __builtin_huge_valf() * (__a * __c + __b * __d); - __imag__(z) = __builtin_huge_valf() * (__b * __c - __a * __d); - } else if (_ISINFf(__logbw) && __logbw > 0 && _ISFINITEf(__a) && - _ISFINITEf(__b)) { - __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c); - __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d); - __real__(z) = 0 * (__a * __c + __b * __d); - __imag__(z) = 0 * (__b * __c - __a * __d); - } - } - return z; -} diff --git a/aomp-device-libs/libm/src/libm-amdgcn.c b/aomp-device-libs/libm/src/libm-amdgcn.c deleted file mode 100644 index e9471b6..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.c +++ /dev/null @@ -1,888 +0,0 @@ -//===--------- libm/libm-amdgcn.c -----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include "libm-amdgcn.h" - -#define __private __attribute__((address_space(5))) -#define USED __attribute__((used)) -#pragma omp declare target -unsigned long long __make_mantissa_base8(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '7') r = (r * 8u) + tmp - '0'; - else return 0; - - ++tagp; - } - - return r; -} - -unsigned long long __make_mantissa_base10(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '9') r = (r * 10u) + tmp - '0'; - else return 0; - - ++tagp; - } - - return r; -} - - -unsigned long long __make_mantissa_base16(const char* tagp) -{ - unsigned long long r = 0; - while (tagp) { - char tmp = *tagp; - - if (tmp >= '0' && tmp <= '9') r = (r * 16u) + tmp - '0'; - else if (tmp >= 'a' && tmp <= 'f') r = (r * 16u) + tmp - 'a' + 10; - else if (tmp >= 'A' && tmp <= 'F') r = (r * 16u) + tmp - 'A' + 10; - else return 0; - - ++tagp; - } - - return r; -} - - -unsigned long long __make_mantissa(const char* tagp) -{ - if (!tagp) return 0u; - - if (*tagp == '0') { - ++tagp; - - if (*tagp == 'x' || *tagp == 'X') return __make_mantissa_base16(tagp); - else return __make_mantissa_base8(tagp); - } - - return __make_mantissa_base10(tagp); -} - -// BEGIN FLOAT - -float acosf(float x) { return __ocml_acos_f32(x); } - -float acoshf(float x) { return __ocml_acosh_f32(x); } - -float asinf(float x) { return __ocml_asin_f32(x); } - -float asinhf(float x) { return __ocml_asinh_f32(x); } - -float atan2f(float x, float y) { return __ocml_atan2_f32(x, y); } - -float atanf(float x) { return __ocml_atan_f32(x); } - -float atanhf(float x) { return __ocml_atanh_f32(x); } - -float cbrtf(float x) { return __ocml_cbrt_f32(x); } - -float ceilf(float x) { return __ocml_ceil_f32(x); } - -float copysignf(float x, float y) { return __ocml_copysign_f32(x, y); } - -USED float cosf(float x) { return __ocml_cos_f32(x); } - -float coshf(float x) { return __ocml_cosh_f32(x); } - -float cospif(float x) { return __ocml_cospi_f32(x); } - -float cyl_bessel_i0f(float x) { return __ocml_i0_f32(x); } - -float cyl_bessel_i1f(float x) { return __ocml_i1_f32(x); } - -float erfcf(float x) { return __ocml_erfc_f32(x); } - -float erfcinvf(float x) { return __ocml_erfcinv_f32(x); } - -float erfcxf(float x) { return __ocml_erfcx_f32(x); } - -float erff(float x) { return __ocml_erf_f32(x); } - -float erfinvf(float x) { return __ocml_erfinv_f32(x); } - -float exp10f(float x) { return __ocml_exp10_f32(x); } - -float exp2f(float x) { return __ocml_exp2_f32(x); } - -float expf(float x) { return __ocml_exp_f32(x); } - -float expm1f(float x) { return __ocml_expm1_f32(x); } - -float fabsf(float x) { return __ocml_fabs_f32(x); } - -float fdimf(float x, float y) { return __ocml_fdim_f32(x, y); } - -float fdividef(float x, float y) { return x / y; } - -float floorf(float x) { return __ocml_floor_f32(x); } - -float fmaf(float x, float y, float z) { return __ocml_fma_f32(x, y, z); } - -float fmaxf(float x, float y) { return __ocml_fmax_f32(x, y); } - -float fminf(float x, float y) { return __ocml_fmin_f32(x, y); } - -float fmodf(float x, float y) { return __ocml_fmod_f32(x, y); } - -float frexpf(float x, int* nptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - float r = - __ocml_frexp_f32(x, &tmp); - *nptr = tmp; - - return r; -} - -float hypotf(float x, float y) { return __ocml_hypot_f32(x, y); } - -int ilogbf(float x) { return __ocml_ilogb_f32(x); } - -//int isfinite(float x) { return __ocml_isfinite_f32(x); } -int __finitef(float x) { return __ocml_isfinite_f32(x); } - - -int __isinff(float x) { return __ocml_isinf_f32(x); } - -int __isnanf(float x) { return __ocml_isnan_f32(x); } - -float j0f(float x) { return __ocml_j0_f32(x); } - -float j1f(float x) { return __ocml_j1_f32(x); } - -float jnf(int n, float x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - float x0 = j0f(x); - float x1 = j1f(x); - for (int i = 1; i < n; ++i) { - float x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -float ldexpf(float x, int e) { return __ocml_ldexp_f32(x, e); } - -float lgammaf(float x) { return __ocml_lgamma_f32(x); } - -long long int llrintf(float x) { return __ocml_rint_f32(x); } - -long long int llroundf(float x) { return __ocml_round_f32(x); } - -float log10f(float x) { return __ocml_log10_f32(x); } - -float log1pf(float x) { return __ocml_log1p_f32(x); } - -float log2f(float x) { return __ocml_log2_f32(x); } - -float logbf(float x) { return __ocml_logb_f32(x); } - -float logf(float x) { return __ocml_log_f32(x); } - -long int lrintf(float x) { return __ocml_rint_f32(x); } - -long int lroundf(float x) { return __ocml_round_f32(x); } - -float modff(float x, float* iptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - float r = - __ocml_modf_f32(x, &tmp); - *iptr = tmp; - - return r; -} - -float nanf(const char* tagp) -{ - union { - float val; - struct ieee_float { - unsigned mantissa : 22; - unsigned quiet : 1; - unsigned exponent : 8; - unsigned sign : 1; - } bits; - - // static_assert(sizeof(float) == sizeof(ieee_float), ""); - } tmp; - - tmp.bits.sign = 0u; - tmp.bits.exponent = ~0u; - tmp.bits.quiet = 1u; - tmp.bits.mantissa = __make_mantissa(tagp); - - return tmp.val; -} - -float nearbyintf(float x) { return __ocml_nearbyint_f32(x); } - -float nextafterf(float x, float y) { return __ocml_nextafter_f32(x, y); } - -float norm3df(float x, float y, float z) { return __ocml_len3_f32(x, y, z); } - -float norm4df(float x, float y, float z, float w) -{ - return __ocml_len4_f32(x, y, z, w); -} - -float normcdff(float x) { return __ocml_ncdf_f32(x); } - -float normcdfinvf(float x) { return __ocml_ncdfinv_f32(x); } - -float normf(int dim, const float* a) -{ // TODO: placeholder until OCML adds support. - float r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_sqrt_f32(r); -} - -float powf(float x, float y) { return __ocml_pow_f32(x, y); } - -float rcbrtf(float x) { return __ocml_rcbrt_f32(x); } - -float remainderf(float x, float y) { return __ocml_remainder_f32(x, y); } - -float remquof(float x, float y, int* quo) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - float r = - __ocml_remquo_f32(x, y, &tmp); - *quo = tmp; - - return r; -} - -float rhypotf(float x, float y) { return __ocml_rhypot_f32(x, y); } - -float rintf(float x) { return __ocml_rint_f32(x); } - -float rnorm3df(float x, float y, float z) -{ - return __ocml_rlen3_f32(x, y, z); -} - - -float rnorm4df(float x, float y, float z, float w) -{ - return __ocml_rlen4_f32(x, y, z, w); -} - -float rnormf(int dim, const float* a) -{ // TODO: placeholder until OCML adds support. - float r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_rsqrt_f32(r); -} - -float roundf(float x) { return __ocml_round_f32(x); } - -float rsqrtf(float x) { return __ocml_rsqrt_f32(x); } - -float scalblnf(float x, long int n) -{ - return (n < INT_MAX) ? __ocml_scalbn_f32(x, n) : __ocml_scalb_f32(x, n); -} - -float scalbnf(float x, int n) { return __ocml_scalbn_f32(x, n); } - -int __signbitf(float x) { return __ocml_signbit_f32(x); } - -void sincosf(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincos_f32(x, &tmp); - *cptr = tmp; -} - -void sincospif(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincospi_f32(x, &tmp); - *cptr = tmp; -} - -USED float sinf(float x) { return __ocml_sin_f32(x); } - -float sinhf(float x) { return __ocml_sinh_f32(x); } - -float sinpif(float x) { return __ocml_sinpi_f32(x); } - -USED float sqrtf(float x) { return __ocml_sqrt_f32(x); } - -float tanf(float x) { return __ocml_tan_f32(x); } - -float tanhf(float x) { return __ocml_tanh_f32(x); } - -float tgammaf(float x) { return __ocml_tgamma_f32(x); } - -float truncf(float x) { return __ocml_trunc_f32(x); } - -float y0f(float x) { return __ocml_y0_f32(x); } - -float y1f(float x) { return __ocml_y1_f32(x); } - -float ynf(int n, float x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return y0f(x); - if (n == 1) return y1f(x); - - float x0 = y0f(x); - float x1 = y1f(x); - for (int i = 1; i < n; ++i) { - float x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -// BEGIN INTRINSICS - -float __cosf(float x) { return __llvm_amdgcn_cos_f32(x); } - -float __exp10f(float x) { return __ocml_exp10_f32(x); } - -float __expf(float x) { return __ocml_exp_f32(x); } - -float __fadd_rd(float x, float y) { return __ocml_add_rtp_f32(x, y); } - -float __fadd_rn(float x, float y) { return __ocml_add_rte_f32(x, y); } - -float __fadd_ru(float x, float y) { return __ocml_add_rtn_f32(x, y); } - -float __fadd_rz(float x, float y) { return __ocml_add_rtz_f32(x, y); } - -float __fdiv_rd(float x, float y) { return x / y; } - -float __fdiv_rn(float x, float y) { return x / y; } - -float __fdiv_ru(float x, float y) { return x / y; } - -float __fdiv_rz(float x, float y) { return x / y; } - -float __fdividef(float x, float y) { return x / y; } - -float __fmaf_rd(float x, float y, float z) -{ - return __ocml_fma_rtp_f32(x, y, z); -} - -float __fmaf_rn(float x, float y, float z) -{ - return __ocml_fma_rte_f32(x, y, z); -} - -float __fmaf_ru(float x, float y, float z) -{ - return __ocml_fma_rtn_f32(x, y, z); -} - -float __fmaf_rz(float x, float y, float z) -{ - return __ocml_fma_rtz_f32(x, y, z); -} - -float __fmul_rd(float x, float y) { return __ocml_mul_rtp_f32(x, y); } - -float __fmul_rn(float x, float y) { return __ocml_mul_rte_f32(x, y); } - -float __fmul_ru(float x, float y) { return __ocml_mul_rtn_f32(x, y); } - -float __fmul_rz(float x, float y) { return __ocml_mul_rtz_f32(x, y); } - -float __frcp_rd(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_rn(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_ru(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frcp_rz(float x) { return __llvm_amdgcn_rcp_f32(x); } - -float __frsqrt_rn(float x) { return __llvm_amdgcn_rsq_f32(x); } - -float __fsqrt_rd(float x) { return __ocml_sqrt_rtp_f32(x); } - -float __fsqrt_rn(float x) { return __ocml_sqrt_rte_f32(x); } - -float __fsqrt_ru(float x) { return __ocml_sqrt_rtn_f32(x); } - -float __fsqrt_rz(float x) { return __ocml_sqrt_rtz_f32(x); } - -float __fsub_rd(float x, float y) { return __ocml_sub_rtp_f32(x, y); } - -float __fsub_rn(float x, float y) { return __ocml_sub_rte_f32(x, y); } - -float __fsub_ru(float x, float y) { return __ocml_sub_rtn_f32(x, y); } - -float __fsub_rz(float x, float y) { return __ocml_sub_rtz_f32(x, y); } - -float __log10f(float x) { return __ocml_log10_f32(x); } - -float __log2f(float x) { return __ocml_log2_f32(x); } - -float __logf(float x) { return __ocml_log_f32(x); } - -float __powf(float x, float y) { return __ocml_pow_f32(x, y); } - -float __saturatef(float x) { return (x < 0) ? 0 : ((x > 1) ? 1 : x); } - -void __sincosf(float x, float* sptr, float* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private float tmp; - *sptr = - __ocml_sincos_f32(x, &tmp); - *cptr = tmp; -} - -float __sinf(float x) { return __llvm_amdgcn_sin_f32(x); } - -float __tanf(float x) { return __ocml_tan_f32(x); } -// END INTRINSICS -// END FLOAT - -// BEGIN DOUBLE - -//double abs(double x) { return __ocml_fabs_f64(x); } - -double acos(double x) { return __ocml_acos_f64(x); } - -double acosh(double x) { return __ocml_acosh_f64(x); } - -double asin(double x) { return __ocml_asin_f64(x); } - -double asinh(double x) { return __ocml_asinh_f64(x); } - -double atan(double x) { return __ocml_atan_f64(x); } - -double atan2(double x, double y) { return __ocml_atan2_f64(x, y); } - -double atanh(double x) { return __ocml_atanh_f64(x); } - -double cbrt(double x) { return __ocml_cbrt_f64(x); } - -double ceil(double x) { return __ocml_ceil_f64(x); } - -double copysign(double x, double y) { return __ocml_copysign_f64(x, y); } - -double cos(double x) { return __ocml_cos_f64(x); } - -double cosh(double x) { return __ocml_cosh_f64(x); } - -double cospi(double x) { return __ocml_cospi_f64(x); } - -double cyl_bessel_i0(double x) { return __ocml_i0_f64(x); } - -double cyl_bessel_i1(double x) { return __ocml_i1_f64(x); } - -double erf(double x) { return __ocml_erf_f64(x); } - -double erfc(double x) { return __ocml_erfc_f64(x); } - -double erfcinv(double x) { return __ocml_erfcinv_f64(x); } - -double erfcx(double x) { return __ocml_erfcx_f64(x); } - -double erfinv(double x) { return __ocml_erfinv_f64(x); } - -double exp(double x) { return __ocml_exp_f64(x); } - -double exp10(double x) { return __ocml_exp10_f64(x); } - -double exp2(double x) { return __ocml_exp2_f64(x); } - -double expm1(double x) { return __ocml_expm1_f64(x); } - -double fabs(double x) { return __ocml_fabs_f64(x); } - -double fdim(double x, double y) { return __ocml_fdim_f64(x, y); } - -double fdivide(double x, double y) { return x / y; } - -double floor(double x) { return __ocml_floor_f64(x); } - -double fma(double x, double y, double z) { return __ocml_fma_f64(x, y, z); } - -double fmax(double x, double y) { return __ocml_fmax_f64(x, y); } - -double fmin(double x, double y) { return __ocml_fmin_f64(x, y); } - -double fmod(double x, double y) { return __ocml_fmod_f64(x, y); } - -double frexp(double x, int* nptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - double r = - __ocml_frexp_f64(x, &tmp); - *nptr = tmp; - - return r; -} - -double hypot(double x, double y) { return __ocml_hypot_f64(x, y); } - -int ilogb(double x) { return __ocml_ilogb_f64(x); } - -int __finite(double x) { return __ocml_isfinite_f64(x); } - -//int __isinf(double x) { return __ocml_isinf_f64(x); } - -//int __isnan(double x) { return __ocml_isnan_f64(x); } - -double j0(double x) { return __ocml_j0_f64(x); } - -double j1(double x) { return __ocml_j1_f64(x); } - -double jn(int n, double x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - double x0 = j0f(x); - double x1 = j1f(x); - for (int i = 1; i < n; ++i) { - double x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -double ldexp(double x, int e) { return __ocml_ldexp_f64(x, e); } - -double lgamma(double x) { return __ocml_lgamma_f64(x); } - -long long int llrint(double x) { return __ocml_rint_f64(x); } - -long long int llround(double x) { return __ocml_round_f64(x); } - -double log(double x) { return __ocml_log_f64(x); } - -double log10(double x) { return __ocml_log10_f64(x); } - -double log1p(double x) { return __ocml_log1p_f64(x); } - -double log2(double x) { return __ocml_log2_f64(x); } - -double logb(double x) { return __ocml_logb_f64(x); } - -long int lrint(double x) { return __ocml_rint_f64(x); } - -long int lround(double x) { return __ocml_round_f64(x); } - -double modf(double x, double* iptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - double r = - __ocml_modf_f64(x, &tmp); - *iptr = tmp; - - return r; -} - -double nan(const char* tagp) -{ - union { - double val; - struct ieee_double { - unsigned long long mantissa : 51; - unsigned quiet : 1; - unsigned exponent : 11; - unsigned sign : 1; - } bits; - - // static_assert(sizeof(double) == sizeof(ieee_double), ""); - } tmp; - - tmp.bits.sign = 0u; - tmp.bits.exponent = ~0u; - tmp.bits.quiet = 1u; - tmp.bits.mantissa = __make_mantissa(tagp); - - return tmp.val; -} - -double nearbyint(double x) { return __ocml_nearbyint_f64(x); } - -double nextafter(double x, double y) { return __ocml_nextafter_f64(x, y); } - -double norm(int dim, const double* a) -{ // TODO: placeholder until OCML adds support. - double r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_sqrt_f64(r); -} - -double norm3d(double x, double y, double z) -{ - return __ocml_len3_f64(x, y, z); -} - -double norm4d(double x, double y, double z, double w) -{ - return __ocml_len4_f64(x, y, z, w); -} - -double normcdf(double x) { return __ocml_ncdf_f64(x); } - -double normcdfinv(double x) { return __ocml_ncdfinv_f64(x); } - -double pow(double x, double y) { return __ocml_pow_f64(x, y); } - -double rcbrt(double x) { return __ocml_rcbrt_f64(x); } - -double remainder(double x, double y) { return __ocml_remainder_f64(x, y); } - -double remquo(double x, double y, int* quo) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private int tmp; - double r = - __ocml_remquo_f64(x, y, &tmp); - *quo = tmp; - - return r; -} - -double rhypot(double x, double y) { return __ocml_rhypot_f64(x, y); } - -double rint(double x) { return __ocml_rint_f64(x); } - -double rnorm(int dim, const double* a) -{ // TODO: placeholder until OCML adds support. - double r = 0; - while (dim--) { r += a[0] * a[0]; ++a; } - - return __ocml_rsqrt_f64(r); -} - -double rnorm3d(double x, double y, double z) -{ - return __ocml_rlen3_f64(x, y, z); -} - -double rnorm4d(double x, double y, double z, double w) -{ - return __ocml_rlen4_f64(x, y, z, w); -} - -double round(double x) { return __ocml_round_f64(x); } - -double rsqrt(double x) { return __ocml_rsqrt_f64(x); } - -double scalbln(double x, long int n) -{ - return (n < INT_MAX) ? __ocml_scalbn_f64(x, n) : __ocml_scalb_f64(x, n); -} - -double scalbn(double x, int n) { return __ocml_scalbn_f64(x, n); } - -int __signbit(double x) { return __ocml_signbit_f64(x); } - -double sin(double x) { return __ocml_sin_f64(x); } - -void sincos(double x, double* sptr, double* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - *sptr = __ocml_sincos_f64(x, &tmp); - *cptr = tmp; -} - -void sincospi(double x, double* sptr, double* cptr) -{ - //FIXME: Added the address space cast to tmp to prevent globalization when building aomp-extras - static __private double tmp; - *sptr = __ocml_sincospi_f64(x, &tmp); - *cptr = tmp; -} - -double sinh(double x) { return __ocml_sinh_f64(x); } - -double sinpi(double x) { return __ocml_sinpi_f64(x); } - -double sqrt(double x) { return __ocml_sqrt_f64(x); } - -double tan(double x) { return __ocml_tan_f64(x); } - -double tanh(double x) { return __ocml_tanh_f64(x); } - -double tgamma(double x) { return __ocml_tgamma_f64(x); } - -double trunc(double x) { return __ocml_trunc_f64(x); } - -double y0(double x) { return __ocml_y0_f64(x); } - -double y1(double x) { return __ocml_y1_f64(x); } - -double yn(int n, double x) -{ // TODO: we could use Ahmes multiplication and the Miller & Brown algorithm - // for linear recurrences to get O(log n) steps, but it's unclear if - // it'd be beneficial in this case. Placeholder until OCML adds - // support. - if (n == 0) return j0f(x); - if (n == 1) return j1f(x); - - double x0 = j0f(x); - double x1 = j1f(x); - for (int i = 1; i < n; ++i) { - double x2 = (2 * i) / x * x1 - x0; - x0 = x1; - x1 = x2; - } - - return x1; -} - -// BEGIN INTRINSICS - -double __dadd_rd(double x, double y) { return __ocml_add_rtp_f64(x, y); } - -double __dadd_rn(double x, double y) { return __ocml_add_rte_f64(x, y); } - -double __dadd_ru(double x, double y) { return __ocml_add_rtn_f64(x, y); } - -double __dadd_rz(double x, double y) { return __ocml_add_rtz_f64(x, y); } - -double __ddiv_rd(double x, double y) { return x / y; } - -double __ddiv_rn(double x, double y) { return x / y; } - -double __ddiv_ru(double x, double y) { return x / y; } - -double __ddiv_rz(double x, double y) { return x / y; } - -double __dmul_rd(double x, double y) { return __ocml_mul_rtp_f64(x, y); } - -double __dmul_rn(double x, double y) { return __ocml_mul_rte_f64(x, y); } - -double __dmul_ru(double x, double y) { return __ocml_mul_rtn_f64(x, y); } - -double __dmul_rz(double x, double y) { return __ocml_mul_rtz_f64(x, y); } - -double __drcp_rd(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_rn(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_ru(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __drcp_rz(double x) { return __llvm_amdgcn_rcp_f64(x); } - -double __dsqrt_rd(double x) { return __ocml_sqrt_rtp_f64(x); } - -double __dsqrt_rn(double x) { return __ocml_sqrt_rte_f64(x); } - -double __dsqrt_ru(double x) { return __ocml_sqrt_rtn_f64(x); } - -double __dsqrt_rz(double x) { return __ocml_sqrt_rtz_f64(x); } - -double __dsub_rd(double x, double y) { return __ocml_sub_rtp_f64(x, y); } - -double __dsub_rn(double x, double y) { return __ocml_sub_rte_f64(x, y); } - -double __dsub_ru(double x, double y) { return __ocml_sub_rtn_f64(x, y); } - -double __dsub_rz(double x, double y) { return __ocml_sub_rtz_f64(x, y); } - -double __fma_rd(double x, double y, double z) -{ - return __ocml_fma_rtp_f64(x, y, z); -} - -double __fma_rn(double x, double y, double z) -{ - return __ocml_fma_rte_f64(x, y, z); -} - -double __fma_ru(double x, double y, double z) -{ - return __ocml_fma_rtn_f64(x, y, z); -} - -double __fma_rz(double x, double y, double z) -{ - return __ocml_fma_rtz_f64(x, y, z); -} -// END INTRINSICS -// END DOUBLE - -// Complex functions -#define _ISNANd __ocml_isnan_f64 -#define _ISNANf __isnanf -#define _ISINFd __ocml_isinf_f64 -#define _ISINFf __isinff -#define _ISFINITEd __finite -#define _ISFINITEf __finitef -#define _COPYSIGNd copysign -#define _COPYSIGNf copysignf -#define _SCALBNd scalbn -#define _SCALBNf scalbnf -#define _ABSd fabs -#define _ABSf fabsf -#define _LOGBd logb -#define _LOGBf logbf - -#include "complex.def" - -#undef _ISNANd -#undef _ISNANf -#undef _ISINFd -#undef _ISINFf -#undef _COPYSIGNd -#undef _COPYSIGNf -#undef _ISFINITEd -#undef _ISFINITEf -#undef _SCALBNd -#undef _SCALBNf -#undef _ABSd -#undef _ABSf -#undef _LOGBd -#undef _LOGBf - -#pragma omp end declare target diff --git a/aomp-device-libs/libm/src/libm-amdgcn.cpp b/aomp-device-libs/libm/src/libm-amdgcn.cpp deleted file mode 100644 index 202248d..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.cpp +++ /dev/null @@ -1,169 +0,0 @@ -//===--------- libm/libm-amdgcn.cpp ---------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include -#include -#include "libm-amdgcn.h" -#pragma omp declare target - -/// Do not provide the double overload because the base functions -/// are defined in libm-amdgcn.c. Only provide non-base variants. - -int abs(int x) -{ - int sgn = x >> (sizeof(int) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} -long labs(long x) -{ - long sgn = x >> (sizeof(long) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} -long long llabs(long long x) -{ - long long sgn = x >> (sizeof(long long) * CHAR_BIT - 1); - return (x ^ sgn) - sgn; -} - -// Template helpers -template -struct __amdgcn_enable_if {}; - -template struct __amdgcn_enable_if { - typedef __T type; -}; - -#define __AMDGCN_OVERLOAD1(__retty, __fn) \ - template \ - typename __amdgcn_enable_if::is_integer, \ - __retty>::type \ - __fn(__T __x) { \ - return ::__fn((double)__x); \ - } - -#define __AMDGCN_OVERLOAD2(__retty, __fn) \ - template \ - typename __amdgcn_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y) { \ - return __fn((double)__x, (double)__y); \ - } -#define __AMDGCN_OVERLOAD3(__retty, __fn) \ - template \ - typename __amdgcn_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized && \ - std::numeric_limits<__T3>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y, __T3 __z) { \ - return __fn((double)__x, (double)__y, (double)__z); \ - } -#define __DEF_FUN1(retty, func) \ -inline \ -float func(float x) \ -{ \ - return func##f(x); \ -} \ -__AMDGCN_OVERLOAD1(retty, func) - -// Define cmath functions with float argument and returns retty. -#define __DEF_FUNI(retty, func) \ -inline \ -retty func(float x) \ -{ \ - return func##f(x); \ -} \ -__AMDGCN_OVERLOAD1(retty, func) - -// define cmath functions with two float arguments. -#define __DEF_FUN2(retty, func) \ -inline \ -float func(float x, float y) \ -{ \ - return func##f(x, y); \ -} \ -__AMDGCN_OVERLOAD2(retty, func) - -// define cmath functions with three float arguments. -#define __DEF_FUN3(retty, func) \ -inline \ -float func(float x, float y, float z) \ -{ \ - return func##f(x, y, z); \ -} \ -__AMDGCN_OVERLOAD3(retty, func) -// cmath functions -long abs(long x) { return labs(x); } -long long abs(long long x) { return llabs(x); } -__DEF_FUN1(double, acos) -__DEF_FUN1(double, acosh) -__DEF_FUN1(double, asin) -__DEF_FUN1(double, asinh) -__DEF_FUN1(double, atan) -__DEF_FUN2(double, atan2); -__DEF_FUN1(double, atanh) -__DEF_FUN1(double, cbrt) -__DEF_FUN1(double, ceil) -__DEF_FUN2(double, copysign); -__DEF_FUN1(double, cos) -__DEF_FUN1(double, cosh) -__DEF_FUN1(double, erf) -__DEF_FUN1(double, erfc) -__DEF_FUN1(double, exp) -__DEF_FUN1(double, exp2) -__DEF_FUN1(double, expm1) -__DEF_FUN1(double, fabs) -__DEF_FUN2(double, fdim); -__DEF_FUN1(double, floor) -__DEF_FUN3(double, fma) -__DEF_FUN2(double, fmax); -__DEF_FUN2(double, fmin); -__DEF_FUN2(double, fmod); -//__AMDGCN_OVERLOAD1(int, fpclassify) -__DEF_FUN2(double, hypot); -__DEF_FUNI(int, ilogb) -//__AMDGCN_OVERLOAD1(bool, isfinite) -__AMDGCN_OVERLOAD2(bool, isgreater); -__AMDGCN_OVERLOAD2(bool, isgreaterequal); -//__AMDGCN_OVERLOAD1(bool, isinf); -__AMDGCN_OVERLOAD2(bool, isless); -__AMDGCN_OVERLOAD2(bool, islessequal); -__AMDGCN_OVERLOAD2(bool, islessgreater); -//__AMDGCN_OVERLOAD1(bool, isnan); -//__AMDGCN_OVERLOAD1(bool, isnormal) -__AMDGCN_OVERLOAD2(bool, isunordered); -__DEF_FUN1(double, lgamma) -__DEF_FUN1(double, log) -__DEF_FUN1(double, log10) -__DEF_FUN1(double, log1p) -__DEF_FUN1(double, log2) -__DEF_FUN1(double, logb) -__DEF_FUNI(long long, llrint) -__DEF_FUNI(long long, llround) -__DEF_FUNI(long, lrint) -__DEF_FUNI(long, lround) -__DEF_FUN1(double, nearbyint); -__DEF_FUN2(double, nextafter); -__DEF_FUN2(double, pow); -__DEF_FUN2(double, remainder); -__DEF_FUN1(double, rint); -__DEF_FUN1(double, round); -//__AMDGCN_OVERLOAD1(bool, signbit) -__DEF_FUN1(double, sin) -__DEF_FUN1(double, sinh) -__DEF_FUN1(double, sqrt) -__DEF_FUN1(double, tan) -__DEF_FUN1(double, tanh) -__DEF_FUN1(double, tgamma) -__DEF_FUN1(double, trunc); - -#pragma omp end declare target diff --git a/aomp-device-libs/libm/src/libm-amdgcn.h b/aomp-device-libs/libm/src/libm-amdgcn.h deleted file mode 100644 index b0d6378..0000000 --- a/aomp-device-libs/libm/src/libm-amdgcn.h +++ /dev/null @@ -1,405 +0,0 @@ -//===--------- libm/libm-amdgcn.h -----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef __LIBM_AMDGCN_H__ -#define __LIBM_AMDGCN_H__ - - -#if defined(__cplusplus) - extern "C" { -#endif - -// BEGIN FLOAT -__attribute__((const)) -float __ocml_acos_f32(float); -__attribute__((pure)) -float __ocml_acosh_f32(float); -__attribute__((const)) -float __ocml_asin_f32(float); -__attribute__((pure)) -float __ocml_asinh_f32(float); -__attribute__((const)) -float __ocml_atan2_f32(float, float); -__attribute__((const)) -float __ocml_atan_f32(float); -__attribute__((pure)) -float __ocml_atanh_f32(float); -__attribute__((pure)) -float __ocml_cbrt_f32(float); -__attribute__((const)) -float __ocml_ceil_f32(float); -__attribute__((const)) -float __ocml_copysign_f32(float, float); -float __ocml_cos_f32(float); -__attribute__((pure)) -float __ocml_cosh_f32(float); -float __ocml_cospi_f32(float); -float __ocml_i0_f32(float); -float __ocml_i1_f32(float); -__attribute__((pure)) -float __ocml_erfc_f32(float); -__attribute__((pure)) -float __ocml_erfcinv_f32(float); -__attribute__((pure)) -float __ocml_erfcx_f32(float); -__attribute__((pure)) -float __ocml_erf_f32(float); -__attribute__((pure)) -float __ocml_erfinv_f32(float); -__attribute__((pure)) -float __ocml_exp10_f32(float); -__attribute__((pure)) -float __ocml_exp2_f32(float); -__attribute__((pure)) -float __ocml_exp_f32(float); -__attribute__((pure)) -float __ocml_expm1_f32(float); -__attribute__((const)) -float __ocml_fabs_f32(float); -__attribute__((const)) -float __ocml_fdim_f32(float, float); -__attribute__((const)) -float __ocml_floor_f32(float); -__attribute__((const)) -float __ocml_fma_f32(float, float, float); -__attribute__((const)) -float __ocml_fmax_f32(float, float); -__attribute__((const)) -float __ocml_fmin_f32(float, float); -__attribute__((const)) -float __ocml_fmod_f32(float, float); -float __ocml_frexp_f32(float, __attribute__((address_space(5))) int*); -__attribute__((const)) -float __ocml_hypot_f32(float, float); -__attribute__((const)) -int __ocml_ilogb_f32(float); -__attribute__((const)) -int __ocml_isfinite_f32(float); -__attribute__((const)) -int __ocml_isinf_f32(float); -__attribute__((const)) -int __ocml_isnan_f32(float); -float __ocml_j0_f32(float); -float __ocml_j1_f32(float); -__attribute__((const)) -float __ocml_ldexp_f32(float, int); -float __ocml_lgamma_f32(float); -__attribute__((pure)) -float __ocml_log10_f32(float); -__attribute__((pure)) -float __ocml_log1p_f32(float); -__attribute__((pure)) -float __ocml_log2_f32(float); -__attribute__((const)) -float __ocml_logb_f32(float); -__attribute__((pure)) -float __ocml_log_f32(float); -float __ocml_modf_f32(float, __attribute__((address_space(5))) float*); -__attribute__((const)) -float __ocml_nearbyint_f32(float); -__attribute__((const)) -float __ocml_nextafter_f32(float, float); -__attribute__((const)) -float __ocml_len3_f32(float, float, float); -__attribute__((const)) -float __ocml_len4_f32(float, float, float, float); -__attribute__((pure)) -float __ocml_ncdf_f32(float); -__attribute__((pure)) -float __ocml_ncdfinv_f32(float); -__attribute__((pure)) -float __ocml_pow_f32(float, float); -__attribute__((pure)) -float __ocml_rcbrt_f32(float); -__attribute__((const)) -float __ocml_remainder_f32(float, float); -float __ocml_remquo_f32(float, float, __attribute__((address_space(5))) int*); -__attribute__((const)) -float __ocml_rhypot_f32(float, float); -__attribute__((const)) -float __ocml_rint_f32(float); -__attribute__((const)) -float __ocml_rlen3_f32(float, float, float); -__attribute__((const)) -float __ocml_rlen4_f32(float, float, float, float); -__attribute__((const)) -float __ocml_round_f32(float); -__attribute__((pure)) -float __ocml_rsqrt_f32(float); -__attribute__((const)) -float __ocml_scalb_f32(float, float); -__attribute__((const)) -float __ocml_scalbn_f32(float, int); -__attribute__((const)) -int __ocml_signbit_f32(float); -float __ocml_sincos_f32(float, __attribute__((address_space(5))) float*); -float __ocml_sincospi_f32(float, __attribute__((address_space(5))) float*); -float __ocml_sin_f32(float); -__attribute__((pure)) -float __ocml_sinh_f32(float); -float __ocml_sinpi_f32(float); -__attribute__((const)) -float __ocml_sqrt_f32(float); -float __ocml_tan_f32(float); -__attribute__((pure)) -float __ocml_tanh_f32(float); -float __ocml_tgamma_f32(float); -__attribute__((const)) -float __ocml_trunc_f32(float); -float __ocml_y0_f32(float); -float __ocml_y1_f32(float); - -// BEGIN INTRINSICS -__attribute__((const)) -float __ocml_add_rte_f32(float, float); -__attribute__((const)) -float __ocml_add_rtn_f32(float, float); -__attribute__((const)) -float __ocml_add_rtp_f32(float, float); -__attribute__((const)) -float __ocml_add_rtz_f32(float, float); -__attribute__((const)) -float __ocml_sub_rte_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtn_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtp_f32(float, float); -__attribute__((const)) -float __ocml_sub_rtz_f32(float, float); -__attribute__((const)) -float __ocml_mul_rte_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtn_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtp_f32(float, float); -__attribute__((const)) -float __ocml_mul_rtz_f32(float, float); -__attribute__((const)) -float __ocml_sqrt_rte_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtn_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtp_f32(float); -__attribute__((const)) -float __ocml_sqrt_rtz_f32(float); -__attribute__((const)) -float __ocml_fma_rte_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtn_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtp_f32(float, float, float); -__attribute__((const)) -float __ocml_fma_rtz_f32(float, float, float); - -__attribute__((const)) -float __llvm_amdgcn_cos_f32(float) __asm("llvm.amdgcn.cos.f32"); -__attribute__((const)) -float __llvm_amdgcn_rcp_f32(float) __asm("llvm.amdgcn.rcp.f32"); -__attribute__((const)) -float __llvm_amdgcn_rsq_f32(float) __asm("llvm.amdgcn.rsq.f32"); -__attribute__((const)) -float __llvm_amdgcn_sin_f32(float) __asm("llvm.amdgcn.sin.f32"); -// END INTRINSICS -// END FLOAT - -// BEGIN DOUBLE -__attribute__((const)) -double __ocml_acos_f64(double); -__attribute__((pure)) -double __ocml_acosh_f64(double); -__attribute__((const)) -double __ocml_asin_f64(double); -__attribute__((pure)) -double __ocml_asinh_f64(double); -__attribute__((const)) -double __ocml_atan2_f64(double, double); -__attribute__((const)) -double __ocml_atan_f64(double); -__attribute__((pure)) -double __ocml_atanh_f64(double); -__attribute__((pure)) -double __ocml_cbrt_f64(double); -__attribute__((const)) -double __ocml_ceil_f64(double); -__attribute__((const)) -double __ocml_copysign_f64(double, double); -double __ocml_cos_f64(double); -__attribute__((pure)) -double __ocml_cosh_f64(double); -double __ocml_cospi_f64(double); -double __ocml_i0_f64(double); -double __ocml_i1_f64(double); -__attribute__((pure)) -double __ocml_erfc_f64(double); -__attribute__((pure)) -double __ocml_erfcinv_f64(double); -__attribute__((pure)) -double __ocml_erfcx_f64(double); -__attribute__((pure)) -double __ocml_erf_f64(double); -__attribute__((pure)) -double __ocml_erfinv_f64(double); -__attribute__((pure)) -double __ocml_exp10_f64(double); -__attribute__((pure)) -double __ocml_exp2_f64(double); -__attribute__((pure)) -double __ocml_exp_f64(double); -__attribute__((pure)) -double __ocml_expm1_f64(double); -__attribute__((const)) -double __ocml_fabs_f64(double); -__attribute__((const)) -double __ocml_fdim_f64(double, double); -__attribute__((const)) -double __ocml_floor_f64(double); -__attribute__((const)) -double __ocml_fma_f64(double, double, double); -__attribute__((const)) -double __ocml_fmax_f64(double, double); -__attribute__((const)) -double __ocml_fmin_f64(double, double); -__attribute__((const)) -double __ocml_fmod_f64(double, double); -double __ocml_frexp_f64(double, __attribute__((address_space(5))) int*); -__attribute__((const)) -double __ocml_hypot_f64(double, double); -__attribute__((const)) -int __ocml_ilogb_f64(double); -__attribute__((const)) -int __ocml_isfinite_f64(double); -__attribute__((const)) -int __ocml_isinf_f64(double); -__attribute__((const)) -int __ocml_isnan_f64(double); -double __ocml_j0_f64(double); -double __ocml_j1_f64(double); -__attribute__((const)) -double __ocml_ldexp_f64(double, int); -double __ocml_lgamma_f64(double); -__attribute__((pure)) -double __ocml_log10_f64(double); -__attribute__((pure)) -double __ocml_log1p_f64(double); -__attribute__((pure)) -double __ocml_log2_f64(double); -__attribute__((const)) -double __ocml_logb_f64(double); -__attribute__((pure)) -double __ocml_log_f64(double); -double __ocml_modf_f64(double, __attribute__((address_space(5))) double*); -__attribute__((const)) -double __ocml_nearbyint_f64(double); -__attribute__((const)) -double __ocml_nextafter_f64(double, double); -__attribute__((const)) -double __ocml_len3_f64(double, double, double); -__attribute__((const)) -double __ocml_len4_f64(double, double, double, double); -__attribute__((pure)) -double __ocml_ncdf_f64(double); -__attribute__((pure)) -double __ocml_ncdfinv_f64(double); -__attribute__((pure)) -double __ocml_pow_f64(double, double); -__attribute__((pure)) -double __ocml_rcbrt_f64(double); -__attribute__((const)) -double __ocml_remainder_f64(double, double); -double __ocml_remquo_f64( - double, double, __attribute__((address_space(5))) int*); -__attribute__((const)) -double __ocml_rhypot_f64(double, double); -__attribute__((const)) -double __ocml_rint_f64(double); -__attribute__((const)) -double __ocml_rlen3_f64(double, double, double); -__attribute__((const)) -double __ocml_rlen4_f64(double, double, double, double); -__attribute__((const)) -double __ocml_round_f64(double); -__attribute__((pure)) -double __ocml_rsqrt_f64(double); -__attribute__((const)) -double __ocml_scalb_f64(double, double); -__attribute__((const)) -double __ocml_scalbn_f64(double, int); -__attribute__((const)) -int __ocml_signbit_f64(double); -double __ocml_sincos_f64(double, __attribute__((address_space(5))) double*); -double __ocml_sincospi_f64(double, __attribute__((address_space(5))) double*); -double __ocml_sin_f64(double); -__attribute__((pure)) -double __ocml_sinh_f64(double); -double __ocml_sinpi_f64(double); -__attribute__((const)) -double __ocml_sqrt_f64(double); -double __ocml_tan_f64(double); -__attribute__((pure)) -double __ocml_tanh_f64(double); -double __ocml_tgamma_f64(double); -__attribute__((const)) -double __ocml_trunc_f64(double); -double __ocml_y0_f64(double); -double __ocml_y1_f64(double); - -// BEGIN INTRINSICS -__attribute__((const)) -double __ocml_add_rte_f64(double, double); -__attribute__((const)) -double __ocml_add_rtn_f64(double, double); -__attribute__((const)) -double __ocml_add_rtp_f64(double, double); -__attribute__((const)) -double __ocml_add_rtz_f64(double, double); -__attribute__((const)) -double __ocml_sub_rte_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtn_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtp_f64(double, double); -__attribute__((const)) -double __ocml_sub_rtz_f64(double, double); -__attribute__((const)) -double __ocml_mul_rte_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtn_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtp_f64(double, double); -__attribute__((const)) -double __ocml_mul_rtz_f64(double, double); -__attribute__((const)) -double __ocml_sqrt_rte_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtn_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtp_f64(double); -__attribute__((const)) -double __ocml_sqrt_rtz_f64(double); -__attribute__((const)) -double __ocml_fma_rte_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtn_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtp_f64(double, double, double); -__attribute__((const)) -double __ocml_fma_rtz_f64(double, double, double); - -__attribute__((const)) -double __llvm_amdgcn_rcp_f64(double) __asm("llvm.amdgcn.rcp.f64"); -__attribute__((const)) -double __llvm_amdgcn_rsq_f64(double) __asm("llvm.amdgcn.rsq.f64"); -// END INTRINSICS -// END DOUBLE - -#if defined(__cplusplus) - } // extern "C" -#endif - -#endif // __LIBM_AMDGCN_H__ diff --git a/aomp-device-libs/libm/src/libm-nvptx.c b/aomp-device-libs/libm/src/libm-nvptx.c deleted file mode 100644 index cb08595..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.c +++ /dev/null @@ -1,724 +0,0 @@ -//===--------- libm/libm-nvptx.c ------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// Ignore all these definitions if clang compiler already defined them -#ifndef __CLANG_CUDA_DEVICE_FUNCTIONS_H__ -#include -#include -#include -#include "libm-nvptx.h" -#pragma omp declare target - -#if 0 -#define __FAST_OR_SLOW(fast, slow) fast -#else -#define __FAST_OR_SLOW(fast, slow) slow -#endif - -// BEGIN FLOAT -float acosf(float __a) { return __nv_acosf(__a); } - -float acoshf(float __a) { return __nv_acoshf(__a); } - -float asinf(float __a) { return __nv_asinf(__a); } - -float asinhf(float __a) { return __nv_asinhf(__a); } - -float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); } - -float atanf(float __a) { return __nv_atanf(__a); } - -float atanhf(float __a) { return __nv_atanhf(__a); } - -float cbrtf(float __a) { return __nv_cbrtf(__a); } - -float ceilf(float __a) { return __nv_ceilf(__a); } - -float copysignf(float __a, float __b) { - return __nv_copysignf(__a, __b); -} - -float cosf(float __a) { - return __FAST_OR_SLOW(__nv_fast_cosf, __nv_cosf)(__a); -} - -float coshf(float __a) { return __nv_coshf(__a); } - -float cospif(float __a) { return __nv_cospif(__a); } - -float cyl_bessel_i0f(float __a) { return __nv_cyl_bessel_i0f(__a); } - -float cyl_bessel_i1f(float __a) { return __nv_cyl_bessel_i1f(__a); } - -float erfcf(float __a) { return __nv_erfcf(__a); } - -float erfcinvf(float __a) { return __nv_erfcinvf(__a); } - -float erfcxf(float __a) { return __nv_erfcxf(__a); } - -float erff(float __a) { return __nv_erff(__a); } - -float erfinvf(float __a) { return __nv_erfinvf(__a); } - -float exp10f(float __a) { return __nv_exp10f(__a); } - -float exp2f(float __a) { return __nv_exp2f(__a); } - -float expf(float __a) { return __nv_expf(__a); } - -float expm1f(float __a) { return __nv_expm1f(__a); } - -float fabsf(float __a) { return __nv_fabsf(__a); } - -float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); } - -float fdividef(float __a, float __b) { -#if __FAST_MATH__ && !__CUDA_PREC_DIV - return __nv_fast_fdividef(__a, __b); -#else - return __a / __b; -#endif -} - -float floorf(float __f) { return __nv_floorf(__f); } - -float fmaf(float __a, float __b, float __c) { - return __nv_fmaf(__a, __b, __c); -} - -float fmaxf(float __a, float __b) { return __nv_fmaxf(__a, __b); } - -float fminf(float __a, float __b) { return __nv_fminf(__a, __b); } - -float fmodf(float __a, float __b) { return __nv_fmodf(__a, __b); } - -float frexpf(float __a, int *__b) { return __nv_frexpf(__a, __b); } - -float hypotf(float __a, float __b) { return __nv_hypotf(__a, __b); } - -int ilogbf(float __a) { return __nv_ilogbf(__a); } - -int __finitef(float __a) { return __nv_finitef(__a); } - -int __isinff(float __a) { return __nv_isinff(__a); } - -int __isnanf(float __a) { return __nv_isnanf(__a); } - -float j0f(float __a) { return __nv_j0f(__a); } - -float j1f(float __a) { return __nv_j1f(__a); } - -float jnf(int __n, float __a) { return __nv_jnf(__n, __a); } - -float ldexpf(float __a, int __b) { return __nv_ldexpf(__a, __b); } - -float lgammaf(float __a) { return __nv_lgammaf(__a); } - -long long llrintf(float __a) { return __nv_llrintf(__a); } - -long long llroundf(float __a) { return __nv_llroundf(__a); } - -float log10f(float __a) { return __nv_log10f(__a); } - -float log1pf(float __a) { return __nv_log1pf(__a); } - -float log2f(float __a) { - return __FAST_OR_SLOW(__nv_fast_log2f, __nv_log2f)(__a); -} - -float logbf(float __a) { return __nv_logbf(__a); } - -float logf(float __a) { - return __FAST_OR_SLOW(__nv_fast_logf, __nv_logf)(__a); -} - -long long __float2ll_rn(float __a) { return __nv_float2ll_rn(__a); } - -#if defined(__LP64__) -long lrintf(float __a) { return __float2ll_rn(__a); } -long lroundf(float __a) { return llroundf(__a); } -#else -long lrintf(float __a) { return __float2int_rn(__a); } -long lroundf(float __a) { return roundf(__a); } -#endif - -float modff(float __a, float *__b) { return __nv_modff(__a, __b); } - -// nanf - missing - -float nearbyintf(float __a) { return __nv_nearbyintf(__a); } - -float nextafterf(float __a, float __b) { - return __nv_nextafterf(__a, __b); -} - -float norm3df(float __a, float __b, float __c) { - return __nv_norm3df(__a, __b, __c); -} - -float norm4df(float __a, float __b, float __c, float __d) { - return __nv_norm4df(__a, __b, __c, __d); -} - -float normcdff(float __a) { return __nv_normcdff(__a); } - -float normf(int __dim, const float *__t) { - return __nv_normf(__dim, __t); -} - -float powf(float __a, float __b) { return __nv_powf(__a, __b); } - -float rcbrtf(float __a) { return __nv_rcbrtf(__a); } - -float remainderf(float __a, float __b) { - return __nv_remainderf(__a, __b); -} - -float remquof(float __a, float __b, int *__c) { - return __nv_remquof(__a, __b, __c); -} - -float rhypotf(float __a, float __b) { - return __nv_rhypotf(__a, __b); -} - -float rintf(float __a) { return __nv_rintf(__a); } - -float rnorm3df(float __a, float __b, float __c) { - return __nv_rnorm3df(__a, __b, __c); -} - -float rnorm4df(float __a, float __b, float __c, float __d) { - return __nv_rnorm4df(__a, __b, __c, __d); -} - -float normcdfinvf(float __a) { return __nv_normcdfinvf(__a); } - -float rnormf(int __dim, const float *__t) { - return __nv_rnormf(__dim, __t); -} - -float roundf(float __a) { return __nv_roundf(__a); } - -float rsqrtf(float __a) { return __nv_rsqrtf(__a); } - -float scalblnf(float __a, long __b) { - if (__b > INT_MAX) - return __a > 0 ? HUGE_VALF : -HUGE_VALF; - if (__b < INT_MIN) - return __a > 0 ? 0.f : -0.f; - return scalbnf(__a, (int)__b); -} - -float scalbnf(float __a, int __b) { return __nv_scalbnf(__a, __b); } - -int __signbitf(float __a) { return __nv_signbitf(__a); } - -void sincosf(float __a, float *__sptr, float *__cptr) { - return __FAST_OR_SLOW(__nv_fast_sincosf, __nv_sincosf)(__a, __sptr, __cptr); -} - -void sincospif(float __a, float *__sptr, float *__cptr) { - return __nv_sincospif(__a, __sptr, __cptr); -} - -float sinf(float __a) { - return __FAST_OR_SLOW(__nv_fast_sinf, __nv_sinf)(__a); -} - -float sinhf(float __a) { return __nv_sinhf(__a); } - -float sinpif(float __a) { return __nv_sinpif(__a); } - -float sqrtf(float __a) { return __nv_sqrtf(__a); } - -float tanf(float __a) { return __nv_tanf(__a); } - -float tanhf(float __a) { return __nv_tanhf(__a); } - -float tgammaf(float __a) { return __nv_tgammaf(__a); } - -float truncf(float __a) { return __nv_truncf(__a); } - -float y0f(float __a) { return __nv_y0f(__a); } - -float y1f(float __a) { return __nv_y1f(__a); } - -float ynf(int __a, float __b) { return __nv_ynf(__a, __b); } - -// BEGIN INTRINSICS - -float __cosf(float __a) { return __nv_fast_cosf(__a); } - -float __exp10f(float __a) { return __nv_fast_exp10f(__a); } - -float __expf(float __a) { return __nv_fast_expf(__a); } - -float __fadd_rd(float __a, float __b) { - return __nv_fadd_rd(__a, __b); -} -float __fadd_rn(float __a, float __b) { - return __nv_fadd_rn(__a, __b); -} -float __fadd_ru(float __a, float __b) { - return __nv_fadd_ru(__a, __b); -} -float __fadd_rz(float __a, float __b) { - return __nv_fadd_rz(__a, __b); -} -float __fdiv_rd(float __a, float __b) { - return __nv_fdiv_rd(__a, __b); -} -float __fdiv_rn(float __a, float __b) { - return __nv_fdiv_rn(__a, __b); -} -float __fdiv_ru(float __a, float __b) { - return __nv_fdiv_ru(__a, __b); -} -float __fdiv_rz(float __a, float __b) { - return __nv_fdiv_rz(__a, __b); -} - -float __fdividef(float __a, float __b) { - return __nv_fast_fdividef(__a, __b); -} - -float __fmaf_rd(float __a, float __b, float __c) { - return __nv_fmaf_rd(__a, __b, __c); -} - -float __fmaf_rn(float __a, float __b, float __c) { - return __nv_fmaf_rn(__a, __b, __c); -} - -float __fmaf_ru(float __a, float __b, float __c) { - return __nv_fmaf_ru(__a, __b, __c); -} - -float __fmaf_rz(float __a, float __b, float __c) { - return __nv_fmaf_rz(__a, __b, __c); -} - -float __fmul_rd(float __a, float __b) { - return __nv_fmul_rd(__a, __b); -} -float __fmul_rn(float __a, float __b) { - return __nv_fmul_rn(__a, __b); -} -float __fmul_ru(float __a, float __b) { - return __nv_fmul_ru(__a, __b); -} -float __fmul_rz(float __a, float __b) { - return __nv_fmul_rz(__a, __b); -} - -float __frcp_rd(float __a) { return __nv_frcp_rd(__a); } - -float __frcp_rn(float __a) { return __nv_frcp_rn(__a); } - -float __frcp_ru(float __a) { return __nv_frcp_ru(__a); } - -float __frcp_rz(float __a) { return __nv_frcp_rz(__a); } - -float __fsqrt_rd(float __a) { return __nv_fsqrt_rd(__a); } - -float __fsqrt_rn(float __a) { return __nv_fsqrt_rn(__a); } - -float __fsqrt_ru(float __a) { return __nv_fsqrt_ru(__a); } - -float __fsqrt_rz(float __a) { return __nv_fsqrt_rz(__a); } - -float __fsub_rd(float __a, float __b) { - return __nv_fsub_rd(__a, __b); -} - -float __fsub_rn(float __a, float __b) { - return __nv_fsub_rn(__a, __b); -} - -float __fsub_ru(float __a, float __b) { - return __nv_fsub_ru(__a, __b); -} - -float __fsub_rz(float __a, float __b) { - return __nv_fsub_rz(__a, __b); -} - -float __log10f(float __a) { return __nv_fast_log10f(__a); } - -float __log2f(float __a) { return __nv_fast_log2f(__a); } - -float __logf(float __a) { return __nv_fast_logf(__a); } - -float __powf(float __a, float __b) { - return __nv_fast_powf(__a, __b); -} - -float __saturatef(float __a) { return __nv_saturatef(__a); } - -void __sincosf(float __a, float *__sptr, float *__cptr) { - return __nv_fast_sincosf(__a, __sptr, __cptr); -} -float __sinf(float __a) { return __nv_fast_sinf(__a); } - -float __tanf(float __a) { return __nv_fast_tanf(__a); } - -// BEGIN DOUBLE - - -double acos(double __a) { return __nv_acos(__a); } - -double acosh(double __a) { return __nv_acosh(__a); } - -double asin(double __a) { return __nv_asin(__a); } - -double asinh(double __a) { return __nv_asinh(__a); } - -double atan(double __a) { return __nv_atan(__a); } - -double atan2(double __a, double __b) { return __nv_atan2(__a, __b); } - -double atanh(double __a) { return __nv_atanh(__a); } - -double cbrt(double __a) { return __nv_cbrt(__a); } - -double ceil(double __a) { return __nv_ceil(__a); } - -double copysign(double __a, double __b) { - return __nv_copysign(__a, __b); -} - -double cos(double __a) { return __nv_cos(__a); } - -double cosh(double __a) { return __nv_cosh(__a); } - -double cospi(double __a) { return __nv_cospi(__a); } - -double cyl_bessel_i0(double __a) { return __nv_cyl_bessel_i0(__a); } - -double cyl_bessel_i1(double __a) { return __nv_cyl_bessel_i1(__a); } - -double erf(double __a) { return __nv_erf(__a); } - -double erfc(double __a) { return __nv_erfc(__a); } - -double erfcinv(double __a) { return __nv_erfcinv(__a); } - -double erfcx(double __a) { return __nv_erfcx(__a); } - -double erfinv(double __a) { return __nv_erfinv(__a); } - -double exp(double __a) { return __nv_exp(__a); } - -double exp10(double __a) { return __nv_exp10(__a); } - -double exp2(double __a) { return __nv_exp2(__a); } - -double expm1(double __a) { return __nv_expm1(__a); } - -double fabs(double __a) { return __nv_fabs(__a); } - -double fdim(double __a, double __b) { return __nv_fdim(__a, __b); } - -double floor(double __f) { return __nv_floor(__f); } - -double fma(double __a, double __b, double __c) { - return __nv_fma(__a, __b, __c); -} - -double fmax(double __a, double __b) { return __nv_fmax(__a, __b); } - -double fmin(double __a, double __b) { return __nv_fmin(__a, __b); } - -double fmod(double __a, double __b) { return __nv_fmod(__a, __b); } - -double frexp(double __a, int *__b) { return __nv_frexp(__a, __b); } - -double hypot(double __a, double __b) { return __nv_hypot(__a, __b); } - -int ilogb(double __a) { return __nv_ilogb(__a); } - -int __finite(double __a) { return __nv_isfinited(__a); } - -// These symbols, isnan and isinf, cause issues on some RHEL systems. -//int __isinf(double __a) { return __nv_isinfd(__a); } - -//int __isnan(double __a) { return __nv_isnand(__a); } - -double j0(double __a) { return __nv_j0(__a); } - -double j1(double __a) { return __nv_j1(__a); } - -double jn(int __n, double __a) { return __nv_jn(__n, __a); } - -double ldexp(double __a, int __b) { return __nv_ldexp(__a, __b); } - -double lgamma(double __a) { return __nv_lgamma(__a); } - -long long llrint(double __a) { return __nv_llrint(__a); } - -long long llround(double __a) { return __nv_llround(__a); } - -double log(double __a) { return __nv_log(__a); } - -double log10(double __a) { return __nv_log10(__a); } - -double log1p(double __a) { return __nv_log1p(__a); } - -double log2(double __a) { return __nv_log2(__a); } - -double logb(double __a) { return __nv_logb(__a); } - -#if defined(__LP64__) -long lrint(double __a) { return llrint(__a); } - -long lround(double __a) { return llround(__a); } -#else -long lrint(double __a) { return (long)rint(__a); } - -long lround(double __a) { return round(__a); } -#endif - -double modf(double __a, double *__b) { return __nv_modf(__a, __b); } - -// nan - missing - -double nearbyint(double __a) { return __nv_nearbyint(__a); } - -double nextafter(double __a, double __b) { - return __nv_nextafter(__a, __b); -} - -double norm(int __dim, const double *__t) { - return __nv_norm(__dim, __t); -} - -double norm3d(double __a, double __b, double __c) { - return __nv_norm3d(__a, __b, __c); -} - -double norm4d(double __a, double __b, double __c, double __d) { - return __nv_norm4d(__a, __b, __c, __d); -} - -double normcdf(double __a) { return __nv_normcdf(__a); } - -double normcdfinv(double __a) { return __nv_normcdfinv(__a); } - -double pow(double __a, double __b) { return __nv_pow(__a, __b); } - -double rcbrt(double __a) { return __nv_rcbrt(__a); } - -double remainder(double __a, double __b) { - return __nv_remainder(__a, __b); -} - -double remquo(double __a, double __b, int *__c) { - return __nv_remquo(__a, __b, __c); -} - -double rhypot(double __a, double __b) { - return __nv_rhypot(__a, __b); -} - -double rint(double __a) { return __nv_rint(__a); } - -double rnorm(int __a, const double *__b) { - return __nv_rnorm(__a, __b); -} - -double rnorm3d(double __a, double __b, double __c) { - return __nv_rnorm3d(__a, __b, __c); -} - -double rnorm4d(double __a, double __b, double __c, double __d) { - return __nv_rnorm4d(__a, __b, __c, __d); -} - -double round(double __a) { return __nv_round(__a); } - -double rsqrt(double __a) { return __nv_rsqrt(__a); } - -double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); } - -double scalbln(double __a, long __b) { - if (__b > INT_MAX) - return __a > 0 ? HUGE_VAL : -HUGE_VAL; - if (__b < INT_MIN) - return __a > 0 ? 0.0 : -0.0; - return scalbn(__a, (int)__b); -} - -int __signbit(double __a) { return __nv_signbitd(__a); } - -double sin(double __a) { return __nv_sin(__a); } - -void sincos(double __a, double *__sptr, double *__cptr) { - return __nv_sincos(__a, __sptr, __cptr); -} - -void sincospi(double __a, double *__sptr, double *__cptr) { - return __nv_sincospi(__a, __sptr, __cptr); -} - -double sinh(double __a) { return __nv_sinh(__a); } - -double sinpi(double __a) { return __nv_sinpi(__a); } - -double sqrt(double __a) { return __nv_sqrt(__a); } - -double tan(double __a) { return __nv_tan(__a); } - -double tanh(double __a) { return __nv_tanh(__a); } - -double tgamma(double __a) { return __nv_tgamma(__a); } - -double trunc(double __a) { return __nv_trunc(__a); } - -double y0(double __a) { return __nv_y0(__a); } - -double y1(double __a) { return __nv_y1(__a); } - -double yn(int __a, double __b) { return __nv_yn(__a, __b); } - -// BEGIN INTRINSICS - -double __dadd_rd(double __a, double __b) { - return __nv_dadd_rd(__a, __b); -} - -double __dadd_rn(double __a, double __b) { - return __nv_dadd_rn(__a, __b); -} - -double __dadd_ru(double __a, double __b) { - return __nv_dadd_ru(__a, __b); -} - -double __dadd_rz(double __a, double __b) { - return __nv_dadd_rz(__a, __b); -} - -double __ddiv_rd(double __a, double __b) { - return __nv_ddiv_rd(__a, __b); -} - -double __ddiv_rn(double __a, double __b) { - return __nv_ddiv_rn(__a, __b); -} - -double __ddiv_ru(double __a, double __b) { - return __nv_ddiv_ru(__a, __b); -} - -double __ddiv_rz(double __a, double __b) { - return __nv_ddiv_rz(__a, __b); -} - -double __dmul_rd(double __a, double __b) { - return __nv_dmul_rd(__a, __b); -} - -double __dmul_rn(double __a, double __b) { - return __nv_dmul_rn(__a, __b); -} - -double __dmul_ru(double __a, double __b) { - return __nv_dmul_ru(__a, __b); -} - -double __dmul_rz(double __a, double __b) { - return __nv_dmul_rz(__a, __b); -} - -double __drcp_rd(double __a) { return __nv_drcp_rd(__a); } - -double __drcp_rn(double __a) { return __nv_drcp_rn(__a); } - -double __drcp_ru(double __a) { return __nv_drcp_ru(__a); } - -double __drcp_rz(double __a) { return __nv_drcp_rz(__a); } - -double __dsqrt_rd(double __a) { return __nv_dsqrt_rd(__a); } - -double __dsqrt_rn(double __a) { return __nv_dsqrt_rn(__a); } - -double __dsqrt_ru(double __a) { return __nv_dsqrt_ru(__a); } - -double __dsqrt_rz(double __a) { return __nv_dsqrt_rz(__a); } - -double __dsub_rd(double __a, double __b) { - return __nv_dsub_rd(__a, __b); -} - -double __dsub_rn(double __a, double __b) { - return __nv_dsub_rn(__a, __b); -} - -double __dsub_ru(double __a, double __b) { - return __nv_dsub_ru(__a, __b); -} - -double __dsub_rz(double __a, double __b) { - return __nv_dsub_rz(__a, __b); -} - -double __fma_rd(double __a, double __b, double __c) { - return __nv_fma_rd(__a, __b, __c); -} - -double __fma_rn(double __a, double __b, double __c) { - return __nv_fma_rn(__a, __b, __c); -} - -double __fma_ru(double __a, double __b, double __c) { - return __nv_fma_ru(__a, __b, __c); -} - -double __fma_rz(double __a, double __b, double __c) { - return __nv_fma_rz(__a, __b, __c); -} - -// END DOUBLE - -// Complex functions -#define _ISNANd __nv_isnand -#define _ISNANf __isnanf -#define _ISINFd __nv_isinfd -#define _ISINFf __isinff -#define _ISFINITEd __finite -#define _ISFINITEf __finitef -#define _COPYSIGNd copysign -#define _COPYSIGNf copysignf -#define _SCALBNd scalbn -#define _SCALBNf scalbnf -#define _ABSd fabs -#define _ABSf fabsf -#define _LOGBd logb -#define _LOGBf logbf - -#include "complex.def" - -#undef _ISNANd -#undef _ISNANf -#undef _ISINFd -#undef _ISINFf -#undef _COPYSIGNd -#undef _COPYSIGNf -#undef _ISFINITEd -#undef _ISFINITEf -#undef _SCALBNd -#undef _SCALBNf -#undef _ABSd -#undef _ABSf -#undef _LOGBd -#undef _LOGBf - -#pragma omp end declare target -#endif - diff --git a/aomp-device-libs/libm/src/libm-nvptx.cpp b/aomp-device-libs/libm/src/libm-nvptx.cpp deleted file mode 100644 index fc7ae83..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.cpp +++ /dev/null @@ -1,273 +0,0 @@ -//===--------- libm/libm-nvptx.cpp ----------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include -#include -#include -#include "libm-nvptx.h" -#ifdef __cplusplus -#pragma omp declare target - -// Extern declarations -extern long long llabs(long long __a); -extern long labs(long __a); -extern float powif(float __a, int __b); -extern double powi(double __a, int __b); -extern float powif(float __a, int __b); -extern int __isfinited(double __a); - -/// Do not provide the double overload because the base functions -/// are defined in libm-amdgcn.c. Only provide non base variants. - -long long abs(long long __n) { return llabs(__n); } -long abs(long __n) { return labs(__n); } -float abs(float __x) { return fabsf(__x); } -double abs(double __x) { return fabs(__x); } -float acos(float __x) { return acosf(__x); } -float asin(float __x) { return asinf(__x); } -float atan(float __x) { return atanf(__x); } -float atan2(float __x, float __y) { return atan2f(__x, __y); } -float ceil(float __x) { return ceilf(__x); } -float cos(float __x) { return cosf(__x); } -float cosh(float __x) { return coshf(__x); } -float exp(float __x) { return expf(__x); } -float fabs(float __x) { return fabsf(__x); } -float floor(float __x) { return floorf(__x); } -float fmod(float __x, float __y) { return fmodf(__x, __y); } -int fpclassify(float __x) { - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, - FP_ZERO, __x); -} -int fpclassify(double __x) { - return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, - FP_ZERO, __x); -} -float frexp(float __arg, int *__exp) { - return frexpf(__arg, __exp); -} - -bool isinf(float __x) { return __isinff(__x); } -//bool isinf(double __x) { return __isinf(__x); } -bool isfinite(float __x) { return __finitef(__x); } -bool isfinite(double __x) { return __isfinited(__x); } -bool isnan(float __x) { return __isnanf(__x); } -//bool isnan(double __x) { return __isnan(__x); } - -bool isgreater(float __x, float __y) { - return __builtin_isgreater(__x, __y); -} -bool isgreater(double __x, double __y) { - return __builtin_isgreater(__x, __y); -} -bool isgreaterequal(float __x, float __y) { - return __builtin_isgreaterequal(__x, __y); -} -bool isgreaterequal(double __x, double __y) { - return __builtin_isgreaterequal(__x, __y); -} -bool isless(float __x, float __y) { - return __builtin_isless(__x, __y); -} -bool isless(double __x, double __y) { - return __builtin_isless(__x, __y); -} -bool islessequal(float __x, float __y) { - return __builtin_islessequal(__x, __y); -} -bool islessequal(double __x, double __y) { - return __builtin_islessequal(__x, __y); -} -bool islessgreater(float __x, float __y) { - return __builtin_islessgreater(__x, __y); -} -bool islessgreater(double __x, double __y) { - return __builtin_islessgreater(__x, __y); -} -bool isnormal(float __x) { return __builtin_isnormal(__x); } -bool isnormal(double __x) { return __builtin_isnormal(__x); } -bool isunordered(float __x, float __y) { - return __builtin_isunordered(__x, __y); -} -bool isunordered(double __x, double __y) { - return __builtin_isunordered(__x, __y); -} -float ldexp(float __arg, int __exp) { - return ldexpf(__arg, __exp); -} - -float log(float __x) { return logf(__x); } -float log10(float __x) { return log10f(__x); } -float modf(float __x, float *__iptr) { return modff(__x, __iptr); } -float pow(float __base, float __exp) { - return powf(__base, __exp); -} -float pow(float __base, int __iexp) { - return powif(__base, __iexp); -} -double pow(double __base, int __iexp) { - return powi(__base, __iexp); -} -/* -bool signbit(float __x) { return __signbitf(__x); } -bool signbit(double __x) { return __signbitd(__x); } -*/ -float sin(float __x) { return sinf(__x); } -float sinh(float __x) { return sinhf(__x); } -float sqrt(float __x) { return sqrtf(__x); } -float tan(float __x) { return tanf(__x); } -float tanh(float __x) { return tanhf(__x); } - - -template struct __clang_cuda_enable_if {}; - -template struct __clang_cuda_enable_if { - typedef __T type; -}; - -// Defines an overload of __fn that accepts one integral argument, calls -// __fn((double)x), and returns __retty. -#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_1(__retty, __fn) \ - template \ - \ - typename __clang_cuda_enable_if::is_integer, \ - __retty>::type \ - __fn(__T __x) { \ - return ::__fn((double)__x); \ - } - -// Defines an overload of __fn that accepts one two arithmetic arguments, calls -// __fn((double)x, (double)y), and returns a double. -// -// Note this is different from OVERLOAD_1, which generates an overload that -// accepts only *integral* arguments. -#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_2(__retty, __fn) \ - template \ - typename __clang_cuda_enable_if< \ - std::numeric_limits<__T1>::is_specialized && \ - std::numeric_limits<__T2>::is_specialized, \ - __retty>::type \ - __fn(__T1 __x, __T2 __y) { \ - return __fn((double)__x, (double)__y); \ - } - -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acos) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, acosh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asin) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, asinh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atan) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, atan2); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, atanh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cbrt) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, ceil) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, copysign); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cos) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, cosh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erf) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, erfc) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, exp2) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, expm1) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, fabs) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fdim); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, floor) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmax); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmin); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, fmod); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, fpclassify) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, hypot); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(int, ilogb) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isfinite) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreater); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isgreaterequal); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isinf); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isless); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessequal); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, islessgreater); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnan); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, isnormal) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(bool, isunordered); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, lgamma) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log10) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log1p) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, log2) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, logb) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llrint) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long long, llround) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lrint) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(long, lround) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, nearbyint); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, nextafter); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, pow); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_2(double, remainder); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, rint); -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, round); -//__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(bool, signbit) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sin) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sinh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, sqrt) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tan) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tanh) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, tgamma) -__CUDA_CLANG_FN_INTEGER_OVERLOAD_1(double, trunc); - -#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_1 -#undef __CUDA_CLANG_FN_INTEGER_OVERLOAD_2 - -// Overloads for functions that don't match the patterns expected by -// __CUDA_CLANG_FN_INTEGER_OVERLOAD_{1,2}. -template -typename __clang_cuda_enable_if< - std::numeric_limits<__T1>::is_specialized && - std::numeric_limits<__T2>::is_specialized && - std::numeric_limits<__T3>::is_specialized, - double>::type -fma(__T1 __x, __T2 __y, __T3 __z) { - return std::fma((double)__x, (double)__y, (double)__z); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -frexp(__T __x, int *__exp) { - return std::frexp((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -ldexp(__T __x, int __exp) { - return std::ldexp((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if< - std::numeric_limits<__T1>::is_specialized && - std::numeric_limits<__T2>::is_specialized, - double>::type -remquo(__T1 __x, __T2 __y, int *__quo) { - return std::remquo((double)__x, (double)__y, __quo); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -scalbln(__T __x, long __exp) { - return std::scalbln((double)__x, __exp); -} - -template -typename __clang_cuda_enable_if::is_integer, - double>::type -scalbn(__T __x, int __exp) { - return std::scalbn((double)__x, __exp); -} - -#pragma omp end declare target -#endif // if c++ - diff --git a/aomp-device-libs/libm/src/libm-nvptx.h b/aomp-device-libs/libm/src/libm-nvptx.h deleted file mode 100644 index 95e1aab..0000000 --- a/aomp-device-libs/libm/src/libm-nvptx.h +++ /dev/null @@ -1,583 +0,0 @@ -//===--------- libm/libm-nvptx.h ------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#ifndef __LIBM_NVTPX_H__ -#define __LIBM_NVTPX_H__ - -int __nv_brev(int x); -long long __nv_brevll(long long x); -int __nv_clz(int x); -int __nv_clzll(long long x); -float __nv_fast_cosf(float x); -double __nv_dadd_rd(double __a, double __b); -double __nv_dadd_rn(double __a, double __b); -double __nv_dadd_ru(double __a, double __b); -double __nv_dadd_rz(double __a, double __b); -int __nv_byte_perm(int __a, int __b, - int __c); -double __nv_ddiv_rd(double __a, double __b); -double __nv_ddiv_rn(double __a, double __b); -double __nv_ddiv_ru(double __a, double __b); -double __nv_ddiv_rz(double __a, double __b); -double __nv_dmul_rd(double __a, double __b); -double __nv_dmul_rn(double __a, double __b); -double __nv_dmul_ru(double __a, double __b); -double __nv_dmul_rz(double __a, double __b); -float __nv_double2float_rd(double __a); -float __nv_double2float_rn(double __a); -float __nv_double2float_ru(double __a); -float __nv_double2float_rz(double __a); -int __nv_double2hiint(double __a); -int __nv_double2int_rd(double __a); -int __nv_double2int_rn(double __a); -int __nv_double2int_ru(double __a); -int __nv_double2int_rz(double __a); -long long __nv_double2ll_rd(double __a); -long long __nv_double2ll_rn(double __a); -long long __nv_double2ll_ru(double __a); -long long __nv_double2ll_rz(double __a); -int __nv_double2loint(double __a); -unsigned int __nv_double2uint_rd(double __a); -unsigned int __nv_double2uint_rn(double __a); -unsigned int __nv_double2uint_ru(double __a); -unsigned int __nv_double2uint_rz(double __a); -unsigned long long __nv_double2ull_rd(double __a); -unsigned long long __nv_double2ull_rn(double __a); -unsigned long long __nv_double2ull_ru(double __a); -unsigned long long __nv_double2ull_rz(double __a); -unsigned long long __nv_double_as_longlong(double __a); -double __nv_drcp_rd(double __a); -double __nv_drcp_rn(double __a); -double __nv_drcp_ru(double __a); -double __nv_drcp_rz(double __a); -double __nv_dsqrt_rd(double __a); -double __nv_dsqrt_rn(double __a); -double __nv_dsqrt_ru(double __a); -double __nv_dsqrt_rz(double __a); -double __nv_dsub_rd(double __a, double __b); -double __nv_dsub_rn(double __a, double __b); -double __nv_dsub_ru(double __a, double __b); -double __nv_dsub_rz(double __a, double __b); -float __nv_fast_exp10f(float __a); -float __nv_fast_expf(float __a); -float __nvvm_atom_add_gen_f(volatile float *__p, float __v); -float __nvvm_atom_cta_add_gen_f(volatile float *__p, float __v); -float __nv_fadd_rd(float __a, float __b); -float __nv_fadd_rn(float __a, float __b); -float __nv_fadd_ru(float __a, float __b); -float __nv_fadd_rz(float __a, float __b); -float __nv_fdiv_rd(float __a, float __b); -float __nv_fdiv_rn(float __a, float __b); -float __nv_fdiv_ru(float __a, float __b); -float __nv_fdiv_rz(float __a, float __b); -float __nv_fast_fdividef(float __a, float __b); -int __nv_ffs(int __a); -int __nv_ffsll(long long __a); -int __nv_isfinited(double __a); -int __nv_finitef(float __a); -int __nv_float2int_rd(float __a); -int __nv_float2int_rn(float __a); -int __nv_float2int_ru(float __a); -int __nv_float2int_rz(float __a); -long long __nv_float2ll_rd(float __a); -long long __nv_float2ll_rn(float __a); -long long __nv_float2ll_ru(float __a); -long long __nv_float2ll_rz(float __a); -unsigned int __nv_float2uint_rd(float __a); -unsigned int __nv_float2uint_rn(float __a); -unsigned int __nv_float2uint_ru(float __a); -unsigned int __nv_float2uint_rz(float __a); -unsigned long long __nv_float2ull_rd(float __a); -unsigned long long __nv_float2ull_rn(float __a); -unsigned long long __nv_float2ull_ru(float __a); -unsigned long long __nv_float2ull_rz(float __a); -int __nv_float_as_int(float __a); -unsigned int __nv_float_as_uint(float __a); -double __nv_fma_rd(double __a, double __b, double __c); -double __nv_fma_rn(double __a, double __b, double __c); -double __nv_fma_ru(double __a, double __b, double __c); -double __nv_fma_rz(double __a, double __b, double __c); -float __nv_fmaf_ieee_rd(float __a, float __b, float __c); -float __nv_fmaf_ieee_rn(float __a, float __b, float __c); -float __nv_fmaf_ieee_ru(float __a, float __b, float __c); -float __nv_fmaf_ieee_rz(float __a, float __b, float __c); -float __nv_fmaf_rd(float __a, float __b, float __c); -float __nv_fmaf_rn(float __a, float __b, float __c); -float __nv_fmaf_ru(float __a, float __b, float __c); -float __nv_fmaf_rz(float __a, float __b, float __c); -float __nv_fmul_rd(float __a, float __b); -float __nv_fmul_rn(float __a, float __b); -float __nv_fmul_ru(float __a, float __b); -float __nv_fmul_rz(float __a, float __b); -float __nv_frcp_rd(float __a); -float __nv_frcp_rn(float __a); -float __nv_frcp_ru(float __a); -float __nv_frcp_rz(float __a); -float __nv_frsqrt_rn(float __a); -float __nv_fsqrt_rd(float __a); -float __nv_fsqrt_rn(float __a); -float __nv_fsqrt_ru(float __a); -float __nv_fsqrt_rz(float __a); -float __nv_fsub_rd(float __a, float __b); -float __nv_fsub_rn(float __a, float __b); -float __nv_fsub_ru(float __a, float __b); -float __nv_fsub_rz(float __a, float __b); -int __nv_hadd(int __a, int __b); -double __nv_hiloint2double(int __a, int __b); -int __nvvm_atom_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_add_gen_i(volatile int *__p, int __v); -int __nvvm_atom_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_and_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_cta_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_sys_cas_gen_i(volatile int *__p, int __cmp, int __v); -int __nvvm_atom_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_xchg_gen_i(volatile int *__p, int __v); -int __nvvm_atom_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_max_gen_i(volatile int *__p, int __v); -int __nvvm_atom_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_min_gen_i(volatile int *__p, int __v); -int __nvvm_atom_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_or_gen_i(volatile int *__p, int __v); -int __nvvm_atom_xor_gen_i(volatile int *__p, int __v); -int __nvvm_atom_cta_xor_gen_i(volatile int *__p, int __v); -int __nvvm_atom_sys_xor_gen_i(volatile int *__p, int __v); -long long __nvvm_atom_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_max_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_min_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_min_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_min_gen_ll(volatile long long *__p, - long long __v); -double __nv_int2double_rn(int __a); -float __nv_int2float_rd(int __a); -float __nv_int2float_rn(int __a); -float __nv_int2float_ru(int __a); -float __nv_int2float_rz(int __a); -float __nv_int_as_float(int __a); -int __nv_isfinited(double __a); -int __nv_isinfd(double __a); -int __nv_isinff(float __a); -int __nv_isnand(double __a); -int __nv_isnanf(float __a); -double __nv_ll2double_rd(long long __a); -double __nv_ll2double_rn(long long __a); -double __nv_ll2double_ru(long long __a); -double __nv_ll2double_rz(long long __a); -float __nv_ll2float_rd(long long __a); -float __nv_ll2float_rn(long long __a); -float __nv_ll2float_ru(long long __a); -float __nv_ll2float_rz(long long __a); -long long __nvvm_atom_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_and_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_or_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_xor_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_cta_xor_gen_ll(volatile long long *__p, - long long __v); -long long __nvvm_atom_sys_xor_gen_ll(volatile long long *__p, - long long __v); -float __nv_fast_log10f(float __a); -float __nv_fast_log2f(float __a); -float __nv_fast_logf(float __a); -double __nv_longlong_as_double(long long __a); -int __nv_mul24(int __a, int __b); -long long __nv_mul64hi(long long __a, long long __b); -int __nv_mulhi(int __a, int __b); -//unsigned int __nvvm_read_ptx_sreg_pm0(void); -//unsigned int __nvvm_read_ptx_sreg_pm1(void); -//unsigned int __nvvm_read_ptx_sreg_pm2(void); -//unsigned int __nvvm_read_ptx_sreg_pm3(void); -int __nv_popc(int __a); -int __nv_popcll(long long __a); -float __nv_fast_powf(float __a, float __b); -int __nv_rhadd(int __a, int __b); -int __nv_sad(int __a, int __b, int __c); -float __nv_saturatef(float __a); -int __nv_signbitd(double __a); -int __nv_signbitf(float __a); -void __nv_fast_sincosf(float __a, float *__sptr, float *__cptr); -float __nv_fast_sinf(float __a); -//int __nvvm_bar0_and(int __a); -//int __nvvm_bar0_popc(int __a); -//int __nvvm_bar0_or(int __a); -float __nv_fast_tanf(float __a); -//void __nvvm_membar_gl(); -//void __nvvm_membar_cta(); -//void __nvvm_membar_sys(); -unsigned int __nvvm_atom_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_dec_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_inc_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_max_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_cta_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -unsigned int __nvvm_atom_sys_min_gen_ui(volatile unsigned int *__p, - unsigned int __v); -int __nv_uhadd(unsigned int __a, unsigned int __b); -double __nv_uint2double_rn(unsigned int __a); -float __nv_uint2float_rd(unsigned int __a); -float __nv_uint2float_rn(unsigned int __a); -float __nv_uint2float_ru(unsigned int __a); -float __nv_uint2float_rz(unsigned int __a); -float __nv_uint_as_float(unsigned int __a); -double __nv_ull2double_rd(unsigned long long __a); -double __nv_ull2double_rn(unsigned long long __a); -double __nv_ull2double_ru(unsigned long long __a); -double __nv_ull2double_rz(unsigned long long __a); -float __nv_ull2float_rd(unsigned long long __a); -float __nv_ull2float_rn(unsigned long long __a); -float __nv_ull2float_ru(unsigned long long __a); -float __nv_ull2float_rz(unsigned long long __a); -long long int __nvvm_atom_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_cta_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_sys_add_gen_ll(volatile long long int *__p, - long long int __v); -long long int __nvvm_atom_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_cta_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_sys_cas_gen_ll(volatile long long int *__p, - long long int __cmp, - long long int __v); -long long int __nvvm_atom_xchg_gen_ll(volatile long long int *__p, - long long int __v); -long long int -__nvvm_atom_cta_xchg_gen_ll(volatile long long int *__p, long long int __v); -long long int -__nvvm_atom_sys_xchg_gen_ll(volatile long long int *__p, long long int __v); -unsigned long long -__nvvm_atom_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_cta_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_sys_max_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_cta_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned long long -__nvvm_atom_sys_min_gen_ull(volatile unsigned long long *__p, - unsigned long long __v); -unsigned int __nv_umul24(unsigned int __a, unsigned int __b); -unsigned long long __nv_umul64hi(unsigned long long __a, - unsigned long long __b); -unsigned int __nv_umulhi(unsigned int __a, unsigned int __b); -unsigned int __nv_urhadd(unsigned int __a, unsigned int __b); -unsigned int __nv_usad(unsigned int __a, unsigned int __b, - unsigned int __c); -unsigned int __nv_vabs2(unsigned int __a); -unsigned int __nv_vabs4(unsigned int __a); -unsigned int __nv_vabsdiffs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsdiffu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vabsss2(unsigned int __a); -unsigned int __nv_vabsss4(unsigned int __a); -unsigned int __nv_vadd2(unsigned int __a, unsigned int __b); -unsigned int __nv_vadd4(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddss2(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddss4(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddus2(unsigned int __a, unsigned int __b); -unsigned int __nv_vaddus4(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vavgu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpeq2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpeq4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpges2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpges4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgeu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgeu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgtu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpgtu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmples2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmples4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpleu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpleu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmplts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmplts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpltu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpltu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpne2(unsigned int __a, unsigned int __b); -unsigned int __nv_vcmpne4(unsigned int __a, unsigned int __b); -unsigned int __nv_vhaddu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vhaddu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxs2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxs4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmaxu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vmins2(unsigned int __a, unsigned int __b); -unsigned int __nv_vmins4(unsigned int __a, unsigned int __b); -unsigned int __nv_vminu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vminu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vneg2(unsigned int __a); -unsigned int __nv_vneg4(unsigned int __a); -unsigned int __nv_vnegss2(unsigned int __a); -unsigned int __nv_vnegss4(unsigned int __a); -unsigned int __nv_vsads2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsads4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsadu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsadu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vseteq2(unsigned int __a, unsigned int __b); -unsigned int __nv_vseteq4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetges2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetges4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgeu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgeu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgtu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetgtu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetles2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetles4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetleu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetleu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetlts2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetlts4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetltu2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetltu4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetne2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsetne4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsub2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsub4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubss2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubss4(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubus2(unsigned int __a, unsigned int __b); -unsigned int __nv_vsubus4(unsigned int __a, unsigned int __b); -int __nv_abs(int __a); -double __nv_acos(double __a); -float __nv_acosf(float __a); -double __nv_acosh(double __a); -float __nv_acoshf(float __a); -double __nv_asin(double __a); -float __nv_asinf(float __a); -double __nv_asinh(double __a); -float __nv_asinhf(float __a); -double __nv_atan(double __a); -double __nv_atan2(double __a, double __b); -float __nv_atan2f(float __a, float __b); -float __nv_atanf(float __a); -double __nv_atanh(double __a); -float __nv_atanhf(float __a); -double __nv_cbrt(double __a); -float __nv_cbrtf(float __a); -double __nv_ceil(double __a); -float __nv_ceilf(float __a); -//int __nvvm_read_ptx_sreg_clock(); -//long long __nvvm_read_ptx_sreg_clock64(); -double __nv_copysign(double __a, double __b); -float __nv_copysignf(float __a, float __b); -double __nv_cos(double __); -float __nv_fast_cosf(float __a); -float __nv_cosf(float __a); -double __nv_cosh(double __a); -float __nv_coshf(float __a); -double __nv_cospi(double __a); -float __nv_cospif(float __a); -double __nv_cyl_bessel_i0(double __a); -float __nv_cyl_bessel_i0f(float __a); -double __nv_cyl_bessel_i1(double __a); -float __nv_cyl_bessel_i1f(float __a); -double __nv_erf(double __a); -double __nv_erfc(double __a); -float __nv_erfcf(float __a); -double __nv_erfcinv(double __a); -float __nv_erfcinvf(float __a); -double __nv_erfcx(double __a); -float __nv_erfcxf(float __a); -float __nv_erff(float __a); -double __nv_erfinv(double __a); -float __nv_erfinvf(float __a); -double __nv_exp(double __a); -double __nv_exp10(double __a); -float __nv_exp10f(float __a); -double __nv_exp2(double __a); -float __nv_exp2f(float __a); -float __nv_expf(float __a); -double __nv_expm1(double __a); -float __nv_expm1f(float __a); -double __nv_fabs(double __a); -float __nv_fabsf(float __a); -double __nv_fdim(double __a, double __b); -float __nv_fdimf(float __a, float __b); -float __nv_fast_fdividef(float __a, float __b); -double __nv_floor(double __f); -float __nv_floorf(float __f); -double __nv_fma(double __a, double __b, double __c); -float __nv_fmaf(float __a, float __b, float __c); -double __nv_fmax(double __a, double __b); -float __nv_fmaxf(float __a, float __b); -double __nv_fmin(double __a, double __b); -float __nv_fminf(float __a, float __b); -double __nv_fmod(double __a, double __b); -float __nv_fmodf(float __a, float __b); -double __nv_frexp(double __a, int *__b); -float __nv_frexpf(float __a, int *__b); -double __nv_hypot(double __a, double __b); -float __nv_hypotf(float __a, float __b); -int __nv_ilogb(double __a); -int __nv_ilogbf(float __a); -double __nv_j0(double __a); -float __nv_j0f(float __a); -double __nv_j1(double __a); -float __nv_j1f(float __a); -double __nv_jn(int __n, double __a); -float __nv_jnf(int __n, float __a); -// long __nv_abs(long __a); -double __nv_ldexp(double __a, int __b); -float __nv_ldexpf(float __a, int __b); -double __nv_lgamma(double __a); -float __nv_lgammaf(float __a); -long long __nv_llabs(long long __a); -long long __nv_llmax(long long __a, long long __b); -long long __nv_llmin(long long __a, long long __b); -long long __nv_llrint(double __a); -long long __nv_llrintf(float __a); -long long __nv_llround(double __a); -long long __nv_llroundf(float __a); -double __nv_log(double __a); -double __nv_log10(double __a); -float __nv_log10f(float __a); -double __nv_log1p(double __a); -float __nv_log1pf(float __a); -double __nv_log2(double __a); -float __nv_log2f(float __a); -float __nv_fast_log2f(float __a); -double __nv_logb(double __a); -float __nv_logbf(float __a); -float __nv_fast_logf(float __a); -float __nv_logf(float __a); -int __nv_max(int __a, int __b); -int __nv_min(int __a, int __b); -double __nv_modf(double __a, double *__b); -float __nv_modff(float __a, float *__b); -double __nv_nearbyint(double __a); -float __nv_nearbyintf(float __a); -double __nv_nextafter(double __a, double __b); -float __nv_nextafterf(float __a, float __b); -double __nv_norm(int __dim, const double *__t); -double __nv_norm3d(double __a, double __b, double __c); -float __nv_norm3df(float __a, float __b, float __c); -double __nv_norm4d(double __a, double __b, double __c, double __d); -float __nv_norm4df(float __a, float __b, float __c, float __d); -double __nv_normcdf(double __a); -float __nv_normcdff(float __a); -double __nv_normcdfinv(double __a); -float __nv_normcdfinvf(float __a); -float __nv_normf(int __dim, const float *__t); - -double __nv_pow(double __a, double __b); -float __nv_powf(float __a, float __b); -double __nv_powi(double __a, int __b); -float __nv_powif(float __a, int __b); -double __nv_rcbrt(double __a); -float __nv_rcbrtf(float __a); -double __nv_remainder(double __a, double __b); -float __nv_remainderf(float __a, float __b); -double __nv_remquo(double __a, double __b, int *__c); -float __nv_remquof(float __a, float __b, int *__c); -double __nv_rhypot(double __a, double __b); -float __nv_rhypotf(float __a, float __b); -double __nv_rint(double __a); -float __nv_rintf(float __a); -double __nv_rnorm(int __a, const double *__b); -double __nv_rnorm3d(double __a, double __b, double __c); -float __nv_rnorm3df(float __a, float __b, float __c); -double __nv_rnorm4d(double __a, double __b, double __c, double __d); -float __nv_rnorm4df(float __a, float __b, float __c, float __d); -float __nv_rnormf(int __dim, const float *__t); -double __nv_round(double __a); -float __nv_roundf(float __a); -double __nv_rsqrt(double __a); -float __nv_rsqrtf(float __a); -double __nv_scalbn(double __a, int __b); -float __nv_scalbnf(float __a, int __b); -double __nv_sin(double __a); -void __nv_sincos(double __a, double *__sptr, double *__cptr); -void __nv_sincosf(float __a, float *__sptr, float *__cptr); -void __nv_sincospi(double __a, double *__sptr, double *__cptr); -void __nv_sincospif(float __a, float *__sptr, float *__cptr); -float __nv_fast_sinf(float __a); -float __nv_sinf(float __a); -double __nv_sinh(double __a); -float __nv_sinhf(float __a); -double __nv_sinpi(double __a); -float __nv_sinpif(float __a); -double __nv_sqrt(double __a); -float __nv_sqrtf(float __a); -double __nv_tan(double __a); -float __nv_tanf(float __a); -double __nv_tanh(double __a); -float __nv_tanhf(float __a); -double __nv_tgamma(double __a); -float __nv_tgammaf(float __a); -double __nv_trunc(double __a); -float __nv_truncf(float __a); -unsigned long long __nv_ullmax(unsigned long long __a, - unsigned long long __b); -unsigned long long __nv_ullmin(unsigned long long __a, - unsigned long long __b); -unsigned int __nv_umax(unsigned int __a, unsigned int __b); -unsigned int __nv_umin(unsigned int __a, unsigned int __b); - -double __nv_y0(double __a); -float __nv_y0f(float __a); -double __nv_y1(double __a); -float __nv_y1f(float __a); -double __nv_yn(int __a, double __b); -float __nv_ynf(int __a, float __b); - -#endif // __LIBM_NVTPX_H__ diff --git a/aomp-device-libs/libm/src/libm.c b/aomp-device-libs/libm/src/libm.c index ca05a6d..e22a11a 100644 --- a/aomp-device-libs/libm/src/libm.c +++ b/aomp-device-libs/libm/src/libm.c @@ -14,10 +14,19 @@ // double fast_sqrt(double __a) { ... } // #endif +#define __BUILD_MATH_BUILTINS_LIB__ + #ifdef __AMDGCN__ -#include "libm-amdgcn.c" +#pragma omp declare target +#define __OPENMP_AMDGCN__ +#include <__clang_hip_math.h> +#pragma omp end declare target #endif #ifdef __NVPTX__ -#include "libm-nvptx.c" +#pragma omp declare target +#define __CUDA__ +#define __OPENMP_NVPTX__ +#include <__clang_cuda_math.h> +#pragma omp end declare target #endif diff --git a/aomp-device-libs/libm/src/libm.cpp b/aomp-device-libs/libm/src/libm.cpp deleted file mode 100644 index 1d3fcb8..0000000 --- a/aomp-device-libs/libm/src/libm.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===--------- libm/libm.cpp ----------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// If the library needs to destinguish betwen different target versions, -// target specific macros for that GPU can be used. -// For nvptx use __NVPTX__. For amdgcn, use __AMDGCN__. -// Example: -// #ifdef __AMDGCN__ && (__AMDGCN__ == 1000) -// double fast_sqrt(double __a) { ... } -// #endif - -#ifdef __AMDGCN__ -#include "libm-amdgcn.cpp" -#endif - -#ifdef __NVPTX__ -#include "libm-nvptx.cpp" -#endif From 29eaee62ab189f2240099b5a5e5dce8542bb8307 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 28 Oct 2020 23:09:12 -0500 Subject: [PATCH 05/31] Cleanup cmake by removing hip-device-lib-path and adding nogpuinc to libm. This was done so that we no longer have to use CCC_OVERRIDE_OPTIONS in build_openmp_extras.sh. --- aomp-device-libs/aompextras/CMakeLists.txt | 10 ---------- aomp-device-libs/libm/CMakeLists.txt | 11 +---------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/aomp-device-libs/aompextras/CMakeLists.txt b/aomp-device-libs/aompextras/CMakeLists.txt index 58c802a..93e1773 100644 --- a/aomp-device-libs/aompextras/CMakeLists.txt +++ b/aomp-device-libs/aompextras/CMakeLists.txt @@ -90,16 +90,6 @@ set(hip_cmd ${LLVM_COMPILER}/bin/clang++ -c -emit-llvm -x hip -I${CMAKE_CURRENT_SOURCE_DIR}/../include -I${CMAKE_CURRENT_SOURCE_DIR}/src) - if(NOT ${AOMP_STANDALONE_BUILD}) - #FIXME Remove NEW_BC_PATH along with reference to /lib/bitcode when non-standalone build switches to new amdgcn path. - if(${NEW_BC_PATH}) - set(BC_DIR ${ROCM_DIR}/amdgcn/bitcode) - else() - set(BC_DIR ${ROCM_DIR}/lib/bitcode) - endif() - set(hip_cmd "${hip_cmd};--hip-device-lib-path=${BC_DIR}") - endif(NOT ${AOMP_STANDALONE_BUILD}) - foreach(file ${hip_sources}) file(RELATIVE_PATH rfile ${CMAKE_CURRENT_SOURCE_DIR}/src ${file}) get_filename_component(fname ${rfile} NAME_WE) diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt index 939a995..4c553dd 100644 --- a/aomp-device-libs/libm/CMakeLists.txt +++ b/aomp-device-libs/libm/CMakeLists.txt @@ -54,19 +54,10 @@ foreach(mcpu ${gpulist}) -Xopenmp-target=${triple} -march=${mcpu} --cuda-device-only + -nogpuinc -nocudalib -O${optimization_level}) - if(NOT ${AOMP_STANDALONE_BUILD}) - #FIXME Remove NEW_BC_PATH along with reference to /lib/bitcode when non-standalone build switches to new amdgcn path. - if(${NEW_BC_PATH}) - set(BC_DIR ${ROCM_DIR}/amdgcn/bitcode) - else() - set(BC_DIR ${ROCM_DIR}/lib/bitcode) - endif() - set(omp_common_args "${omp_common_args};--hip-device-lib-path=${BC_DIR}") - endif(NOT ${AOMP_STANDALONE_BUILD}) - set(openmp_c_cmd ${LLVM_INSTALL_PREFIX}/bin/clang ${omp_common_args} ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c) From d6827a47df420bb6338aa61b16d97ed18688e0e0 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Mon, 30 Nov 2020 20:16:48 -0600 Subject: [PATCH 06/31] slimmed down aompcc goal is to get this script installed into /opt/rocm/llvm/bin//aompcc and have a symlink from /opt/rocm/bin/aompcc -> /opt/rocm/llvm/bin//aompcc --- utils/bin/aompcc | 127 ++++------------------------------------------- 1 file changed, 10 insertions(+), 117 deletions(-) diff --git a/utils/bin/aompcc b/utils/bin/aompcc index 3b19701..c9e9430 100755 --- a/utils/bin/aompcc +++ b/utils/bin/aompcc @@ -2,11 +2,10 @@ # # aompcc: Wrapper (driver) for the AOMP compiler. # The goal of this wrapper is to have a simplified interface for -# all languages and options supported by AOMP. +# compiling for openmp target offload. # # Written by Greg Rodgers Gregory.Rodgers@amd.com # -PROGVERSION="X.Y-Z" # # Copyright (c) 2020 ADVANCED MICRO DEVICES, INC. # @@ -51,17 +50,11 @@ function usage(){ aompcc: Wrapper (driver) for the AOMP compiler. The goal of this wrapper is to have a simplified interface - for all languages and options supported by AOMP. + for compiling openmp target offload. Usage: aompcc [ options ] input-files - hipcc: Symbolic link to aompcc to treat c and cpp input files as if hip - Usage: hipcc [ options ] input-files - Options without values: - -ll Generate LLVM IR for compiler passes - -s Generate dissassembled gcn -g Generate debug information - -version Display version of aompcc then exit -v Verbose, just print commands -vv Very verbose, pass -v to commands -n Dryrun, do nothing, show commands that would execute @@ -71,7 +64,6 @@ function usage(){ Options with values: -aomp $AOMP or _AOMP_INSTALL_DIR_ - -cuda-path $CUDA_PATH or /usr/local/cuda -I Provide one directory per -I option -O LLVM optimization level -o Default=a.out @@ -81,12 +73,11 @@ function usage(){ Examples: aompcc my.c /* Compiles with OpenMP to create a.out */ - aompcc my.hip -o myhip /* Compiles with HIP to create myhip */ Note: Instead of providing these command line options: - -aomp, -cuda-path, --offload-arch, + -aomp, --offload-arch, you may set these environment variables, respectively: - AOMP, CUDA_PATH, AOMP_GPU + AOMP, AOMP_GPU Command line options take precedence over environment variables. @@ -115,11 +106,6 @@ function do_err(){ exit $1 } -function version(){ - echo $PROGVERSION - exit 0 -} - function runcmd(){ THISCMD=$1 if [ $DRYRUN ] ; then @@ -167,14 +153,10 @@ while [ $# -gt 0 ] ; do --quiet) QUIET=true;; -k) KEEPTDIR=true;; -n) DRYRUN=true;; - -c) GEN_OBJECT_ONLY=true;; - -g) GEN_DEBUG=true;; - -ll) GENLL=true;; - -s) GENASM=true;; + -c) GEN_OBJECT_ONLY=true;; + -g) GEN_DEBUG=true;; -noqp) NOQP=true;; - -cl12) CL12=true;; -noshared) NOSHARED=true;; - -cuopts) CUOPTS=$2; shift ;; -I) INCLUDES="$INCLUDES -I $2"; shift ;; -O) LLVMOPT=$2; shift ;; -O3) LLVMOPT=3 ;; @@ -190,8 +172,6 @@ while [ $# -gt 0 ] ; do -h) usage ;; -help) usage ;; --help) usage ;; - -version) version ;; - --version) version ;; -v) VERBOSE=true;; -vv) VV=true;; --) shift ;; @@ -237,7 +217,6 @@ if [ ! -d $AOMP ] ; then fi TARGET_TRIPLE=${TARGET_TRIPLE:-amdgcn-amd-amdhsa} -CUDA_PATH=${CUDA_PATH:-/usr/local/cuda} # Determine which gfx processor to use, default to Vega (gfx900) if [ ! $AOMP_GPU ] ; then @@ -248,10 +227,6 @@ if [ ! $AOMP_GPU ] ; then fi fi -if [ "${AOMP_GPU:0:3}" == "sm_" ] ; then - TARGET_TRIPLE="nvptx64-nvidia-cuda" -fi - LLVMOPT=${LLVMOPT:-3} if [ $VV ] ; then @@ -314,7 +289,6 @@ fi # Print Header block if [ $VERBOSE ] ; then echo "# " - echo "#Info: AOMP Version: $PROGVERSION" echo "#Info: AOMP Path: $AOMP/bin" echo "#Info: How called: $HOW_CALLED" echo "#Info: Run date: $RUNDATE" @@ -333,41 +307,7 @@ fi # Pick the compiler based on filetype COMPILER_BIN_DIR="$AOMP/bin" -if [ "$HOW_CALLED" == "hipcc" ] || [ "$INPUT_FTYPE" == "hip" ] ; then - CLANG_CMD="clang++" - AOMP_GPU_UCASE=${AOMP_GPU^^} - CLANG_ARGS="-O$LLVMOPT \ --lamdhip64 -fopenmp \ --std=c++11 -I$AOMP/clang/11.0.0/include \ --I$AOMP/hsa/include \ --D__HIP_VDI__ \ --fhip-new-launch-api \ --I$AOMP/include \ --D__HIP_ARCH_${AOMP_GPU_UCASE}__=1 \ ---cuda-gpu-arch=$AOMP_GPU " - # treat rest of c and cpp files as hip - HOW_CALLED="hipcc" -elif [ "$INPUT_FTYPE" == "cu" ] ; then - echo "WARNING: CUDA WITH NVCC IN aompcc IS UNTESTED " - if [ ! -d $CUDA_PATH ] ; then - echo "WARNING: No CUDA_PATH directory at $CUDA_PATH " - exit $DEADRC - fi - CLANG_CMD="nvcc" - INCLUDES="-I $CUDA_PATH/include ${INCLUDES}" - CLANG_ARGS="$CLANG_ARGS $INCLUDES" - COMPILER_BIN_DIR="$CUDA_PATH/bin" - -elif [ "$INPUT_FTYPE" == "cl" ] ; then - echo "WARNING: OPENCL IN aompcc IS UNTESTED " - CLANG_CMD="clang-ocl" - if [ $CL12 ] ; then - CLANG_ARGS="$CLANG_ARGS -emit-llvm -target $TARGET_TRIPLE -x cl -D__AMD__=1 -D__$AOMP_GPU__=1 -D__OPENCL_VERSION__=120 -D__IMAGE_SUPPORT__=1 -O3 -m64 -cl-kernel-arg-info -cl-std=CL1.2 -mllvm -amdgpu-early-inline-all -Xclang -target-feature -Xclang -code-object-v3 -Xclang -cl-ext=+cl_khr_fp64,+cl_khr_global_int32_base_atomics,+cl_khr_global_int32_extended_atomics,+cl_khr_local_int32_base_atomics,+cl_khr_local_int32_extended_atomics,+cl_khr_int64_base_atomics,+cl_khr_int64_extended_atomics,+cl_khr_3d_image_writes,+cl_khr_byte_addressable_store,+cl_khr_gl_sharing,+cl_amd_media_ops,+cl_amd_media_ops2,+cl_khr_subgroups -include $AOMP/lib/clang/9.0.1/include/opencl-c.h $CLOPTS $LINKOPTS" - else - CLANG_ARGS="$CLANG_ARGS -x cl -Xclang -cl-std=CL2.0 -Xclang -code-object-v3 $CLOPTS $LINKOPTS $INCLUDES -include $AOMP/lib/clang/9.0.1/include/opencl-c.h -Dcl_clang_storage_class_specifiers -Dcl_khr_fp64 -target ${TARGET_TRIPLE}" - fi - -elif [ "$INPUT_FTYPE" == "cpp" ] || [ "$INPUT_FTYPE" == "cxx" ] ; then +if [ "$INPUT_FTYPE" == "cpp" ] || [ "$INPUT_FTYPE" == "cxx" ] ; then # OpenMP c++ CLANG_ARGS="$CLANG_ARGS -O$LLVMOPT -target $HOST_TARGET -fopenmp -fopenmp-targets=$TARGET_TRIPLE -Xopenmp-target=$TARGET_TRIPLE -march=$AOMP_GPU" CLANG_CMD="clang++" @@ -389,68 +329,21 @@ fi if [ $GEN_DEBUG ] ; then CLANG_ARGS=" -g $CLANG_ARGS" fi -if [ $VV ] ; then +if [ $VV ] ; then CLANG_ARGS=" -v $CLANG_ARGS" fi -if [ $GEN_OBJECT_ONLY ] ; then +if [ $GEN_OBJECT_ONLY ] ; then CLANG_ARGS=" -c $CLANG_ARGS" fi -if [ $GENLL ] ; then - echo "ERROR: -ll option not supported yet" - exit $DEADRC -fi -if [ $GENASM ] ; then - echo "ERROR: -s option not supported yet" - exit $DEADRC -fi __INPUTS="" for __input_file in `echo $INPUTFILES` ; do - _ftype=${__input_file##*\.} - if [ "$_ftype" == "hip" ] ; then - __INPUTS+=" -x hip $__input_file" - elif [ "$HOW_CALLED" == "hipcc" ] && [ "$_ftype" == "cpp" ] ; then - __INPUTS+=" -x hip $__input_file" - elif [ "$HOW_CALLED" == "hipcc" ] && [ "$_ftype" == "hpp" ] ; then - __INPUTS+=" -x hip $__input_file" - elif [ "$HOW_CALLED" == "hipcc" ] && [ "$_ftype" == "c" ] ; then - __INPUTS+=" -x hip $__input_file" - elif [ "$HOW_CALLED" == "hipcc" ] && [ "$_ftype" == "h" ] ; then - __INPUTS+=" -x hip $__input_file" - else - __INPUTS+=" $__input_file" - fi + __INPUTS+=" $__input_file" done rc=0 runcmd "$COMPILER_BIN_DIR/$CLANG_CMD $CLANG_ARGS $PASSTHRUARGS $__INPUTS -o $OUTDIR/$OUTFILE" -# FIXME: This needs to be cleaned up and tested -if [ $GENLL ] ; then - runcmd "$AOMP/bin/llvm-dis -o $TMPDIR/$FNAME.ll $TMPDIR/$FNAME.bc" - if [ "$OUTDIR" != "$TMPDIR" ] ; then - runcmd "cp $TMPDIR/$FNAME.ll $OUTDIR/$FNAME.ll" - fi -fi - -# FIXME: This needs to be cleaned up and tested -if [ $GENASM ] ; then - textstarthex=`readelf -S -W $OUTDIR/$OUTFILE | grep .text | awk '{print $6}'` - textstart=$((0x$textstarthex)) - textszhex=`readelf -S -W $OUTDIR/$OUTFILE | grep .text | awk '{print $7}'` - textsz=$((0x$textszhex)) - countclause=" count=$textsz skip=$textstart" - dd if=$OUTDIR/$OUTFILE of=$OUTDIR/$FNAME.raw bs=1 $countclause 2>/dev/null - hexdump -v -e '/1 "0x%02X "' $OUTDIR/$FNAME.raw | $AOMP/bin/llvm-mc -arch=amdgcn -offload-arch=$AOMP_GPU -disassemble >$OUTDIR/$FNAME.s 2>$OUTDIR/$FNAME.s.err - rm $OUTDIR/$FNAME.raw - if [ "$AOMP_GPU" == "kaveri" ] ; then - echo "WARNING: Disassembly not supported for Kaveri. See $FNAME.s.err" - else - rm $OUTDIR/$FNAME.s.err - echo "#INFO File $OUTDIR/$FNAME.s contains amdgcn assembly" - fi -fi - # cleanup do_err 0 exit 0 From cc6154e96095d7b79b89fc1838fbe7406fc7bdd3 Mon Sep 17 00:00:00 2001 From: estewart08 Date: Thu, 3 Dec 2020 14:49:03 -0600 Subject: [PATCH 07/31] Add soft link for aompcc for UC build. (#35) Soft link will reside in /opt/rocm/bin/aompcc and point to ../llvm/bin/aompcc. --- utils/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 1a81505..9d6475e 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -177,4 +177,9 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins DESTINATION "rocm-bin") + + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/aompcc DESTINATION "bin") + + # Create soft link for rocm/bin/aompcc -> rocm/llvm/bin/aompcc. + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../llvm/bin/aompcc ${CMAKE_INSTALL_PREFIX}/rocm-bin/aompcc)" endif() From 7d27bde562b9b349123496767e229f2c2eaea7c1 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Thu, 3 Dec 2020 15:29:38 -0600 Subject: [PATCH 08/31] Add missing ')' --- utils/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 9d6475e..4a206d9 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -181,5 +181,5 @@ else() install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/aompcc DESTINATION "bin") # Create soft link for rocm/bin/aompcc -> rocm/llvm/bin/aompcc. - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../llvm/bin/aompcc ${CMAKE_INSTALL_PREFIX}/rocm-bin/aompcc)" + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../llvm/bin/aompcc ${CMAKE_INSTALL_PREFIX}/rocm-bin/aompcc)") endif() From 9c3a4aed0f659321e5ebfd5e58660fbd92ee6526 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 13 Jan 2021 16:42:56 -0600 Subject: [PATCH 09/31] Install utils into bin which will ultimately land in llvm/bin. Symlinks will be created in the prototype build script. --- utils/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4a206d9..7516409 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -173,13 +173,8 @@ if(${AOMP_STANDALONE_BUILD}) else() install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mymcpu + ${CMAKE_CURRENT_BINARY_DIR}/aompcc ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu - ${CMAKE_CURRENT_BINARY_DIR}/prepare-builtins - DESTINATION "rocm-bin") - - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/aompcc DESTINATION "bin") - - # Create soft link for rocm/bin/aompcc -> rocm/llvm/bin/aompcc. - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../llvm/bin/aompcc ${CMAKE_INSTALL_PREFIX}/rocm-bin/aompcc)") + DESTINATION "bin") endif() From 7d3626ed5f7110de205c15bc56d2894ee74a5ffb Mon Sep 17 00:00:00 2001 From: Dhruva Chakrabarti Date: Thu, 4 Feb 2021 17:02:28 -0800 Subject: [PATCH 10/31] Added back support for -version and --version --- utils/bin/aompcc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/bin/aompcc b/utils/bin/aompcc index c9e9430..8329cc2 100755 --- a/utils/bin/aompcc +++ b/utils/bin/aompcc @@ -45,6 +45,9 @@ # EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the # Software License Agreement. # + +PROGVERSION="12.0-0" + function usage(){ /bin/cat 2>&1 <<"EOF" @@ -55,6 +58,8 @@ function usage(){ Options without values: -g Generate debug information + -version Display version of aompcc then exit + --version Display version of aompcc then exit -v Verbose, just print commands -vv Very verbose, pass -v to commands -n Dryrun, do nothing, show commands that would execute @@ -106,6 +111,11 @@ function do_err(){ exit $1 } +function version(){ + echo $PROGVERSION + exit 0 +} + function runcmd(){ THISCMD=$1 if [ $DRYRUN ] ; then @@ -172,6 +182,8 @@ while [ $# -gt 0 ] ; do -h) usage ;; -help) usage ;; --help) usage ;; + -version) version ;; + --version) version ;; -v) VERBOSE=true;; -vv) VV=true;; --) shift ;; From f76c3be3b29a779a1ccc19e8d0035880fe71e09b Mon Sep 17 00:00:00 2001 From: Dhruva Chakrabarti Date: Mon, 8 Feb 2021 21:41:40 -0800 Subject: [PATCH 11/31] Change hardcoded version number to generic --- utils/bin/aompcc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/bin/aompcc b/utils/bin/aompcc index 8329cc2..cecbd3a 100755 --- a/utils/bin/aompcc +++ b/utils/bin/aompcc @@ -5,6 +5,7 @@ # compiling for openmp target offload. # # Written by Greg Rodgers Gregory.Rodgers@amd.com +PROGVERSION="X.Y-Z" # # # Copyright (c) 2020 ADVANCED MICRO DEVICES, INC. @@ -46,8 +47,6 @@ # Software License Agreement. # -PROGVERSION="12.0-0" - function usage(){ /bin/cat 2>&1 <<"EOF" From 0aa6595822feba1391e55677aa1dcf3356239e2d Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Fri, 26 Feb 2021 19:44:26 -0500 Subject: [PATCH 12/31] Add f90print f90printi f90printf f90printd routines --- aomp-device-libs/aompextras/src/cprint.c | 22 +++ aomp-device-libs/aompextras/src/cprint.ll | 227 ++++++++++++++++++++++ 2 files changed, 249 insertions(+) create mode 100644 aomp-device-libs/aompextras/src/cprint.c create mode 100644 aomp-device-libs/aompextras/src/cprint.ll diff --git a/aomp-device-libs/aompextras/src/cprint.c b/aomp-device-libs/aompextras/src/cprint.c new file mode 100644 index 0000000..eb4b0df --- /dev/null +++ b/aomp-device-libs/aompextras/src/cprint.c @@ -0,0 +1,22 @@ +// compile with +// /home/rlieberm/rocm/aomp_13.0-2/bin/clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 -c cprint.c -emit-llvm -o cprint.bc -save-temps + +// dump the ll +// cp cprint-openmp-amdgcn-amd-amdhsa-gfx906.tmp.ll ~/git/aomp12/aomp-extras/aomp-device-libs/aompextras/src/cprint.ll + + +#include +#pragma omp declare target +void f90print_(char *s) { + printf("%s\n", s); +} +void f90printi_(char *s, int *i) { + printf("%s %d\n", s, *i); +} +void f90printf_(char *s, float *f) { + printf("%s %f\n", s, *f); +} +void f90printd_(char *s, double *d) { + printf("%s %g\n", s, *d); +} +#pragma omp end declare target diff --git a/aomp-device-libs/aompextras/src/cprint.ll b/aomp-device-libs/aompextras/src/cprint.ll new file mode 100644 index 0000000..c8b1ce0 --- /dev/null +++ b/aomp-device-libs/aompextras/src/cprint.ll @@ -0,0 +1,227 @@ +; ModuleID = 'cprint-openmp-amdgcn-amd-amdhsa-gfx906.tmp.bc' +source_filename = "cprint.c" +target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7" +target triple = "amdgcn-amd-amdhsa" + +@.str.1 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %d\0A\00", align 1 +@.str.2 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %f\0A\00", align 1 +@.str.3 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %g\0A\00", align 1 + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90print_(i8* %s) local_unnamed_addr #0 { +entry: + %0 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %0, 28 + %1 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %2 = bitcast i8* %1 to i32* + %3 = addrspacecast i32* %2 to i32 addrspace(1)* + store i32 24, i32 addrspace(1)* %3, align 4 + %4 = getelementptr inbounds i8, i8* %1, i64 4 + %5 = bitcast i8* %4 to i32* + %6 = addrspacecast i32* %5 to i32 addrspace(1)* + store i32 2, i32 addrspace(1)* %6, align 4 + %7 = getelementptr inbounds i8, i8* %1, i64 8 + %8 = bitcast i8* %7 to i32* + %9 = addrspacecast i32* %8 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %9, align 4 + %10 = getelementptr inbounds i8, i8* %1, i64 12 + %11 = bitcast i8* %10 to i32* + %12 = addrspacecast i32* %11 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %12, align 4 + %13 = getelementptr inbounds i8, i8* %1, i64 16 + %14 = bitcast i8* %13 to i32* + %15 = addrspacecast i32* %14 to i32 addrspace(1)* + store i32 4, i32 addrspace(1)* %15, align 4 + %16 = getelementptr inbounds i8, i8* %1, i64 20 + %17 = bitcast i8* %16 to i32* + %18 = addrspacecast i32* %17 to i32 addrspace(1)* + store i32 %0, i32 addrspace(1)* %18, align 4 + %19 = getelementptr inbounds i8, i8* %1, i64 24 + %20 = bitcast i8* %19 to i32* + %21 = addrspacecast i32* %20 to i32 addrspace(1)* + store i32 684837, i32 addrspace(1)* %21, align 1 + %22 = getelementptr inbounds i8, i8* %1, i64 28 + %23 = addrspacecast i8* %22 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %23, i8* align 1 %s, i32 %0, i1 false) + %24 = tail call i32 @printf_execute(i8* %1, i32 %total_buffer_size) #2 + ret void +} + +declare i32 @__strlen_max(i8*, i32) local_unnamed_addr + +declare i8* @printf_allocate(i32) local_unnamed_addr + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #1 + +declare i32 @printf_execute(i8*, i32) local_unnamed_addr + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printi_(i8* %s, i32* nocapture readonly %i) local_unnamed_addr #0 { +entry: + %0 = load i32, i32* %i, align 4, !tbaa !4 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 39 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 32, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 852000, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 28 + %24 = bitcast i8* %23 to i32* + %25 = addrspacecast i32* %24 to i32 addrspace(1)* + store i32 %0, i32 addrspace(1)* %25, align 4 + %26 = getelementptr inbounds i8, i8* %2, i64 32 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %27, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.1, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 39 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printf_(i8* %s, float* nocapture readonly %f) local_unnamed_addr #0 { +entry: + %0 = load float, float* %f, align 4, !tbaa !8 + %conv = fpext float %0 to double + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 47 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 196672, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to double* + %25 = addrspacecast double* %24 to double addrspace(1)* + store double %conv, double addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %27, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.2, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 47 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printd_(i8* %s, double* nocapture readonly %d) local_unnamed_addr #0 { +entry: + %0 = bitcast double* %d to i64* + %1 = load i64, i64* %0, align 8, !tbaa !10 + %2 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %2, 47 + %3 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %4 = bitcast i8* %3 to i32* + %5 = addrspacecast i32* %4 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %5, align 4 + %6 = getelementptr inbounds i8, i8* %3, i64 4 + %7 = bitcast i8* %6 to i32* + %8 = addrspacecast i32* %7 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %8, align 4 + %9 = getelementptr inbounds i8, i8* %3, i64 8 + %10 = bitcast i8* %9 to i32* + %11 = addrspacecast i32* %10 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %11, align 4 + %12 = getelementptr inbounds i8, i8* %3, i64 12 + %13 = bitcast i8* %12 to i32* + %14 = addrspacecast i32* %13 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %14, align 4 + %15 = getelementptr inbounds i8, i8* %3, i64 16 + %16 = bitcast i8* %15 to i32* + %17 = addrspacecast i32* %16 to i32 addrspace(1)* + store i32 196672, i32 addrspace(1)* %17, align 4 + %18 = getelementptr inbounds i8, i8* %3, i64 20 + %19 = bitcast i8* %18 to i32* + %20 = addrspacecast i32* %19 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %20, align 4 + %21 = getelementptr inbounds i8, i8* %3, i64 24 + %22 = bitcast i8* %21 to i32* + %23 = addrspacecast i32* %22 to i32 addrspace(1)* + store i32 %2, i32 addrspace(1)* %23, align 4 + %24 = getelementptr inbounds i8, i8* %3, i64 32 + %25 = bitcast i8* %24 to i64* + %26 = addrspacecast i64* %25 to i64 addrspace(1)* + store i64 %1, i64 addrspace(1)* %26, align 8 + %27 = getelementptr inbounds i8, i8* %3, i64 40 + %28 = addrspacecast i8* %27 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %28, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.3, i64 0, i64 0), i64 7, i1 false) + %29 = getelementptr inbounds i8, i8* %3, i64 47 + %30 = addrspacecast i8* %29 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %30, i8* align 1 %s, i32 %2, i1 false) + %31 = tail call i32 @printf_execute(i8* %3, i32 %total_buffer_size) #2 + ret void +} + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noalias nocapture writeonly, i8 addrspace(4)* noalias nocapture readonly, i64, i1 immarg) #1 + +attributes #0 = { alwaysinline norecurse nounwind "amdgpu-unsafe-fp-atomics"="true" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { argmemonly nofree nosync nounwind willreturn } +attributes #2 = { nounwind } + +!llvm.module.flags = !{!0, !1} +!opencl.ocl.version = !{!2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 7, !"PIC Level", i32 2} +!2 = !{i32 2, i32 0} +!3 = !{!"AOMP_STANDALONE_13.0-2 clang version 13.0.0 (https://github.com/ROCm-Developer-Tools/llvm-project 897d9549eb6dfdf42ee44e6371107b9ae2df7129)"} +!4 = !{!5, !5, i64 0} +!5 = !{!"int", !6, i64 0} +!6 = !{!"omnipotent char", !7, i64 0} +!7 = !{!"Simple C/C++ TBAA"} +!8 = !{!9, !9, i64 0} +!9 = !{!"float", !6, i64 0} +!10 = !{!11, !11, i64 0} +!11 = !{!"double", !6, i64 0} From 2f321ea72ca61a649b46022d15ed9967ebf2ce9a Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Wed, 17 Mar 2021 09:12:25 -0500 Subject: [PATCH 13/31] Add linking of ocml.bc into libm to resolve undefined symbols. --- aomp-device-libs/libm/CMakeLists.txt | 48 ++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt index 4c553dd..580ad54 100644 --- a/aomp-device-libs/libm/CMakeLists.txt +++ b/aomp-device-libs/libm/CMakeLists.txt @@ -61,12 +61,31 @@ foreach(mcpu ${gpulist}) set(openmp_c_cmd ${LLVM_INSTALL_PREFIX}/bin/clang ${omp_common_args} ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c) - add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}.bc - COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" - ) - add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc) + # AMD only linking of ocml.bc to libm + if(${triple} STREQUAL "amdgcn-amd-amdhsa") + add_custom_command( + OUTPUT libm-${systemarch}-${mcpu}-tmp.bc + COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}-tmp.bc + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" + ) + add_custom_command( + OUTPUT libm-${systemarch}-${mcpu}.bc + COMMAND ${LLVM_INSTALL_PREFIX}/bin/llvm-link ${OUTPUTDIR}/libm-${systemarch}-${mcpu}-tmp.bc ${ocml_bc} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc + COMMENT "Linking ocml.bc to libm-${mcpu}" + ) + + # Final bc is dependent on libm-tmp.bc + add_custom_target(libm-${systemarch}-${mcpu}-tmp ALL DEPENDS libm-${systemarch}-${mcpu}-tmp.bc) + add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc libm-${systemarch}-${mcpu}-tmp) + else() + add_custom_command( + OUTPUT libm-${systemarch}-${mcpu}.bc + COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" + ) + add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc) + endif() + install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc DESTINATION "lib/libdevice") install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc @@ -88,6 +107,23 @@ separate_arguments(gfxgpus) set(triple "amdgcn-amd-amdhsa") set(systemarch "amdgcn") set(gpulist ${gfxgpus}) + +# Use config from device-libs to find install location +# Look for ocml.bc to link into libm +find_package(AMDDeviceLibs REQUIRED CONFIG) +if(NOT DEFINED AMD_DEVICE_LIBS_TARGETS) + get_property(AMD_DEVICE_LIBS_TARGETS GLOBAL PROPERTY AMD_DEVICE_LIBS) +endif() +foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) + get_target_property(bc_lib_path ${AMDGCN_LIB_TARGET} LOCATION) + if(NOT bc_lib_path) + message(FATAL_ERROR "Could not find path to bitcode library") + endif() + if(${AMDGCN_LIB_TARGET} STREQUAL "ocml") + set(ocml_bc ${bc_lib_path}) + endif() +endforeach() + build_static_device_bc_lib() set(nvptx_numbers $ENV{NVPTXGPUS}) From ccd29303e582eb488d6963b8d1365d06b349c422 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Thu, 18 Mar 2021 11:21:26 -0500 Subject: [PATCH 14/31] Add message to print out AMDDeviceLibs_DIR location. --- aomp-device-libs/libm/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt index 580ad54..dd79536 100644 --- a/aomp-device-libs/libm/CMakeLists.txt +++ b/aomp-device-libs/libm/CMakeLists.txt @@ -111,6 +111,7 @@ set(gpulist ${gfxgpus}) # Use config from device-libs to find install location # Look for ocml.bc to link into libm find_package(AMDDeviceLibs REQUIRED CONFIG) +message("---AMDDeviceLibs_DIR: ${AMDDeviceLibs_DIR}") if(NOT DEFINED AMD_DEVICE_LIBS_TARGETS) get_property(AMD_DEVICE_LIBS_TARGETS GLOBAL PROPERTY AMD_DEVICE_LIBS) endif() From 7c66cf0b0327e2bc0e6d83a14d11570ef00c105e Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Tue, 4 May 2021 16:43:37 -0500 Subject: [PATCH 15/31] Fix for aomp13 an cov4 --- utils/bin/cloc.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/bin/cloc.sh b/utils/bin/cloc.sh index c7a836e..8042730 100755 --- a/utils/bin/cloc.sh +++ b/utils/bin/cloc.sh @@ -313,12 +313,12 @@ else if [ -d $AOMP/lib/clang/12.0.0 ] ; then CLANGDIR=$AOMP/lib/clang/12.0.0 else - CLANGDIR=$AOMP/lib/clang/11.0.0 + CLANGDIR=$AOMP/lib/clang/13.0.0 fi if [ $CL12 ] ; then - CMD_CLC=${CMD_CLC:-clang --rocm-path=$AOMPHIP -c -mcpu=$LC_MCPU -emit-llvm -target $TARGET_TRIPLE -x cl -D__AMD__=1 -D__$LC_MCPU__=1 -D__OPENCL_VERSION__=120 -D__IMAGE_SUPPORT__=1 -O3 -m64 -cl-kernel-arg-info -cl-std=CL1.2 -mllvm -amdgpu-early-inline-all -Xclang -target-feature -Xclang -code-object-v3 -Xclang -cl-ext=+cl_khr_fp64,+cl_khr_global_int32_base_atomics,+cl_khr_global_int32_extended_atomics,+cl_khr_local_int32_base_atomics,+cl_khr_local_int32_extended_atomics,+cl_khr_int64_base_atomics,+cl_khr_int64_extended_atomics,+cl_khr_3d_image_writes,+cl_khr_byte_addressable_store,+cl_khr_gl_sharing,+cl_amd_media_ops,+cl_amd_media_ops2,+cl_khr_subgroups -include $CLANGDIR/include/opencl-c.h $CLOPTS $LINKOPTS} + CMD_CLC=${CMD_CLC:-clang --rocm-path=$AOMPHIP -c -mcpu=$LC_MCPU -emit-llvm -target $TARGET_TRIPLE -x cl -D__AMD__=1 -D__$LC_MCPU__=1 -D__OPENCL_VERSION__=120 -D__IMAGE_SUPPORT__=1 -O3 -m64 -cl-kernel-arg-info -cl-std=CL1.2 -mllvm -amdgpu-early-inline-all -Xclang -target-feature -Xclang -cl-ext=+cl_khr_fp64,+cl_khr_global_int32_base_atomics,+cl_khr_global_int32_extended_atomics,+cl_khr_local_int32_base_atomics,+cl_khr_local_int32_extended_atomics,+cl_khr_int64_base_atomics,+cl_khr_int64_extended_atomics,+cl_khr_3d_image_writes,+cl_khr_byte_addressable_store,+cl_khr_gl_sharing,+cl_amd_media_ops,+cl_amd_media_ops2,+cl_khr_subgroups -include $CLANGDIR/include/opencl-c.h $CLOPTS $LINKOPTS} else - CMD_CLC=${CMD_CLC:-clang --rocm-path=$AOMPHIP -c -mcpu=$LC_MCPU -emit-llvm -x cl -Xclang -cl-std=CL2.0 -Xclang -code-object-v3 $CLOPTS $LINKOPTS $INCLUDES -include $CLANGDIR/include/opencl-c.h -Dcl_clang_storage_class_specifiers -Dcl_khr_fp64 -target ${TARGET_TRIPLE}} + CMD_CLC=${CMD_CLC:-clang --rocm-path=$AOMPHIP -c -mcpu=$LC_MCPU -emit-llvm -x cl -Xclang -cl-std=CL2.0 $CLOPTS $LINKOPTS $INCLUDES -include $CLANGDIR/include/opencl-c.h -Dcl_clang_storage_class_specifiers -Dcl_khr_fp64 -target ${TARGET_TRIPLE}} fi fi @@ -329,9 +329,9 @@ CMD_OPT=${CMD_OPT:-opt -O$LLVMOPT -mcpu=$LC_MCPU -amdgpu-annotate-kernel-feature #cl files require code-object-v2 if [ "$filetype" == "cl" ] ; then - CMD_LLC=${CMD_LLC:-llc -mtriple ${TARGET_TRIPLE} -filetype=obj -mattr=-code-object-v3 -mcpu=$LC_MCPU} + CMD_LLC=${CMD_LLC:-llc -mtriple ${TARGET_TRIPLE} -filetype=obj -mcpu=$LC_MCPU} else - CMD_LLC=${CMD_LLC:-llc -mtriple ${TARGET_TRIPLE} -filetype=obj -mattr=+code-object-v3 -mcpu=$LC_MCPU} + CMD_LLC=${CMD_LLC:-llc -mtriple ${TARGET_TRIPLE} -filetype=obj -mcpu=$LC_MCPU} fi RUNDATE=`date` From f820ba26a4bdb886bb7eb07cb2980a03580b8936 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Wed, 5 May 2021 14:51:40 -0500 Subject: [PATCH 16/31] Add f90printl to do long (int64) --- aomp-device-libs/aompextras/src/cprint.c | 3 + aomp-device-libs/aompextras/src/cprint.ll | 154 ++++++++++++++-------- 2 files changed, 105 insertions(+), 52 deletions(-) diff --git a/aomp-device-libs/aompextras/src/cprint.c b/aomp-device-libs/aompextras/src/cprint.c index eb4b0df..1caba95 100644 --- a/aomp-device-libs/aompextras/src/cprint.c +++ b/aomp-device-libs/aompextras/src/cprint.c @@ -13,6 +13,9 @@ void f90print_(char *s) { void f90printi_(char *s, int *i) { printf("%s %d\n", s, *i); } +void f90printl_(char *s, long *i) { + printf("%s %ld\n", s, *i); +} void f90printf_(char *s, float *f) { printf("%s %f\n", s, *f); } diff --git a/aomp-device-libs/aompextras/src/cprint.ll b/aomp-device-libs/aompextras/src/cprint.ll index c8b1ce0..a0c425a 100644 --- a/aomp-device-libs/aompextras/src/cprint.ll +++ b/aomp-device-libs/aompextras/src/cprint.ll @@ -4,8 +4,8 @@ target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:3 target triple = "amdgcn-amd-amdhsa" @.str.1 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %d\0A\00", align 1 -@.str.2 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %f\0A\00", align 1 -@.str.3 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %g\0A\00", align 1 +@.str.3 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %f\0A\00", align 1 +@.str.4 = private unnamed_addr addrspace(4) constant [7 x i8] c"%s %g\0A\00", align 1 ; Function Attrs: alwaysinline norecurse nounwind define void @f90print_(i8* %s) local_unnamed_addr #0 { @@ -96,7 +96,7 @@ entry: store i32 %0, i32 addrspace(1)* %25, align 4 %26 = getelementptr inbounds i8, i8* %2, i64 32 %27 = addrspacecast i8* %26 to i8 addrspace(1)* - tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %27, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.1, i64 0, i64 0), i64 7, i1 false) + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.1, i64 0, i64 0), i64 7, i1 false) %28 = getelementptr inbounds i8, i8* %2, i64 39 %29 = addrspacecast i8* %28 to i8 addrspace(1)* tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) @@ -104,10 +104,59 @@ entry: ret void } +; Function Attrs: alwaysinline norecurse nounwind +define void @f90printl_(i8* %s, i64* nocapture readonly %i) local_unnamed_addr #0 { +entry: + %0 = load i64, i64* %i, align 8, !tbaa !8 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 48 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 852032, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 8, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to i64* + %25 = addrspacecast i64* %24 to i64 addrspace(1)* + store i64 %0, i64 addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = bitcast i8* %26 to i64* + %28 = addrspacecast i64* %27 to i64 addrspace(1)* + store i64 2925165409235749, i64 addrspace(1)* %28, align 1 + %29 = getelementptr inbounds i8, i8* %2, i64 48 + %30 = addrspacecast i8* %29 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %30, i8* align 1 %s, i32 %1, i1 false) + %31 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 + ret void +} + ; Function Attrs: alwaysinline norecurse nounwind define void @f90printf_(i8* %s, float* nocapture readonly %f) local_unnamed_addr #0 { entry: - %0 = load float, float* %f, align 4, !tbaa !8 + %0 = load float, float* %f, align 4, !tbaa !10 %conv = fpext float %0 to double %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 %total_buffer_size = add i32 %1, 47 @@ -145,7 +194,7 @@ entry: store double %conv, double addrspace(1)* %25, align 8 %26 = getelementptr inbounds i8, i8* %2, i64 40 %27 = addrspacecast i8* %26 to i8 addrspace(1)* - tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %27, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.2, i64 0, i64 0), i64 7, i1 false) + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.3, i64 0, i64 0), i64 7, i1 false) %28 = getelementptr inbounds i8, i8* %2, i64 47 %29 = addrspacecast i8* %28 to i8 addrspace(1)* tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) @@ -156,56 +205,55 @@ entry: ; Function Attrs: alwaysinline norecurse nounwind define void @f90printd_(i8* %s, double* nocapture readonly %d) local_unnamed_addr #0 { entry: - %0 = bitcast double* %d to i64* - %1 = load i64, i64* %0, align 8, !tbaa !10 - %2 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 - %total_buffer_size = add i32 %2, 47 - %3 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 - %4 = bitcast i8* %3 to i32* - %5 = addrspacecast i32* %4 to i32 addrspace(1)* - store i32 40, i32 addrspace(1)* %5, align 4 - %6 = getelementptr inbounds i8, i8* %3, i64 4 - %7 = bitcast i8* %6 to i32* - %8 = addrspacecast i32* %7 to i32 addrspace(1)* - store i32 3, i32 addrspace(1)* %8, align 4 - %9 = getelementptr inbounds i8, i8* %3, i64 8 - %10 = bitcast i8* %9 to i32* - %11 = addrspacecast i32* %10 to i32 addrspace(1)* - store i32 983041, i32 addrspace(1)* %11, align 4 - %12 = getelementptr inbounds i8, i8* %3, i64 12 - %13 = bitcast i8* %12 to i32* - %14 = addrspacecast i32* %13 to i32 addrspace(1)* - store i32 983041, i32 addrspace(1)* %14, align 4 - %15 = getelementptr inbounds i8, i8* %3, i64 16 - %16 = bitcast i8* %15 to i32* - %17 = addrspacecast i32* %16 to i32 addrspace(1)* - store i32 196672, i32 addrspace(1)* %17, align 4 - %18 = getelementptr inbounds i8, i8* %3, i64 20 - %19 = bitcast i8* %18 to i32* - %20 = addrspacecast i32* %19 to i32 addrspace(1)* - store i32 7, i32 addrspace(1)* %20, align 4 - %21 = getelementptr inbounds i8, i8* %3, i64 24 - %22 = bitcast i8* %21 to i32* - %23 = addrspacecast i32* %22 to i32 addrspace(1)* - store i32 %2, i32 addrspace(1)* %23, align 4 - %24 = getelementptr inbounds i8, i8* %3, i64 32 - %25 = bitcast i8* %24 to i64* - %26 = addrspacecast i64* %25 to i64 addrspace(1)* - store i64 %1, i64 addrspace(1)* %26, align 8 - %27 = getelementptr inbounds i8, i8* %3, i64 40 - %28 = addrspacecast i8* %27 to i8 addrspace(1)* - tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* align 1 dereferenceable(7) %28, i8 addrspace(4)* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.3, i64 0, i64 0), i64 7, i1 false) - %29 = getelementptr inbounds i8, i8* %3, i64 47 - %30 = addrspacecast i8* %29 to i8 addrspace(1)* - tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %30, i8* align 1 %s, i32 %2, i1 false) - %31 = tail call i32 @printf_execute(i8* %3, i32 %total_buffer_size) #2 + %0 = load double, double* %d, align 8, !tbaa !12 + %1 = tail call i32 @__strlen_max(i8* %s, i32 1024) #2 + %total_buffer_size = add i32 %1, 47 + %2 = tail call i8* @printf_allocate(i32 %total_buffer_size) #2 + %3 = bitcast i8* %2 to i32* + %4 = addrspacecast i32* %3 to i32 addrspace(1)* + store i32 40, i32 addrspace(1)* %4, align 4 + %5 = getelementptr inbounds i8, i8* %2, i64 4 + %6 = bitcast i8* %5 to i32* + %7 = addrspacecast i32* %6 to i32 addrspace(1)* + store i32 3, i32 addrspace(1)* %7, align 4 + %8 = getelementptr inbounds i8, i8* %2, i64 8 + %9 = bitcast i8* %8 to i32* + %10 = addrspacecast i32* %9 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %10, align 4 + %11 = getelementptr inbounds i8, i8* %2, i64 12 + %12 = bitcast i8* %11 to i32* + %13 = addrspacecast i32* %12 to i32 addrspace(1)* + store i32 983041, i32 addrspace(1)* %13, align 4 + %14 = getelementptr inbounds i8, i8* %2, i64 16 + %15 = bitcast i8* %14 to i32* + %16 = addrspacecast i32* %15 to i32 addrspace(1)* + store i32 196672, i32 addrspace(1)* %16, align 4 + %17 = getelementptr inbounds i8, i8* %2, i64 20 + %18 = bitcast i8* %17 to i32* + %19 = addrspacecast i32* %18 to i32 addrspace(1)* + store i32 7, i32 addrspace(1)* %19, align 4 + %20 = getelementptr inbounds i8, i8* %2, i64 24 + %21 = bitcast i8* %20 to i32* + %22 = addrspacecast i32* %21 to i32 addrspace(1)* + store i32 %1, i32 addrspace(1)* %22, align 4 + %23 = getelementptr inbounds i8, i8* %2, i64 32 + %24 = bitcast i8* %23 to double* + %25 = addrspacecast double* %24 to double addrspace(1)* + store double %0, double addrspace(1)* %25, align 8 + %26 = getelementptr inbounds i8, i8* %2, i64 40 + %27 = addrspacecast i8* %26 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noundef align 1 dereferenceable(7) %27, i8 addrspace(4)* noundef align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8] addrspace(4)* @.str.4, i64 0, i64 0), i64 7, i1 false) + %28 = getelementptr inbounds i8, i8* %2, i64 47 + %29 = addrspacecast i8* %28 to i8 addrspace(1)* + tail call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* align 1 %29, i8* align 1 %s, i32 %1, i1 false) + %30 = tail call i32 @printf_execute(i8* %2, i32 %total_buffer_size) #2 ret void } ; Function Attrs: argmemonly nofree nosync nounwind willreturn declare void @llvm.memcpy.p1i8.p4i8.i64(i8 addrspace(1)* noalias nocapture writeonly, i8 addrspace(4)* noalias nocapture readonly, i64, i1 immarg) #1 -attributes #0 = { alwaysinline norecurse nounwind "amdgpu-unsafe-fp-atomics"="true" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #0 = { alwaysinline norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot7-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" } attributes #1 = { argmemonly nofree nosync nounwind willreturn } attributes #2 = { nounwind } @@ -216,12 +264,14 @@ attributes #2 = { nounwind } !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{i32 7, !"PIC Level", i32 2} !2 = !{i32 2, i32 0} -!3 = !{!"AOMP_STANDALONE_13.0-2 clang version 13.0.0 (https://github.com/ROCm-Developer-Tools/llvm-project 897d9549eb6dfdf42ee44e6371107b9ae2df7129)"} +!3 = !{!"AOMP_STANDALONE_12.0-0 clang version 13.0.0 (ssh://rlieberm@gerrit-git.amd.com:29418/lightning/ec/llvm-project 25f685d3c7ea9fccd2872f39d7603736a103575e)"} !4 = !{!5, !5, i64 0} !5 = !{!"int", !6, i64 0} !6 = !{!"omnipotent char", !7, i64 0} !7 = !{!"Simple C/C++ TBAA"} !8 = !{!9, !9, i64 0} -!9 = !{!"float", !6, i64 0} +!9 = !{!"long", !6, i64 0} !10 = !{!11, !11, i64 0} -!11 = !{!"double", !6, i64 0} +!11 = !{!"float", !6, i64 0} +!12 = !{!13, !13, i64 0} +!13 = !{!"double", !6, i64 0} From 9afbd7b336db818cf71aa5dd9e5163bd57601e83 Mon Sep 17 00:00:00 2001 From: gregrodgers Date: Tue, 18 May 2021 15:48:42 -0500 Subject: [PATCH 17/31] remove the build of libm from extras and move it to llvm-project/openmp/libomptarget/deviceRTLs/libm --- aomp-device-libs/CMakeLists.txt | 1 - aomp-device-libs/libm/CMakeLists.txt | 149 --------------------------- aomp-device-libs/libm/src/libm.c | 32 ------ 3 files changed, 182 deletions(-) delete mode 100644 aomp-device-libs/libm/CMakeLists.txt delete mode 100644 aomp-device-libs/libm/src/libm.c diff --git a/aomp-device-libs/CMakeLists.txt b/aomp-device-libs/CMakeLists.txt index 201d894..d271567 100644 --- a/aomp-device-libs/CMakeLists.txt +++ b/aomp-device-libs/CMakeLists.txt @@ -44,7 +44,6 @@ set(AMDGCN_DEP_LIST) add_subdirectory(irif) # cuda2gcn and extra hip are merged into aompextras add_subdirectory(aompextras) -add_subdirectory(libm) # I don't see why we need cudamath, so I am deleting for now. #add_subdirectory(cudamath) diff --git a/aomp-device-libs/libm/CMakeLists.txt b/aomp-device-libs/libm/CMakeLists.txt deleted file mode 100644 index dd79536..0000000 --- a/aomp-device-libs/libm/CMakeLists.txt +++ /dev/null @@ -1,149 +0,0 @@ -##===----------------------------------------------------------------------===## -# -# The LLVM Compiler Infrastructure -# -# This file is dual licensed under the MIT and the University of Illinois Open -# Source Licenses. See LICENSE.txt for details. -##===----------------------------------------------------------------------===## -# -# aomp-extras/libm/libdevice/CMakeLists.txt -# Written by Greg Rodgers (Gregory.Rodgers@amd.com) -# -##===----------------------------------------------------------------------===## - -cmake_minimum_required(VERSION 3.0 FATAL_ERROR) -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - project(libm-project) - message("--------------------------------------------") -endif() - -# find the llvm compiler -find_package(LLVM QUIET CONFIG - PATHS - ${CMAKE_INSTALL_PREFIX} - ${AOMP} - ${CMAKE_CXX_COMPILER_DIR} - NO_DEFAULT_PATH -) - -if (LLVM_DIR) - message(" -- Building libm libdevice with LLVM ${LLVM_PACKAGE_VERSION} found at ${LLVM_INSTALL_PREFIX}") -else() - message(" ERROR: NO LLVM FOUND! Not building libm libdevice.") - return() -endif() - -#optimization level -set(optimization_level 2) - -set(OUTPUTDIR ${CMAKE_CURRENT_BINARY_DIR}) - -macro(build_static_device_bc_lib) -foreach(mcpu ${gpulist}) - set(cpu_target x86_64-pc-linux-gnu) - if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "ppc64le") - set(cpu_target powerpc64le-linux-gnu) - endif() - - set(omp_common_args - -c - -emit-llvm - -target ${cpu_target} - -fopenmp - -fopenmp-targets=${triple} - -Xopenmp-target=${triple} - -march=${mcpu} - --cuda-device-only - -nogpuinc - -nocudalib - -O${optimization_level}) - - set(openmp_c_cmd ${LLVM_INSTALL_PREFIX}/bin/clang ${omp_common_args} - ${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c) - - # AMD only linking of ocml.bc to libm - if(${triple} STREQUAL "amdgcn-amd-amdhsa") - add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}-tmp.bc - COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}-tmp.bc - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" - ) - add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}.bc - COMMAND ${LLVM_INSTALL_PREFIX}/bin/llvm-link ${OUTPUTDIR}/libm-${systemarch}-${mcpu}-tmp.bc ${ocml_bc} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - COMMENT "Linking ocml.bc to libm-${mcpu}" - ) - - # Final bc is dependent on libm-tmp.bc - add_custom_target(libm-${systemarch}-${mcpu}-tmp ALL DEPENDS libm-${systemarch}-${mcpu}-tmp.bc) - add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc libm-${systemarch}-${mcpu}-tmp) - else() - add_custom_command( - OUTPUT libm-${systemarch}-${mcpu}.bc - COMMAND ${openmp_c_cmd} -o ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/libm.c" - ) - add_custom_target(libm-${systemarch}-${mcpu} ALL DEPENDS libm-${systemarch}-${mcpu}.bc) - endif() - - install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DESTINATION "lib/libdevice") - install(FILES ${OUTPUTDIR}/libm-${systemarch}-${mcpu}.bc - DESTINATION "lib-debug/libdevice") -endforeach() -endmacro() - -# Get list of AMD GPUs to build for -set(gfxgpus $ENV{GFXLIST}) -if(gfxgpus) - message(" -- Building for devices specified by GFXLIST: ${gfxgpus}") -else() - set(gfxgpus gfx700 gfx701 gfx801 gfx803 gfx900) - message(" -- Building default set of AMD GPUs: ${gfxgpus}") - message(" -- You may override default with GFXLIST environment variable ") -endif() -separate_arguments(gfxgpus) -# prepare variables used by build_static_device_bc_lib -set(triple "amdgcn-amd-amdhsa") -set(systemarch "amdgcn") -set(gpulist ${gfxgpus}) - -# Use config from device-libs to find install location -# Look for ocml.bc to link into libm -find_package(AMDDeviceLibs REQUIRED CONFIG) -message("---AMDDeviceLibs_DIR: ${AMDDeviceLibs_DIR}") -if(NOT DEFINED AMD_DEVICE_LIBS_TARGETS) - get_property(AMD_DEVICE_LIBS_TARGETS GLOBAL PROPERTY AMD_DEVICE_LIBS) -endif() -foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS}) - get_target_property(bc_lib_path ${AMDGCN_LIB_TARGET} LOCATION) - if(NOT bc_lib_path) - message(FATAL_ERROR "Could not find path to bitcode library") - endif() - if(${AMDGCN_LIB_TARGET} STREQUAL "ocml") - set(ocml_bc ${bc_lib_path}) - endif() -endforeach() - -build_static_device_bc_lib() - -set(nvptx_numbers $ENV{NVPTXGPUS}) -if(NOT nvptx_numbers) - set(nvptx_numbers "30,35,50,60,61,70") -endif() - -set(nvptxgpus) -string(REGEX REPLACE "," ";" nvptx_numbers_list ${nvptx_numbers}) -foreach(sm_number ${nvptx_numbers_list}) - list(APPEND nvptxgpus "sm_${sm_number}") -endforeach() - -# prepare variables used by build_static_device_bc_lib -set(gpulist ${nvptxgpus}) -set(systemarch "nvptx") -set(triple "nvptx64-nvidia-cuda ") -build_static_device_bc_lib() - -if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - message("--------------------------------------------") -endif() diff --git a/aomp-device-libs/libm/src/libm.c b/aomp-device-libs/libm/src/libm.c deleted file mode 100644 index e22a11a..0000000 --- a/aomp-device-libs/libm/src/libm.c +++ /dev/null @@ -1,32 +0,0 @@ -//===--------- libm/libm.c ------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// If the library needs to destinguish betwen different targets, -// target specific macros for that GPU can be used. -// For nvptx use __NVPTX__. For amdgcn, use __AMDGCN__. -// Example: -// #ifdef __AMDGCN__ && (__AMDGCN__ == 1000) -// double fast_sqrt(double __a) { ... } -// #endif - -#define __BUILD_MATH_BUILTINS_LIB__ - -#ifdef __AMDGCN__ -#pragma omp declare target -#define __OPENMP_AMDGCN__ -#include <__clang_hip_math.h> -#pragma omp end declare target -#endif - -#ifdef __NVPTX__ -#pragma omp declare target -#define __CUDA__ -#define __OPENMP_NVPTX__ -#include <__clang_cuda_math.h> -#pragma omp end declare target -#endif From d949120bf0dcf63591aeb19c1a2be915777c6782 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Wed, 16 Jun 2021 21:20:42 -0500 Subject: [PATCH 18/31] Change spelling fs::F_None to fs::OF_None --- utils/src/prepare-builtins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/prepare-builtins.cpp b/utils/src/prepare-builtins.cpp index b766dce..d69519f 100644 --- a/utils/src/prepare-builtins.cpp +++ b/utils/src/prepare-builtins.cpp @@ -112,7 +112,7 @@ int main(int argc, char **argv) { std::error_code EC; std::unique_ptr Out( - new ToolOutputFile(OutputFilename, EC, sys::fs::F_None)); + new ToolOutputFile(OutputFilename, EC, sys::fs::OF_None)); if (EC) { errs() << EC.message() << '\n'; exit(1); From d9be85c2450348edcadff03f8559d742fe5d9f65 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Fri, 16 Jul 2021 13:43:09 -0500 Subject: [PATCH 19/31] Add gfx1030 to gputable.txt and mygpu. --- utils/bin/gputable.txt | 1 + utils/bin/mymcpu | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/utils/bin/gputable.txt b/utils/bin/gputable.txt index e1be698..e918405 100644 --- a/utils/bin/gputable.txt +++ b/utils/bin/gputable.txt @@ -1866,6 +1866,7 @@ 1002:7300 174b e329 fiji : Radeon R9 FURY 1002:731f 0000 0000 gfx1010 : GFX 10 1002:738c 0000 0000 NRAXJ : NRAXJ +1002:73a1 0000 0000 gfx1030 : GFX 1030 1002:7834 0000 0000 rs350 : RS350 [Radeon 9100 PRO/XT IGP] 1002:7835 0000 0000 rs350m : RS350M [Mobility Radeon 9000 IGP] 1002:7919 0000 0000 rs690 : RS690 HDMI Audio [Radeon Xpress 1200 Series] diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index e1faf1a..0068714 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -145,6 +145,8 @@ function code2gpu(){ ;; "gfx1010") gpuname="gfx1010" ;; + "gfx1030") gpuname="gfx1030" + ;; "sm_30") gpuname="sm_30" ;; "k4000") gpuname="sm_30" @@ -207,6 +209,8 @@ function gpu2code(){ ;; "gfx1010") codename="gfx1010" ;; + "gfx1030") codename="gfx1030" + ;; # sm_ numbers do not map to specific gpus so just return the sm number *) codename="$1" ;; From c2bd38bf04fdea86ace33605e78405d125f90140 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Thu, 22 Jul 2021 10:44:04 -0500 Subject: [PATCH 20/31] Updates to gputable.txt and mygpu. -Added gfx1031 support -Corrected gpu2code for gfx1010, gfx1030 -Added additional descriptions in gputable.txt --- utils/bin/gputable.txt | 6 ++++-- utils/bin/mymcpu | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/bin/gputable.txt b/utils/bin/gputable.txt index e918405..e9e8173 100644 --- a/utils/bin/gputable.txt +++ b/utils/bin/gputable.txt @@ -1864,9 +1864,11 @@ 1002:7300 1043 049e fiji : Radeon R9 FURY 1002:7300 1043 04a0 fiji : Radeon R9 FURY X 1002:7300 174b e329 fiji : Radeon R9 FURY -1002:731f 0000 0000 gfx1010 : GFX 10 +1002:731f 0000 0000 navi10 : [Radeon 5700/5700XT] 1002:738c 0000 0000 NRAXJ : NRAXJ -1002:73a1 0000 0000 gfx1030 : GFX 1030 +1002:73a1 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73bf 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73df 0000 0000 navi22 : [Radeon 6700XT] 1002:7834 0000 0000 rs350 : RS350 [Radeon 9100 PRO/XT IGP] 1002:7835 0000 0000 rs350m : RS350M [Mobility Radeon 9000 IGP] 1002:7919 0000 0000 rs690 : RS690 HDMI Audio [Radeon Xpress 1200 Series] diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index 0068714..ec50638 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -143,9 +143,11 @@ function code2gpu(){ ;; "NRAXJ") gpuname="gfx908" ;; - "gfx1010") gpuname="gfx1010" + "navi10") gpuname="gfx1010" ;; - "gfx1030") gpuname="gfx1030" + "navi21") gpuname="gfx1030" + ;; + "navi22") gpuname="gfx1031" ;; "sm_30") gpuname="sm_30" ;; @@ -207,9 +209,11 @@ function gpu2code(){ ;; "gfx908") codename="NRAXJ" ;; - "gfx1010") codename="gfx1010" + "gfx1010") codename="navi10" + ;; + "gfx1030") codename="navi21" ;; - "gfx1030") codename="gfx1030" + "gfx1031") codename="navi22" ;; # sm_ numbers do not map to specific gpus so just return the sm number *) codename="$1" From 7c0fef8bb714f3e945f63691fc7fb99da7996009 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Thu, 22 Jul 2021 16:15:23 -0500 Subject: [PATCH 21/31] Cherry-pick changes for mygpu. d9be85c2450348edcadff03f8559d742fe5d9f65 c2bd38bf04fdea86ace33605e78405d125f90140 -Adds support for gfx1030/1031. -Some older commits are still waiting on a LLVM mainline update. Change-Id: I42daaee40ffeae64e730896170076de0a3fbaa59 --- utils/bin/gputable.txt | 5 ++++- utils/bin/mymcpu | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/utils/bin/gputable.txt b/utils/bin/gputable.txt index e1be698..e9e8173 100644 --- a/utils/bin/gputable.txt +++ b/utils/bin/gputable.txt @@ -1864,8 +1864,11 @@ 1002:7300 1043 049e fiji : Radeon R9 FURY 1002:7300 1043 04a0 fiji : Radeon R9 FURY X 1002:7300 174b e329 fiji : Radeon R9 FURY -1002:731f 0000 0000 gfx1010 : GFX 10 +1002:731f 0000 0000 navi10 : [Radeon 5700/5700XT] 1002:738c 0000 0000 NRAXJ : NRAXJ +1002:73a1 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73bf 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73df 0000 0000 navi22 : [Radeon 6700XT] 1002:7834 0000 0000 rs350 : RS350 [Radeon 9100 PRO/XT IGP] 1002:7835 0000 0000 rs350m : RS350M [Mobility Radeon 9000 IGP] 1002:7919 0000 0000 rs690 : RS690 HDMI Audio [Radeon Xpress 1200 Series] diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index e1faf1a..ec50638 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -143,7 +143,11 @@ function code2gpu(){ ;; "NRAXJ") gpuname="gfx908" ;; - "gfx1010") gpuname="gfx1010" + "navi10") gpuname="gfx1010" + ;; + "navi21") gpuname="gfx1030" + ;; + "navi22") gpuname="gfx1031" ;; "sm_30") gpuname="sm_30" ;; @@ -205,7 +209,11 @@ function gpu2code(){ ;; "gfx908") codename="NRAXJ" ;; - "gfx1010") codename="gfx1010" + "gfx1010") codename="navi10" + ;; + "gfx1030") codename="navi21" + ;; + "gfx1031") codename="navi22" ;; # sm_ numbers do not map to specific gpus so just return the sm number *) codename="$1" From 7a84cd139fbb449a3247ac4f911efc07b9c265d3 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Mon, 9 Aug 2021 16:36:03 -0500 Subject: [PATCH 22/31] Add additional cards to gpulist/mymcpu. Add gfx90a ID, update MI100 naming, and add additional gfx1030 ID. --- utils/bin/gputable.txt | 5 ++++- utils/bin/mymcpu | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/bin/gputable.txt b/utils/bin/gputable.txt index e9e8173..8def2b1 100644 --- a/utils/bin/gputable.txt +++ b/utils/bin/gputable.txt @@ -1865,10 +1865,13 @@ 1002:7300 1043 04a0 fiji : Radeon R9 FURY X 1002:7300 174b e329 fiji : Radeon R9 FURY 1002:731f 0000 0000 navi10 : [Radeon 5700/5700XT] -1002:738c 0000 0000 NRAXJ : NRAXJ +1002:738c 0000 0000 MI100 : MI100 1002:73a1 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73a3 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] 1002:73bf 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] 1002:73df 0000 0000 navi22 : [Radeon 6700XT] +1002:7408 0000 0000 NDPXY : NDPXY +1002:740f 0000 0000 NDPXY : NDPXY 1002:7834 0000 0000 rs350 : RS350 [Radeon 9100 PRO/XT IGP] 1002:7835 0000 0000 rs350m : RS350M [Mobility Radeon 9000 IGP] 1002:7919 0000 0000 rs690 : RS690 HDMI Audio [Radeon Xpress 1200 Series] diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index ec50638..e0ef4f6 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -141,7 +141,9 @@ function code2gpu(){ ;; "vega20") gpuname="gfx906" ;; - "NRAXJ") gpuname="gfx908" + "MI100") gpuname="gfx908" + ;; + "NDPXY") gpuname="gfx90a" ;; "navi10") gpuname="gfx1010" ;; @@ -207,7 +209,9 @@ function gpu2code(){ ;; "gfx906") codename="vega20" ;; - "gfx908") codename="NRAXJ" + "gfx908") codename="MI100" + ;; + "gfx90a") codename="NDPXY" ;; "gfx1010") codename="navi10" ;; From d1f411acd46252f8b405c4713cf687b5ca834d8b Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Mon, 9 Aug 2021 19:10:29 -0500 Subject: [PATCH 23/31] Cherry-pick more changes for mygpu. 7a84cd139fbb449a3247ac4f911efc07b9c265d3 Add more support for gfx1030. Add support for gfx90a. Update MI100 naming. Still waiting on llvm to merge older commits. Change-Id: I897e469a573ad841e4fc8466667f8e577e20da8c --- utils/bin/gputable.txt | 5 ++++- utils/bin/mymcpu | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/utils/bin/gputable.txt b/utils/bin/gputable.txt index e9e8173..8def2b1 100644 --- a/utils/bin/gputable.txt +++ b/utils/bin/gputable.txt @@ -1865,10 +1865,13 @@ 1002:7300 1043 04a0 fiji : Radeon R9 FURY X 1002:7300 174b e329 fiji : Radeon R9 FURY 1002:731f 0000 0000 navi10 : [Radeon 5700/5700XT] -1002:738c 0000 0000 NRAXJ : NRAXJ +1002:738c 0000 0000 MI100 : MI100 1002:73a1 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] +1002:73a3 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] 1002:73bf 0000 0000 navi21 : [Radeon 6800/6800XT/6900XT] 1002:73df 0000 0000 navi22 : [Radeon 6700XT] +1002:7408 0000 0000 NDPXY : NDPXY +1002:740f 0000 0000 NDPXY : NDPXY 1002:7834 0000 0000 rs350 : RS350 [Radeon 9100 PRO/XT IGP] 1002:7835 0000 0000 rs350m : RS350M [Mobility Radeon 9000 IGP] 1002:7919 0000 0000 rs690 : RS690 HDMI Audio [Radeon Xpress 1200 Series] diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index ec50638..e0ef4f6 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -141,7 +141,9 @@ function code2gpu(){ ;; "vega20") gpuname="gfx906" ;; - "NRAXJ") gpuname="gfx908" + "MI100") gpuname="gfx908" + ;; + "NDPXY") gpuname="gfx90a" ;; "navi10") gpuname="gfx1010" ;; @@ -207,7 +209,9 @@ function gpu2code(){ ;; "gfx906") codename="vega20" ;; - "gfx908") codename="NRAXJ" + "gfx908") codename="MI100" + ;; + "gfx90a") codename="NDPXY" ;; "gfx1010") codename="navi10" ;; From b458abe47c5d38a0dd32e0cde3e238e0625cf6de Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Tue, 22 Mar 2022 08:41:11 -0500 Subject: [PATCH 24/31] Add installation of gpurun and openmpi_cu_mask for ROCm. --- utils/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index d681975..d82dc5d 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -177,5 +177,7 @@ else() ${CMAKE_CURRENT_BINARY_DIR}/aompcc ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu + ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask + ${CMAKE_CURRENT_BINARY_DIR}/gpurun DESTINATION "bin") endif() From bd38e1ef8155b73038c4d9069efcd07af143a30b Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Mon, 28 Mar 2022 14:02:37 -0500 Subject: [PATCH 25/31] Fix faulty merge conflict resolution. Remove installation of gputable.txt from cmake as this no longer exists. mygpu uses offload-arch instead. --- utils/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index d82dc5d..4f9208a 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -175,7 +175,6 @@ else() install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mymcpu ${CMAKE_CURRENT_BINARY_DIR}/aompcc - ${CMAKE_CURRENT_BINARY_DIR}/gputable.txt ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask ${CMAKE_CURRENT_BINARY_DIR}/gpurun From 55baa1b7c802bc3dba38ed18883ce1b0b7ce20d8 Mon Sep 17 00:00:00 2001 From: estewart08 Date: Wed, 1 Jun 2022 13:43:14 -0500 Subject: [PATCH 26/31] ROCm 5.3 package reorg. (#44) (#45) Split openmp package to runtime and devel Change-Id: I9aa0d7d0627e07f76fe45f33e7cf89b04369610e Co-authored-by: Ethan Stewart Co-authored-by: raramakr <91213141+raramakr@users.noreply.github.com> --- CMakeLists.txt | 3 +++ utils/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc427d..82368fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,6 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(aomp-extras) +if(${ENABLE_DEVEL_PACKAGE}) + set(DEVEL_PACKAGE "devel/") +endif() add_subdirectory(utils) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4f9208a..d323513 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -178,5 +178,5 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask ${CMAKE_CURRENT_BINARY_DIR}/gpurun - DESTINATION "bin") + DESTINATION "${DEVEL_PACKAGE}bin") endif() From f3f027a95094ccf07ef7f18cf6d32374d7c10458 Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Thu, 16 Jun 2022 10:09:19 -0500 Subject: [PATCH 27/31] Cherry-pick copyright changes to mainline. d5f0840407414da6aa6fbcac36c7d912a8babe95 cf7b257965931f95962300ba37a6f26c617b44b4 Change-Id: Ice9bc5427ca486832896b22c3b4cb746cd772413 --- CMakeLists.txt | 1 + LICENSE | 1 + utils/CMakeLists.txt | 1 + utils/bin/aompExtractRegion | 3 +- utils/bin/aompcc | 3 +- utils/bin/aompversion | 2 +- utils/bin/blt.patch | 1 + utils/bin/bundle.sh | 1 + utils/bin/clang-ocl | 1 + utils/bin/clang-offload-bundler.sh | 1 + utils/bin/cloc.sh | 2 +- utils/bin/gpurun | 37 +++++++++++++++++++++++- utils/bin/kokkos_build.sh | 2 +- utils/bin/make_header_from_ll_defines.sh | 2 +- utils/bin/modulefile | 1 + utils/bin/mymcpu | 2 +- utils/bin/raja.patch | 1 + utils/bin/raja_build.sh | 2 +- utils/bin/unbundle.sh | 1 + 19 files changed, 55 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc427d..4c8a71c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(aomp-extras) add_subdirectory(utils) diff --git a/LICENSE b/LICENSE index 0ddde0f..53f7559 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,4 @@ +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. MIT License Copyright (c) 2019 ROCm Developer Tools diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4f9208a..9fa49a4 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,3 +1,4 @@ +# Copyright (C) 2019–2022 Advanced Micro Devices, Inc. All rights Reserved. ##===----------------------------------------------------------------------===## # # The LLVM Compiler Infrastructure diff --git a/utils/bin/aompExtractRegion b/utils/bin/aompExtractRegion index 5f19c78..69ba6a3 100755 --- a/utils/bin/aompExtractRegion +++ b/utils/bin/aompExtractRegion @@ -1,5 +1,6 @@ #!/bin/bash # This string is changed by cmake when building and installing aomp utils. +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. PROGVERSION="X.Y-Z" function version(){ @@ -20,7 +21,7 @@ function usage(){ -version Print the version of aompExtractRegion -n Dump the first few lines of image .note section - Copyright (c) 2019 ADVANCED MICRO DEVICES, INC. + Copyright(C) 2022 Advanced Micro Devices, Inc. All rights reserved. EOF exit 1 diff --git a/utils/bin/aompcc b/utils/bin/aompcc index a46b8d1..53af1a7 100755 --- a/utils/bin/aompcc +++ b/utils/bin/aompcc @@ -7,8 +7,7 @@ # Written by Greg Rodgers Gregory.Rodgers@amd.com PROGVERSION="X.Y-Z" # -# -# Copyright (c) 2020 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/aompversion b/utils/bin/aompversion index 8a399be..7eb53cd 100755 --- a/utils/bin/aompversion +++ b/utils/bin/aompversion @@ -7,7 +7,7 @@ # This string is changed by cmake when building and installing aomp utils. PROGVERSION="X.Y-Z" # -# Copyright (c) 2018 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2018 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/blt.patch b/utils/bin/blt.patch index 64bf9be..aeb6169 100644 --- a/utils/bin/blt.patch +++ b/utils/bin/blt.patch @@ -1,3 +1,4 @@ +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. diff --git a/cmake/SetupCompilerOptions.cmake b/cmake/SetupCompilerOptions.cmake index a9e0743..d5f9da8 100644 --- a/cmake/SetupCompilerOptions.cmake diff --git a/utils/bin/bundle.sh b/utils/bin/bundle.sh index 95513f4..50d834b 100755 --- a/utils/bin/bundle.sh +++ b/utils/bin/bundle.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. # # bundle.sh: Use the clang bundle tool to combine files for # different targets that were created by coral 3.8 compiler. diff --git a/utils/bin/clang-ocl b/utils/bin/clang-ocl index b7b0c38..550463e 100755 --- a/utils/bin/clang-ocl +++ b/utils/bin/clang-ocl @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. # # clang-ocl: Driver for OpenCL to call clang # This does not use the roc-cl driver. diff --git a/utils/bin/clang-offload-bundler.sh b/utils/bin/clang-offload-bundler.sh index ee46268..06f523f 100755 --- a/utils/bin/clang-offload-bundler.sh +++ b/utils/bin/clang-offload-bundler.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. # # $AOMP/bin/clang-offload-bundler.sh # diff --git a/utils/bin/cloc.sh b/utils/bin/cloc.sh index 2495abe..c52bf2a 100755 --- a/utils/bin/cloc.sh +++ b/utils/bin/cloc.sh @@ -10,7 +10,7 @@ # PROGVERSION="X.Y-Z" # -# Copyright (c) 2018 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2018 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/gpurun b/utils/bin/gpurun index 84b5b8f..3b165c9 100755 --- a/utils/bin/gpurun +++ b/utils/bin/gpurun @@ -61,7 +61,42 @@ # mpirun -np 60 -hostfile $_host_file gpurun $_appbin $_appargs # mpirun -np 55 -hostfile $_host_file gpurun $_appbin $_appargs # -# Copyright (c) 2022 ADVANCED MICRO DEVICES, INC. +# TODO: +# - Use existing setting of ROCR_VISIBLE_DEVICES to avoid those GPUs. +# This utility currently ignores any previous setting to +# ROCR_VISIBLE_DEVICES and overrides it with a single selected GPU. +# - Warn if HSA_CU_MASK is preset and use that instead of calculated MASK. +# Note that rocminfo does not recognize ROCR_VISIBLE_DEVICES or HSA_CU_MASK. +# - Add support for cuda. +# - Add support for other mpi launchers besides openmpi's mpirun. +# - If gpurun becomes popular, convert this script to a program +# +# Copyright(C) 2021 Advanced Micro Devices, Inc. All rights reserved. +# +# AMD is granting you permission to use this software and documentation (if any) (collectively, the +# Materials) pursuant to the terms and conditions of the Software License Agreement included with the +# Materials. If you do not have a copy of the Software License Agreement, contact your AMD +# representative for a copy. +# +# WARRANTY DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +# KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT +# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE, TITLE, NON-INFRINGEMENT, THAT THE SOFTWARE WILL RUN UNINTERRUPTED OR ERROR- +# FREE OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK +# ASSOCIATED WITH THE USE OF THE SOFTWARE IS ASSUMED BY YOU. Some jurisdictions do not +# allow the exclusion of implied warranties, so the above exclusion may not apply to You. +# +# LIMITATION OF LIABILITY AND INDEMNIFICATION: AMD AND ITS LICENSORS WILL NOT, +# UNDER ANY CIRCUMSTANCES BE LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, +# INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE SOFTWARE OR THIS +# AGREEMENT EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGES. In no event shall AMD's total liability to You for all damages, losses, and +# causes of action (whether in contract, tort (including negligence) or otherwise) +# exceed the amount of $100 USD. You agree to defend, indemnify and hold harmless +# AMD and its licensors, and any of their directors, officers, employees, affiliates or +# agents from and against any and all loss, damage, liability and other expenses +# (including reasonable attorneys' fees), resulting from Your use of the Software or +# violation of the terms and conditions of this Agreement. # PROGVERSION=X.Y-Z function version(){ diff --git a/utils/bin/kokkos_build.sh b/utils/bin/kokkos_build.sh index e3d1217..ede9606 100755 --- a/utils/bin/kokkos_build.sh +++ b/utils/bin/kokkos_build.sh @@ -8,7 +8,7 @@ # PROGVERSION="X.Y-Z" # -# Copyright (c) 2020 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/make_header_from_ll_defines.sh b/utils/bin/make_header_from_ll_defines.sh index 596ddc0..f925c98 100755 --- a/utils/bin/make_header_from_ll_defines.sh +++ b/utils/bin/make_header_from_ll_defines.sh @@ -1,5 +1,5 @@ #!/bin/bash - +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. # make_header_from_ll_defines.sh: # To use low level hc functions maintained in .ll, we need c/cpp headers so # we can use them properly in hip device library implementations. diff --git a/utils/bin/modulefile b/utils/bin/modulefile index a1c1630..c3872ac 100644 --- a/utils/bin/modulefile +++ b/utils/bin/modulefile @@ -1,4 +1,5 @@ #%Module1.0 +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. ## ## aomp@X.Y-Z ## diff --git a/utils/bin/mymcpu b/utils/bin/mymcpu index 85f7246..36a0f19 100755 --- a/utils/bin/mymcpu +++ b/utils/bin/mymcpu @@ -9,7 +9,7 @@ PROGVERSION=X.Y-Z -# Copyright (c) 2018 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2018 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/raja.patch b/utils/bin/raja.patch index 9286601..d57541d 100644 --- a/utils/bin/raja.patch +++ b/utils/bin/raja.patch @@ -1,3 +1,4 @@ +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. diff --git a/include/RAJA/policy/atomic_auto.hpp b/include/RAJA/policy/atomic_auto.hpp index 934bfc68..02789511 100644 --- a/include/RAJA/policy/atomic_auto.hpp diff --git a/utils/bin/raja_build.sh b/utils/bin/raja_build.sh index 6c6f8fe..e3696c8 100755 --- a/utils/bin/raja_build.sh +++ b/utils/bin/raja_build.sh @@ -8,7 +8,7 @@ # PROGVERSION="X.Y-Z" # -# Copyright (c) 2019 ADVANCED MICRO DEVICES, INC. +# Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the # Materials) pursuant to the terms and conditions of the Software License Agreement included with the diff --git a/utils/bin/unbundle.sh b/utils/bin/unbundle.sh index 16e5977..42a275d 100755 --- a/utils/bin/unbundle.sh +++ b/utils/bin/unbundle.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. # # unbundle.sh: use clang clang-offload-bundler tool to unbundle files # This script is the companion to bundle.sh. It will name the From 98210a4c94bb9064a717f9994bbab64c63484987 Mon Sep 17 00:00:00 2001 From: estewart08 Date: Wed, 1 Jun 2022 13:43:14 -0500 Subject: [PATCH 28/31] ROCm 5.3 package reorg. (#44) (#45) Split openmp package to runtime and devel Change-Id: I9aa0d7d0627e07f76fe45f33e7cf89b04369610e Co-authored-by: Ethan Stewart Co-authored-by: raramakr <91213141+raramakr@users.noreply.github.com> --- CMakeLists.txt | 3 +++ utils/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c8a71c..a712e39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ # Copyright(C) 2019 Advanced Micro Devices, Inc. All rights reserved. cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(aomp-extras) +if(${ENABLE_DEVEL_PACKAGE}) + set(DEVEL_PACKAGE "devel/") +endif() add_subdirectory(utils) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 9fa49a4..4028a1e 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -179,5 +179,5 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/bin/mygpu ${CMAKE_CURRENT_SOURCE_DIR}/bin/openmpi_set_cu_mask ${CMAKE_CURRENT_BINARY_DIR}/gpurun - DESTINATION "bin") + DESTINATION "${DEVEL_PACKAGE}bin") endif() From 6c625da3808c1fdd3fbcb16e62fe8a7b70ef7f93 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Mon, 17 Oct 2022 17:55:59 -0500 Subject: [PATCH 29/31] Move copyright and MIT to near top of file, cause palameda wants it --- utils/bin/gpurun | 56 +++++++++++++++++++-------------------- utils/bin/kokkos_build.sh | 18 ++++++------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/utils/bin/gpurun b/utils/bin/gpurun index 7296fcd..dd3a303 100755 --- a/utils/bin/gpurun +++ b/utils/bin/gpurun @@ -1,32 +1,4 @@ #!/bin/bash -# -# gpurun: Process launch utility for GPU applications. This is a wrapper -# to execute a GPU application including OpenMPI GPU applications. -# See help message below (gpurun -h) for more information. -# -# Usage Examples: -# _appbin=true -# _appargs="" -# gpurun $_appbin $_appargs -# mpirun -np 4 gpurun $_appbin $_appargs -# mpirun -np 8 gpurun $_appbin $_appargs -# mpirun -np 9 gpurun $_appbin $_appargs -# mpirun -np 23 gpurun $_appbin $_appargs -# # For large numbers of ranks, increase slots with a hosfile. -# _host_file="/tmp/host_file$$" -# echo "`hostname` slots=64" >$_host_file -# mpirun -np 64 -hostfile $_host_file gpurun $_appbin $_appargs -# mpirun -np 60 -hostfile $_host_file gpurun $_appbin $_appargs -# mpirun -np 55 -hostfile $_host_file gpurun $_appbin $_appargs -# -# TODO: -# - Limit HSA queues with GPU_MAX_HW_QUEUES when multiple ranks per GPU -# - Warn if HSA_CU_MASK is preset and use that instead of calculated MASK. -# Note that rocminfo does not recognize ROCR_VISIBLE_DEVICES or HSA_CU_MASK. -# - Add support for cuda. -# - Add support for other mpi launchers besides openmpi's mpirun. -# - If gpurun becomes popular, convert this script to a program -# # Copyright(C) 2021 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the @@ -61,6 +33,34 @@ # # EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the # Software License Agreement. +# +# gpurun: Process launch utility for GPU applications. This is a wrapper +# to execute a GPU application including OpenMPI GPU applications. +# See help message below (gpurun -h) for more information. +# +# Usage Examples: +# _appbin=true +# _appargs="" +# gpurun $_appbin $_appargs +# mpirun -np 4 gpurun $_appbin $_appargs +# mpirun -np 8 gpurun $_appbin $_appargs +# mpirun -np 9 gpurun $_appbin $_appargs +# mpirun -np 23 gpurun $_appbin $_appargs +# # For large numbers of ranks, increase slots with a hosfile. +# _host_file="/tmp/host_file$$" +# echo "`hostname` slots=64" >$_host_file +# mpirun -np 64 -hostfile $_host_file gpurun $_appbin $_appargs +# mpirun -np 60 -hostfile $_host_file gpurun $_appbin $_appargs +# mpirun -np 55 -hostfile $_host_file gpurun $_appbin $_appargs +# +# TODO: +# - Limit HSA queues with GPU_MAX_HW_QUEUES when multiple ranks per GPU +# - Warn if HSA_CU_MASK is preset and use that instead of calculated MASK. +# Note that rocminfo does not recognize ROCR_VISIBLE_DEVICES or HSA_CU_MASK. +# - Add support for cuda. +# - Add support for other mpi launchers besides openmpi's mpirun. +# - If gpurun becomes popular, convert this script to a program +# PROGVERSION=X.Y-Z function version(){ diff --git a/utils/bin/kokkos_build.sh b/utils/bin/kokkos_build.sh index ede9606..060d6dc 100755 --- a/utils/bin/kokkos_build.sh +++ b/utils/bin/kokkos_build.sh @@ -1,13 +1,4 @@ #!/bin/bash -# -# kokkos_build.sh: Script to clone and build kokkos for a specific GPU -# This will build kokkos in directory $HOME/kokkos_build. -# -# -# Written by Greg Rodgers Gregory.Rodgers@amd.com -# -PROGVERSION="X.Y-Z" -# # Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. # # AMD is granting you permission to use this software and documentation (if any) (collectively, the @@ -46,6 +37,15 @@ PROGVERSION="X.Y-Z" # EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the # Software License Agreement. # +# +# kokkos_build.sh: Script to clone and build kokkos for a specific GPU +# This will build kokkos in directory $HOME/kokkos_build. +# +# +# Written by Greg Rodgers Gregory.Rodgers@amd.com +# +PROGVERSION="X.Y-Z" +# AOMP=${AOMP:-_AOMP_INSTALL_DIR_} if [ ! -d $AOMP ] ; then From 11a3fdd600be7443eebf80a445a70f127297cd87 Mon Sep 17 00:00:00 2001 From: Ron Lieberman Date: Wed, 19 Oct 2022 16:49:42 -0500 Subject: [PATCH 30/31] Revise license per suggestion from Jeff O --- utils/bin/gpurun | 49 ++++++++++++++------------------------- utils/bin/kokkos_build.sh | 49 ++++++++++++--------------------------- 2 files changed, 32 insertions(+), 66 deletions(-) diff --git a/utils/bin/gpurun b/utils/bin/gpurun index dd3a303..d928be3 100755 --- a/utils/bin/gpurun +++ b/utils/bin/gpurun @@ -1,38 +1,23 @@ #!/bin/bash # Copyright(C) 2021 Advanced Micro Devices, Inc. All rights reserved. # -# AMD is granting you permission to use this software and documentation (if any) (collectively, the -# Materials) pursuant to the terms and conditions of the Software License Agreement included with the -# Materials. If you do not have a copy of the Software License Agreement, contact your AMD -# representative for a copy. -# -# WARRANTY DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -# KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT -# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, TITLE, NON-INFRINGEMENT, THAT THE SOFTWARE WILL RUN UNINTERRUPTED OR ERROR- -# FREE OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK -# ASSOCIATED WITH THE USE OF THE SOFTWARE IS ASSUMED BY YOU. Some jurisdictions do not -# allow the exclusion of implied warranties, so the above exclusion may not apply to You. -# -# LIMITATION OF LIABILITY AND INDEMNIFICATION: AMD AND ITS LICENSORS WILL NOT, -# UNDER ANY CIRCUMSTANCES BE LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, -# INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE SOFTWARE OR THIS -# AGREEMENT EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGES. In no event shall AMD's total liability to You for all damages, losses, and -# causes of action (whether in contract, tort (including negligence) or otherwise) -# exceed the amount of $100 USD. You agree to defend, indemnify and hold harmless -# AMD and its licensors, and any of their directors, officers, employees, affiliates or -# agents from and against any and all loss, damage, liability and other expenses -# (including reasonable attorneys' fees), resulting from Your use of the Software or -# violation of the terms and conditions of this Agreement. -# -# U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED RIGHTS." -# Use, duplication, or disclosure by the Government is subject to the restrictions as set -# forth in FAR 52.227-14 and DFAR252.227-7013, et seq., or its successor. Use of the -# Materials by the Government constitutes acknowledgement of AMD's proprietary rights in them. -# -# EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the -# Software License Agreement. +# 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. # # gpurun: Process launch utility for GPU applications. This is a wrapper # to execute a GPU application including OpenMPI GPU applications. diff --git a/utils/bin/kokkos_build.sh b/utils/bin/kokkos_build.sh index 060d6dc..2be87f7 100755 --- a/utils/bin/kokkos_build.sh +++ b/utils/bin/kokkos_build.sh @@ -1,42 +1,23 @@ #!/bin/bash # Copyright(C) 2020 Advanced Micro Devices, Inc. All rights reserved. # -# AMD is granting you permission to use this software and documentation (if any) (collectively, the -# Materials) pursuant to the terms and conditions of the Software License Agreement included with the -# Materials. If you do not have a copy of the Software License Agreement, contact your AMD -# representative for a copy. +# 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: # -# You agree that you will not reverse engineer or decompile the Materials, in whole or in part, except for -# example code which is provided in source code form and as allowed by applicable law. -# -# WARRANTY DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY -# KIND. AMD DISCLAIMS ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT -# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE, TITLE, NON-INFRINGEMENT, THAT THE SOFTWARE WILL RUN UNINTERRUPTED OR ERROR- -# FREE OR WARRANTIES ARISING FROM CUSTOM OF TRADE OR COURSE OF USAGE. THE ENTIRE RISK -# ASSOCIATED WITH THE USE OF THE SOFTWARE IS ASSUMED BY YOU. Some jurisdictions do not -# allow the exclusion of implied warranties, so the above exclusion may not apply to You. -# -# LIMITATION OF LIABILITY AND INDEMNIFICATION: AMD AND ITS LICENSORS WILL NOT, -# UNDER ANY CIRCUMSTANCES BE LIABLE TO YOU FOR ANY PUNITIVE, DIRECT, INCIDENTAL, -# INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM USE OF THE SOFTWARE OR THIS -# AGREEMENT EVEN IF AMD AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH -# DAMAGES. In no event shall AMD's total liability to You for all damages, losses, and -# causes of action (whether in contract, tort (including negligence) or otherwise) -# exceed the amount of $100 USD. You agree to defend, indemnify and hold harmless -# AMD and its licensors, and any of their directors, officers, employees, affiliates or -# agents from and against any and all loss, damage, liability and other expenses -# (including reasonable attorneys' fees), resulting from Your use of the Software or -# violation of the terms and conditions of this Agreement. -# -# U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with "RESTRICTED RIGHTS." -# Use, duplication, or disclosure by the Government is subject to the restrictions as set -# forth in FAR 52.227-14 and DFAR252.227-7013, et seq., or its successor. Use of the -# Materials by the Government constitutes acknowledgement of AMD's proprietary rights in them. -# -# EXPORT RESTRICTIONS: The Materials may be subject to export restrictions as stated in the -# Software License Agreement. +# 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. # # kokkos_build.sh: Script to clone and build kokkos for a specific GPU # This will build kokkos in directory $HOME/kokkos_build. From f08356a0a7b38f5eb188567fd4314fcb5f1aa5ce Mon Sep 17 00:00:00 2001 From: Ethan Stewart Date: Mon, 6 Mar 2023 11:15:14 -0600 Subject: [PATCH 31/31] [gpurun] - Add init for NUMANODE if null. Works around issue on 16 gpu system. Change-Id: I836b1686600f987fa42e20ff601b788633149a19 --- utils/bin/gpurun | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/bin/gpurun b/utils/bin/gpurun index d928be3..bb5f29b 100755 --- a/utils/bin/gpurun +++ b/utils/bin/gpurun @@ -331,6 +331,7 @@ fi NUMANODE=`cat /sys/bus/pci/devices/0000:$_bdfidstrc.0/numa_node` # Sometimes lscpu shows 0 for the node, when /sys/bus/pci/.. shows -1 [[ $NUMANODE == -1 ]] && NUMANODE=0 +[[ "$NUMANODE" == "" ]] && NUMANODE=0 _taskset_cmd="taskset -c " lscpu --extended=cpu,node >$_tfile while read _linepair ; do